Search in sources :

Example 1 with Item1N4148

use of club.nsdn.nyasamarailway.item.tool.Item1N4148 in project NyaSamaRailway by NSDN.

the class NSPCT10M method interactFirst.

@Override
public boolean interactFirst(EntityPlayer player) {
    if (MinecraftForge.EVENT_BUS.post(new MinecartInteractEvent(this, player))) {
        return true;
    } else if (this.riddenByEntity != null && this.riddenByEntity instanceof EntityPlayer && this.riddenByEntity != player) {
        return true;
    } else if (this.riddenByEntity != null && this.riddenByEntity != player) {
        return false;
    } else {
        if (player != null) {
            ItemStack stack = player.getCurrentEquippedItem();
            if (stack != null) {
                if (stack.getItem() instanceof Item1N4148 || stack.getItem() instanceof ItemNTP8Bit || stack.getItem() instanceof ItemNTP32Bit) {
                    return true;
                }
                if (stack.getItem() instanceof ItemMinecart)
                    return true;
            }
            if (!this.worldObj.isRemote) {
                player.mountEntity(this);
                player.addChatComponentMessage(new ChatComponentTranslation("info.nsr.x"));
            }
        }
        return true;
    }
}
Also used : ItemNTP32Bit(club.nsdn.nyasamarailway.item.tool.ItemNTP32Bit) ItemNTP8Bit(club.nsdn.nyasamarailway.item.tool.ItemNTP8Bit) Item1N4148(club.nsdn.nyasamarailway.item.tool.Item1N4148) ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) ItemMinecart(net.minecraft.item.ItemMinecart) MinecartInteractEvent(net.minecraftforge.event.entity.minecart.MinecartInteractEvent) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack)

Example 2 with Item1N4148

use of club.nsdn.nyasamarailway.item.tool.Item1N4148 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)

Example 3 with Item1N4148

use of club.nsdn.nyasamarailway.item.tool.Item1N4148 in project NyaSamaRailway by NSDN.

the class MinecartBase method attackEntityFrom.

@Override
public boolean attackEntityFrom(DamageSource source, float damage) {
    if (!this.worldObj.isRemote && !this.isDead) {
        if (this.isEntityInvulnerable()) {
            return false;
        } else {
            this.setRollingDirection(-this.getRollingDirection());
            this.setRollingAmplitude(10);
            this.setBeenAttacked();
            this.setDamage(this.getDamage() + damage * 10.0F);
            boolean flag = false;
            if (source.getEntity() instanceof EntityPlayer) {
                EntityPlayer player = (EntityPlayer) source.getEntity();
                ItemStack stack = player.getCurrentEquippedItem();
                if (stack == null)
                    return false;
                if (stack.getItem() instanceof Item1N4148)
                    flag = true;
            }
            if (flag || this.getDamage() > 40.0F) {
                if (this.riddenByEntity != null) {
                    this.riddenByEntity.mountEntity(this);
                }
                if (flag && !this.hasCustomInventoryName()) {
                    this.setDead();
                } else {
                    this.killMinecart(source);
                }
            }
            return true;
        }
    } else {
        return true;
    }
}
Also used : Item1N4148(club.nsdn.nyasamarailway.item.tool.Item1N4148) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack)

Example 4 with Item1N4148

use of club.nsdn.nyasamarailway.item.tool.Item1N4148 in project NyaSamaRailway by NSDN.

the class NSPCT10 method interactFirst.

@Override
public boolean interactFirst(EntityPlayer player) {
    if (MinecraftForge.EVENT_BUS.post(new MinecartInteractEvent(this, player))) {
        return true;
    } else if (this.riddenByEntity != null && this.riddenByEntity instanceof EntityPlayer && this.riddenByEntity != player) {
        return true;
    } else if (this.riddenByEntity != null && this.riddenByEntity != player) {
        return false;
    } else {
        if (player != null) {
            ItemStack stack = player.getCurrentEquippedItem();
            if (stack != null) {
                if (stack.getItem() instanceof Item1N4148 || stack.getItem() instanceof ItemNTP8Bit || stack.getItem() instanceof ItemNTP32Bit) {
                    return true;
                }
                if (stack.getItem() instanceof ItemMinecart)
                    return true;
            }
            if (!this.worldObj.isRemote) {
                player.mountEntity(this);
                player.addChatComponentMessage(new ChatComponentTranslation("info.nsr.x"));
            }
        }
        return true;
    }
}
Also used : ItemNTP32Bit(club.nsdn.nyasamarailway.item.tool.ItemNTP32Bit) ItemNTP8Bit(club.nsdn.nyasamarailway.item.tool.ItemNTP8Bit) Item1N4148(club.nsdn.nyasamarailway.item.tool.Item1N4148) ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) ItemMinecart(net.minecraft.item.ItemMinecart) MinecartInteractEvent(net.minecraftforge.event.entity.minecart.MinecartInteractEvent) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack)

Example 5 with Item1N4148

use of club.nsdn.nyasamarailway.item.tool.Item1N4148 in project NyaSamaRailway by NSDN.

the class LocoBase method attackEntityFrom.

@Override
public boolean attackEntityFrom(DamageSource source, float damage) {
    if (!this.worldObj.isRemote && !this.isDead) {
        if (this.isEntityInvulnerable()) {
            return false;
        } else {
            this.setRollingDirection(-this.getRollingDirection());
            this.setRollingAmplitude(10);
            this.setBeenAttacked();
            this.setDamage(this.getDamage() + damage * 10.0F);
            boolean flag = false;
            if (source.getEntity() instanceof EntityPlayer) {
                EntityPlayer player = (EntityPlayer) source.getEntity();
                ItemStack stack = player.getCurrentEquippedItem();
                if (stack == null)
                    return false;
                if (stack.getItem() instanceof Item1N4148)
                    flag = true;
            }
            if (flag || this.getDamage() > 40.0F) {
                if (this.riddenByEntity != null) {
                    this.riddenByEntity.mountEntity(this);
                }
                if (flag && !this.hasCustomInventoryName()) {
                    this.setDead();
                } else {
                    this.killMinecart(source);
                }
            }
            return true;
        }
    } else {
        return true;
    }
}
Also used : Item1N4148(club.nsdn.nyasamarailway.item.tool.Item1N4148) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack)

Aggregations

Item1N4148 (club.nsdn.nyasamarailway.item.tool.Item1N4148)6 EntityPlayer (net.minecraft.entity.player.EntityPlayer)6 ItemStack (net.minecraft.item.ItemStack)6 ItemNTP32Bit (club.nsdn.nyasamarailway.item.tool.ItemNTP32Bit)4 ItemNTP8Bit (club.nsdn.nyasamarailway.item.tool.ItemNTP8Bit)4 ItemMinecart (net.minecraft.item.ItemMinecart)3 ChatComponentTranslation (net.minecraft.util.ChatComponentTranslation)3 MinecartInteractEvent (net.minecraftforge.event.entity.minecart.MinecartInteractEvent)3 IHighSpeedCart (club.nsdn.nyasamarailway.entity.IHighSpeedCart)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 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)1 Entity (net.minecraft.entity.Entity)1 EntityMinecart (net.minecraft.entity.item.EntityMinecart)1