Calcinator network work
This commit is contained in:
parent
fa7df500f6
commit
a328988b28
|
@ -65,6 +65,14 @@ public class BlockCalcinator extends BlockEE implements ITileEntityProvider
|
|||
return RenderIds.calcinatorRender;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockEventReceived(World par1World, int par2, int par3, int par4, int par5, int par6)
|
||||
{
|
||||
super.onBlockEventReceived(par1World, par2, par3, par4, par5, par6);
|
||||
TileEntity tileentity = par1World.getBlockTileEntity(par2, par3, par4);
|
||||
return tileentity != null ? tileentity.receiveClientEvent(par5, par6) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
|
@ -91,7 +99,7 @@ public class BlockCalcinator extends BlockEE implements ITileEntityProvider
|
|||
{
|
||||
if (world.getBlockTileEntity(x, y, z) instanceof TileCalcinator)
|
||||
{
|
||||
if (((TileCalcinator) world.getBlockTileEntity(x, y, z)).isBurning())
|
||||
if (((TileCalcinator) world.getBlockTileEntity(x, y, z)).getState() == 1)
|
||||
{
|
||||
// Fire pot particles
|
||||
// TODO TileEntity.onClientEvent to update particles
|
||||
|
|
|
@ -50,7 +50,7 @@ public class GuiCalcinator extends GuiContainer
|
|||
this.drawTexturedModalRect(xStart, yStart, 0, 0, xSize, ySize);
|
||||
int scaleAdjustment;
|
||||
|
||||
if (this.tileCalcinator.isBurning())
|
||||
if (this.tileCalcinator.getState() == 1)
|
||||
{
|
||||
scaleAdjustment = this.tileCalcinator.getBurnTimeRemainingScaled(12);
|
||||
this.drawTexturedModalRect(xStart + 57, yStart + 36 + 23 - scaleAdjustment, 176, 12 - scaleAdjustment, 14, scaleAdjustment + 2);
|
||||
|
|
|
@ -80,7 +80,7 @@ public class ItemCalcinatorRenderer implements IItemRenderer
|
|||
GL11.glRotatef(-90F, 1F, 0, 0);
|
||||
|
||||
// Bind texture
|
||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(Textures.MODEL_CALCINATOR);
|
||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(Textures.MODEL_CALCINATOR_IDLE);
|
||||
|
||||
// Render
|
||||
modelCalcinator.renderPart("Calcinator");
|
||||
|
|
|
@ -42,7 +42,14 @@ public class TileEntityCalcinatorRenderer extends TileEntitySpecialRenderer
|
|||
GL11.glRotatef(-90F, 1F, 0F, 0F);
|
||||
|
||||
// Bind texture
|
||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(Textures.MODEL_CALCINATOR);
|
||||
if (tileCalcinator.getState() == 1)
|
||||
{
|
||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(Textures.MODEL_CALCINATOR_ACTIVE);
|
||||
}
|
||||
else
|
||||
{
|
||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(Textures.MODEL_CALCINATOR_IDLE);
|
||||
}
|
||||
|
||||
// Render
|
||||
modelCalcinator.renderPart("Calcinator");
|
||||
|
|
|
@ -35,8 +35,6 @@ public class CraftingHandler implements ICraftingHandler
|
|||
RecipesVanilla.init();
|
||||
RecipesTransmutationStones.init();
|
||||
RecipesAludel.getInstance();
|
||||
|
||||
RecipesAludel.getInstance().debugDumpMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -127,7 +127,7 @@ public class ContainerCalcinator extends Container
|
|||
public void addCraftingToCrafters(ICrafting iCrafting)
|
||||
{
|
||||
super.addCraftingToCrafters(iCrafting);
|
||||
iCrafting.sendProgressBarUpdate(this, 0, this.calcinator.calcinatorCookTime);
|
||||
iCrafting.sendProgressBarUpdate(this, 0, this.calcinator.deviceCookTime);
|
||||
iCrafting.sendProgressBarUpdate(this, 1, this.calcinator.fuelBurnTime);
|
||||
iCrafting.sendProgressBarUpdate(this, 2, this.calcinator.itemCookTime);
|
||||
}
|
||||
|
@ -141,9 +141,9 @@ public class ContainerCalcinator extends Container
|
|||
{
|
||||
ICrafting icrafting = (ICrafting) this.crafters.get(i);
|
||||
|
||||
if (this.lastCookTime != this.calcinator.calcinatorCookTime)
|
||||
if (this.lastCookTime != this.calcinator.deviceCookTime)
|
||||
{
|
||||
icrafting.sendProgressBarUpdate(this, 0, this.calcinator.calcinatorCookTime);
|
||||
icrafting.sendProgressBarUpdate(this, 0, this.calcinator.deviceCookTime);
|
||||
}
|
||||
|
||||
if (this.lastBurnTime != this.calcinator.fuelBurnTime)
|
||||
|
@ -157,7 +157,7 @@ public class ContainerCalcinator extends Container
|
|||
}
|
||||
}
|
||||
|
||||
this.lastCookTime = this.calcinator.calcinatorCookTime;
|
||||
this.lastCookTime = this.calcinator.deviceCookTime;
|
||||
this.lastBurnTime = this.calcinator.fuelBurnTime;
|
||||
this.lastItemCookTime = this.calcinator.itemCookTime;
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ public class ContainerCalcinator extends Container
|
|||
{
|
||||
if (valueType == 0)
|
||||
{
|
||||
this.calcinator.calcinatorCookTime = updatedValue;
|
||||
this.calcinator.deviceCookTime = updatedValue;
|
||||
}
|
||||
|
||||
if (valueType == 1)
|
||||
|
|
|
@ -36,7 +36,8 @@ public class Textures
|
|||
public static final ResourceLocation GUI_GLASS_BELL = ResourceLocationHelper.getResourceLocation(GUI_SHEET_LOCATION + "glassBell.png");
|
||||
|
||||
// Model textures
|
||||
public static final ResourceLocation MODEL_CALCINATOR = ResourceLocationHelper.getResourceLocation(MODEL_TEXTURE_LOCATION + "calcinator.png");
|
||||
public static final ResourceLocation MODEL_CALCINATOR_IDLE = ResourceLocationHelper.getResourceLocation(MODEL_TEXTURE_LOCATION + "calcinator.png");
|
||||
public static final ResourceLocation MODEL_CALCINATOR_ACTIVE = ResourceLocationHelper.getResourceLocation(MODEL_TEXTURE_LOCATION + "calcinator_Active.png");
|
||||
public static final ResourceLocation MODEL_ALUDEL = ResourceLocationHelper.getResourceLocation(MODEL_TEXTURE_LOCATION + "aludel.png");
|
||||
public static final ResourceLocation MODEL_ALCHEMICAL_CHEST_SMALL = ResourceLocationHelper.getResourceLocation(MODEL_TEXTURE_LOCATION + "alchemicalChest_Small.png");
|
||||
public static final ResourceLocation MODEL_ALCHEMICAL_CHEST_MEDIUM = ResourceLocationHelper.getResourceLocation(MODEL_TEXTURE_LOCATION + "alchemicalChest_Medium.png");
|
||||
|
|
|
@ -15,7 +15,6 @@ import net.minecraft.network.packet.Packet250CustomPayload;
|
|||
*/
|
||||
public class PacketHandler implements IPacketHandler
|
||||
{
|
||||
|
||||
/**
|
||||
* Handles Packet250CustomPayload packets that are registered to an Equivalent Exchange 3 network channel
|
||||
*
|
||||
|
@ -29,7 +28,6 @@ public class PacketHandler implements IPacketHandler
|
|||
@Override
|
||||
public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player)
|
||||
{
|
||||
|
||||
// Build a PacketEE object from the data contained within the Packet250CustomPayload packet
|
||||
PacketEE packetEE = PacketTypeHandler.buildPacket(packet.data);
|
||||
|
||||
|
|
|
@ -29,13 +29,11 @@ public enum PacketTypeHandler
|
|||
|
||||
PacketTypeHandler(Class<? extends PacketEE> clazz)
|
||||
{
|
||||
|
||||
this.clazz = clazz;
|
||||
}
|
||||
|
||||
public static PacketEE buildPacket(byte[] data)
|
||||
{
|
||||
|
||||
ByteArrayInputStream bis = new ByteArrayInputStream(data);
|
||||
int selector = bis.read();
|
||||
DataInputStream dis = new DataInputStream(bis);
|
||||
|
@ -58,7 +56,6 @@ public enum PacketTypeHandler
|
|||
|
||||
public static PacketEE buildPacket(PacketTypeHandler type)
|
||||
{
|
||||
|
||||
PacketEE packet = null;
|
||||
|
||||
try
|
||||
|
@ -75,7 +72,6 @@ public enum PacketTypeHandler
|
|||
|
||||
public static Packet populatePacket(PacketEE packetEE)
|
||||
{
|
||||
|
||||
byte[] data = packetEE.populate();
|
||||
|
||||
Packet250CustomPayload packet250 = new Packet250CustomPayload();
|
||||
|
|
|
@ -19,7 +19,6 @@ import java.io.IOException;
|
|||
*/
|
||||
public class PacketTileUpdate extends PacketEE
|
||||
{
|
||||
|
||||
public int x, y, z;
|
||||
public byte orientation;
|
||||
public byte state;
|
||||
|
@ -27,13 +26,11 @@ public class PacketTileUpdate extends PacketEE
|
|||
|
||||
public PacketTileUpdate()
|
||||
{
|
||||
|
||||
super(PacketTypeHandler.TILE, true);
|
||||
}
|
||||
|
||||
public PacketTileUpdate(int x, int y, int z, ForgeDirection orientation, byte state, String customName)
|
||||
{
|
||||
|
||||
super(PacketTypeHandler.TILE, true);
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
|
@ -46,7 +43,6 @@ public class PacketTileUpdate extends PacketEE
|
|||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException
|
||||
{
|
||||
|
||||
data.writeInt(x);
|
||||
data.writeInt(y);
|
||||
data.writeInt(z);
|
||||
|
@ -58,7 +54,6 @@ public class PacketTileUpdate extends PacketEE
|
|||
@Override
|
||||
public void readData(DataInputStream data) throws IOException
|
||||
{
|
||||
|
||||
x = data.readInt();
|
||||
y = data.readInt();
|
||||
z = data.readInt();
|
||||
|
|
|
@ -12,7 +12,6 @@ import java.io.IOException;
|
|||
|
||||
public class PacketTileWithItemUpdate extends PacketEE
|
||||
{
|
||||
|
||||
public int x, y, z;
|
||||
public byte orientation;
|
||||
public byte state;
|
||||
|
@ -21,13 +20,11 @@ public class PacketTileWithItemUpdate extends PacketEE
|
|||
|
||||
public PacketTileWithItemUpdate()
|
||||
{
|
||||
|
||||
super(PacketTypeHandler.TILE_WITH_ITEM, true);
|
||||
}
|
||||
|
||||
public PacketTileWithItemUpdate(int x, int y, int z, ForgeDirection orientation, byte state, String customName, int itemID, int metaData, int stackSize, int color)
|
||||
{
|
||||
|
||||
super(PacketTypeHandler.TILE_WITH_ITEM, true);
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
|
@ -44,7 +41,6 @@ public class PacketTileWithItemUpdate extends PacketEE
|
|||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException
|
||||
{
|
||||
|
||||
data.writeInt(x);
|
||||
data.writeInt(y);
|
||||
data.writeInt(z);
|
||||
|
@ -60,7 +56,6 @@ public class PacketTileWithItemUpdate extends PacketEE
|
|||
@Override
|
||||
public void readData(DataInputStream data) throws IOException
|
||||
{
|
||||
|
||||
x = data.readInt();
|
||||
y = data.readInt();
|
||||
z = data.readInt();
|
||||
|
@ -76,7 +71,6 @@ public class PacketTileWithItemUpdate extends PacketEE
|
|||
@Override
|
||||
public void execute(INetworkManager manager, Player player)
|
||||
{
|
||||
|
||||
EquivalentExchange3.proxy.handleTileWithItemPacket(x, y, z, ForgeDirection.getOrientation(orientation), state, customName, itemID, metaData, stackSize, color);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@ import net.minecraft.network.packet.Packet;
|
|||
*/
|
||||
public class TileAludel extends TileEE implements IInventory
|
||||
{
|
||||
|
||||
/**
|
||||
* The ItemStacks that hold the items currently being used in the Aludel
|
||||
*/
|
||||
|
@ -32,9 +31,12 @@ public class TileAludel extends TileEE implements IInventory
|
|||
public static final int DUST_INVENTORY_INDEX = 2;
|
||||
public static final int OUTPUT_INVENTORY_INDEX = 3;
|
||||
|
||||
public int deviceCookTime; // How much longer the Aludel will cook
|
||||
public int fuelBurnTime; // The fuel value for the currently burning fuel
|
||||
public int itemCookTime; // How long the current item has been "cooking"
|
||||
|
||||
public TileAludel()
|
||||
{
|
||||
|
||||
inventory = new ItemStack[INVENTORY_SIZE];
|
||||
}
|
||||
|
||||
|
@ -48,14 +50,12 @@ public class TileAludel extends TileEE implements IInventory
|
|||
@Override
|
||||
public ItemStack getStackInSlot(int slotIndex)
|
||||
{
|
||||
|
||||
return inventory[slotIndex];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slotIndex, int decrementAmount)
|
||||
{
|
||||
|
||||
ItemStack itemStack = getStackInSlot(slotIndex);
|
||||
if (itemStack != null)
|
||||
{
|
||||
|
@ -79,7 +79,6 @@ public class TileAludel extends TileEE implements IInventory
|
|||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slotIndex)
|
||||
{
|
||||
|
||||
ItemStack itemStack = getStackInSlot(slotIndex);
|
||||
if (itemStack != null)
|
||||
{
|
||||
|
@ -91,7 +90,6 @@ public class TileAludel extends TileEE implements IInventory
|
|||
@Override
|
||||
public void setInventorySlotContents(int slotIndex, ItemStack itemStack)
|
||||
{
|
||||
|
||||
inventory[slotIndex] = itemStack;
|
||||
if (itemStack != null && itemStack.stackSize > getInventoryStackLimit())
|
||||
{
|
||||
|
@ -102,33 +100,30 @@ public class TileAludel extends TileEE implements IInventory
|
|||
@Override
|
||||
public String getInvName()
|
||||
{
|
||||
|
||||
return this.hasCustomName() ? this.getCustomName() : Strings.CONTAINER_ALUDEL_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openChest()
|
||||
{
|
||||
|
||||
// NOOP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeChest()
|
||||
{
|
||||
|
||||
// NOOP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbtTagCompound)
|
||||
{
|
||||
|
||||
super.readFromNBT(nbtTagCompound);
|
||||
|
||||
// Read in the ItemStacks in the inventory from NBT
|
||||
|
@ -148,7 +143,6 @@ public class TileAludel extends TileEE implements IInventory
|
|||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbtTagCompound)
|
||||
{
|
||||
|
||||
super.writeToNBT(nbtTagCompound);
|
||||
|
||||
// Write the ItemStacks in the inventory to NBT
|
||||
|
@ -169,21 +163,18 @@ public class TileAludel extends TileEE implements IInventory
|
|||
@Override
|
||||
public boolean isInvNameLocalized()
|
||||
{
|
||||
|
||||
return this.hasCustomName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack)
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket()
|
||||
{
|
||||
|
||||
ItemStack itemStack = getStackInSlot(INPUT_INVENTORY_INDEX);
|
||||
|
||||
if (itemStack != null && itemStack.stackSize > 0)
|
||||
|
@ -199,7 +190,6 @@ public class TileAludel extends TileEE implements IInventory
|
|||
@Override
|
||||
public void onInventoryChanged()
|
||||
{
|
||||
|
||||
worldObj.updateAllLightTypes(xCoord, yCoord, zCoord);
|
||||
|
||||
if (worldObj.getBlockTileEntity(xCoord, yCoord + 1, zCoord) instanceof TileGlassBell)
|
||||
|
@ -211,7 +201,6 @@ public class TileAludel extends TileEE implements IInventory
|
|||
@Override
|
||||
public String toString()
|
||||
{
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
|
||||
stringBuilder.append(super.toString());
|
||||
|
|
|
@ -32,10 +32,13 @@ public class TileCalcinator extends TileEE implements IInventory
|
|||
public static final int OUTPUT_LEFT_INVENTORY_INDEX = 2;
|
||||
public static final int OUTPUT_RIGHT_INVENTORY_INDEX = 3;
|
||||
|
||||
public int calcinatorCookTime; // How much longer the Calcinator will cook
|
||||
public int deviceCookTime; // How much longer the Calcinator will cook
|
||||
public int fuelBurnTime; // The fuel value for the currently burning fuel
|
||||
public int itemCookTime; // How long the current item has been "cooking"
|
||||
|
||||
public String dustColour;
|
||||
public int dustPileSize;
|
||||
|
||||
public TileCalcinator()
|
||||
{
|
||||
inventory = new ItemStack[INVENTORY_SIZE];
|
||||
|
@ -115,6 +118,20 @@ public class TileCalcinator extends TileEE implements IInventory
|
|||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean receiveClientEvent(int eventId, int eventData)
|
||||
{
|
||||
if (eventId == 1)
|
||||
{
|
||||
this.state = (byte) eventData;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return super.receiveClientEvent(eventId, eventData);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openChest()
|
||||
{
|
||||
|
@ -181,24 +198,27 @@ public class TileCalcinator extends TileEE implements IInventory
|
|||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
boolean isBurning = this.calcinatorCookTime > 0;
|
||||
boolean isBurning = this.deviceCookTime > 0;
|
||||
this.state = this.deviceCookTime > 0 ? (byte) 1 : (byte) 0;
|
||||
boolean inventoryChanged = false;
|
||||
|
||||
// If the Calcinator still has burn time, decrement it
|
||||
if (this.calcinatorCookTime > 0)
|
||||
if (this.deviceCookTime > 0)
|
||||
{
|
||||
this.calcinatorCookTime--;
|
||||
this.deviceCookTime--;
|
||||
}
|
||||
|
||||
// TODO Make this less network spammy
|
||||
this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType().blockID, 1, this.state);
|
||||
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
if (this.calcinatorCookTime == 0 && this.canCalcinate())
|
||||
if (this.deviceCookTime == 0 && this.canCalcinate())
|
||||
{
|
||||
// TODO Effect burn speed by fuel quality
|
||||
// TODO Notify the client that we are still burning
|
||||
this.fuelBurnTime = this.calcinatorCookTime = TileEntityFurnace.getItemBurnTime(this.inventory[FUEL_INVENTORY_INDEX]);
|
||||
this.fuelBurnTime = this.deviceCookTime = TileEntityFurnace.getItemBurnTime(this.inventory[FUEL_INVENTORY_INDEX]);
|
||||
|
||||
if (this.calcinatorCookTime > 0)
|
||||
if (this.deviceCookTime > 0)
|
||||
{
|
||||
inventoryChanged = true;
|
||||
|
||||
|
@ -214,7 +234,7 @@ public class TileCalcinator extends TileEE implements IInventory
|
|||
}
|
||||
}
|
||||
|
||||
if (this.isBurning() && this.canCalcinate())
|
||||
if (this.deviceCookTime > 0 && this.canCalcinate())
|
||||
{
|
||||
this.itemCookTime++;
|
||||
|
||||
|
@ -230,10 +250,9 @@ public class TileCalcinator extends TileEE implements IInventory
|
|||
this.itemCookTime = 0;
|
||||
}
|
||||
|
||||
if (isBurning != this.calcinatorCookTime > 0)
|
||||
if (isBurning != this.deviceCookTime > 0)
|
||||
{
|
||||
inventoryChanged = true;
|
||||
// TODO Add in world effects to show that we are making dust
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -243,11 +262,6 @@ public class TileCalcinator extends TileEE implements IInventory
|
|||
}
|
||||
}
|
||||
|
||||
public boolean isBurning()
|
||||
{
|
||||
return this.calcinatorCookTime > 0;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getCookProgressScaled(int scale)
|
||||
{
|
||||
|
@ -262,7 +276,7 @@ public class TileCalcinator extends TileEE implements IInventory
|
|||
this.itemCookTime = 200;
|
||||
}
|
||||
|
||||
return this.calcinatorCookTime * scale / this.fuelBurnTime;
|
||||
return this.deviceCookTime * scale / this.fuelBurnTime;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Binary file not shown.
Loading…
Reference in a new issue