diff --git a/src/main/java/com/minelittlepony/unicopia/UBlocks.java b/src/main/java/com/minelittlepony/unicopia/UBlocks.java index 8b91b0a9..8df6adba 100644 --- a/src/main/java/com/minelittlepony/unicopia/UBlocks.java +++ b/src/main/java/com/minelittlepony/unicopia/UBlocks.java @@ -1,16 +1,28 @@ package com.minelittlepony.unicopia; import com.minelittlepony.unicopia.block.BlockAlfalfa; +import com.minelittlepony.unicopia.block.BlockFruitLeaves; import com.minelittlepony.unicopia.block.BlockCloud; import com.minelittlepony.unicopia.block.BlockCloudAnvil; import com.minelittlepony.unicopia.block.BlockCloudSlab; import com.minelittlepony.unicopia.block.BlockCloudStairs; import com.minelittlepony.unicopia.block.BlockSugar; import com.minelittlepony.unicopia.block.BlockTomatoPlant; +import com.minelittlepony.unicopia.block.IColourful; +import com.minelittlepony.unicopia.block.USapling; import com.minelittlepony.unicopia.block.BlockCloudDoor; import com.minelittlepony.unicopia.block.BlockCloudFarm; import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.renderer.color.BlockColors; +import net.minecraft.client.renderer.color.ItemColors; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.world.ColorizerFoliage; +import net.minecraft.world.biome.BiomeColorHelper; +import net.minecraft.world.gen.feature.WorldGenTrees; import net.minecraftforge.registries.IForgeRegistry; public class UBlocks { @@ -33,10 +45,41 @@ public class UBlocks { public static final Block sugar_block = new BlockSugar(Unicopia.MODID, "sugar_block"); + public static final USapling apple_tree = new USapling(Unicopia.MODID, "apple_sapling") + .setTreeGen((w, s, m) -> new WorldGenTrees(true, 5, Blocks.LOG.getDefaultState(), UBlocks.apple_leaves.getDefaultState(), false)); + public static final Block apple_leaves = new BlockFruitLeaves(Unicopia.MODID, "apple_leaves", apple_tree) + .setBaseGrowthChance(1200) + .setTint(0xFFEE81) + .setHarvestFruit(w -> UItems.apple.getRandomApple(w.rand, null)) + .setUnharvestFruit(w -> new ItemStack(UItems.rotten_apple)); + static void registerBlocks(IForgeRegistry registry) { registry.registerAll(cloud, cloud_stairs, double_cloud_slab, cloud_slab, mist_door, anvil, cloud_farmland, sugar_block, alfalfa, - tomato_plant); + tomato_plant, + apple_tree, apple_leaves); + } + + static void registerColors(ItemColors items, BlockColors blocks) { + items.registerItemColorHandler((stack, tint) -> { + @SuppressWarnings("deprecation") + IBlockState state = ((ItemBlock)stack.getItem()).getBlock().getStateFromMeta(stack.getMetadata()); + + return blocks.colorMultiplier(state, null, null, tint); + }, apple_leaves); + blocks.registerBlockColorHandler((state, world, pos, tint) -> { + Block block = state.getBlock(); + + if (block instanceof IColourful) { + return ((IColourful)block).getCustomTint(state, tint); + } + + if (world != null && pos != null) { + return BiomeColorHelper.getFoliageColorAtPos(world, pos); + } + + return ColorizerFoliage.getFoliageColorBasic(); + }, apple_leaves); } } diff --git a/src/main/java/com/minelittlepony/unicopia/UItems.java b/src/main/java/com/minelittlepony/unicopia/UItems.java index 574d432d..00052d43 100644 --- a/src/main/java/com/minelittlepony/unicopia/UItems.java +++ b/src/main/java/com/minelittlepony/unicopia/UItems.java @@ -4,6 +4,7 @@ import com.minelittlepony.unicopia.item.ItemApple; import com.minelittlepony.unicopia.item.ItemCereal; import com.minelittlepony.unicopia.item.ItemCloud; import com.minelittlepony.unicopia.item.ItemCurse; +import com.minelittlepony.unicopia.item.ItemFruitLeaves; import com.minelittlepony.unicopia.item.ItemOfHolding; import com.minelittlepony.unicopia.item.ItemRottenApple; import com.minelittlepony.unicopia.item.ItemSpell; @@ -14,6 +15,7 @@ import com.minelittlepony.unicopia.item.ItemTomatoSeeds; import com.minelittlepony.unicopia.item.ItemZapApple; import com.minelittlepony.unicopia.item.UItemBlock; import com.minelittlepony.unicopia.item.UItemMultiTexture; +import com.minelittlepony.unicopia.item.UItemDecoration; import com.minelittlepony.unicopia.item.UItemSlab; import com.minelittlepony.unicopia.spell.SpellRegistry; @@ -25,7 +27,6 @@ import net.minecraft.init.Blocks; import net.minecraft.init.Enchantments; import net.minecraft.init.Items; import net.minecraft.item.Item; -import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemDoor; import net.minecraft.item.ItemFood; import net.minecraft.item.ItemSeedFood; @@ -53,7 +54,6 @@ public class UItems { .setSubTypes("zap_apple", "red", "green", "sweet", "sour"); public static final ItemApple rotten_apple = new ItemRottenApple(Unicopia.MODID, "rotten_apple"); - public static final ItemApple cooked_zap_apple = new ItemApple(Unicopia.MODID, "cooked_zap_apple"); public static final Item cloud_matter = new Item() @@ -73,25 +73,18 @@ public class UItems { }, INTERACT_WITH_CLOUDS) .setRegistryName(Unicopia.MODID, "cloud_block"); - public static final Item cloud_stairs = new UItemBlock(UBlocks.cloud_stairs, INTERACT_WITH_CLOUDS) - .setTranslationKey("cloud_stairs") - .setRegistryName(Unicopia.MODID, "cloud_stairs"); + public static final Item cloud_stairs = new UItemBlock(UBlocks.cloud_stairs, Unicopia.MODID, "cloud_stairs", INTERACT_WITH_CLOUDS); - public static final Item cloud_farmland = new UItemBlock(UBlocks.cloud_farmland, INTERACT_WITH_CLOUDS) - .setTranslationKey("cloud_farmland") - .setRegistryName(Unicopia.MODID, "cloud_farmland"); + public static final Item cloud_farmland = new UItemBlock(UBlocks.cloud_farmland, Unicopia.MODID, "cloud_farmland", INTERACT_WITH_CLOUDS); - public static final Item anvil = new UItemBlock(UBlocks.anvil, INTERACT_WITH_CLOUDS) - .setTranslationKey("cloud_anvil") - .setRegistryName(Unicopia.MODID, "anvil"); + public static final Item anvil = new UItemBlock(UBlocks.anvil, Unicopia.MODID, "anvil", INTERACT_WITH_CLOUDS) + .setTranslationKey("cloud_anvil"); public static final Item mist_door = new ItemDoor(UBlocks.mist_door) .setTranslationKey("mist_door") .setRegistryName(Unicopia.MODID, "mist_door"); - public static final Item sugar_block = new ItemBlock(UBlocks.sugar_block) - .setTranslationKey("sugar_block") - .setRegistryName(Unicopia.MODID, "sugar_block"); + public static final Item sugar_block = new UItemDecoration(UBlocks.sugar_block, Unicopia.MODID, "sugar_block"); public static final Item cloud_slab = new UItemSlab(UBlocks.cloud_slab, UBlocks.cloud_slab, UBlocks.double_cloud_slab, INTERACT_WITH_CLOUDS) .setTranslationKey("cloud_slab") @@ -122,6 +115,10 @@ public class UItems { public static final ItemTomato cloudsdale_tomato = new ItemTomato(Unicopia.MODID, "cloudsdale_tomato", 16, 4); public static final ItemTomatoSeeds tomato_seeds = new ItemTomatoSeeds(Unicopia.MODID, "tomato_seeds"); + public static final Item apple_seeds = new UItemDecoration(UBlocks.apple_tree, Unicopia.MODID, "apple_seeds"); + + public static final Item apple_leaves = new ItemFruitLeaves(UBlocks.apple_leaves, Unicopia.MODID, "apple_leaves"); + static void registerItems(IForgeRegistry registry) { RegistryLockSpinner.unlock(Item.REGISTRY); @@ -140,7 +137,9 @@ public class UItems { cereal, sugar_cereal, sugar_block, rotten_apple, zap_apple, cooked_zap_apple, - cloudsdale_tomato, tomato_seeds, tomato); + cloudsdale_tomato, tomato_seeds, tomato, + + apple_seeds, apple_leaves); if (UClient.isClientSide()) { registerAllVariants(apple, apple.getVariants()); @@ -168,6 +167,8 @@ public class UItems { registerAllVariants(tomato, "tomato", "rotten_tomato"); registerAllVariants(cloudsdale_tomato, "cloudsdale_tomato", "rotten_cloudsdale_tomato"); registerAllVariants(tomato_seeds, "tomato_seeds"); + registerAllVariants(apple_seeds, "apple_seeds"); + registerAllVariants(apple_leaves, "apple_leaves"); BuildInTexturesBakery.getBuiltInTextures().add(new ResourceLocation("unicopia", "items/empty_slot_gem")); } diff --git a/src/main/java/com/minelittlepony/unicopia/Unicopia.java b/src/main/java/com/minelittlepony/unicopia/Unicopia.java index 515ef080..f1db8855 100644 --- a/src/main/java/com/minelittlepony/unicopia/Unicopia.java +++ b/src/main/java/com/minelittlepony/unicopia/Unicopia.java @@ -161,6 +161,7 @@ public class Unicopia implements IGuiHandler { @SubscribeEvent public static void registerItemColoursStatic(ColorHandlerEvent.Item event) { UItems.registerColors(event.getItemColors()); + UBlocks.registerColors(event.getItemColors(), event.getBlockColors()); } @SubscribeEvent diff --git a/src/main/java/com/minelittlepony/unicopia/block/BlockFruitLeaves.java b/src/main/java/com/minelittlepony/unicopia/block/BlockFruitLeaves.java new file mode 100644 index 00000000..2d1bb890 --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/block/BlockFruitLeaves.java @@ -0,0 +1,250 @@ +package com.minelittlepony.unicopia.block; + +import java.util.Random; +import java.util.function.Function; + +import javax.annotation.Nonnull; + +import com.minelittlepony.unicopia.player.PlayerSpeciesList; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockLeaves; +import net.minecraft.block.BlockPlanks.EnumType; +import net.minecraft.block.properties.PropertyBool; +import net.minecraft.block.state.BlockStateContainer; +import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.SoundEvents; +import net.minecraft.item.EnumDyeColor; +import net.minecraft.item.Item; +import net.minecraft.item.ItemDye; +import net.minecraft.item.ItemStack; +import net.minecraft.util.BlockRenderLayer; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumHand; +import net.minecraft.util.NonNullList; +import net.minecraft.util.SoundCategory; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraft.world.biome.Biome.TempCategory; + +public class BlockFruitLeaves extends BlockLeaves implements IColourful { + + public static final PropertyBool HEAVY = PropertyBool.create("heavy"); + + private final Block sapling; + + private boolean hardy; + + private int baseGrowthChance; + private int customTint; + + private Function fruitProducer = w -> ItemStack.EMPTY; + private Function compostProducer = w -> ItemStack.EMPTY; + + public BlockFruitLeaves(String domain, String name, Block sapling) { + setTranslationKey(name); + setRegistryName(domain, name); + + setDefaultState(blockState.getBaseState() + .withProperty(HEAVY, false) + .withProperty(CHECK_DECAY, true) + .withProperty(DECAYABLE, true) + ); + + this.sapling = sapling; + } + + public BlockFruitLeaves setHardy(boolean value) { + hardy = value; + + return this; + } + + public BlockFruitLeaves setHarvestFruit(@Nonnull Function producer) { + fruitProducer = producer; + + return this; + } + + public BlockFruitLeaves setUnharvestFruit(@Nonnull Function producer) { + compostProducer = producer; + + return this; + } + + public BlockFruitLeaves setBaseGrowthChance(int chance) { + baseGrowthChance = chance; + + return this; + } + + public BlockFruitLeaves setTint(int tint) { + customTint = tint; + + return this; + } + + @Override + public boolean isOpaqueCube(IBlockState state) { + return Blocks.LEAVES.getDefaultState().isOpaqueCube(); + } + + @Override + public BlockRenderLayer getRenderLayer() { + setGraphicsLevel(!Blocks.LEAVES.getDefaultState().isOpaqueCube()); + return super.getRenderLayer(); + } + + @Deprecated + @Override + public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) { + setGraphicsLevel(!Blocks.LEAVES.getDefaultState().isOpaqueCube()); + return super.shouldSideBeRendered(blockState, blockAccess, pos, side); + } + + @Override + public Item getItemDropped(IBlockState state, Random rand, int fortune) { + return Item.getItemFromBlock(sapling); + } + + @Override + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { + ItemStack stack = player.getHeldItem(hand); + + if (PlayerSpeciesList.instance().getPlayer(player).getPlayerSpecies().canUseEarth()) { + if (stack.isEmpty()) { + + if (state.getValue(HEAVY)) { + dropApple(world, pos, state, 0); + world.setBlockState(pos, state.withProperty(HEAVY, false)); + } + } else if (stack.getItem() instanceof ItemDye && EnumDyeColor.byDyeDamage(stack.getMetadata()) == EnumDyeColor.WHITE) { + if (!state.getValue(HEAVY)) { + world.setBlockState(pos, state.withProperty(HEAVY, true)); + + if (!world.isRemote) { + world.playEvent(2005, pos, 0); + } + + if (!player.capabilities.isCreativeMode) { + stack.shrink(1); + } + } + } + + return true; + } + + return false; + } + + @Override + public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) { + if (!world.isRemote && world.isAreaLoaded(pos, 1)) { + if (state.getValue(CHECK_DECAY) && state.getValue(DECAYABLE)) { + int growthChance = getGrowthChance(world, pos, state); + + if (!state.getValue(HEAVY) && (growthChance <= 0 || rand.nextInt(growthChance) == 0)) { + world.setBlockState(pos, state.withProperty(HEAVY, true)); + } else { + growthChance /= 10; + + if (state.getValue(HEAVY) && (growthChance <= 0 || rand.nextInt(growthChance) == 0)) { + dropApple(world, pos, state, 0); + world.setBlockState(pos, state.withProperty(HEAVY, false)); + } else { + super.updateTick(world, pos, state, rand); + } + } + } + } + } + + protected int getGrowthChance(World world, BlockPos pos, IBlockState state) { + int chance = baseGrowthChance; + + if (!hardy && !world.isDaytime()) { + chance *= 40; + } + + if (world.getLight(pos) >= 4) { + chance /= 3; + } + + TempCategory temp = world.getBiome(pos).getTempCategory(); + + if (!hardy && temp == TempCategory.COLD) { + chance *= 1000; + } + + if (temp == TempCategory.WARM) { + chance /= 100; + } + + if (temp == TempCategory.MEDIUM) { + chance /= 50; + } + + return chance; + } + + @Override + public int getCustomTint(IBlockState state, int tint) { + return customTint; + } + + @Override + protected void dropApple(World world, BlockPos pos, IBlockState state, int chance) { + if (state.getValue(HEAVY)) { + Function fruit = world.rand.nextInt(40) == 0 ? compostProducer : fruitProducer; + spawnAsEntity(world, pos, fruit.apply(world)); + + world.playSound(null, pos, SoundEvents.ENTITY_ITEMFRAME_PLACE, SoundCategory.BLOCKS, 0.3F, 1); + } + } + + @Override + public NonNullList onSheared(ItemStack item, net.minecraft.world.IBlockAccess world, BlockPos pos, int fortune) { + return NonNullList.withSize(1, new ItemStack(this, 1, 0)); + } + + @Override + public EnumType getWoodType(int meta) { + return EnumType.OAK; + } + + @Override + public IBlockState getStateFromMeta(int meta) { + return getDefaultState() + .withProperty(HEAVY, (meta & 1) != 0) + .withProperty(DECAYABLE, (meta & 2) != 0) + .withProperty(CHECK_DECAY, (meta & 4) != 0); + } + + @Override + public int getMetaFromState(IBlockState state) { + int i = 0; + + if (state.getValue(HEAVY)) { + i |= 1; + } + + if (!state.getValue(DECAYABLE)) { + i |= 2; + } + + if (state.getValue(CHECK_DECAY)) { + i |= 4; + } + + return i; + } + + @Override + protected BlockStateContainer createBlockState() { + return new BlockStateContainer(this, HEAVY, CHECK_DECAY, DECAYABLE); + } +} diff --git a/src/main/java/com/minelittlepony/unicopia/block/IColourful.java b/src/main/java/com/minelittlepony/unicopia/block/IColourful.java new file mode 100644 index 00000000..854684c1 --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/block/IColourful.java @@ -0,0 +1,7 @@ +package com.minelittlepony.unicopia.block; + +import net.minecraft.block.state.IBlockState; + +public interface IColourful { + int getCustomTint(IBlockState state, int tint); +} diff --git a/src/main/java/com/minelittlepony/unicopia/block/ITreeGen.java b/src/main/java/com/minelittlepony/unicopia/block/ITreeGen.java new file mode 100644 index 00000000..a1434916 --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/block/ITreeGen.java @@ -0,0 +1,14 @@ +package com.minelittlepony.unicopia.block; + +import net.minecraft.block.state.IBlockState; +import net.minecraft.world.World; +import net.minecraft.world.gen.feature.WorldGenAbstractTree; + +@FunctionalInterface +public interface ITreeGen { + WorldGenAbstractTree getTreeGen(World world, IBlockState state, boolean massive); + + default boolean canGrowMassive() { + return false; + } +} \ No newline at end of file diff --git a/src/main/java/com/minelittlepony/unicopia/block/USapling.java b/src/main/java/com/minelittlepony/unicopia/block/USapling.java new file mode 100644 index 00000000..a9fe353b --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/block/USapling.java @@ -0,0 +1,166 @@ +package com.minelittlepony.unicopia.block; + +import java.util.Optional; +import java.util.Random; + +import javax.annotation.Nullable; + +import com.google.common.collect.ImmutableMap; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockSapling; +import net.minecraft.block.SoundType; +import net.minecraft.block.properties.IProperty; +import net.minecraft.block.state.BlockStateContainer; +import net.minecraft.block.state.IBlockState; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraft.world.gen.feature.WorldGenAbstractTree; +import net.minecraftforge.common.property.IUnlistedProperty; + +public class USapling extends BlockSapling implements ITreeGen { + + private ITreeGen treeGen; + + public USapling(String domain, String name) { + setRegistryName(domain, name); + setTranslationKey(name); + setSoundType(SoundType.PLANT); + + setDefaultState(blockState.getBaseState().withProperty(STAGE, 0)); + } + + public USapling setTreeGen(ITreeGen gen) { + treeGen = gen; + + return this; + } + + @Override + public void generateTree(World world, BlockPos pos, IBlockState state, Random rand) { + + boolean massive = canGrowMassive(); + + BlockPos i = massive ? findTwoByTwoSpace(world, pos, state) : pos; + + if (i == null) { + massive = false; + i = BlockPos.ORIGIN; + } + + // remove the sapling and any contributing siblings before growing the tree + setSaplingsState(world, Blocks.AIR.getDefaultState(), massive, i); + + if (!getTreeGen(world, state, massive).generate(world, rand, i)) { + // place them back if tree growth failed + setSaplingsState(world, state, massive, i); + } + } + + @Override + public void getSubBlocks(CreativeTabs tab, NonNullList items) { + items.add(new ItemStack(this)); + } + + protected void setSaplingsState(World world, IBlockState state, boolean massive, BlockPos pos) { + if (massive) { + world.setBlockState(pos , state, 4); + world.setBlockState(pos.add(1, 0, 0), state, 4); + world.setBlockState(pos.add(0, 0, 1), state, 4); + world.setBlockState(pos.add(1, 0, 1), state, 4); + } else { + world.setBlockState(pos, state, 4); + } + } + + @Override + public WorldGenAbstractTree getTreeGen(World world, IBlockState state, boolean massive) { + return treeGen.getTreeGen(world, state, massive); + } + + @Override + public boolean canGrowMassive() { + return treeGen.canGrowMassive(); + } + + /** + * Looks for a suitable 2x2 space that a tree can grow in. + * Returns null if no such spaces were found. + */ + @Nullable + public BlockPos findTwoByTwoSpace(World world, BlockPos pos, IBlockState state) { + BlockPos xNegP = pos.add(-1, 0, 0); + BlockPos xPosP = pos.add( 1, 0, 0); + + BlockPos zNegP = pos.add( 0, 0, -1); + BlockPos zPosP = pos.add( 0, 0, 1); + + boolean xNeg = isMatch(state, world.getBlockState(xNegP)); + boolean xPos = isMatch(state, world.getBlockState(xPosP)); + + boolean zNeg = isMatch(state, world.getBlockState(zNegP)); + boolean zPos = isMatch(state, world.getBlockState(zPosP)); + + if (xNeg && zNeg) { + BlockPos corner = pos.add(-1, 0, -1); + + if (isMatch(state, world.getBlockState(corner))) { + return corner; + } + } + + if (xNeg && zPos && isMatch(state, world.getBlockState(pos.add(-1, 0, 1)))) { + return xNegP; + } + + if (xPos && zNeg && isMatch(state, world.getBlockState(pos.add(1, 0, -1)))) { + return pos; + } + + if (xPos && zPos && isMatch(state, world.getBlockState(pos.add(-1, 0, 1)))) { + return zNegP; + } + + return null; + } + + protected boolean isMatch(IBlockState state, IBlockState other) { + return other.getBlock() == this; + } + + @Override + public IBlockState getStateFromMeta(int meta) { + return getDefaultState().withProperty(STAGE, (meta & 8) >> 3); + } + + @Override + public int getMetaFromState(IBlockState state) { + int i = 0; + i |= state.getValue(STAGE) << 3; + return i; + } + + @Override + protected BlockStateContainer createBlockState() { + return new BlockStateContainer(this, new IProperty[] {STAGE}) { + @Override + protected StateImplementation createState(Block block, ImmutableMap, Comparable> properties, @Nullable ImmutableMap, Optional> unlistedProperties) { + return new StateImplementation(block, properties) { + @Override + public , V extends T> IBlockState withProperty(IProperty property, V value) { + if (property == TYPE && !getProperties().containsKey(property)) { + return this; + } + + return super.withProperty(property, value); + } + }; + } + + }; + } +} diff --git a/src/main/java/com/minelittlepony/unicopia/item/ItemApple.java b/src/main/java/com/minelittlepony/unicopia/item/ItemApple.java index b03f5d66..3f668bd1 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/ItemApple.java +++ b/src/main/java/com/minelittlepony/unicopia/item/ItemApple.java @@ -75,10 +75,6 @@ public class ItemApple extends ItemFood { setRegistryName(domain, name); } - public int getZapAppleMetadata() { - return 4; - } - public ItemApple setSubTypes(String... types) { setHasSubtypes(true); setMaxDamage(0); diff --git a/src/main/java/com/minelittlepony/unicopia/item/ItemFruitLeaves.java b/src/main/java/com/minelittlepony/unicopia/item/ItemFruitLeaves.java new file mode 100644 index 00000000..9ff35ba4 --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/item/ItemFruitLeaves.java @@ -0,0 +1,15 @@ +package com.minelittlepony.unicopia.item; + +import net.minecraft.block.Block; + +public class ItemFruitLeaves extends UItemDecoration { + + public ItemFruitLeaves(Block block, String domain, String name) { + super(block, domain, name); + } + + @Override + public int getMetadata(int damage) { + return damage | 4; + } +} diff --git a/src/main/java/com/minelittlepony/unicopia/item/UItemBlock.java b/src/main/java/com/minelittlepony/unicopia/item/UItemBlock.java index 66e3799e..88c169ce 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/UItemBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/item/UItemBlock.java @@ -4,18 +4,17 @@ import java.util.function.Predicate; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -public class UItemBlock extends ItemBlock { +public class UItemBlock extends UItemDecoration { private final Predicate abilityTest; - public UItemBlock(Block block, Predicate abilityTest) { - super(block); + public UItemBlock(Block block, String domain, String name, Predicate abilityTest) { + super(block, domain, name); this.abilityTest = abilityTest; } diff --git a/src/main/java/com/minelittlepony/unicopia/item/UItemDecoration.java b/src/main/java/com/minelittlepony/unicopia/item/UItemDecoration.java new file mode 100644 index 00000000..86f26cb8 --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/item/UItemDecoration.java @@ -0,0 +1,15 @@ +package com.minelittlepony.unicopia.item; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemBlock; + +public class UItemDecoration extends ItemBlock { + + public UItemDecoration(Block block, String domain, String name) { + super(block); + + setTranslationKey(name); + setRegistryName(domain, name); + setCreativeTab(block.getCreativeTab()); + } +} diff --git a/src/main/resources/assets/unicopia/blockstates/apple_leaves.json b/src/main/resources/assets/unicopia/blockstates/apple_leaves.json new file mode 100644 index 00000000..78d26656 --- /dev/null +++ b/src/main/resources/assets/unicopia/blockstates/apple_leaves.json @@ -0,0 +1,13 @@ +{ + "variants": { + "normal": { "model": "unicopia:apple_leaves" }, + "check_decay=false,decayable=false,heavy=false": { "model": "unicopia:apple_leaves" }, + "check_decay=true,decayable=false,heavy=false": { "model": "unicopia:apple_leaves" }, + "check_decay=false,decayable=true,heavy=false": { "model": "unicopia:apple_leaves" }, + "check_decay=true,decayable=true,heavy=false": { "model": "unicopia:apple_leaves" }, + "check_decay=false,decayable=false,heavy=true": { "model": "unicopia:apple_leaves_heavy" }, + "check_decay=true,decayable=false,heavy=true": { "model": "unicopia:apple_leaves_heavy" }, + "check_decay=false,decayable=true,heavy=true": { "model": "unicopia:apple_leaves_heavy" }, + "check_decay=true,decayable=true,heavy=true": { "model": "unicopia:apple_leaves_heavy" } + } +} diff --git a/src/main/resources/assets/unicopia/blockstates/apple_sapling.json b/src/main/resources/assets/unicopia/blockstates/apple_sapling.json new file mode 100644 index 00000000..69f7e19a --- /dev/null +++ b/src/main/resources/assets/unicopia/blockstates/apple_sapling.json @@ -0,0 +1,6 @@ +{ + "variants": { + "stage=0": { "model": "unicopia:apple_sapling" }, + "stage=1": { "model": "unicopia:apple_sapling" } + } +} diff --git a/src/main/resources/assets/unicopia/lang/en_US.lang b/src/main/resources/assets/unicopia/lang/en_US.lang index cd84f0e5..09336272 100644 --- a/src/main/resources/assets/unicopia/lang/en_US.lang +++ b/src/main/resources/assets/unicopia/lang/en_US.lang @@ -9,6 +9,9 @@ tile.cloud_slab.enchanted.name=Enchanted Cloud Slab tile.cloud_stairs.name=Cloud Stairs tile.cloud_farmland.name=Tilled Clouds +tile.apple_leaves.name=Apple Leaves +tile.apple_sapling.name=Apple Seeds + tile.sugar_block.name=Block of Sugar item.cloud_matter.name=Lump of Cloud @@ -60,6 +63,8 @@ item.zap_apple.green.name=Granny Smith Apple item.zap_apple.sweet.name=Sweet Apple Acres Apple item.zap_apple.sour.name=Sour Apple +item.apple_seeds.name=Apple Seeds + item.tomato.name=Tomato item.tomato.rotten.name=Rotten Tomato item.tomato_seeds.name=Tomato Seeds diff --git a/src/main/resources/assets/unicopia/models/block/apple_leaves.json b/src/main/resources/assets/unicopia/models/block/apple_leaves.json new file mode 100644 index 00000000..ff8128c3 --- /dev/null +++ b/src/main/resources/assets/unicopia/models/block/apple_leaves.json @@ -0,0 +1,6 @@ +{ + "parent": "block/leaves", + "textures": { + "all": "unicopia:blocks/leaves_apple" + } +} diff --git a/src/main/resources/assets/unicopia/models/block/apple_leaves_heavy.json b/src/main/resources/assets/unicopia/models/block/apple_leaves_heavy.json new file mode 100644 index 00000000..932f59e2 --- /dev/null +++ b/src/main/resources/assets/unicopia/models/block/apple_leaves_heavy.json @@ -0,0 +1,38 @@ +{ + "parent": "block/leaves", + "textures": { + "all": "unicopia:blocks/leaves_apple", + "fruit": "minecraft:items/apple" + }, + "elements": [ + { "from": [ 0, 0, 0 ], + "to": [ 16, 16, 16 ], + "faces": { + "down": { "uv": [ 0, 0, 16, 16 ], "texture": "#all", "tintindex": 0, "cullface": "down" }, + "up": { "uv": [ 0, 0, 16, 16 ], "texture": "#all", "tintindex": 0, "cullface": "up" }, + "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#all", "tintindex": 0, "cullface": "north" }, + "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#all", "tintindex": 0, "cullface": "south" }, + "west": { "uv": [ 0, 0, 16, 16 ], "texture": "#all", "tintindex": 0, "cullface": "west" }, + "east": { "uv": [ 0, 0, 16, 16 ], "texture": "#all", "tintindex": 0, "cullface": "east" } + } + }, + { "from": [ 0.8, 0, 8 ], + "to": [ 15.2, 16, 8 ], + "rotation": { "origin": [ 8, 8, 8 ], "axis": "y", "angle": 45, "rescale": true }, + "shade": false, + "faces": { + "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#fruit" }, + "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#fruit" } + } + }, + { "from": [ 8, 0, 0.8 ], + "to": [ 8, 16, 15.2 ], + "rotation": { "origin": [ 8, 8, 8 ], "axis": "y", "angle": 45, "rescale": true }, + "shade": false, + "faces": { + "east": { "uv": [ 0, 0, 16, 16 ], "texture": "#fruit" }, + "west": { "uv": [ 0, 0, 16, 16 ], "texture": "#fruit" } + } + } + ] +} diff --git a/src/main/resources/assets/unicopia/models/block/apple_sapling.json b/src/main/resources/assets/unicopia/models/block/apple_sapling.json new file mode 100644 index 00000000..7e308cfb --- /dev/null +++ b/src/main/resources/assets/unicopia/models/block/apple_sapling.json @@ -0,0 +1,6 @@ +{ + "parent": "block/cross", + "textures": { + "cross": "unicopia:blocks/sapling_apple" + } +} diff --git a/src/main/resources/assets/unicopia/models/item/apple_leaves.json b/src/main/resources/assets/unicopia/models/item/apple_leaves.json new file mode 100644 index 00000000..8d70ab83 --- /dev/null +++ b/src/main/resources/assets/unicopia/models/item/apple_leaves.json @@ -0,0 +1,3 @@ +{ + "parent": "unicopia:block/red_apple_leaves" +} diff --git a/src/main/resources/assets/unicopia/models/item/apple_seeds.json b/src/main/resources/assets/unicopia/models/item/apple_seeds.json new file mode 100644 index 00000000..9b051338 --- /dev/null +++ b/src/main/resources/assets/unicopia/models/item/apple_seeds.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "unicopia:items/apple_seeds" + } +} diff --git a/src/main/resources/assets/unicopia/recipes/apple_seeds.json b/src/main/resources/assets/unicopia/recipes/apple_seeds.json new file mode 100644 index 00000000..f214899d --- /dev/null +++ b/src/main/resources/assets/unicopia/recipes/apple_seeds.json @@ -0,0 +1,12 @@ +{ + "type": "minecraft:crafting_shapeless", + "ingredients": [ + { + "item": "unicopia:rotten_apple" + } + ], + "result": { + "item": "unicopia:apple_seeds", + "count": 3 + } +} \ No newline at end of file diff --git a/src/main/resources/assets/unicopia/textures/blocks/leaves_apple.png b/src/main/resources/assets/unicopia/textures/blocks/leaves_apple.png new file mode 100644 index 00000000..a6773aff Binary files /dev/null and b/src/main/resources/assets/unicopia/textures/blocks/leaves_apple.png differ diff --git a/src/main/resources/assets/unicopia/textures/blocks/sapling_apple.png b/src/main/resources/assets/unicopia/textures/blocks/sapling_apple.png new file mode 100644 index 00000000..8fdb3264 Binary files /dev/null and b/src/main/resources/assets/unicopia/textures/blocks/sapling_apple.png differ diff --git a/src/main/resources/assets/unicopia/textures/items/apple_seeds.png b/src/main/resources/assets/unicopia/textures/items/apple_seeds.png new file mode 100644 index 00000000..95e9db81 Binary files /dev/null and b/src/main/resources/assets/unicopia/textures/items/apple_seeds.png differ