diff --git a/src/main/java/com/minelittlepony/unicopia/UItems.java b/src/main/java/com/minelittlepony/unicopia/UItems.java index 0f8e26e2..f81395c3 100644 --- a/src/main/java/com/minelittlepony/unicopia/UItems.java +++ b/src/main/java/com/minelittlepony/unicopia/UItems.java @@ -20,7 +20,9 @@ import net.minecraft.init.Enchantments; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemDoor; -import net.minecraft.item.ItemSeeds; +import net.minecraft.item.ItemFood; +import net.minecraft.item.ItemSeedFood; +import net.minecraft.item.ItemSoup; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.FurnaceRecipes; import net.minecraft.item.crafting.IRecipe; @@ -77,10 +79,18 @@ public class UItems { public static final ItemOfHolding bag_of_holding = new ItemOfHolding(Unicopia.MODID, "bag_of_holding"); - public static final Item alfalfa_seeds = new ItemSeeds(UBlocks.alfalfa, Blocks.FARMLAND) + public static final Item alfalfa_seeds = new ItemSeedFood(1, 4, UBlocks.alfalfa, Blocks.FARMLAND) .setTranslationKey("alfalfa_seeds") .setRegistryName(Unicopia.MODID, "alfalfa_seeds"); + public static final Item alfalfa_leaves = new ItemFood(1, 3, false) + .setTranslationKey("alfalfa_leaves") + .setRegistryName(Unicopia.MODID, "alfalfa_leaves"); + + public static final Item cereal = new ItemSoup(15) + .setTranslationKey("cereal") + .setRegistryName(Unicopia.MODID, "cereal"); + static void registerItems(IForgeRegistry registry) { RegistryLockSpinner.unlock(Item.REGISTRY); @@ -88,10 +98,12 @@ public class UItems { RegistryLockSpinner.lock(Item.REGISTRY); + + registry.registerAll(cloud_spawner, dew_drop, cloud_matter, cloud_block, cloud_stairs, cloud_slab, mist_door, anvil, bag_of_holding, spell, curse, - alfalfa_seeds); + alfalfa_seeds, alfalfa_leaves, cereal); if (UClient.isClientSide()) { registerAllVariants(apple, apple.getVariants()); @@ -107,6 +119,8 @@ public class UItems { registerAllVariants(spell, "gem"); registerAllVariants(curse, "corrupted_gem"); registerAllVariants(alfalfa_seeds, "alfalfa_seeds"); + registerAllVariants(alfalfa_leaves, "alfalfa_leaves"); + registerAllVariants(cereal, "cereal"); } registerFuels(); diff --git a/src/main/java/com/minelittlepony/unicopia/Unicopia.java b/src/main/java/com/minelittlepony/unicopia/Unicopia.java index 43f1957a..c83ce30f 100644 --- a/src/main/java/com/minelittlepony/unicopia/Unicopia.java +++ b/src/main/java/com/minelittlepony/unicopia/Unicopia.java @@ -1,6 +1,7 @@ package com.minelittlepony.unicopia; import net.minecraft.block.Block; +import net.minecraft.block.BlockCrops; import net.minecraft.client.Minecraft; import net.minecraft.init.Blocks; import net.minecraft.item.EnumAction; @@ -154,7 +155,9 @@ public class Unicopia { @SubscribeEvent public static void onBlockHarvested(BlockEvent.HarvestDropsEvent event) { - if (event.getState().getBlock() == Blocks.STONE) { + Block block = event.getState().getBlock(); + + if (block == Blocks.STONE) { int fortuneFactor = 1 + event.getFortuneLevel() * 15; if (event.getWorld().rand.nextInt(500 / fortuneFactor) == 0) { @@ -166,6 +169,14 @@ public class Unicopia { } } } + } else if (block instanceof BlockCrops) { + int fortuneFactor = 1 + event.getFortuneLevel() * 15; + + if (event.getWorld().rand.nextInt(500 / fortuneFactor) == 0) { + for (int i = 0; i < 1 + event.getFortuneLevel(); i++) { + event.getDrops().add(new ItemStack(UItems.alfalfa_seeds, 1)); + } + } } } diff --git a/src/main/java/com/minelittlepony/unicopia/block/BlockAlfalfa.java b/src/main/java/com/minelittlepony/unicopia/block/BlockAlfalfa.java index f59dddf5..71e3e4f4 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/BlockAlfalfa.java +++ b/src/main/java/com/minelittlepony/unicopia/block/BlockAlfalfa.java @@ -12,7 +12,9 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; import net.minecraft.util.IStringSerializable; +import net.minecraft.util.NonNullList; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; @@ -139,6 +141,25 @@ public class BlockAlfalfa extends BlockCrops { return super.getItemDropped(state, rand, fortune); } + @Override + public void getDrops(NonNullList drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { + Random rand = world instanceof World ? ((World)world).rand : RANDOM; + + Item item = getItemDropped(state, rand, fortune); + if (item != Items.AIR) { + drops.add(new ItemStack(item, getFullAge(world, pos), damageDropped(state))); + + if (isMaxAge(state)) { + drops.add(new ItemStack(UItems.alfalfa_leaves, rand.nextInt(10))); + } + } + } + + @Override + public int quantityDropped(IBlockState state, int fortune, Random random) { + return 1; + } + @Override public boolean canBlockStay(World world, BlockPos pos, IBlockState state) { return getHalf(state) != Half.BOTTOM || super.canBlockStay(world, pos, state); @@ -198,8 +219,6 @@ public class BlockAlfalfa extends BlockCrops { @Override public boolean canGrow(World world, BlockPos pos, IBlockState state, boolean isClient) { - - Half half = getHalf(state); if (half == Half.MIDDLE || (half == Half.TOP && world.getBlockState(pos.down()).getBlock() == this)) { diff --git a/src/main/resources/assets/unicopia/lang/en_US.lang b/src/main/resources/assets/unicopia/lang/en_US.lang index fb2dfb8f..89b3445a 100644 --- a/src/main/resources/assets/unicopia/lang/en_US.lang +++ b/src/main/resources/assets/unicopia/lang/en_US.lang @@ -45,6 +45,9 @@ item.apple.rotten.name=Rotten Apple item.apple.zap.name=Zap Apple item.apple.zap_cooked.name=Cooked Zap Apple +item.alfalfa_leaves.name=Alfalfa +item.alfalfa_seeds.name=Grain + entity.racing_cloud.name=Bucking Bronco entity.construction_cloud.name=Construction Cloud entity.cloud.name=Cloud diff --git a/src/main/resources/assets/unicopia/models/item/alfalfa_leaves.json b/src/main/resources/assets/unicopia/models/item/alfalfa_leaves.json new file mode 100644 index 00000000..09eca0fa --- /dev/null +++ b/src/main/resources/assets/unicopia/models/item/alfalfa_leaves.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "unicopia:items/alfalfa_leaves" + } +} diff --git a/src/main/resources/assets/unicopia/models/item/cereal.json b/src/main/resources/assets/unicopia/models/item/cereal.json new file mode 100644 index 00000000..ce05147e --- /dev/null +++ b/src/main/resources/assets/unicopia/models/item/cereal.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "unicopia:items/cereal" + } +} diff --git a/src/main/resources/assets/unicopia/recipes/anvil.json b/src/main/resources/assets/unicopia/recipes/anvil.json new file mode 100644 index 00000000..fb26050f --- /dev/null +++ b/src/main/resources/assets/unicopia/recipes/anvil.json @@ -0,0 +1,21 @@ +{ + "type": "minecraft:crafting_shaped", + "pattern": [ + "###", + " # ", + "###" + ], + "key": { + "#": [ + { + "item": "unicopia:cloud_block", + "data": 0 + } + ] + }, + "result": { + "item": "unicopia:anvil", + "data": 0, + "count": 1 + } +} diff --git a/src/main/resources/assets/unicopia/recipes/cereal.json b/src/main/resources/assets/unicopia/recipes/cereal.json new file mode 100644 index 00000000..ab52d81d --- /dev/null +++ b/src/main/resources/assets/unicopia/recipes/cereal.json @@ -0,0 +1,22 @@ +{ + "type": "minecraft:crafting_shapeless", + "ingredients": [ + { + "item": "minecraft:bowl" + }, + { + "item": "unicopia:alfalfa_seeds" + }, + { + "item": "unicopia:alfalfa_leaves" + }, + { + "item": "minecraft:milk_bucket" + } + ], + "result": { + "item": "unicopia:cereal", + "data": 0, + "count": 1 + } +} diff --git a/src/main/resources/assets/unicopia/textures/items/alfalfa_leaves.png b/src/main/resources/assets/unicopia/textures/items/alfalfa_leaves.png new file mode 100644 index 00000000..a9dd88b2 Binary files /dev/null and b/src/main/resources/assets/unicopia/textures/items/alfalfa_leaves.png differ diff --git a/src/main/resources/assets/unicopia/textures/items/cereal.png b/src/main/resources/assets/unicopia/textures/items/cereal.png new file mode 100644 index 00000000..dfe9eca6 Binary files /dev/null and b/src/main/resources/assets/unicopia/textures/items/cereal.png differ