Search in sources :

Example 1 with ExternalConnectionContainer

use of crazypants.enderio.conduits.gui.ExternalConnectionContainer in project EnderIO by SleepyTrousers.

the class AbstractConduitPacket method getConduit.

@SuppressWarnings("unchecked")
@Nullable
public T getConduit(MessageContext ctx) {
    if (ctx.side == Side.SERVER) {
        if (ctx.getServerHandler().player.openContainer instanceof ExternalConnectionContainer) {
            final TileConduitBundle tileEntity = ((ExternalConnectionContainer) ctx.getServerHandler().player.openContainer).getTileEntity();
            if (tileEntity == null || !tileEntity.getPos().equals(getPos())) {
                Log.warn("Player " + ctx.getServerHandler().player.getName() + " tried to manipulate conduit while having another conduit's GUI open!");
                return null;
            }
        } else {
            if (BlockCoord.get(ctx.getServerHandler().player).distanceSq(getPos()) > EnderIO.proxy.getReachDistanceForPlayer(ctx.getServerHandler().player)) {
                Log.warn("Player " + ctx.getServerHandler().player.getName() + " tried to manipulate conduit without having its GUI open or being near it!");
                return null;
            }
        }
    }
    World world = getWorld(ctx);
    TileEntity tileEntity = getTileEntity(world);
    if (tileEntity instanceof IConduitBundle) {
        return (T) ((IConduitBundle) tileEntity).getConduit(getConType());
    }
    return null;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileConduitBundle(crazypants.enderio.conduits.conduit.TileConduitBundle) ExternalConnectionContainer(crazypants.enderio.conduits.gui.ExternalConnectionContainer) IConduitBundle(crazypants.enderio.base.conduit.IConduitBundle) World(net.minecraft.world.World) Nullable(javax.annotation.Nullable)

Aggregations

IConduitBundle (crazypants.enderio.base.conduit.IConduitBundle)1 TileConduitBundle (crazypants.enderio.conduits.conduit.TileConduitBundle)1 ExternalConnectionContainer (crazypants.enderio.conduits.gui.ExternalConnectionContainer)1 Nullable (javax.annotation.Nullable)1 TileEntity (net.minecraft.tileentity.TileEntity)1 World (net.minecraft.world.World)1