More retrofitting, T45 charge fix, infinite fusion core

This commit is contained in:
HbmMods 2017-08-18 08:27:03 +02:00
parent 58d9266775
commit ba31e11f07
13 changed files with 173 additions and 286 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 287 B

View File

@ -14,19 +14,17 @@ public class ContainerMachineDiesel extends Container {
private TileEntityMachineDiesel diFurnace;
private int power;
private int diesel;
private int burnTime;
public ContainerMachineDiesel(InventoryPlayer invPlayer, TileEntityMachineDiesel tedf) {
power = 0;
diesel = 0;
burnTime = 0;
diFurnace = tedf;
this.addSlotToContainer(new Slot(tedf, 0, 44, 53));
this.addSlotToContainer(new SlotMachineOutput(invPlayer.player, tedf, 1, 80, 53));
this.addSlotToContainer(new Slot(tedf, 0, 44, 17));
this.addSlotToContainer(new SlotMachineOutput(invPlayer.player, tedf, 1, 44, 53));
this.addSlotToContainer(new Slot(tedf, 2, 116, 53));
this.addSlotToContainer(new Slot(tedf, 3, 8, 17));
this.addSlotToContainer(new SlotMachineOutput(invPlayer.player, tedf, 4, 8, 53));
for(int i = 0; i < 3; i++)
{
@ -45,8 +43,7 @@ public class ContainerMachineDiesel extends Container {
@Override
public void addCraftingToCrafters(ICrafting crafting) {
super.addCraftingToCrafters(crafting);
crafting.sendProgressBarUpdate(this, 0, this.diFurnace.diesel);
crafting.sendProgressBarUpdate(this, 1, this.diFurnace.power);
crafting.sendProgressBarUpdate(this, 0, this.diFurnace.power);
}
@Override
@ -60,8 +57,8 @@ public class ContainerMachineDiesel extends Container {
ItemStack var5 = var4.getStack();
var3 = var5.copy();
if (par2 <= 2) {
if (!this.mergeItemStack(var5, 3, this.inventorySlots.size(), true))
if (par2 <= 4) {
if (!this.mergeItemStack(var5, 5, this.inventorySlots.size(), true))
{
return null;
}
@ -69,6 +66,7 @@ public class ContainerMachineDiesel extends Container {
else if (!this.mergeItemStack(var5, 0, 1, false))
{
if (!this.mergeItemStack(var5, 2, 3, false))
if (!this.mergeItemStack(var5, 4, 5, false))
return null;
}
@ -98,28 +96,18 @@ public class ContainerMachineDiesel extends Container {
{
ICrafting par1 = (ICrafting)this.crafters.get(i);
if(this.diesel != this.diFurnace.diesel)
{
par1.sendProgressBarUpdate(this, 0, this.diFurnace.diesel);
}
if(this.power != this.diFurnace.power)
{
par1.sendProgressBarUpdate(this, 1, this.diFurnace.power);
par1.sendProgressBarUpdate(this, 0, this.diFurnace.power);
}
}
this.diesel = this.diFurnace.diesel;
this.power = this.diFurnace.power;
}
@Override
public void updateProgressBar(int i, int j) {
if(i == 0)
{
diFurnace.diesel = j;
}
if(i == 1)
{
diFurnace.power = j;
}

View File

@ -13,11 +13,8 @@ import net.minecraft.item.ItemStack;
public class ContainerPuF6Tank extends Container {
private TileEntityMachinePuF6Tank testNuke;
private int fillState;
public ContainerPuF6Tank(InventoryPlayer invPlayer, TileEntityMachinePuF6Tank tedf) {
fillState = 0;
testNuke = tedf;
this.addSlotToContainer(new Slot(tedf, 0, 44, 17));
@ -42,7 +39,6 @@ public class ContainerPuF6Tank extends Container {
@Override
public void addCraftingToCrafters(ICrafting crafting) {
super.addCraftingToCrafters(crafting);
crafting.sendProgressBarUpdate(this, 0, this.testNuke.fillState);
}
@Override
@ -86,29 +82,4 @@ public class ContainerPuF6Tank extends Container {
return testNuke.isUseableByPlayer(player);
}
@Override
public void detectAndSendChanges() {
super.detectAndSendChanges();
for(int i = 0; i < this.crafters.size(); i++)
{
ICrafting par1 = (ICrafting)this.crafters.get(i);
if(this.fillState != this.testNuke.fillState)
{
par1.sendProgressBarUpdate(this, 0, this.testNuke.fillState);
}
}
this.fillState = this.testNuke.fillState;
}
@Override
public void updateProgressBar(int i, int j) {
if(i == 0)
{
testNuke.fillState = j;
}
}
}

View File

@ -2,6 +2,7 @@ package com.hbm.inventory.gui;
import org.lwjgl.opengl.GL11;
import com.hbm.inventory.FluidTank;
import com.hbm.inventory.container.ContainerMachineDiesel;
import com.hbm.lib.RefStrings;
import com.hbm.tileentity.TileEntityMachineDiesel;
@ -12,7 +13,7 @@ import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
public class GUIMachineDiesel extends GuiContainer {
public class GUIMachineDiesel extends GuiFluidContainer {
private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/GUIDiesel.png");
private TileEntityMachineDiesel diFurnace;
@ -25,6 +26,13 @@ public class GUIMachineDiesel extends GuiContainer {
this.ySize = 166;
}
@Override
public void drawScreen(int mouseX, int mouseY, float f) {
super.drawScreen(mouseX, mouseY, f);
diFurnace.tank.renderTankInfo(this, mouseX, mouseY, guiLeft + 80, guiTop + 69 - 52, 16, 52);
}
@Override
protected void drawGuiContainerForegroundLayer(int i, int j) {
String name = this.diFurnace.hasCustomInventoryName() ? this.diFurnace.getInventoryName() : I18n.format(this.diFurnace.getInventoryName());
@ -44,11 +52,13 @@ public class GUIMachineDiesel extends GuiContainer {
drawTexturedModalRect(guiLeft + 152, guiTop + 69 - i, 176, 52 - i, 16, i);
}
if(diFurnace.diesel > 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);
}
}

View File

@ -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;
@ -25,6 +26,13 @@ public class GUIMachinePuF6Tank extends GuiContainer {
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) {
String name = this.tank.hasCustomInventoryName() ? this.tank.getInventoryName() : I18n.format(this.tank.getInventoryName());
@ -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);
}
}

View File

@ -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)));
}

View File

@ -699,6 +699,7 @@ public class ModItems {
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());

View File

@ -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,17 +160,22 @@ 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);
int j = (int) ItemBattery.getCharge(stack);
armor.stackTagCompound.setInteger("charge", j);
player.inventory.mainInventory[i] = null;
player.addChatMessage(new ChatComponentText("[Power Armor recharged]"));
break;
@ -177,7 +183,6 @@ public class ArmorT45 extends ItemArmor implements ISpecialArmor {
}
}
}
}
if (armor.stackTagCompound.getInteger("charge") > 0 && Library.checkArmor(player, ModItems.t45_helmet,
ModItems.t45_plate, ModItems.t45_legs, ModItems.t45_boots)) {
@ -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));
}
}
}

View File

@ -678,6 +678,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)
{
power += 100;

View File

@ -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<IConsumer> 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;
}
@ -219,129 +216,67 @@ public class TileEntityMachineDiesel extends TileEntity implements ISidedInvento
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;
}
}
//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 (hasAcceptableFuel()) {
if (tank.getFill() > 0) {
if (soundCycle == 0) {
if(this.superTimer > 0)
this.worldObj.playSoundEffect(this.xCoord, this.yCoord, this.zCoord, "fireworks.blast", 1.0F, 1.0F);
else
//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;
if (power + getHEFromFuel() <= powerCap) {
power += getHEFromFuel();
} else {
power = powerCap;
}
}
}
}
@Override
public void ffgeua(int x, int y, int z, boolean newTact) {
@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);