From fc3c423523a9de943facc1e704b5077a25005aea Mon Sep 17 00:00:00 2001 From: Cheeserolls Date: Mon, 4 May 2015 10:05:42 +0100 Subject: [PATCH] Make sacred oad sapling items shiny --- .../common/block/BlockBOPSapling.java | 4 ++ .../common/item/ItemBOPSapling.java | 43 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 src/main/java/biomesoplenty/common/item/ItemBOPSapling.java diff --git a/src/main/java/biomesoplenty/common/block/BlockBOPSapling.java b/src/main/java/biomesoplenty/common/block/BlockBOPSapling.java index c390c1695..09367061c 100644 --- a/src/main/java/biomesoplenty/common/block/BlockBOPSapling.java +++ b/src/main/java/biomesoplenty/common/block/BlockBOPSapling.java @@ -15,6 +15,7 @@ import java.util.Random; import biomesoplenty.api.block.BOPBlocks; import biomesoplenty.api.block.BOPTreeEnums; import biomesoplenty.api.block.BOPTreeEnums.AllTrees; +import biomesoplenty.common.item.ItemBOPSapling; import net.minecraft.block.Block; import net.minecraft.block.IGrowable; import net.minecraft.block.properties.IProperty; @@ -23,6 +24,7 @@ import net.minecraft.block.properties.PropertyInteger; import net.minecraft.block.state.BlockState; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; +import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.util.BlockPos; import net.minecraft.world.World; @@ -98,6 +100,8 @@ public abstract class BlockBOPSapling extends BlockDecoration implements IGrowab // implement IBOPBlock @Override + public Class getItemClass() { return ItemBOPSapling.class; } + @Override public IProperty[] getPresetProperties() { return new IProperty[] {getMyVariantProperty()}; } @Override public IProperty[] getNonRenderingProperties() { return new IProperty[] {STAGE}; } diff --git a/src/main/java/biomesoplenty/common/item/ItemBOPSapling.java b/src/main/java/biomesoplenty/common/item/ItemBOPSapling.java new file mode 100644 index 000000000..9b6554927 --- /dev/null +++ b/src/main/java/biomesoplenty/common/item/ItemBOPSapling.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright 2014, the Biomes O' Plenty Team + * + * This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License. + * + * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/. + ******************************************************************************/ + +package biomesoplenty.common.item; + +import biomesoplenty.api.block.BOPTreeEnums.AllTrees; +import biomesoplenty.common.block.BlockBOPSapling; +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; + +public class ItemBOPSapling extends ItemBOPBlock +{ + + public BlockBOPSapling saplingBlock; + + public ItemBOPSapling(Block block) { + super(block); + if (!(block instanceof BlockBOPSapling)) + { + throw new IllegalArgumentException("ItemBOPSapling must be created with a BlockBOPSapling block"); + } + this.saplingBlock = (BlockBOPSapling)block; + } + + @Override + public boolean hasEffect(ItemStack stack) + { + AllTrees tree = this.saplingBlock.variantFromMeta(stack.getMetadata()); + switch (tree) + { + case SACRED_OAK: + return true; + default: + return super.hasEffect(stack); + } + } + +} \ No newline at end of file