Search in sources :

Example 1 with ItemMinecart

use of net.minecraft.item.ItemMinecart 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 2 with ItemMinecart

use of net.minecraft.item.ItemMinecart in project Railcraft by Railcraft.

the class TrackmanBackpack method setup.

public void setup() {
    for (ResourceLocation id : Block.REGISTRY.getKeys()) {
        Block block = Block.REGISTRY.getObject(id);
        if (block == null)
            continue;
        if (TrackTools.isRailBlock(block))
            add(block);
    }
    for (ResourceLocation id : Item.REGISTRY.getKeys()) {
        Item item = Item.REGISTRY.getObject(id);
        if (item instanceof ItemMinecart || item instanceof IMinecartItem)
            add(item);
    }
    add(IToolCrowbar.ORE_TAG);
    add(RailcraftBlocks.WORLDSPIKE);
    add(RailcraftBlocks.WORLDSPIKE_POINT);
    add(RailcraftItems.BOTTLE_CREOSOTE);
    add(RailcraftItems.SPIKE_MAUL_IRON);
    add(RailcraftItems.SPIKE_MAUL_STEEL);
    add(RailcraftItems.CHARGE_METER);
    add(RailcraftItems.RAIL);
    add(RailcraftItems.RAILBED);
    add(RailcraftItems.TICKET);
    add(RailcraftItems.TICKET_GOLD);
    add(RailcraftItems.TIE);
    add(RailcraftItems.WHISTLE_TUNER);
    add(RailcraftItems.OVERALLS);
    add(RailcraftItems.TRACK_KIT);
    add(RailcraftItems.TRACK_PARTS);
    add(RailcraftBlocks.CHARGE_FEEDER);
    add(RailcraftBlocks.MANIPULATOR);
    add(RailcraftBlocks.TRACK_ELEVATOR);
    add(RailcraftBlocks.WIRE);
}
Also used : Item(net.minecraft.item.Item) IMinecartItem(mods.railcraft.api.core.items.IMinecartItem) ResourceLocation(net.minecraft.util.ResourceLocation) ItemMinecart(net.minecraft.item.ItemMinecart) Block(net.minecraft.block.Block) IMinecartItem(mods.railcraft.api.core.items.IMinecartItem)

Aggregations

IMinecartItem (mods.railcraft.api.core.items.IMinecartItem)2 ItemMinecart (net.minecraft.item.ItemMinecart)2 Block (net.minecraft.block.Block)1 EntityMinecart (net.minecraft.entity.item.EntityMinecart)1 Item (net.minecraft.item.Item)1 ItemStack (net.minecraft.item.ItemStack)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 BlockPos (net.minecraft.util.math.BlockPos)1