Fixed tile assembly table on SMP.
This commit is contained in:
commit
9d30299a91
4 changed files with 57 additions and 37 deletions
|
@ -18,6 +18,7 @@ import net.minecraft.src.buildcraft.api.APIProxy;
|
|||
import net.minecraft.src.buildcraft.core.AssemblyRecipe;
|
||||
import net.minecraft.src.buildcraft.core.CoreProxy;
|
||||
import net.minecraft.src.buildcraft.core.GuiAdvancedInterface;
|
||||
import net.minecraft.src.buildcraft.core.network.PacketCoordinates;
|
||||
import net.minecraft.src.buildcraft.core.network.PacketIds;
|
||||
import net.minecraft.src.buildcraft.core.network.PacketPayload;
|
||||
import net.minecraft.src.buildcraft.core.network.PacketUpdate;
|
||||
|
@ -69,6 +70,9 @@ public class GuiAssemblyTable extends GuiAdvancedInterface {
|
|||
}
|
||||
|
||||
updateRecipes();
|
||||
|
||||
// Request current selection from server
|
||||
CoreProxy.sendToServer(new PacketCoordinates(PacketIds.SELECTION_ASSEMBLY_GET, assemblyTable.xCoord, assemblyTable.yCoord, assemblyTable.zCoord).getPacket());
|
||||
}
|
||||
|
||||
public void updateRecipes() {
|
||||
|
@ -154,9 +158,9 @@ public class GuiAssemblyTable extends GuiAdvancedInterface {
|
|||
PacketPayload payload = TileAssemblyTable.selectionMessageWrapper.toPayload(container.x, container.y,container.z, message);
|
||||
|
||||
PacketUpdate packet = new PacketUpdate(PacketIds.SELECTION_ASSEMBLY, payload);
|
||||
packet.posX = container.x;
|
||||
packet.posY = container.y;
|
||||
packet.posZ = container.z;
|
||||
packet.posX = assemblyTable.xCoord;
|
||||
packet.posY = assemblyTable.yCoord;
|
||||
packet.posZ = assemblyTable.zCoord;
|
||||
|
||||
CoreProxy.sendToServer(packet.getPacket());
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ public class PacketHandler implements IPacketHandler {
|
|||
private void onSelectionUpdate(PacketUpdate packet) {
|
||||
|
||||
GuiScreen screen = ModLoader.getMinecraftInstance().currentScreen;
|
||||
|
||||
|
||||
if (screen instanceof GuiAssemblyTable) {
|
||||
GuiAssemblyTable gui = (GuiAssemblyTable) screen;
|
||||
SelectionMessage message = new SelectionMessage();
|
||||
|
|
|
@ -3,8 +3,10 @@ package net.minecraft.src.buildcraft.factory;
|
|||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.src.BuildCraftCore;
|
||||
import net.minecraft.src.Container;
|
||||
import net.minecraft.src.EntityItem;
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
import net.minecraft.src.ICrafting;
|
||||
import net.minecraft.src.IInventory;
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
|
@ -30,6 +32,7 @@ public class TileAssemblyTable extends TileEntity implements IInventory, IPipeCo
|
|||
|
||||
public AssemblyRecipe currentRecipe;
|
||||
|
||||
private float currentRequiredEnergy = 0;
|
||||
private float energyStored = 0;
|
||||
|
||||
public static class SelectionMessage {
|
||||
|
@ -289,25 +292,33 @@ public class TileAssemblyTable extends TileEntity implements IInventory, IPipeCo
|
|||
return recipe != null && recipe == currentRecipe;
|
||||
}
|
||||
|
||||
private void setCurrentRecipe(AssemblyRecipe recipe) {
|
||||
this.currentRecipe = recipe;
|
||||
if(recipe != null)
|
||||
this.currentRequiredEnergy = recipe.energy;
|
||||
else
|
||||
this.currentRequiredEnergy = 0;
|
||||
}
|
||||
|
||||
public void planOutput (AssemblyRecipe recipe) {
|
||||
if (recipe != null && !isPlanned(recipe)) {
|
||||
plannedOutput.add(recipe);
|
||||
|
||||
if (!isAssembling(currentRecipe) || !isPlanned(currentRecipe)) {
|
||||
currentRecipe = recipe;
|
||||
setCurrentRecipe(recipe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void cancelPlanOutput(AssemblyRecipe recipe) {
|
||||
if (isAssembling(recipe)) {
|
||||
currentRecipe = null;
|
||||
setCurrentRecipe(null);
|
||||
}
|
||||
|
||||
plannedOutput.remove(recipe);
|
||||
|
||||
if (plannedOutput.size() != 0) {
|
||||
currentRecipe = plannedOutput.getFirst();
|
||||
setCurrentRecipe(plannedOutput.getFirst());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -318,19 +329,19 @@ public class TileAssemblyTable extends TileEntity implements IInventory, IPipeCo
|
|||
if (recipe == currentRecipe) {
|
||||
takeNext = true;
|
||||
} else if (takeNext && recipe.canBeDone(items)) {
|
||||
currentRecipe = recipe;
|
||||
setCurrentRecipe(recipe);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (AssemblyRecipe recipe : plannedOutput) {
|
||||
if (recipe.canBeDone(items)) {
|
||||
currentRecipe = recipe;
|
||||
setCurrentRecipe(recipe);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
currentRecipe = null;
|
||||
setCurrentRecipe(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -339,13 +350,13 @@ public class TileAssemblyTable extends TileEntity implements IInventory, IPipeCo
|
|||
}
|
||||
|
||||
public void handleSelectionMessage(SelectionMessage message) {
|
||||
for (AssemblyRecipe r : BuildCraftCore.assemblyRecipes) {
|
||||
if (r.output.itemID == message.itemID
|
||||
&& r.output.getItemDamage() == message.itemDmg) {
|
||||
for (AssemblyRecipe recipe : BuildCraftCore.assemblyRecipes) {
|
||||
if (recipe.output.itemID == message.itemID
|
||||
&& recipe.output.getItemDamage() == message.itemDmg) {
|
||||
if (message.select) {
|
||||
planOutput(r);
|
||||
planOutput(recipe);
|
||||
} else {
|
||||
cancelPlanOutput(r);
|
||||
cancelPlanOutput(recipe);
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -375,4 +386,24 @@ public class TileAssemblyTable extends TileEntity implements IInventory, IPipeCo
|
|||
mod_BuildCraftSilicon.instance);
|
||||
}
|
||||
}
|
||||
|
||||
/* SMP GUI */
|
||||
public void getGUINetworkData(int i, int j) {
|
||||
switch(i)
|
||||
{
|
||||
case 0:
|
||||
currentRequiredEnergy = j;
|
||||
break;
|
||||
case 1:
|
||||
energyStored = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void sendGUINetworkData(Container container, ICrafting iCrafting) {
|
||||
iCrafting.updateCraftingInventoryInfo(container, 0, (int)currentRequiredEnergy);
|
||||
iCrafting.updateCraftingInventoryInfo(container, 1, (int)energyStored);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
|
||||
package net.minecraft.src.buildcraft.silicon;
|
||||
|
||||
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
import net.minecraft.src.ICrafting;
|
||||
import net.minecraft.src.IInventory;
|
||||
|
@ -61,31 +60,17 @@ class ContainerAssemblyTable extends BuildCraftContainer {
|
|||
public boolean canInteractWith(EntityPlayer entityplayer) {
|
||||
return table.isUseableByPlayer(entityplayer);
|
||||
}
|
||||
|
||||
// @Override client side only
|
||||
public void updateProgressBar(int i, int j) {
|
||||
table.getGUINetworkData (i, j);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCraftingResults() {
|
||||
super.updateCraftingResults();
|
||||
|
||||
for (int i = 0; i < crafters.size(); i++) {
|
||||
ICrafting crafting = (ICrafting) crafters.get(i);
|
||||
|
||||
crafting.updateCraftingInventoryInfo(this, 0, table.xCoord);
|
||||
crafting.updateCraftingInventoryInfo(this, 1, table.yCoord);
|
||||
crafting.updateCraftingInventoryInfo(this, 2, table.zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateProgressBar(int i, int j) {
|
||||
if (i == 0) {
|
||||
x = j;
|
||||
} else if (i == 1) {
|
||||
y = j;
|
||||
} else if (i == 2) {
|
||||
z = j;
|
||||
}
|
||||
|
||||
if (!networkSynchronized && x != Integer.MAX_VALUE && y != Integer.MAX_VALUE && z != Integer.MAX_VALUE)
|
||||
networkSynchronized = true;
|
||||
CoreProxy.sendToServer(new PacketCoordinates(PacketIds.SELECTION_ASSEMBLY_GET, x, y, z).getPacket());
|
||||
for(int i = 0; i < crafters.size(); i++)
|
||||
table.sendGUINetworkData (this, (ICrafting)crafters.get(i));
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue