Search in sources :

Example 1 with EntityMinecartCommandBlock

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

the class TrackKitDetector method getComparatorInputOverride.

@Override
public int getComparatorInputOverride() {
    if (isEmittingPower()) {
        World world = theWorldAsserted();
        List<EntityMinecart> carts = EntitySearcher.findMinecarts().around(getPos()).upTo(-0.2F).in(world);
        if (!carts.isEmpty() && carts.get(0).getComparatorLevel() > -1)
            return carts.get(0).getComparatorLevel();
        List<EntityMinecartCommandBlock> commandCarts = EntitySearcher.find(EntityMinecartCommandBlock.class).around(getPos()).upTo(-0.2F).in(world);
        if (!commandCarts.isEmpty()) {
            return commandCarts.get(0).getCommandBlockLogic().getSuccessCount();
        }
        List<EntityMinecart> chestCarts = EntitySearcher.findMinecarts().around(getPos()).upTo(-0.2F).and(EntitySelectors.HAS_INVENTORY).in(world);
        if (!chestCarts.isEmpty()) {
            return Container.calcRedstoneFromInventory((IInventory) chestCarts.get(0));
        }
    }
    return 0;
}
Also used : EntityMinecartCommandBlock(net.minecraft.entity.item.EntityMinecartCommandBlock) World(net.minecraft.world.World) EntityMinecart(net.minecraft.entity.item.EntityMinecart)

Aggregations

EntityMinecart (net.minecraft.entity.item.EntityMinecart)1 EntityMinecartCommandBlock (net.minecraft.entity.item.EntityMinecartCommandBlock)1 World (net.minecraft.world.World)1