mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-13 17:04:24 +00:00
Fix Tanks doing their stuff clientside #1535
As a side effect this change also fixes the tank-filling-animation and synchronizes it
This commit is contained in:
1 parent
7e0b9faea4
commit
d37db87c2d
2 files changed
+38
-28
No files matched your search
@@ -163,7 +163,8 @@ public class LavaTankBlock extends BlockContainer
|
||||
{
|
||||
FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(current);
|
||||
LavaTankLogic logic = (LavaTankLogic) world.getTileEntity(i, j, k);
|
||||
if (liquid != null)
|
||||
// putting liquid into the tank
|
||||
if (liquid != null && !world.isRemote)
|
||||
{
|
||||
int amount = logic.fill(ForgeDirection.UNKNOWN, liquid, false);
|
||||
if (amount == liquid.amount)
|
||||
@@ -171,41 +172,43 @@ public class LavaTankBlock extends BlockContainer
|
||||
logic.fill(ForgeDirection.UNKNOWN, liquid, true);
|
||||
if (!entityplayer.capabilities.isCreativeMode)
|
||||
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, consumeItem(current));
|
||||
return true;
|
||||
|
||||
// update
|
||||
entityplayer.inventoryContainer.detectAndSendChanges();
|
||||
world.markBlockForUpdate(i,j,k);
|
||||
}
|
||||
else
|
||||
return true;
|
||||
|
||||
return true;
|
||||
}
|
||||
// taking liquit out of the tank
|
||||
else if (FluidContainerRegistry.isBucket(current))
|
||||
{
|
||||
FluidTankInfo[] tanks = logic.getTankInfo(ForgeDirection.UNKNOWN);
|
||||
FluidStack fillFluid = tanks[0].fluid;// getFluid();
|
||||
ItemStack fillStack = FluidContainerRegistry.fillFluidContainer(fillFluid, current);
|
||||
if (fillStack != null)
|
||||
{
|
||||
logic.drain(ForgeDirection.UNKNOWN, FluidContainerRegistry.getFluidForFilledItem(fillStack).amount, true);
|
||||
if (!entityplayer.capabilities.isCreativeMode)
|
||||
{
|
||||
if (current.stackSize == 1)
|
||||
{
|
||||
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, fillStack);
|
||||
}
|
||||
else
|
||||
{
|
||||
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, consumeItem(current));
|
||||
if(!world.isRemote) {
|
||||
ItemStack fillStack = FluidContainerRegistry.fillFluidContainer(fillFluid, current);
|
||||
if (fillStack != null) {
|
||||
logic.drain(ForgeDirection.UNKNOWN, FluidContainerRegistry.getFluidForFilledItem(fillStack).amount, true);
|
||||
if (!entityplayer.capabilities.isCreativeMode && !world.isRemote) {
|
||||
if (current.stackSize == 1) {
|
||||
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, fillStack);
|
||||
} else {
|
||||
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, consumeItem(current));
|
||||
|
||||
if (!entityplayer.inventory.addItemStackToInventory(fillStack))
|
||||
{
|
||||
entityplayer.dropPlayerItemWithRandomChoice(fillStack, false);
|
||||
if (!entityplayer.inventory.addItemStackToInventory(fillStack)) {
|
||||
entityplayer.dropPlayerItemWithRandomChoice(fillStack, false);
|
||||
}
|
||||
}
|
||||
|
||||
// update inventory
|
||||
entityplayer.inventoryContainer.detectAndSendChanges();
|
||||
// and block
|
||||
}
|
||||
world.markBlockForUpdate(i, j, k);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ public class LavaTankLogic extends MultiServantLogic implements IFluidHandler
|
||||
int amount = tank.fill(resource, doFill);
|
||||
if (amount > 0 && doFill)
|
||||
{
|
||||
renderOffset = resource.amount;
|
||||
renderOffset += resource.amount;
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, this.getBlockType());
|
||||
}
|
||||
@@ -135,6 +135,9 @@ public class LavaTankLogic extends MultiServantLogic implements IFluidHandler
|
||||
}
|
||||
else
|
||||
tank.setFluid(null);
|
||||
|
||||
if(tags.hasKey("renderOffset"))
|
||||
renderOffset = tags.getInteger("renderOffset");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -147,6 +150,7 @@ public class LavaTankLogic extends MultiServantLogic implements IFluidHandler
|
||||
tags.setString("fluidName", liquid.getFluid().getName());
|
||||
tags.setInteger("amount", liquid.amount);
|
||||
}
|
||||
tags.setInteger("renderOffset", renderOffset);
|
||||
}
|
||||
|
||||
/* Packets */
|
||||
@@ -175,9 +179,12 @@ public class LavaTankLogic extends MultiServantLogic implements IFluidHandler
|
||||
@Override
|
||||
public void updateEntity ()
|
||||
{
|
||||
if (renderOffset > 0)
|
||||
if (renderOffset != 0)
|
||||
{
|
||||
renderOffset -= 6;
|
||||
renderOffset -= renderOffset/12 + 1; // has to be at least 1
|
||||
|
||||
if(renderOffset < 0)
|
||||
renderOffset = 0;
|
||||
worldObj.func_147479_m(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user