Search in sources :

Example 11 with IToolCrowbar

use of mods.railcraft.api.core.items.IToolCrowbar in project Railcraft by Railcraft.

the class TrackKitLauncher method blockActivated.

@Override
public boolean blockActivated(EntityPlayer player, EnumHand hand, ItemStack heldItem) {
    if (!InvTools.isEmpty(heldItem) && heldItem.getItem() instanceof IToolCrowbar) {
        IToolCrowbar crowbar = (IToolCrowbar) heldItem.getItem();
        if (crowbar.canWhack(player, hand, heldItem, getPos())) {
            GuiHandler.openGui(EnumGui.TRACK_LAUNCHER, player, theWorldAsserted(), getPos().getX(), getPos().getY(), getPos().getZ());
            crowbar.onWhack(player, hand, heldItem, getPos());
            return true;
        }
    }
    return false;
}
Also used : IToolCrowbar(mods.railcraft.api.core.items.IToolCrowbar)

Example 12 with IToolCrowbar

use of mods.railcraft.api.core.items.IToolCrowbar in project Railcraft by Railcraft.

the class BlockWorldspikePoint method onBlockActivated.

@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
    if (heldItem != null && heldItem.getItem() instanceof IToolCrowbar) {
        IToolCrowbar crowbar = (IToolCrowbar) heldItem.getItem();
        if (crowbar.canWhack(player, hand, heldItem, pos)) {
            WorldCoordinate ourCoord = new WorldCoordinate(world.provider.getDimension(), pos);
            WorldCoordinate target = TileWorldspike.getTarget(player);
            if (target == null)
                TileWorldspike.setTarget(ourCoord, player, getUnlocalizedName());
            else if (world.provider.getDimension() != target.getDim())
                ChatPlugin.sendLocalizedChatFromServer(player, "gui.railcraft.worldspike.pair.fail.dimension", getUnlocalizedName());
            else if (ourCoord.equals(target)) {
                TileWorldspike.removeTarget(player);
                ChatPlugin.sendLocalizedChatFromServer(player, "gui.railcraft.worldspike.pair.cancel", getUnlocalizedName());
            } else {
                if (TileWorldspike.isTargetLoaded(player, target, getUnlocalizedName())) {
                    TileEntity tile = WorldPlugin.getBlockTile(world, target.getPos());
                    if (tile instanceof TileWorldspike)
                        ((TileWorldspike) tile).setPoint(player, ourCoord);
                    else if (tile != null)
                        ChatPlugin.sendLocalizedChatFromServer(player, "gui.railcraft.worldspike.pair.fail.invalid", getUnlocalizedName());
                }
            }
            crowbar.onWhack(player, hand, heldItem, pos);
            return true;
        }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) WorldCoordinate(mods.railcraft.api.core.WorldCoordinate) IToolCrowbar(mods.railcraft.api.core.items.IToolCrowbar)

Example 13 with IToolCrowbar

use of mods.railcraft.api.core.items.IToolCrowbar in project Railcraft by Railcraft.

the class TileWorldspike method blockActivated.

@Override
public boolean blockActivated(EntityPlayer player, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
    if (heldItem != null && heldItem.getItem() instanceof IToolCrowbar) {
        IToolCrowbar crowbar = (IToolCrowbar) heldItem.getItem();
        if (crowbar.canWhack(player, hand, heldItem, getPos())) {
            if (Game.isHost(worldObj)) {
                WorldCoordinate ourCoord = new WorldCoordinate(this);
                WorldCoordinate target = pointPairingMap.get(player);
                if (target == null)
                    setTarget(ourCoord, player, getLocalizationTag());
                else if (worldObj.provider.getDimension() != target.getDim())
                    ChatPlugin.sendLocalizedChatFromServer(player, "gui.railcraft.worldspike.pair.fail.dimension", getLocalizationTag());
                else if (Objects.equals(ourCoord, target)) {
                    removeTarget(player);
                    ChatPlugin.sendLocalizedChatFromServer(player, "gui.railcraft.worldspike.pair.cancel", getLocalizationTag());
                } else
                    setPoint(player, target);
                crowbar.onWhack(player, hand, heldItem, getPos());
            }
            return true;
        }
    }
    return super.blockActivated(player, hand, heldItem, side, hitX, hitY, hitZ);
}
Also used : WorldCoordinate(mods.railcraft.api.core.WorldCoordinate) IToolCrowbar(mods.railcraft.api.core.items.IToolCrowbar)

Aggregations

IToolCrowbar (mods.railcraft.api.core.items.IToolCrowbar)13 ItemStack (net.minecraft.item.ItemStack)3 WorldCoordinate (mods.railcraft.api.core.WorldCoordinate)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 ILinkableCart (mods.railcraft.api.carts.ILinkableCart)1 ModuleTrain (mods.railcraft.common.modules.ModuleTrain)1 Entity (net.minecraft.entity.Entity)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 EntityMinecart (net.minecraft.entity.item.EntityMinecart)1 EntitySlime (net.minecraft.entity.monster.EntitySlime)1 TileEntity (net.minecraft.tileentity.TileEntity)1 EnumHand (net.minecraft.util.EnumHand)1 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1