diff options
author | Jordan Byrne <draknyte1@hotmail.com> | 2018-03-04 17:39:33 +1000 |
---|---|---|
committer | Jordan Byrne <draknyte1@hotmail.com> | 2018-03-04 17:39:33 +1000 |
commit | 9366db518e680fd3ed618826a08e33bcac573ab8 (patch) | |
tree | 7c2e9b35bbc98d4217bddc601ff1956b2a57fa59 /src/Java/gtPlusPlus/core/item | |
parent | a06b75f0761681ebf57b142b30a5eb4d3ee0fe49 (diff) | |
download | GT5-Unofficial-9366db518e680fd3ed618826a08e33bcac573ab8.tar.gz GT5-Unofficial-9366db518e680fd3ed618826a08e33bcac573ab8.tar.bz2 GT5-Unofficial-9366db518e680fd3ed618826a08e33bcac573ab8.zip |
+ Added dusts that can decay.
+ Added more Cyclotron Recipes.
% Tweaked Cyclotron tooltip.
% Tweaked creative energy buffer textures.
Diffstat (limited to 'src/Java/gtPlusPlus/core/item')
-rw-r--r-- | src/Java/gtPlusPlus/core/item/ModItems.java | 5 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/core/item/base/BaseItemTickable.java | 248 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/core/item/materials/DustDecayable.java | 61 |
3 files changed, 314 insertions, 0 deletions
diff --git a/src/Java/gtPlusPlus/core/item/ModItems.java b/src/Java/gtPlusPlus/core/item/ModItems.java index 8066409baf..a20686cede 100644 --- a/src/Java/gtPlusPlus/core/item/ModItems.java +++ b/src/Java/gtPlusPlus/core/item/ModItems.java @@ -41,6 +41,7 @@ import gtPlusPlus.core.item.general.throwables.ItemHydrofluoricAcidPotion; import gtPlusPlus.core.item.general.throwables.ItemSulfuricAcidPotion; import gtPlusPlus.core.item.init.ItemsFoods; import gtPlusPlus.core.item.init.ItemsMultiTools; +import gtPlusPlus.core.item.materials.DustDecayable; import gtPlusPlus.core.item.tool.misc.SandstoneHammer; import gtPlusPlus.core.item.tool.staballoy.*; import gtPlusPlus.core.lib.CORE; @@ -182,6 +183,8 @@ public final class ModItems { public static Item dustCalciumCarbonate; public static Item dustLi2CO3CaOH2; public static Item dustLi2BeF4; + + public static Item dustNeptunium238; public static Item dustAer; public static Item dustIgnis; @@ -680,6 +683,8 @@ public final class ModItems { if ((ItemUtils.getItemStackOfAmountFromOreDictNoBroken("plateDoubleEuropium", 1) == null) && CORE.ConfigSwitches.enableCustom_Pipes){ itemDoublePlateEuropium = new BaseItemPlateDouble(MaterialUtils.generateMaterialFromGtENUM(Materials.Europium)); } + + dustNeptunium238 = new DustDecayable("dustNeptunium238", Utils.rgbtoHexValue(175, 240, 75), 50640, "Result: Plutonium 238 ("+StringUtils.superscript("238Pu")+")", CORE.GT_Tooltip_Radioactive, NUCLIDE.getInstance().PLUTONIUM238.getDust(1).getItem()); itemBoilerChassis = new ItemBoilerChassis(); itemDehydratorCoilWire = new ItemDehydratorCoilWire(); diff --git a/src/Java/gtPlusPlus/core/item/base/BaseItemTickable.java b/src/Java/gtPlusPlus/core/item/base/BaseItemTickable.java new file mode 100644 index 0000000000..501b881f9f --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/BaseItemTickable.java @@ -0,0 +1,248 @@ +package gtPlusPlus.core.item.base; + +import java.util.List; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.NBTUtils; + +public class BaseItemTickable extends CoreItem { + + public final String descriptionString; + public final String descriptionString2; + public final int itemColour; + public final int maxTicks; + public final boolean twoRenderPasses; + + public IIcon[] mIcon = new IIcon[2]; + + public BaseItemTickable(boolean twoPass, final String unlocalName, final int colour, final int maxTicks) { + this(twoPass, unlocalName, colour, maxTicks, ""); + } + + public BaseItemTickable(boolean twoPass, final String unlocalName, final int colour, final int maxTicks, final String Description) { + this(twoPass, unlocalName, colour, maxTicks, "", Description); + } + + public BaseItemTickable(boolean twoPass, final String unlocalName, final int colour, final int maxTicks, final String Description, final String Description2) { + super(unlocalName, AddToCreativeTab.tabMisc, 1, 999999999, Description, EnumRarity.epic, EnumChatFormatting.DARK_RED, true, null); + this.itemColour = colour; + this.descriptionString = Description; + this.descriptionString2 = Description2; + this.maxTicks = maxTicks; + this.twoRenderPasses = twoPass; + //setGregtechItemList(); + } + + @Override + public void onUpdate(final ItemStack iStack, final World world, final Entity entityHolding, final int p_77663_4_, final boolean p_77663_5_) { + if (world == null || iStack == null) { + return; + } + tickItemTag(iStack); + } + + /*private final boolean setGregtechItemList() { + ItemList.Component_LavaFilter.set(this); + return ItemList.Component_LavaFilter.get(1) != null ? true : false; + }*/ + + /** + * + * Handle Custom Rendering + * + */ + + @Override + @SideOnly(Side.CLIENT) + public boolean requiresMultipleRenderPasses(){ + return this.twoRenderPasses; + } + + @Override + public int getColorFromItemStack(final ItemStack stack, final int renderPass) { + if (renderPass == 1 && this.twoRenderPasses){ + return Utils.rgbtoHexValue(255, 255, 255); + } + return this.itemColour; + } + + @Override + public IIcon getIconFromDamageForRenderPass(final int damage, final int pass) { + if (this.twoRenderPasses) { + if(pass == 0) { + return this.mIcon[0]; + } + return this.mIcon[1]; + } + return this.mIcon[0]; + } + + @Override + public void registerIcons(final IIconRegister i) { + + if (this.twoRenderPasses){ + this.mIcon[0] = i.registerIcon(CORE.MODID + ":" + this.getUnlocalizedName()); + this.mIcon[1] = i.registerIcon(CORE.MODID + ":" + this.getUnlocalizedName() + "_OVERLAY"); + } + else { + this.mIcon[0] = i.registerIcon(CORE.MODID + ":" + this.getUnlocalizedName()); + //this.overlay = i.registerIcon(getCorrectTextures() + "_OVERLAY"); + } + } + + + private boolean createNBT(ItemStack rStack){ + final NBTTagCompound tagMain = new NBTTagCompound(); + final NBTTagCompound tagNBT = new NBTTagCompound(); + tagNBT.setLong("Tick", 0); + tagNBT.setLong("maxTick", this.maxTicks); + tagNBT.setBoolean("isActive", true); + tagMain.setTag("TickableItem", tagNBT); + rStack.setTagCompound(tagMain); + return true; + } + + public final long getFilterDamage(final ItemStack aStack) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("TickableItem"); + if (aNBT != null) { + return aNBT.getLong("Tick"); + } + } + else { + createNBT(aStack); + } + return 0L; + } + + public final boolean setFilterDamage(final ItemStack aStack, final long aDamage) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("TickableItem"); + if (aNBT != null) { + aNBT.setLong("Tick", aDamage); + return true; + } + } + else { + createNBT(aStack); + } + return false; + } + + public final boolean getIsActive(final ItemStack aStack) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("TickableItem"); + if (aNBT != null) { + return aNBT.getBoolean("isActive"); + } + } + else { + createNBT(aStack); + } + return true; + } + + public final boolean setIsActive(final ItemStack aStack, final boolean active) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("TickableItem"); + if (aNBT != null) { + aNBT.setBoolean("isActive", active); + return true; + } + } + else { + createNBT(aStack); + } + return false; + } + + public final boolean tickItemTag(ItemStack aStack) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + //Done Ticking + if (maxTicks-getFilterDamage(aStack) <= 0) { + setIsActive(aStack, false); + } + if (getIsActive(aStack)) { + aNBT = aNBT.getCompoundTag("TickableItem"); + if (aNBT != null) { + aNBT.setLong("Tick", getFilterDamage(aStack)+1); + return true; + } + } + } + else { + createNBT(aStack); + } + return false; + } + + @Override + public double getDurabilityForDisplay(ItemStack stack) { + if (stack.getTagCompound() == null){ + createNBT(stack); + } + double currentDamage = getFilterDamage(stack); + double durabilitypercent = currentDamage / maxTicks; + return durabilitypercent; + } + + @SuppressWarnings("unchecked") + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) { + EnumChatFormatting durability = EnumChatFormatting.GRAY; + if (maxTicks-getFilterDamage(stack) > (maxTicks*0.8)){ + durability = EnumChatFormatting.GRAY; + } + else if (maxTicks-getFilterDamage(stack) > (maxTicks*0.6)){ + durability = EnumChatFormatting.GREEN; + } + else if (maxTicks-getFilterDamage(stack) > (maxTicks*0.4)){ + durability = EnumChatFormatting.YELLOW; + } + else if (maxTicks-getFilterDamage(stack) > (maxTicks*0.2)){ + durability = EnumChatFormatting.GOLD; + } + else if (maxTicks-getFilterDamage(stack) > 0){ + durability = EnumChatFormatting.RED; + } + list.add(durability+""+((maxTicks-getFilterDamage(stack))/20)+EnumChatFormatting.GRAY+" seconds until decay"); + + if ((this.descriptionString != "") || !this.descriptionString.equals("")){ + list.add(EnumChatFormatting.GRAY+this.descriptionString); + } + if ((this.descriptionString2 != "") || !this.descriptionString2.equals("")){ + list.add(EnumChatFormatting.GRAY+this.descriptionString2); + } + + //super.addInformation(stack, player, list, bool); + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + return true; + } + + +} + + diff --git a/src/Java/gtPlusPlus/core/item/materials/DustDecayable.java b/src/Java/gtPlusPlus/core/item/materials/DustDecayable.java new file mode 100644 index 0000000000..b7461a8558 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/materials/DustDecayable.java @@ -0,0 +1,61 @@ +package gtPlusPlus.core.item.materials; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +import gregtech.api.util.GT_OreDictUnificator; + +import gtPlusPlus.core.item.base.BaseItemTickable; +import gtPlusPlus.core.item.base.ore.BaseOreComponent.ComponentTypes; +import gtPlusPlus.core.util.minecraft.ItemUtils; + +public class DustDecayable extends BaseItemTickable { + + private final Item turnsIntoItem; + + public DustDecayable(String unlocal, int colour, int maxTicks, String desc1, String desc2, Item turnsInto) { + super(true, unlocal, colour, maxTicks, desc1, desc2); + this.turnsIntoItem = turnsInto; + GT_OreDictUnificator.registerOre(unlocal, ItemUtils.getSimpleStack(this)); + } + + @Override + public void registerIcons(IIconRegister reg) { + String gt = "gregtech" + ":" + "materialicons/"+"METALLIC"+"/" + ComponentTypes.DUSTIMPURE.getComponent(); + this.mIcon[0] = reg.registerIcon(gt); + String gt2 = "gregtech" + ":" + "materialicons/"+"METALLIC"+"/" + ComponentTypes.DUSTIMPURE.getComponent()+"_Overlay"; + this.mIcon[1] = reg.registerIcon(gt2); + } + + @Override + public void onUpdate(final ItemStack iStack, final World world, final Entity entityHolding, final int p_77663_4_, final boolean p_77663_5_) { + if (world == null || iStack == null) { + return; + } + if (!tickItemTag(iStack)) { + if (entityHolding instanceof EntityPlayer){ + ItemStack replacement = ItemUtils.getSimpleStack(turnsIntoItem); + //Logger.INFO("Replacing "+iStack.getDisplayName()+" with "+replacement.getDisplayName()+"."); + final ItemStack tempTransform = replacement; + if (iStack.stackSize == 64){ + tempTransform.stackSize=64; + ((EntityPlayer) entityHolding).inventory.addItemStackToInventory((tempTransform)); + for (int l=0;l<64;l++){ + ((EntityPlayer) entityHolding).inventory.consumeInventoryItem(this); + } + + } + else { + tempTransform.stackSize=1; + ((EntityPlayer) entityHolding).inventory.addItemStackToInventory((tempTransform)); + ((EntityPlayer) entityHolding).inventory.consumeInventoryItem(this); + } + } + } + } + +} |