Search in sources :

Example 11 with EnumPipePart

use of buildcraft.api.core.EnumPipePart in project BuildCraft by BuildCraft.

the class GuiElementStatementDrag method drawForeground.

@Override
public void drawForeground(float partialTicks) {
    if (isDragging) {
        boolean canPlace = false;
        for (IGuiElement element : gui.getElementsAt(gui.mouse.getX(), gui.mouse.getY())) {
            if (element instanceof IReference<?>) {
                if (checkCanSet((IReference<?>) element, dragging)) {
                    canPlace = true;
                    break;
                }
            }
        }
        GlStateManager.clear(GL11.GL_DEPTH_BUFFER_BIT);
        if (!canPlace) {
            GlStateManager.color(1.0f, 0.7f, 0.7f);
        }
        double x = gui.mouse.getX() - 9;
        double y = gui.mouse.getY() - 9;
        if (dragging instanceof IStatementParameter) {
            ParameterRenderer.draw((IStatementParameter) dragging, x, y);
        } else {
            GuiIcon background = GuiElementStatement.SLOT_COLOUR;
            if (dragging instanceof StatementWrapper) {
                EnumPipePart part = ((StatementWrapper) dragging).sourcePart;
                if (part != EnumPipePart.CENTER) {
                    background = background.offset(0, (1 + part.getIndex()) * 18);
                }
            }
            background.drawAt(x, y);
            if (dragging != null) {
                ISprite sprite = dragging.getSprite();
                if (sprite != null) {
                    GuiIcon.drawAt(sprite, x + 1, y + 1, 16);
                }
            }
        }
        GlStateManager.color(1, 1, 1);
    }
}
Also used : StatementWrapper(buildcraft.lib.statement.StatementWrapper) ISprite(buildcraft.api.core.render.ISprite) EnumPipePart(buildcraft.api.core.EnumPipePart) IGuiElement(buildcraft.lib.gui.IGuiElement) IStatementParameter(buildcraft.api.statements.IStatementParameter) IReference(buildcraft.lib.misc.data.IReference) GuiIcon(buildcraft.lib.gui.GuiIcon)

Example 12 with EnumPipePart

use of buildcraft.api.core.EnumPipePart in project BuildCraft by BuildCraft.

the class GuiElementStatementSource method drawGuiSlot.

public static void drawGuiSlot(@Nullable IGuiSlot guiSlot, double x, double y) {
    if (guiSlot instanceof IStatementParameter) {
        ParameterRenderer.draw((IStatementParameter) guiSlot, x, y);
        return;
    }
    GuiIcon background = GuiElementStatement.SLOT_COLOUR;
    if (guiSlot instanceof StatementWrapper) {
        EnumPipePart part = ((StatementWrapper) guiSlot).sourcePart;
        if (part != EnumPipePart.CENTER) {
            background = background.offset(0, (1 + part.getIndex()) * 18);
        }
    }
    background.drawAt(x, y);
    if (guiSlot != null) {
        ISprite sprite = guiSlot.getSprite();
        if (sprite != null) {
            GuiIcon.drawAt(sprite, x + 1, y + 1, 16);
        }
    }
}
Also used : StatementWrapper(buildcraft.lib.statement.StatementWrapper) ISprite(buildcraft.api.core.render.ISprite) EnumPipePart(buildcraft.api.core.EnumPipePart) IStatementParameter(buildcraft.api.statements.IStatementParameter) GuiIcon(buildcraft.lib.gui.GuiIcon)

Example 13 with EnumPipePart

use of buildcraft.api.core.EnumPipePart in project BuildCraft by BuildCraft.

the class ItemRenderUtil method renderItemStack.

/**
 * Used to render a lot of items in sequential order. Assumes that you don't change the glstate inbetween calls.
 * You must call {@link #endItemBatch()} after your have rendered all of the items.
 */
public static void renderItemStack(double x, double y, double z, ItemStack stack, int lightc, EnumFacing dir, BufferBuilder bb) {
    if (stack.isEmpty()) {
        return;
    }
    if (dir == null) {
        dir = EnumFacing.EAST;
    }
    dir = BCLibConfig.rotateTravelingItems.changeFacing(dir);
    IBakedModel model = Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getItemModel(stack);
    model = model.getOverrides().handleItemState(model, stack, null, null);
    boolean requireGl = stack.hasEffect() || model.isBuiltInRenderer();
    if (bb != null && !requireGl) {
        bb.setTranslation(x, y, z);
        float scale = 0.30f;
        MutableQuad q = new MutableQuad(-1, null);
        for (EnumPipePart part : EnumPipePart.VALUES) {
            for (BakedQuad quad : model.getQuads(null, part.face, 0)) {
                q.fromBakedItem(quad);
                q.translated(-0.5, -0.5, -0.5);
                q.scaled(scale);
                q.rotate(EnumFacing.SOUTH, dir, 0, 0, 0);
                if (quad.hasTintIndex()) {
                    int colour = Minecraft.getMinecraft().getItemColors().colorMultiplier(stack, quad.getTintIndex());
                    if (EntityRenderer.anaglyphEnable) {
                        colour = TextureUtil.anaglyphColor(colour);
                    }
                    q.multColouri(colour, colour >> 8, colour >> 16, 0xFF);
                }
                q.lighti(lightc);
                Vector3f normal = q.getCalculatedNormal();
                q.normalvf(normal);
                q.multShade();
                q.render(bb);
            }
        }
        bb.setTranslation(0, 0, 0);
        return;
    }
    if (!inBatch) {
        inBatch = true;
        Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
        GL11.glPushMatrix();
        GL11.glTranslated(x, y, z);
        GL11.glScaled(0.3, 0.3, 0.3);
        RenderHelper.disableStandardItemLighting();
    }
    OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightc % (float) 0x1_00_00, lightc / (float) 0x1_00_00);
    Minecraft.getMinecraft().getRenderItem().renderItem(stack, model);
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) Vector3f(javax.vecmath.Vector3f) EnumPipePart(buildcraft.api.core.EnumPipePart) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) MutableQuad(buildcraft.lib.client.model.MutableQuad)

Example 14 with EnumPipePart

use of buildcraft.api.core.EnumPipePart in project BuildCraft by BuildCraft.

the class ContainerGate method refresh.

private static <T extends StatementWrapper> void refresh(SortedSet<T> from, GateContext<T> to) {
    to.groups.clear();
    Map<EnumPipePart, List<T>> parts = new EnumMap<>(EnumPipePart.class);
    for (T val : from) {
        parts.computeIfAbsent(val.sourcePart, p -> new ArrayList<>()).add(val);
    }
    List<T> list = parts.get(EnumPipePart.CENTER);
    if (list == null) {
        list = new ArrayList<>(1);
        list.add(null);
    } else {
        list.add(0, null);
    }
    to.groups.add(new GateGroup<>(EnumPipePart.CENTER, list));
    for (EnumPipePart part : EnumPipePart.FACES) {
        list = parts.get(part);
        if (list != null) {
            to.groups.add(new GateGroup<>(part, list));
        }
    }
}
Also used : PacketBufferBC(buildcraft.lib.net.PacketBufferBC) SortedSet(java.util.SortedSet) TriggerWrapper(buildcraft.transport.gate.TriggerWrapper) EnumMap(java.util.EnumMap) IdAllocator(buildcraft.lib.misc.data.IdAllocator) ContainerBC_Neptune(buildcraft.lib.gui.ContainerBC_Neptune) StatementWrapper(buildcraft.lib.statement.StatementWrapper) IOException(java.io.IOException) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) GateGroup(buildcraft.transport.gate.GateContext.GateGroup) List(java.util.List) MessageContext(net.minecraftforge.fml.common.network.simpleimpl.MessageContext) StatementManager(buildcraft.api.statements.StatementManager) Side(net.minecraftforge.fml.relauncher.Side) ActionWrapper(buildcraft.transport.gate.ActionWrapper) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Map(java.util.Map) GateContext(buildcraft.transport.gate.GateContext) GateLogic(buildcraft.transport.gate.GateLogic) EnumPipePart(buildcraft.api.core.EnumPipePart) EnumPipePart(buildcraft.api.core.EnumPipePart) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) EnumMap(java.util.EnumMap)

Example 15 with EnumPipePart

use of buildcraft.api.core.EnumPipePart in project BuildCraft by BuildCraft.

the class TriggerWrapper method getPossible.

@Override
public TriggerWrapper[] getPossible() {
    IStatement[] possible = delegate.getPossible();
    boolean andSides = sourcePart != EnumPipePart.CENTER;
    TriggerWrapper[] real = new TriggerWrapper[possible.length + (andSides ? 5 : 0)];
    for (int i = 0; i < possible.length; i++) {
        real[i] = wrap(possible[i], sourcePart.face);
    }
    if (andSides) {
        EnumPipePart part = sourcePart;
        for (int j = 0; j < 5; j++) {
            int i = j + possible.length;
            part = part.next();
            real[i] = wrap(delegate, part.face);
        }
    }
    return real;
}
Also used : EnumPipePart(buildcraft.api.core.EnumPipePart) IStatement(buildcraft.api.statements.IStatement) ITriggerExternalOverride(buildcraft.api.statements.ITriggerExternalOverride)

Aggregations

EnumPipePart (buildcraft.api.core.EnumPipePart)24 IStatement (buildcraft.api.statements.IStatement)6 PacketBufferBC (buildcraft.lib.net.PacketBufferBC)3 StatementWrapper (buildcraft.lib.statement.StatementWrapper)3 ArrayList (java.util.ArrayList)3 InvalidInputDataException (buildcraft.api.core.InvalidInputDataException)2 ISprite (buildcraft.api.core.render.ISprite)2 IAction (buildcraft.api.statements.IAction)2 IStatementParameter (buildcraft.api.statements.IStatementParameter)2 ITrigger (buildcraft.api.statements.ITrigger)2 GuiIcon (buildcraft.lib.gui.GuiIcon)2 FluidStack (net.minecraftforge.fluids.FluidStack)2 ITriggerExternalOverride (buildcraft.api.statements.ITriggerExternalOverride)1 StatementManager (buildcraft.api.statements.StatementManager)1 EnumWirePart (buildcraft.api.transport.EnumWirePart)1 IItemPluggable (buildcraft.api.transport.IItemPluggable)1 IStripesHandler (buildcraft.api.transport.IStripesHandler)1 WireNode (buildcraft.api.transport.WireNode)1 PipeEventFluid (buildcraft.api.transport.pipe.PipeEventFluid)1 OnMoveToCentre (buildcraft.api.transport.pipe.PipeEventFluid.OnMoveToCentre)1