Search in sources :

Example 1 with ITileNodeHost

use of com.builtbroken.mc.api.tile.node.ITileNodeHost in project Engine by VoltzEngine-Project.

the class PacketOpenGUI method handle.

@Override
public void handle(EntityPlayer player, TileEntity tile) {
    if (!player.worldObj.isRemote) {
        IGuiTile guiTile = null;
        if (tile instanceof IGuiTile) {
            guiTile = (IGuiTile) tile;
        } else if (tile instanceof ITileNodeHost && ((ITileNodeHost) tile).getTileNode() instanceof IGuiTile) {
            guiTile = (IGuiTile) ((ITileNodeHost) tile).getTileNode();
        }
        if (guiTile != null) {
            ByteBuf buf = data().slice();
            int guiID = buf.readInt();
            if (!guiTile.openGui(player, guiID)) {
                Engine.logger().error("Failed to open gui with ID(" + guiID + ") at location " + new Location(player.worldObj, x, y, z) + ", tile = " + tile);
            }
        } else if (Engine.runningAsDev) {
            Engine.logger().error("Tile at location " + new Location(player.worldObj, x, y, z) + " is not an instance of ITileGUI, tile = " + tile);
        }
    } else if (Engine.runningAsDev) {
        Engine.logger().error("Can not open GUI on client using PacketOpenGUI, tile = " + tile);
    }
}
Also used : ITileNodeHost(com.builtbroken.mc.api.tile.node.ITileNodeHost) IGuiTile(com.builtbroken.mc.api.tile.access.IGuiTile) ByteBuf(io.netty.buffer.ByteBuf) Location(com.builtbroken.mc.imp.transform.vector.Location)

Example 2 with ITileNodeHost

use of com.builtbroken.mc.api.tile.node.ITileNodeHost in project Engine by VoltzEngine-Project.

the class MultiBlockListener method getLayoutOfMultiBlock.

@Override
public HashMap<IPos3D, String> getLayoutOfMultiBlock() {
    if (doRotation) {
        TileEntity tileEntity = getTileEntity();
        ForgeDirection dir = null;
        if (tileEntity instanceof IRotation) {
            dir = ((IRotation) tileEntity).getDirection();
        } else if (tileEntity instanceof ITileNodeHost && ((ITileNodeHost) tileEntity).getTileNode() instanceof IRotation) {
            dir = ((IRotation) ((ITileNodeHost) tileEntity).getTileNode()).getDirection();
        }
        return getLayoutOfMultiBlock(dir);
    }
    return MultiBlockLayoutHandler.get(layoutKey);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IRotation(com.builtbroken.mc.api.tile.access.IRotation) ITileNodeHost(com.builtbroken.mc.api.tile.node.ITileNodeHost) ForgeDirection(net.minecraftforge.common.util.ForgeDirection)

Aggregations

ITileNodeHost (com.builtbroken.mc.api.tile.node.ITileNodeHost)2 IGuiTile (com.builtbroken.mc.api.tile.access.IGuiTile)1 IRotation (com.builtbroken.mc.api.tile.access.IRotation)1 Location (com.builtbroken.mc.imp.transform.vector.Location)1 ByteBuf (io.netty.buffer.ByteBuf)1 TileEntity (net.minecraft.tileentity.TileEntity)1 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)1