mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-24 22:04:34 +00:00
#561 Add "gui open" and "active" packet updates
This commit is contained in:
1 parent
0655ea235a
commit
68315ee614
23 files changed
+377
-142
No files matched your search
@@ -59,19 +59,19 @@ public class GuiHandlerApiculture extends GuiHandlerBase {
|
||||
switch (GuiId.values()[cleanId]) {
|
||||
|
||||
case AlvearyGUI:
|
||||
return new GuiAlveary(player.inventory, (TileAlvearyPlain) getTileForestry(world, x, y, z));
|
||||
return new GuiAlveary(player.inventory, getTileForestry(world, x, y, z, TileAlvearyPlain.class));
|
||||
|
||||
case AlvearySieveGUI:
|
||||
return new GuiAlvearySieve(player.inventory, (TileAlvearySieve) getTileForestry(world, x, y, z));
|
||||
return new GuiAlvearySieve(player.inventory, getTileForestry(world, x, y, z, TileAlvearySieve.class));
|
||||
|
||||
case AlvearySwarmerGUI:
|
||||
return new GuiAlvearySwarmer(player.inventory, (TileAlvearySwarmer) getTileForestry(world, x, y, z));
|
||||
return new GuiAlvearySwarmer(player.inventory, getTileForestry(world, x, y, z, TileAlvearySwarmer.class));
|
||||
|
||||
case ApiaristChestGUI:
|
||||
return getNaturalistChestGui(BeeHelper.UID, player, world, x, y, z, guiData);
|
||||
|
||||
case ApiaryGUI:
|
||||
return new GuiApiary(player.inventory, (TileApiary) getTileForestry(world, x, y, z));
|
||||
return new GuiApiary(player.inventory, getTileForestry(world, x, y, z, TileApiary.class));
|
||||
|
||||
case BeealyzerGUI:
|
||||
equipped = player.getCurrentEquippedItem();
|
||||
@@ -82,7 +82,7 @@ public class GuiHandlerApiculture extends GuiHandlerBase {
|
||||
return new GuiBeealyzer(player, new BeealyzerInventory(player, equipped));
|
||||
|
||||
case BeehouseGUI:
|
||||
return new GuiApiary(player.inventory, (TileBeehouse) getTileForestry(world, x, y, z));
|
||||
return new GuiApiary(player.inventory, getTileForestry(world, x, y, z, TileBeehouse.class));
|
||||
|
||||
case HabitatLocatorGUI:
|
||||
equipped = player.getCurrentEquippedItem();
|
||||
@@ -93,7 +93,7 @@ public class GuiHandlerApiculture extends GuiHandlerBase {
|
||||
return new GuiHabitatLocator(player, new HabitatLocatorInventory(player, equipped));
|
||||
|
||||
case HygroregulatorGUI:
|
||||
return new GuiAlvearyHygroregulator(player.inventory, (TileAlvearyHygroregulator) getTileForestry(world, x, y, z));
|
||||
return new GuiAlvearyHygroregulator(player.inventory, getTileForestry(world, x, y, z, TileAlvearyHygroregulator.class));
|
||||
|
||||
case ImprinterGUI:
|
||||
equipped = player.getCurrentEquippedItem();
|
||||
@@ -122,20 +122,20 @@ public class GuiHandlerApiculture extends GuiHandlerBase {
|
||||
|
||||
case AlvearyGUI:
|
||||
synchApiaristTracker(world, player);
|
||||
return new ContainerAlveary(player.inventory, (TileAlvearyPlain) getTileForestry(world, x, y, z));
|
||||
return new ContainerAlveary(player.inventory, getTileForestry(world, x, y, z, TileAlvearyPlain.class));
|
||||
|
||||
case AlvearySieveGUI:
|
||||
return new ContainerAlvearySieve(player.inventory, (TileAlvearySieve) getTileForestry(world, x, y, z));
|
||||
return new ContainerAlvearySieve(player.inventory, getTileForestry(world, x, y, z, TileAlvearySieve.class));
|
||||
|
||||
case AlvearySwarmerGUI:
|
||||
return new ContainerAlvearySwarmer(player.inventory, (TileAlvearySwarmer) getTileForestry(world, x, y, z));
|
||||
return new ContainerAlvearySwarmer(player.inventory, getTileForestry(world, x, y, z, TileAlvearySwarmer.class));
|
||||
|
||||
case ApiaristChestGUI:
|
||||
return getNaturalistChestContainer(BeeHelper.UID, player, world, x, y, z, guiData);
|
||||
|
||||
case ApiaryGUI:
|
||||
synchApiaristTracker(world, player);
|
||||
return new ContainerApiary(player.inventory, (TileApiary) getTileForestry(world, x, y, z), true);
|
||||
return new ContainerApiary(player.inventory, getTileForestry(world, x, y, z, TileApiary.class), true);
|
||||
|
||||
case BeealyzerGUI:
|
||||
equipped = player.getCurrentEquippedItem();
|
||||
@@ -148,7 +148,7 @@ public class GuiHandlerApiculture extends GuiHandlerBase {
|
||||
|
||||
case BeehouseGUI:
|
||||
synchApiaristTracker(world, player);
|
||||
return new ContainerApiary(player.inventory, (TileBeehouse) getTileForestry(world, x, y, z), false);
|
||||
return new ContainerApiary(player.inventory, getTileForestry(world, x, y, z, TileBeehouse.class), false);
|
||||
|
||||
case HabitatLocatorGUI:
|
||||
equipped = player.getCurrentEquippedItem();
|
||||
@@ -159,7 +159,7 @@ public class GuiHandlerApiculture extends GuiHandlerBase {
|
||||
return new ContainerHabitatLocator(player, new HabitatLocatorInventory(player, equipped));
|
||||
|
||||
case HygroregulatorGUI:
|
||||
return new ContainerAlvearyHygroregulator(player.inventory, (TileAlvearyHygroregulator) getTileForestry(world, x, y, z));
|
||||
return new ContainerAlvearyHygroregulator(player.inventory, getTileForestry(world, x, y, z, TileAlvearyHygroregulator.class));
|
||||
|
||||
case ImprinterGUI:
|
||||
synchApiaristTracker(world, player);
|
||||
|
||||
@@ -19,11 +19,14 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import forestry.api.apiculture.IAlvearyComponent;
|
||||
import forestry.apiculture.network.PacketActiveUpdate;
|
||||
import forestry.core.interfaces.IActivatable;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.energy.EnergyManager;
|
||||
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
|
||||
public abstract class TileAlvearyClimatiser extends TileAlveary implements IEnergyHandler {
|
||||
public abstract class TileAlvearyClimatiser extends TileAlveary implements IEnergyHandler, IActivatable {
|
||||
|
||||
public static class ClimateControl {
|
||||
|
||||
@@ -44,6 +47,9 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
|
||||
private final int textureOff;
|
||||
private final int textureOn;
|
||||
|
||||
// CLIENT
|
||||
private boolean active;
|
||||
|
||||
public TileAlvearyClimatiser(ClimateControl control, int textureOff, int textureOn, int componentBlockMeta) {
|
||||
super(componentBlockMeta);
|
||||
this.climateControl = control;
|
||||
@@ -62,8 +68,6 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
|
||||
return;
|
||||
}
|
||||
|
||||
boolean wasInactive = (workingTime == 0);
|
||||
|
||||
if (workingTime < 20 && energyManager.consumeEnergyToDoWork()) {
|
||||
// consume 10 RF per tick of work
|
||||
workingTime += energyManager.getEnergyPerWork() / 10;
|
||||
@@ -77,9 +81,7 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
|
||||
}
|
||||
}
|
||||
|
||||
if ((wasInactive && workingTime > 0) || (!wasInactive && workingTime == 0)) {
|
||||
setNeedsNetworkUpdate();
|
||||
}
|
||||
setActive(workingTime > 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -90,7 +92,7 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
|
||||
/* TEXTURES */
|
||||
@Override
|
||||
public int getIcon(int side, int metadata) {
|
||||
if (workingTime > 0) {
|
||||
if (active) {
|
||||
return textureOn;
|
||||
} else {
|
||||
return textureOff;
|
||||
@@ -103,6 +105,7 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
|
||||
super.readFromNBT(nbttagcompound);
|
||||
energyManager.readFromNBT(nbttagcompound);
|
||||
workingTime = nbttagcompound.getInteger("Heating");
|
||||
setActive(workingTime > 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -116,16 +119,32 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
super.writeData(data);
|
||||
data.writeShort(workingTime);
|
||||
data.writeBoolean(active);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
super.readData(data);
|
||||
short workingTime = data.readShort();
|
||||
if (this.workingTime != workingTime) {
|
||||
this.workingTime = workingTime;
|
||||
setActive(data.readBoolean());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActive(boolean active) {
|
||||
if (this.active == active) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.active = active;
|
||||
|
||||
if (worldObj.isRemote) {
|
||||
worldObj.func_147479_m(xCoord, yCoord, zCoord);
|
||||
} else {
|
||||
Proxies.net.sendNetworkPacket(new PacketActiveUpdate(this));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -127,17 +127,14 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
|
||||
}
|
||||
}
|
||||
|
||||
if (!updateOnInterval(20)) {
|
||||
return;
|
||||
if (updateOnInterval(20)) {
|
||||
IInventoryAdapter canInventory = getInternalInventory();
|
||||
|
||||
// Check if we have suitable items waiting in the item slot
|
||||
if (canInventory.getStackInSlot(0) != null) {
|
||||
FluidHelper.drainContainers(tankManager, canInventory, 0);
|
||||
}
|
||||
}
|
||||
|
||||
IInventoryAdapter canInventory = getInternalInventory();
|
||||
|
||||
// Check if we have suitable items waiting in the item slot
|
||||
if (canInventory.getStackInSlot(0) != null) {
|
||||
FluidHelper.drainContainers(tankManager, canInventory, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,6 +10,9 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.gadgets;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -39,8 +42,10 @@ import forestry.api.core.IErrorState;
|
||||
import forestry.api.core.ITileStructure;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.apiculture.gui.ContainerAlveary;
|
||||
import forestry.apiculture.network.PacketActiveUpdate;
|
||||
import forestry.core.EnumErrorCode;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.interfaces.IActivatable;
|
||||
import forestry.core.interfaces.IClimatised;
|
||||
import forestry.core.interfaces.IErrorSource;
|
||||
import forestry.core.interfaces.IHintSource;
|
||||
@@ -52,7 +57,7 @@ import forestry.core.network.PacketId;
|
||||
import forestry.core.network.PacketInventoryStack;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IBeeHousing, IClimatised, IHintSource {
|
||||
public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IBeeHousing, IClimatised, IHintSource, IActivatable {
|
||||
|
||||
// / CONSTANTS
|
||||
public static final int SLOT_QUEEN = 0;
|
||||
@@ -69,6 +74,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
|
||||
private int displayHealthMax = 0;
|
||||
private int displayHealth = 0;
|
||||
|
||||
// CLIENT
|
||||
private boolean active;
|
||||
|
||||
public TileAlvearyPlain() {
|
||||
super(0);
|
||||
}
|
||||
@@ -117,6 +125,35 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
super.writeData(data);
|
||||
data.writeBoolean(active);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
super.readData(data);
|
||||
active = data.readBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActive(boolean active) {
|
||||
if (this.active == active) {
|
||||
return;
|
||||
}
|
||||
this.active = active;
|
||||
|
||||
if (!worldObj.isRemote) {
|
||||
Proxies.net.sendNetworkPacket(new PacketActiveUpdate(this));
|
||||
}
|
||||
}
|
||||
|
||||
/* UPDATING */
|
||||
@Override
|
||||
public void initialize() {
|
||||
@@ -135,8 +172,11 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
|
||||
return;
|
||||
}
|
||||
|
||||
if (beekeepingLogic.canWork())
|
||||
boolean canWork = beekeepingLogic.canWork();
|
||||
setActive(canWork);
|
||||
if (canWork) {
|
||||
beekeepingLogic.doWork();
|
||||
}
|
||||
|
||||
// Equalize humidity and temperature
|
||||
equalizeTemperature();
|
||||
@@ -180,7 +220,7 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
|
||||
return;
|
||||
}
|
||||
|
||||
if (hasErrorState()) {
|
||||
if (!active) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,16 +28,19 @@ import forestry.api.apiculture.IAlvearyComponent;
|
||||
import forestry.api.apiculture.IBee;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.apiculture.network.PacketActiveUpdate;
|
||||
import forestry.apiculture.worldgen.Hive;
|
||||
import forestry.apiculture.worldgen.HiveDecorator;
|
||||
import forestry.apiculture.worldgen.HiveDescriptionSwarmer;
|
||||
import forestry.core.interfaces.IActivatable;
|
||||
import forestry.core.inventory.TileInventoryAdapter;
|
||||
import forestry.core.inventory.wrappers.IInvSlot;
|
||||
import forestry.core.inventory.wrappers.InventoryIterator;
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.StackUtils;
|
||||
|
||||
public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory {
|
||||
public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory, IActivatable {
|
||||
|
||||
/* CONSTANTS */
|
||||
public static final int BLOCK_META = 2;
|
||||
@@ -61,12 +64,12 @@ public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory {
|
||||
super.updateServerSide();
|
||||
|
||||
if (pendingSpawns.size() > 0) {
|
||||
setIsActive(true);
|
||||
setActive(true);
|
||||
if (updateOnInterval(1000)) {
|
||||
trySpawnSwarm();
|
||||
}
|
||||
} else {
|
||||
setIsActive(false);
|
||||
setActive(false);
|
||||
}
|
||||
|
||||
if (!updateOnInterval(500)) {
|
||||
@@ -145,13 +148,6 @@ public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory {
|
||||
}
|
||||
}
|
||||
|
||||
private void setIsActive(boolean isActive) {
|
||||
if (this.active != isActive) {
|
||||
this.active = isActive;
|
||||
setNeedsNetworkUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
/* NETWORK */
|
||||
|
||||
@Override
|
||||
@@ -220,6 +216,24 @@ public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActive(boolean active) {
|
||||
if (this.active == active) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.active = active;
|
||||
|
||||
if (!worldObj.isRemote) {
|
||||
Proxies.net.sendNetworkPacket(new PacketActiveUpdate(this));
|
||||
}
|
||||
}
|
||||
|
||||
private static class SwarmerInventoryAdapter extends TileInventoryAdapter<TileAlvearySwarmer> {
|
||||
public SwarmerInventoryAdapter(TileAlvearySwarmer alvearySwarmer) {
|
||||
super(alvearySwarmer, 4, "SwarmInv");
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package forestry.apiculture.network;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import forestry.core.gadgets.TileForestry;
|
||||
import forestry.core.interfaces.IActivatable;
|
||||
import forestry.core.network.PacketCoordinates;
|
||||
import forestry.core.network.PacketId;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public class PacketActiveUpdate extends PacketCoordinates {
|
||||
|
||||
private IActivatable activatable;
|
||||
|
||||
public static void onPacketData(DataInputStream data) throws IOException {
|
||||
new PacketActiveUpdate(data);
|
||||
}
|
||||
|
||||
private PacketActiveUpdate(DataInputStream data) throws IOException {
|
||||
super(data);
|
||||
}
|
||||
|
||||
public <T extends TileForestry & IActivatable> PacketActiveUpdate(T tile) {
|
||||
super(PacketId.TILE_FORESTRY_ACTIVE, tile);
|
||||
this.activatable = tile;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeData(DataOutputStream data) throws IOException {
|
||||
super.writeData(data);
|
||||
data.writeBoolean(activatable.isActive());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readData(DataInputStream data) throws IOException {
|
||||
super.readData(data);
|
||||
|
||||
boolean active = data.readBoolean();
|
||||
|
||||
TileEntity tile = getTarget(Proxies.common.getRenderWorld());
|
||||
if (tile instanceof IActivatable) {
|
||||
((IActivatable) tile).setActive(active);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -38,10 +38,10 @@ public class GuiHandler extends GuiHandlerBase {
|
||||
switch (GuiId.values()[cleanId]) {
|
||||
|
||||
case AnalyzerGUI:
|
||||
return new GuiAnalyzer(player.inventory, (TileAnalyzer) getTileForestry(world, x, y, z));
|
||||
return new GuiAnalyzer(player.inventory, getTileForestry(world, x, y, z, TileAnalyzer.class));
|
||||
|
||||
case NaturalistBenchGUI:
|
||||
return new GuiEscritoire(player, (TileEscritoire) getTileForestry(world, x, y, z));
|
||||
return new GuiEscritoire(player, getTileForestry(world, x, y, z, TileEscritoire.class));
|
||||
|
||||
case SolderingIronGUI:
|
||||
ItemStack equipped = player.getCurrentEquippedItem();
|
||||
@@ -73,10 +73,10 @@ public class GuiHandler extends GuiHandlerBase {
|
||||
switch (GuiId.values()[cleanId]) {
|
||||
|
||||
case AnalyzerGUI:
|
||||
return new ContainerAnalyzer(player.inventory, (TileAnalyzer) getTileForestry(world, x, y, z));
|
||||
return new ContainerAnalyzer(player.inventory, getTileForestry(world, x, y, z, TileAnalyzer.class));
|
||||
|
||||
case NaturalistBenchGUI:
|
||||
return new ContainerEscritoire(player, (TileEscritoire) getTileForestry(world, x, y, z));
|
||||
return new ContainerEscritoire(player, getTileForestry(world, x, y, z, TileEscritoire.class));
|
||||
|
||||
case SolderingIronGUI:
|
||||
ItemStack equipped = player.getCurrentEquippedItem();
|
||||
|
||||
@@ -21,22 +21,28 @@ import forestry.core.gadgets.TileForestry;
|
||||
import forestry.core.gadgets.TileNaturalistChest;
|
||||
import forestry.core.gui.ContainerNaturalistInventory;
|
||||
import forestry.core.gui.GuiNaturalistInventory;
|
||||
import forestry.core.network.PacketTileGuiOpened;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public abstract class GuiHandlerBase implements IGuiHandler {
|
||||
|
||||
public TileForestry getTileForestry(World world, int x, int y, int z) {
|
||||
public <T extends TileForestry> T getTileForestry(World world, int x, int y, int z, Class<T> tileClass) {
|
||||
T tileForestry = null;
|
||||
try {
|
||||
return (TileForestry) world.getTileEntity(x, y, z);
|
||||
} catch (Exception ex) {
|
||||
Proxies.log.warning("Failed to cast a tile entity to a TileForestry at " + x + "/" + y + "/" + z);
|
||||
tileForestry = tileClass.cast(world.getTileEntity(x, y, z));
|
||||
} catch (ClassCastException ex) {
|
||||
Proxies.log.warning("Failed to cast a tile entity to a TileForestry at " + x + '/' + y + '/' + z);
|
||||
}
|
||||
|
||||
return null;
|
||||
if (tileForestry != null && !world.isRemote) {
|
||||
Proxies.net.sendNetworkPacket(new PacketTileGuiOpened(tileForestry));
|
||||
}
|
||||
|
||||
return tileForestry;
|
||||
}
|
||||
|
||||
public GuiNaturalistInventory getNaturalistChestGui(String rootUID, EntityPlayer player, World world, int x, int y, int z, int page) {
|
||||
TileNaturalistChest tile = (TileNaturalistChest) getTileForestry(world, x, y, z);
|
||||
TileNaturalistChest tile = getTileForestry(world, x, y, z, TileNaturalistChest.class);
|
||||
ISpeciesRoot speciesRoot = AlleleManager.alleleRegistry.getSpeciesRoot(rootUID);
|
||||
return new GuiNaturalistInventory(speciesRoot, player, new ContainerNaturalistInventory(player.inventory, tile, page, 25), tile, page, 5);
|
||||
}
|
||||
@@ -44,7 +50,7 @@ public abstract class GuiHandlerBase implements IGuiHandler {
|
||||
public ContainerNaturalistInventory getNaturalistChestContainer(String rootUID, EntityPlayer player, World world, int x, int y, int z, int page) {
|
||||
ISpeciesRoot speciesRoot = AlleleManager.alleleRegistry.getSpeciesRoot(rootUID);
|
||||
speciesRoot.getBreedingTracker(world, player.getGameProfile()).synchToPlayer(player);
|
||||
return new ContainerNaturalistInventory(player.inventory, (TileNaturalistChest) getTileForestry(world, x, y, z), page, 25);
|
||||
return new ContainerNaturalistInventory(player.inventory, getTileForestry(world, x, y, z, TileNaturalistChest.class), page, 25);
|
||||
}
|
||||
|
||||
public static int encodeGuiData(int guiId, int data) {
|
||||
|
||||
@@ -24,15 +24,18 @@ import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import forestry.apiculture.network.PacketActiveUpdate;
|
||||
import forestry.core.EnumErrorCode;
|
||||
import forestry.core.TemperatureState;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.interfaces.IActivatable;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.BlockUtil;
|
||||
import forestry.energy.EnergyManager;
|
||||
|
||||
import cofh.api.energy.IEnergyConnection;
|
||||
|
||||
public abstract class Engine extends TileBase implements IEnergyConnection {
|
||||
public abstract class Engine extends TileBase implements IEnergyConnection, IActivatable {
|
||||
|
||||
public boolean active = false; // Used for smp.
|
||||
/**
|
||||
@@ -157,13 +160,21 @@ public abstract class Engine extends TileBase implements IEnergyConnection {
|
||||
}
|
||||
}
|
||||
|
||||
private void setActive(boolean isActive) {
|
||||
if (this.active == isActive) {
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActive(boolean active) {
|
||||
if (this.active == active) {
|
||||
return;
|
||||
}
|
||||
this.active = active;
|
||||
|
||||
this.active = isActive;
|
||||
setNeedsNetworkUpdate();
|
||||
if (!worldObj.isRemote) {
|
||||
Proxies.net.sendNetworkPacket(new PacketActiveUpdate(this));
|
||||
}
|
||||
}
|
||||
|
||||
/* INTERACTION */
|
||||
|
||||
@@ -51,7 +51,6 @@ import forestry.core.interfaces.IRestrictedAccess;
|
||||
import forestry.core.inventory.FakeInventoryAdapter;
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.network.IStreamable;
|
||||
import forestry.core.network.PacketErrorUpdate;
|
||||
import forestry.core.network.PacketTileStream;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.AdjacentTileCache;
|
||||
@@ -118,8 +117,6 @@ public abstract class TileForestry extends TileEntity implements IStreamable, IR
|
||||
|
||||
}
|
||||
|
||||
private ImmutableSet<IErrorState> previousErrorStates;
|
||||
|
||||
// / UPDATING
|
||||
@Override
|
||||
public final void updateEntity() {
|
||||
@@ -136,16 +133,10 @@ public abstract class TileForestry extends TileEntity implements IStreamable, IR
|
||||
updateClientSide();
|
||||
}
|
||||
|
||||
ImmutableSet<IErrorState> errorStates = getErrorStates();
|
||||
|
||||
if (needsNetworkUpdate) {
|
||||
needsNetworkUpdate = false;
|
||||
sendNetworkUpdate();
|
||||
} else if (!errorStates.equals(previousErrorStates)) {
|
||||
sendErrorUpdate();
|
||||
}
|
||||
|
||||
previousErrorStates = errorStates;
|
||||
}
|
||||
|
||||
protected void updateClientSide() {
|
||||
@@ -211,29 +202,9 @@ public abstract class TileForestry extends TileEntity implements IStreamable, IR
|
||||
Proxies.net.sendNetworkPacket(packet);
|
||||
}
|
||||
|
||||
public final void sendErrorUpdate() {
|
||||
PacketErrorUpdate packet = new PacketErrorUpdate(this);
|
||||
Proxies.net.sendNetworkPacket(packet);
|
||||
}
|
||||
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
data.writeByte(orientation.ordinal());
|
||||
|
||||
writeErrorData(data);
|
||||
|
||||
// TODO: Should this really be sent to the client? Huge network cost.
|
||||
// As far as I know, only GUIs need it, and there are better ways to get the information to a GUI.
|
||||
// -CovertJaguar
|
||||
if (owner == null) {
|
||||
data.writeBoolean(false);
|
||||
} else {
|
||||
data.writeBoolean(true);
|
||||
data.writeByte(access.ordinal());
|
||||
data.writeLong(owner.getId().getMostSignificantBits());
|
||||
data.writeLong(owner.getId().getLeastSignificantBits());
|
||||
data.writeUTF(owner.getName());
|
||||
}
|
||||
|
||||
if (this instanceof ILiquidTankContainer) {
|
||||
TankManager tankManager = ((ILiquidTankContainer) this).getTankManager();
|
||||
if (tankManager != null) {
|
||||
@@ -245,14 +216,6 @@ public abstract class TileForestry extends TileEntity implements IStreamable, IR
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
orientation = ForgeDirection.getOrientation(data.readByte());
|
||||
|
||||
readErrorData(data);
|
||||
|
||||
if (data.readBoolean()) {
|
||||
byte accessOrdinal = data.readByte();
|
||||
access = EnumAccess.values()[accessOrdinal];
|
||||
owner = new GameProfile(new UUID(data.readLong(), data.readLong()), data.readUTF());
|
||||
}
|
||||
|
||||
if (this instanceof ILiquidTankContainer) {
|
||||
TankManager tankManager = ((ILiquidTankContainer) this).getTankManager();
|
||||
if (tankManager != null) {
|
||||
@@ -279,6 +242,29 @@ public abstract class TileForestry extends TileEntity implements IStreamable, IR
|
||||
}
|
||||
}
|
||||
|
||||
public final void writeGuiData(DataOutputStream data) throws IOException {
|
||||
writeErrorData(data);
|
||||
|
||||
if (owner == null) {
|
||||
data.writeByte(-1);
|
||||
} else {
|
||||
data.writeByte(access.ordinal());
|
||||
data.writeLong(owner.getId().getMostSignificantBits());
|
||||
data.writeLong(owner.getId().getLeastSignificantBits());
|
||||
data.writeUTF(owner.getName());
|
||||
}
|
||||
}
|
||||
|
||||
public final void readGuiData(DataInputStream data) throws IOException {
|
||||
readErrorData(data);
|
||||
|
||||
byte accessOrdinal = data.readByte();
|
||||
if (accessOrdinal >= 0) {
|
||||
access = EnumAccess.values()[accessOrdinal];
|
||||
owner = new GameProfile(new UUID(data.readLong(), data.readLong()), data.readUTF());
|
||||
}
|
||||
}
|
||||
|
||||
public void onRemoval() {
|
||||
}
|
||||
|
||||
|
||||
@@ -10,10 +10,15 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.gui;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import forestry.api.core.IErrorState;
|
||||
import forestry.core.gadgets.TileForestry;
|
||||
import forestry.core.network.PacketErrorUpdate;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public class ContainerTile<T extends TileForestry> extends ContainerForestry {
|
||||
|
||||
@@ -34,4 +39,24 @@ public class ContainerTile<T extends TileForestry> extends ContainerForestry {
|
||||
public final boolean canInteractWith(EntityPlayer entityplayer) {
|
||||
return tile.isUseableByPlayer(entityplayer);
|
||||
}
|
||||
|
||||
private ImmutableSet<IErrorState> previousErrorStates;
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
|
||||
ImmutableSet<IErrorState> errorStates = tile.getErrorStates();
|
||||
|
||||
if (!errorStates.equals(previousErrorStates)) {
|
||||
PacketErrorUpdate packet = new PacketErrorUpdate(tile);
|
||||
for (Object crafter : crafters) {
|
||||
if (crafter instanceof EntityPlayer) {
|
||||
Proxies.net.sendToPlayer(packet, (EntityPlayer) crafter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
previousErrorStates = errorStates;
|
||||
}
|
||||
}
|
||||
@@ -97,7 +97,7 @@ public abstract class GuiForestry<C extends Container, I extends IInventory> ext
|
||||
ledgerManager.add(new HintLedger(ledgerManager, (IHintSource) inventory));
|
||||
}
|
||||
|
||||
if (inventory instanceof IOwnable && ((IOwnable) inventory).isOwned()) {
|
||||
if (inventory instanceof IOwnable) {
|
||||
ledgerManager.add(new OwnerLedger(ledgerManager, (IOwnable) inventory));
|
||||
}
|
||||
|
||||
|
||||
@@ -31,13 +31,12 @@ import forestry.core.utils.StringUtil;
|
||||
public class OwnerLedger extends Ledger {
|
||||
|
||||
private final IOwnable tile;
|
||||
private final boolean playerIsOwner;
|
||||
|
||||
public OwnerLedger(LedgerManager manager, IOwnable tile) {
|
||||
super(manager, "owner");
|
||||
this.tile = tile;
|
||||
|
||||
playerIsOwner = tile.isOwner(manager.minecraft.thePlayer);
|
||||
boolean playerIsOwner = tile.isOwner(manager.minecraft.thePlayer);
|
||||
|
||||
if (playerIsOwner) {
|
||||
maxHeight = 60;
|
||||
@@ -54,6 +53,11 @@ public class OwnerLedger extends Ledger {
|
||||
return mouseX >= shiftX && mouseX <= currentShiftX + currentWidth && mouseY >= shiftY && mouseY <= shiftY + 12;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return tile.isOwned();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(int x, int y) {
|
||||
// Draw background
|
||||
@@ -78,6 +82,7 @@ public class OwnerLedger extends Ledger {
|
||||
|
||||
drawText(PlayerUtil.getOwnerName(tile), x + 22, y + 20);
|
||||
|
||||
boolean playerIsOwner = tile.isOwner(manager.minecraft.thePlayer);
|
||||
if (playerIsOwner && tile instanceof IRestrictedAccess) {
|
||||
drawSubheader(StringUtil.localize("gui.access") + ':', x + 22, y + 32);
|
||||
// Access rules
|
||||
|
||||
@@ -16,7 +16,7 @@ import net.minecraft.item.ItemStack;
|
||||
import forestry.core.interfaces.IFilterSlotDelegate;
|
||||
|
||||
/**
|
||||
* Slot which only takes specific items, specified by the ICustomSlotInventory.
|
||||
* Slot which only takes specific items, specified by the IFilterSlotDelegate.
|
||||
*/
|
||||
public class SlotFiltered extends SlotWatched {
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.core.interfaces;
|
||||
|
||||
/* Networked tile entities that have a client side "active" flag */
|
||||
public interface IActivatable {
|
||||
boolean isActive();
|
||||
|
||||
void setActive(boolean active);
|
||||
}
|
||||
@@ -35,6 +35,7 @@ import forestry.api.core.ForestryEvent;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IBreedingTracker;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import forestry.apiculture.network.PacketActiveUpdate;
|
||||
import forestry.core.circuits.ContainerSolderingIron;
|
||||
import forestry.core.circuits.ItemCircuitBoard;
|
||||
import forestry.core.gadgets.TileForestry;
|
||||
@@ -87,6 +88,14 @@ public class PacketHandler {
|
||||
PacketErrorUpdate packet = new PacketErrorUpdate(data);
|
||||
return true;
|
||||
}
|
||||
case TILE_FORESTRY_GUI_OPENED: {
|
||||
PacketTileGuiOpened.onPacketData(data);
|
||||
return true;
|
||||
}
|
||||
case TILE_FORESTRY_ACTIVE: {
|
||||
PacketActiveUpdate.onPacketData(data);
|
||||
return true;
|
||||
}
|
||||
case SOCKET_UPDATE: {
|
||||
PacketSocketUpdate packetS = new PacketSocketUpdate(data);
|
||||
onSocketUpdate(packetS);
|
||||
|
||||
@@ -15,6 +15,8 @@ public enum PacketId {
|
||||
|
||||
TILE_FORESTRY_UPDATE,
|
||||
TILE_FORESTRY_ERROR_UPDATE,
|
||||
TILE_FORESTRY_GUI_OPENED,
|
||||
TILE_FORESTRY_ACTIVE,
|
||||
IINVENTORY_STACK,
|
||||
FX_SIGNAL,
|
||||
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.core.network;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import forestry.core.gadgets.TileForestry;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public class PacketTileGuiOpened extends PacketCoordinates {
|
||||
|
||||
private TileForestry tileForestry;
|
||||
|
||||
public static void onPacketData(DataInputStream data) throws IOException {
|
||||
new PacketTileGuiOpened(data);
|
||||
}
|
||||
|
||||
private PacketTileGuiOpened(DataInputStream data) throws IOException {
|
||||
super(data);
|
||||
}
|
||||
|
||||
public PacketTileGuiOpened(TileForestry tileForestry) {
|
||||
super(PacketId.TILE_FORESTRY_GUI_OPENED, tileForestry);
|
||||
this.tileForestry = tileForestry;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeData(DataOutputStream data) throws IOException {
|
||||
super.writeData(data);
|
||||
tileForestry.writeGuiData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readData(DataInputStream data) throws IOException {
|
||||
super.readData(data);
|
||||
|
||||
TileEntity tile = getTarget(Proxies.common.getRenderWorld());
|
||||
if (tile instanceof TileForestry) {
|
||||
((TileForestry) tile).readGuiData(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -43,16 +43,16 @@ public class GuiHandlerEnergy extends GuiHandlerBase {
|
||||
switch (GuiId.values()[id]) {
|
||||
|
||||
case EngineBronzeGUI:
|
||||
return new GuiEngineBronze(player.inventory, (EngineBronze) getTileForestry(world, x, y, z));
|
||||
return new GuiEngineBronze(player.inventory, getTileForestry(world, x, y, z, EngineBronze.class));
|
||||
|
||||
case EngineCopperGUI:
|
||||
return new GuiEngineCopper(player.inventory, (EngineCopper) getTileForestry(world, x, y, z));
|
||||
return new GuiEngineCopper(player.inventory, getTileForestry(world, x, y, z, EngineCopper.class));
|
||||
|
||||
case EngineTinGUI:
|
||||
return new GuiEngineTin(player.inventory, (EngineTin) getTileForestry(world, x, y, z));
|
||||
return new GuiEngineTin(player.inventory, getTileForestry(world, x, y, z, EngineTin.class));
|
||||
|
||||
case GeneratorGUI:
|
||||
return new GuiGenerator(player.inventory, (MachineGenerator) getTileForestry(world, x, y, z));
|
||||
return new GuiGenerator(player.inventory, getTileForestry(world, x, y, z, MachineGenerator.class));
|
||||
|
||||
default:
|
||||
return null;
|
||||
@@ -69,18 +69,18 @@ public class GuiHandlerEnergy extends GuiHandlerBase {
|
||||
switch (GuiId.values()[id]) {
|
||||
|
||||
case EngineBronzeGUI:
|
||||
return new ContainerEngineBronze(player.inventory, (EngineBronze) getTileForestry(world, x, y, z));
|
||||
return new ContainerEngineBronze(player.inventory, getTileForestry(world, x, y, z, EngineBronze.class));
|
||||
|
||||
case EngineCopperGUI:
|
||||
return new ContainerEngineCopper(player.inventory, (EngineCopper) getTileForestry(world, x, y, z));
|
||||
return new ContainerEngineCopper(player.inventory, getTileForestry(world, x, y, z, EngineCopper.class));
|
||||
|
||||
case EngineTinGUI:
|
||||
EngineTin tile = (EngineTin) getTileForestry(world, x, y, z);
|
||||
EngineTin tile = getTileForestry(world, x, y, z, EngineTin.class);
|
||||
Proxies.net.sendToPlayer(new PacketSocketUpdate(PacketId.SOCKET_UPDATE, tile), player);
|
||||
return new ContainerEngineTin(player.inventory, tile);
|
||||
|
||||
case GeneratorGUI:
|
||||
return new ContainerGenerator(player.inventory, (MachineGenerator) getTileForestry(world, x, y, z));
|
||||
return new ContainerGenerator(player.inventory, getTileForestry(world, x, y, z, MachineGenerator.class));
|
||||
|
||||
default:
|
||||
return null;
|
||||
|
||||
@@ -58,34 +58,34 @@ public class GuiHandlerFactory extends GuiHandlerBase {
|
||||
switch (GuiId.values()[id]) {
|
||||
|
||||
case BottlerGUI:
|
||||
return new GuiBottler(player.inventory, (MachineBottler) getTileForestry(world, x, y, z));
|
||||
return new GuiBottler(player.inventory, getTileForestry(world, x, y, z, MachineBottler.class));
|
||||
|
||||
case CarpenterGUI:
|
||||
return new GuiCarpenter(player.inventory, (MachineCarpenter) getTileForestry(world, x, y, z));
|
||||
return new GuiCarpenter(player.inventory, getTileForestry(world, x, y, z, MachineCarpenter.class));
|
||||
|
||||
case CentrifugeGUI:
|
||||
return new GuiCentrifuge(player.inventory, (MachineCentrifuge) getTileForestry(world, x, y, z));
|
||||
return new GuiCentrifuge(player.inventory, getTileForestry(world, x, y, z, MachineCentrifuge.class));
|
||||
|
||||
case FabricatorGUI:
|
||||
return new GuiFabricator(player.inventory, (MachineFabricator) getTileForestry(world, x, y, z));
|
||||
return new GuiFabricator(player.inventory, getTileForestry(world, x, y, z, MachineFabricator.class));
|
||||
|
||||
case FermenterGUI:
|
||||
return new GuiFermenter(player.inventory, (MachineFermenter) getTileForestry(world, x, y, z));
|
||||
return new GuiFermenter(player.inventory, getTileForestry(world, x, y, z, MachineFermenter.class));
|
||||
|
||||
case MoistenerGUI:
|
||||
return new GuiMoistener(player.inventory, (MachineMoistener) getTileForestry(world, x, y, z));
|
||||
return new GuiMoistener(player.inventory, getTileForestry(world, x, y, z, MachineMoistener.class));
|
||||
|
||||
case RaintankGUI:
|
||||
return new GuiRaintank(player.inventory, (MachineRaintank) getTileForestry(world, x, y, z));
|
||||
return new GuiRaintank(player.inventory, getTileForestry(world, x, y, z, MachineRaintank.class));
|
||||
|
||||
case SqueezerGUI:
|
||||
return new GuiSqueezer(player.inventory, (MachineSqueezer) getTileForestry(world, x, y, z));
|
||||
return new GuiSqueezer(player.inventory, getTileForestry(world, x, y, z, MachineSqueezer.class));
|
||||
|
||||
case StillGUI:
|
||||
return new GuiStill(player.inventory, (MachineStill) getTileForestry(world, x, y, z));
|
||||
return new GuiStill(player.inventory, getTileForestry(world, x, y, z, MachineStill.class));
|
||||
|
||||
case WorktableGUI:
|
||||
return new GuiWorktable(player, (TileWorktable) getTileForestry(world, x, y, z));
|
||||
return new GuiWorktable(player, getTileForestry(world, x, y, z, TileWorktable.class));
|
||||
|
||||
default:
|
||||
return null;
|
||||
@@ -103,34 +103,34 @@ public class GuiHandlerFactory extends GuiHandlerBase {
|
||||
switch (GuiId.values()[id]) {
|
||||
|
||||
case BottlerGUI:
|
||||
return new ContainerBottler(player.inventory, (MachineBottler) getTileForestry(world, x, y, z));
|
||||
return new ContainerBottler(player.inventory, getTileForestry(world, x, y, z, MachineBottler.class));
|
||||
|
||||
case CarpenterGUI:
|
||||
return new ContainerCarpenter(player.inventory, (MachineCarpenter) getTileForestry(world, x, y, z));
|
||||
return new ContainerCarpenter(player.inventory, getTileForestry(world, x, y, z, MachineCarpenter.class));
|
||||
|
||||
case CentrifugeGUI:
|
||||
return new ContainerCentrifuge(player.inventory, (MachineCentrifuge) getTileForestry(world, x, y, z));
|
||||
return new ContainerCentrifuge(player.inventory, getTileForestry(world, x, y, z, MachineCentrifuge.class));
|
||||
|
||||
case FabricatorGUI:
|
||||
return new ContainerFabricator(player.inventory, (MachineFabricator) getTileForestry(world, x, y, z));
|
||||
return new ContainerFabricator(player.inventory, getTileForestry(world, x, y, z, MachineFabricator.class));
|
||||
|
||||
case FermenterGUI:
|
||||
return new ContainerFermenter(player.inventory, (MachineFermenter) getTileForestry(world, x, y, z));
|
||||
return new ContainerFermenter(player.inventory, getTileForestry(world, x, y, z, MachineFermenter.class));
|
||||
|
||||
case MoistenerGUI:
|
||||
return new ContainerMoistener(player.inventory, (MachineMoistener) getTileForestry(world, x, y, z));
|
||||
return new ContainerMoistener(player.inventory, getTileForestry(world, x, y, z, MachineMoistener.class));
|
||||
|
||||
case RaintankGUI:
|
||||
return new ContainerRaintank(player.inventory, (MachineRaintank) getTileForestry(world, x, y, z));
|
||||
return new ContainerRaintank(player.inventory, getTileForestry(world, x, y, z, MachineRaintank.class));
|
||||
|
||||
case SqueezerGUI:
|
||||
return new ContainerSqueezer(player.inventory, (MachineSqueezer) getTileForestry(world, x, y, z));
|
||||
return new ContainerSqueezer(player.inventory, getTileForestry(world, x, y, z, MachineSqueezer.class));
|
||||
|
||||
case StillGUI:
|
||||
return new ContainerStill(player.inventory, (MachineStill) getTileForestry(world, x, y, z));
|
||||
return new ContainerStill(player.inventory, getTileForestry(world, x, y, z, MachineStill.class));
|
||||
|
||||
case WorktableGUI:
|
||||
return new ContainerWorktable(player, (TileWorktable) getTileForestry(world, x, y, z));
|
||||
return new ContainerWorktable(player, getTileForestry(world, x, y, z, TileWorktable.class));
|
||||
|
||||
default:
|
||||
return null;
|
||||
|
||||
@@ -33,7 +33,7 @@ public class GuiHandlerFarming extends GuiHandlerBase {
|
||||
|
||||
switch (GuiId.values()[id]) {
|
||||
case MultiFarmGUI:
|
||||
TileFarmPlain tile = (TileFarmPlain) getTileForestry(world, x, y, z);
|
||||
TileFarmPlain tile = getTileForestry(world, x, y, z, TileFarmPlain.class);
|
||||
Proxies.net.sendToPlayer(new PacketSocketUpdate(PacketId.SOCKET_UPDATE, tile), player);
|
||||
return new ContainerFarm(player.inventory, tile);
|
||||
default:
|
||||
@@ -50,7 +50,7 @@ public class GuiHandlerFarming extends GuiHandlerBase {
|
||||
|
||||
switch (GuiId.values()[id]) {
|
||||
case MultiFarmGUI:
|
||||
return new GuiFarm(player, (TileFarmPlain) getTileForestry(world, x, y, z));
|
||||
return new GuiFarm(player, getTileForestry(world, x, y, z, TileFarmPlain.class));
|
||||
default:
|
||||
return null;
|
||||
|
||||
|
||||
@@ -70,13 +70,13 @@ public class GuiHandlerMail extends GuiHandlerBase {
|
||||
}
|
||||
|
||||
case MailboxGUI:
|
||||
return new GuiMailbox(player.inventory, (MachineMailbox) getTileForestry(world, x, y, z));
|
||||
return new GuiMailbox(player.inventory, getTileForestry(world, x, y, z, MachineMailbox.class));
|
||||
case PhilatelistGUI:
|
||||
return new GuiPhilatelist(player.inventory, (MachinePhilatelist) getTileForestry(world, x, y, z));
|
||||
return new GuiPhilatelist(player.inventory, getTileForestry(world, x, y, z, MachinePhilatelist.class));
|
||||
case TraderGUI:
|
||||
return new GuiTrader(player.inventory, (MachineTrader) getTileForestry(world, x, y, z));
|
||||
return new GuiTrader(player.inventory, getTileForestry(world, x, y, z, MachineTrader.class));
|
||||
case TraderNameGUI:
|
||||
return new GuiTradeName(player.inventory, (MachineTrader) getTileForestry(world, x, y, z));
|
||||
return new GuiTradeName(player.inventory, getTileForestry(world, x, y, z, MachineTrader.class));
|
||||
default:
|
||||
return null;
|
||||
|
||||
@@ -116,13 +116,13 @@ public class GuiHandlerMail extends GuiHandlerBase {
|
||||
}
|
||||
|
||||
case MailboxGUI:
|
||||
return new ContainerMailbox(player.inventory, (MachineMailbox) getTileForestry(world, x, y, z));
|
||||
return new ContainerMailbox(player.inventory, getTileForestry(world, x, y, z, MachineMailbox.class));
|
||||
case PhilatelistGUI:
|
||||
return new ContainerPhilatelist(player.inventory, (MachinePhilatelist) getTileForestry(world, x, y, z));
|
||||
return new ContainerPhilatelist(player.inventory, getTileForestry(world, x, y, z, MachinePhilatelist.class));
|
||||
case TraderGUI:
|
||||
return new ContainerTrader(player.inventory, (MachineTrader) getTileForestry(world, x, y, z));
|
||||
return new ContainerTrader(player.inventory, getTileForestry(world, x, y, z, MachineTrader.class));
|
||||
case TraderNameGUI:
|
||||
return new ContainerTradeName(player.inventory, (MachineTrader) getTileForestry(world, x, y, z));
|
||||
return new ContainerTradeName(player.inventory, getTileForestry(world, x, y, z, MachineTrader.class));
|
||||
default:
|
||||
return null;
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@ public class MachineTrader extends TileBase {
|
||||
setErrorCondition(!hasSupplies, EnumErrorCode.NOSUPPLIES);
|
||||
}
|
||||
|
||||
if (inventory instanceof TradeStation) {
|
||||
if (inventory instanceof TradeStation && updateOnInterval(200)) {
|
||||
boolean canReceivePayment = ((TradeStation) inventory).canReceivePayment();
|
||||
setErrorCondition(!canReceivePayment, EnumErrorCode.NOSPACE);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user