mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
Merge pull request #2282 from abel1502/abel-electrolyzer-persist-gui
Persist electrolyzer GUI
This commit is contained in:
commit
6374f912cb
@ -35,7 +35,7 @@ public class MachineElectrolyser extends BlockDummyable {
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
|
||||
return this.standardOpenBehavior(world, x, y, z, player, 0);
|
||||
return this.standardOpenBehavior(world, x, y, z, player, -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -66,6 +66,8 @@ public class TileEntityElectrolyser extends TileEntityMachineBase implements IEn
|
||||
public MaterialStack leftStack;
|
||||
public MaterialStack rightStack;
|
||||
public int maxMaterial = MaterialShapes.BLOCK.q(16);
|
||||
|
||||
private int lastSelectedGUI = 0;
|
||||
|
||||
public FluidTank[] tanks;
|
||||
|
||||
@ -248,6 +250,7 @@ public class TileEntityElectrolyser extends TileEntityMachineBase implements IEn
|
||||
buf.writeInt(rightStack.material.id);
|
||||
buf.writeInt(rightStack.amount);
|
||||
}
|
||||
buf.writeInt(lastSelectedGUI);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -269,6 +272,7 @@ public class TileEntityElectrolyser extends TileEntityMachineBase implements IEn
|
||||
if(right) {
|
||||
this.rightStack = new MaterialStack(Mats.matById.get(buf.readInt()), buf.readInt());
|
||||
}
|
||||
this.lastSelectedGUI = buf.readInt();
|
||||
}
|
||||
|
||||
public boolean canProcessFluid() {
|
||||
@ -423,6 +427,7 @@ public class TileEntityElectrolyser extends TileEntityMachineBase implements IEn
|
||||
if(nbt.hasKey("rightType")) this.rightStack = new MaterialStack(Mats.matById.get(nbt.getInteger("rightType")), nbt.getInteger("rightAmount"));
|
||||
else this.rightStack = null;
|
||||
for(int i = 0; i < 4; i++) tanks[i].readFromNBT(nbt, "t" + i);
|
||||
this.lastSelectedGUI = nbt.getInteger("lastSelectedGUI");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -443,7 +448,7 @@ public class TileEntityElectrolyser extends TileEntityMachineBase implements IEn
|
||||
nbt.setInteger("rightAmount", rightStack.amount);
|
||||
}
|
||||
for(int i = 0; i < 4; i++) tanks[i].writeToNBT(nbt, "t" + i);
|
||||
|
||||
nbt.setInteger("lastSelectedGUI", this.lastSelectedGUI);
|
||||
}
|
||||
|
||||
AxisAlignedBB bb = null;
|
||||
@ -503,6 +508,7 @@ public class TileEntityElectrolyser extends TileEntityMachineBase implements IEn
|
||||
|
||||
@Override
|
||||
public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
if(ID == -1) ID = lastSelectedGUI;
|
||||
if(ID == 0) return new ContainerElectrolyserFluid(player.inventory, this);
|
||||
return new ContainerElectrolyserMetal(player.inventory, this);
|
||||
}
|
||||
@ -510,6 +516,7 @@ public class TileEntityElectrolyser extends TileEntityMachineBase implements IEn
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Object provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
if(ID == -1) ID = lastSelectedGUI;
|
||||
if(ID == 0) return new GUIElectrolyserFluid(player.inventory, this);
|
||||
return new GUIElectrolyserMetal(player.inventory, this);
|
||||
}
|
||||
@ -520,8 +527,10 @@ public class TileEntityElectrolyser extends TileEntityMachineBase implements IEn
|
||||
@Override
|
||||
public void receiveControl(EntityPlayer player, NBTTagCompound data) {
|
||||
|
||||
if(data.hasKey("sgm")) FMLNetworkHandler.openGui(player, MainRegistry.instance, 1, worldObj, xCoord, yCoord, zCoord);
|
||||
if(data.hasKey("sgf")) FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, worldObj, xCoord, yCoord, zCoord);
|
||||
if(data.hasKey("sgm")) lastSelectedGUI = 1;
|
||||
if(data.hasKey("sgf")) lastSelectedGUI = 0;
|
||||
|
||||
FMLNetworkHandler.openGui(player, MainRegistry.instance, lastSelectedGUI, worldObj, xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user