Search in sources :

Example 1 with IBulletContainer

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);
}
Also used : IBulletContainer(blusunrize.immersiveengineering.common.items.IEItemInterfaces.IBulletContainer) GuiBlastFurnace(blusunrize.immersiveengineering.client.gui.GuiBlastFurnace) ShaderWrapper(blusunrize.immersiveengineering.api.shader.CapabilityShader.ShaderWrapper) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 2 with IBulletContainer

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();
        }
    }
}
Also used : ShaderWrapper(blusunrize.immersiveengineering.api.shader.CapabilityShader.ShaderWrapper) EnumHand(net.minecraft.util.EnumHand) FMLCommonHandler(net.minecraftforge.fml.common.FMLCommonHandler) TileEntityTurntable(blusunrize.immersiveengineering.common.blocks.wooden.TileEntityTurntable) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) I18n(net.minecraft.client.resources.I18n) IFluxReceiver(blusunrize.immersiveengineering.api.energy.immersiveflux.IFluxReceiver) Block(net.minecraft.block.Block) Vec3d(net.minecraft.util.math.Vec3d) Pair(org.apache.commons.lang3.tuple.Pair) Side(net.minecraftforge.fml.relauncher.Side) NonNullList(net.minecraft.util.NonNullList) GL11(org.lwjgl.opengl.GL11) TileEntitySampleDrill(blusunrize.immersiveengineering.common.blocks.metal.TileEntitySampleDrill) IEPotions(blusunrize.immersiveengineering.common.util.IEPotions) IResourceManagerReloadListener(net.minecraft.client.resources.IResourceManagerReloadListener) Mouse(org.lwjgl.input.Mouse) Config(blusunrize.immersiveengineering.common.Config) BlastFurnaceRecipe(blusunrize.immersiveengineering.api.crafting.BlastFurnaceRecipe) EntityJoinWorldEvent(net.minecraftforge.event.entity.EntityJoinWorldEvent) MessageRequestBlockUpdate(blusunrize.immersiveengineering.common.util.network.MessageRequestBlockUpdate) BlueprintCraftingRecipe(blusunrize.immersiveengineering.api.crafting.BlueprintCraftingRecipe) ItemTooltipEvent(net.minecraftforge.event.entity.player.ItemTooltipEvent) IEMuffledSound(blusunrize.immersiveengineering.common.util.sound.IEMuffledSound) IAdvancedSelectionBounds(blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IAdvancedSelectionBounds) FluidStack(net.minecraftforge.fluids.FluidStack) TickEvent(net.minecraftforge.fml.common.gameevent.TickEvent) java.util(java.util) Connection(blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) EntityEquipmentSlot(net.minecraft.inventory.EntityEquipmentSlot) DefaultVertexFormats(net.minecraft.client.renderer.vertex.DefaultVertexFormats) ItemStack(net.minecraft.item.ItemStack) PotionEffect(net.minecraft.potion.PotionEffect) TileRenderAutoWorkbench(blusunrize.immersiveengineering.client.render.TileRenderAutoWorkbench) ZoomHandler(blusunrize.immersiveengineering.api.tool.ZoomHandler) MessageMagnetEquip(blusunrize.immersiveengineering.common.util.network.MessageMagnetEquip) EnumHandSide(net.minecraft.util.EnumHandSide) IFluidHandler(net.minecraftforge.fluids.capability.IFluidHandler) Utils(blusunrize.immersiveengineering.common.util.Utils) World(net.minecraft.world.World) TextFormatting(net.minecraft.util.text.TextFormatting) TextureMap(net.minecraft.client.renderer.texture.TextureMap) BlockPos(net.minecraft.util.math.BlockPos) TileEntityRendererDispatcher(net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher) ItemNBTHelper(blusunrize.immersiveengineering.common.util.ItemNBTHelper) LivingDeathEvent(net.minecraftforge.event.entity.living.LivingDeathEvent) EntityLivingBase(net.minecraft.entity.EntityLivingBase) IZoomTool(blusunrize.immersiveengineering.api.tool.ZoomHandler.IZoomTool) MessageChemthrowerSwitch(blusunrize.immersiveengineering.common.util.network.MessageChemthrowerSwitch) Phase(net.minecraftforge.fml.common.gameevent.TickEvent.Phase) EnergyHelper(blusunrize.immersiveengineering.common.util.EnergyHelper) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) TileEntity(net.minecraft.tileentity.TileEntity) GuiToolbox(blusunrize.immersiveengineering.client.gui.GuiToolbox) GLContext(org.lwjgl.opengl.GLContext) Axis(net.minecraft.util.EnumFacing.Axis) net.minecraftforge.client.event(net.minecraftforge.client.event) IEContent(blusunrize.immersiveengineering.common.IEContent) ImmersiveEngineering(blusunrize.immersiveengineering.ImmersiveEngineering) MessageRevolverRotate(blusunrize.immersiveengineering.common.util.network.MessageRevolverRotate) CapabilityShader(blusunrize.immersiveengineering.api.shader.CapabilityShader) blusunrize.immersiveengineering.common.items(blusunrize.immersiveengineering.common.items) OreDictionary(net.minecraftforge.oredict.OreDictionary) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Lib(blusunrize.immersiveengineering.api.Lib) BlockTypes_MetalDevice1(blusunrize.immersiveengineering.common.blocks.metal.BlockTypes_MetalDevice1) GuiRevolver(blusunrize.immersiveengineering.client.gui.GuiRevolver) BlueprintLines(blusunrize.immersiveengineering.client.render.TileRenderAutoWorkbench.BlueprintLines) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ModelVillager(net.minecraft.client.model.ModelVillager) IWireCoil(blusunrize.immersiveengineering.api.energy.wires.IWireCoil) EventPriority(net.minecraftforge.fml.common.eventhandler.EventPriority) IBulletContainer(blusunrize.immersiveengineering.common.items.IEItemInterfaces.IBulletContainer) SourceFactor(net.minecraft.client.renderer.GlStateManager.SourceFactor) EntityPlayer(net.minecraft.entity.player.EntityPlayer) WireType(blusunrize.immersiveengineering.api.energy.wires.WireType) Entry(java.util.Map.Entry) ITickableSound(net.minecraft.client.audio.ITickableSound) ClientConnectedToServerEvent(net.minecraftforge.fml.common.network.FMLNetworkEvent.ClientConnectedToServerEvent) IEMuffledTickableSound(blusunrize.immersiveengineering.common.util.sound.IEMuffledTickableSound) ModelBiped(net.minecraft.client.model.ModelBiped) net.minecraft.client.renderer(net.minecraft.client.renderer) GuiIngameForge(net.minecraftforge.client.GuiIngameForge) FluidUtil(net.minecraftforge.fluids.FluidUtil) IDrillHead(blusunrize.immersiveengineering.api.tool.IDrillHead) DestFactor(net.minecraft.client.renderer.GlStateManager.DestFactor) PositionedSoundRecord(net.minecraft.client.audio.PositionedSoundRecord) IBlockOverlayText(blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IBlockOverlayText) PlaySoundEvent(net.minecraftforge.client.event.sound.PlaySoundEvent) IFluidTankProperties(net.minecraftforge.fluids.capability.IFluidTankProperties) RayTraceResult(net.minecraft.util.math.RayTraceResult) ImmutableList(com.google.common.collect.ImmutableList) Minecraft(net.minecraft.client.Minecraft) IResourceManager(net.minecraft.client.resources.IResourceManager) GuiBlastFurnace(blusunrize.immersiveengineering.client.gui.GuiBlastFurnace) Entity(net.minecraft.entity.Entity) PlayerControllerMP(net.minecraft.client.multiplayer.PlayerControllerMP) EnumFacing(net.minecraft.util.EnumFacing) Type(net.minecraft.util.math.RayTraceResult.Type) ModelBase(net.minecraft.client.model.ModelBase) IEConfig(blusunrize.immersiveengineering.common.Config.IEConfig) ParticleFractal(blusunrize.immersiveengineering.client.fx.ParticleFractal) FontRenderer(net.minecraft.client.gui.FontRenderer) Matrix4(blusunrize.immersiveengineering.common.util.chickenbones.Matrix4) IBulletContainer(blusunrize.immersiveengineering.common.items.IEItemInterfaces.IBulletContainer) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 3 with IBulletContainer

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;
}
Also used : IBulletContainer(blusunrize.immersiveengineering.common.items.IEItemInterfaces.IBulletContainer) IItemHandler(net.minecraftforge.items.IItemHandler) IEItemStackHandler(blusunrize.immersiveengineering.common.util.inventory.IEItemStackHandler) ItemStack(net.minecraft.item.ItemStack)

Aggregations

IBulletContainer (blusunrize.immersiveengineering.common.items.IEItemInterfaces.IBulletContainer)3 ItemStack (net.minecraft.item.ItemStack)3 ShaderWrapper (blusunrize.immersiveengineering.api.shader.CapabilityShader.ShaderWrapper)2 GuiBlastFurnace (blusunrize.immersiveengineering.client.gui.GuiBlastFurnace)2 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)2 ImmersiveEngineering (blusunrize.immersiveengineering.ImmersiveEngineering)1 Lib (blusunrize.immersiveengineering.api.Lib)1 BlastFurnaceRecipe (blusunrize.immersiveengineering.api.crafting.BlastFurnaceRecipe)1 BlueprintCraftingRecipe (blusunrize.immersiveengineering.api.crafting.BlueprintCraftingRecipe)1 IFluxReceiver (blusunrize.immersiveengineering.api.energy.immersiveflux.IFluxReceiver)1 IWireCoil (blusunrize.immersiveengineering.api.energy.wires.IWireCoil)1 Connection (blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection)1 WireType (blusunrize.immersiveengineering.api.energy.wires.WireType)1 CapabilityShader (blusunrize.immersiveengineering.api.shader.CapabilityShader)1 IDrillHead (blusunrize.immersiveengineering.api.tool.IDrillHead)1 ZoomHandler (blusunrize.immersiveengineering.api.tool.ZoomHandler)1 IZoomTool (blusunrize.immersiveengineering.api.tool.ZoomHandler.IZoomTool)1 ParticleFractal (blusunrize.immersiveengineering.client.fx.ParticleFractal)1 GuiRevolver (blusunrize.immersiveengineering.client.gui.GuiRevolver)1 GuiToolbox (blusunrize.immersiveengineering.client.gui.GuiToolbox)1