Search in sources :

Example 1 with IMultiTileHost

use of com.builtbroken.mc.api.tile.multiblock.IMultiTileHost in project Engine by VoltzEngine-Project.

the class TileMulti method read.

@Override
public boolean read(ByteBuf buf, int id, EntityPlayer player, PacketType type) {
    if (worldObj.isRemote) {
        if (id == 1) {
            //Update host data for client use
            Pos pos = new Pos(buf);
            if (pos.isZero()) {
                this.setHost(null);
            } else {
                TileEntity tile = pos.getTileEntity(worldObj);
                if (tile instanceof IMultiTileHost) {
                    this.setHost((IMultiTileHost) tile);
                }
            }
            //Update should render
            boolean prev = shouldRenderBlock;
            shouldRenderBlock = buf.readBoolean();
            //Update render bounds
            if (buf.readBoolean()) {
                overrideRenderBounds = new Cube(buf);
            } else {
                overrideRenderBounds = new Cube(0, 0, 0, 1, 1, 1);
            }
            if (prev != shouldRenderBlock) {
                worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord);
            }
            return true;
        }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) Pos(com.builtbroken.mc.imp.transform.vector.Pos) Cube(com.builtbroken.mc.imp.transform.region.Cube) IMultiTileHost(com.builtbroken.mc.api.tile.multiblock.IMultiTileHost)

Example 2 with IMultiTileHost

use of com.builtbroken.mc.api.tile.multiblock.IMultiTileHost in project ICBM-Classic by BuiltBrokenModding.

the class ItemRadarGun method onItemUse.

@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hit_x, float hit_y, float hit_z) {
    if (world.isRemote) {
        return true;
    }
    Location location = new Location(world, x, y, z);
    TileEntity tile = location.getTileEntity();
    if (tile instanceof IMultiTile) {
        IMultiTileHost host = ((IMultiTile) tile).getHost();
        if (host instanceof TileEntity) {
            tile = (TileEntity) host;
        }
    }
    if (player.isSneaking()) {
        stack.setTagCompound(null);
        stack.setItemDamage(0);
        LanguageUtility.addChatToPlayer(player, "gps.cleared");
        player.inventoryContainer.detectAndSendChanges();
        return true;
    } else {
        Location storedLocation = getLocation(stack);
        if (storedLocation == null || !storedLocation.isAboveBedrock()) {
            LanguageUtility.addChatToPlayer(player, "gps.error.pos.invalid");
            return true;
        } else if (tile instanceof ILauncherController) {
            ((ILauncherController) tile).setTarget(storedLocation.toPos());
            LanguageUtility.addChatToPlayer(player, "gps.data.transferred");
            return true;
        }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ILauncherController(resonant.api.explosion.ILauncherController) IMultiTile(com.builtbroken.mc.api.tile.multiblock.IMultiTile) IMultiTileHost(com.builtbroken.mc.api.tile.multiblock.IMultiTileHost) Location(com.builtbroken.mc.imp.transform.vector.Location)

Example 3 with IMultiTileHost

use of com.builtbroken.mc.api.tile.multiblock.IMultiTileHost in project Engine by VoltzEngine-Project.

the class TileMulti method read.

@Override
public boolean read(ByteBuf buf, int id, EntityPlayer player, PacketType type) {
    if (worldObj.isRemote) {
        if (id == 1) {
            // Update host data for client use
            Pos pos = new Pos(buf);
            if (pos.isZero()) {
                this.setHost(null);
            } else {
                TileEntity tile = pos.getTileEntity(worldObj);
                if (tile instanceof IMultiTileHost) {
                    this.setHost((IMultiTileHost) tile);
                }
            }
            // Update should render
            boolean prev = shouldRenderBlock;
            shouldRenderBlock = buf.readBoolean();
            // Update render bounds
            if (buf.readBoolean()) {
                overrideRenderBounds = new Cube(buf);
            } else {
                overrideRenderBounds = new Cube(0, 0, 0, 1, 1, 1);
            }
            if (prev != shouldRenderBlock) {
                worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord);
            }
            return true;
        }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) Pos(com.builtbroken.mc.lib.transform.vector.Pos) Cube(com.builtbroken.mc.lib.transform.region.Cube) IMultiTileHost(com.builtbroken.mc.api.tile.multiblock.IMultiTileHost)

Aggregations

IMultiTileHost (com.builtbroken.mc.api.tile.multiblock.IMultiTileHost)3 TileEntity (net.minecraft.tileentity.TileEntity)3 IMultiTile (com.builtbroken.mc.api.tile.multiblock.IMultiTile)1 Cube (com.builtbroken.mc.imp.transform.region.Cube)1 Location (com.builtbroken.mc.imp.transform.vector.Location)1 Pos (com.builtbroken.mc.imp.transform.vector.Pos)1 Cube (com.builtbroken.mc.lib.transform.region.Cube)1 Pos (com.builtbroken.mc.lib.transform.vector.Pos)1 ILauncherController (resonant.api.explosion.ILauncherController)1