use of net.minecraft.util.EnumHand in project SpongeCommon by SpongePowered.
the class UseItemPacketState method unwind.
@Override
public void unwind(BasicPacketContext context) {
final EntityPlayerMP player = context.getPacketPlayer();
final ItemStack itemStack = context.getItemUsed();
final ItemStackSnapshot snapshot = ItemStackUtil.snapshotOf(itemStack);
try (CauseStackManager.StackFrame frame = Sponge.getCauseStackManager().pushCauseFrame()) {
Sponge.getCauseStackManager().pushCause(player);
Sponge.getCauseStackManager().pushCause(snapshot);
Sponge.getCauseStackManager().addContext(EventContextKeys.SPAWN_TYPE, itemStack.getType() == ItemTypes.SPAWN_EGG ? InternalSpawnTypes.SPAWN_EGG : InternalSpawnTypes.PLACEMENT);
context.getCapturedEntitySupplier().acceptAndClearIfNotEmpty(entities -> {
final SpawnEntityEvent spawnEntityEvent = SpongeEventFactory.createSpawnEntityEvent(Sponge.getCauseStackManager().getCurrentCause(), entities);
SpongeImpl.postEvent(spawnEntityEvent);
if (!spawnEntityEvent.isCancelled()) {
processSpawnedEntities(player, spawnEntityEvent);
}
});
}
context.getCapturedBlockSupplier().acceptAndClearIfNotEmpty(originalBlocks -> {
boolean success = TrackingUtil.processBlockCaptures(originalBlocks, this, context);
if (!success && snapshot != ItemTypeRegistryModule.NONE_SNAPSHOT) {
Sponge.getCauseStackManager().pushCause(player);
EnumHand hand = ((CPacketPlayerTryUseItem) context.getPacket()).getHand();
PacketPhaseUtil.handlePlayerSlotRestore(player, (net.minecraft.item.ItemStack) itemStack, hand);
}
});
}
use of net.minecraft.util.EnumHand in project Charset by CharsetMC.
the class CharsetMiscScaffold method onBlockRightClick.
@SubscribeEvent
public void onBlockRightClick(PlayerInteractEvent.RightClickBlock event) {
EnumHand hand = event.getHand();
EnumFacing facing = event.getFace();
EntityPlayer playerIn = event.getEntityPlayer();
if (hand != EnumHand.MAIN_HAND)
return;
if (facing == null || facing.getAxis() == EnumFacing.Axis.Y)
return;
if (playerIn.isSneaking())
return;
World worldIn = event.getWorld();
BlockPos pos = event.getPos();
ItemStack stack = playerIn.getHeldItem(hand);
ItemStack oldStack = stack.copy();
if (!stack.isEmpty() && stack.getItem() instanceof ItemScaffold) {
if (worldIn.getBlockState(pos).getBlock() instanceof BlockScaffold) {
event.setCanceled(true);
for (int overhang = 1; overhang < BlockScaffold.MAX_OVERHANG; overhang++) {
BlockPos targetPos = new BlockPos(pos.getX(), pos.getY() + overhang, pos.getZ());
if (worldIn.isValid(targetPos) && stack.getItem().onItemUse(playerIn, worldIn, targetPos, hand, EnumFacing.DOWN, 0.5f, 0.0f, 0.5f) == EnumActionResult.SUCCESS) {
if (playerIn.isCreative()) {
playerIn.setHeldItem(hand, oldStack);
}
return;
}
if (worldIn.isAirBlock(targetPos)) {
return;
}
}
}
}
}
use of net.minecraft.util.EnumHand in project ImmersiveEngineering by BluSunrize.
the class ClientEventHandler method onRenderWorldLastEvent.
@SubscribeEvent
public void onRenderWorldLastEvent(RenderWorldLastEvent event) {
EntityPlayer player = ClientUtils.mc().player;
// Overlay renderer for the sample drill
int[] chunkBorders = null;
if (sampleDrill.isEmpty())
sampleDrill = new ItemStack(IEContent.blockMetalDevice1, 1, BlockTypes_MetalDevice1.SAMPLE_DRILL.getMeta());
if (coreSample.isEmpty())
coreSample = new ItemStack(IEContent.itemCoresample);
for (EnumHand hand : EnumHand.values()) {
ItemStack heldItem = player.getHeldItem(hand);
if (OreDictionary.itemMatches(sampleDrill, heldItem, true)) {
chunkBorders = new int[] { (int) player.posX >> 4 << 4, (int) player.posZ >> 4 << 4 };
break;
} else if (OreDictionary.itemMatches(coreSample, heldItem, true) && ItemNBTHelper.hasKey(heldItem, "coords")) {
int[] coords = ItemNBTHelper.getIntArray(heldItem, "coords");
if (coords[0] == player.getEntityWorld().provider.getDimension()) {
chunkBorders = new int[] { coords[1] << 4, coords[2] << 4 };
break;
}
}
}
if (chunkBorders == null && ClientUtils.mc().objectMouseOver != null && ClientUtils.mc().objectMouseOver.typeOfHit == Type.BLOCK && ClientUtils.mc().world.getTileEntity(ClientUtils.mc().objectMouseOver.getBlockPos()) instanceof TileEntitySampleDrill)
chunkBorders = new int[] { (int) player.posX >> 4 << 4, (int) player.posZ >> 4 << 4 };
float partial = event.getPartialTicks();
if (!ParticleFractal.PARTICLE_FRACTAL_DEQUE.isEmpty()) {
double px = TileEntityRendererDispatcher.staticPlayerX;
double py = TileEntityRendererDispatcher.staticPlayerY;
double pz = TileEntityRendererDispatcher.staticPlayerZ;
Tessellator tessellator = Tessellator.getInstance();
GlStateManager.disableTexture2D();
GlStateManager.enableBlend();
GlStateManager.disableCull();
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
GlStateManager.shadeModel(GL11.GL_SMOOTH);
tessellator.getBuffer().setTranslation(-px, -py, -pz);
ParticleFractal part;
while ((part = ParticleFractal.PARTICLE_FRACTAL_DEQUE.pollFirst()) != null) part.render(tessellator, tessellator.getBuffer(), partial);
tessellator.getBuffer().setTranslation(0, 0, 0);
GlStateManager.shadeModel(GL11.GL_FLAT);
GlStateManager.enableCull();
GlStateManager.disableBlend();
GlStateManager.enableTexture2D();
}
if (chunkBorders != null) {
renderChunkBorders(player, chunkBorders[0], chunkBorders[1]);
}
if (!FAILED_CONNECTIONS.isEmpty()) {
Entity viewer = ClientUtils.mc().getRenderViewEntity();
if (viewer == null)
viewer = player;
double dx = viewer.lastTickPosX + (viewer.posX - viewer.lastTickPosX) * partial;
double dy = viewer.lastTickPosY + (viewer.posY - viewer.lastTickPosY) * partial;
double dz = viewer.lastTickPosZ + (viewer.posZ - viewer.lastTickPosZ) * partial;
Tessellator tes = Tessellator.getInstance();
BufferBuilder bb = tes.getBuffer();
float oldLineWidth = GL11.glGetFloat(GL11.GL_LINE_WIDTH);
GlStateManager.glLineWidth(5);
GlStateManager.disableTexture2D();
GlStateManager.enableBlend();
bb.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_COLOR);
for (Entry<Connection, Pair<BlockPos, AtomicInteger>> entry : FAILED_CONNECTIONS.entrySet()) {
Connection conn = entry.getKey();
bb.setTranslation(conn.start.getX() - dx, conn.start.getY() - dy, conn.start.getZ() - dz);
Vec3d[] points = conn.getSubVertices(ClientUtils.mc().world);
int time = entry.getValue().getValue().get();
float alpha = (float) Math.min((2 + Math.sin(time * Math.PI / 40)) / 3, time / 20F);
for (int i = 0; i < points.length - 1; i++) {
bb.pos(points[i].x, points[i].y, points[i].z).color(1, 0, 0, alpha).endVertex();
alpha = (float) Math.min((2 + Math.sin((time + (i + 1) * 8) * Math.PI / 40)) / 3, time / 20F);
bb.pos(points[i + 1].x, points[i + 1].y, points[i + 1].z).color(1, 0, 0, alpha).endVertex();
}
}
bb.setTranslation(0, 0, 0);
tes.draw();
GlStateManager.glLineWidth(oldLineWidth);
GlStateManager.enableBlend();
GlStateManager.color(1, 0, 0, .5F);
renderObstructingBlocks(bb, tes, dx, dy, dz);
// Code to render the obstructing block through other blocks
// GlStateManager.color(1, 0, 0, .25F);
// GlStateManager.depthFunc(GL11.GL_GREATER);
// renderObstructingBlocks(bb, tes, dx, dy, dz);
// GlStateManager.depthFunc(GL11.GL_LEQUAL);
GlStateManager.disableBlend();
GlStateManager.enableTexture2D();
}
}
use of net.minecraft.util.EnumHand in project ImmersiveEngineering by BluSunrize.
the class ClientEventHandler method onRenderOverlayPost.
@SubscribeEvent()
public void onRenderOverlayPost(RenderGameOverlayEvent.Post event) {
if (ClientUtils.mc().player != null && event.getType() == RenderGameOverlayEvent.ElementType.TEXT) {
EntityPlayer player = ClientUtils.mc().player;
for (EnumHand hand : EnumHand.values()) if (!player.getHeldItem(hand).isEmpty()) {
ItemStack equipped = player.getHeldItem(hand);
if (OreDictionary.itemMatches(new ItemStack(IEContent.itemTool, 1, 2), equipped, false) || equipped.getItem() instanceof IWireCoil) {
if (ItemNBTHelper.hasKey(equipped, "linkingPos")) {
int[] link = ItemNBTHelper.getIntArray(equipped, "linkingPos");
if (link != null && link.length > 3) {
String s = I18n.format(Lib.DESC_INFO + "attachedTo", link[1], link[2], link[3]);
int col = WireType.ELECTRUM.getColour(null);
if (equipped.getItem() instanceof IWireCoil) {
RayTraceResult rtr = ClientUtils.mc().objectMouseOver;
double d = rtr != null && rtr.getBlockPos() != null ? rtr.getBlockPos().distanceSq(link[1], link[2], link[3]) : player.getDistanceSq(link[1], link[2], link[3]);
int max = ((IWireCoil) equipped.getItem()).getWireType(equipped).getMaxLength();
if (d > max * max)
col = 0xdd3333;
}
ClientUtils.font().drawString(s, event.getResolution().getScaledWidth() / 2 - ClientUtils.font().getStringWidth(s) / 2, event.getResolution().getScaledHeight() - GuiIngameForge.left_height - 20, col, true);
}
}
} else if (OreDictionary.itemMatches(equipped, new ItemStack(IEContent.itemFluorescentTube), false)) {
String s = I18n.format("desc.immersiveengineering.info.colour", "#" + ItemFluorescentTube.hexColorString(equipped));
ClientUtils.font().drawString(s, event.getResolution().getScaledWidth() / 2 - ClientUtils.font().getStringWidth(s) / 2, event.getResolution().getScaledHeight() - GuiIngameForge.left_height - 20, ItemFluorescentTube.getRGBInt(equipped, 1), true);
} else if (equipped.getItem() instanceof ItemRevolver || equipped.getItem() instanceof ItemSpeedloader) {
NonNullList<ItemStack> bullets = ((IBulletContainer) equipped.getItem()).getBullets(equipped, true);
if (bullets != null) {
int bulletAmount = ((IBulletContainer) equipped.getItem()).getBulletCount(equipped);
EnumHandSide side = hand == EnumHand.MAIN_HAND ? player.getPrimaryHand() : player.getPrimaryHand().opposite();
boolean right = side == EnumHandSide.RIGHT;
float dx = right ? event.getResolution().getScaledWidth() - 32 - 48 : 48;
float dy = event.getResolution().getScaledHeight() - 64;
GlStateManager.pushMatrix();
GlStateManager.enableRescaleNormal();
GlStateManager.enableBlend();
GlStateManager.translate(dx, dy, 0);
GlStateManager.scale(.5f, .5f, 1);
GuiRevolver.drawExternalGUI(bullets, bulletAmount);
if (equipped.getItem() instanceof ItemRevolver) {
int cd = ((ItemRevolver) equipped.getItem()).getShootCooldown(equipped);
float cdMax = ((ItemRevolver) equipped.getItem()).getMaxShootCooldown(equipped);
float cooldown = 1 - cd / cdMax;
if (cooldown > 0) {
GlStateManager.scale(2, 2, 1);
GlStateManager.translate(-dx, -dy, 0);
GlStateManager.translate(event.getResolution().getScaledWidth() / 2 + (right ? 1 : -6), event.getResolution().getScaledHeight() / 2 - 7, 0);
float h1 = cooldown > .33 ? .5f : cooldown * 1.5f;
float h2 = cooldown;
float x2 = cooldown < .75 ? 1 : 4 * (1 - cooldown);
float uMin = (88 + (right ? 0 : 7 * x2)) / 256f;
float uMax = (88 + (right ? 7 * x2 : 0)) / 256f;
float vMin1 = (112 + (right ? h1 : h2) * 15) / 256f;
float vMin2 = (112 + (right ? h2 : h1) * 15) / 256f;
ClientUtils.bindTexture("immersiveengineering:textures/gui/hud_elements.png");
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder worldrenderer = tessellator.getBuffer();
worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
worldrenderer.pos((right ? 0 : 1 - x2) * 7, 15, 0).tex(uMin, 127 / 256f).endVertex();
worldrenderer.pos((right ? x2 : 1) * 7, 15, 0).tex(uMax, 127 / 256f).endVertex();
worldrenderer.pos((right ? x2 : 1) * 7, (right ? h2 : h1) * 15, 0).tex(uMax, vMin2).endVertex();
worldrenderer.pos((right ? 0 : 1 - x2) * 7, (right ? h1 : h2) * 15, 0).tex(uMin, vMin1).endVertex();
tessellator.draw();
}
}
RenderHelper.disableStandardItemLighting();
GlStateManager.disableBlend();
GlStateManager.popMatrix();
}
} else if (equipped.getItem() instanceof ItemRailgun) {
int duration = 72000 - (player.isHandActive() && player.getActiveHand() == hand ? player.getItemInUseCount() : 0);
int chargeTime = ((ItemRailgun) equipped.getItem()).getChargeTime(equipped);
int chargeLevel = duration < 72000 ? Math.min(99, (int) (duration / (float) chargeTime * 100)) : 0;
float scale = 2f;
GlStateManager.pushMatrix();
GlStateManager.translate(event.getResolution().getScaledWidth() - 80, event.getResolution().getScaledHeight() - 30, 0);
GlStateManager.scale(scale, scale, 1);
ClientProxy.nixieFont.drawString((chargeLevel < 10 ? "0" : "") + chargeLevel, 0, 0, Lib.colour_nixieTubeText, false);
GlStateManager.scale(1 / scale, 1 / scale, 1);
GlStateManager.popMatrix();
} else if ((equipped.getItem() instanceof ItemDrill && equipped.getItemDamage() == 0) || equipped.getItem() instanceof ItemChemthrower) {
boolean drill = equipped.getItem() instanceof ItemDrill;
ClientUtils.bindTexture("immersiveengineering:textures/gui/hud_elements.png");
GlStateManager.color(1, 1, 1, 1);
float dx = event.getResolution().getScaledWidth() - 16;
float dy = event.getResolution().getScaledHeight();
GlStateManager.pushMatrix();
GlStateManager.translate(dx, dy, 0);
int w = 31;
int h = 62;
double uMin = 179 / 256f;
double uMax = 210 / 256f;
double vMin = 9 / 256f;
double vMax = 71 / 256f;
ClientUtils.drawTexturedRect(-24, -68, w, h, uMin, uMax, vMin, vMax);
GlStateManager.translate(-23, -37, 0);
IFluidHandler handler = FluidUtil.getFluidHandler(equipped);
int capacity = -1;
if (handler != null) {
IFluidTankProperties[] props = handler.getTankProperties();
if (props != null && props.length > 0)
capacity = props[0].getCapacity();
}
if (capacity > -1) {
FluidStack fuel = FluidUtil.getFluidContained(equipped);
int amount = fuel != null ? fuel.amount : 0;
if (!drill && player.isHandActive() && player.getActiveHand() == hand) {
int use = player.getItemInUseMaxCount();
amount -= use * IEConfig.Tools.chemthrower_consumption;
}
float cap = (float) capacity;
float angle = 83 - (166 * amount / cap);
GlStateManager.rotate(angle, 0, 0, 1);
ClientUtils.drawTexturedRect(6, -2, 24, 4, 91 / 256f, 123 / 256f, 80 / 256f, 87 / 256f);
GlStateManager.rotate(-angle, 0, 0, 1);
// for(int i=0; i<=8; i++)
// {
// float angle = 83-(166/8f)*i;
// GL11.glRotatef(angle, 0, 0, 1);
// ClientUtils.drawTexturedRect(6,-2, 24,4, 91/256f,123/256f, 80/96f,87/96f);
// GL11.glRotatef(-angle, 0, 0, 1);
// }
GlStateManager.translate(23, 37, 0);
if (drill) {
ClientUtils.drawTexturedRect(-54, -73, 66, 72, 108 / 256f, 174 / 256f, 4 / 256f, 76 / 256f);
RenderItem ir = ClientUtils.mc().getRenderItem();
ItemStack head = ((ItemDrill) equipped.getItem()).getHead(equipped);
if (!head.isEmpty()) {
ir.renderItemIntoGUI(head, -51, -45);
ir.renderItemOverlayIntoGUI(head.getItem().getFontRenderer(head), head, -51, -45, null);
RenderHelper.disableStandardItemLighting();
}
} else {
ClientUtils.drawTexturedRect(-41, -73, 53, 72, 8 / 256f, 61 / 256f, 4 / 256f, 76 / 256f);
boolean ignite = ItemNBTHelper.getBoolean(equipped, "ignite");
ClientUtils.drawTexturedRect(-32, -43, 12, 12, 66 / 256f, 78 / 256f, (ignite ? 21 : 9) / 256f, (ignite ? 33 : 21) / 256f);
ClientUtils.drawTexturedRect(-100, -20, 64, 16, 0 / 256f, 64 / 256f, 76 / 256f, 92 / 256f);
if (fuel != null) {
String name = ClientUtils.font().trimStringToWidth(fuel.getLocalizedName(), 50).trim();
ClientUtils.font().drawString(name, -68 - ClientUtils.font().getStringWidth(name) / 2, -15, 0);
}
}
}
GlStateManager.popMatrix();
} else if (equipped.getItem() instanceof ItemIEShield) {
NBTTagCompound upgrades = ((ItemIEShield) equipped.getItem()).getUpgrades(equipped);
if (!upgrades.isEmpty()) {
ClientUtils.bindTexture("immersiveengineering:textures/gui/hud_elements.png");
GlStateManager.color(1, 1, 1, 1);
boolean boundLeft = (player.getPrimaryHand() == EnumHandSide.RIGHT) == (hand == EnumHand.OFF_HAND);
float dx = boundLeft ? 16 : (event.getResolution().getScaledWidth() - 16 - 64);
float dy = event.getResolution().getScaledHeight();
GlStateManager.pushMatrix();
GlStateManager.enableBlend();
GlStateManager.translate(dx, dy, 0);
ClientUtils.drawTexturedRect(0, -22, 64, 22, 0, 64 / 256f, 176 / 256f, 198 / 256f);
if (upgrades.getBoolean("flash")) {
ClientUtils.drawTexturedRect(11, -38, 16, 16, 11 / 256f, 27 / 256f, 160 / 256f, 176 / 256f);
if (upgrades.hasKey("flash_cooldown")) {
float h = upgrades.getInteger("flash_cooldown") / 40f * 16;
ClientUtils.drawTexturedRect(11, -22 - h, 16, h, 11 / 256f, 27 / 256f, (214 - h) / 256f, 214 / 256f);
}
}
if (upgrades.getBoolean("shock")) {
ClientUtils.drawTexturedRect(40, -38, 12, 16, 40 / 256f, 52 / 256f, 160 / 256f, 176 / 256f);
if (upgrades.hasKey("shock_cooldown")) {
float h = upgrades.getInteger("shock_cooldown") / 40f * 16;
ClientUtils.drawTexturedRect(40, -22 - h, 12, h, 40 / 256f, 52 / 256f, (214 - h) / 256f, 214 / 256f);
}
}
GlStateManager.disableBlend();
GlStateManager.popMatrix();
}
}
// else if(equipped.getItem() instanceof ItemRailgun)
// {
// float dx = event.getResolution().getScaledWidth()-32-48;
// float dy = event.getResolution().getScaledHeight()-40;
// ClientUtils.bindTexture("immersiveengineering:textures/gui/hud_elements.png");
// GlStateManager.color(1, 1, 1, 1);
// GlStateManager.pushMatrix();
// GL11.glEnable(GL11.GL_BLEND);
// GlStateManager.translate(dx, dy, 0);
//
// int duration = player.getItemInUseDuration();
// int chargeTime = ((ItemRailgun)equipped.getItem()).getChargeTime(equipped);
// int chargeLevel = Math.min(99, (int)(duration/(float)chargeTime*100));
// // ClientUtils.drawTexturedRect(0,0, 64,32, 0/256f,64/256f, 96/256f,128/256f);
//
// GlStateManager.scale(1.5f,1.5f,1.5f);
// int col = Config.getBoolean("nixietubeFont")?Lib.colour_nixieTubeText:0xffffff;
// ClientProxy.nixieFont.setDrawTubeFlag(false);
// // ClientProxy.nixieFont.drawString((chargeLevel<10?"0"+chargeLevel:""+chargeLevel), 19,3, col);
// ClientProxy.nixieFont.setDrawTubeFlag(true);
//
// GlStateManager.popMatrix();
// }
RayTraceResult mop = ClientUtils.mc().objectMouseOver;
if (mop != null && mop.getBlockPos() != null) {
TileEntity tileEntity = player.world.getTileEntity(mop.getBlockPos());
if (OreDictionary.itemMatches(new ItemStack(IEContent.itemTool, 1, 2), equipped, true)) {
int col = IEConfig.nixietubeFont ? Lib.colour_nixieTubeText : 0xffffff;
String[] text = null;
if (tileEntity instanceof IFluxReceiver) {
int maxStorage = ((IFluxReceiver) tileEntity).getMaxEnergyStored(mop.sideHit);
int storage = ((IFluxReceiver) tileEntity).getEnergyStored(mop.sideHit);
if (maxStorage > 0)
text = I18n.format(Lib.DESC_INFO + "energyStored", "<br>" + Utils.toScientificNotation(storage, "0##", 100000) + " / " + Utils.toScientificNotation(maxStorage, "0##", 100000)).split("<br>");
} else // }
if (mop.entityHit instanceof IFluxReceiver) {
int maxStorage = ((IFluxReceiver) mop.entityHit).getMaxEnergyStored(null);
int storage = ((IFluxReceiver) mop.entityHit).getEnergyStored(null);
if (maxStorage > 0)
text = I18n.format(Lib.DESC_INFO + "energyStored", "<br>" + Utils.toScientificNotation(storage, "0##", 100000) + " / " + Utils.toScientificNotation(maxStorage, "0##", 100000)).split("<br>");
}
if (text != null) {
if (player.world.getTotalWorldTime() % 20 == 0) {
ImmersiveEngineering.packetHandler.sendToServer(new MessageRequestBlockUpdate(mop.getBlockPos()));
}
int i = 0;
for (String s : text) if (s != null) {
int w = ClientProxy.nixieFontOptional.getStringWidth(s);
ClientProxy.nixieFontOptional.drawString(s, event.getResolution().getScaledWidth() / 2 - w / 2, event.getResolution().getScaledHeight() / 2 - 4 - text.length * (ClientProxy.nixieFontOptional.FONT_HEIGHT + 2) + (i++) * (ClientProxy.nixieFontOptional.FONT_HEIGHT + 2), col, true);
}
}
}
}
}
if (ClientUtils.mc().objectMouseOver != null) {
boolean hammer = !player.getHeldItem(EnumHand.MAIN_HAND).isEmpty() && Utils.isHammer(player.getHeldItem(EnumHand.MAIN_HAND));
RayTraceResult mop = ClientUtils.mc().objectMouseOver;
if (mop != null && mop.getBlockPos() != null) {
TileEntity tileEntity = player.world.getTileEntity(mop.getBlockPos());
if (tileEntity instanceof IBlockOverlayText) {
IBlockOverlayText overlayBlock = (IBlockOverlayText) tileEntity;
String[] text = overlayBlock.getOverlayText(ClientUtils.mc().player, mop, hammer);
boolean useNixie = overlayBlock.useNixieFont(ClientUtils.mc().player, mop);
if (text != null && text.length > 0) {
FontRenderer font = useNixie ? ClientProxy.nixieFontOptional : ClientUtils.font();
int col = (useNixie && IEConfig.nixietubeFont) ? Lib.colour_nixieTubeText : 0xffffff;
int i = 0;
for (String s : text) if (s != null)
font.drawString(s, event.getResolution().getScaledWidth() / 2 + 8, event.getResolution().getScaledHeight() / 2 + 8 + (i++) * font.FONT_HEIGHT, col, true);
}
}
}
}
}
}
use of net.minecraft.util.EnumHand in project ImmersiveEngineering by BluSunrize.
the class ModelPowerpack method render.
@Override
public void render(Entity entity, float p_78088_2_, float p_78088_3_, float p_78088_4_, float p_78088_5_, float p_78088_6_, float scale) {
if (entity instanceof EntityLivingBase) {
ItemStack chest = ((EntityLivingBase) entity).getItemStackFromSlot(EntityEquipmentSlot.CHEST);
ItemStack powerpack = null;
float storage = 0;
if (!chest.isEmpty() && chest.getItem() instanceof ItemPowerpack)
powerpack = chest;
else if (!chest.isEmpty() && chest.getItem() instanceof ItemArmor && ItemNBTHelper.hasKey(chest, "IE:Powerpack"))
powerpack = ItemNBTHelper.getItemStack(chest, "IE:Powerpack");
else if (IEBipedLayerRenderer.POWERPACK_PLAYERS.containsKey(entity.getUniqueID()))
powerpack = IEBipedLayerRenderer.POWERPACK_PLAYERS.get(entity.getUniqueID()).getLeft();
if (powerpack != null) {
float max = EnergyHelper.getMaxEnergyStored(powerpack);
storage = max <= 0 ? 0 : EnergyHelper.getEnergyStored(powerpack) / max;
this.modelParts[7].rotateAngleZ = 0.5235987f - (1.047197f * storage);
}
}
GlStateManager.enableBlend();
super.render(entity, p_78088_2_, p_78088_3_, p_78088_4_, p_78088_5_, p_78088_6_, scale);
GlStateManager.disableBlend();
ClientUtils.bindTexture("immersiveengineering:textures/blocks/wire.png");
GlStateManager.pushMatrix();
if (entity instanceof EntityLivingBase)
for (EnumHand hand : EnumHand.values()) {
ItemStack stack = ((EntityLivingBase) entity).getHeldItem(hand);
if (!stack.isEmpty() && EnergyHelper.isFluxItem(stack)) {
boolean right = (hand == EnumHand.MAIN_HAND) == (((EntityLivingBase) entity).getPrimaryHand() == EnumHandSide.RIGHT);
float angleX = (right ? bipedRightArm : bipedLeftArm).rotateAngleX;
float angleZ = (right ? bipedRightArm : bipedLeftArm).rotateAngleZ;
String cacheKey = keyFormat.format(angleX) + "_" + keyFormat.format(angleZ);
Vec3d[] vex = new Vec3d[0];
try {
vex = (right ? catenaryCacheRight : catenaryCacheLeft).get(cacheKey, () -> {
double armLength = .75f;
double x = .3125 + (right ? 1 : -1) * armLength * Math.sin(angleZ);
double y = armLength * Math.cos(angleX);
double z = armLength * Math.sin(angleX);
return ApiUtils.getConnectionCatenary(new Vec3d(.484375, -.75, .25), new Vec3d(x, -y, z), 1.5);
});
} catch (Exception e) {
}
float vStep = 1f / vex.length;
int i = 0;
Tessellator tes = ClientUtils.tes();
BufferBuilder worldrenderer = tes.getBuffer();
// float[] colour = {.7f,.42f,.25f,1};
float[] colour = { .93f, .63f, .27f, 1 };
worldrenderer.begin(GL11.GL_QUAD_STRIP, DefaultVertexFormats.POSITION_TEX_COLOR);
for (Vec3d v : vex) {
worldrenderer.pos((right ? -v.x : v.x) - .015625, -v.y, v.z).tex(vStep * i, 0).color(colour[0], colour[1], colour[2], colour[3]).endVertex();
worldrenderer.pos((right ? -v.x : v.x) + .015625, -v.y, v.z).tex(vStep * i++, 1).color(colour[0], colour[1], colour[2], colour[3]).endVertex();
}
tes.draw();
worldrenderer.begin(GL11.GL_QUAD_STRIP, DefaultVertexFormats.POSITION_TEX_COLOR);
i = 0;
for (Vec3d v : vex) {
worldrenderer.pos((right ? -v.x : v.x), -v.y - .015625, v.z).tex(vStep * i, 0).color(colour[0], colour[1], colour[2], colour[3]).endVertex();
worldrenderer.pos((right ? -v.x : v.x), -v.y + .015625, v.z).tex(vStep * i++, 1).color(colour[0], colour[1], colour[2], colour[3]).endVertex();
}
tes.draw();
}
}
GlStateManager.popMatrix();
}
Aggregations