Search in sources :

Example 11 with IoMode

use of crazypants.enderio.base.machine.modes.IoMode in project EnderIO by SleepyTrousers.

the class CapBankBlockRenderMapper method renderBody.

@Override
@SideOnly(Side.CLIENT)
protected List<IBlockState> renderBody(@Nonnull IBlockStateWrapper state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, BlockRenderLayer blockLayer, @Nonnull QuadCollector quadCollector) {
    List<IBlockState> states = new ArrayList<IBlockState>();
    TileEntity tileEntity = state.getTileEntity();
    if (tileEntity instanceof TileCapBank && state.getBlock() instanceof BlockCapBank) {
        NNList.FACING.apply(new Callback<EnumFacing>() {

            @Override
            public void apply(@Nonnull EnumFacing face) {
                IoMode ioMode = ((TileCapBank) tileEntity).getIoMode(face);
                InfoDisplayType displayType = ((TileCapBank) tileEntity).getDisplayType(face);
                EnumIOMode iOMode = ((BlockCapBank) state.getBlock()).mapIOMode(displayType, ioMode);
                states.add(ModObject.block_machine_io.getBlockNN().getDefaultState().withProperty(IOMode.IO, IOMode.get(face, iOMode)));
            }
        });
    } else {
        states.add(state.getState().withProperty(RENDER, EnumMergingBlockRenderMode.sides).withProperty(CapBankType.KIND, CapBankType.NONE));
    }
    return states;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileCapBank(crazypants.enderio.powertools.machine.capbank.TileCapBank) IBlockState(net.minecraft.block.state.IBlockState) BlockCapBank(crazypants.enderio.powertools.machine.capbank.BlockCapBank) EnumFacing(net.minecraft.util.EnumFacing) ArrayList(java.util.ArrayList) EnumIOMode(crazypants.enderio.base.render.property.IOMode.EnumIOMode) IoMode(crazypants.enderio.base.machine.modes.IoMode) InfoDisplayType(crazypants.enderio.powertools.machine.capbank.InfoDisplayType) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 12 with IoMode

use of crazypants.enderio.base.machine.modes.IoMode in project EnderIO by SleepyTrousers.

the class BlockCapBank method onBlockActivated.

@Override
public boolean onBlockActivated(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull IBlockState state, @Nonnull EntityPlayer entityPlayer, @Nonnull EnumHand hand, @Nonnull EnumFacing faceHit, float hitX, float hitY, float hitZ) {
    TileCapBank tcb = getTileEntity(world, pos);
    if (tcb == null) {
        return false;
    }
    if (entityPlayer.isSneaking() && Prep.isInvalid(entityPlayer.getHeldItem(hand)) && faceHit.getFrontOffsetY() == 0) {
        InfoDisplayType newDisplayType = tcb.getDisplayType(faceHit).next();
        if (newDisplayType == InfoDisplayType.NONE) {
            tcb.setDefaultIoMode(faceHit);
        } else {
            tcb.setIoMode(faceHit, IoMode.DISABLED);
        }
        tcb.setDisplayType(faceHit, newDisplayType);
        return true;
    }
    if (!entityPlayer.isSneaking() && ToolUtil.isToolEquipped(entityPlayer, hand)) {
        IoMode ioMode = tcb.getIoMode(faceHit);
        if (faceHit.getFrontOffsetY() == 0) {
            if (ioMode == IoMode.DISABLED) {
                InfoDisplayType newDisplayType = tcb.getDisplayType(faceHit).next();
                tcb.setDisplayType(faceHit, newDisplayType);
                if (newDisplayType == InfoDisplayType.NONE) {
                    tcb.toggleIoModeForFace(faceHit);
                }
            } else {
                tcb.toggleIoModeForFace(faceHit);
            }
        } else {
            tcb.toggleIoModeForFace(faceHit);
        }
        if (!world.isRemote) {
            world.notifyNeighborsOfStateChange(pos, this, true);
        }
        world.notifyBlockUpdate(pos, state, state, 3);
        return true;
    }
    return super.onBlockActivated(world, pos, state, entityPlayer, hand, faceHit, hitX, hitY, hitZ);
}
Also used : IoMode(crazypants.enderio.base.machine.modes.IoMode)

Example 13 with IoMode

use of crazypants.enderio.base.machine.modes.IoMode in project EnderIO by SleepyTrousers.

the class IoConfigRenderer method renderOverlay.

private void renderOverlay(int mx, int my) {
    Rectangle vp = camera.getViewport();
    ScaledResolution scaledresolution = new ScaledResolution(mc);
    int vpx = vp.x / scaledresolution.getScaleFactor();
    int vph = vp.height / scaledresolution.getScaleFactor();
    int vpw = vp.width / scaledresolution.getScaleFactor();
    int vpy = (int) ((float) (vp.y + vp.height - 4) / (float) scaledresolution.getScaleFactor());
    GL11.glViewport(0, 0, mc.displayWidth, mc.displayHeight);
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(0.0D, scaledresolution.getScaledWidth_double(), scaledresolution.getScaledHeight_double(), 0.0D, 1000.0D, 3000.0D);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    GL11.glTranslatef(vpx, vpy, -2000.0F);
    GlStateManager.disableLighting();
    int x = vpw - 17;
    int y = vph - 18;
    mx -= vpx;
    my -= vpy;
    if (mx >= x && mx <= x + IconEIO.IO_WHATSIT.width && my >= y && my <= y + IconEIO.IO_WHATSIT.height) {
        GlStateManager.enableBlend();
        RenderUtil.renderQuad2D(x, y, 0, IconEIO.IO_WHATSIT.width, IconEIO.IO_WHATSIT.height, new Vector4f(0.4f, 0.4f, 0.4f, 0.6f));
        GlStateManager.disableBlend();
        inNeigButBounds = true;
    } else {
        inNeigButBounds = false;
    }
    GL11.glColor3f(1, 1, 1);
    IconEIO.map.render(IconEIO.IO_WHATSIT, x, y, true);
    if (selection != null) {
        IconEIO ioIcon = null;
        int yOffset = 0;
        // INPUT
        IoMode mode = selection.config.getIoMode(selection.face);
        if (mode == IoMode.PULL) {
            ioIcon = IconEIO.INPUT;
        } else if (mode == IoMode.PUSH) {
            ioIcon = IconEIO.OUTPUT;
        } else if (mode == IoMode.PUSH_PULL) {
            ioIcon = IconEIO.INPUT_OUTPUT;
        } else if (mode == IoMode.DISABLED) {
            ioIcon = IconEIO.DISABLED;
            yOffset = 5;
        }
        y = vph - mc.fontRenderer.FONT_HEIGHT - 2;
        mc.fontRenderer.drawString(getLabelForMode(mode), 4, y, ColorUtil.getRGB(Color.white));
        if (ioIcon != null) {
            int w = mc.fontRenderer.getStringWidth(mode.getLocalisedName());
            double xd = (w - ioIcon.width) / 2;
            xd = Math.max(0, w);
            xd /= 2;
            xd += 4;
            xd /= scaledresolution.getScaleFactor();
            ioIcon.getMap().render(ioIcon, xd, y - mc.fontRenderer.FONT_HEIGHT - 2 - yOffset, true);
        }
    }
}
Also used : ScaledResolution(net.minecraft.client.gui.ScaledResolution) Vector4f(com.enderio.core.common.vecmath.Vector4f) Rectangle(java.awt.Rectangle) PacketIoMode(crazypants.enderio.base.machine.modes.PacketIoMode) IoMode(crazypants.enderio.base.machine.modes.IoMode)

Example 14 with IoMode

use of crazypants.enderio.base.machine.modes.IoMode in project EnderIO by SleepyTrousers.

the class MachineRenderMapper method renderIO.

@SideOnly(Side.CLIENT)
protected EnumMap<EnumFacing, EnumIOMode> renderIO(@Nonnull AbstractMachineEntity tileEntity, @Nonnull AbstractMachineBlock<?> block) {
    EnumMap<EnumFacing, EnumIOMode> result = new EnumMap<EnumFacing, EnumIOMode>(EnumFacing.class);
    for (EnumFacing face : EnumFacing.values()) {
        IoMode ioMode = tileEntity.getIoMode(face);
        if (ioMode != IoMode.NONE) {
            EnumIOMode iOMode = block.mapIOMode(ioMode, face);
            result.put(face, iOMode);
        }
    }
    return result.isEmpty() ? null : result;
}
Also used : EnumFacing(net.minecraft.util.EnumFacing) EnumIOMode(crazypants.enderio.base.render.property.IOMode.EnumIOMode) IoMode(crazypants.enderio.base.machine.modes.IoMode) EnumMap(java.util.EnumMap) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 15 with IoMode

use of crazypants.enderio.base.machine.modes.IoMode in project EnderIO by SleepyTrousers.

the class LegacyKillerJoeWrapper method getSlots.

@Override
public int getSlots() {
    int result = 0;
    final IoMode ioMode = machine.getIoMode(side);
    if (ioMode.canRecieveInput() || ioMode.canOutput()) {
        result += machine.getSlotDefinition().getNumInputSlots();
    }
    return result;
}
Also used : IoMode(crazypants.enderio.base.machine.modes.IoMode)

Aggregations

IoMode (crazypants.enderio.base.machine.modes.IoMode)16 EnumFacing (net.minecraft.util.EnumFacing)8 EnumIOMode (crazypants.enderio.base.render.property.IOMode.EnumIOMode)4 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)4 EnumMap (java.util.EnumMap)3 Nonnull (javax.annotation.Nonnull)3 IPowerInterface (crazypants.enderio.base.power.IPowerInterface)2 Rectangle (java.awt.Rectangle)2 IBlockState (net.minecraft.block.state.IBlockState)2 IFluidWrapper (com.enderio.core.common.fluid.IFluidWrapper)1 Vector4f (com.enderio.core.common.vecmath.Vector4f)1 IConduitBundle (crazypants.enderio.base.conduit.IConduitBundle)1 SlotDefinition (crazypants.enderio.base.machine.baselegacy.SlotDefinition)1 PacketIoMode (crazypants.enderio.base.machine.modes.PacketIoMode)1 BlockCapBank (crazypants.enderio.powertools.machine.capbank.BlockCapBank)1 InfoDisplayType (crazypants.enderio.powertools.machine.capbank.InfoDisplayType)1 TileCapBank (crazypants.enderio.powertools.machine.capbank.TileCapBank)1 EnergyReceptor (crazypants.enderio.powertools.machine.capbank.network.EnergyReceptor)1 ArrayList (java.util.ArrayList)1 Entry (java.util.Map.Entry)1