From ba31e11f0707a2196125be7d814cb6ce181f4041 Mon Sep 17 00:00:00 2001 From: HbmMods Date: Fri, 18 Aug 2017 08:27:03 +0200 Subject: [PATCH] More retrofitting, T45 charge fix, infinite fusion core --- assets/hbm/textures/gui/GUIDiesel.png | Bin 2929 -> 3713 bytes .../textures/items/fusion_core_infinite.png | Bin 0 -> 287 bytes .../container/ContainerMachineDiesel.java | 30 +-- .../container/ContainerPuF6Tank.java | 29 --- com/hbm/inventory/gui/GUIMachineDiesel.java | 20 +- com/hbm/inventory/gui/GUIMachinePuF6Tank.java | 17 +- .../gui/GUIScreenTemplateFolder.java | 5 - com/hbm/items/ModItems.java | 5 +- com/hbm/items/gear/ArmorT45.java | 37 ++-- com/hbm/lib/Library.java | 5 + .../tileentity/TileEntityMachineDiesel.java | 203 +++++++----------- .../tileentity/TileEntityMachinePuF6Tank.java | 104 +++------ com/hbm/world/DesertAtom003.java | 4 +- 13 files changed, 173 insertions(+), 286 deletions(-) create mode 100644 assets/hbm/textures/items/fusion_core_infinite.png diff --git a/assets/hbm/textures/gui/GUIDiesel.png b/assets/hbm/textures/gui/GUIDiesel.png index 8a544c9f54cdb828aae95d586fbaec9702a57faa..c6ad31d9598fe37ab1733ba6b7be59165bb96277 100644 GIT binary patch literal 3713 zcmc&%eK^za8vky_7NPT#m-1dxi3nwxwJFk+@}4qpwd21danEaJok0q_wziroKHI_ z%5Rqk06-CQ!p;={K+-7)fXPV}Ho7WUsvt2(G43#_B*6mz0RT#HjGe9fwMX+~ZPA)6 z?ap80zCbF)xnT{63pV%6QNP>q#>2*?R4HXs{G-xB%VNuj-fflzxj45IMGA~RJmhm0 zW#AT$9fF))Ia~Fjuk2N8!xDg79XfLz9C5+x6F^r7Q=UVY#4OF>wS62RSJQ|R6Om5^ zZ{D7}T$mtToD#2l44 zSi!T1dlbN>XK~)e9HWfMSNyiY{)Lw$gPDbXpTk)@$K$_KNc;C6wRd?0&5YMIN>2KQ zWr~;w($mvj@4vX2QsH2Ud>Aqbch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&x@qG4P45?<+|HZ+8$G54NM z#VcjQs>fHmQlq=-^v!Mxx7M8^tFAL2y07{-fAJF4DXWu6I#o^PhxgOhP||OP#$VPP z`M15(G;rN^kpLlSmlDdiHD1cvUV`<=y+OLwo@Ye-4@^GH=NrK)Q)9t+aLA6wbiHp% za7ccgGpTS+)md~Ks@IN@k|0&qz3sot9d!z-G5pTOd<)9fCr49{r#G?qjP)|21hFY2 ztYPPfWRiE%`cGLkJBVpi3nbx0Hjql~;jW7YbP;6fzH&Hoy>(dSf1bxkcM$)FmYcBz aIiW~WUW}abr$F`9FOIdPE$I=_Blb65@W%uI diff --git a/assets/hbm/textures/items/fusion_core_infinite.png b/assets/hbm/textures/items/fusion_core_infinite.png new file mode 100644 index 0000000000000000000000000000000000000000..6d70e68ab204f64cad984d65edc3cd4314b2e89c GIT binary patch literal 287 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`EX7WqAsj$Z!;#Vf|H)jQcT8pC^Gfajk=Bp*wqJ{?oAGE4bHc9rM{h5Fvf?=+ z@l)p+TLQy_z4@V2m;9ElE0<4?o?Cn-?pdxm!-Lwr@1#ORLtR}~yfrpF*3I}~0#E4q z84{_|+l 0) + if(diFurnace.tank.getFill() > 0 && diFurnace.hasAcceptableFuel()) { - int j = diFurnace.getDieselScaled(52); - drawTexturedModalRect(guiLeft + 8, guiTop + 69 - j, 192, 52 - j, 16, j); - drawTexturedModalRect(guiLeft + 43, guiTop + 34, 208, 0, 18, 18); + drawTexturedModalRect(guiLeft + 43 + 18 * 4, guiTop + 34, 208, 0, 18, 18); } + + Minecraft.getMinecraft().getTextureManager().bindTexture(FluidTank.fluidTextures); + + diFurnace.tank.renderTank(this, guiLeft + 80, guiTop + 69, diFurnace.tank.getTankType().textureX() * FluidTank.x, diFurnace.tank.getTankType().textureY() * FluidTank.y, 16, 52); } } diff --git a/com/hbm/inventory/gui/GUIMachinePuF6Tank.java b/com/hbm/inventory/gui/GUIMachinePuF6Tank.java index 26bd26da0..bb90ad016 100644 --- a/com/hbm/inventory/gui/GUIMachinePuF6Tank.java +++ b/com/hbm/inventory/gui/GUIMachinePuF6Tank.java @@ -2,6 +2,7 @@ package com.hbm.inventory.gui; import org.lwjgl.opengl.GL11; +import com.hbm.inventory.FluidTank; import com.hbm.inventory.container.ContainerPuF6Tank; import com.hbm.lib.RefStrings; import com.hbm.tileentity.TileEntityMachinePuF6Tank; @@ -12,7 +13,7 @@ import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.ResourceLocation; -public class GUIMachinePuF6Tank extends GuiContainer { +public class GUIMachinePuF6Tank extends GuiFluidContainer { private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/puf6Tank.png"); private TileEntityMachinePuF6Tank tank; @@ -24,6 +25,13 @@ public class GUIMachinePuF6Tank extends GuiContainer { this.xSize = 176; this.ySize = 166; } + + @Override + public void drawScreen(int mouseX, int mouseY, float f) { + super.drawScreen(mouseX, mouseY, f); + + tank.tank.renderTankInfo(this, mouseX, mouseY, guiLeft + 80, guiTop + 69 - 52, 16, 52); + } @Override protected void drawGuiContainerForegroundLayer( int i, int j) { @@ -39,10 +47,7 @@ public class GUIMachinePuF6Tank extends GuiContainer { Minecraft.getMinecraft().getTextureManager().bindTexture(texture); drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); - if(tank.fillState > 0) - { - int i1 = tank.getFillStateScaled(52); - drawTexturedModalRect(guiLeft + 80, guiTop + 69 - i1, 177, 52 - i1, 16, i1); - } + Minecraft.getMinecraft().getTextureManager().bindTexture(FluidTank.fluidTextures); + tank.tank.renderTank(this, guiLeft + 80, guiTop + 69, tank.tank.getTankType().textureX() * FluidTank.x, tank.tank.getTankType().textureY() * FluidTank.y, 16, 52); } } diff --git a/com/hbm/inventory/gui/GUIScreenTemplateFolder.java b/com/hbm/inventory/gui/GUIScreenTemplateFolder.java index e8bf6b74a..903b9b94b 100644 --- a/com/hbm/inventory/gui/GUIScreenTemplateFolder.java +++ b/com/hbm/inventory/gui/GUIScreenTemplateFolder.java @@ -87,11 +87,6 @@ public class GUIScreenTemplateFolder extends GuiScreen { if(!buttons.isEmpty()) buttons.clear(); - /*for(int u = 0; u < 7; u++) - for(int v = 0; v < 5; v++) - if((currentPage * 35) + (v * 5) + u < stacks.size()) - buttons.add(new FolderButton(guiLeft + 25 + (27 * v), guiTop + 26 + (27 * u), stacks.get((currentPage * 35) + (v * 5) + u)));*/ - for(int i = currentPage * 35; i < Math.min(currentPage * 35 + 35, stacks.size()); i++) { buttons.add(new FolderButton(guiLeft + 25 + (27 * (i % 5)), guiTop + 26 + (27 * (int)Math.floor((i / 5D))) - currentPage * 27 * 7, stacks.get(i))); } diff --git a/com/hbm/items/ModItems.java b/com/hbm/items/ModItems.java index 2011088ed..160810d80 100644 --- a/com/hbm/items/ModItems.java +++ b/com/hbm/items/ModItems.java @@ -697,8 +697,9 @@ public class ModItems { public static Item battery_schrabidium_cell; public static Item battery_schrabidium_cell_2; public static Item battery_schrabidium_cell_4; - + public static Item fusion_core; + public static Item fusion_core_infinite; public static Item energy_core; public static Item fuse; public static Item redcoil_capacitor; @@ -1643,6 +1644,7 @@ public class ModItems { battery_schrabidium_cell_4 = new ItemBattery(30000 * 4).setUnlocalizedName("battery_schrabidium_cell_4").setMaxStackSize(1).setCreativeTab(MainRegistry.tabParts).setTextureName(RefStrings.MODID + ":battery_schrabidium_cell_4"); fusion_core = new ItemBattery(5000).setUnlocalizedName("fusion_core").setMaxStackSize(1).setCreativeTab(MainRegistry.tabParts).setTextureName(RefStrings.MODID + ":fusion_core"); + fusion_core_infinite = new Item().setUnlocalizedName("fusion_core_infinite").setMaxStackSize(1).setCreativeTab(MainRegistry.tabParts).setTextureName(RefStrings.MODID + ":fusion_core_infinite"); energy_core = new ItemBattery(5000).setUnlocalizedName("energy_core").setMaxStackSize(1).setCreativeTab(MainRegistry.tabParts).setTextureName(RefStrings.MODID + ":energy_core"); fuse = new ItemCustomLore().setUnlocalizedName("fuse").setMaxStackSize(1).setCreativeTab(MainRegistry.tabParts).setTextureName(RefStrings.MODID + ":fuse"); redcoil_capacitor = new ItemCapacitor(10).setUnlocalizedName("redcoil_capacitor").setMaxStackSize(1).setCreativeTab(MainRegistry.tabParts).setTextureName(RefStrings.MODID + ":redcoil_capacitor"); @@ -2359,6 +2361,7 @@ public class ModItems { GameRegistry.registerItem(battery_creative, battery_creative.getUnlocalizedName()); GameRegistry.registerItem(fusion_core, fusion_core.getUnlocalizedName()); GameRegistry.registerItem(energy_core, energy_core.getUnlocalizedName()); + GameRegistry.registerItem(fusion_core_infinite, fusion_core_infinite.getUnlocalizedName()); GameRegistry.registerItem(factory_core_titanium, factory_core_titanium.getUnlocalizedName()); GameRegistry.registerItem(factory_core_advanced, factory_core_advanced.getUnlocalizedName()); diff --git a/com/hbm/items/gear/ArmorT45.java b/com/hbm/items/gear/ArmorT45.java index 3e0be1f01..d341ccde8 100644 --- a/com/hbm/items/gear/ArmorT45.java +++ b/com/hbm/items/gear/ArmorT45.java @@ -4,6 +4,7 @@ import java.util.List; import com.google.common.collect.Multimap; import com.hbm.items.ModItems; +import com.hbm.items.special.ItemBattery; import com.hbm.lib.Library; import com.hbm.render.model.ModelT45Boots; import com.hbm.render.model.ModelT45Chest; @@ -159,21 +160,25 @@ public class ArmorT45 extends ItemArmor implements ISpecialArmor { armor.stackTagCompound = new NBTTagCompound(); armor.stackTagCompound.setInteger("charge", 0); } + + boolean b = true; + + if(player.inventory.hasItem(ModItems.fusion_core_infinite)) { + armor.stackTagCompound.setInteger("charge", (int)ItemBattery.getCharge(ItemBattery.getFullBattery(ModItems.fusion_core))); + } + + if(b) if (armor.stackTagCompound.getInteger("charge") <= 0) { for (int i = 0; i < player.inventory.mainInventory.length; i++) { ItemStack stack = player.inventory.getStackInSlot(i); if (stack != null && stack.getItem() == ModItems.fusion_core - && stack.getItemDamage() != stack.getMaxDamage()) { + && ItemBattery.getCharge(stack) != 0) { if (armor.stackTagCompound.getInteger("charge") == 0) { - if (world.isRemote && armor.stackTagCompound.getInteger("charge") == 0) { - } - if (!player.worldObj.isRemote) { - int j = stack.getItemDamage(); - armor.stackTagCompound.setInteger("charge", stack.getMaxDamage() - j); - player.inventory.mainInventory[i] = null; - player.addChatMessage(new ChatComponentText("[Power Armor recharged]")); - break; - } + int j = (int) ItemBattery.getCharge(stack); + armor.stackTagCompound.setInteger("charge", j); + player.inventory.mainInventory[i] = null; + player.addChatMessage(new ChatComponentText("[Power Armor recharged]")); + break; } } } @@ -191,13 +196,13 @@ public class ArmorT45 extends ItemArmor implements ISpecialArmor { && player.inventory.armorInventory[2].getItem() == ModItems.t45_plate && player.inventory.armorInventory[2].stackTagCompound != null && player.inventory.armorInventory[2].stackTagCompound.getInteger("charge") > 0) { - player.addPotionEffect(new PotionEffect(Potion.jump.id, 5, 0, true)); - player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 5, 1, true)); - player.addPotionEffect(new PotionEffect(Potion.damageBoost.id, 5, 2, true)); - player.addPotionEffect(new PotionEffect(Potion.digSpeed.id, 5, 0, true)); + player.addPotionEffect(new PotionEffect(Potion.jump.id, 20, 0, true)); + player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 20, 1, true)); + player.addPotionEffect(new PotionEffect(Potion.damageBoost.id, 20, 2, true)); + player.addPotionEffect(new PotionEffect(Potion.digSpeed.id, 20, 0, true)); } else { - player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 5, 1, true)); - player.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, 5, 0, true)); + player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 20, 1, true)); + player.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, 20, 0, true)); } } } diff --git a/com/hbm/lib/Library.java b/com/hbm/lib/Library.java index e5f6d9b3e..8d498c31a 100644 --- a/com/hbm/lib/Library.java +++ b/com/hbm/lib/Library.java @@ -677,6 +677,11 @@ public class Library { { return maxPower; } + + if(slots[index] != null && slots[index].getItem() == ModItems.fusion_core_infinite) + { + return maxPower; + } if(power + 100 <= maxPower && slots[index] != null && slots[index].getItem() == ModItems.battery_generic && ItemBattery.getCharge(slots[index]) > 0) { diff --git a/com/hbm/tileentity/TileEntityMachineDiesel.java b/com/hbm/tileentity/TileEntityMachineDiesel.java index a14855889..3f5ddda59 100644 --- a/com/hbm/tileentity/TileEntityMachineDiesel.java +++ b/com/hbm/tileentity/TileEntityMachineDiesel.java @@ -4,8 +4,12 @@ import java.util.ArrayList; import java.util.List; import com.hbm.blocks.ModBlocks; +import com.hbm.handler.FluidTypeHandler.FluidType; import com.hbm.interfaces.IConsumer; +import com.hbm.interfaces.IFluidAcceptor; +import com.hbm.interfaces.IFluidContainer; import com.hbm.interfaces.ISource; +import com.hbm.inventory.FluidTank; import com.hbm.items.ModItems; import com.hbm.items.special.ItemBattery; import com.hbm.lib.Library; @@ -19,19 +23,17 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; -public class TileEntityMachineDiesel extends TileEntity implements ISidedInventory, ISource { +public class TileEntityMachineDiesel extends TileEntity implements ISidedInventory, ISource, IFluidContainer, IFluidAcceptor { private ItemStack slots[]; public int power; - public int diesel; public int soundCycle = 0; - public static final int maxPower = 100000; - public int powerCap = 10000; - public int superTimer; - public static final int maxDiesel = 10000; + public static final int maxPower = 15000; + public int powerCap = 15000; public int age = 0; public List list = new ArrayList(); + public FluidTank tank; private static final int[] slots_top = new int[] { 0 }; private static final int[] slots_bottom = new int[] { 1, 2 }; @@ -40,7 +42,8 @@ public class TileEntityMachineDiesel extends TileEntity implements ISidedInvento private String customName; public TileEntityMachineDiesel() { - slots = new ItemStack[3]; + slots = new ItemStack[5]; + tank = new FluidTank(FluidType.DIESEL, 16000, 0); } @Override @@ -147,9 +150,8 @@ public class TileEntityMachineDiesel extends TileEntity implements ISidedInvento NBTTagList list = nbt.getTagList("items", 10); this.power = nbt.getInteger("powerTime"); - this.diesel = nbt.getInteger("diesel"); this.powerCap = nbt.getInteger("powerCap"); - this.superTimer = nbt.getInteger("superTimer"); + tank.readFromNBT(nbt, "fuel"); slots = new ItemStack[getSizeInventory()]; for (int i = 0; i < list.tagCount(); i++) { @@ -165,9 +167,8 @@ public class TileEntityMachineDiesel extends TileEntity implements ISidedInvento public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); nbt.setInteger("powerTime", power); - nbt.setInteger("diesel", diesel); nbt.setInteger("powerCap", powerCap); - nbt.setInteger("superTimer", superTimer); + tank.writeToNBT(nbt, "fuel"); NBTTagList list = new NBTTagList(); for (int i = 0; i < slots.length; i++) { @@ -203,10 +204,6 @@ public class TileEntityMachineDiesel extends TileEntity implements ISidedInvento return false; } - public int getDieselScaled(int i) { - return (diesel * i) / maxDiesel; - } - public int getPowerScaled(int i) { return (power * i) / powerCap; } @@ -218,127 +215,65 @@ public class TileEntityMachineDiesel extends TileEntity implements ISidedInvento if (age >= 20) { age = 0; } - - if(superTimer > 0) - { - superTimer--; - powerCap = 1000000000; - } - - if(superTimer <= 0 && powerCap != maxPower) - { - powerCap = maxPower; - - if(worldObj.getBlock(this.xCoord, this.yCoord + 1, this.zCoord) == Blocks.air) - worldObj.setBlock(this.xCoord, this.yCoord + 1, this.zCoord, Blocks.fire); - } if (age == 9 || age == 19) ffgeuaInit(); - if (slots[0] != null && slots[0].getItem() == ModItems.inf_diesel) { - diesel = maxDiesel; - } - - if (slots[0] != null && slots[0].getItem() == ModItems.canister_fuel && diesel + 625 <= maxDiesel) { - if (slots[1] == null || slots[1] != null && slots[1].getItem() == slots[0].getItem().getContainerItem() - && slots[1].stackSize < slots[1].getMaxStackSize()) { - if (slots[1] == null) - slots[1] = new ItemStack(slots[0].getItem().getContainerItem()); - else - slots[1].stackSize++; - - slots[0].stackSize--; - if (slots[0].stackSize <= 0) - slots[0] = null; - - diesel += 625; - } - } - - if (slots[0] != null && slots[0].getItem() == ModItems.canister_petroil && diesel + 450 <= maxDiesel) { - if (slots[1] == null || slots[1] != null && slots[1].getItem() == slots[0].getItem().getContainerItem() - && slots[1].stackSize < slots[1].getMaxStackSize()) { - if (slots[1] == null) - slots[1] = new ItemStack(slots[0].getItem().getContainerItem()); - else - slots[1].stackSize++; - - slots[0].stackSize--; - if (slots[0].stackSize <= 0) - slots[0] = null; - - diesel += 450; - } - } - - if (slots[0] != null && slots[0].getItem() == ModItems.canister_NITAN && diesel + 625 <= maxDiesel) { - if (slots[1] == null || slots[1] != null && slots[1].getItem() == slots[0].getItem().getContainerItem() - && slots[1].stackSize < slots[1].getMaxStackSize()) { - if (slots[1] == null) - slots[1] = new ItemStack(slots[0].getItem().getContainerItem()); - else - slots[1].stackSize++; - - slots[0].stackSize--; - if (slots[0].stackSize <= 0) - slots[0] = null; - - diesel += 625; - superTimer += 200; - } - } - - if (slots[0] != null && slots[0].getItem() == Item.getItemFromBlock(ModBlocks.red_barrel) - && diesel + 5000 <= maxDiesel) { - if (slots[1] == null || slots[1] != null && slots[1].getItem() == ModItems.tank_steel - && slots[1].stackSize < slots[1].getMaxStackSize()) { - if (slots[1] == null) - slots[1] = new ItemStack(ModItems.tank_steel); - else - slots[1].stackSize++; - - slots[0].stackSize--; - if (slots[0].stackSize <= 0) - slots[0] = null; - - diesel += 5000; - } - } - - // Battery Item + //Tank Management + tank.setType(3, 4, slots); + tank.loadTank(0, 1, slots); + tank.updateTank(xCoord, yCoord, zCoord); + // Battery Item power = Library.chargeItemsFromTE(slots, 2, power, maxPower); generate(); } } + + public boolean hasAcceptableFuel() { + FluidType type = tank.getTankType(); + if(type.name().equals(FluidType.DIESEL.name())) + return true; + if(type.name().equals(FluidType.PETROIL.name())) + return true; + return false; + } + + public int getHEFromFuel() { + FluidType type = tank.getTankType(); + if(type.name().equals(FluidType.DIESEL.name())) + return 250; + if(type.name().equals(FluidType.PETROIL.name())) + return 150; + return 0; + } public void generate() { - if (diesel > 0) { - if (soundCycle == 0) { - if(this.superTimer > 0) - this.worldObj.playSoundEffect(this.xCoord, this.yCoord, this.zCoord, "fireworks.blast", 1.0F, 1.0F); - else - this.worldObj.playSoundEffect(this.xCoord, this.yCoord, this.zCoord, "fireworks.blast", 1.0F, 0.5F); - } - soundCycle++; + if (hasAcceptableFuel()) { + if (tank.getFill() > 0) { + if (soundCycle == 0) { + //if (tank.getTankType().name().equals(FluidType.) > 0) + // this.worldObj.playSoundEffect(this.xCoord, this.yCoord, this.zCoord, "fireworks.blast", 1.0F, 1.0F); + //else + this.worldObj.playSoundEffect(this.xCoord, this.yCoord, this.zCoord, "fireworks.blast", 1.0F, 0.5F); + } + soundCycle++; - if (soundCycle >= 3 && this.superTimer <= 0) - soundCycle = 0; - if(this.superTimer > 0) - soundCycle = 0; + //if (soundCycle >= 3 && this.superTimer <= 0) + // soundCycle = 0; + //if (this.superTimer > 0) + // soundCycle = 0; - diesel -= 10; - if (diesel < 0) - diesel = 0; + tank.setFill(tank.getFill() - 10); + if (tank.getFill() < 0) + tank.setFill(0); - if (power + 250 <= powerCap && this.superTimer <= 0) { - power += 250; - } else if (power + 1000000000 <= powerCap && this.superTimer > 0) { - power += 1000000000; - } else { - power = powerCap; + if (power + getHEFromFuel() <= powerCap) { + power += getHEFromFuel(); + } else { + power = powerCap; + } } } } @@ -387,4 +322,30 @@ public class TileEntityMachineDiesel extends TileEntity implements ISidedInvento public void clearList() { this.list.clear(); } + + @Override + public void setFillstate(int fill, int index) { + tank.setFill(fill); + } + + @Override + public void setType(FluidType type, int index) { + tank.setTankType(type); + } + + @Override + public int getMaxAFluidFill(FluidType type) { + return type.name().equals(this.tank.getTankType().name()) ? tank.getMaxFill() : 0; + } + + @Override + public int getAFluidFill(FluidType type) { + return type.name().equals(this.tank.getTankType().name()) ? tank.getFill() : 0; + } + + @Override + public void setAFluidFill(int i, FluidType type) { + if(type.name().equals(tank.getTankType().name())) + tank.setFill(i); + } } diff --git a/com/hbm/tileentity/TileEntityMachinePuF6Tank.java b/com/hbm/tileentity/TileEntityMachinePuF6Tank.java index 6acba9ba6..36ea148d7 100644 --- a/com/hbm/tileentity/TileEntityMachinePuF6Tank.java +++ b/com/hbm/tileentity/TileEntityMachinePuF6Tank.java @@ -1,5 +1,8 @@ package com.hbm.tileentity; +import com.hbm.handler.FluidTypeHandler.FluidType; +import com.hbm.interfaces.IFluidContainer; +import com.hbm.inventory.FluidTank; import com.hbm.items.ModItems; import cpw.mods.fml.relauncher.Side; @@ -12,12 +15,11 @@ import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; -public class TileEntityMachinePuF6Tank extends TileEntity implements ISidedInventory { +public class TileEntityMachinePuF6Tank extends TileEntity implements ISidedInventory, IFluidContainer { private ItemStack slots[]; - - public int fillState; - public static final int maxFill = 64000; + + public FluidTank tank; private static final int[] slots_top = new int[] {0}; private static final int[] slots_bottom = new int[] {1, 3}; @@ -27,6 +29,7 @@ public class TileEntityMachinePuF6Tank extends TileEntity implements ISidedInven public TileEntityMachinePuF6Tank() { slots = new ItemStack[4]; + tank = new FluidTank(FluidType.PUF6, 64000, 0); } @Override @@ -131,9 +134,10 @@ public class TileEntityMachinePuF6Tank extends TileEntity implements ISidedInven super.readFromNBT(nbt); NBTTagList list = nbt.getTagList("items", 10); - fillState = nbt.getShort("fillState"); slots = new ItemStack[getSizeInventory()]; + tank.readFromNBT(nbt, "content"); + for(int i = 0; i < list.tagCount(); i++) { NBTTagCompound nbt1 = list.getCompoundTagAt(i); @@ -148,9 +152,10 @@ public class TileEntityMachinePuF6Tank extends TileEntity implements ISidedInven @Override public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); - nbt.setShort("fillState", (short) fillState); NBTTagList list = new NBTTagList(); + tank.writeToNBT(nbt, "content"); + for(int i = 0; i < slots.length; i++) { if(slots[i] != null) @@ -180,84 +185,13 @@ public class TileEntityMachinePuF6Tank extends TileEntity implements ISidedInven return true; } - public int getFillStateScaled(int i) { - return (fillState * i) / maxFill; - } - - public boolean canGive() { - if(slots[0] != null && slots[0].getItem() == ModItems.cell_puf6) - { - if(slots[1] == null || (slots[1] != null && slots[1].getItem() == ModItems.cell_empty && slots[1].stackSize < slots[1].getMaxStackSize())) - { - if(fillState < maxFill) - { - return true; - } - } - } - - return false; - } - - public boolean canTake() { - if(slots[2] != null && slots[2].getItem() == ModItems.cell_empty) - { - if(slots[3] == null || (slots[3] != null && slots[3].getItem() == ModItems.cell_puf6 && slots[3].stackSize < slots[3].getMaxStackSize())) - { - if(fillState > 0) - { - return true; - } - } - } - - return false; - } - @Override public void updateEntity() { - if(!worldObj.isRemote) { - if(this.canGive()) - { - this.slots[0].stackSize--; - if(slots[0].stackSize <= 0) - { - slots[0] = null; - } - - this.fillState += 1000; - - if(slots[1] != null) - { - slots[1].stackSize++; - } - else - { - slots[1] = new ItemStack(ModItems.cell_empty, 1); - } - } - - if(this.canTake()) - { - this.slots[2].stackSize--; - if(slots[2].stackSize <= 0) - { - slots[2] = null; - } - - this.fillState -= 1000; - - if(slots[3] != null) - { - slots[3].stackSize++; - } - else - { - slots[3] = new ItemStack(ModItems.cell_puf6, 1); - } - } + tank.loadTank(0, 1, slots); + tank.unloadTank(2, 3, slots); + tank.updateTank(xCoord, yCoord, zCoord); } } @@ -272,4 +206,14 @@ public class TileEntityMachinePuF6Tank extends TileEntity implements ISidedInven { return 65536.0D; } + + @Override + public void setFillstate(int fill, int index) { + tank.setFill(fill); + } + + @Override + public void setType(FluidType type, int index) { + tank.setTankType(type); + } } diff --git a/com/hbm/world/DesertAtom003.java b/com/hbm/world/DesertAtom003.java index 15e51f6a6..821747c4d 100644 --- a/com/hbm/world/DesertAtom003.java +++ b/com/hbm/world/DesertAtom003.java @@ -387,14 +387,14 @@ public class DesertAtom003 if(tank0 instanceof TileEntityMachinePuF6Tank) { TileEntityMachinePuF6Tank tankuf2 = (TileEntityMachinePuF6Tank)tank2; - tankuf2.fillState = rand.nextInt(TileEntityMachinePuF6Tank.maxFill); + //tankuf2.fillState = rand.nextInt(TileEntityMachinePuF6Tank.maxFill); } world.setBlock(x + 31, y + 4, z + 7, Block21, 3, 3); TileEntity tank3 = world.getTileEntity(x + 31, y + 4, z + 7); if(tank3 instanceof TileEntityMachinePuF6Tank) { TileEntityMachinePuF6Tank tankuf3 = (TileEntityMachinePuF6Tank)tank3; - tankuf3.fillState = rand.nextInt(TileEntityMachinePuF6Tank.maxFill); + //tankuf3.fillState = rand.nextInt(TileEntityMachinePuF6Tank.maxFill); } world.setBlock(x + 32, y + 4, z + 7, Block2, 0, 3); world.setBlock(x + 33, y + 4, z + 7, Block22, 0, 3);