added cotton and canola

This commit is contained in:
Jottyfan 2024-06-09 23:14:12 +02:00
parent 5a427a34b9
commit 5f068b5cdb
68 changed files with 544 additions and 8 deletions

View File

@ -12,7 +12,11 @@
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-21/"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="output" path="bin/default"/>
</classpath>

View File

@ -1,8 +1,11 @@
package de.jottyfan.quickiemod;
import de.jottyfan.quickiemod.blocks.QuickieBlocks;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.minecraft.client.render.RenderLayer;
/**
*
@ -13,5 +16,7 @@ import net.fabricmc.api.Environment;
public class QuickieModClient implements ClientModInitializer {
@Override
public void onInitializeClient() {
BlockRenderLayerMap.INSTANCE.putBlock(QuickieBlocks.COTTONPLANT.getBlock(), RenderLayer.getCutout());
BlockRenderLayerMap.INSTANCE.putBlock(QuickieBlocks.CANOLAPLANT.getBlock(), RenderLayer.getCutout());
}
}

View File

@ -0,0 +1,66 @@
package de.jottyfan.quickiemod.blocks;
import java.util.List;
import java.util.Random;
import de.jottyfan.quickiemod.items.QuickieItems;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.CropBlock;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemConvertible;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContextParameterSet.Builder;
import net.minecraft.util.ActionResult;
import net.minecraft.util.ItemScatterer;
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class BlockCanolaplant extends CropBlock {
public BlockCanolaplant() {
super(AbstractBlock.Settings.copy(Blocks.WHEAT));
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, Builder builder) {
DefaultedList<ItemStack> list = DefaultedList.of();
list.add(new ItemStack(getSeedsItem())); // the one from the seed
if (isMature(state)) {
list.add(new ItemStack(getSeedsItem(), new Random().nextInt(2)));
list.add(new ItemStack(QuickieItems.CANOLA.getItem(), new Random().nextFloat() > 0.9f ? 2 : 1));
}
return list;
}
private void spawnHarvested(World world, BlockPos pos, BlockState state) {
DefaultedList<ItemStack> list = DefaultedList.of();
getDroppedStacks(state, null).forEach(itemStack -> {
list.add(itemStack);
});
ItemScatterer.spawn(world, pos, list);
}
@Override
public BlockState onBreak(World world, BlockPos pos, BlockState state, PlayerEntity player) {
spawnHarvested(world, pos, state);
return super.onBreak(world, pos, state, player);
}
@Override
protected ItemConvertible getSeedsItem() {
return QuickieItems.CANOLASEED.getItem();
}
@Override
protected ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, BlockHitResult hit) {
if (!world.isClient && isMature(state)) {
spawnHarvested(world, pos, state);
world.setBlockState(pos, state.with(AGE, 0));
}
return ActionResult.PASS;
}
}

View File

@ -0,0 +1,66 @@
package de.jottyfan.quickiemod.blocks;
import java.util.List;
import java.util.Random;
import de.jottyfan.quickiemod.items.QuickieItems;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.CropBlock;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemConvertible;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContextParameterSet.Builder;
import net.minecraft.util.ActionResult;
import net.minecraft.util.ItemScatterer;
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class BlockCottonplant extends CropBlock {
public BlockCottonplant() {
super(AbstractBlock.Settings.copy(Blocks.WHEAT));
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, Builder builder) {
DefaultedList<ItemStack> list = DefaultedList.of();
list.add(new ItemStack(getSeedsItem())); // the one from the seed
if (isMature(state)) {
list.add(new ItemStack(getSeedsItem(), new Random().nextInt(2)));
list.add(new ItemStack(QuickieItems.COTTON.getItem(), new Random().nextFloat() > 0.9f ? 2 : 1));
}
return list;
}
private void spawnHarvested(World world, BlockPos pos, BlockState state) {
DefaultedList<ItemStack> list = DefaultedList.of();
getDroppedStacks(state, null).forEach(itemStack -> {
list.add(itemStack);
});
ItemScatterer.spawn(world, pos, list);
}
@Override
public BlockState onBreak(World world, BlockPos pos, BlockState state, PlayerEntity player) {
spawnHarvested(world, pos, state);
return super.onBreak(world, pos, state, player);
}
@Override
protected ItemConvertible getSeedsItem() {
return QuickieItems.COTTONSEED.getItem();
}
@Override
protected ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, BlockHitResult hit) {
if (!world.isClient && isMature(state)) {
spawnHarvested(world, pos, state);
world.setBlockState(pos, state.with(AGE, 0));
}
return ActionResult.PASS;
}
}

View File

@ -10,13 +10,15 @@ import net.minecraft.block.Block;
public enum QuickieBlocks {
// @formatter:off
KELPSTACK(new BlockKelpstack(), "kelpstack"),
DIRT_SALPETER(new BlockDirtSalpeter(), "dirtsalpeter"),
COTTONPLANT(new BlockCottonplant(), "cottonplant", false),
CANOLAPLANT(new BlockCanolaplant(), "canolaplant", false),
DIRTSALPETER(new BlockDirtSalpeter(), "dirtsalpeter"),
ORE_NETHER_SULPHOR(new BlockOreNetherSulphor(), "orenethersulphor"),
ORE_SALPETER(new BlockOreSalpeter(), "oresalpeter"),
ORE_SAND_SALPETER(new BlockSandSalpeter(), "oresandsalpeter"),
ORE_SULPHOR(new BlockOreSulphor(), "oresulphor"),
ORE_DEEPSLATESULPHOR(new BlockOreDeepslateSulphor(), "oredeepslatesulphor"),
SAND_SALPETER(new BlockSandSalpeter(), "sandsalpeter"),
SANDSALPETER(new BlockSandSalpeter(), "sandsalpeter"),
BLOCKSULPHOR(new BlockSulphor(), "blocksulphor"),
BLOCKSALPETER(new BlockSalpeter(), "blocksalpeter"),
BLOCKSPEEDPOWDER(new BlockSpeedpowder(), "blockspeedpowder"),
@ -25,10 +27,16 @@ public enum QuickieBlocks {
private final Block block;
private final String name;
private final Boolean add2BlockPanel;
private QuickieBlocks(Block block, String name) {
this(block, name, true);
}
private QuickieBlocks(Block block, String name, Boolean add2BlockPanel) {
this.block = block;
this.name = name;
this.add2BlockPanel = add2BlockPanel;
}
public final Block getBlock() {
@ -38,4 +46,8 @@ public enum QuickieBlocks {
public final String getName() {
return name;
}
public final Boolean getAdd2BlockPanel() {
return add2BlockPanel;
}
}

View File

@ -11,6 +11,7 @@ import net.fabricmc.fabric.api.biome.v1.BiomeSelectors;
import net.fabricmc.fabric.api.biome.v1.ModificationPhase;
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup;
import net.fabricmc.fabric.api.registry.FuelRegistry;
import net.minecraft.block.ComposterBlock;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item.Settings;
import net.minecraft.item.ItemStack;
@ -37,8 +38,10 @@ public class RegistryManager {
stacks.add(new ItemStack(i.getItem()));
}
for (QuickieBlocks b : QuickieBlocks.values()) {
if (b.getAdd2BlockPanel()) {
stacks.add(new ItemStack(b.getBlock()));
}
}
}).build());
}
@ -47,6 +50,10 @@ public class RegistryManager {
for (QuickieItems i : QuickieItems.values()) {
Registry.register(Registries.ITEM, new Identifier(QuickieMod.MODID, i.getName()), i.getItem());
}
ComposterBlock.ITEM_TO_LEVEL_INCREASE_CHANCE.put(QuickieItems.COTTONSEED.getItem(), 0.5f);
ComposterBlock.ITEM_TO_LEVEL_INCREASE_CHANCE.put(QuickieItems.COTTON.getItem(), 0.75f);
ComposterBlock.ITEM_TO_LEVEL_INCREASE_CHANCE.put(QuickieItems.CANOLASEED.getItem(), 0.5f);
ComposterBlock.ITEM_TO_LEVEL_INCREASE_CHANCE.put(QuickieItems.CANOLA.getItem(), 0.75f);
FuelRegistry.INSTANCE.add(QuickieItems.SULPHOR.getItem(), 200);
FuelRegistry.INSTANCE.add(QuickieBlocks.BLOCKSULPHOR.getBlock(), 2000);
}
@ -61,11 +68,11 @@ public class RegistryManager {
public static final void registerFeatures() {
// Overworld features
BiomeModifications.create(new Identifier(QuickieMod.MODID, "features")).add(ModificationPhase.ADDITIONS,
BiomeSelectors.foundInOverworld(), FeaturesManager.overworldOres());
BiomeModifications.create(new Identifier(QuickieMod.MODID, "features")).add(ModificationPhase.ADDITIONS, BiomeSelectors.foundInOverworld(),
FeaturesManager.overworldOres());
// Nether features
BiomeModifications.create(new Identifier(QuickieMod.MODID, "nether_features")).add(ModificationPhase.ADDITIONS,
BiomeSelectors.foundInTheNether(), FeaturesManager.netherOres());
BiomeModifications.create(new Identifier(QuickieMod.MODID, "nether_features")).add(ModificationPhase.ADDITIONS, BiomeSelectors.foundInTheNether(),
FeaturesManager.netherOres());
}
}

View File

@ -0,0 +1,15 @@
package de.jottyfan.quickiemod.items;
import net.minecraft.item.Item;
/**
*
* @author jotty
*
*/
public class ItemCanola extends Item {
public ItemCanola() {
super(new Item.Settings().maxCount(64));
}
}

View File

@ -0,0 +1,15 @@
package de.jottyfan.quickiemod.items;
import net.minecraft.item.Item;
/**
*
* @author jotty
*
*/
public class ItemCanolabottle extends Item {
public ItemCanolabottle() {
super(new Item.Settings().maxCount(64));
}
}

View File

@ -0,0 +1,15 @@
package de.jottyfan.quickiemod.items;
import net.minecraft.item.Item;
/**
*
* @author jotty
*
*/
public class ItemCanolabottlestack extends Item {
public ItemCanolabottlestack() {
super(new Item.Settings().maxCount(64));
}
}

View File

@ -0,0 +1,36 @@
package de.jottyfan.quickiemod.items;
import de.jottyfan.quickiemod.blocks.QuickieBlocks;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemUsageContext;
import net.minecraft.util.ActionResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
/**
*
* @author jotty
*
*/
public class ItemCanolaseed extends Item {
public ItemCanolaseed() {
super(new Item.Settings().maxCount(64));
}
@Override
public ActionResult useOnBlock(ItemUsageContext context) {
BlockPos pos = context.getBlockPos();
World world = context.getWorld();
if (QuickieItems.CANOLASEED.getItem().equals(context.getStack().getItem())) {
BlockState state = world.getBlockState(pos);
if (Blocks.FARMLAND.equals(state.getBlock()) && world.getBlockState(pos.up()).isAir()) {
world.setBlockState(pos.up(), QuickieBlocks.CANOLAPLANT.getBlock().getDefaultState());
context.getStack().decrement(1);
}
}
return super.useOnBlock(context);
}
}

View File

@ -0,0 +1,15 @@
package de.jottyfan.quickiemod.items;
import net.minecraft.item.Item;
/**
*
* @author jotty
*
*/
public class ItemCotton extends Item {
public ItemCotton() {
super(new Item.Settings().maxCount(64));
}
}

View File

@ -0,0 +1,36 @@
package de.jottyfan.quickiemod.items;
import de.jottyfan.quickiemod.blocks.QuickieBlocks;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemUsageContext;
import net.minecraft.util.ActionResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
/**
*
* @author jotty
*
*/
public class ItemCottonseed extends Item {
public ItemCottonseed() {
super(new Item.Settings().maxCount(64));
}
@Override
public ActionResult useOnBlock(ItemUsageContext context) {
BlockPos pos = context.getBlockPos();
World world = context.getWorld();
if (QuickieItems.COTTONSEED.getItem().equals(context.getStack().getItem())) {
BlockState state = world.getBlockState(pos);
if (Blocks.FARMLAND.equals(state.getBlock()) && world.getBlockState(pos.up()).isAir()) {
world.setBlockState(pos.up(), QuickieBlocks.COTTONPLANT.getBlock().getDefaultState());
context.getStack().decrement(1);
}
}
return super.useOnBlock(context);
}
}

View File

@ -11,6 +11,12 @@ public enum QuickieItems {
// @formatter:off
ROTTEN_FLESH_STRIPES(new ItemRottenFleshStripes(), "rotten_flesh_stripes"),
CARROTSTACK(new ItemCarrotstack(), "carrotstack"),
COTTON(new ItemCotton(), "cotton"),
COTTONSEED(new ItemCottonseed(), "cottonseed"),
CANOLA(new ItemCanola(), "canola"),
CANOLASEED(new ItemCanolaseed(), "canolaseed"),
CANOLABOTTLE(new ItemCanolabottle(), "canolabottle"),
CANOLABOTTLESTACK(new ItemCanolabottlestack(), "canolabottlestack"),
STUB(new ItemStub(), "stub"),
SALPETER(new ItemSalpeter(), "salpeter"),
SULPHOR(new ItemSulphor(), "sulphor"),

View File

@ -0,0 +1,12 @@
{
"variants": {
"age=0": { "model": "quickiemod:block/canolaplant0" },
"age=1": { "model": "quickiemod:block/canolaplant1" },
"age=2": { "model": "quickiemod:block/canolaplant2" },
"age=3": { "model": "quickiemod:block/canolaplant3" },
"age=4": { "model": "quickiemod:block/canolaplant4" },
"age=5": { "model": "quickiemod:block/canolaplant5" },
"age=6": { "model": "quickiemod:block/canolaplant6" },
"age=7": { "model": "quickiemod:block/canolaplant7" }
}
}

View File

@ -0,0 +1,12 @@
{
"variants": {
"age=0": { "model": "quickiemod:block/cottonplant0" },
"age=1": { "model": "quickiemod:block/cottonplant1" },
"age=2": { "model": "quickiemod:block/cottonplant2" },
"age=3": { "model": "quickiemod:block/cottonplant3" },
"age=4": { "model": "quickiemod:block/cottonplant4" },
"age=5": { "model": "quickiemod:block/cottonplant5" },
"age=6": { "model": "quickiemod:block/cottonplant6" },
"age=7": { "model": "quickiemod:block/cottonplant7" }
}
}

View File

@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "quickiemod:block/dirtsalpeter"
}
}
}

View File

@ -69,6 +69,7 @@
"block.quickiemod.monsterhoarder": "Monstersauger",
"block.quickiemod.kelpstack": "Seegrassbündel",
"block.quickiemod.cottonplant": "Baumwollpflanze",
"block.quickiemod.canolaplant": "Canolapflanze",
"block.quickiemod.blocksulphor": "Schwefelblock",
"block.quickiemod.blocksalpeter": "Salpeterblock",
"block.quickiemod.blockspeedpowder": "Fluchtpulverblock",

View File

@ -69,6 +69,7 @@
"block.quickiemod.monsterhoarder": "monster hoarder",
"block.quickiemod.kelpstack": "kelp bundle",
"block.quickiemod.cottonplant": "cotton plant",
"block.quickiemod.canolaplant": "canola plant",
"block.quickiemod.blocksulphor": "block of sulfur",
"block.quickiemod.blocksalpeter": "block of salpeter",
"block.quickiemod.blockspeedpowder": "block of speedpowder",

View File

@ -0,0 +1,6 @@
{
"parent":"block/cross",
"textures":{
"cross":"quickiemod:block/canolaplant0"
}
}

View File

@ -0,0 +1,6 @@
{
"parent":"block/cross",
"textures":{
"cross":"quickiemod:block/canolaplant1"
}
}

View File

@ -0,0 +1,6 @@
{
"parent":"block/cross",
"textures":{
"cross":"quickiemod:block/canolaplant2"
}
}

View File

@ -0,0 +1,6 @@
{
"parent":"block/cross",
"textures":{
"cross":"quickiemod:block/canolaplant3"
}
}

View File

@ -0,0 +1,6 @@
{
"parent":"block/cross",
"textures":{
"cross":"quickiemod:block/canolaplant4"
}
}

View File

@ -0,0 +1,6 @@
{
"parent":"block/cross",
"textures":{
"cross":"quickiemod:block/canolaplant5"
}
}

View File

@ -0,0 +1,6 @@
{
"parent":"block/cross",
"textures":{
"cross":"quickiemod:block/canolaplant6"
}
}

View File

@ -0,0 +1,6 @@
{
"parent":"block/cross",
"textures":{
"cross":"quickiemod:block/canolaplant7"
}
}

View File

@ -0,0 +1,6 @@
{
"parent":"block/cross",
"textures":{
"cross":"quickiemod:block/cottonplant0"
}
}

View File

@ -0,0 +1,6 @@
{
"parent":"block/cross",
"textures":{
"cross":"quickiemod:block/cottonplant1"
}
}

View File

@ -0,0 +1,6 @@
{
"parent":"block/cross",
"textures":{
"cross":"quickiemod:block/cottonplant2"
}
}

View File

@ -0,0 +1,6 @@
{
"parent":"block/cross",
"textures":{
"cross":"quickiemod:block/cottonplant3"
}
}

View File

@ -0,0 +1,6 @@
{
"parent":"block/cross",
"textures":{
"cross":"quickiemod:block/cottonplant4"
}
}

View File

@ -0,0 +1,6 @@
{
"parent":"block/cross",
"textures":{
"cross":"quickiemod:block/cottonplant5"
}
}

View File

@ -0,0 +1,6 @@
{
"parent":"block/cross",
"textures":{
"cross":"quickiemod:block/cottonplant6"
}
}

View File

@ -0,0 +1,6 @@
{
"parent":"block/cross",
"textures":{
"cross":"quickiemod:block/cottonplant7"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "quickiemod:item/canola"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "quickiemod:item/canolabottle"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "quickiemod:item/canolabottlestack"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "quickiemod:item/canolaseed"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "quickiemod:item/canolaseed"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "quickiemod:item/cotton"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "quickiemod:item/cottonseed"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "quickiemod:item/cottonseed"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 590 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 603 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -0,0 +1,17 @@
{
"type": "crafting_shaped",
"pattern": [
"ccc",
"ccc",
"ccc"
],
"key": {
"c": {
"item": "quickiemod:canolabottle"
}
},
"result": {
"id": "quickiemod:canolabottlestack",
"count": 1
}
}

View File

@ -0,0 +1,17 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"c",
"c",
"c"
],
"key": {
"c": {
"item": "quickiemod:cotton"
}
},
"result": {
"id": "minecraft:string",
"count": 1
}
}

View File

@ -0,0 +1,15 @@
{
"type": "minecraft:crafting_shapeless",
"ingredients": [
{
"item": "minecraft:glass_bottle"
},
{
"item": "quickiemod:canola"
}
],
"result": {
"id": "quickiemod:canolabottle",
"count": 1
}
}

View File

@ -0,0 +1,12 @@
{
"type": "minecraft:crafting_shapeless",
"ingredients": [
{
"item": "quickiemod:canolabottlestack"
}
],
"result": {
"id": "quickiemod:canolabottle",
"count": 9
}
}