diff options
author | Draknyte1 <Draknyte1@hotmail.com> | 2016-05-30 07:53:03 +1000 |
---|---|---|
committer | Draknyte1 <Draknyte1@hotmail.com> | 2016-05-30 07:53:03 +1000 |
commit | 15a270851304fd3204bfbc2cf2c6268f3a6b06c8 (patch) | |
tree | fc5d13969279acdac75c2922a93e9044101272c8 /src/Java/miscutil | |
parent | 9a1352dac23c09cb333edf7b2db7cce07c15ee91 (diff) | |
download | GT5-Unofficial-15a270851304fd3204bfbc2cf2c6268f3a6b06c8.tar.gz GT5-Unofficial-15a270851304fd3204bfbc2cf2c6268f3a6b06c8.tar.bz2 GT5-Unofficial-15a270851304fd3204bfbc2cf2c6268f3a6b06c8.zip |
+Cleaned up Helium Generator GUI
+Rewrote portions of the HG from scratch
Diffstat (limited to 'src/Java/miscutil')
9 files changed, 853 insertions, 449 deletions
diff --git a/src/Java/miscutil/core/block/HeliumGenerator.java b/src/Java/miscutil/core/block/HeliumGenerator.java index 0df56d0022..da3f3b8041 100644 --- a/src/Java/miscutil/core/block/HeliumGenerator.java +++ b/src/Java/miscutil/core/block/HeliumGenerator.java @@ -98,16 +98,16 @@ public class HeliumGenerator extends BlockContainer { int l = MathHelper.floor_double((double) (player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; if (l == 0) - machine.setFacing(2); + machine.setFacing((short) 2); if (l == 1) - machine.setFacing(5); + machine.setFacing((short) 5); if (l == 2) - machine.setFacing(3); + machine.setFacing((short) 3); if (l == 3) - machine.setFacing(4); + machine.setFacing((short) 4); } } diff --git a/src/Java/miscutil/core/gui/ContainerHeliumGenerator.java b/src/Java/miscutil/core/gui/ContainerHeliumGenerator.java index ae8e2d3176..8acf0313fd 100644 --- a/src/Java/miscutil/core/gui/ContainerHeliumGenerator.java +++ b/src/Java/miscutil/core/gui/ContainerHeliumGenerator.java @@ -1,95 +1,72 @@ package miscutil.core.gui; +import ic2.core.ContainerBase; +import ic2.core.slot.SlotInvSlot; + +import java.util.List; + import miscutil.core.tileentities.TileEntityHeliumGenerator; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.inventory.SlotFurnace; -import net.minecraft.item.ItemStack; - -public class ContainerHeliumGenerator extends Container { - private TileEntityHeliumGenerator tileThis; - public ContainerHeliumGenerator(InventoryPlayer player, TileEntityHeliumGenerator machine) +public class ContainerHeliumGenerator + extends ContainerBase<TileEntityHeliumGenerator> +{ + public short size; + + public ContainerHeliumGenerator(InventoryPlayer player, TileEntityHeliumGenerator machine) + { + super(machine); + this.addSlotToContainer(new SlotFurnace(player.player, machine, 2, 80, 35)); + this.size = machine.getReactorSize(); + int startX = 16; + int startY = 16; + int i = 0; + for (i = 0; i < 9; i++) { - this.tileThis = machine; - this.addSlotToContainer(new SlotFurnace(player.player, machine, 2, 80, 35)); - int i; - - for (i = 0; i < 3; ++i) - { - for (int j = 0; j < 9; ++j) - { - this.addSlotToContainer(new Slot(player, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); - } - } - - for (i = 0; i < 9; ++i) - { - this.addSlotToContainer(new Slot(player, i, 8 + i * 18, 142)); - } + int x = i % this.size; + int y = i / this.size; + + addSlotToContainer(new SlotInvSlot(machine.reactorSlot, i, startX + 18 * x, startY + 18 * y)); } - - public boolean canInteractWith(EntityPlayer player) + startX = 108; + startY = 16; + for (i = 9; i < 18; i++) { - return this.tileThis.isUseableByPlayer(player); + int x = i % this.size; + int y = (i-9) / this.size; + + addSlotToContainer(new SlotInvSlot(machine.reactorSlot, i, startX + 18 * x, startY + 18 * y)); } - - /** - * Called when a player shift-clicks on a slot. You must override this or you will crash when someone does that. - */ - public ItemStack transferStackInSlot(EntityPlayer player, int slotNumber) + for (i = 0; i < 3; ++i) { - ItemStack itemstack = null; - Slot slot = (Slot)this.inventorySlots.get(slotNumber); - - if (slot != null && slot.getHasStack()) + for (int j = 0; j < 9; ++j) { - ItemStack itemstack1 = slot.getStack(); - itemstack = itemstack1.copy(); - - if (slotNumber == 0) - { - if (!this.mergeItemStack(itemstack1, 1, 37, true)) - { - return null; - } - - slot.onSlotChange(itemstack1, itemstack); - } - else - { - if (slotNumber >= 1 && slotNumber < 28) - { - if (!this.mergeItemStack(itemstack1, 28, 37, false)) - { - return null; - } - } - else if (slotNumber >= 28 && slotNumber < 37 && !this.mergeItemStack(itemstack1, 1, 28, false)) - { - return null; - } - } - - if (itemstack1.stackSize == 0) - { - slot.putStack((ItemStack)null); - } - else - { - slot.onSlotChanged(); - } - - if (itemstack1.stackSize == itemstack.stackSize) - { - return null; - } - - slot.onPickupFromSlot(player, itemstack1); + this.addSlotToContainer(new Slot(player, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); } + } - return itemstack; + for (i = 0; i < 9; ++i) + { + this.addSlotToContainer(new Slot(player, i, 8 + i * 18, 142)); } + // addSlotToContainer(new SlotInvSlot(machine.coolantinputSlot, 0, 8, 25)); + //addSlotToContainer(new SlotInvSlot(machine.hotcoolinputSlot, 0, 188, 25)); + //addSlotToContainer(new SlotInvSlot(machine.coolantoutputSlot, 0, 8, 115)); + //addSlotToContainer(new SlotInvSlot(machine.hotcoolantoutputSlot, 0, 188, 115)); + } + + public List<String> getNetworkedFields() + { + List<String> ret = super.getNetworkedFields(); + + ret.add("heat"); + ret.add("maxHeat"); + ret.add("EmitHeat"); + /*ret.add("inputTank"); + ret.add("outputTank"); + ret.add("fluidcoolreactor");*/ + return ret; + } }
\ No newline at end of file diff --git a/src/Java/miscutil/core/gui/GUIHeliumGenerator.java b/src/Java/miscutil/core/gui/GUIHeliumGenerator.java index 6510f7480f..8188176c83 100644 --- a/src/Java/miscutil/core/gui/GUIHeliumGenerator.java +++ b/src/Java/miscutil/core/gui/GUIHeliumGenerator.java @@ -25,14 +25,16 @@ public class GUIHeliumGenerator extends GuiContainer /** * Draw the foreground layer for the GuiContainer (everything in front of the items) */ - protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) + @Override + protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { - String s = StatCollector.translateToLocal("container.helium_collector"); + String s = StatCollector.translateToLocal("container.radiation_collector"); this.fontRendererObj.drawString(s, this.xSize / 2 - this.fontRendererObj.getStringWidth(s) / 2, 6, 4210752); this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752); } - protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) + @Override + protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(collectorGuiTexture); diff --git a/src/Java/miscutil/core/handler/InvSlotRadiation.java b/src/Java/miscutil/core/handler/InvSlotRadiation.java new file mode 100644 index 0000000000..cafb71f00c --- /dev/null +++ b/src/Java/miscutil/core/handler/InvSlotRadiation.java @@ -0,0 +1,73 @@ +package miscutil.core.handler; + +import ic2.core.block.invslot.InvSlot; +import miscutil.core.tileentities.TileEntityHeliumGenerator; +import net.minecraft.item.ItemStack; + +public class InvSlotRadiation extends InvSlot +{ + public InvSlotRadiation(TileEntityHeliumGenerator base, String name1, int oldStartIndex1, int count) + { + super(base, name1, oldStartIndex1, InvSlot.Access.IO, count); + + setStackSizeLimit(1); + } + + public boolean accepts(ItemStack itemStack) + { + return ((TileEntityHeliumGenerator)this.base).isUsefulItem(itemStack, true); + } + + public int size() + { + return ((TileEntityHeliumGenerator)this.base).getReactorSize() * 6; + } + + public int rawSize() + { + return super.size(); + } + + public ItemStack get(int index) + { + return super.get(mapIndex(index)); + } + + public ItemStack get(int x, int y) + { + return super.get(y * 9 + x); + } + + public void put(int index, ItemStack content) + { + super.put(mapIndex(index), content); + } + + public void put(int x, int y, ItemStack content) + { + super.put(y * 9 + x, content); + } + + private int mapIndex(int index) + { + int size = size(); + int cols = size / 6; + if (index < size) + { + int row = index / cols; + int col = index % cols; + + return row * 9 + col; + } + index -= size; + int remCols = 9 - cols; + + int row = index / remCols; + int col = cols + index % remCols; + + return row * 9 + col; + } + + private final int rows = 6; + private final int maxCols = 9; +} diff --git a/src/Java/miscutil/core/item/ModItems.java b/src/Java/miscutil/core/item/ModItems.java index ab97e89edc..49abc71cbc 100644 --- a/src/Java/miscutil/core/item/ModItems.java +++ b/src/Java/miscutil/core/item/ModItems.java @@ -1,7 +1,8 @@ package miscutil.core.item; - +import static miscutil.core.creative.AddToCreativeTab.tabMisc; import static miscutil.core.lib.CORE.LOAD_ALL_CONTENT; import miscutil.core.creative.AddToCreativeTab; +import miscutil.core.item.effects.RarityUncommon; import miscutil.core.item.general.BufferCore; import miscutil.core.item.tool.misc.SandstoneHammer; import miscutil.core.item.tool.staballoy.StaballoyAxe; @@ -9,55 +10,50 @@ import miscutil.core.item.tool.staballoy.StaballoyPickaxe; import miscutil.core.lib.CORE; import miscutil.core.lib.LoadedMods; import miscutil.core.util.Utils; -import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.Item.ToolMaterial; import net.minecraftforge.common.util.EnumHelper; import cpw.mods.fml.common.registry.GameRegistry; - public final class ModItems { - private static int totalGenerated = 0; - /* A name for the material. This should be the same as the name of the variable we use to store the material (in this case "TUTORIAL"). - A harvest level for pickaxes. This is a value between 0 and 3 and defines which blocks can be mined with this tool. Its also possible to create blocks which need a higher harvest level than 3, but then you are not able to mine them with vanilla tools. - Common values for the harvest level are: - Wood/Gold Tool: 0 - Stone Tool: 1 - Iron Tool: 2 - Diamond Tool: 3 - The durability of the tool or sword. This value defines how often you can use a tool until it breaks. The tools always last one use longer than the entered value. - Common values for the durability are: - Wood Tool: 59 - Stone Tool: 131 - Iron Tool: 250 - Diamond Tool: 1561 - Gold Tool: 32 - The mining speed of the tool. This value defines how much faster you are with this tool than with your hand. - Common values for the mining speed are: - Wood Tool: 2.0F - Stone Tool: 4.0F - Iron Tool: 6.0F - Diamond Tool: 8.0F - Gold Tool: 12.0F - The damage versus Entites. This value is used to calculate the damage an entity takes if you hit it with this tool/sword. This value defines the basic damage to which different values are added, depending on the type of tool. A sword always causes 4 more damage than written in the ToolMaterial. So, if you want to create a sword which adds 10 damage to your normal damage, the value in the ToolMaterial needs to be 6.0F. Of course the values can be below zero. - Common values for the damage versus Entities are: - Wood Tool: 0.0F (Sword adds 4.0 damage) - Stone Tool: 1.0F (Sword adds 5.0 damage) - Iron Tool: 2.0F (Sword adds 6.0 damage) - Diamond Tool: 3.0F (Sword adds 7.0 damage) - Gold Tool: 0.0F (Sword adds 4.0 damage) - The enchantability of this tool. This value is quite complex to understand and I have to admit that I don't quite know how it is calculated. Basically you can say that a higher enchantability leads to better enchantements with the same amount of XP. - Common values for the enchantability are: - Wood Tool: 15 - Stone Tool: 5 - Iron Tool: 14 - Diamond Tool: 10 - Gold Tool: 22*/ - + /* A name for the material. This should be the same as the name of the variable we use to store the material (in this case "TUTORIAL"). +A harvest level for pickaxes. This is a value between 0 and 3 and defines which blocks can be mined with this tool. Its also possible to create blocks which need a higher harvest level than 3, but then you are not able to mine them with vanilla tools. +Common values for the harvest level are: +Wood/Gold Tool: 0 +Stone Tool: 1 +Iron Tool: 2 +Diamond Tool: 3 +The durability of the tool or sword. This value defines how often you can use a tool until it breaks. The tools always last one use longer than the entered value. +Common values for the durability are: +Wood Tool: 59 +Stone Tool: 131 +Iron Tool: 250 +Diamond Tool: 1561 +Gold Tool: 32 +The mining speed of the tool. This value defines how much faster you are with this tool than with your hand. +Common values for the mining speed are: +Wood Tool: 2.0F +Stone Tool: 4.0F +Iron Tool: 6.0F +Diamond Tool: 8.0F +Gold Tool: 12.0F +The damage versus Entites. This value is used to calculate the damage an entity takes if you hit it with this tool/sword. This value defines the basic damage to which different values are added, depending on the type of tool. A sword always causes 4 more damage than written in the ToolMaterial. So, if you want to create a sword which adds 10 damage to your normal damage, the value in the ToolMaterial needs to be 6.0F. Of course the values can be below zero. +Common values for the damage versus Entities are: +Wood Tool: 0.0F (Sword adds 4.0 damage) +Stone Tool: 1.0F (Sword adds 5.0 damage) +Iron Tool: 2.0F (Sword adds 6.0 damage) +Diamond Tool: 3.0F (Sword adds 7.0 damage) +Gold Tool: 0.0F (Sword adds 4.0 damage) +The enchantability of this tool. This value is quite complex to understand and I have to admit that I don't quite know how it is calculated. Basically you can say that a higher enchantability leads to better enchantements with the same amount of XP. +Common values for the enchantability are: +Wood Tool: 15 +Stone Tool: 5 +Iron Tool: 14 +Diamond Tool: 10 +Gold Tool: 22*/ //Tool Materials //public static ToolMaterial TUTORIAL = EnumHelper.addToolMaterial("TUTORIAL", harvestLevel, durability, miningSpeed, damageVsEntities, enchantability); - public static ToolMaterial tutMaterial = EnumHelper.addToolMaterial("BloodSteel Tool Material", 3, 200, 15.0F, 4.0F, 10); public static ToolMaterial STABALLOY = EnumHelper.addToolMaterial("Staballoy", 3, 2500, 7, 1.0F, 18); - + //EnderIO public static Item itemPlateSoularium; public static Item itemPlateRedstoneAlloy; @@ -67,310 +63,190 @@ public final class ModItems { public static Item itemPlateVibrantAlloy; public static Item itemPlateConductiveIron; public static Item itemPlateDarkSteel; - //Big Reactors public static Item itemPlateBlutonium; public static Item itemPlateCyanite; public static Item itemPlateLudicrite; - //Thaumcraft public static Item itemPlateVoidMetal; - //ExtraUtils public static Item itemPlateBedrockium; - //Pneumaticraft public static Item itemPlateCompressedIron; - //SimplyJetpacks public static Item itemPlateEnrichedSoularium; - //rfTools public static Item itemPlateDimensionShard; - //Blood Steel Items public static Item itemIngotBloodSteel; public static Item itemPlateBloodSteel; - //Staballoy public static Item itemStaballoyPickaxe; public static Item itemStaballoyAxe; public static Item itemPlateStaballoy; public static Item itemIngotStaballoy; - //Tools public static Item itemSandstoneHammer; - - //Machine Related public static Item itemBufferCore0; - //Material related public static Item itemStickyRubber; public static Item itemIngotBatteryAlloy; public static Item itemPlateBatteryAlloy; public static Item itemHeliumBlob; public static Item item_PLEASE_FACTOR_ME_4; - + //@SuppressWarnings("unused") public static final void init(){ //EnderIO Resources if (LoadedMods.EnderIO || LOAD_ALL_CONTENT){ - Utils.LOG_INFO("EnderIO Found - Loading Resources."); - GenerateItem(itemPlateSoularium, "itemPlateSoularium", AddToCreativeTab.tabMisc, 64, 0); - GenerateItem(itemPlateRedstoneAlloy, "itemPlateRedstoneAlloy", AddToCreativeTab.tabMisc, 64, 0); - GenerateItem(itemPlateElectricalSteel, "itemPlateElectricalSteel", AddToCreativeTab.tabMisc, 64, 0); - GenerateItem(itemPlatePulsatingIron, "itemPlatePulsatingIron", AddToCreativeTab.tabMisc, 64, 0); - GenerateItem(itemPlateEnergeticAlloy, "itemPlateEnergeticAlloy", AddToCreativeTab.tabMisc, 64, 0); - GenerateItem(itemPlateVibrantAlloy, "itemPlateVibrantAlloy", AddToCreativeTab.tabMisc, 64, 0); - GenerateItem(itemPlateConductiveIron, "itemPlateConductiveIron", AddToCreativeTab.tabMisc, 64, 0); - GenerateItem(itemPlateDarkSteel, "itemPlateDarkSteel", AddToCreativeTab.tabMisc, 64, 0); + Utils.LOG_INFO("EnderIO Found - Loading Resources."); + //Item Init + itemPlateSoularium = new Item().setUnlocalizedName("itemPlateSoularium").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateSoularium"); + itemPlateRedstoneAlloy = new Item().setUnlocalizedName("itemPlateRedstoneAlloy").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateRedstoneAlloy"); + itemPlateElectricalSteel = new Item().setUnlocalizedName("itemPlateElectricalSteel").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateElectricalSteel"); + itemPlatePulsatingIron = new Item().setUnlocalizedName("itemPlatePulsatingIron").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlatePulsatingIron"); + itemPlateEnergeticAlloy = new Item().setUnlocalizedName("itemPlateEnergeticAlloy").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateEnergeticAlloy"); + itemPlateVibrantAlloy = new Item().setUnlocalizedName("itemPlateVibrantAlloy").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateVibrantAlloy"); + itemPlateConductiveIron = new Item().setUnlocalizedName("itemPlateConductiveIron").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateConductiveIron"); + itemPlateDarkSteel = new Item().setUnlocalizedName("itemPlateDarkSteel").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateDarkSteel"); + //Registry + GameRegistry.registerItem(itemPlateSoularium, "itemPlateSoularium"); + GameRegistry.registerItem(itemPlateRedstoneAlloy, "itemPlateRedstoneAlloy"); + GameRegistry.registerItem(itemPlateElectricalSteel, "itemPlateElectricalSteel"); + GameRegistry.registerItem(itemPlatePulsatingIron, "itemPlatePulsatingIron"); + GameRegistry.registerItem(itemPlateEnergeticAlloy, "itemPlateEnergeticAlloy"); + GameRegistry.registerItem(itemPlateVibrantAlloy, "itemPlateVibrantAlloy"); + GameRegistry.registerItem(itemPlateConductiveIron, "itemPlateConductiveIron"); + GameRegistry.registerItem(itemPlateDarkSteel, "itemPlateDarkSteel"); } else { Utils.LOG_WARNING("EnderIO not Found - Skipping Resources."); } - //Big Reactors if (LoadedMods.Big_Reactors|| LOAD_ALL_CONTENT){ - Utils.LOG_INFO("BigReactors Found - Loading Resources."); - GenerateItem(itemPlateBlutonium, "itemPlateBlutonium", AddToCreativeTab.tabMisc, 64, 0); - GenerateItem(itemPlateCyanite, "itemPlateCyanite", AddToCreativeTab.tabMisc, 64, 0); - GenerateItem(itemPlateLudicrite, "itemPlateLudicrite", AddToCreativeTab.tabMisc, 64, 0); + Utils.LOG_INFO("BigReactors Found - Loading Resources."); + //Item Init + itemPlateBlutonium = new Item().setUnlocalizedName("itemPlateBlutonium").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateBlutonium"); + itemPlateCyanite = new Item().setUnlocalizedName("itemPlateCyanite").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateCyanite"); + itemPlateLudicrite = new Item().setUnlocalizedName("itemPlateLudicrite").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateLudicrite"); + //Registry + GameRegistry.registerItem(itemPlateBlutonium, "itemPlateBlutonium"); + GameRegistry.registerItem(itemPlateCyanite, "itemPlateCyanite"); + GameRegistry.registerItem(itemPlateLudicrite, "itemPlateLudicrite"); } else { Utils.LOG_WARNING("BigReactors not Found - Skipping Resources."); } - //Thaumcraft if (LoadedMods.Thaumcraft|| LOAD_ALL_CONTENT){ - Utils.LOG_INFO("Thaumcraft Found - Loading Resources."); - GenerateItem(itemPlateVoidMetal, "itemPlateVoidMetal", AddToCreativeTab.tabMisc, 64, 0); + Utils.LOG_INFO("Thaumcraft Found - Loading Resources."); + //Item Init + try { + itemPlateVoidMetal = new Item().setUnlocalizedName("itemPlateVoidMetal").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateVoidMetal"); + } catch (NullPointerException e){ + e.getClass(); + } + //Registry + GameRegistry.registerItem(itemPlateVoidMetal, "itemPlateVoidMetal"); } else { Utils.LOG_WARNING("Thaumcraft not Found - Skipping Resources."); } - //ExtraUtils if (LoadedMods.Extra_Utils|| LOAD_ALL_CONTENT){ - Utils.LOG_INFO("ExtraUtilities Found - Loading Resources."); - GenerateItem(itemPlateBedrockium, "itemPlateBedrockium", AddToCreativeTab.tabMisc, 64, 0); + Utils.LOG_INFO("ExtraUtilities Found - Loading Resources."); + //Item Init + try { + itemPlateBedrockium = new Item().setUnlocalizedName("itemPlateBedrockium").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateBedrockium"); + } catch (NullPointerException e){ + e.getClass(); + } + //Registry + GameRegistry.registerItem(itemPlateBedrockium, "itemPlateBedrockium"); } else { Utils.LOG_WARNING("ExtraUtilities not Found - Skipping Resources."); } - //Pneumaticraft if (LoadedMods.PneumaticCraft|| LOAD_ALL_CONTENT){ - Utils.LOG_INFO("PneumaticCraft Found - Loading Resources."); - GenerateItem(itemPlateCompressedIron, "itemPlateCompressedIron", AddToCreativeTab.tabMisc, 64, 0); + Utils.LOG_INFO("PneumaticCraft Found - Loading Resources."); + //Item Init + itemPlateCompressedIron = new Item().setUnlocalizedName("itemPlateCompressedIron").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateCompressedIron"); + //Registry + GameRegistry.registerItem(itemPlateCompressedIron, "itemPlateCompressedIron"); } else { Utils.LOG_WARNING("PneumaticCraft not Found - Skipping Resources."); } - //Simply Jetpacks if (LoadedMods.Simply_Jetpacks|| LOAD_ALL_CONTENT){ Utils.LOG_INFO("SimplyJetpacks Found - Loading Resources."); - GenerateItem(itemPlateEnrichedSoularium, "itemPlateEnrichedSoularium", AddToCreativeTab.tabMisc, 64, 0); + //Item Init + itemPlateEnrichedSoularium = new RarityUncommon().setUnlocalizedName("itemPlateEnrichedSoularium").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateSoularium"); + //Registry + GameRegistry.registerItem(itemPlateEnrichedSoularium, "itemPlateEnrichedSoularium"); } else { Utils.LOG_WARNING("SimplyJetpacks not Found - Skipping Resources."); } - - //rfTools if (LoadedMods.RFTools|| LOAD_ALL_CONTENT){ Utils.LOG_INFO("rfTools Found - Loading Resources."); - GenerateItem(itemPlateDimensionShard, "itemPlateDimensionShard", AddToCreativeTab.tabMisc, 64, 0); + //Item Init + itemPlateDimensionShard = new Item().setUnlocalizedName("itemPlateDimensionShard").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateDimensionShard"); + //Registry + GameRegistry.registerItem(itemPlateDimensionShard, "itemPlateDimensionShard"); } else { Utils.LOG_WARNING("rfTools not Found - Skipping Resources."); } - /* * Misc Items */ - //Staballoy Equipment itemStaballoyPickaxe = new StaballoyPickaxe("itemStaballoyPickaxe", STABALLOY).setCreativeTab(AddToCreativeTab.tabTools); GameRegistry.registerItem(itemStaballoyPickaxe, itemStaballoyPickaxe.getUnlocalizedName()); itemStaballoyAxe = new StaballoyAxe("itemStaballoyAxe", STABALLOY).setCreativeTab(AddToCreativeTab.tabTools); GameRegistry.registerItem(itemStaballoyAxe, itemStaballoyAxe.getUnlocalizedName()); - + //Staballoy Ingot/Plate + itemIngotStaballoy = new Item().setUnlocalizedName("itemIngotStaballoy").setCreativeTab(tabMisc).setTextureName(CORE.MODID + ":itemIngotStaballoy"); + GameRegistry.registerItem(itemIngotStaballoy, "itemIngotStaballoy"); + itemPlateStaballoy = new Item().setUnlocalizedName("itemPlateStaballoy").setCreativeTab(tabMisc).setTextureName(CORE.MODID + ":itemPlateStaballoy"); + GameRegistry.registerItem(itemPlateStaballoy, "itemPlateStaballoy"); + //Blood Steel Ingot/Plate + itemIngotBloodSteel = new Item().setUnlocalizedName("itemIngotBloodSteel").setCreativeTab(tabMisc).setTextureName(CORE.MODID + ":itemIngotBloodSteel"); + GameRegistry.registerItem(itemIngotBloodSteel, "itemIngotBloodSteel"); + itemPlateBloodSteel = new Item().setUnlocalizedName("itemPlateBloodSteel").setCreativeTab(tabMisc).setTextureName(CORE.MODID + ":itemPlateBloodSteel"); + GameRegistry.registerItem(itemPlateBloodSteel, "itemPlateBloodSteel"); //Sandstone Hammer itemSandstoneHammer = new SandstoneHammer("itemSandstoneHammer").setCreativeTab(AddToCreativeTab.tabTools); - GameRegistry.registerItem(itemSandstoneHammer, itemSandstoneHammer.getUnlocalizedName()); - + GameRegistry.registerItem(itemSandstoneHammer, itemSandstoneHammer.getUnlocalizedName()); //Buffer Cores! Item itemBufferCore; for(int i=1; i<=10; i++){ Utils.LOG_INFO(""+i); itemBufferCore = new BufferCore("itemBufferCore", i).setCreativeTab(AddToCreativeTab.tabMisc); GameRegistry.registerItem(itemBufferCore, itemBufferCore.getUnlocalizedName()+i); - System.out.println("Buffer Core registration count is: "+i); + System.out.println("Buffer Core registration count is: "+i); } - - GenerateItem(itemHeliumBlob, "itemHeliumBlob", AddToCreativeTab.tabMisc, 32, 2); - GenerateItem(itemStickyRubber, "itemStickyRubber", AddToCreativeTab.tabMisc, 64, 0); - GenerateItem(itemIngotBatteryAlloy, "itemIngotBatteryAlloy", AddToCreativeTab.tabMisc, 64, 0); - GenerateItem(itemPlateBatteryAlloy, "itemPlateBatteryAlloy", AddToCreativeTab.tabMisc, 64, 0); - GenerateItem(itemIngotStaballoy, "itemIngotStaballoy", AddToCreativeTab.tabMisc, 64, 0); - GenerateItem(itemPlateStaballoy, "itemPlateStaballoy", AddToCreativeTab.tabMisc, 64, 0); - GenerateItem(itemIngotBloodSteel, "itemIngotBloodSteel", AddToCreativeTab.tabMisc, 64, 0); - GenerateItem(itemPlateBloodSteel, "itemPlateBloodSteel", AddToCreativeTab.tabMisc, 64, 0); - - - /*GenerateItem(itemHeliumBlob, "heliumBlob", AddToCreativeTab.tabMisc); - GenerateItem(itemHeliumBlob, "heliumBlob", AddToCreativeTab.tabMisc); - -//Armour Materials - public static ArmorMaterial tutArmorMaterial = EnumHelper.addArmorMaterial("BloodSteel Armor Material", 33, new int[]{2, 5, 4, 2}, 10); - - //Base Classes For Items - public static Item tutPickaxe; - public static Item tutAxe; - public static Item tutSword; - public static Item tutHoe; - public static Item tutSpade; - - //Base Classes For Armour - public static Item tutHelmet; - public static Item tutPlate; - public static Item tutPants; - public static Item tutBoots; - - itemPlateDimensionShard = new Item().setUnlocalizedName("itemPlateDimensionShard").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateDimensionShard"); - GameRegistry.registerItem(itemPlateDimensionShard, "itemPlateDimensionShard"); - - - //Item Init - itemPlateSoularium = new Item().setUnlocalizedName("itemPlateSoularium").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateSoularium"); - itemPlateRedstoneAlloy = new Item().setUnlocalizedName("itemPlateRedstoneAlloy").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateRedstoneAlloy"); - itemPlateElectricalSteel = new Item().setUnlocalizedName("itemPlateElectricalSteel").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateElectricalSteel"); - itemPlatePulsatingIron = new Item().setUnlocalizedName("itemPlatePulsatingIron").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlatePulsatingIron"); - itemPlateEnergeticAlloy = new Item().setUnlocalizedName("itemPlateEnergeticAlloy").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateEnergeticAlloy"); - itemPlateVibrantAlloy = new Item().setUnlocalizedName("itemPlateVibrantAlloy").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateVibrantAlloy"); - itemPlateConductiveIron = new Item().setUnlocalizedName("itemPlateConductiveIron").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateConductiveIron"); - itemPlateDarkSteel = new Item().setUnlocalizedName("itemPlateDarkSteel").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateDarkSteel"); - - //Blood Steel Equipment - - //Item Init - tutPickaxe = new BloodSteelPickaxe(tutMaterial).setUnlocalizedName("BloodSteelPickaxe").setCreativeTab(TMCreativeTabs.tabTools).setTextureName(CORE.MODID + ":BloodSteelPickaxe"); - tutAxe = new BloodSteelAxe(tutMaterial).setUnlocalizedName("BloodSteelAxe").setCreativeTab(TMCreativeTabs.tabTools).setTextureName(CORE.MODID + ":BloodSteelAxe"); - tutSword = new BloodSteelSword(tutMaterial).setUnlocalizedName("BloodSteelSword").setCreativeTab(TMCreativeTabs.tabCombat).setTextureName(CORE.MODID + ":BloodSteelSword"); - tutHoe = new BloodSteelHoe(tutMaterial).setUnlocalizedName("BloodSteelHoe").setCreativeTab(TMCreativeTabs.tabTools).setTextureName(CORE.MODID + ":BloodSteelHoe"); - tutSpade = new BloodSteelSpade(tutMaterial).setUnlocalizedName("BloodSteelSpade").setCreativeTab(TMCreativeTabs.tabTools).setTextureName(CORE.MODID + ":BloodSteelSpade"); - tutHelmet = new BloodSteelArmor(tutArmorMaterial, MiscUtils.proxy.addArmor("BloodSteelArmor"), 0).setUnlocalizedName("BloodSteelHelmet").setCreativeTab(TMCreativeTabs.tabCombat).setTextureName(CORE.MODID + ":BloodSteelHelmet"); - tutPlate = new BloodSteelArmor(tutArmorMaterial, MiscUtils.proxy.addArmor("BloodSteelArmor"), 1).setUnlocalizedName("BloodSteelPlate").setCreativeTab(TMCreativeTabs.tabCombat).setTextureName(CORE.MODID + ":BloodSteelPlate"); - tutPants = new BloodSteelArmor(tutArmorMaterial, MiscUtils.proxy.addArmor("BloodSteelArmor"), 2).setUnlocalizedName("BloodSteelPants").setCreativeTab(TMCreativeTabs.tabCombat).setTextureName(CORE.MODID + ":BloodSteelPants"); - tutBoots = new BloodSteelArmor(tutArmorMaterial, MiscUtils.proxy.addArmor("BloodSteelArmor"), 3).setUnlocalizedName("BloodSteelBoots").setCreativeTab(TMCreativeTabs.tabCombat).setTextureName(CORE.MODID + ":BloodSteelBoots"); - - //Registry - GameRegistry.registerItem(tutPickaxe, tutPickaxe.getUnlocalizedName()); - GameRegistry.registerItem(tutAxe, tutAxe.getUnlocalizedName()); - GameRegistry.registerItem(tutSword, tutSword.getUnlocalizedName()); - GameRegistry.registerItem(tutHoe, tutHoe.getUnlocalizedName()); - GameRegistry.registerItem(tutSpade, tutSpade.getUnlocalizedName()); - GameRegistry.registerItem(tutHelmet, tutHelmet.getUnlocalizedName()); - GameRegistry.registerItem(tutPlate, tutPlate.getUnlocalizedName()); - GameRegistry.registerItem(tutPants, tutPants.getUnlocalizedName()); - GameRegistry.registerItem(tutBoots, tutBoots.getUnlocalizedName()); - - //Registry - GameRegistry.registerItem(itemPlateSoularium, "itemPlateSoularium"); - GameRegistry.registerItem(itemPlateRedstoneAlloy, "itemPlateRedstoneAlloy"); - GameRegistry.registerItem(itemPlateElectricalSteel, "itemPlateElectricalSteel"); - GameRegistry.registerItem(itemPlatePulsatingIron, "itemPlatePulsatingIron"); - GameRegistry.registerItem(itemPlateEnergeticAlloy, "itemPlateEnergeticAlloy"); - GameRegistry.registerItem(itemPlateVibrantAlloy, "itemPlateVibrantAlloy"); - GameRegistry.registerItem(itemPlateConductiveIron, "itemPlateConductiveIron"); - GameRegistry.registerItem(itemPlateDarkSteel, "itemPlateDarkSteel"); - - //Item Init - itemPlateEnrichedSoularium = new RarityUncommon().setUnlocalizedName("itemPlateEnrichedSoularium").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateSoularium"); - - //Registry - GameRegistry.registerItem(itemPlateEnrichedSoularium, "itemPlateEnrichedSoularium"); - //Item Init - itemPlateCompressedIron = new Item().setUnlocalizedName("itemPlateCompressedIron").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateCompressedIron"); - - //Registry - GameRegistry.registerItem(itemPlateCompressedIron, "itemPlateCompressedIron"); - - //Item Init - itemPlateBlutonium = new Item().setUnlocalizedName("itemPlateBlutonium").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateBlutonium"); - itemPlateCyanite = new Item().setUnlocalizedName("itemPlateCyanite").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateCyanite"); - itemPlateLudicrite = new Item().setUnlocalizedName("itemPlateLudicrite").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateLudicrite"); - - //Registry - GameRegistry.registerItem(itemPlateBlutonium, "itemPlateBlutonium"); - GameRegistry.registerItem(itemPlateCyanite, "itemPlateCyanite"); - GameRegistry.registerItem(itemPlateLudicrite, "itemPlateLudicrite"); - - //Item Init - try { - itemPlateVoidMetal = new Item().setUnlocalizedName("itemPlateVoidMetal").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateVoidMetal"); - } catch (NullPointerException e){ - e.getClass(); - } - - //Registry - GameRegistry.registerItem(itemPlateVoidMetal, "itemPlateVoidMetal"); - - //Item Init - try { - itemPlateBedrockium = new Item().setUnlocalizedName("itemPlateBedrockium").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateBedrockium"); - } catch (NullPointerException e){ - e.getClass(); - } - //Registry - GameRegistry.registerItem(itemPlateBedrockium, "itemPlateBedrockium"); - //Dev Items itemStickyRubber = new Item().setUnlocalizedName("itemStickyRubber").setCreativeTab(tabMisc).setTextureName(CORE.MODID + ":itemDefault"); GameRegistry.registerItem(itemStickyRubber, "itemStickyRubber"); - //Battery Alloy For cheap Niggers itemIngotBatteryAlloy = new Item().setUnlocalizedName("itemIngotBatteryAlloy").setCreativeTab(tabMisc).setTextureName(CORE.MODID + ":itemDefault"); GameRegistry.registerItem(itemIngotBatteryAlloy, "itemIngotBatteryAlloy"); itemPlateBatteryAlloy = new Item().setUnlocalizedName("itemPlateBatteryAlloy").setCreativeTab(tabMisc).setTextureName(CORE.MODID + ":itemDefault"); - GameRegistry.registerItem(itemPlateBatteryAlloy, "itemPlateBatteryAlloy");*/ - - - /*//Staballoy Ingot/Plate - itemIngotStaballoy = new Item().setUnlocalizedName("itemIngotStaballoy").setCreativeTab(tabMisc).setTextureName(CORE.MODID + ":itemIngotStaballoy"); - GameRegistry.registerItem(itemIngotStaballoy, "itemIngotStaballoy"); - itemPlateStaballoy = new Item().setUnlocalizedName("itemPlateStaballoy").setCreativeTab(tabMisc).setTextureName(CORE.MODID + ":itemPlateStaballoy"); - GameRegistry.registerItem(itemPlateStaballoy, "itemPlateStaballoy"); - - //Blood Steel Ingot/Plate - itemIngotBloodSteel = new Item().setUnlocalizedName("itemIngotBloodSteel").setCreativeTab(tabMisc).setTextureName(CORE.MODID + ":itemIngotBloodSteel"); - GameRegistry.registerItem(itemIngotBloodSteel, "itemIngotBloodSteel"); - itemPlateBloodSteel = new Item().setUnlocalizedName("itemPlateBloodSteel").setCreativeTab(tabMisc).setTextureName(CORE.MODID + ":itemPlateBloodSteel"); - GameRegistry.registerItem(itemPlateBloodSteel, "itemPlateBloodSteel");*/ - - - /*item_PLEASE_FACTOR_ME_4 = new Item().setUnlocalizedName("unlocalName4").setCreativeTab(tabMisc).setTextureName(CORE.MODID + ":itemDefault"); + GameRegistry.registerItem(itemPlateBatteryAlloy, "itemPlateBatteryAlloy"); + itemHeliumBlob = new Item().setUnlocalizedName("itemHeliumBlob").setCreativeTab(tabMisc).setTextureName(CORE.MODID + ":itemHeliumBlob"); + GameRegistry.registerItem(itemHeliumBlob, "itemHeliumBlob"); + + /* + item_PLEASE_FACTOR_ME_4 = new Item().setUnlocalizedName("unlocalName4").setCreativeTab(tabMisc).setTextureName(CORE.MODID + ":itemDefault"); GameRegistry.registerItem(item_PLEASE_FACTOR_ME_4, "localName4");*/ - - //Try some New Tools from GT //GT_Tool_Item x = null; //x = GregTech_API.constructHardHammerItem("rockBelter", "Sandstone Hammer", 5000 /**Max Damage**/,50 /**Entity Damage**/); //GregTech_API.registerHardHammer(x); - - } - - private static void GenerateItem(Item item, String name, CreativeTabs tab, int stackSize, int itemDamage){ - //item = new BaseItemGeneric(name, tab, stackSize, itemDamage); - item = new Item().setUnlocalizedName(name).setCreativeTab(tab).setTextureName(CORE.MODID + name); - Utils.LOG_INFO("Generating Item ["+totalGenerated+"] Name: "+item.getUnlocalizedName()); - GameRegistry.registerItem(item, name); - totalGenerated++; - - } - - -} +}
\ No newline at end of file diff --git a/src/Java/miscutil/core/item/base/BaseItemGeneric.java b/src/Java/miscutil/core/item/base/BaseItemGeneric.java index ffdb495a21..55d98528ce 100644 --- a/src/Java/miscutil/core/item/base/BaseItemGeneric.java +++ b/src/Java/miscutil/core/item/base/BaseItemGeneric.java @@ -4,6 +4,7 @@ import miscutil.core.lib.CORE; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; +@Deprecated public class BaseItemGeneric extends Item { public BaseItemGeneric(String s, CreativeTabs c, int stackSize, int maxDmg) diff --git a/src/Java/miscutil/core/item/base/BaseMetaItemTool.java b/src/Java/miscutil/core/item/base/BaseMetaItemTool.java deleted file mode 100644 index bbd792cce4..0000000000 --- a/src/Java/miscutil/core/item/base/BaseMetaItemTool.java +++ /dev/null @@ -1,5 +0,0 @@ -package miscutil.core.item.base; - -public class BaseMetaItemTool { - -} diff --git a/src/Java/miscutil/core/tileentities/TileEntityHeliumGenerator.java b/src/Java/miscutil/core/tileentities/TileEntityHeliumGenerator.java index bc1d452495..5e255f0bbf 100644 --- a/src/Java/miscutil/core/tileentities/TileEntityHeliumGenerator.java +++ b/src/Java/miscutil/core/tileentities/TileEntityHeliumGenerator.java @@ -1,134 +1,609 @@ package miscutil.core.tileentities; +import ic2.api.Direction; +import ic2.api.reactor.IReactor; +import ic2.api.reactor.IReactorComponent; +import ic2.api.tile.IWrenchable; +import ic2.core.IC2; +import ic2.core.IC2DamageSource; +import ic2.core.Ic2Items; +import ic2.core.block.TileEntityInventory; +import ic2.core.init.MainConfig; +import ic2.core.item.reactor.ItemReactorHeatStorage; +import ic2.core.network.NetworkManager; +import ic2.core.util.ConfigUtil; + +import java.util.List; + +import miscutil.core.block.ModBlocks; +import miscutil.core.handler.InvSlotRadiation; import miscutil.core.item.ModItems; +import miscutil.core.util.Utils; import miscutil.core.util.UtilsItems; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; import net.minecraft.inventory.IInventory; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.world.World; + +public class TileEntityHeliumGenerator extends TileEntityInventory implements IInventory ,IReactor, IWrenchable { + + private ItemStack heliumStack; + private int facing = 2; + private int progress; + + @Override + public void updateEntity(){ + if(++progress >= 40){ + //if(++progress >= 300){ + if(heliumStack == null) + heliumStack = UtilsItems.getSimpleStack(ModItems.itemHeliumBlob); + else if(heliumStack.getItem() == ModItems.itemHeliumBlob && heliumStack.stackSize < 64) + heliumStack.stackSize++; + progress = 0; + markDirty(); + } + } + + @Override + public short getFacing(){ + return (short) facing; + } + + @Override + public void setFacing(short dir){ + facing = dir; + } + + /*@Override + public void readCustomNBT(NBTTagCompound tag) + { + this.heliumStack = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("Helium")); + this.progress = tag.getInteger("Progress"); + this.facing = tag.getShort("Facing"); + this.heat = tag.getInteger("heat"); + this.prevActive = (this.active = tag.getBoolean("active")); + } + + @Override + public void writeCustomNBT(NBTTagCompound tag) + { + tag.setInteger("Progress", this.progress); + tag.setShort("Facing", (short) this.facing); + tag.setInteger("heat", this.heat); + tag.setBoolean("active", this.active); + if(heliumStack != null) { + NBTTagCompound produce = new NBTTagCompound(); + heliumStack.writeToNBT(produce); + tag.setTag("Helium", produce); + } + else + tag.removeTag("Helium"); + }*/ + + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) + { + super.readFromNBT(nbttagcompound); -public class TileEntityHeliumGenerator extends TILE_ENTITY_BASE implements IInventory { - - private ItemStack heliumStack; - private int facing = 2; - private int progress; - - @Override - public void updateEntity(){ - if(++progress >= 40){ - //if(++progress >= 300){ - if(heliumStack == null) - heliumStack = UtilsItems.getSimpleStack(ModItems.itemHeliumBlob); - else if(heliumStack.getItem() == ModItems.itemHeliumBlob && heliumStack.stackSize < 64) - heliumStack.stackSize++; - progress = 0; - markDirty(); - } - } - - public int getFacing(){ - return facing; - } - - public void setFacing(int dir){ - facing = dir; - } - - @Override - public void readCustomNBT(NBTTagCompound tag) - { - this.heliumStack = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("Helium")); - this.progress = tag.getInteger("Progress"); - this.facing = tag.getShort("Facing"); - } - - @Override - public void writeCustomNBT(NBTTagCompound tag) - { - tag.setInteger("Progress", this.progress); - tag.setShort("Facing", (short) this.facing); - if(heliumStack != null) { - NBTTagCompound produce = new NBTTagCompound(); - heliumStack.writeToNBT(produce); - tag.setTag("Helium", produce); - } - else - tag.removeTag("Helium"); - } - - @Override - public int getSizeInventory() - { - return 1; - } - - @Override - public ItemStack getStackInSlot(int slot){ - return heliumStack; - } - - @Override - public ItemStack decrStackSize(int slot, int decrement){ - if(heliumStack == null) - return null; + this.heliumStack = ItemStack.loadItemStackFromNBT(nbttagcompound.getCompoundTag("Helium")); + this.progress = nbttagcompound.getInteger("Progress"); + this.facing = nbttagcompound.getShort("Facing"); + this.heat = nbttagcompound.getInteger("heat"); + this.output = nbttagcompound.getShort("output"); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) + { + super.writeToNBT(nbttagcompound); + + nbttagcompound.setInteger("Progress", this.progress); + nbttagcompound.setShort("Facing", (short) this.facing); + nbttagcompound.setInteger("heat", this.heat); + nbttagcompound.setShort("output", (short)(int)getReactorEnergyOutput()); + if(heliumStack != null) { + NBTTagCompound produce = new NBTTagCompound(); + heliumStack.writeToNBT(produce); + nbttagcompound.setTag("Helium", produce); + } + else + nbttagcompound.removeTag("Helium"); + } + + + @Override + public Packet getDescriptionPacket() { + NBTTagCompound tag = new NBTTagCompound(); + writeToNBT(tag); + return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, -999, tag); + } + + @Override + public void onDataPacket(net.minecraft.network.NetworkManager net, S35PacketUpdateTileEntity packet) { + super.onDataPacket(net, packet); + readFromNBT(packet.func_148857_g()); + } + + + @Override + public int getSizeInventory() + { + return 19; + } + + @Override + public ItemStack getStackInSlot(int slot){ + return heliumStack; + } + + @Override + public ItemStack decrStackSize(int slot, int decrement){ + if(heliumStack == null) + return null; if(decrement < heliumStack.stackSize){ - ItemStack take = heliumStack.splitStack(decrement); - if(heliumStack.stackSize <= 0) - heliumStack = null; - return take; + ItemStack take = heliumStack.splitStack(decrement); + if(heliumStack.stackSize <= 0) + heliumStack = null; + return take; } ItemStack take = heliumStack; heliumStack = null; return take; - } - - @Override - public void openInventory() {} - @Override - public void closeInventory() {} - - @Override - public boolean isUseableByPlayer(EntityPlayer player) - { - return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) == this && player.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D; - } - - @Override - public boolean isItemValidForSlot(int slot, ItemStack stack){ - return false; - } - - @Override - public int getInventoryStackLimit(){ - return 64; - } - - @Override - public void setInventorySlotContents(int slot, ItemStack stack){ - heliumStack = stack; - } - - @Override - public ItemStack getStackInSlotOnClosing(int slot){ - return null; - } - - /** - * Returns the name of the inventory - */ - @Override - public String getInventoryName() - { - return "container.helium_collector"; - } - - /** - * Returns if the inventory is named - */ - @Override - public boolean hasCustomInventoryName() - { - return false; - } + } + + @Override + public void openInventory() {} + @Override + public void closeInventory() {} + + @Override + public boolean isUseableByPlayer(EntityPlayer player) + { + return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) == this && player.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D; + } + + @Override + public boolean isItemValidForSlot(int slot, ItemStack stack){ + return false; + } + + @Override + public int getInventoryStackLimit(){ + return 64; + } + + @Override + public void setInventorySlotContents(int slot, ItemStack stack){ + heliumStack = stack; + } + + @Override + public ItemStack getStackInSlotOnClosing(int slot){ + return null; + } + + /** + * Returns the name of the inventory + */ + @Override + public String getInventoryName() + { + //return "container.helium_collector"; + return "container.radiation_collector"; + } + + /** + * Returns if the inventory is named + */ + @Override + public boolean hasCustomInventoryName() + { + return false; + } + + //IC2 Nuclear Code + + + public Block[][][] surroundings = new Block[5][5][5]; + public final InvSlotRadiation reactorSlot; + public float output = 0.0F; + public int updateTicker; + public int heat = 5000; + public int maxHeat = 10000; + public float hem = 1.0F; + private int EmitHeatbuffer = 0; + public int EmitHeat = 0; + private boolean redstone = false; + private boolean fluidcoolreactor = false; + private boolean active = true; + public boolean prevActive = false; + + + public short getReactorSize() + { + if (this.worldObj == null) { + return 9; + } + short cols = 3; + for (Direction direction : Direction.directions) + { + TileEntity target = direction.applyToTileEntity(this); + if ((target instanceof TileEntityHeliumGenerator)) { + cols = (short)(cols + 1); + } + } + return cols; + } + + protected void updateEntityServer() + { + super.updateEntity(); + + if (this.updateTicker++ % getTickRate() != 0) { + return; + } + if (!this.worldObj.doChunksNearChunkExist(this.xCoord, this.yCoord, this.zCoord, 2)) + { + this.output = 0.0F; + } + else + { + + dropAllUnfittingStuff(); + + this.output = 0.0F; + this.maxHeat = 10000; + this.hem = 1.0F; + + processChambers(); + this.EmitHeatbuffer = 0; + if (calculateHeatEffects()) { + return; + } + setActive((this.heat >= 1000) || (this.output > 0.0F)); + + markDirty(); + } + ((NetworkManager)IC2.network.get()).updateTileEntityField(this, "output"); + } + + @Override + public void setActive(boolean active1) + { + this.active = active1; + if (this.prevActive != active1) { + ((NetworkManager)IC2.network.get()).updateTileEntityField(this, "active"); + } + this.prevActive = active1; + } + + public void dropAllUnfittingStuff() + { + for (int i = 0; i < this.reactorSlot.size(); i++) + { + ItemStack stack = this.reactorSlot.get(i); + if ((stack != null) && (!isUsefulItem(stack, false))) + { + this.reactorSlot.put(i, null); + eject(stack); + } + } + for (int i = this.reactorSlot.size(); i < this.reactorSlot.rawSize(); i++) + { + ItemStack stack = this.reactorSlot.get(i); + + this.reactorSlot.put(i, null); + eject(stack); + } + } + + public void eject(ItemStack drop) + { + if ((!IC2.platform.isSimulating()) || (drop == null)) { + return; + } + float f = 0.7F; + double d = this.worldObj.rand.nextFloat() * f + (1.0F - f) * 0.5D; + double d1 = this.worldObj.rand.nextFloat() * f + (1.0F - f) * 0.5D; + double d2 = this.worldObj.rand.nextFloat() * f + (1.0F - f) * 0.5D; + EntityItem entityitem = new EntityItem(this.worldObj, this.xCoord + d, this.yCoord + d1, this.zCoord + d2, drop); + entityitem.delayBeforeCanPickup = 10; + this.worldObj.spawnEntityInWorld(entityitem); + } + + public boolean isUsefulItem(ItemStack stack, boolean forInsertion) + { + Item item = stack.getItem(); + if ((forInsertion) && (this.fluidcoolreactor) && + ((item instanceof ItemReactorHeatStorage)) && + (((ItemReactorHeatStorage)item).getCustomDamage(stack) > 0)) { + return false; + } + if ((item instanceof IReactorComponent)) { + return true; + } + return (item == Ic2Items.TritiumCell.getItem()) || (item == Ic2Items.reactorDepletedUraniumSimple.getItem()) || (item == Ic2Items.reactorDepletedUraniumDual.getItem()) || (item == Ic2Items.reactorDepletedUraniumQuad.getItem()) || (item == Ic2Items.reactorDepletedMOXSimple.getItem()) || (item == Ic2Items.reactorDepletedMOXDual.getItem()) || (item == Ic2Items.reactorDepletedMOXQuad.getItem()); + } + + public boolean calculateHeatEffects() + { + if ((this.heat < 4000) || (!IC2.platform.isSimulating()) || (ConfigUtil.getFloat(MainConfig.get(), "protection/reactorExplosionPowerLimit") <= 0.0F)) { + return false; + } + float power = this.heat / this.maxHeat; + if (power >= 1.0F) + { + explode(); + return true; + } + if ((power >= 0.85F) && (this.worldObj.rand.nextFloat() <= 0.2F * this.hem)) + { + int[] coord = getRandCoord(2); + if (coord != null) + { + Block block = this.worldObj.getBlock(coord[0], coord[1], coord[2]); + if (block.isAir(this.worldObj, coord[0], coord[1], coord[2])) + { + this.worldObj.setBlock(coord[0], coord[1], coord[2], Blocks.fire, 0, 7); + } + else if ((block.getBlockHardness(this.worldObj, coord[0], coord[1], coord[2]) >= 0.0F) && (this.worldObj.getTileEntity(coord[0], coord[1], coord[2]) == null)) + { + Material mat = block.getMaterial(); + if ((mat == Material.rock) || (mat == Material.iron) || (mat == Material.lava) || (mat == Material.ground) || (mat == Material.clay)) { + this.worldObj.setBlock(coord[0], coord[1], coord[2], Blocks.flowing_lava, 15, 7); + } else { + this.worldObj.setBlock(coord[0], coord[1], coord[2], Blocks.fire, 0, 7); + } + } + } + } + if (power >= 0.7F) + { + List list1 = this.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(this.xCoord - 3, this.yCoord - 3, this.zCoord - 3, this.xCoord + 4, this.yCoord + 4, this.zCoord + 4)); + for (int l = 0; l < list1.size(); l++) + { + Entity ent = (Entity)list1.get(l); + ent.attackEntityFrom(IC2DamageSource.radiation, (int)(this.worldObj.rand.nextInt(4) * this.hem)); + } + } + if ((power >= 0.5F) && (this.worldObj.rand.nextFloat() <= this.hem)) + { + int[] coord = getRandCoord(2); + if (coord != null) + { + Block block = this.worldObj.getBlock(coord[0], coord[1], coord[2]); + if (block.getMaterial() == Material.water) { + this.worldObj.setBlockToAir(coord[0], coord[1], coord[2]); + } + } + } + if ((power >= 0.4F) && (this.worldObj.rand.nextFloat() <= this.hem)) + { + int[] coord = getRandCoord(2); + if ((coord != null) && + (this.worldObj.getTileEntity(coord[0], coord[1], coord[2]) == null)) + { + Block block = this.worldObj.getBlock(coord[0], coord[1], coord[2]); + Material mat = block.getMaterial(); + if ((mat == Material.wood) || (mat == Material.leaves) || (mat == Material.cloth)) { + this.worldObj.setBlock(coord[0], coord[1], coord[2], Blocks.fire, 0, 7); + } + } + } + return false; + } + + public int[] getRandCoord(int radius) + { + if (radius <= 0) { + return null; + } + int[] c = new int[3]; + c[0] = (this.xCoord + this.worldObj.rand.nextInt(2 * radius + 1) - radius); + c[1] = (this.yCoord + this.worldObj.rand.nextInt(2 * radius + 1) - radius); + c[2] = (this.zCoord + this.worldObj.rand.nextInt(2 * radius + 1) - radius); + if ((c[0] == this.xCoord) && (c[1] == this.yCoord) && (c[2] == this.zCoord)) { + return null; + } + return c; + } + + public void processChambers() + { + int size = getReactorSize(); + for (int pass = 0; pass < 2; pass++) { + for (int y = 0; y < 6; y++) { + for (int x = 0; x < size; x++) + { + ItemStack stack = this.reactorSlot.get(x, y); + if ((stack != null) && ((stack.getItem() instanceof IReactorComponent))) + { + IReactorComponent comp = (IReactorComponent)stack.getItem(); + comp.processChamber(this, stack, x, y, pass == 0); + } + } + } + } + } + + @Override + public ChunkCoordinates getPosition() + { + return new ChunkCoordinates(this.xCoord, this.yCoord, this.zCoord); + } + + @Override + public World getWorld() { + return this.worldObj; + } + + @Override + public int getHeat() { + return this.heat; + } + + @Override + public void setHeat(int heat1) + { + this.heat = heat1; + } + + @Override + public int addHeat(int amount) + { + this.heat += amount; + return this.heat; + } + + @Override + public int getMaxHeat() + { + return this.maxHeat; + } + + @Override + public void setMaxHeat(int newMaxHeat) + { + this.maxHeat = newMaxHeat; + } + + @Override + public void addEmitHeat(int heat) + { + this.EmitHeatbuffer += heat; + } + + @Override + public float getHeatEffectModifier() + { + return this.hem; + } + + @Override + public void setHeatEffectModifier(float newHEM) + { + this.hem = newHEM; + } + + @Override + public float getReactorEnergyOutput() + { + return this.output; + } + + @Override + public double getReactorEUEnergyOutput() + { + return getOfferedEnergy(); + } + + public double getOfferedEnergy() + { + return getReactorEnergyOutput() * 5.0F * 1.0F; + } + + @Override + public float addOutput(float energy) + { + return this.output += energy; + } + + @Override + public ItemStack getItemAt(int x, int y) + { + if ((x < 0) || (x >= getReactorSize()) || (y < 0) || (y >= 6)) { + return null; + } + return this.reactorSlot.get(x, y); + } + + @Override + public void setItemAt(int x, int y, ItemStack item) + { + if ((x < 0) || (x >= getReactorSize()) || (y < 0) || (y >= 6)) { + return; + } + this.reactorSlot.put(x, y, item); + } + + public TileEntityHeliumGenerator() { + this.updateTicker = IC2.random.nextInt(getTickRate()); + this.reactorSlot = new InvSlotRadiation(this, "reactor", 0, 54); //TODO + } + + @Override + public void explode() { + Utils.LOG_INFO("Explosion"); + //TODO + } + + @Override + public int getTickRate() + { + return 20; + } + + public boolean receiveredstone() + { + if ((this.worldObj.isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord)) || (this.redstone)) { + return true; + } + return false; + } + + @Override + public boolean produceEnergy() + { + return (receiveredstone()) && (ConfigUtil.getFloat(MainConfig.get(), "balance/energy/generator/generator") > 0.0F); + } + + @Override + public void setRedstoneSignal(boolean redstone) + { + this.redstone = redstone; + } + + @Override + public boolean isFluidCooled() { + return false; + } + + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) + { + return true; + } + + @Override + public boolean wrenchCanRemove(EntityPlayer entityPlayer) + { + return true; + } + + @Override + public float getWrenchDropRate() + { + return 1F; + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) + { + return new ItemStack(ModBlocks.blockHeliumGenerator, 1); + } } diff --git a/src/Java/miscutil/core/util/UtilsItems.java b/src/Java/miscutil/core/util/UtilsItems.java index bd82cc104a..c2bf2823fc 100644 --- a/src/Java/miscutil/core/util/UtilsItems.java +++ b/src/Java/miscutil/core/util/UtilsItems.java @@ -46,9 +46,14 @@ public class UtilsItems { } public static ItemStack getSimpleStack(Item x){ + try { ItemStack r = new ItemStack(x, 1); return r; + } catch(Throwable e){ + return null; + } } + public static void getItemForOreDict(String FQRN, String oreDictName, String itemName, int meta){ try { |