Search in sources :

Example 56 with EntityMinecart

use of net.minecraft.entity.item.EntityMinecart in project Railcraft by Railcraft.

the class CartTools method getMinecartUUIDsAt.

public static List<UUID> getMinecartUUIDsAt(World world, int i, int j, int k, float sensitivity) {
    sensitivity = Math.min(sensitivity, 0.49f);
    List<EntityMinecart> entities = world.getEntitiesWithinAABB(EntityMinecart.class, new AxisAlignedBB(i + sensitivity, j + sensitivity, k + sensitivity, i + 1 - sensitivity, j + 1 - sensitivity, k + 1 - sensitivity));
    return entities.stream().filter(cart -> !cart.isDead).map(Entity::getPersistentID).collect(Collectors.toList());
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) EntityMinecart(net.minecraft.entity.item.EntityMinecart)

Example 57 with EntityMinecart

use of net.minecraft.entity.item.EntityMinecart in project Railcraft by Railcraft.

the class EntityLocomotive method canLinkWithCart.

@Override
public boolean canLinkWithCart(EntityMinecart cart) {
    if (isExemptFromLinkLimits(cart))
        return true;
    LinkageManager lm = LinkageManager.instance();
    EntityMinecart linkA = lm.getLinkedCartA(this);
    if (linkA != null && !isExemptFromLinkLimits(linkA))
        return false;
    EntityMinecart linkB = lm.getLinkedCartB(this);
    return linkB == null || isExemptFromLinkLimits(linkB);
}
Also used : EntityMinecart(net.minecraft.entity.item.EntityMinecart)

Example 58 with EntityMinecart

use of net.minecraft.entity.item.EntityMinecart in project Railcraft by Railcraft.

the class ItemMagnifyingGlass method onEntityInteract.

@SubscribeEvent
public void onEntityInteract(PlayerInteractEvent.EntityInteract event) {
    EntityPlayer thePlayer = event.getEntityPlayer();
    Entity entity = event.getTarget();
    ItemStack stack = event.getItemStack();
    if (stack != null && stack.getItem() instanceof ItemMagnifyingGlass)
        thePlayer.swingArm(event.getHand());
    if (Game.isClient(thePlayer.worldObj))
        return;
    if (stack != null && stack.getItem() instanceof ItemMagnifyingGlass)
        if (entity instanceof EntityMinecart) {
            EntityMinecart cart = (EntityMinecart) entity;
            ChatPlugin.sendLocalizedChatFromServer(thePlayer, "gui.railcraft.mag.glass.placedby", LocalizationPlugin.getEntityLocalizationTag(cart), CartToolsAPI.getCartOwner(cart));
            event.setCanceled(true);
        }
}
Also used : Entity(net.minecraft.entity.Entity) TileEntity(net.minecraft.tileentity.TileEntity) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) EntityMinecart(net.minecraft.entity.item.EntityMinecart) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 59 with EntityMinecart

use of net.minecraft.entity.item.EntityMinecart in project NyaSamaRailway by NSDN.

the class BlockRailReception method onRailPowered.

@Override
public void onRailPowered(World world, int x, int y, int z, int meta, boolean hasCart) {
    boolean playerDetectable = false;
    if (!checkNearbySameRail(world, x, y, z))
        playerDetectable = true;
    if (playerDetectable) {
        TileEntityRailReception rail = null;
        if (world.getTileEntity(x, y, z) instanceof TileEntityRailReception) {
            rail = (TileEntityRailReception) world.getTileEntity(x, y, z);
        }
        if (rail != null) {
            if (!rail.cartType.isEmpty() && !world.isRemote) {
                if (rail.cartType.equals("loco")) {
                    return;
                }
                if (!hasCart && (isRailPowered(world, x + 1, y, z) || isRailPowered(world, x, y, z - 1))) {
                    spawnCart(world, x, y, z);
                    rail.delay = 0;
                    rail.enable = false;
                }
                if (hasCart && (isRailPowered(world, x - 1, y, z) || isRailPowered(world, x, y, z + 1))) {
                    EntityMinecart cart = getMinecart(world, x, y, z);
                    if (cart == null)
                        return;
                    cart.killMinecart(new DamageSource("nsr"));
                }
            }
        }
    }
}
Also used : DamageSource(net.minecraft.util.DamageSource) EntityMinecart(net.minecraft.entity.item.EntityMinecart)

Example 60 with EntityMinecart

use of net.minecraft.entity.item.EntityMinecart in project NyaSamaRailway by NSDN.

the class BlockRailReception method spawnCart.

public void spawnCart(World world, int x, int y, int z) {
    TileEntityRailReception rail = null;
    if (world.getTileEntity(x, y, z) instanceof TileEntityRailReception) {
        rail = (TileEntityRailReception) world.getTileEntity(x, y, z);
    }
    if (rail != null) {
        if (rail.cartType.isEmpty())
            return;
        if (rail.cartType.equals("loco"))
            return;
        if (rail.cartType.equals(NSTCT1.class.getName())) {
            MinecartBase cart = new NSTCT1(world, (double) x + 0.5, (double) y + 0.5, (double) z + 0.5);
            world.spawnEntityInWorld(cart);
        } else if (rail.cartType.equals(NSBT1.class.getName())) {
            MinecartBase cart = new NSBT1(world, (double) x + 0.5, (double) y + 0.5, (double) z + 0.5);
            world.spawnEntityInWorld(cart);
        } else if (rail.cartType.equals(NSPCT1.class.getName())) {
            MinecartBase cart = new NSPCT1(world, (double) x + 0.5, (double) y + 0.5, (double) z + 0.5);
            world.spawnEntityInWorld(cart);
        } else if (rail.cartType.equals(NSPCT2.class.getName())) {
            MinecartBase cart = new NSPCT2(world, (double) x + 0.5, (double) y + 0.5, (double) z + 0.5);
            world.spawnEntityInWorld(cart);
        } else if (rail.cartType.equals(NSPCT3.class.getName())) {
            MinecartBase cart = new NSPCT3(world, (double) x + 0.5, (double) y + 0.5, (double) z + 0.5);
            world.spawnEntityInWorld(cart);
        } else if (rail.cartType.equals(NSPCT5L.class.getName())) {
            MinecartBase cart = new NSPCT5L(world, (double) x + 0.5, (double) y + 0.5, (double) z + 0.5);
            world.spawnEntityInWorld(cart);
        } else if (rail.cartType.equals(NSPCT6.class.getName())) {
            MinecartBase cart = new NSPCT6(world, (double) x + 0.5, (double) y + 0.5, (double) z + 0.5);
            world.spawnEntityInWorld(cart);
        } else if (rail.cartType.equals(NSPCT8.class.getName())) {
            MinecartBase cart = new NSPCT8(world, (double) x + 0.5, (double) y + 0.5, (double) z + 0.5);
            world.spawnEntityInWorld(cart);
        } else if (rail.cartType.equals(NSPCT9.class.getName())) {
            NSPCT9 cart = new NSPCT9(world, (double) x + 0.5, (double) y + 0.5, (double) z + 0.5);
            cart.setExtendedInfo(rail.extInfo);
            world.spawnEntityInWorld(cart);
        } else {
            EntityMinecart cart = EntityMinecartEmpty.createMinecart(world, (double) x + 0.5, (double) y + 0.5, (double) z + 0.5, -1);
            world.spawnEntityInWorld(cart);
        }
    }
}
Also used : EntityMinecart(net.minecraft.entity.item.EntityMinecart)

Aggregations

EntityMinecart (net.minecraft.entity.item.EntityMinecart)75 EntityPlayer (net.minecraft.entity.player.EntityPlayer)21 ItemStack (net.minecraft.item.ItemStack)17 List (java.util.List)16 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)11 Entity (net.minecraft.entity.Entity)9 DamageSource (net.minecraft.util.DamageSource)8 World (net.minecraft.world.World)8 ItemNTP32Bit (club.nsdn.nyasamarailway.item.tool.ItemNTP32Bit)6 ItemNTP8Bit (club.nsdn.nyasamarailway.item.tool.ItemNTP8Bit)6 ILinkageManager (mods.railcraft.api.carts.ILinkageManager)6 LocoBase (club.nsdn.nyasamarailway.entity.LocoBase)5 Nullable (javax.annotation.Nullable)5 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)5 TileEntityReceiver (club.nsdn.nyasamatelecom.api.tileentity.TileEntityReceiver)4 EntityLivingBase (net.minecraft.entity.EntityLivingBase)4 MinecartUpdateEvent (net.minecraftforge.event.entity.minecart.MinecartUpdateEvent)4 TrainPacket (club.nsdn.nyasamarailway.network.TrainPacket)3 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)3 ArrayList (java.util.ArrayList)3