Added tier system for items

Added plasma torch (wip)
This commit is contained in:
Unknown 2018-07-27 13:19:14 +02:00 committed by unknown
parent e718c9863b
commit 554b0149ee
18 changed files with 389 additions and 40 deletions

View file

@ -1,5 +1,7 @@
package cr0s.warpdrive.api;
import cr0s.warpdrive.data.EnumTier;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
@ -13,6 +15,11 @@ public interface IItemBase {
// wrapper for Forge ItemExpireEvent
void onEntityExpireEvent(final EntityItem entityItem, final ItemStack itemStack);
@Nonnull
EnumTier getTier(final ItemStack itemStack);
// getRarity is defined in Item
@SideOnly(Side.CLIENT)
void modelInitialisation();

View file

@ -64,6 +64,15 @@ public class ItemBlockAbstractBase extends ItemBlock implements IItemBase {
return getTranslationKey() + itemStack.getItemDamage();
}
@Nonnull
@Override
public EnumTier getTier(@Nonnull final ItemStack itemStack) {
if ( !(block instanceof IBlockBase) ) {
return EnumTier.BASIC;
}
return ((IBlockBase) block).getTier(itemStack);
}
@Nonnull
@Override
public EnumRarity getRarity(@Nonnull final ItemStack itemStack) {

View file

@ -1417,10 +1417,32 @@ public class Recipes {
// Electromagnetic cell
WarpDrive.register(new ShapedOreRecipe(groupMachines,
new ItemStack(WarpDrive.itemElectromagneticCell, 2), "iri", "i i", "ici",
new ItemStack(WarpDrive.itemElectromagneticCell[EnumTier.BASIC.getIndex()], 2), "iri", "i i", "ici",
'i', ironBars,
'c', ItemComponent.getItemStack(EnumComponentType.CAPACITIVE_CRYSTAL),
'r', Items.REDSTONE));
WarpDrive.register(new ShapedOreRecipe(groupMachines,
new ItemStack(WarpDrive.itemElectromagneticCell[EnumTier.ADVANCED.getIndex()], 2), "iei", "iei", "gcg",
'e', WarpDrive.itemElectromagneticCell[EnumTier.BASIC.getIndex()],
'i', ironBars,
'g', Items.GOLD_NUGGET,
'c', ItemComponent.getItemStack(EnumComponentType.CAPACITIVE_CRYSTAL)));
WarpDrive.register(new ShapedOreRecipe(groupMachines,
new ItemStack(WarpDrive.itemElectromagneticCell[EnumTier.SUPERIOR.getIndex()], 2), "geg", "geg", "gcg",
'e', WarpDrive.itemElectromagneticCell[EnumTier.ADVANCED.getIndex()],
'g', Items.GOLD_NUGGET,
'c', ItemComponent.getItemStack(EnumComponentType.CAPACITIVE_CRYSTAL)));
// Plasma torch
WarpDrive.register(new ShapedOreRecipe(groupTools,
WarpDrive.itemPlasmaTorch[EnumTier.BASIC.getIndex()], false, "tcr", "mgb", "i ",
't', WarpDrive.itemElectromagneticCell[EnumTier.BASIC.getIndex()],
'c', ItemComponent.getItemStack(EnumComponentType.ACTIVATED_CARBON),
'r', Items.BLAZE_ROD,
'm', ItemComponent.getItemStack(EnumComponentType.MOTOR),
'g', "ingotGold",
'b', Blocks.STONE_BUTTON,
'i', Items.IRON_INGOT));
// Accelerator control point
WarpDrive.register(new ShapedOreRecipe(groupMachines,

View file

@ -446,6 +446,12 @@ public class WarpDriveConfig {
public static final double ACCELERATOR_THRESHOLD_DEFAULT = 0.95D;
public static int ACCELERATOR_MAX_PARTICLE_BUNCHES = 20;
// Electromagnetic cell
public static int[] ELECTROMAGNETIC_CELL_CAPACITY_BY_TIER = { 16000, 500, 1000, 2000 };
// Plasma torch
public static int[] PLASMA_TORCH_CAPACITY_BY_TIER = { 16000, 200, 400, 800 };
@Nonnull
public static Block getBlockOrFire(@Nonnull final String registryName) {
try {

View file

@ -8,14 +8,14 @@ import net.minecraft.util.IStringSerializable;
public enum EnumAirTankTier implements IStringSerializable {
CANISTER ("canister", 0, EnumRarity.COMMON ),
BASIC ("basic" , 1, EnumRarity.COMMON ),
ADVANCED ("advanced", 2, EnumRarity.UNCOMMON),
SUPERIOR ("superior", 3, EnumRarity.RARE );
CANISTER ("canister", 0, EnumTier.BASIC ),
BASIC ("basic" , 1, EnumTier.BASIC ),
ADVANCED ("advanced", 2, EnumTier.ADVANCED),
SUPERIOR ("superior", 3, EnumTier.SUPERIOR);
private final String name;
private final int index;
private final EnumRarity enumRarity;
private final EnumTier enumTier;
// cached values
public static final int length;
@ -29,10 +29,10 @@ public enum EnumAirTankTier implements IStringSerializable {
}
}
EnumAirTankTier(final String name, final int index, final EnumRarity enumRarity) {
EnumAirTankTier(final String name, final int index, final EnumTier enumTier) {
this.name = name;
this.index = index;
this.enumRarity = enumRarity;
this.enumTier = enumTier;
}
@Nonnull
@ -49,7 +49,11 @@ public enum EnumAirTankTier implements IStringSerializable {
return index;
}
public EnumTier getTier(){
return enumTier;
}
public EnumRarity getRarity() {
return enumRarity;
return enumTier.getRarity();
}
}

View file

@ -4,11 +4,13 @@ import cr0s.warpdrive.Commons;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.api.IItemBase;
import cr0s.warpdrive.client.ClientProxy;
import cr0s.warpdrive.data.EnumTier;
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;
@ -23,11 +25,14 @@ import java.util.List;
public class ItemAbstractBase extends Item implements IItemBase {
public ItemAbstractBase(final String registryName) {
protected final EnumTier enumTier;
public ItemAbstractBase(final String registryName, final EnumTier enumTier) {
super();
setRegistryName(registryName);
this.enumTier = enumTier;
setCreativeTab(WarpDrive.creativeTabMain);
setRegistryName(registryName);
WarpDrive.register(this);
}
@ -48,6 +53,17 @@ public class ItemAbstractBase extends Item implements IItemBase {
return ClientProxy.getModelResourceLocation(itemStack);
}
@Nonnull
@Override
public EnumTier getTier(final ItemStack itemStack) {
return enumTier;
}
@Nonnull
public EnumRarity getRarity(final ItemStack itemStack) {
return getTier(itemStack).getRarity();
}
@Override
@SideOnly(Side.CLIENT)
public void addInformation(@Nonnull final ItemStack itemStack, @Nullable World world,

View file

@ -5,7 +5,6 @@ import cr0s.warpdrive.config.WarpDriveConfig;
import cr0s.warpdrive.data.EnumAirTankTier;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
@ -16,7 +15,7 @@ public class ItemAirTank extends ItemAbstractBase implements IAirContainerItem {
protected EnumAirTankTier enumAirTankTier;
public ItemAirTank(final String registryName, final EnumAirTankTier enumAirTankTier) {
super(registryName);
super(registryName, enumAirTankTier.getTier());
this.enumAirTankTier = enumAirTankTier;
setMaxDamage(WarpDriveConfig.BREATHING_AIR_TANK_CAPACITY_BY_TIER[enumAirTankTier.getIndex()]);
@ -30,12 +29,6 @@ public class ItemAirTank extends ItemAbstractBase implements IAirContainerItem {
return;
}
list.add(new ItemStack(this, 1, 0));
}
@Nonnull
@Override
public EnumRarity getRarity(@Nonnull final ItemStack itemStack) {
return enumAirTankTier.getRarity();
list.add(new ItemStack(this, 1, getMaxDamage(null)));
}

View file

@ -4,6 +4,7 @@ import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.api.IAirContainerItem;
import cr0s.warpdrive.block.energy.BlockCapacitor;
import cr0s.warpdrive.data.EnumComponentType;
import cr0s.warpdrive.data.EnumTier;
import javax.annotation.Nonnull;
@ -23,8 +24,8 @@ public class ItemComponent extends ItemAbstractBase implements IAirContainerItem
private static ItemStack[] itemStackCache;
public ItemComponent(final String registryName) {
super(registryName);
public ItemComponent(final String registryName, final EnumTier enumTier) {
super(registryName, enumTier);
setHasSubtypes(true);
setTranslationKey("warpdrive.component.malformed");

View file

@ -6,6 +6,8 @@ import cr0s.warpdrive.api.IParticleContainerItem;
import cr0s.warpdrive.api.Particle;
import cr0s.warpdrive.api.ParticleRegistry;
import cr0s.warpdrive.api.ParticleStack;
import cr0s.warpdrive.config.WarpDriveConfig;
import cr0s.warpdrive.data.EnumTier;
import cr0s.warpdrive.data.Vector3;
import java.util.List;
@ -32,12 +34,12 @@ import net.minecraftforge.fml.relauncher.SideOnly;
public class ItemElectromagneticCell extends ItemAbstractBase implements IParticleContainerItem {
public ItemElectromagneticCell(final String registryName) {
super(registryName);
public ItemElectromagneticCell(final String registryName, final EnumTier enumTier) {
super(registryName, enumTier);
setMaxDamage(0);
setMaxStackSize(1);
setTranslationKey("warpdrive.atomic.electromagnetic_cell");
setTranslationKey("warpdrive.atomic.electromagnetic_cell." + enumTier.getName());
setHasSubtypes(true);
addPropertyOverride(new ResourceLocation(WarpDrive.MODID, "fill"), new IItemPropertyGetter() {
@ -68,7 +70,7 @@ public class ItemElectromagneticCell extends ItemAbstractBase implements IPartic
}
public static ItemStack getItemStackNoCache(final Particle particle, final int amount) {
final ItemStack itemStack = new ItemStack(WarpDrive.itemElectromagneticCell, 1, 0);
final ItemStack itemStack = new ItemStack(WarpDrive.itemElectromagneticCell[EnumTier.BASIC.getIndex()], 1, 0);
ParticleStack particleStack = null;
if (particle != null && amount != 0) {
particleStack = new ParticleStack(particle, amount);
@ -176,7 +178,7 @@ public class ItemElectromagneticCell extends ItemAbstractBase implements IPartic
@Override
public int getCapacity(final ItemStack container) {
return 1000;
return WarpDriveConfig.ELECTROMAGNETIC_CELL_CAPACITY_BY_TIER[enumTier.getIndex()];
}
@Override

View file

@ -6,6 +6,7 @@ import cr0s.warpdrive.block.forcefield.BlockForceFieldProjector;
import cr0s.warpdrive.block.forcefield.BlockForceFieldRelay;
import cr0s.warpdrive.data.EnumComponentType;
import cr0s.warpdrive.data.EnumForceFieldShape;
import cr0s.warpdrive.data.EnumTier;
import java.util.List;
@ -32,8 +33,8 @@ public class ItemForceFieldShape extends ItemAbstractBase {
private static ItemStack[] itemStackCache;
public ItemForceFieldShape(final String registryName) {
super(registryName);
public ItemForceFieldShape(final String registryName, final EnumTier enumTier) {
super(registryName, enumTier);
setHasSubtypes(true);
setTranslationKey("warpdrive.force_field.shape");

View file

@ -6,6 +6,7 @@ import cr0s.warpdrive.block.forcefield.BlockForceFieldProjector;
import cr0s.warpdrive.block.forcefield.BlockForceFieldRelay;
import cr0s.warpdrive.data.EnumComponentType;
import cr0s.warpdrive.data.EnumForceFieldUpgrade;
import cr0s.warpdrive.data.EnumTier;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@ -31,8 +32,8 @@ public class ItemForceFieldUpgrade extends ItemAbstractBase {
private static ItemStack[] itemStackCache;
public ItemForceFieldUpgrade(final String registryName) {
super(registryName);
public ItemForceFieldUpgrade(final String registryName, final EnumTier enumTier) {
super(registryName, enumTier);
setHasSubtypes(true);
setTranslationKey("warpdrive.force_field.upgrade");

View file

@ -2,6 +2,8 @@ package cr0s.warpdrive.item;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.config.WarpDriveConfig;
import cr0s.warpdrive.data.EnumTier;
import ic2.api.reactor.IReactor;
import ic2.api.reactor.IReactorComponent;
@ -18,8 +20,8 @@ public class ItemIC2reactorLaserFocus extends ItemAbstractBase implements IReact
private static final int[] xOffset = { -1, 0, 0, 1 };
private static final int[] yOffset = { 0, -1, 1, 0 };
public ItemIC2reactorLaserFocus(final String registryName) {
super(registryName);
public ItemIC2reactorLaserFocus(final String registryName, final EnumTier enumTier) {
super(registryName, enumTier);
setMaxDamage(WarpDriveConfig.IC2_REACTOR_MAX_HEAT_STORED);
setTranslationKey("warpdrive.energy.IC2reactorLaserFocus");

View file

@ -0,0 +1,266 @@
package cr0s.warpdrive.item;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.api.IParticleContainerItem;
import cr0s.warpdrive.api.Particle;
import cr0s.warpdrive.api.ParticleRegistry;
import cr0s.warpdrive.api.ParticleStack;
import cr0s.warpdrive.config.WarpDriveConfig;
import cr0s.warpdrive.data.EnumTier;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.Blocks;
import net.minecraft.item.IItemPropertyGetter;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class ItemPlasmaTorch extends ItemAbstractBase implements IParticleContainerItem {
public ItemPlasmaTorch(final String registryName, final EnumTier enumTier) {
super(registryName, enumTier);
setMaxDamage(0);
setMaxStackSize(1);
setTranslationKey("warpdrive.tool.plasma_torch." + enumTier.getName());
addPropertyOverride(new ResourceLocation(WarpDrive.MODID, "fill"), new IItemPropertyGetter() {
@SideOnly(Side.CLIENT)
@Override
public float apply(@Nonnull ItemStack itemStack, @Nullable World world, @Nullable EntityLivingBase entity) {
final ParticleStack particleStack = getParticleStack(itemStack);
if (particleStack != null) {
return (float) particleStack.getAmount() / getCapacity(itemStack);
}
return 0.0F;
}
});
}
@Nonnull
@Override
public ModelResourceLocation getModelResourceLocation(ItemStack itemStack) {
String variant = "empty";
final ParticleStack particleStack = getParticleStack(itemStack);
if (particleStack != null) {
variant = particleStack.getTranslationKey().replace("warpdrive.particle.", "");
}
ResourceLocation resourceLocation = getRegistryName();
assert resourceLocation != null;
resourceLocation = new ResourceLocation(resourceLocation.getNamespace(), resourceLocation.getPath() + "-" + variant);
return new ModelResourceLocation(resourceLocation, "inventory");
}
public static ItemStack getItemStackNoCache(final Particle particle, final int amount) {
final ItemStack itemStack = new ItemStack(WarpDrive.itemElectromagneticCell[EnumTier.BASIC.getIndex()], 1, 0);
ParticleStack particleStack = null;
if (particle != null && amount != 0) {
particleStack = new ParticleStack(particle, amount);
final NBTTagCompound tagCompound = new NBTTagCompound();
tagCompound.setTag(IParticleContainerItem.TAG_PARTICLE, particleStack.writeToNBT(new NBTTagCompound()));
itemStack.setTagCompound(tagCompound);
}
updateDamageLevel(itemStack, particleStack);
return itemStack;
}
@Override
public void getSubItems(@Nonnull final CreativeTabs creativeTab, @Nonnull final NonNullList<ItemStack> list) {
if (!isInCreativeTab(creativeTab)) {
return;
}
list.add(getItemStackNoCache(null, 0));
list.add(getItemStackNoCache(ParticleRegistry.ION, 1000));
list.add(getItemStackNoCache(ParticleRegistry.PROTON, 1000));
list.add(getItemStackNoCache(ParticleRegistry.ANTIMATTER, 1000));
list.add(getItemStackNoCache(ParticleRegistry.STRANGE_MATTER, 1000));
// list.add(getItemStackNoCache(ParticleRegistry.TACHYONS, 1000));
}
@Override
public boolean hasContainerItem(final ItemStack stack) {
return true;
}
@Nonnull
@Override
public Item getContainerItem() {
return Item.getItemFromBlock(Blocks.FIRE);
}
@Nonnull
@Override
public ItemStack getContainerItem(@Nonnull final ItemStack itemStackFilled) {
final ParticleStack particleStack = getParticleStack(itemStackFilled);
if (particleStack != null) {
final int amount = particleStack.getAmount() - getAmountToConsume(itemStackFilled);
if (amount <= 0) {
return getItemStackNoCache(null, 0);
}
return getItemStackNoCache(particleStack.getParticle(), amount);
}
return new ItemStack(Blocks.FIRE);
}
@Override
public void setAmountToConsume(@Nonnull final ItemStack itemStack, final int amountToConsume) {
final ParticleStack particleStack = getParticleStack(itemStack);
if (particleStack == null || particleStack.getParticle() == null) {
return;
}
NBTTagCompound tagCompound = itemStack.getTagCompound();
if (tagCompound == null) {
tagCompound = new NBTTagCompound();
}
tagCompound.setInteger(IParticleContainerItem.TAG_AMOUNT_TO_CONSUME, amountToConsume);
}
private int getAmountToConsume(@Nonnull final ItemStack itemStack) {
final NBTTagCompound tagCompound = itemStack.getTagCompound();
if (tagCompound != null) {
return tagCompound.getInteger(IParticleContainerItem.TAG_AMOUNT_TO_CONSUME);
}
return 0;
}
private static int getDamageLevel(@Nonnull final ItemStack itemStack, final ParticleStack particleStack) {
if (!(itemStack.getItem() instanceof ItemPlasmaTorch)) {
WarpDrive.logger.error(String.format("Invalid ItemStack passed, expecting ItemPlasmaTorch: %s",
itemStack));
return itemStack.getItemDamage();
}
if (particleStack == null || particleStack.getParticle() == null) {
return 0;
}
final ItemPlasmaTorch itemPlasmaTorch = (ItemPlasmaTorch) itemStack.getItem();
final int type = particleStack.getParticle().getColorIndex() % 5;
final double ratio = particleStack.getAmount() / (double) itemPlasmaTorch.getCapacity(itemStack);
final int offset = (ratio < 0.2) ? 0 : (ratio < 0.4) ? 1 : (ratio < 0.6) ? 2 : (ratio < 0.8) ? 3 : (ratio < 1.0) ? 4 : 5;
return (1 + type * 6 + offset);
}
private static void updateDamageLevel(@Nonnull final ItemStack itemStack, final ParticleStack particleStack) {
itemStack.setItemDamage(getDamageLevel(itemStack, particleStack));
}
@Override
public ParticleStack getParticleStack(@Nonnull final ItemStack itemStack) {
if (itemStack.getItem() != this) {
return null;
}
final NBTTagCompound tagCompound = itemStack.getTagCompound();
if (tagCompound == null) {
return null;
}
if (!tagCompound.hasKey(IParticleContainerItem.TAG_PARTICLE)) {
return null;
}
return ParticleStack.loadFromNBT(tagCompound.getCompoundTag(IParticleContainerItem.TAG_PARTICLE));
}
@Override
public int getCapacity(ItemStack container) {
return WarpDriveConfig.PLASMA_TORCH_CAPACITY_BY_TIER[enumTier.getIndex()];
}
@Override
public boolean isEmpty(final ItemStack itemStack) {
final ParticleStack particleStack = getParticleStack(itemStack);
return particleStack == null || particleStack.isEmpty();
}
@Override
public int fill(final ItemStack itemStack, final ParticleStack resource, final boolean doFill) {
ParticleStack particleStack = getParticleStack(itemStack);
if (particleStack == null || particleStack.getParticle() == null) {
particleStack = new ParticleStack(resource.getParticle(), 0);
} else if (!particleStack.isParticleEqual(resource) || particleStack.getAmount() >= getCapacity(itemStack)) {
return 0;
}
final int transfer = Math.min(resource.getAmount(), getCapacity(itemStack) - particleStack.getAmount());
if (doFill) {
particleStack.fill(transfer);
final NBTTagCompound tagCompound = itemStack.hasTagCompound() ? itemStack.getTagCompound() : new NBTTagCompound();
assert tagCompound != null;
tagCompound.setTag(IParticleContainerItem.TAG_PARTICLE, particleStack.writeToNBT(new NBTTagCompound()));
if (!itemStack.hasTagCompound()) {
itemStack.setTagCompound(tagCompound);
}
updateDamageLevel(itemStack, particleStack);
}
return transfer;
}
@Override
public ParticleStack drain(final ItemStack itemStack, final ParticleStack resource, final boolean doDrain) {
final ParticleStack particleStack = getParticleStack(itemStack);
if (particleStack == null || particleStack.getParticle() == null) {
return null;
}
if (!particleStack.isParticleEqual(resource) || particleStack.getAmount() <= 0) {
return null;
}
final int transfer = Math.min(resource.getAmount(), particleStack.getAmount());
if (doDrain) {
particleStack.fill(-transfer);
final NBTTagCompound tagCompound = itemStack.hasTagCompound() ? itemStack.getTagCompound() : new NBTTagCompound();
assert tagCompound != null;
tagCompound.setTag(IParticleContainerItem.TAG_PARTICLE, particleStack.writeToNBT(new NBTTagCompound()));
if (!itemStack.hasTagCompound()) {
itemStack.setTagCompound(tagCompound);
}
updateDamageLevel(itemStack, particleStack);
}
return resource.copy(transfer);
}
@Override
@SideOnly(Side.CLIENT)
public void addInformation(@Nonnull final ItemStack itemStack, @Nullable World world,
@Nonnull final List<String> list, @Nullable final ITooltipFlag advancedItemTooltips) {
super.addInformation(itemStack, world, list, advancedItemTooltips);
if (!(itemStack.getItem() instanceof ItemPlasmaTorch)) {
WarpDrive.logger.error(String.format("Invalid ItemStack passed, expecting ItemPlasmaTorch: %s",
itemStack));
return;
}
final ItemPlasmaTorch itemPlasmaTorch = (ItemPlasmaTorch) itemStack.getItem();
final ParticleStack particleStack = itemPlasmaTorch.getParticleStack(itemStack);
final String tooltip;
if (particleStack == null || particleStack.getParticle() == null) {
tooltip = new TextComponentTranslation("item.warpdrive.tool.plasma_torch.tooltip.empty").getFormattedText();
Commons.addTooltip(list, tooltip);
} else {
final Particle particle = particleStack.getParticle();
tooltip = new TextComponentTranslation("item.warpdrive.tool.plasma_torch.tooltip.filled",
particleStack.getAmount(), particle.getLocalizedName()).getFormattedText();
Commons.addTooltip(list, tooltip);
final String particleTooltip = particle.getLocalizedTooltip();
if (!particleTooltip.isEmpty()) {
Commons.addTooltip(list, particleTooltip);
}
}
}
}

View file

@ -2,6 +2,7 @@ package cr0s.warpdrive.item;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.data.EnumTier;
import java.util.List;
import java.util.Random;
@ -25,8 +26,8 @@ public class ItemShipToken extends ItemAbstractBase {
private static ItemStack[] itemStackCache;
private static final int[] VALID_METADATAS = { 0, 1, 2, 3, 4, 5, 10, 11, 12, 13, 14, 15, 20, 21, 22, 23, 24, 25, 30, 31, 32, 33, 34, 35, 40, 41, 42, 43, 44, 45 };
public ItemShipToken(final String registryName) {
super(registryName);
public ItemShipToken(final String registryName, final EnumTier enumTier) {
super(registryName, enumTier);
setHasSubtypes(true);
setTranslationKey("warpdrive.tool.ship_token");

View file

@ -7,6 +7,7 @@ import cr0s.warpdrive.api.IControlChannel;
import cr0s.warpdrive.api.IVideoChannel;
import cr0s.warpdrive.api.IWarpTool;
import cr0s.warpdrive.block.energy.BlockCapacitor;
import cr0s.warpdrive.data.EnumTier;
import cr0s.warpdrive.data.SoundEvents;
import javax.annotation.Nonnull;
@ -44,8 +45,8 @@ public class ItemTuningDriver extends ItemAbstractBase implements IWarpTool {
public static final int MODE_BEAM_FREQUENCY = 1;
public static final int MODE_CONTROL_CHANNEL = 2;
public ItemTuningDriver(final String registryName) {
super(registryName);
public ItemTuningDriver(final String registryName, final EnumTier enumTier) {
super(registryName, enumTier);
setMaxDamage(0);
setCreativeTab(WarpDrive.creativeTabMain);

View file

@ -6,6 +6,7 @@ import cr0s.warpdrive.api.IControlChannel;
import cr0s.warpdrive.api.IVideoChannel;
import cr0s.warpdrive.api.IWarpTool;
import cr0s.warpdrive.block.energy.BlockCapacitor;
import cr0s.warpdrive.data.EnumTier;
import cr0s.warpdrive.data.SoundEvents;
import javax.annotation.Nonnull;
@ -37,8 +38,8 @@ import net.minecraftforge.fml.relauncher.SideOnly;
public class ItemTuningFork extends ItemAbstractBase implements IWarpTool {
public ItemTuningFork(final String registryName) {
super(registryName);
public ItemTuningFork(final String registryName, final EnumTier enumTier) {
super(registryName, enumTier);
setMaxDamage(0);
setMaxStackSize(1);

View file

@ -4,6 +4,7 @@ import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.api.IBreathingHelmet;
import cr0s.warpdrive.api.IItemBase;
import cr0s.warpdrive.client.ClientProxy;
import cr0s.warpdrive.data.EnumTier;
import javax.annotation.Nonnull;
@ -12,6 +13,7 @@ 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;
@ -22,13 +24,16 @@ public class ItemWarpArmor extends ItemArmor implements IItemBase, IBreathingHel
public static final String[] suffixes = { "boots", "leggings", "chestplate", "helmet" };
public ItemWarpArmor(final String registryName, final ArmorMaterial armorMaterial, final int renderIndex, final EntityEquipmentSlot entityEquipmentSlot) {
protected final EnumTier enumTier;
public ItemWarpArmor(final String registryName, final EnumTier enumTier,
final ArmorMaterial armorMaterial, final int renderIndex, final EntityEquipmentSlot entityEquipmentSlot) {
super(armorMaterial, renderIndex, entityEquipmentSlot);
this.enumTier = enumTier;
setTranslationKey("warpdrive.armor." + suffixes[entityEquipmentSlot.getIndex()]);
setRegistryName(registryName);
setCreativeTab(WarpDrive.creativeTabMain);
setRegistryName(registryName);
WarpDrive.register(this);
}
@ -38,6 +43,17 @@ public class ItemWarpArmor extends ItemArmor implements IItemBase, IBreathingHel
return "warpdrive:textures/armor/warp_armor_" + (armorType == EntityEquipmentSlot.LEGS ? 2 : 1) + ".png";
}
@Nonnull
@Override
public EnumTier getTier(final ItemStack itemStack) {
return enumTier;
}
@Nonnull
public EnumRarity getRarity(final ItemStack itemStack) {
return getTier(itemStack).getRarity();
}
@Override
public void onEntityExpireEvent(final EntityItem entityItem, final ItemStack itemStack) {
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 867 B