Added hot plate stack size cache preventing smelt time cheat
This commit is contained in:
parent
cd593898a3
commit
c38290a920
2 changed files with 40 additions and 17 deletions
|
@ -53,9 +53,9 @@ public class InventoryCrate extends ExternalInventory
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NBTTagCompound save(NBTTagCompound nbt)
|
public void save(NBTTagCompound nbt)
|
||||||
{
|
{
|
||||||
return nbt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -10,8 +10,6 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.network.packet.Packet;
|
import net.minecraft.network.packet.Packet;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import resonantinduction.core.ResonantInduction;
|
import resonantinduction.core.ResonantInduction;
|
||||||
import universalelectricity.api.vector.Vector2;
|
|
||||||
import universalelectricity.api.vector.Vector3;
|
|
||||||
import calclavia.lib.network.IPacketReceiver;
|
import calclavia.lib.network.IPacketReceiver;
|
||||||
import calclavia.lib.network.IPacketSender;
|
import calclavia.lib.network.IPacketSender;
|
||||||
import calclavia.lib.network.PacketHandler;
|
import calclavia.lib.network.PacketHandler;
|
||||||
|
@ -33,6 +31,7 @@ public class TileHotPlate extends TileExternalInventory implements IPacketSender
|
||||||
*/
|
*/
|
||||||
private final int POWER = 50000;
|
private final int POWER = 50000;
|
||||||
public final int[] smeltTime = new int[] { 0, 0, 0, 0 };
|
public final int[] smeltTime = new int[] { 0, 0, 0, 0 };
|
||||||
|
public final int[] stackSizeCache = new int[] { 0, 0, 0, 0 };
|
||||||
public static final int MAX_SMELT_TIME = 200;
|
public static final int MAX_SMELT_TIME = 200;
|
||||||
|
|
||||||
public TileHotPlate()
|
public TileHotPlate()
|
||||||
|
@ -60,7 +59,8 @@ public class TileHotPlate extends TileExternalInventory implements IPacketSender
|
||||||
/**
|
/**
|
||||||
* Heat up all slots
|
* Heat up all slots
|
||||||
*/
|
*/
|
||||||
smeltTime[i] = MAX_SMELT_TIME * this.getStackInSlot(i).stackSize;
|
stackSizeCache[i] = this.getStackInSlot(i).stackSize;
|
||||||
|
smeltTime[i] = MAX_SMELT_TIME * stackSizeCache[i];
|
||||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||||
}
|
}
|
||||||
else if (smeltTime[i] > 0)
|
else if (smeltTime[i] > 0)
|
||||||
|
@ -73,7 +73,7 @@ public class TileHotPlate extends TileExternalInventory implements IPacketSender
|
||||||
if (!worldObj.isRemote)
|
if (!worldObj.isRemote)
|
||||||
{
|
{
|
||||||
ItemStack outputStack = FurnaceRecipes.smelting().getSmeltingResult(getStackInSlot(i)).copy();
|
ItemStack outputStack = FurnaceRecipes.smelting().getSmeltingResult(getStackInSlot(i)).copy();
|
||||||
outputStack.stackSize = this.getStackInSlot(i).stackSize;
|
outputStack.stackSize = stackSizeCache[i];
|
||||||
setInventorySlotContents(i, outputStack);
|
setInventorySlotContents(i, outputStack);
|
||||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||||
}
|
}
|
||||||
|
@ -90,6 +90,40 @@ public class TileHotPlate extends TileExternalInventory implements IPacketSender
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onInventoryChanged()
|
||||||
|
{
|
||||||
|
super.onInventoryChanged();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update cache calculation.
|
||||||
|
*/
|
||||||
|
for (int i = 0; i < invSlots; i++)
|
||||||
|
{
|
||||||
|
if (getStackInSlot(i) != null)
|
||||||
|
{
|
||||||
|
if (stackSizeCache[i] != getStackInSlot(i).stackSize)
|
||||||
|
{
|
||||||
|
if (smeltTime[i] > 0)
|
||||||
|
{
|
||||||
|
smeltTime[i] += (getStackInSlot(i).stackSize - stackSizeCache[i]) * MAX_SMELT_TIME;
|
||||||
|
}
|
||||||
|
|
||||||
|
stackSizeCache[i] = getStackInSlot(i).stackSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
stackSizeCache[i] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (worldObj != null)
|
||||||
|
{
|
||||||
|
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean canSmelt(ItemStack stack)
|
public boolean canSmelt(ItemStack stack)
|
||||||
{
|
{
|
||||||
return FurnaceRecipes.smelting().getSmeltingResult(stack) != null;
|
return FurnaceRecipes.smelting().getSmeltingResult(stack) != null;
|
||||||
|
@ -125,17 +159,6 @@ public class TileHotPlate extends TileExternalInventory implements IPacketSender
|
||||||
return ResonantInduction.PACKET_TILE.getPacket(this, this.getPacketData(0).toArray());
|
return ResonantInduction.PACKET_TILE.getPacket(this, this.getPacketData(0).toArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onInventoryChanged()
|
|
||||||
{
|
|
||||||
super.onInventoryChanged();
|
|
||||||
|
|
||||||
if (worldObj != null)
|
|
||||||
{
|
|
||||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 1 - Description Packet
|
* 1 - Description Packet
|
||||||
* 2 - Energy Update
|
* 2 - Energy Update
|
||||||
|
|
Loading…
Reference in a new issue