use of crazypants.enderio.base.conduit.ConduitDisplayMode in project EnderIO by SleepyTrousers.
the class ToolTickHandler method changeDisplayMode.
private void changeDisplayMode(@Nonnull ItemStack stack, @Nonnull EntityPlayer player, int dWheel) {
if (!((IConduitControl) stack.getItem()).showOverlay(stack, player)) {
return;
}
ConduitDisplayMode mode = ConduitDisplayMode.getDisplayMode(stack);
mode = dWheel < 0 ? mode.next() : mode.previous();
ConduitDisplayMode.setDisplayMode(stack, mode);
PacketHandler.INSTANCE.sendToServer(new YetaWrenchPacketProcessor(player.inventory.currentItem, mode));
}
use of crazypants.enderio.base.conduit.ConduitDisplayMode in project EnderIO by SleepyTrousers.
the class YetaWrenchOverlayRenderer method doRenderOverlay.
private void doRenderOverlay(@Nonnull RenderGameOverlayEvent event, @Nonnull ItemStack equippedWrench) {
ConduitDisplayMode mode = ConduitDisplayMode.getDisplayMode(equippedWrench);
if (mode != cachedMode) {
cachedMode = mode;
displayTickCount = 20;
lastTick = ClientHandler.getTicksElapsed();
}
ScaledResolution res = event.getResolution();
int modeCount = ConduitDisplayMode.registrySize();
Iterable<ConduitDisplayMode> renderable = ConduitDisplayMode.getRenderableModes();
switch(PersonalConfig.yetaOverlayMode.get()) {
case 0:
if (displayTickCount > 0) {
if (lastTick < ClientHandler.getTicksElapsed()) {
lastTick++;
displayTickCount--;
}
int x = res.getScaledWidth() / 2 - 8;
int y = res.getScaledHeight() / 2 - 24;
IWidgetIcon widget = mode.getWidgetSelected();
RenderUtil.bindTexture(widget.getMap().getTexture());
widget.getMap().render(widget, x, y, true);
int size = 12;
widget = mode.previous().getWidgetSelected();
RenderUtil.bindTexture(widget.getMap().getTexture());
widget.getMap().render(widget, x - 18 + (16 - size), y + (16 - size), size, size, 0, true);
widget = mode.next().getWidgetSelected();
RenderUtil.bindTexture(widget.getMap().getTexture());
widget.getMap().render(widget, x + 18, y + (16 - size), size, size, 0, true);
} else {
int x = res.getScaledWidth() - 20;
int y = res.getScaledHeight() - 20;
IWidgetIcon widget = mode.getWidgetSelected();
RenderUtil.bindTexture(widget.getMap().getTexture());
widget.getMap().render(widget, x, y, true);
}
break;
case 1:
int size = 16;
int padding = 2;
int inset = (int) (size / 1.5);
int offsetX = res.getScaledWidth() - inset - 1;
int offsetY = res.getScaledHeight() - modeCount * (size + padding) - padding;
inset = size - inset;
int x = offsetX + 2;
int y = offsetY - (padding * 2);
int height = (modeCount * (size + padding)) + (padding * 3);
// FIXME
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glShadeModel(GL11.GL_SMOOTH);
VertexFormat vf = DefaultVertexFormats.POSITION_COLOR;
Tessellator tess = Tessellator.getInstance();
BufferBuilder wr = tess.getBuffer();
wr.begin(GL11.GL_QUADS, vf);
wr.pos(x, y, -5).color(0, 0, 0, 0.2f).endVertex();
;
wr.pos(x, y + height, -5).color(0, 0, 0, 0.2f).endVertex();
;
Vector4f color = new Vector4f(0, 0, 0, 1);
wr.pos(x + size, y + height, -5).color(color.x, color.y, color.z, color.w).endVertex();
wr.pos(x + size, y, -5).color(color.x, color.y, color.z, color.w).endVertex();
tess.draw();
GlStateManager.color(1, 1, 1);
GL11.glShadeModel(GL11.GL_FLAT);
y += padding * 2;
x -= 2;
if (mode == ConduitDisplayMode.ALL) {
x -= inset;
}
GL11.glEnable(GL11.GL_TEXTURE_2D);
for (ConduitDisplayMode toRender : renderable) {
IWidgetIcon widget = mode == ConduitDisplayMode.ALL ? toRender.getWidgetSelected() : toRender.getWidgetUnselected();
RenderUtil.bindTexture(widget.getMap().getTexture());
if (toRender == mode) {
widget = toRender.getWidgetSelected();
widget.getMap().render(widget, x - inset, y, true);
} else {
widget.getMap().render(widget, x, y, true);
}
y += size + padding;
}
break;
case 2:
offsetX = res.getScaledWidth() - (modeCount * 8) - 16;
y = res.getScaledHeight() - 40;
x = offsetX;
if (modeCount % 2 == 1) {
x += 8;
}
int count = 0;
for (ConduitDisplayMode toRender : renderable) {
IWidgetIcon widget = mode == ConduitDisplayMode.ALL || toRender == mode ? toRender.getWidgetSelected() : toRender.getWidgetUnselected();
RenderUtil.bindTexture(widget.getMap().getTexture());
widget.getMap().render(widget, x, y, true);
x += 16;
if (count == modeCount / 2 - 1) {
x = offsetX;
y += 16;
}
count++;
}
}
}
use of crazypants.enderio.base.conduit.ConduitDisplayMode in project EnderIO by SleepyTrousers.
the class ToolTickHandler method changeDisplayMode.
private static void changeDisplayMode(@Nonnull ItemStack stack, @Nonnull EntityPlayer player, int dWheel) {
if (!((IConduitControl) stack.getItem()).showOverlay(stack, player)) {
return;
}
ConduitDisplayMode mode = ConduitDisplayMode.getDisplayMode(stack);
mode = dWheel < 0 ? mode.next() : mode.previous();
ConduitDisplayMode.setDisplayMode(stack, mode);
PacketHandler.INSTANCE.sendToServer(new YetaWrenchPacketProcessor(player.inventory.currentItem, mode));
}
use of crazypants.enderio.base.conduit.ConduitDisplayMode in project EnderIO by SleepyTrousers.
the class ItemYetaWrench method onItemRightClick.
@Override
@Nonnull
public ActionResult<ItemStack> onItemRightClick(@Nonnull World world, @Nonnull EntityPlayer player, @Nonnull EnumHand hand) {
ItemStack equipped = player.getHeldItem(hand);
if (!PersonalConfig.yetaUseSneakRightClick.get() || !player.isSneaking()) {
return new ActionResult<ItemStack>(EnumActionResult.PASS, equipped);
}
ConduitDisplayMode curMode = ConduitDisplayMode.getDisplayMode(equipped);
ConduitDisplayMode newMode = curMode.next();
ConduitDisplayMode.setDisplayMode(equipped, newMode);
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, equipped);
}
use of crazypants.enderio.base.conduit.ConduitDisplayMode in project EnderIO by SleepyTrousers.
the class BlockConduitBundle method doRayTraceAll.
@Nonnull
protected NNList<RaytraceResult> doRayTraceAll(@Nonnull IBlockState bs, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull Vec3d origin, @Nonnull Vec3d direction, EntityPlayer player) {
TileEntity te = world.getTileEntity(pos);
if (!(te instanceof IConduitBundle)) {
return NNList.emptyList();
}
IConduitBundle bundle = (IConduitBundle) te;
NNList<RaytraceResult> hits = new NNList<RaytraceResult>();
if (YetaUtil.isSolidFacadeRendered(bundle, player)) {
setBlockBounds(0, 0, 0, 1, 1, 1);
RayTraceResult hitPos = super.collisionRayTrace(bs, world, pos, origin, direction);
if (hitPos != null) {
hits.add(new RaytraceResult(new CollidableComponent(null, BoundingBox.UNIT_CUBE, hitPos.sideHit, null), hitPos));
}
} else {
ConduitDisplayMode mode = YetaUtil.getDisplayMode(player);
for (CollidableComponent component : new ArrayList<CollidableComponent>(bundle.getCollidableComponents())) {
if (mode.isAll() || component.conduitType == null || YetaUtil.renderConduit(player, component.conduitType)) {
setBlockBounds(component.bound.minX, component.bound.minY, component.bound.minZ, component.bound.maxX, component.bound.maxY, component.bound.maxZ);
RayTraceResult hitPos = super.collisionRayTrace(bs, world, pos, origin, direction);
if (hitPos != null) {
hits.add(new RaytraceResult(component, hitPos));
}
}
}
// safety to prevent unbreakable empty bundles in case of a bug
if (bundle.getConduits().isEmpty() && !YetaUtil.isFacadeHidden(bundle, player)) {
setBlockBounds(0, 0, 0, 1, 1, 1);
RayTraceResult hitPos = super.collisionRayTrace(bs, world, pos, origin, direction);
if (hitPos != null) {
hits.add(new RaytraceResult(null, hitPos));
}
}
}
setBlockBounds(0, 0, 0, 1, 1, 1);
return hits;
}
Aggregations