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;
}
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);
}
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);
}
}
}
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;
}
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;
}
Aggregations