use of mods.railcraft.api.core.items.IToolCrowbar in project Railcraft by Railcraft.
the class TrackKitLocomotive 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())) {
mode = EnumTools.next(mode, LocoMode.VALUES);
crowbar.onWhack(player, hand, heldItem, getPos());
sendUpdateToClient();
return true;
}
}
return false;
}
use of mods.railcraft.api.core.items.IToolCrowbar in project Railcraft by Railcraft.
the class TrackKitCoupler 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())) {
Mode m;
if (player.isSneaking())
m = mode.previous();
else
m = mode.next();
crowbar.onWhack(player, hand, heldItem, getPos());
if (Game.isHost(theWorldAsserted()))
setMode(m);
else
ChatPlugin.sendLocalizedChat(player, "gui.railcraft.track.mode.change", "ยง5" + LocalizationPlugin.translate("gui.railcraft.track.coupler.mode." + m.getName()));
return true;
}
}
return false;
}
use of mods.railcraft.api.core.items.IToolCrowbar in project Railcraft by Railcraft.
the class CrowbarHandler method onEntityInteract.
@SubscribeEvent
public void onEntityInteract(MinecartInteractEvent event) {
EntityPlayer thePlayer = event.getPlayer();
Entity entity = event.getEntity();
EnumHand hand = event.getHand();
if (event.getItem() != null && event.getItem().getItem() instanceof IToolCrowbar)
event.setCanceled(true);
ItemStack stack = event.getItem();
if (!InvTools.isEmpty(stack) && stack.getItem() instanceof IToolCrowbar) {
thePlayer.swingArm(event.getHand());
event.setCanceled(true);
} else
return;
if (Game.isClient(thePlayer.worldObj))
return;
boolean used = false;
IToolCrowbar crowbar = (IToolCrowbar) stack.getItem();
if (entity instanceof EntityMinecart) {
EntityMinecart cart = (EntityMinecart) entity;
if (RailcraftModuleManager.isModuleEnabled(ModuleTrain.class) && crowbar.canLink(thePlayer, hand, stack, cart)) {
boolean linkable = cart instanceof ILinkableCart;
if (!linkable || ((ILinkableCart) cart).isLinkable()) {
EntityMinecart last = linkMap.remove(thePlayer);
if (last != null && last.isEntityAlive()) {
LinkageManager lm = LinkageManager.instance();
if (lm.areLinked(cart, last, false)) {
lm.breakLink(cart, last);
used = true;
ChatPlugin.sendLocalizedChatFromServer(thePlayer, "gui.railcraft.link.broken");
LinkageManager.printDebug("Reason For Broken Link: User removed link.");
} else {
used = lm.createLink(last, (EntityMinecart) entity);
if (used)
ChatPlugin.sendLocalizedChatFromServer(thePlayer, "gui.railcraft.link.created");
}
if (!used)
ChatPlugin.sendLocalizedChatFromServer(thePlayer, "gui.railcraft.link.failed");
} else {
linkMap.put(thePlayer, (EntityMinecart) entity);
ChatPlugin.sendLocalizedChatFromServer(thePlayer, "gui.railcraft.link.started");
}
}
if (used)
crowbar.onLink(thePlayer, hand, stack, cart);
} else if (crowbar.canBoost(thePlayer, hand, stack, cart)) {
thePlayer.addExhaustion(1F);
//noinspection StatementWithEmptyBody
if (thePlayer.getRidingEntity() != null) {
// NOOP
} else //noinspection StatementWithEmptyBody
if (cart instanceof EntityTunnelBore) {
// NOOP
} else if (cart instanceof IDirectionalCart)
((IDirectionalCart) cart).reverse();
else {
int lvl = RailcraftEnchantments.SMACK.getLevel(stack);
if (lvl == 0) {
CartTools.smackCart(cart, thePlayer, SMACK_VELOCITY);
}
float smackVelocity = SMACK_VELOCITY * (float) Math.pow(1.7, lvl);
Train train = Train.getTrain(cart);
smackVelocity /= (float) Math.pow(train.size(), 1D / (1 + lvl));
for (EntityMinecart each : train) {
CartTools.smackCart(cart, each, thePlayer, smackVelocity);
}
}
crowbar.onBoost(thePlayer, hand, stack, cart);
}
}
}
use of mods.railcraft.api.core.items.IToolCrowbar in project Railcraft by Railcraft.
the class TrackKitThrottle 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())) {
if (speed == LocoSpeed.MAX) {
if (!getReverse()) {
setReverse(true);
} else {
setReverse(false);
setSpeed(EnumTools.next(speed, LocoSpeed.VALUES));
}
} else {
setSpeed(EnumTools.next(speed, LocoSpeed.VALUES));
}
crowbar.onWhack(player, hand, heldItem, getPos());
sendUpdateToClient();
return true;
}
}
return false;
}
use of mods.railcraft.api.core.items.IToolCrowbar in project Railcraft by Railcraft.
the class TrackKitPriming 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_PRIMING, player, theWorldAsserted(), getPos().getX(), getPos().getY(), getPos().getZ());
crowbar.onWhack(player, hand, heldItem, getPos());
return true;
}
}
return false;
}
Aggregations