Search in sources :

Example 6 with IToolCrowbar

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

the class TrackKitRouting method blockActivated.

@Override
public boolean blockActivated(EntityPlayer player, EnumHand hand, @Nullable 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_ROUTING, 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 7 with IToolCrowbar

use of mods.railcraft.api.core.items.IToolCrowbar in project Trains-In-Motion-1.7.10 by EternalBlueFlame.

the class TrackInstanceBase method blockActivated.

@Override
public boolean blockActivated(EntityPlayer player) {
    if (this instanceof ITrackReversable) {
        ItemStack current = player.getCurrentEquippedItem();
        if (current != null && current.getItem() instanceof IToolCrowbar) {
            IToolCrowbar crowbar = (IToolCrowbar) current.getItem();
            if (crowbar.canWhack(player, current, getX(), getY(), getZ())) {
                ITrackReversable track = (ITrackReversable) this;
                track.setReversed(!track.isReversed());
                markBlockNeedsUpdate();
                crowbar.onWhack(player, current, getX(), getY(), getZ());
                return true;
            }
        }
    }
    return false;
}
Also used : IToolCrowbar(mods.railcraft.api.core.items.IToolCrowbar) ItemStack(net.minecraft.item.ItemStack)

Example 8 with IToolCrowbar

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

the class TrackKitLocking method blockActivated.

@Override
public boolean blockActivated(EntityPlayer player, EnumHand hand, @Nullable ItemStack heldItem) {
    if (!InvTools.isEmpty(heldItem) && heldItem.getItem() instanceof IToolCrowbar) {
        IToolCrowbar crowbar = (IToolCrowbar) heldItem.getItem();
        if (crowbar.canWhack(player, hand, heldItem, getPos())) {
            LockingProfileType p;
            if (player.isSneaking())
                p = profile.previous();
            else
                p = profile.next();
            crowbar.onWhack(player, hand, heldItem, getPos());
            if (Game.isHost(theWorldAsserted()))
                setProfile(p);
            else
                ChatPlugin.sendLocalizedChat(player, "gui.railcraft.track.mode.change", "ยง5" + LocalizationPlugin.translate("gui.railcraft.track.locking.mode." + p.tag));
            return true;
        }
    }
    return false;
}
Also used : IToolCrowbar(mods.railcraft.api.core.items.IToolCrowbar)

Example 9 with IToolCrowbar

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

the class TrackKitEmbarking method onMinecartPass.

@Override
public void onMinecartPass(EntityMinecart cart) {
    if (isPowered() && cart.canBeRidden() && !cart.isBeingRidden() && cart.getEntityData().getInteger("MountPrevention") <= 0) {
        int a = area;
        AxisAlignedBB box = AABBFactory.start().createBoxForTileAt(getPos()).build();
        box = box.expand(a, a, a);
        List<EntityLivingBase> entities = theWorldAsserted().getEntitiesWithinAABB(EntityLivingBase.class, box);
        if (entities.size() > 0) {
            EntityLivingBase entity = entities.get(MiscTools.RANDOM.nextInt(entities.size()));
            if (entity instanceof EntityPlayer) {
                EntityPlayer player = (EntityPlayer) entity;
                if (player.isSneaking()) {
                    return;
                }
                ItemStack current = player.getActiveItemStack();
                if (!InvTools.isEmpty(current) && current.getItem() instanceof IToolCrowbar) {
                    return;
                }
            } else if (excludedEntities.contains(entity.getClass())) {
                return;
            } else if (entity instanceof EntitySlime) {
                EntitySlime slime = (EntitySlime) entity;
                if (slime.getSlimeSize() >= 100)
                    return;
            }
            if (!entity.isRiding()) {
                EffectManager.instance.teleportEffect(entity, cart.getPositionVector());
                CartTools.addPassenger(cart, entity);
            }
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) EntitySlime(net.minecraft.entity.monster.EntitySlime) EntityLivingBase(net.minecraft.entity.EntityLivingBase) IToolCrowbar(mods.railcraft.api.core.items.IToolCrowbar) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack)

Example 10 with IToolCrowbar

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

the class TrackKitEmbarking method blockActivated.

@Override
public boolean blockActivated(EntityPlayer player, EnumHand hand, @Nullable ItemStack heldItem) {
    if (!InvTools.isEmpty(heldItem) && heldItem.getItem() instanceof IToolCrowbar) {
        IToolCrowbar crowbar = (IToolCrowbar) heldItem.getItem();
        GuiHandler.openGui(EnumGui.TRACK_EMBARKING, 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)

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