Search in sources :

Example 1 with LensPluggable

use of buildcraft.transport.pluggable.LensPluggable in project BuildCraft by BuildCraft.

the class LensPluggableModel method create.

public static PerspAwareModelBase create(ItemLens lensItem, int meta) {
    LensPluggable lens = new LensPluggable(new ItemStack(lensItem, 1, meta));
    ImmutableList.Builder<BakedQuad> quads = ImmutableList.builder();
    VertexFormat format = DefaultVertexFormats.ITEM;
    quads.addAll(INSTANCE.bakeCutout(lens.isFilter, EnumFacing.EAST, format));
    quads.addAll(INSTANCE.bakeTransclucent(lens.dyeColor, lens.isFilter, EnumFacing.EAST, format));
    return new PerspAwareModelBase(format, quads.build(), spriteLensCutout, getBlockTransforms());
}
Also used : LensPluggable(buildcraft.transport.pluggable.LensPluggable) BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) ImmutableList(com.google.common.collect.ImmutableList) PerspAwareModelBase(buildcraft.core.lib.client.model.PerspAwareModelBase) ItemStack(net.minecraft.item.ItemStack) VertexFormat(net.minecraft.client.renderer.vertex.VertexFormat)

Example 2 with LensPluggable

use of buildcraft.transport.pluggable.LensPluggable in project BuildCraft by BuildCraft.

the class LensFilterHandler method eventHandler.

@PipeEventPriority(priority = -100)
public void eventHandler(PipeEventItem.FindDest event) {
    IPipeTile container = event.pipe.getTile();
    List<EnumSet<EnumFacing>> newDestinations = new ArrayList<>(event.destinations.size() * 2);
    for (EnumSet<EnumFacing> dirs : event.destinations) {
        EnumSet<EnumFacing> correctColored = EnumSet.noneOf(EnumFacing.class);
        EnumSet<EnumFacing> notColored = EnumSet.noneOf(EnumFacing.class);
        EnumDyeColor myColor = event.item.color;
        for (EnumFacing dir : dirs) {
            boolean hasFilter = false;
            boolean hasLens = false;
            EnumDyeColor sideColor = null;
            EnumDyeColor sideLensColor = null;
            // Get the side's color
            // (1/2) From this pipe's outpost
            PipePluggable pluggable = container.getPipePluggable(dir);
            if (pluggable != null && pluggable instanceof LensPluggable) {
                if (((LensPluggable) pluggable).isFilter) {
                    hasFilter = true;
                    sideColor = ((LensPluggable) pluggable).dyeColor;
                } else {
                    hasLens = true;
                    sideLensColor = ((LensPluggable) pluggable).dyeColor;
                }
            }
            // (2/2) From the other pipe's outpost
            IPipe otherPipe = container.getNeighborPipe(dir);
            if (otherPipe != null && otherPipe.getTile() != null) {
                IPipeTile otherContainer = otherPipe.getTile();
                pluggable = otherContainer.getPipePluggable(dir.getOpposite());
                if (pluggable != null && pluggable instanceof LensPluggable && ((LensPluggable) pluggable).isFilter) {
                    EnumDyeColor otherColor = ((LensPluggable) pluggable).dyeColor;
                    if (hasFilter && otherColor != sideColor) {
                        // Filter colors conflict - the side is unpassable
                        continue;
                    } else if (hasLens) {
                        // treated as colorless
                        if (sideLensColor == otherColor) {
                            hasFilter = false;
                            sideColor = null;
                        } else {
                            continue;
                        }
                    } else {
                        hasFilter = true;
                        sideColor = otherColor;
                    }
                }
            }
            if (hasFilter) {
                if (myColor == sideColor) {
                    correctColored.add(dir);
                }
            } else {
                notColored.add(dir);
            }
        }
        if (!correctColored.isEmpty()) {
            newDestinations.add(correctColored);
        }
        if (!notColored.isEmpty()) {
            newDestinations.add(notColored);
        }
    }
    event.destinations.clear();
    event.destinations.addAll(newDestinations);
}
Also used : IPipeTile(buildcraft.api.transport.IPipeTile) LensPluggable(buildcraft.transport.pluggable.LensPluggable) EnumSet(java.util.EnumSet) EnumFacing(net.minecraft.util.EnumFacing) ArrayList(java.util.ArrayList) PipePluggable(buildcraft.api.transport.pluggable.PipePluggable) EnumDyeColor(net.minecraft.item.EnumDyeColor) IPipe(buildcraft.api.transport.IPipe) PipeEventPriority(buildcraft.transport.pipes.events.PipeEventPriority)

Aggregations

LensPluggable (buildcraft.transport.pluggable.LensPluggable)2 IPipe (buildcraft.api.transport.IPipe)1 IPipeTile (buildcraft.api.transport.IPipeTile)1 PipePluggable (buildcraft.api.transport.pluggable.PipePluggable)1 PerspAwareModelBase (buildcraft.core.lib.client.model.PerspAwareModelBase)1 PipeEventPriority (buildcraft.transport.pipes.events.PipeEventPriority)1 ImmutableList (com.google.common.collect.ImmutableList)1 ArrayList (java.util.ArrayList)1 EnumSet (java.util.EnumSet)1 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)1 VertexFormat (net.minecraft.client.renderer.vertex.VertexFormat)1 EnumDyeColor (net.minecraft.item.EnumDyeColor)1 ItemStack (net.minecraft.item.ItemStack)1 EnumFacing (net.minecraft.util.EnumFacing)1