Search in sources :

Example 1 with MinecartInteractEvent

use of net.minecraftforge.event.entity.minecart.MinecartInteractEvent in project Railcraft by Railcraft.

the class EntityCartFurnace method processInitialInteract.

//    public double getDrag() {
//        return DRAG_FACTOR;
//    }
@Override
public boolean processInitialInteract(EntityPlayer player, @Nullable ItemStack stack, EnumHand hand) {
    if (MinecraftForge.EVENT_BUS.post(new MinecartInteractEvent(this, player, stack, hand)))
        return true;
    Integer fuel = ReflectionHelper.getPrivateValue(EntityMinecartFurnace.class, this, 1);
    if (!InvTools.isEmpty(stack)) {
        int burnTime = FuelPlugin.getBurnTime(stack);
        if (burnTime > 0 && fuel + burnTime <= 32000) {
            if (!player.capabilities.isCreativeMode)
                player.inventory.setInventorySlotContents(player.inventory.currentItem, InvTools.depleteItem(stack));
            fuel += burnTime;
            ReflectionHelper.setPrivateValue(EntityMinecartFurnace.class, this, fuel, 1);
            pushX = posX - player.posX;
            pushZ = posZ - player.posZ;
        }
    }
    return true;
}
Also used : MinecartInteractEvent(net.minecraftforge.event.entity.minecart.MinecartInteractEvent)

Aggregations

MinecartInteractEvent (net.minecraftforge.event.entity.minecart.MinecartInteractEvent)1