Search in sources :

Example 41 with EntityMinecart

use of net.minecraft.entity.item.EntityMinecart in project Trains-In-Motion-1.7.10 by EternalBlueFlame.

the class CartTools method getMinecartsOnAllSides.

public static List<EntityMinecart> getMinecartsOnAllSides(World world, int i, int j, int k, float sensitivity, Class<? extends EntityMinecart> type, boolean subclass) {
    List<EntityMinecart> list = new ArrayList<EntityMinecart>();
    List<EntityMinecart> carts = new ArrayList<EntityMinecart>();
    for (int side = 0; side < 6; side++) {
        list.addAll(getMinecartsOnSide(world, i, j, k, sensitivity, ForgeDirection.getOrientation(side)));
    }
    for (EntityMinecart cart : list) {
        if ((subclass && type.isInstance(cart)) || cart.getClass() == type)
            carts.add(cart);
    }
    return carts;
}
Also used : ArrayList(java.util.ArrayList) EntityMinecart(net.minecraft.entity.item.EntityMinecart)

Example 42 with EntityMinecart

use of net.minecraft.entity.item.EntityMinecart in project Trains-In-Motion-1.7.10 by EternalBlueFlame.

the class CartTools method getMinecartsAt.

/**
     * @param world
     * @param i
     * @param j
     * @param k
     * @param sensitivity Controls the size of the search box, ranges from
     *                    (-inf, 0.49].
     * @return
     */
public static List<EntityMinecart> getMinecartsAt(World world, int i, int j, int k, float sensitivity) {
    sensitivity = Math.min(sensitivity, 0.49f);
    List entities = world.getEntitiesWithinAABB(EntityMinecart.class, AxisAlignedBB.getBoundingBox(i + sensitivity, j + sensitivity, k + sensitivity, i + 1 - sensitivity, j + 1 - sensitivity, k + 1 - sensitivity));
    List<EntityMinecart> carts = new ArrayList<EntityMinecart>();
    for (Object o : entities) {
        EntityMinecart cart = (EntityMinecart) o;
        if (!cart.isDead)
            carts.add((EntityMinecart) o);
    }
    return carts;
}
Also used : ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) EntityMinecart(net.minecraft.entity.item.EntityMinecart)

Example 43 with EntityMinecart

use of net.minecraft.entity.item.EntityMinecart in project ImmersiveEngineering by BluSunrize.

the class EventHandler method onCapabilitiesAttach.

@SubscribeEvent
public void onCapabilitiesAttach(AttachCapabilitiesEvent.Entity event) {
    if (event.getEntity() instanceof EntityMinecart) {
        EntityMinecart entityMinecart = (EntityMinecart) event.getEntity();
        event.addCapability(new ResourceLocation("immersiveengineering:shader"), new ShaderWrapper_Direct("immersiveengineering:minecart"));
    }
}
Also used : ResourceLocation(net.minecraft.util.ResourceLocation) EntityMinecart(net.minecraft.entity.item.EntityMinecart) ShaderWrapper_Direct(blusunrize.immersiveengineering.api.shader.CapabilityShader.ShaderWrapper_Direct) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 44 with EntityMinecart

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

the class TileDispenserTrain method spawnNextCart.

private boolean spawnNextCart() {
    ItemStack spawn = getPattern().getStackInSlot(patternIndex);
    if (InvTools.isEmpty(spawn)) {
        resetSpawnSequence();
        return false;
    }
    Predicate<ItemStack> filter = new MinecartItemType(spawn);
    if (InvTools.countItems(invStock, filter) == 0) {
        resetSpawnSequence();
        return false;
    }
    BlockPos offset = getPos().offset(facing);
    if ((spawn.getItem() instanceof ItemMinecart || spawn.getItem() instanceof IMinecartItem) && CartToolsAPI.getMinecartOnSide(worldObj, getPos(), 0, facing) == null) {
        ItemStack cartItem = InvTools.removeOneItem(invStock, filter);
        if (!InvTools.isEmpty(cartItem)) {
            EntityMinecart cartPlaced = CartTools.placeCart(getOwner(), cartItem, (WorldServer) worldObj, offset);
            if (cartPlaced != null) {
                CartToolsAPI.getLinkageManager(worldObj).createLink(cartPlaced, lastCart);
                lastCart = cartPlaced;
                patternIndex++;
                if (patternIndex >= getPattern().getSizeInventory())
                    resetSpawnSequence();
                return true;
            } else
                InvTools.moveItemStack(cartItem, invStock);
        }
    }
    return false;
}
Also used : ItemMinecart(net.minecraft.item.ItemMinecart) IMinecartItem(mods.railcraft.api.core.items.IMinecartItem) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) EntityMinecart(net.minecraft.entity.item.EntityMinecart)

Example 45 with EntityMinecart

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

the class TileFluidLoader method getCart.

@Nullable
@Override
public EntityMinecart getCart() {
    needsPipe = false;
    EntityMinecart cart = super.getCart();
    if (cart == null) {
        cart = CartToolsAPI.getMinecartOnSide(worldObj, getPos().down(), 0.2f, EnumFacing.DOWN);
        needsPipe = true;
    }
    return cart;
}
Also used : EntityMinecart(net.minecraft.entity.item.EntityMinecart) Nullable(javax.annotation.Nullable)

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