Search in sources :

Example 1 with ILauncherController

use of resonant.api.explosion.ILauncherController in project ICBM-Classic by BuiltBrokenModding.

the class ItemRadarGun method onItemRightClick.

@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
    if (world.isRemote) {
        MovingObjectPosition objectMouseOver = player.rayTrace(200, 1);
        TileEntity tileEntity = world.getTileEntity(objectMouseOver.blockX, objectMouseOver.blockY, objectMouseOver.blockZ);
        if (!(tileEntity instanceof ILauncherController)) {
            Engine.instance.packetHandler.sendToServer(new PacketPlayerItem(player, objectMouseOver.blockX, objectMouseOver.blockY, objectMouseOver.blockZ));
        }
    }
    return stack;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) MovingObjectPosition(net.minecraft.util.MovingObjectPosition) ILauncherController(resonant.api.explosion.ILauncherController) PacketPlayerItem(com.builtbroken.mc.core.network.packet.PacketPlayerItem)

Example 2 with ILauncherController

use of resonant.api.explosion.ILauncherController 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 ILauncherController

use of resonant.api.explosion.ILauncherController in project ICBM-Classic by BuiltBrokenModding.

the class TileLauncherBase method getController.

@Override
public ILauncherController getController() {
    for (byte i = 2; i < 6; i++) {
        Pos position = new Pos((TileEntity) this).add(ForgeDirection.getOrientation(i));
        TileEntity tileEntity = position.getTileEntity(this.worldObj);
        if (tileEntity instanceof ILauncherController) {
            return (ILauncherController) tileEntity;
        }
    }
    return null;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ILauncherController(resonant.api.explosion.ILauncherController) Pos(com.builtbroken.mc.imp.transform.vector.Pos)

Example 4 with ILauncherController

use of resonant.api.explosion.ILauncherController in project ICBM-Classic by BuiltBrokenModding.

the class ItemLaserDetonator method onItemRightClick.

@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
    if (world.isRemote) {
        MovingObjectPosition objectMouseOver = player.rayTrace(200, 1);
        TileEntity tileEntity = world.getTileEntity(objectMouseOver.blockX, objectMouseOver.blockY, objectMouseOver.blockZ);
        if (!(tileEntity instanceof ILauncherController)) {
            Engine.instance.packetHandler.sendToServer(new PacketPlayerItem(player, objectMouseOver.blockX, objectMouseOver.blockY, objectMouseOver.blockZ));
        }
    }
    return stack;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) MovingObjectPosition(net.minecraft.util.MovingObjectPosition) ILauncherController(resonant.api.explosion.ILauncherController) PacketPlayerItem(com.builtbroken.mc.core.network.packet.PacketPlayerItem)

Aggregations

TileEntity (net.minecraft.tileentity.TileEntity)4 ILauncherController (resonant.api.explosion.ILauncherController)4 PacketPlayerItem (com.builtbroken.mc.core.network.packet.PacketPlayerItem)2 MovingObjectPosition (net.minecraft.util.MovingObjectPosition)2 IMultiTile (com.builtbroken.mc.api.tile.multiblock.IMultiTile)1 IMultiTileHost (com.builtbroken.mc.api.tile.multiblock.IMultiTileHost)1 Location (com.builtbroken.mc.imp.transform.vector.Location)1 Pos (com.builtbroken.mc.imp.transform.vector.Pos)1