use of blusunrize.immersiveengineering.common.items.IEItemInterfaces.IBulletContainer in project ImmersiveEngineering by BluSunrize.
the class ClientEventHandler method onItemTooltip.
@SubscribeEvent
public void onItemTooltip(ItemTooltipEvent event) {
if (event.getItemStack() == null || event.getItemStack().isEmpty())
return;
if (event.getItemStack().hasCapability(CapabilityShader.SHADER_CAPABILITY, null)) {
ShaderWrapper wrapper = event.getItemStack().getCapability(CapabilityShader.SHADER_CAPABILITY, null);
ItemStack shader = wrapper != null ? wrapper.getShaderItem() : null;
if (!shader.isEmpty())
event.getToolTip().add(TextFormatting.DARK_GRAY + shader.getDisplayName());
}
if (ItemNBTHelper.hasKey(event.getItemStack(), Lib.NBT_Earmuffs)) {
ItemStack earmuffs = ItemNBTHelper.getItemStack(event.getItemStack(), Lib.NBT_Earmuffs);
if (!earmuffs.isEmpty())
event.getToolTip().add(TextFormatting.GRAY + earmuffs.getDisplayName());
}
if (ItemNBTHelper.hasKey(event.getItemStack(), Lib.NBT_Powerpack)) {
ItemStack powerpack = ItemNBTHelper.getItemStack(event.getItemStack(), Lib.NBT_Powerpack);
if (!powerpack.isEmpty()) {
event.getToolTip().add(TextFormatting.GRAY + powerpack.getDisplayName());
event.getToolTip().add(TextFormatting.GRAY.toString() + EnergyHelper.getEnergyStored(powerpack) + "/" + EnergyHelper.getMaxEnergyStored(powerpack) + " IF");
}
}
if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT && ClientUtils.mc().currentScreen != null && ClientUtils.mc().currentScreen instanceof GuiBlastFurnace && BlastFurnaceRecipe.isValidBlastFuel(event.getItemStack()))
event.getToolTip().add(TextFormatting.GRAY + I18n.format("desc.immersiveengineering.info.blastFuelTime", BlastFurnaceRecipe.getBlastFuelTime(event.getItemStack())));
if (IEConfig.oreTooltips && event.getFlags().isAdvanced()) {
for (int oid : OreDictionary.getOreIDs(event.getItemStack())) event.getToolTip().add(TextFormatting.GRAY + OreDictionary.getOreName(oid));
// FluidStack fs = FluidUtil.getFluidContained(event.getItemStack());
// if(fs!=null && fs.getFluid()!=null)
// event.getToolTip().add("Fluid: "+ FluidRegistry.getFluidName(fs));
}
if (event.getItemStack().getItem() instanceof IBulletContainer)
for (String s : BULLET_TOOLTIP) event.getToolTip().add(s);
}
use of blusunrize.immersiveengineering.common.items.IEItemInterfaces.IBulletContainer in project ImmersiveEngineering by BluSunrize.
the class ClientEventHandler method onRenderTooltip.
@SubscribeEvent()
public void onRenderTooltip(RenderTooltipEvent.PostText event) {
ItemStack stack = event.getStack();
if (stack.getItem() instanceof IBulletContainer) {
NonNullList<ItemStack> bullets = ((IBulletContainer) stack.getItem()).getBullets(stack, true);
if (bullets != null) {
int bulletAmount = ((IBulletContainer) stack.getItem()).getBulletCount(stack);
int line = event.getLines().size() - Utils.findSequenceInList(event.getLines(), BULLET_TOOLTIP, (s, s2) -> s.equals(s2.substring(2)));
int currentX = event.getX();
int currentY = line > 0 ? event.getY() + (event.getHeight() + 1 - line * 10) : event.getY() - 42;
GlStateManager.pushMatrix();
GlStateManager.enableBlend();
GlStateManager.enableRescaleNormal();
GlStateManager.translate(currentX, currentY, 700);
GlStateManager.scale(.5f, .5f, 1);
GuiRevolver.drawExternalGUI(bullets, bulletAmount);
GlStateManager.disableRescaleNormal();
GlStateManager.popMatrix();
}
}
}
use of blusunrize.immersiveengineering.common.items.IEItemInterfaces.IBulletContainer in project ImmersiveEngineering by BluSunrize.
the class ContainerRevolver method addSlots.
@Override
int addSlots() {
if (this.equipmentSlot == EntityEquipmentSlot.MAINHAND || this.equipmentSlot == EntityEquipmentSlot.OFFHAND) {
int bullets0 = ((IBulletContainer) (heldItem).getItem()).getBulletCount(heldItem);
this.secondHand = this.equipmentSlot == EntityEquipmentSlot.MAINHAND ? EntityEquipmentSlot.OFFHAND : EntityEquipmentSlot.MAINHAND;
this.secondRevolver = this.player.getItemStackFromSlot(this.secondHand);
if (!secondRevolver.isEmpty() && secondRevolver.getItem() instanceof IBulletContainer) {
int bullets1 = ((IBulletContainer) secondRevolver.getItem()).getBulletCount(secondRevolver);
this.offset = ((bullets0 >= 18 ? 150 : bullets0 > 8 ? 136 : 74) + (bullets1 >= 18 ? 150 : bullets1 > 8 ? 136 : 74) + 4 - 176) / 2;
} else {
this.secondRevolver = ItemStack.EMPTY;
this.secondHand = null;
this.offset = ((bullets0 >= 18 ? 150 : bullets0 > 8 ? 136 : 74) - 176) / 2;
}
}
int total = 0;
int off = (offset < 0 ? -offset : 0);
for (int hand = 0; hand < (this.secondHand != null ? 2 : 1); hand++) {
int i = 0;
ItemStack held = this.secondHand == null ? heldItem : (hand == 0) == (player.getPrimaryHand() == EnumHandSide.RIGHT) ? secondRevolver : heldItem;
IItemHandler secondRevolverInventory = secondRevolver.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
IItemHandler inv = this.secondHand == null ? this.inv : (hand == 0) == (player.getPrimaryHand() == EnumHandSide.RIGHT) ? secondRevolverInventory : this.inv;
int revolverSlots = ((IBulletContainer) (held).getItem()).getBulletCount(held);
if (inv instanceof IEItemStackHandler)
((IEItemStackHandler) inv).setInventoryForUpdate(this.inventoryPlayer);
this.addSlotToContainer(new IESlot.Bullet(inv, i++, off + 29, 3, 1));
int slots = revolverSlots >= 18 ? 2 : revolverSlots > 8 ? 1 : 0;
for (int[] slot : slotPositions[slots]) this.addSlotToContainer(new IESlot.Bullet(inv, i++, off + slot[0], slot[1], 1));
this.addSlotToContainer(new IESlot.Bullet(inv, i++, off + 48, 49, 1));
this.addSlotToContainer(new IESlot.Bullet(inv, i++, off + 29, 57, 1));
this.addSlotToContainer(new IESlot.Bullet(inv, i++, off + 10, 49, 1));
this.addSlotToContainer(new IESlot.Bullet(inv, i++, off + 2, 30, 1));
this.addSlotToContainer(new IESlot.Bullet(inv, i++, off + 10, 11, 1));
off += (revolverSlots >= 18 ? 150 : revolverSlots > 8 ? 136 : 74) + 4;
total += i;
}
this.bindPlayerInventory(this.inventoryPlayer);
return total;
}
Aggregations