diff --git a/src/main/java/cr0s/warpdrive/api/IBlockBase.java b/src/main/java/cr0s/warpdrive/api/IBlockBase.java new file mode 100644 index 00000000..18a11846 --- /dev/null +++ b/src/main/java/cr0s/warpdrive/api/IBlockBase.java @@ -0,0 +1,9 @@ +package cr0s.warpdrive.api; + +import net.minecraft.item.EnumRarity; +import net.minecraft.item.ItemStack; + +public interface IBlockBase { + + EnumRarity getRarity(final ItemStack itemStack, final EnumRarity rarity); +} \ No newline at end of file diff --git a/src/main/java/cr0s/warpdrive/block/BlockAbstractContainer.java b/src/main/java/cr0s/warpdrive/block/BlockAbstractContainer.java index d53db514..bc7491ab 100644 --- a/src/main/java/cr0s/warpdrive/block/BlockAbstractContainer.java +++ b/src/main/java/cr0s/warpdrive/block/BlockAbstractContainer.java @@ -1,6 +1,7 @@ package cr0s.warpdrive.block; import cpw.mods.fml.common.Optional; +import cr0s.warpdrive.api.IBlockBase; import cr0s.warpdrive.config.WarpDriveConfig; import defense.api.IEMPBlock; import defense.api.IExplosion; @@ -23,7 +24,7 @@ import net.minecraftforge.common.util.ForgeDirection; @Optional.InterfaceList({ @Optional.Interface(iface = "defense.api.IEMPBlock", modid = "DefenseTech") }) -public abstract class BlockAbstractContainer extends BlockContainer implements IEMPBlock { +public abstract class BlockAbstractContainer extends BlockContainer implements IBlockBase, IEMPBlock { protected boolean isRotating = false; protected boolean hasSubBlocks = false; @@ -198,7 +199,8 @@ public abstract class BlockAbstractContainer extends BlockContainer implements I return 1; } - EnumRarity getRarity(final ItemStack itemStack, final EnumRarity rarity) { + @Override + public EnumRarity getRarity(final ItemStack itemStack, final EnumRarity rarity) { switch (getTier(itemStack)) { case 0: return EnumRarity.epic; case 1: return EnumRarity.common; diff --git a/src/main/java/cr0s/warpdrive/block/ItemBlockAbstractBase.java b/src/main/java/cr0s/warpdrive/block/ItemBlockAbstractBase.java index 03a377fd..8ab5e0bf 100644 --- a/src/main/java/cr0s/warpdrive/block/ItemBlockAbstractBase.java +++ b/src/main/java/cr0s/warpdrive/block/ItemBlockAbstractBase.java @@ -3,6 +3,7 @@ package cr0s.warpdrive.block; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import cr0s.warpdrive.WarpDrive; +import cr0s.warpdrive.api.IBlockBase; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumRarity; @@ -48,10 +49,10 @@ public class ItemBlockAbstractBase extends ItemBlock { @Override public EnumRarity getRarity(ItemStack itemStack) { if ( itemStack == null - || !(field_150939_a instanceof BlockAbstractContainer) ) { + || !(field_150939_a instanceof IBlockBase) ) { return super.getRarity(itemStack); } - return ((BlockAbstractContainer)field_150939_a).getRarity(itemStack, super.getRarity(itemStack)); + return ((IBlockBase) field_150939_a).getRarity(itemStack, super.getRarity(itemStack)); } private String getStatus(final NBTTagCompound nbtTagCompound, final int metadata) { diff --git a/src/main/java/cr0s/warpdrive/block/atomic/BlockAbstractAccelerator.java b/src/main/java/cr0s/warpdrive/block/atomic/BlockAbstractAccelerator.java index d0a3ab99..5ba48f7d 100644 --- a/src/main/java/cr0s/warpdrive/block/atomic/BlockAbstractAccelerator.java +++ b/src/main/java/cr0s/warpdrive/block/atomic/BlockAbstractAccelerator.java @@ -1,14 +1,16 @@ package cr0s.warpdrive.block.atomic; import cr0s.warpdrive.WarpDrive; +import cr0s.warpdrive.api.IBlockBase; import cr0s.warpdrive.config.WarpDriveConfig; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.EnumCreatureType; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.ItemStack; import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; -public class BlockAbstractAccelerator extends Block { +public class BlockAbstractAccelerator extends Block implements IBlockBase { public final byte tier; public BlockAbstractAccelerator(final byte tier) { @@ -40,6 +42,21 @@ public class BlockAbstractAccelerator extends Block { return 0; } + public byte getTier(final ItemStack itemStack) { + return tier; + } + + @Override + public EnumRarity getRarity(final ItemStack itemStack, final EnumRarity rarity) { + switch (getTier(itemStack)) { + case 0: return EnumRarity.epic; + case 1: return EnumRarity.common; + case 2: return EnumRarity.uncommon; + case 3: return EnumRarity.rare; + default: return rarity; + } + } + @Override public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) { return false;