Search in sources :

Example 1 with NO_POWER

use of mods.railcraft.common.plugins.forge.PowerPlugin.NO_POWER in project Railcraft by Railcraft.

the class DetectorLocomotive method testCarts.

@Override
public int testCarts(List<EntityMinecart> carts) {
    for (EntityMinecart cart : carts) {
        if (cart instanceof EntityLocomotive) {
            EntityLocomotive loco = (EntityLocomotive) cart;
            ItemStack primary = getFilters().getStackInSlot(0);
            boolean matches = EnumColor.fromItemStack(primary).map(c -> c == loco.getPrimaryColor()).orElse(false);
            ItemStack secondary = getFilters().getStackInSlot(1);
            matches &= EnumColor.fromItemStack(secondary).map(c -> c == loco.getSecondaryColor()).orElse(false);
            if (matches)
                return FULL_POWER;
        }
    }
    return NO_POWER;
}
Also used : EnumGui(mods.railcraft.common.gui.EnumGui) ItemStack(net.minecraft.item.ItemStack) List(java.util.List) EnumDetector(mods.railcraft.common.blocks.detector.EnumDetector) NO_POWER(mods.railcraft.common.plugins.forge.PowerPlugin.NO_POWER) EntityLocomotive(mods.railcraft.common.carts.EntityLocomotive) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EnumColor(mods.railcraft.common.plugins.color.EnumColor) EntityMinecart(net.minecraft.entity.item.EntityMinecart) DetectorFilter(mods.railcraft.common.blocks.detector.DetectorFilter) FULL_POWER(mods.railcraft.common.plugins.forge.PowerPlugin.FULL_POWER) EntityLocomotive(mods.railcraft.common.carts.EntityLocomotive) ItemStack(net.minecraft.item.ItemStack) EntityMinecart(net.minecraft.entity.item.EntityMinecart)

Aggregations

List (java.util.List)1 DetectorFilter (mods.railcraft.common.blocks.detector.DetectorFilter)1 EnumDetector (mods.railcraft.common.blocks.detector.EnumDetector)1 EntityLocomotive (mods.railcraft.common.carts.EntityLocomotive)1 EnumGui (mods.railcraft.common.gui.EnumGui)1 EnumColor (mods.railcraft.common.plugins.color.EnumColor)1 FULL_POWER (mods.railcraft.common.plugins.forge.PowerPlugin.FULL_POWER)1 NO_POWER (mods.railcraft.common.plugins.forge.PowerPlugin.NO_POWER)1 EntityMinecart (net.minecraft.entity.item.EntityMinecart)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 ItemStack (net.minecraft.item.ItemStack)1