Search in sources :

Example 1 with IHighSpeedCart

use of club.nsdn.nyasamarailway.entity.IHighSpeedCart in project NyaSamaRailway by NSDN.

the class ItemNTP8Bit method onUpdate.

@Override
public void onUpdate(ItemStack itemStack, World world, Entity entity, int index, boolean inHand) {
    if (!world.isRemote && inHand) {
        if (entity instanceof EntityPlayer) {
            EntityPlayer player = (EntityPlayer) entity;
            TrainPacket packet = new TrainPacket();
            packet.P = this.power.get(itemStack);
            packet.R = this.brake.get(itemStack);
            packet.Dir = this.dir.get(itemStack);
            packet.Mode = this.mode.get(itemStack);
            packet.dimensionID = player.dimension;
            EntityMinecart cart = packet.getCartInServer(this.cart.get(itemStack));
            if (cart != null) {
                if (cart instanceof IHighSpeedCart) {
                    ((IHighSpeedCart) cart).setHighSpeedMode(packet.Mode);
                }
                if (cart instanceof LocoBase) {
                    ((LocoBase) cart).setTrainPacket(packet);
                    return;
                }
                if (Traincraft.getInstance() != null) {
                    if (Traincraft.instance.isLocomotive(cart)) {
                        Traincraft.instance.Locomotive_setIsLocoTurnedOn(cart, true);
                    }
                }
                packet.Velocity = Dynamics.vel(cart.motionX, cart.motionZ);
                TrainController.doMotion(packet, cart);
            }
        }
    }
}
Also used : LocoBase(club.nsdn.nyasamarailway.entity.LocoBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityMinecart(net.minecraft.entity.item.EntityMinecart) IHighSpeedCart(club.nsdn.nyasamarailway.entity.IHighSpeedCart) TrainPacket(club.nsdn.nyasamarailway.network.TrainPacket)

Example 2 with IHighSpeedCart

use of club.nsdn.nyasamarailway.entity.IHighSpeedCart in project NyaSamaRailway by NSDN.

the class EntityInteractHandler method onEntityInteract.

@SubscribeEvent
public void onEntityInteract(EntityInteractEvent event) {
    if (event.entityLiving instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) event.entityLiving;
        if (player.worldObj.isRemote)
            return;
        Entity entity = event.target;
        ItemStack stack = player.getCurrentEquippedItem();
        if (stack != null) {
            if (stack.getItem() instanceof ItemNTP8Bit) {
                if (player.isSneaking()) {
                    ((ItemNTP8Bit) stack.getItem()).clearCart(stack, player);
                    return;
                }
                if (entity instanceof EntityMinecart) {
                    ((ItemNTP8Bit) stack.getItem()).addCart(stack, player, entity);
                }
            } else if (stack.getItem() instanceof ItemNTP32Bit) {
                if (player.isSneaking()) {
                    ((ItemNTP32Bit) stack.getItem()).clearCart(stack, player);
                    return;
                }
                if (entity instanceof EntityMinecart) {
                    ((ItemNTP32Bit) stack.getItem()).addCart(stack, player, entity);
                } else {
                    if (ExRollerCoaster.getInstance() != null) {
                        if (ExRollerCoaster.getInstance().verifyEntity(entity)) {
                            ((ItemNTP32Bit) stack.getItem()).addCart(stack, player, entity);
                        }
                    }
                    if (RailsOfWar.getInstance() != null) {
                        if (RailsOfWar.getInstance().verifyEntity(entity)) {
                            ((ItemNTP32Bit) stack.getItem()).addCart(stack, player, entity);
                        }
                    }
                }
            } else if (stack.getItem() instanceof Item1N4148) {
                if (entity instanceof IHighSpeedCart) {
                    IHighSpeedCart highSpeedCart = (IHighSpeedCart) entity;
                    highSpeedCart.modifyHighSpeedMode(player);
                }
            } else if (stack.getItem() instanceof ItemNSPCT5) {
                if (entity instanceof NSPCT5) {
                    ((NSPCT5) entity).modifyLength();
                }
            } else if (stack.getItem() instanceof ItemNSPCT5L) {
                if (entity instanceof NSPCT5L) {
                    ((NSPCT5L) entity).modifyLength();
                }
            }
        }
    }
}
Also used : ItemNTP32Bit(club.nsdn.nyasamarailway.item.tool.ItemNTP32Bit) Entity(net.minecraft.entity.Entity) ItemNTP8Bit(club.nsdn.nyasamarailway.item.tool.ItemNTP8Bit) Item1N4148(club.nsdn.nyasamarailway.item.tool.Item1N4148) NSPCT5(club.nsdn.nyasamarailway.entity.cart.NSPCT5) ItemNSPCT5(club.nsdn.nyasamarailway.item.cart.ItemNSPCT5) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) NSPCT5L(club.nsdn.nyasamarailway.entity.cart.NSPCT5L) ItemNSPCT5L(club.nsdn.nyasamarailway.item.cart.ItemNSPCT5L) EntityMinecart(net.minecraft.entity.item.EntityMinecart) ItemNSPCT5L(club.nsdn.nyasamarailway.item.cart.ItemNSPCT5L) IHighSpeedCart(club.nsdn.nyasamarailway.entity.IHighSpeedCart) ItemNSPCT5(club.nsdn.nyasamarailway.item.cart.ItemNSPCT5) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Aggregations

IHighSpeedCart (club.nsdn.nyasamarailway.entity.IHighSpeedCart)2 EntityMinecart (net.minecraft.entity.item.EntityMinecart)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 LocoBase (club.nsdn.nyasamarailway.entity.LocoBase)1 NSPCT5 (club.nsdn.nyasamarailway.entity.cart.NSPCT5)1 NSPCT5L (club.nsdn.nyasamarailway.entity.cart.NSPCT5L)1 ItemNSPCT5 (club.nsdn.nyasamarailway.item.cart.ItemNSPCT5)1 ItemNSPCT5L (club.nsdn.nyasamarailway.item.cart.ItemNSPCT5L)1 Item1N4148 (club.nsdn.nyasamarailway.item.tool.Item1N4148)1 ItemNTP32Bit (club.nsdn.nyasamarailway.item.tool.ItemNTP32Bit)1 ItemNTP8Bit (club.nsdn.nyasamarailway.item.tool.ItemNTP8Bit)1 TrainPacket (club.nsdn.nyasamarailway.network.TrainPacket)1 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)1 Entity (net.minecraft.entity.Entity)1 ItemStack (net.minecraft.item.ItemStack)1