fixed player in net handler and deprecated proxies
This commit is contained in:
parent
f227dc2afc
commit
8f7f8d31ad
60 changed files with 237 additions and 181 deletions
|
@ -30,11 +30,6 @@ public class BuildCraftMod {
|
|||
channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(entityplayer);
|
||||
channels.get(Side.SERVER).writeOutbound(packet);
|
||||
}
|
||||
|
||||
public void replyToPlayer(EntityPlayer entityplayer, BuildCraftPacket packet) {
|
||||
channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(OutboundTarget.REPLY);
|
||||
channels.get(Side.SERVER).writeOutbound(packet);
|
||||
}
|
||||
|
||||
public void sendToServer(BuildCraftPacket packet) {
|
||||
channels.get(Side.CLIENT).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(OutboundTarget.TOSERVER);
|
||||
|
|
|
@ -86,7 +86,7 @@ public class BlockArchitect extends BlockContainer {
|
|||
return true;
|
||||
} else {
|
||||
|
||||
if (!CoreProxy.proxy.isRenderWorld(world)) {
|
||||
if (!world.isRemote) {
|
||||
entityplayer.openGui(BuildCraftBuilders.instance, GuiIds.ARCHITECT_TABLE, world, i, j, k);
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -47,7 +47,7 @@ public class BlockBlueprintLibrary extends BlockContainer {
|
|||
TileBlueprintLibrary tile = (TileBlueprintLibrary) world.getTileEntity(i, j, k);
|
||||
|
||||
if (!tile.locked || entityplayer.getDisplayName().equals(tile.owner))
|
||||
if (!CoreProxy.proxy.isRenderWorld(world)) {
|
||||
if (!world.isRemote) {
|
||||
entityplayer.openGui(BuildCraftBuilders.instance, GuiIds.BLUEPRINT_LIBRARY, world, i, j, k);
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ public class BlockBlueprintLibrary extends BlockContainer {
|
|||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entityliving, ItemStack stack) {
|
||||
if (CoreProxy.proxy.isSimulating(world) && entityliving instanceof EntityPlayer) {
|
||||
if (!world.isRemote && entityliving instanceof EntityPlayer) {
|
||||
TileBlueprintLibrary tile = (TileBlueprintLibrary) world.getTileEntity(i, j, k);
|
||||
tile.owner = ((EntityPlayer) entityliving).getDisplayName();
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ public class BlockBuilder extends BlockContainer {
|
|||
return true;
|
||||
} else {
|
||||
|
||||
if (!CoreProxy.proxy.isRenderWorld(world)) {
|
||||
if (!world.isRemote) {
|
||||
entityplayer.openGui(BuildCraftBuilders.instance, GuiIds.BUILDER, world, i, j, k);
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -52,7 +52,7 @@ public class BlockFiller extends BlockContainer {
|
|||
if (entityplayer.isSneaking())
|
||||
return false;
|
||||
|
||||
if (!CoreProxy.proxy.isRenderWorld(world)) {
|
||||
if (!world.isRemote) {
|
||||
entityplayer.openGui(BuildCraftBuilders.instance, GuiIds.FILLER, world, i, j, k);
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -44,7 +44,7 @@ public abstract class ItemBptBase extends ItemBuildCraft {
|
|||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) {
|
||||
if (CoreProxy.proxy.isSimulating(world)) {
|
||||
if (!world.isRemote) {
|
||||
BptBase bpt = BuildCraftBuilders.getBptRootIndex().getBluePrint(itemStack.getItemDamage());
|
||||
if (bpt != null)
|
||||
return BuildCraftBuilders.getBptItemStack(itemStack.getItem(), itemStack.getItemDamage(), bpt.getName());
|
||||
|
|
|
@ -45,7 +45,7 @@ public class TileArchitect extends TileBuildCraft implements IInventory {
|
|||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
|
||||
if (CoreProxy.proxy.isSimulating(worldObj) && isComputing) {
|
||||
if (!worldObj.isRemote && isComputing) {
|
||||
if (computingTime < 200) {
|
||||
computingTime++;
|
||||
} else {
|
||||
|
@ -68,7 +68,7 @@ public class TileArchitect extends TileBuildCraft implements IInventory {
|
|||
}
|
||||
}
|
||||
|
||||
if (!CoreProxy.proxy.isRenderWorld(worldObj) && box.isInitialized()) {
|
||||
if (!worldObj.isRemote && box.isInitialized()) {
|
||||
box.createLasers(worldObj, LaserKind.Stripes);
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ public class TileBlueprintLibrary extends TileBuildCraft implements IInventory {
|
|||
@Override
|
||||
public void initialize() {
|
||||
super.initialize();
|
||||
if (CoreProxy.proxy.isSimulating(worldObj)) {
|
||||
if (!worldObj.isRemote) {
|
||||
setCurrentPage(getNextPage(null));
|
||||
}
|
||||
}
|
||||
|
@ -250,8 +250,10 @@ public class TileBlueprintLibrary extends TileBuildCraft implements IInventory {
|
|||
@Override
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
if (CoreProxy.proxy.isRenderWorld(worldObj))
|
||||
|
||||
if (worldObj.isRemote) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (progressIn > 0 && progressIn < 100) {
|
||||
progressIn++;
|
||||
|
|
|
@ -177,8 +177,9 @@ public class TileBuilder extends TileBuildCraft implements IBuilderInventory, IP
|
|||
public void initialize() {
|
||||
super.initialize();
|
||||
|
||||
if (CoreProxy.proxy.isRenderWorld(worldObj))
|
||||
if (worldObj.isRemote) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int x = xCoord - 1; x <= xCoord + 1; ++x) {
|
||||
for (int y = yCoord - 1; y <= yCoord + 1; ++y) {
|
||||
|
@ -264,8 +265,9 @@ public class TileBuilder extends TileBuildCraft implements IBuilderInventory, IP
|
|||
|
||||
@Override
|
||||
public void doWork(PowerHandler workProvider) {
|
||||
if (CoreProxy.proxy.isRenderWorld(worldObj))
|
||||
if (worldObj.isRemote) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (done)
|
||||
return;
|
||||
|
@ -566,7 +568,7 @@ public class TileBuilder extends TileBuildCraft implements IBuilderInventory, IP
|
|||
box.deleteLasers();
|
||||
box.reset();
|
||||
|
||||
if (CoreProxy.proxy.isSimulating(worldObj)) {
|
||||
if (!worldObj.isRemote) {
|
||||
sendNetworkUpdate(BuildCraftBuilders.instance);
|
||||
}
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ public class TileFiller extends TileBuildCraft implements IInventory, IPowerRece
|
|||
public void initialize() {
|
||||
super.initialize();
|
||||
|
||||
if (!CoreProxy.proxy.isRenderWorld(worldObj)) {
|
||||
if (!worldObj.isRemote) {
|
||||
IAreaProvider a = Utils.getNearbyAreaProvider(worldObj, xCoord, yCoord, zCoord);
|
||||
|
||||
if (a != null) {
|
||||
|
@ -84,7 +84,7 @@ public class TileFiller extends TileBuildCraft implements IInventory, IPowerRece
|
|||
((TileMarker) a).removeFromWorld();
|
||||
}
|
||||
|
||||
if (!CoreProxy.proxy.isRenderWorld(worldObj) && box.isInitialized()) {
|
||||
if (!worldObj.isRemote && box.isInitialized()) {
|
||||
box.createLasers(worldObj, LaserKind.Stripes);
|
||||
}
|
||||
sendNetworkUpdate(BuildCraftBuilders.instance);
|
||||
|
@ -104,7 +104,7 @@ public class TileFiller extends TileBuildCraft implements IInventory, IPowerRece
|
|||
|
||||
@Override
|
||||
public void doWork(PowerHandler workProvider) {
|
||||
if (CoreProxy.proxy.isRenderWorld(worldObj))
|
||||
if (worldObj.isRemote)
|
||||
return;
|
||||
if (done)
|
||||
return;
|
||||
|
|
|
@ -91,7 +91,7 @@ public class TileMarker extends TileBuildCraft implements IAreaProvider {
|
|||
boolean showSignals = false;
|
||||
|
||||
public void updateSignals() {
|
||||
if (CoreProxy.proxy.isSimulating(worldObj)) {
|
||||
if (!worldObj.isRemote) {
|
||||
showSignals = worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord);
|
||||
sendNetworkUpdate(BuildCraftBuilders.instance);
|
||||
}
|
||||
|
@ -153,8 +153,9 @@ public class TileMarker extends TileBuildCraft implements IAreaProvider {
|
|||
}
|
||||
|
||||
public void tryConnection() {
|
||||
if (CoreProxy.proxy.isRenderWorld(worldObj))
|
||||
if (worldObj.isRemote) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int j = 0; j < 3; ++j) {
|
||||
if (!origin.isSet() || !origin.vect[j].isSet()) {
|
||||
|
@ -390,7 +391,7 @@ public class TileMarker extends TileBuildCraft implements IAreaProvider {
|
|||
|
||||
signals = null;
|
||||
|
||||
if (CoreProxy.proxy.isSimulating(worldObj) && markerOrigin != null && markerOrigin != this) {
|
||||
if (!worldObj.isRemote && markerOrigin != null && markerOrigin != this) {
|
||||
markerOrigin.sendNetworkUpdate(BuildCraftBuilders.instance);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,8 +55,9 @@ public class TilePathMarker extends TileMarker {
|
|||
|
||||
public void createLaserAndConnect(TilePathMarker pathMarker) {
|
||||
|
||||
if (CoreProxy.proxy.isRenderWorld(worldObj))
|
||||
if (worldObj.isRemote) {
|
||||
return;
|
||||
}
|
||||
|
||||
EntityPowerLaser laser = new EntityPowerLaser(worldObj, new Position(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5), new Position(pathMarker.xCoord + 0.5,
|
||||
pathMarker.yCoord + 0.5, pathMarker.zCoord + 0.5));
|
||||
|
@ -97,8 +98,9 @@ public class TilePathMarker extends TileMarker {
|
|||
@Override
|
||||
public void tryConnection() {
|
||||
|
||||
if (CoreProxy.proxy.isRenderWorld(worldObj) || isFullyConnected())
|
||||
if (worldObj.isRemote || isFullyConnected()) {
|
||||
return;
|
||||
}
|
||||
|
||||
tryingToConnect = !tryingToConnect; // Allow the user to stop the path marker from searching for new path markers to connect
|
||||
sendNetworkUpdate(BuildCraftBuilders.instance);
|
||||
|
@ -108,8 +110,9 @@ public class TilePathMarker extends TileMarker {
|
|||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
|
||||
if (CoreProxy.proxy.isRenderWorld(worldObj))
|
||||
if (worldObj.isRemote) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (tryingToConnect) {
|
||||
TilePathMarker nearestPathMarker = findNearestAvailablePathMarker();
|
||||
|
@ -171,7 +174,7 @@ public class TilePathMarker extends TileMarker {
|
|||
public void initialize() {
|
||||
super.initialize();
|
||||
|
||||
if (CoreProxy.proxy.isSimulating(worldObj) && !isFullyConnected()) {
|
||||
if (!worldObj.isRemote && !isFullyConnected()) {
|
||||
availableMarkers.add(this);
|
||||
}
|
||||
|
||||
|
@ -207,7 +210,7 @@ public class TilePathMarker extends TileMarker {
|
|||
links[1] = null;
|
||||
}
|
||||
|
||||
if (!isFullyConnected() && !availableMarkers.contains(this) && CoreProxy.proxy.isSimulating(worldObj)) {
|
||||
if (!isFullyConnected() && !availableMarkers.contains(this) && !worldObj.isRemote) {
|
||||
availableMarkers.add(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import buildcraft.core.network.PacketIds;
|
|||
import buildcraft.core.network.PacketPayloadArrays;
|
||||
import buildcraft.core.network.PacketUpdate;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
import buildcraft.core.utils.Utils;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
|
@ -27,10 +28,8 @@ public class PacketHandlerBuilders extends BuildCraftChannelHandler {
|
|||
super.decodeInto(ctx, data, packet);
|
||||
|
||||
try {
|
||||
INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get();
|
||||
|
||||
EntityPlayer player =
|
||||
CoreProxy.proxy.getPlayerFromNetHandler(netHandler);
|
||||
INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get();
|
||||
EntityPlayer player = Utils.getPlayerFromNetHandler(netHandler);
|
||||
|
||||
int packetID = packet.getID();
|
||||
|
||||
|
|
|
@ -68,12 +68,12 @@ public abstract class EntityLaser extends Entity {
|
|||
if (head == null || tail == null)
|
||||
return;
|
||||
|
||||
if (CoreProxy.proxy.isSimulating(worldObj) && needsUpdate) {
|
||||
if (!worldObj.isRemote && needsUpdate) {
|
||||
updateDataServer();
|
||||
needsUpdate = false;
|
||||
}
|
||||
|
||||
if (CoreProxy.proxy.isRenderWorld(worldObj)) {
|
||||
if (worldObj.isRemote) {
|
||||
updateDataClient();
|
||||
}
|
||||
|
||||
|
|
|
@ -210,7 +210,7 @@ public class EntityRobot extends Entity implements IEntityAdditionalSpawnData {
|
|||
//System.out.printf("RobotChanging %d %d %d %s\n",target.x, target.y, target.z, target.mode);
|
||||
if (wait <= 0 && BlockUtil.canChangeBlock(worldObj, target.x, target.y, target.z)) {
|
||||
|
||||
if (!CoreProxy.proxy.isRenderWorld(worldObj)) {
|
||||
if (!worldObj.isRemote) {
|
||||
|
||||
if (target.mode == Mode.ClearIfInvalid) {
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ public abstract class TileBuildCraft extends TileEntity implements ISynchronized
|
|||
}
|
||||
|
||||
public void sendNetworkUpdate(BuildCraftMod mod) {
|
||||
if (CoreProxy.proxy.isSimulating(worldObj)) {
|
||||
if (!worldObj.isRemote) {
|
||||
mod.sendToPlayers(getUpdatePacket(), worldObj, xCoord, yCoord, zCoord, DefaultProps.NETWORK_UPDATE_RANGE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,8 +49,9 @@ public abstract class GuiAdvancedInterface extends GuiBuildCraft {
|
|||
}
|
||||
|
||||
public void drawSprite(int cornerX, int cornerY) {
|
||||
if (!isDefined())
|
||||
if (!isDefined()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (getItemStack() != null) {
|
||||
drawStack(getItemStack());
|
||||
|
|
|
@ -8,8 +8,11 @@ import java.io.DataInputStream;
|
|||
import java.io.IOException;
|
||||
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
import buildcraft.core.utils.Utils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.network.INetHandler;
|
||||
import net.minecraft.network.NetHandlerPlayServer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
|
@ -39,11 +42,8 @@ public class PacketHandler extends BuildCraftChannelHandler {
|
|||
super.decodeInto(ctx, data, packet);
|
||||
|
||||
try {
|
||||
|
||||
INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get();
|
||||
|
||||
EntityPlayer player =
|
||||
CoreProxy.proxy.getPlayerFromNetHandler(netHandler);
|
||||
EntityPlayer player = Utils.getPlayerFromNetHandler(netHandler);
|
||||
|
||||
int packetID = packet.getID();
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ public class PacketUpdate extends BuildCraftPacket {
|
|||
|
||||
@Override
|
||||
public void writeData(ByteBuf data) {
|
||||
data.writeByte(packetId);
|
||||
data.writeInt(posX);
|
||||
data.writeInt(posY);
|
||||
data.writeInt(posZ);
|
||||
|
@ -52,6 +53,7 @@ public class PacketUpdate extends BuildCraftPacket {
|
|||
|
||||
@Override
|
||||
public void readData(ByteBuf data) {
|
||||
packetId = data.readByte();
|
||||
posX = data.readInt();
|
||||
posY = data.readInt();
|
||||
posZ = data.readInt();
|
||||
|
|
|
@ -32,8 +32,6 @@ import net.minecraft.item.Item;
|
|||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.network.INetHandler;
|
||||
import net.minecraft.network.NetHandlerPlayServer;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
|
@ -42,6 +40,12 @@ import net.minecraft.world.World;
|
|||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
||||
|
||||
|
||||
/**
|
||||
* This class comes from the old times where there were two Minecrafts
|
||||
* codebases, one client and one server. We should slowly aim at removing it.
|
||||
*/
|
||||
@Deprecated
|
||||
public class CoreProxy {
|
||||
|
||||
@SidedProxy(clientSide = "buildcraft.core.proxy.CoreProxyClient", serverSide = "buildcraft.core.proxy.CoreProxy")
|
||||
|
@ -60,15 +64,6 @@ public class CoreProxy {
|
|||
return null;
|
||||
}
|
||||
|
||||
/* SIMULATION */
|
||||
public boolean isSimulating(World world) {
|
||||
return !world.isRemote;
|
||||
}
|
||||
|
||||
public boolean isRenderWorld(World world) {
|
||||
return world.isRemote;
|
||||
}
|
||||
|
||||
public String getCurrentLanguage() {
|
||||
return null;
|
||||
}
|
||||
|
@ -219,15 +214,4 @@ public class CoreProxy {
|
|||
public EntityBlock newEntityBlock(World world, double i, double j, double k, double iSize, double jSize, double kSize, LaserKind laserKind) {
|
||||
return new EntityBlock(world, i, j, k, iSize, jSize, kSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function returns either the player from the handler if it's on the
|
||||
* server, or directly from the minecraft instance if it's the client.
|
||||
*
|
||||
* TODO: This is a bit kludgy, probably better to separate the client and
|
||||
* server channels instead.
|
||||
*/
|
||||
public EntityPlayer getPlayerFromNetHandler (INetHandler hander) {
|
||||
return ((NetHandlerPlayServer) hander).playerEntity;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ public class CoreProxyClient extends CoreProxy {
|
|||
public void removeEntity(Entity entity) {
|
||||
super.removeEntity(entity);
|
||||
|
||||
if (isRenderWorld(entity.worldObj)) {
|
||||
if (entity.worldObj.isRemote) {
|
||||
((WorldClient) entity.worldObj).removeEntityFromWorld(entity.getEntityId());
|
||||
}
|
||||
}
|
||||
|
@ -184,9 +184,4 @@ public class CoreProxyClient extends CoreProxy {
|
|||
}
|
||||
return eb;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityPlayer getPlayerFromNetHandler (INetHandler hander) {
|
||||
return Minecraft.getMinecraft().thePlayer;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,9 @@ import java.util.Random;
|
|||
|
||||
import cpw.mods.fml.common.network.internal.FMLProxyPacket;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.InventoryLargeChest;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -60,6 +62,8 @@ import net.minecraft.nbt.NBTTagList;
|
|||
import net.minecraft.nbt.NBTTagLong;
|
||||
import net.minecraft.nbt.NBTTagShort;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraft.network.INetHandler;
|
||||
import net.minecraft.network.NetHandlerPlayServer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityChest;
|
||||
import net.minecraft.util.MathHelper;
|
||||
|
@ -334,7 +338,7 @@ public class Utils {
|
|||
public static void preDestroyBlock(World world, int i, int j, int k) {
|
||||
TileEntity tile = world.getTileEntity(i, j, k);
|
||||
|
||||
if (tile instanceof IInventory && !CoreProxy.proxy.isRenderWorld(world)) {
|
||||
if (tile instanceof IInventory && !world.isRemote) {
|
||||
if (!(tile instanceof IDropControlInventory) || ((IDropControlInventory) tile).doDrop()) {
|
||||
InvUtils.dropItems(world, (IInventory) tile, i, j, k);
|
||||
InvUtils.wipeInventory((IInventory) tile);
|
||||
|
@ -508,4 +512,16 @@ public class Utils {
|
|||
|
||||
return new FMLProxyPacket(buf, DefaultProps.NET_CHANNEL_NAME + "-CORE");
|
||||
}
|
||||
|
||||
/**
|
||||
* This function returns either the player from the handler if it's on the
|
||||
* server, or directly from the minecraft instance if it's the client.
|
||||
*/
|
||||
public static EntityPlayer getPlayerFromNetHandler (INetHandler handler) {
|
||||
if (handler instanceof NetHandlerPlayServer) {
|
||||
return ((NetHandlerPlayServer) handler).playerEntity;
|
||||
} else {
|
||||
return Minecraft.getMinecraft().thePlayer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
|||
|
||||
@Override
|
||||
public void initialize() {
|
||||
if (!CoreProxy.proxy.isRenderWorld(worldObj)) {
|
||||
if (!worldObj.isRemote) {
|
||||
powerHandler.configure(minEnergyReceived(), maxEnergyReceived(), 1, getMaxEnergy());
|
||||
checkRedstonePower();
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
|||
}
|
||||
|
||||
public final EnergyStage getEnergyStage() {
|
||||
if (CoreProxy.proxy.isSimulating(worldObj)) {
|
||||
if (!worldObj.isRemote) {
|
||||
if (energyStage == EnergyStage.OVERHEAT)
|
||||
return energyStage;
|
||||
EnergyStage newStage = computeEnergyStage();
|
||||
|
@ -135,7 +135,7 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
|||
}
|
||||
|
||||
public float getPistonSpeed() {
|
||||
if (CoreProxy.proxy.isSimulating(worldObj)) {
|
||||
if (!worldObj.isRemote) {
|
||||
return Math.max(0.16f * getHeatLevel(), 0.01f);
|
||||
}
|
||||
|
||||
|
@ -157,7 +157,7 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
|||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
|
||||
if (CoreProxy.proxy.isRenderWorld(worldObj)) {
|
||||
if (worldObj.isRemote) {
|
||||
if (progressPart != 0) {
|
||||
progress += getPistonSpeed();
|
||||
|
||||
|
@ -381,8 +381,9 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
|||
|
||||
@Override
|
||||
public void doWork(PowerHandler workProvider) {
|
||||
if (CoreProxy.proxy.isRenderWorld(worldObj))
|
||||
if (worldObj.isRemote) {
|
||||
return;
|
||||
}
|
||||
|
||||
addEnergy(powerHandler.useEnergy(1, maxEnergyReceived(), true) * 0.95F);
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan
|
|||
}
|
||||
ItemStack current = player.getCurrentEquippedItem();
|
||||
if (current != null) {
|
||||
if (CoreProxy.proxy.isSimulating(worldObj)) {
|
||||
if (!worldObj.isRemote) {
|
||||
if (FluidUtils.handleRightClick(this, side, player, true, true)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan
|
|||
}
|
||||
}
|
||||
}
|
||||
if (!CoreProxy.proxy.isRenderWorld(worldObj)) {
|
||||
if (!worldObj.isRemote) {
|
||||
player.openGui(BuildCraftEnergy.instance, GuiIds.ENGINE_IRON, worldObj, xCoord, yCoord, zCoord);
|
||||
}
|
||||
return true;
|
||||
|
@ -96,7 +96,7 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan
|
|||
|
||||
@Override
|
||||
public float getPistonSpeed() {
|
||||
if (CoreProxy.proxy.isSimulating(worldObj)) {
|
||||
if (!worldObj.isRemote) {
|
||||
return Math.max(0.07f * getHeatLevel(), 0.01f);
|
||||
}
|
||||
switch (getEnergyStage()) {
|
||||
|
|
|
@ -43,7 +43,7 @@ public class TileEngineStone extends TileEngineWithInventory {
|
|||
|
||||
@Override
|
||||
public boolean onBlockActivated(EntityPlayer player, ForgeDirection side) {
|
||||
if (!CoreProxy.proxy.isRenderWorld(worldObj)) {
|
||||
if (!worldObj.isRemote) {
|
||||
player.openGui(BuildCraftEnergy.instance, GuiIds.ENGINE_STONE, worldObj, xCoord, yCoord, zCoord);
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -52,7 +52,7 @@ public class TileEngineWood extends TileEngine {
|
|||
|
||||
@Override
|
||||
public float getPistonSpeed() {
|
||||
if (CoreProxy.proxy.isSimulating(worldObj))
|
||||
if (!worldObj.isRemote)
|
||||
return Math.max(0.08f * getHeatLevel(), 0.01f);
|
||||
switch (getEnergyStage()) {
|
||||
case GREEN:
|
||||
|
|
|
@ -56,7 +56,7 @@ public class BlockAutoWorkbench extends BlockBuildCraft {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!CoreProxy.proxy.isRenderWorld(world)) {
|
||||
if (!world.isRemote) {
|
||||
entityplayer.openGui(BuildCraftFactory.instance, GuiIds.AUTO_CRAFTING_TABLE, world, i, j, k);
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ public class BlockHopper extends BlockBuildCraft {
|
|||
}
|
||||
}
|
||||
|
||||
if (!CoreProxy.proxy.isRenderWorld(world)) {
|
||||
if (!world.isRemote) {
|
||||
entityplayer.openGui(BuildCraftFactory.instance, GuiIds.HOPPER, world, x, y, z);
|
||||
}
|
||||
|
||||
|
|
|
@ -135,9 +135,9 @@ public class BlockQuarry extends BlockBuildCraft {
|
|||
|
||||
@Override
|
||||
public void breakBlock(World world, int i, int j, int k, Block block, int par6) {
|
||||
|
||||
if (!CoreProxy.proxy.isSimulating(world))
|
||||
if (world.isRemote) {
|
||||
return;
|
||||
}
|
||||
|
||||
TileEntity tile = world.getTileEntity(i, j, k);
|
||||
if (tile instanceof TileQuarry) {
|
||||
|
|
|
@ -187,7 +187,7 @@ public class TileAutoWorkbench extends TileBuildCraft implements ISidedInventory
|
|||
@Override
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
if (CoreProxy.proxy.isRenderWorld(worldObj)) {
|
||||
if (worldObj.isRemote) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ public class TileFloodGate extends TileBuildCraft implements IFluidHandler {
|
|||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
|
||||
if (CoreProxy.proxy.isRenderWorld(worldObj))
|
||||
if (worldObj.isRemote)
|
||||
return;
|
||||
|
||||
if (powered)
|
||||
|
|
|
@ -34,7 +34,7 @@ public class TileHopper extends TileBuildCraft implements IInventory {
|
|||
@Override
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
if (CoreProxy.proxy.isRenderWorld(worldObj) || worldObj.getTotalWorldTime() % 2 != 0)
|
||||
if (worldObj.isRemote || worldObj.getTotalWorldTime() % 2 != 0)
|
||||
return;
|
||||
|
||||
TileEntity tile = this.getWorldObj().getTileEntity(xCoord, yCoord - 1, zCoord);
|
||||
|
|
|
@ -139,11 +139,11 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept
|
|||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
if (!isAlive && CoreProxy.proxy.isSimulating(worldObj)) {
|
||||
if (!isAlive && !worldObj.isRemote) {
|
||||
super.updateEntity();
|
||||
return;
|
||||
}
|
||||
if (!CoreProxy.proxy.isSimulating(worldObj) && isAlive) {
|
||||
if (!!worldObj.isRemote && isAlive) {
|
||||
super.updateEntity();
|
||||
return;
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept
|
|||
}
|
||||
}
|
||||
|
||||
if (CoreProxy.proxy.isSimulating(worldObj) && inProcess) {
|
||||
if (!worldObj.isRemote && inProcess) {
|
||||
sendNetworkUpdate(BuildCraftFactory.instance);
|
||||
}
|
||||
if (inProcess || !isDigging)
|
||||
|
@ -530,7 +530,7 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept
|
|||
}
|
||||
if (chunkTicket == null) {
|
||||
isAlive = false;
|
||||
if (placedBy != null && CoreProxy.proxy.isSimulating(worldObj)) {
|
||||
if (placedBy != null && !worldObj.isRemote) {
|
||||
((EntityPlayerMP) placedBy)
|
||||
.addChatMessage(new ChatComponentText(
|
||||
String.format(
|
||||
|
@ -673,7 +673,7 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept
|
|||
public void initialize() {
|
||||
super.initialize();
|
||||
|
||||
if (CoreProxy.proxy.isSimulating(this.getWorldObj()) && !box.initialized) {
|
||||
if (!this.getWorldObj().isRemote && !box.initialized) {
|
||||
setBoundaries(false);
|
||||
}
|
||||
|
||||
|
|
|
@ -124,7 +124,7 @@ public class TileRefinery extends TileBuildCraft implements IFluidHandler, IPowe
|
|||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
if (CoreProxy.proxy.isRenderWorld(worldObj)) {
|
||||
if (worldObj.isRemote) {
|
||||
simpleAnimationIterate();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ public class TileTank extends TileBuildCraft implements IFluidHandler {
|
|||
/* UPDATING */
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
if (CoreProxy.proxy.isRenderWorld(worldObj)) {
|
||||
if (worldObj.isRemote) {
|
||||
int lightValue = getFluidLightLevel();
|
||||
if (prevLightValue != lightValue) {
|
||||
prevLightValue = lightValue;
|
||||
|
|
|
@ -39,7 +39,7 @@ public class ContainerAutoWorkbench extends BuildCraftContainer {
|
|||
@Override
|
||||
public void setInventorySlotContents(int slot, ItemStack stack) {
|
||||
super.setInventorySlotContents(slot, stack);
|
||||
if (stack != null && tile.isLast() && CoreProxy.proxy.isRenderWorld(tile.getWorldObj())) {
|
||||
if (stack != null && tile.isLast() && tile.getWorldObj().isRemote) {
|
||||
InvUtils.addItemToolTip(stack, EnumChatFormatting.YELLOW + StringUtils.localize("gui.clickcraft"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ public class ContainerRefinery extends BuildCraftContainer {
|
|||
|
||||
refinery.setFilter(slot, filter);
|
||||
|
||||
if (CoreProxy.proxy.isRenderWorld(refinery.getWorldObj())) {
|
||||
if (refinery.getWorldObj().isRemote) {
|
||||
PacketPayloadStream payload = new PacketPayloadStream(new PacketPayloadStream.StreamWriter() {
|
||||
@Override
|
||||
public void writeData(ByteBuf data) {
|
||||
|
|
|
@ -7,6 +7,7 @@ import buildcraft.core.network.PacketPayload;
|
|||
import buildcraft.core.network.PacketPayloadStream;
|
||||
import buildcraft.core.network.PacketUpdate;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
import buildcraft.core.utils.Utils;
|
||||
import buildcraft.factory.TileRefinery;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
|
@ -30,9 +31,7 @@ public class PacketHandlerFactory extends BuildCraftChannelHandler {
|
|||
|
||||
try {
|
||||
INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get();
|
||||
|
||||
EntityPlayer player =
|
||||
CoreProxy.proxy.getPlayerFromNetHandler(netHandler);
|
||||
EntityPlayer player = Utils.getPlayerFromNetHandler(netHandler);
|
||||
|
||||
int packetID = packet.getID();
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ public class BlockLaserTable extends BlockContainer {
|
|||
if (entityplayer.isSneaking())
|
||||
return false;
|
||||
|
||||
if (!CoreProxy.proxy.isRenderWorld(world)) {
|
||||
if (!world.isRemote) {
|
||||
int meta = world.getBlockMetadata(i, j, k);
|
||||
entityplayer.openGui(BuildCraftSilicon.instance, meta, world, i, j, k);
|
||||
}
|
||||
|
|
|
@ -242,7 +242,7 @@ public class TileAdvancedCraftingTable extends TileLaserTableBase implements IIn
|
|||
craftSlot = new SlotCrafting(internalPlayer, internalInventoryCrafting, craftResult, 0, 0, 0);
|
||||
updateRecipe();
|
||||
}
|
||||
if (!CoreProxy.proxy.isSimulating(worldObj))
|
||||
if (!!worldObj.isRemote)
|
||||
return;
|
||||
if (lastMode == ActionMachineControl.Mode.Off)
|
||||
return;
|
||||
|
@ -369,7 +369,7 @@ public class TileAdvancedCraftingTable extends TileLaserTableBase implements IIn
|
|||
public void updateCraftingMatrix(int slot, ItemStack stack) {
|
||||
craftingSlots.setInventorySlotContents(slot, stack);
|
||||
updateRecipe();
|
||||
if (CoreProxy.proxy.isRenderWorld(worldObj)) {
|
||||
if (worldObj.isRemote) {
|
||||
PacketSlotChange packet = new PacketSlotChange(PacketIds.ADVANCED_WORKBENCH_SETSLOT, xCoord, yCoord, zCoord, slot, stack);
|
||||
BuildCraftSilicon.instance.sendToServer(packet);
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor, IAction
|
|||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
|
||||
if (!CoreProxy.proxy.isSimulating(worldObj))
|
||||
if (!!worldObj.isRemote)
|
||||
return;
|
||||
|
||||
// If a gate disabled us, remove laser and do nothing.
|
||||
|
|
|
@ -115,7 +115,7 @@ public class GuiAssemblyTable extends GuiAdvancedInterface {
|
|||
updateRecipes();
|
||||
|
||||
// Request current selection from server
|
||||
if (CoreProxy.proxy.isRenderWorld(assemblyTable.getWorldObj())) {
|
||||
if (assemblyTable.getWorldObj().isRemote) {
|
||||
BuildCraftSilicon.instance.sendToServer(new PacketCoordinates(PacketIds.SELECTION_ASSEMBLY_GET, assemblyTable.xCoord, assemblyTable.yCoord,
|
||||
assemblyTable.zCoord));
|
||||
}
|
||||
|
@ -197,14 +197,11 @@ public class GuiAssemblyTable extends GuiAdvancedInterface {
|
|||
|
||||
message.stack = slot.recipe.output;
|
||||
|
||||
if (CoreProxy.proxy.isRenderWorld(table.getWorldObj())) {
|
||||
|
||||
if (table.getWorldObj().isRemote) {
|
||||
PacketNBT packet = new PacketNBT(PacketIds.SELECTION_ASSEMBLY, message.getNBT(), table.xCoord, table.yCoord, table.zCoord);
|
||||
|
||||
BuildCraftSilicon.instance.sendToServer(packet);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -7,6 +7,7 @@ import buildcraft.core.network.PacketIds;
|
|||
import buildcraft.core.network.PacketNBT;
|
||||
import buildcraft.core.network.PacketSlotChange;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
import buildcraft.core.utils.Utils;
|
||||
import buildcraft.silicon.TileAdvancedCraftingTable;
|
||||
import buildcraft.silicon.TileAssemblyTable;
|
||||
import buildcraft.silicon.TileAssemblyTable.SelectionMessage;
|
||||
|
@ -33,8 +34,7 @@ public class PacketHandlerSilicon extends BuildCraftChannelHandler {
|
|||
try {
|
||||
INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get();
|
||||
|
||||
EntityPlayer player =
|
||||
CoreProxy.proxy.getPlayerFromNetHandler(netHandler);
|
||||
EntityPlayer player = Utils.getPlayerFromNetHandler(netHandler);
|
||||
|
||||
int packetID = packet.getID();
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ public class BlockFilteredBuffer extends BlockBuildCraft {
|
|||
}
|
||||
}
|
||||
|
||||
if (!CoreProxy.proxy.isRenderWorld(world)) {
|
||||
if (!world.isRemote) {
|
||||
entityplayer.openGui(BuildCraftTransport.instance, GuiIds.FILTERED_BUFFER, world, x, y, z);
|
||||
}
|
||||
|
||||
|
|
|
@ -514,7 +514,7 @@ public class BlockGenericPipe extends BlockBuildCraft {
|
|||
@Override
|
||||
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
|
||||
|
||||
if (CoreProxy.proxy.isRenderWorld(world))
|
||||
if (world.isRemote)
|
||||
return null;
|
||||
|
||||
ArrayList<ItemStack> list = new ArrayList<ItemStack>();
|
||||
|
@ -545,7 +545,7 @@ public class BlockGenericPipe extends BlockBuildCraft {
|
|||
@Override
|
||||
public void dropBlockAsItemWithChance(World world, int i, int j, int k, int l, float f, int dmg) {
|
||||
|
||||
if (CoreProxy.proxy.isRenderWorld(world))
|
||||
if (world.isRemote)
|
||||
return;
|
||||
|
||||
int i1 = quantityDropped(world.rand);
|
||||
|
@ -743,7 +743,7 @@ public class BlockGenericPipe extends BlockBuildCraft {
|
|||
|
||||
private boolean stripGate(Pipe pipe) {
|
||||
if (pipe.hasGate()) {
|
||||
if (!CoreProxy.proxy.isRenderWorld(pipe.container.getWorldObj())) {
|
||||
if (!pipe.container.getWorldObj().isRemote) {
|
||||
pipe.gate.dropGate();
|
||||
}
|
||||
pipe.resetGate();
|
||||
|
@ -774,7 +774,7 @@ public class BlockGenericPipe extends BlockBuildCraft {
|
|||
|
||||
private boolean stripWire(Pipe pipe, PipeWire color) {
|
||||
if (pipe.wireSet[color.ordinal()]) {
|
||||
if (!CoreProxy.proxy.isRenderWorld(pipe.container.getWorldObj())) {
|
||||
if (!pipe.container.getWorldObj().isRemote) {
|
||||
dropWire(color, pipe);
|
||||
}
|
||||
pipe.wireSet[color.ordinal()] = false;
|
||||
|
|
|
@ -147,7 +147,7 @@ public final class Gate {
|
|||
|
||||
// GUI
|
||||
public void openGui(EntityPlayer player) {
|
||||
if (!CoreProxy.proxy.isRenderWorld(player.worldObj)) {
|
||||
if (!player.worldObj.isRemote) {
|
||||
player.openGui(BuildCraftTransport.instance, GuiIds.GATES, pipe.container.getWorldObj(), pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -188,8 +188,9 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler
|
|||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
if (CoreProxy.proxy.isRenderWorld(container.getWorldObj()))
|
||||
if (container.getWorldObj().isRemote) {
|
||||
return;
|
||||
}
|
||||
|
||||
moveFluids();
|
||||
|
||||
|
|
|
@ -134,8 +134,9 @@ public class PipeTransportPower extends PipeTransport {
|
|||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
if (CoreProxy.proxy.isRenderWorld(container.getWorldObj()))
|
||||
if (container.getWorldObj().isRemote) {
|
||||
return;
|
||||
}
|
||||
|
||||
step();
|
||||
|
||||
|
|
|
@ -198,7 +198,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
|
|||
public boolean initialized = false;
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
public void updateEntity() {
|
||||
if (!worldObj.isRemote) {
|
||||
if (deletePipe) {
|
||||
worldObj.setBlockToAir(xCoord, yCoord, zCoord);
|
||||
|
|
|
@ -192,7 +192,7 @@ public final class TravelingItem {
|
|||
}
|
||||
|
||||
public EntityItem toEntityItem() {
|
||||
if (container != null && !CoreProxy.proxy.isRenderWorld(container.getWorldObj())) {
|
||||
if (container != null && !container.getWorldObj().isRemote) {
|
||||
if (getItemStack().stackSize <= 0)
|
||||
return null;
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ import java.util.NavigableSet;
|
|||
import java.util.TreeSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
@ -51,18 +52,21 @@ public class ContainerGateInterface extends BuildCraftContainer {
|
|||
|
||||
IInventory playerIInventory;
|
||||
Pipe pipe;
|
||||
|
||||
private final NavigableSet<ITrigger> _potentialTriggers = new TreeSet<ITrigger>(new Comparator<ITrigger>() {
|
||||
@Override
|
||||
public int compare(ITrigger o1, ITrigger o2) {
|
||||
return o1.getUniqueTag().compareTo(o2.getUniqueTag());
|
||||
}
|
||||
});
|
||||
|
||||
private final NavigableSet<IAction> _potentialActions = new TreeSet<IAction>(new Comparator<IAction>() {
|
||||
@Override
|
||||
public int compare(IAction o1, IAction o2) {
|
||||
return o1.getUniqueTag().compareTo(o2.getUniqueTag());
|
||||
}
|
||||
});
|
||||
|
||||
private boolean isSynchronized = false;
|
||||
private boolean isNetInitialized = false;
|
||||
public boolean[] triggerState = new boolean[8];
|
||||
|
@ -70,6 +74,7 @@ public class ContainerGateInterface extends BuildCraftContainer {
|
|||
|
||||
public ContainerGateInterface(IInventory playerInventory, Pipe pipe) {
|
||||
super(0);
|
||||
|
||||
this.playerIInventory = playerInventory;
|
||||
|
||||
for (int y = 0; y < 3; y++) {
|
||||
|
@ -86,7 +91,7 @@ public class ContainerGateInterface extends BuildCraftContainer {
|
|||
|
||||
// Do not attempt to create a list of potential actions and triggers on
|
||||
// the client.
|
||||
if (!CoreProxy.proxy.isRenderWorld(pipe.container.getWorldObj())) {
|
||||
if (!pipe.container.getWorldObj().isRemote) {
|
||||
_potentialActions.addAll(pipe.getActions());
|
||||
_potentialTriggers.addAll(ActionManager.getPipeTriggers(pipe.container));
|
||||
|
||||
|
@ -103,10 +108,13 @@ public class ContainerGateInterface extends BuildCraftContainer {
|
|||
|
||||
if (!pipe.gate.material.hasParameterSlot) {
|
||||
Iterator<ITrigger> it = _potentialTriggers.iterator();
|
||||
|
||||
while (it.hasNext()) {
|
||||
ITrigger trigger = it.next();
|
||||
if (trigger.requiresParameter())
|
||||
|
||||
if (trigger.requiresParameter()) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -114,9 +122,11 @@ public class ContainerGateInterface extends BuildCraftContainer {
|
|||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
if (pipe == null || pipe.gate == null)
|
||||
if (pipe == null || pipe.gate == null) {
|
||||
return false;
|
||||
return true;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -138,6 +148,7 @@ public class ContainerGateInterface extends BuildCraftContainer {
|
|||
public void updateActions(PacketUpdate packet) {
|
||||
_potentialActions.clear();
|
||||
PacketPayloadArrays payload = (PacketPayloadArrays) packet.payload;
|
||||
|
||||
int length = payload.intPayload[0];
|
||||
|
||||
for (int i = 0; i < length; i++) {
|
||||
|
@ -215,7 +226,12 @@ public class ContainerGateInterface extends BuildCraftContainer {
|
|||
}
|
||||
|
||||
public void sendSelectionChange(int position) {
|
||||
BuildCraftTransport.instance.sendToServer(new PacketUpdate(PacketIds.GATE_SELECTION_CHANGE, pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord, getSelectionPayload(position)));
|
||||
if (pipe.container.getWorld().isRemote) {
|
||||
BuildCraftTransport.instance.sendToServer(new PacketUpdate(
|
||||
PacketIds.GATE_SELECTION_CHANGE, pipe.container.xCoord,
|
||||
pipe.container.yCoord, pipe.container.zCoord,
|
||||
getSelectionPayload(position)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -223,13 +239,12 @@ public class ContainerGateInterface extends BuildCraftContainer {
|
|||
* (re-)requests the current selection on the gate if needed.
|
||||
*/
|
||||
public void synchronize() {
|
||||
|
||||
if (!isNetInitialized && CoreProxy.proxy.isRenderWorld(pipe.container.getWorldObj())) {
|
||||
if (!isNetInitialized && pipe.container.getWorldObj().isRemote) {
|
||||
isNetInitialized = true;
|
||||
BuildCraftTransport.instance.sendToServer(new PacketCoordinates(PacketIds.GATE_REQUEST_INIT, pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord));
|
||||
}
|
||||
|
||||
if (!isSynchronized && CoreProxy.proxy.isRenderWorld(pipe.container.getWorldObj())) {
|
||||
if (!isSynchronized && pipe.container.getWorldObj().isRemote) {
|
||||
isSynchronized = true;
|
||||
BuildCraftTransport.instance.sendToServer(new PacketCoordinates(PacketIds.GATE_REQUEST_SELECTION, pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord));
|
||||
}
|
||||
|
@ -249,28 +264,36 @@ public class ContainerGateInterface extends BuildCraftContainer {
|
|||
* SERVER SIDE *
|
||||
*/
|
||||
private int calculateTriggerState() {
|
||||
if (pipe.gate == null)
|
||||
if (pipe.gate == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int state = 0;
|
||||
|
||||
for (int i = 0; i < triggerState.length; i++) {
|
||||
if (pipe.gate.triggers[i] != null) {
|
||||
triggerState[i] = isNearbyTriggerActive(pipe.gate.triggers[i], pipe.gate.getTriggerParameter(i));
|
||||
}
|
||||
|
||||
state |= triggerState[i] ? 0x01 << i : 0x0;
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
|
||||
int state = calculateTriggerState();
|
||||
|
||||
if (state != lastTriggerState) {
|
||||
for (int i = 0; i < this.crafters.size(); i++) {
|
||||
ICrafting viewingPlayer = (ICrafting) this.crafters.get(i);
|
||||
|
||||
viewingPlayer.sendProgressBarUpdate(this, 0 /* State update */, state);
|
||||
}
|
||||
|
||||
lastTriggerState = state;
|
||||
}
|
||||
}
|
||||
|
@ -287,13 +310,15 @@ public class ContainerGateInterface extends BuildCraftContainer {
|
|||
* @param player
|
||||
*/
|
||||
private void sendActions(EntityPlayer player) {
|
||||
|
||||
// Compose update packet
|
||||
int length = _potentialActions.size();
|
||||
|
||||
PacketPayloadArrays payload = new PacketPayloadArrays(1, 0, length);
|
||||
|
||||
payload.intPayload[0] = length;
|
||||
|
||||
int i = 0;
|
||||
|
||||
for (IAction action : _potentialActions) {
|
||||
payload.stringPayload[i++] = action.getUniqueTag();
|
||||
}
|
||||
|
@ -310,7 +335,6 @@ public class ContainerGateInterface extends BuildCraftContainer {
|
|||
* @param player
|
||||
*/
|
||||
private void sendTriggers(EntityPlayer player) {
|
||||
|
||||
// Compose update packet
|
||||
int length = _potentialTriggers.size();
|
||||
PacketPayloadArrays payload = new PacketPayloadArrays(1, 0, length);
|
||||
|
@ -333,13 +357,13 @@ public class ContainerGateInterface extends BuildCraftContainer {
|
|||
* @param player
|
||||
*/
|
||||
public void sendSelection(EntityPlayer player) {
|
||||
if (pipe == null || pipe.gate == null)
|
||||
if (pipe == null || pipe.gate == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int position = 0; position < pipe.gate.material.numSlots; position++) {
|
||||
BuildCraftTransport.instance.sendToPlayer(player, new PacketUpdate(PacketIds.GATE_SELECTION, pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord, getSelectionPayload(position)));
|
||||
}
|
||||
|
||||
// System.out.println("Sending current selection to player");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -350,15 +374,19 @@ public class ContainerGateInterface extends BuildCraftContainer {
|
|||
}
|
||||
|
||||
public ITrigger getFirstTrigger() {
|
||||
if (_potentialTriggers.isEmpty())
|
||||
if (_potentialTriggers.isEmpty()) {
|
||||
return null;
|
||||
return _potentialTriggers.first();
|
||||
} else {
|
||||
return _potentialTriggers.first();
|
||||
}
|
||||
}
|
||||
|
||||
public ITrigger getLastTrigger() {
|
||||
if (_potentialTriggers.isEmpty())
|
||||
if (_potentialTriggers.isEmpty()) {
|
||||
return null;
|
||||
return _potentialTriggers.last();
|
||||
} else {
|
||||
return _potentialTriggers.last();
|
||||
}
|
||||
}
|
||||
|
||||
public Iterator<ITrigger> getTriggerIterator(boolean descending) {
|
||||
|
@ -366,25 +394,33 @@ public class ContainerGateInterface extends BuildCraftContainer {
|
|||
}
|
||||
|
||||
public boolean isNearbyTriggerActive(ITrigger trigger, ITriggerParameter parameter) {
|
||||
if (pipe.gate == null)
|
||||
if (pipe.gate == null) {
|
||||
return false;
|
||||
return pipe.gate.isNearbyTriggerActive(trigger, parameter);
|
||||
} else {
|
||||
return pipe.gate.isNearbyTriggerActive(trigger, parameter);
|
||||
}
|
||||
}
|
||||
|
||||
public void setTrigger(int position, ITrigger trigger, boolean notify) {
|
||||
if (pipe.gate == null)
|
||||
if (pipe.gate == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
pipe.gate.setTrigger(position, trigger);
|
||||
if (CoreProxy.proxy.isRenderWorld(pipe.container.getWorldObj()) && notify) {
|
||||
|
||||
if (pipe.container.getWorldObj().isRemote && notify) {
|
||||
sendSelectionChange(position);
|
||||
}
|
||||
}
|
||||
|
||||
public void setTriggerParameter(int position, ITriggerParameter parameter, boolean notify) {
|
||||
if (pipe.gate == null)
|
||||
if (pipe.gate == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
pipe.gate.setTriggerParameter(position, parameter);
|
||||
if (CoreProxy.proxy.isRenderWorld(pipe.container.getWorldObj()) && notify) {
|
||||
|
||||
if (pipe.container.getWorldObj().isRemote && notify) {
|
||||
sendSelectionChange(position);
|
||||
}
|
||||
}
|
||||
|
@ -397,15 +433,19 @@ public class ContainerGateInterface extends BuildCraftContainer {
|
|||
}
|
||||
|
||||
public IAction getFirstAction() {
|
||||
if (_potentialActions.isEmpty())
|
||||
if (_potentialActions.isEmpty()) {
|
||||
return null;
|
||||
return _potentialActions.first();
|
||||
} else {
|
||||
return _potentialActions.first();
|
||||
}
|
||||
}
|
||||
|
||||
public IAction getLastAction() {
|
||||
if (_potentialActions.isEmpty())
|
||||
if (_potentialActions.isEmpty()) {
|
||||
return null;
|
||||
return _potentialActions.last();
|
||||
} else {
|
||||
return _potentialActions.last();
|
||||
}
|
||||
}
|
||||
|
||||
public Iterator<IAction> getActionIterator(boolean descending) {
|
||||
|
@ -414,7 +454,8 @@ public class ContainerGateInterface extends BuildCraftContainer {
|
|||
|
||||
public void setAction(int position, IAction action, boolean notify) {
|
||||
pipe.gate.setAction(position, action);
|
||||
if (CoreProxy.proxy.isRenderWorld(pipe.container.getWorldObj()) && notify) {
|
||||
|
||||
if (pipe.container.getWorldObj().isRemote && notify) {
|
||||
sendSelectionChange(position);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ public class GuiEmeraldPipe extends GuiBuildCraft {
|
|||
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
if (CoreProxy.proxy.isRenderWorld(pipe.getWorld())) {
|
||||
if (pipe.getWorld().isRemote) {
|
||||
pipe.getStateController().setCurrentState(button.getController().getCurrentState());
|
||||
PacketGuiReturn pkt = new PacketGuiReturn(pipe.getContainer());
|
||||
pkt.sendPacket();
|
||||
|
|
|
@ -46,20 +46,24 @@ public class GuiGateInterface extends GuiAdvancedInterface {
|
|||
@Override
|
||||
public String getDescription() {
|
||||
ITrigger trigger = pipe.gate.getTrigger(slot);
|
||||
if (trigger != null)
|
||||
|
||||
if (trigger != null) {
|
||||
return trigger.getDescription();
|
||||
else
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public IIcon getIcon() {
|
||||
ITrigger trigger = pipe.gate.getTrigger(slot);
|
||||
if (trigger != null)
|
||||
|
||||
if (trigger != null) {
|
||||
return trigger.getIcon();
|
||||
else
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -87,30 +91,37 @@ public class GuiGateInterface extends GuiAdvancedInterface {
|
|||
@Override
|
||||
public String getDescription() {
|
||||
IAction action = pipe.gate.getAction(slot);
|
||||
if (action != null)
|
||||
if (action != null) {
|
||||
return action.getDescription();
|
||||
else
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public IIcon getIcon() {
|
||||
IAction action = pipe.gate.getAction(slot);
|
||||
if (action != null)
|
||||
|
||||
if (action != null) {
|
||||
return action.getIcon();
|
||||
else
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getTexture() {
|
||||
IAction action = pipe.gate.getAction(slot);
|
||||
|
||||
if (action instanceof BCAction) {
|
||||
BCAction bcAction = (BCAction) action;
|
||||
if (bcAction.getTextureMap() == 0)
|
||||
|
||||
if (bcAction.getTextureMap() == 0) {
|
||||
return TextureMap.locationBlocksTexture;
|
||||
}
|
||||
}
|
||||
|
||||
return super.getTexture();
|
||||
}
|
||||
|
||||
|
@ -144,10 +155,12 @@ public class GuiGateInterface extends GuiAdvancedInterface {
|
|||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
ITriggerParameter parameter = pipe.gate.getTriggerParameter(slot);
|
||||
if (parameter != null)
|
||||
|
||||
if (parameter != null) {
|
||||
return parameter.getItemStack();
|
||||
else
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public ITriggerParameter getTriggerParameter() {
|
||||
|
@ -290,8 +303,9 @@ public class GuiGateInterface extends GuiAdvancedInterface {
|
|||
|
||||
AdvancedSlot slot = null;
|
||||
|
||||
if (position < 0)
|
||||
if (position < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
slot = slots[position];
|
||||
|
||||
|
|
|
@ -7,12 +7,14 @@ import buildcraft.core.network.PacketIds;
|
|||
import buildcraft.core.network.PacketSlotChange;
|
||||
import buildcraft.core.network.PacketUpdate;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
import buildcraft.core.utils.Utils;
|
||||
import buildcraft.transport.PipeTransportItems;
|
||||
import buildcraft.transport.PipeTransportPower;
|
||||
import buildcraft.transport.TileGenericPipe;
|
||||
import buildcraft.transport.gui.ContainerGateInterface;
|
||||
import buildcraft.transport.pipes.PipeItemsDiamond;
|
||||
import buildcraft.transport.pipes.PipeItemsEmerald;
|
||||
import cpw.mods.fml.common.network.FMLOutboundHandler;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
|
@ -42,10 +44,8 @@ public class PacketHandlerTransport extends BuildCraftChannelHandler {
|
|||
public void decodeInto(ChannelHandlerContext ctx, ByteBuf data, BuildCraftPacket packet) {
|
||||
super.decodeInto(ctx, data, packet);
|
||||
try {
|
||||
INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get();
|
||||
|
||||
EntityPlayer player =
|
||||
CoreProxy.proxy.getPlayerFromNetHandler(netHandler);
|
||||
INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get();
|
||||
EntityPlayer player = Utils.getPlayerFromNetHandler(netHandler);
|
||||
|
||||
int packetID = packet.getID();
|
||||
|
||||
|
@ -82,29 +82,29 @@ public class PacketHandlerTransport extends BuildCraftChannelHandler {
|
|||
* SERVER SIDE *
|
||||
*/
|
||||
case PacketIds.DIAMOND_PIPE_SELECT: {
|
||||
onDiamondPipeSelect((EntityPlayer) player, (PacketSlotChange) packet);
|
||||
onDiamondPipeSelect(player, (PacketSlotChange) packet);
|
||||
break;
|
||||
}
|
||||
|
||||
case PacketIds.EMERALD_PIPE_SELECT: {
|
||||
onEmeraldPipeSelect((EntityPlayer) player, (PacketSlotChange) packet);
|
||||
onEmeraldPipeSelect(player, (PacketSlotChange) packet);
|
||||
break;
|
||||
}
|
||||
|
||||
case PacketIds.GATE_REQUEST_INIT:
|
||||
onGateInitRequest((EntityPlayer) player, (PacketCoordinates) packet);
|
||||
onGateInitRequest(player, (PacketCoordinates) packet);
|
||||
break;
|
||||
|
||||
case PacketIds.GATE_REQUEST_SELECTION:
|
||||
onGateSelectionRequest((EntityPlayer) player, (PacketCoordinates) packet);
|
||||
onGateSelectionRequest(player, (PacketCoordinates) packet);
|
||||
break;
|
||||
|
||||
case PacketIds.GATE_SELECTION_CHANGE:
|
||||
onGateSelectionChange((EntityPlayer) player, (PacketUpdate) packet);
|
||||
onGateSelectionChange(player, (PacketUpdate) packet);
|
||||
break;
|
||||
|
||||
case PacketIds.PIPE_ITEMSTACK_REQUEST: {
|
||||
((PacketPipeTransportItemStackRequest) packet).sendDataToPlayer((EntityPlayer) player);
|
||||
((PacketPipeTransportItemStackRequest) packet).sendDataToPlayer(player);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -216,8 +216,9 @@ public class PacketHandlerTransport extends BuildCraftChannelHandler {
|
|||
* @param packet
|
||||
*/
|
||||
private void onGateSelectionChange(EntityPlayer playerEntity, PacketUpdate packet) {
|
||||
if (!(playerEntity.openContainer instanceof ContainerGateInterface))
|
||||
if (!(playerEntity.openContainer instanceof ContainerGateInterface)) {
|
||||
return;
|
||||
}
|
||||
|
||||
((ContainerGateInterface) playerEntity.openContainer).setSelection(packet, true);
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public class PacketPipeTransportItemStackRequest extends BuildCraftPacket {
|
|||
|
||||
public void sendDataToPlayer (EntityPlayer player) {
|
||||
if (item != null) {
|
||||
BuildCraftTransport.instance.replyToPlayer(
|
||||
BuildCraftTransport.instance.sendToPlayer(
|
||||
player,
|
||||
new PacketPipeTransportItemStack(travelerID, item
|
||||
.getItemStack()));
|
||||
|
|
|
@ -89,7 +89,7 @@ public class PipeItemsDiamond extends Pipe<PipeTransportItems> implements IClien
|
|||
if (Block.getBlockFromItem(entityplayer.getCurrentEquippedItem().getItem()) instanceof BlockGenericPipe)
|
||||
return false;
|
||||
|
||||
if (!CoreProxy.proxy.isRenderWorld(container.getWorldObj())) {
|
||||
if (!container.getWorldObj().isRemote) {
|
||||
entityplayer.openGui(BuildCraftTransport.instance, GuiIds.PIPE_DIAMOND, container.getWorldObj(), container.xCoord, container.yCoord, container.zCoord);
|
||||
}
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ public class PipeItemsEmerald extends PipeItemsWood implements IClientState, IGu
|
|||
return true;
|
||||
}
|
||||
|
||||
if (!CoreProxy.proxy.isRenderWorld(container.getWorldObj())) {
|
||||
if (!container.getWorldObj().isRemote) {
|
||||
entityplayer.openGui(BuildCraftTransport.instance, GuiIds.PIPE_EMERALD_ITEM, container.getWorldObj(), container.xCoord, container.yCoord, container.zCoord);
|
||||
}
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ public class PipeItemsEmzuli extends PipeItemsWood implements IGuiReturnHandler
|
|||
return true;
|
||||
}
|
||||
|
||||
if (!CoreProxy.proxy.isRenderWorld(container.getWorldObj())) {
|
||||
if (!container.getWorldObj().isRemote) {
|
||||
entityplayer.openGui(BuildCraftTransport.instance, GuiIds.PIPE_LOGEMERALD_ITEM, container.getWorldObj(), container.xCoord, container.yCoord, container.zCoord);
|
||||
}
|
||||
|
||||
|
|
|
@ -192,8 +192,9 @@ public class PipeItemsObsidian extends Pipe<PipeTransportItems> implements IPowe
|
|||
}
|
||||
|
||||
public void pullItemIntoPipe(Entity entity, int distance) {
|
||||
if (CoreProxy.proxy.isRenderWorld(container.getWorldObj()))
|
||||
if (container.getWorldObj().isRemote) {
|
||||
return;
|
||||
}
|
||||
|
||||
ForgeDirection orientation = getOpenOrientation().getOpposite();
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ public abstract class PipeLogicWood {
|
|||
protected abstract boolean isValidConnectingTile(TileEntity tile);
|
||||
|
||||
public void initialize() {
|
||||
if (!CoreProxy.proxy.isRenderWorld(pipe.container.getWorldObj())) {
|
||||
if (!pipe.container.getWorldObj().isRemote) {
|
||||
switchSourceIfNeeded();
|
||||
}
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ public abstract class PipeLogicWood {
|
|||
}
|
||||
|
||||
public void onNeighborBlockChange(int blockId) {
|
||||
if (!CoreProxy.proxy.isRenderWorld(pipe.container.getWorldObj())) {
|
||||
if (!pipe.container.getWorldObj().isRemote) {
|
||||
switchSourceIfNeeded();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue