diff --git a/src/main/java/cr0s/warpdrive/api/IBlockBase.java b/src/main/java/cr0s/warpdrive/api/IBlockBase.java index 2f057a5b..0368518e 100644 --- a/src/main/java/cr0s/warpdrive/api/IBlockBase.java +++ b/src/main/java/cr0s/warpdrive/api/IBlockBase.java @@ -2,19 +2,21 @@ package cr0s.warpdrive.api; import cr0s.warpdrive.data.EnumTier; -import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import javax.annotation.Nonnull; import javax.annotation.Nullable; +import net.minecraftforge.common.IRarity; + public interface IBlockBase { @Nonnull EnumTier getTier(final ItemStack itemStack); - EnumRarity getRarity(final ItemStack itemStack); + @Nonnull + IRarity getForgeRarity(final ItemStack itemStack); @Nullable ItemBlock createItemBlock(); diff --git a/src/main/java/cr0s/warpdrive/api/IItemBase.java b/src/main/java/cr0s/warpdrive/api/IItemBase.java index e956da4b..9efaa206 100644 --- a/src/main/java/cr0s/warpdrive/api/IItemBase.java +++ b/src/main/java/cr0s/warpdrive/api/IItemBase.java @@ -18,7 +18,7 @@ public interface IItemBase { @Nonnull EnumTier getTier(final ItemStack itemStack); - // getRarity is defined in Item + // getForgeRarity is defined in Item @SideOnly(Side.CLIENT) void modelInitialisation(); diff --git a/src/main/java/cr0s/warpdrive/api/Particle.java b/src/main/java/cr0s/warpdrive/api/Particle.java index 4dedb95e..2be06bf9 100644 --- a/src/main/java/cr0s/warpdrive/api/Particle.java +++ b/src/main/java/cr0s/warpdrive/api/Particle.java @@ -4,12 +4,14 @@ import cr0s.warpdrive.Commons; import cr0s.warpdrive.WarpDrive; import cr0s.warpdrive.data.Vector3; +import javax.annotation.Nonnull; import java.util.Locale; import net.minecraft.item.EnumRarity; import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.world.World; +import net.minecraftforge.common.IRarity; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -20,7 +22,7 @@ public class Particle { protected int color; protected int colorIndex; - protected EnumRarity enumRarity = EnumRarity.COMMON; + protected IRarity rarity = EnumRarity.COMMON; private int entityLifespan; private float radiationLevel = 0.0F; private float explosionStrength = 0.0F; @@ -29,8 +31,8 @@ public class Particle { this.registryName = registryName.toLowerCase(Locale.ENGLISH); } - public Particle setRarity(final EnumRarity enumRarity) { - this.enumRarity = enumRarity; + public Particle setRarity(@Nonnull final IRarity rarity) { + this.rarity = rarity; return this; } @@ -40,7 +42,7 @@ public class Particle { } public Particle setColor(final int colorIndex) { - this.color = Commons.clamp(0x000000, 0xFFFFFF, color); + this.color = Commons.clamp(0x000000, 0xFFFFFF, colorIndex); return this; } @@ -88,18 +90,16 @@ public class Particle { /* Default Accessors */ - public EnumRarity getRarity() - { - return enumRarity; + @Nonnull + public IRarity getForgeRarity() { + return rarity; } - public int getColorIndex() - { + public int getColorIndex() { return colorIndex; } - public int getColor() - { + public int getColor() { return color; } @@ -132,7 +132,7 @@ public class Particle { public String toString() { return String.format("Particle %s (%s, RGB 0x%x %d, %d ticks, %.3f Sv, strength %.3f)", registryName, - enumRarity, + rarity, color, colorIndex, entityLifespan, radiationLevel, diff --git a/src/main/java/cr0s/warpdrive/block/BlockAbstractBase.java b/src/main/java/cr0s/warpdrive/block/BlockAbstractBase.java index 63769d0e..6cc35a14 100644 --- a/src/main/java/cr0s/warpdrive/block/BlockAbstractBase.java +++ b/src/main/java/cr0s/warpdrive/block/BlockAbstractBase.java @@ -15,6 +15,7 @@ import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; +import net.minecraftforge.common.IRarity; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -25,7 +26,6 @@ import cr0s.warpdrive.data.BlockProperties; import cr0s.warpdrive.data.EnumTier; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; import net.minecraft.world.World; @@ -111,8 +111,9 @@ public abstract class BlockAbstractBase extends Block implements IBlockBase { return enumTier; } + @Nonnull @Override - public EnumRarity getRarity(final ItemStack itemStack) { - return getTier(itemStack).getRarity(); + public IRarity getForgeRarity(@Nonnull final ItemStack itemStack) { + return getTier(itemStack).getForgeRarity(); } } diff --git a/src/main/java/cr0s/warpdrive/block/BlockAbstractContainer.java b/src/main/java/cr0s/warpdrive/block/BlockAbstractContainer.java index ac66ddc9..0720bfc1 100644 --- a/src/main/java/cr0s/warpdrive/block/BlockAbstractContainer.java +++ b/src/main/java/cr0s/warpdrive/block/BlockAbstractContainer.java @@ -27,13 +27,14 @@ import net.minecraft.util.NonNullList; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; + +import net.minecraftforge.common.IRarity; import net.minecraftforge.fml.common.Optional; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; @@ -278,9 +279,10 @@ public abstract class BlockAbstractContainer extends BlockContainer implements I return enumTier; } + @Nonnull @Override - public EnumRarity getRarity(final ItemStack itemStack) { - return getTier(itemStack).getRarity(); + public IRarity getForgeRarity(@Nonnull final ItemStack itemStack) { + return getTier(itemStack).getForgeRarity(); } @Override diff --git a/src/main/java/cr0s/warpdrive/block/ItemBlockAbstractBase.java b/src/main/java/cr0s/warpdrive/block/ItemBlockAbstractBase.java index e9372133..0aece897 100644 --- a/src/main/java/cr0s/warpdrive/block/ItemBlockAbstractBase.java +++ b/src/main/java/cr0s/warpdrive/block/ItemBlockAbstractBase.java @@ -29,6 +29,7 @@ import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.world.World; +import net.minecraftforge.common.IRarity; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -74,13 +75,17 @@ public class ItemBlockAbstractBase extends ItemBlock implements IItemBase { @Nonnull @Override - public EnumRarity getRarity(@Nonnull final ItemStack itemStack) { - final EnumRarity enumRarityDefault = super.getRarity(itemStack); + public IRarity getForgeRarity(@Nonnull final ItemStack itemStack) { + final IRarity rarityDefault = super.getForgeRarity(itemStack); if ( !(block instanceof IBlockBase) ) { - return enumRarityDefault; + return rarityDefault; } - final EnumRarity enumRarityStack = ((IBlockBase) block).getRarity(itemStack); - return enumRarityStack.ordinal() > enumRarityDefault.ordinal() ? enumRarityStack : enumRarityDefault; + final IRarity rarityItemStack = ((IBlockBase) block).getForgeRarity(itemStack); + if ( rarityItemStack instanceof EnumRarity + && rarityDefault instanceof EnumRarity ) { + return ((EnumRarity) rarityItemStack).ordinal() > ((EnumRarity) rarityDefault).ordinal() ? rarityItemStack : rarityDefault; + } + return rarityItemStack; } public ITextComponent getStatus(final World world, @Nonnull final ItemStack itemStack) { @@ -115,7 +120,6 @@ public class ItemBlockAbstractBase extends ItemBlock implements IItemBase { return ClientProxy.getModelResourceLocation(itemStack); } - @SuppressWarnings("deprecation") @Override @SideOnly(Side.CLIENT) public void addInformation(@Nonnull final ItemStack itemStack, @Nullable final World world, diff --git a/src/main/java/cr0s/warpdrive/block/hull/BlockHullGlass.java b/src/main/java/cr0s/warpdrive/block/hull/BlockHullGlass.java index 80bafbb3..78632c42 100644 --- a/src/main/java/cr0s/warpdrive/block/hull/BlockHullGlass.java +++ b/src/main/java/cr0s/warpdrive/block/hull/BlockHullGlass.java @@ -16,7 +16,6 @@ import net.minecraft.block.BlockGlass; import net.minecraft.block.SoundType; import net.minecraft.block.material.EnumPushReaction; import net.minecraft.block.material.Material; -import net.minecraft.item.EnumRarity; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; @@ -28,6 +27,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import net.minecraftforge.common.IRarity; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -69,9 +69,10 @@ public class BlockHullGlass extends BlockColored implements IBlockBase, IDamageR return enumTier; } + @Nonnull @Override - public EnumRarity getRarity(final ItemStack itemStack) { - return getTier(itemStack).getRarity(); + public IRarity getForgeRarity(@Nonnull final ItemStack itemStack) { + return getTier(itemStack).getForgeRarity(); } @Nullable diff --git a/src/main/java/cr0s/warpdrive/block/hull/BlockHullSlab.java b/src/main/java/cr0s/warpdrive/block/hull/BlockHullSlab.java index bff98dea..ad1930b0 100644 --- a/src/main/java/cr0s/warpdrive/block/hull/BlockHullSlab.java +++ b/src/main/java/cr0s/warpdrive/block/hull/BlockHullSlab.java @@ -25,7 +25,6 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.EnumDyeColor; -import net.minecraft.item.EnumRarity; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; @@ -39,6 +38,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import net.minecraftforge.common.IRarity; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -173,7 +173,7 @@ public class BlockHullSlab extends BlockSlab implements IBlockBase, IDamageRecei @SuppressWarnings("deprecation") @Override - public boolean isFullBlock(IBlockState blockState) { + public boolean isFullBlock(final IBlockState blockState) { return ((BlockSlab) blockState.getBlock()).isDouble(); } @@ -301,9 +301,10 @@ public class BlockHullSlab extends BlockSlab implements IBlockBase, IDamageRecei return enumTier; } + @Nonnull @Override - public EnumRarity getRarity(final ItemStack itemStack) { - return enumTier.getRarity(); + public IRarity getForgeRarity(@Nonnull final ItemStack itemStack) { + return enumTier.getForgeRarity(); } @Nullable diff --git a/src/main/java/cr0s/warpdrive/block/hull/BlockHullStairs.java b/src/main/java/cr0s/warpdrive/block/hull/BlockHullStairs.java index 81a3841a..62486633 100644 --- a/src/main/java/cr0s/warpdrive/block/hull/BlockHullStairs.java +++ b/src/main/java/cr0s/warpdrive/block/hull/BlockHullStairs.java @@ -15,7 +15,6 @@ import net.minecraft.block.BlockStairs; import net.minecraft.block.material.EnumPushReaction; import net.minecraft.block.state.IBlockState; import net.minecraft.item.EnumDyeColor; -import net.minecraft.item.EnumRarity; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; @@ -23,6 +22,7 @@ import net.minecraft.util.DamageSource; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import net.minecraftforge.common.IRarity; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -55,9 +55,10 @@ public class BlockHullStairs extends BlockStairs implements IBlockBase, IDamageR return enumTier; } + @Nonnull @Override - public EnumRarity getRarity(final ItemStack itemStack) { - return enumTier.getRarity(); + public IRarity getForgeRarity(@Nonnull final ItemStack itemStack) { + return enumTier.getForgeRarity(); } @Nullable diff --git a/src/main/java/cr0s/warpdrive/data/EnumAirTankTier.java b/src/main/java/cr0s/warpdrive/data/EnumAirTankTier.java index 14e8b8fc..d5fdd863 100644 --- a/src/main/java/cr0s/warpdrive/data/EnumAirTankTier.java +++ b/src/main/java/cr0s/warpdrive/data/EnumAirTankTier.java @@ -3,9 +3,10 @@ package cr0s.warpdrive.data; import javax.annotation.Nonnull; import java.util.HashMap; -import net.minecraft.item.EnumRarity; import net.minecraft.util.IStringSerializable; +import net.minecraftforge.common.IRarity; + public enum EnumAirTankTier implements IStringSerializable { CANISTER ("canister", 0, EnumTier.BASIC ), @@ -53,7 +54,8 @@ public enum EnumAirTankTier implements IStringSerializable { return enumTier; } - public EnumRarity getRarity() { - return enumTier.getRarity(); + @Nonnull + public IRarity getForgeRarity() { + return enumTier.getForgeRarity(); } } diff --git a/src/main/java/cr0s/warpdrive/data/EnumTier.java b/src/main/java/cr0s/warpdrive/data/EnumTier.java index ed87cd27..f766d27a 100644 --- a/src/main/java/cr0s/warpdrive/data/EnumTier.java +++ b/src/main/java/cr0s/warpdrive/data/EnumTier.java @@ -7,6 +7,8 @@ import java.util.HashMap; import net.minecraft.item.EnumRarity; import net.minecraft.util.IStringSerializable; +import net.minecraftforge.common.IRarity; + public enum EnumTier implements IStringSerializable { CREATIVE ("creative", 0, EnumRarity.EPIC ), @@ -16,7 +18,7 @@ public enum EnumTier implements IStringSerializable { private final String name; private final int index; - private final EnumRarity enumRarity; + private final IRarity rarity; // cached values public static final int length; @@ -36,10 +38,10 @@ public enum EnumTier implements IStringSerializable { tblNonCreatives = list.toArray(new EnumTier[0]); } - EnumTier(final String name, final int index, final EnumRarity enumRarity) { + EnumTier(final String name, final int index, @Nonnull final IRarity rarity) { this.name = name; this.index = index; - this.enumRarity = enumRarity; + this.rarity = rarity; } @Nonnull @@ -56,8 +58,9 @@ public enum EnumTier implements IStringSerializable { return index; } - public EnumRarity getRarity() { - return enumRarity; + @Nonnull + public IRarity getForgeRarity() { + return rarity; } public static EnumTier[] nonCreative() { diff --git a/src/main/java/cr0s/warpdrive/item/ItemAbstractBase.java b/src/main/java/cr0s/warpdrive/item/ItemAbstractBase.java index 6b6dcda0..27e07238 100644 --- a/src/main/java/cr0s/warpdrive/item/ItemAbstractBase.java +++ b/src/main/java/cr0s/warpdrive/item/ItemAbstractBase.java @@ -10,12 +10,12 @@ import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.resources.I18n; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.item.EntityItem; -import net.minecraft.item.EnumRarity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.world.World; +import net.minecraftforge.common.IRarity; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -60,8 +60,9 @@ public class ItemAbstractBase extends Item implements IItemBase { } @Nonnull - public EnumRarity getRarity(final ItemStack itemStack) { - return getTier(itemStack).getRarity(); + @Override + public IRarity getForgeRarity(@Nonnull final ItemStack itemStack) { + return getTier(itemStack).getForgeRarity(); } @Override diff --git a/src/main/java/cr0s/warpdrive/item/ItemWarpArmor.java b/src/main/java/cr0s/warpdrive/item/ItemWarpArmor.java index cabceab1..c99cf7fd 100644 --- a/src/main/java/cr0s/warpdrive/item/ItemWarpArmor.java +++ b/src/main/java/cr0s/warpdrive/item/ItemWarpArmor.java @@ -13,10 +13,10 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.inventory.EntityEquipmentSlot; -import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; +import net.minecraftforge.common.IRarity; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -50,8 +50,9 @@ public class ItemWarpArmor extends ItemArmor implements IItemBase, IBreathingHel } @Nonnull - public EnumRarity getRarity(final ItemStack itemStack) { - return getTier(itemStack).getRarity(); + @Override + public IRarity getForgeRarity(@Nonnull final ItemStack itemStack) { + return getTier(itemStack).getForgeRarity(); } @Override