HUD element for Sigil of Holding
Needs cleaning and configurability still TODO: Move to HUDElement system that Hemomancy had.
This commit is contained in:
parent
f7179f6d6a
commit
eceb0eab6e
|
@ -4,6 +4,7 @@ import WayofTime.bloodmagic.api.Constants;
|
|||
import WayofTime.bloodmagic.item.inventory.ContainerHolding;
|
||||
import WayofTime.bloodmagic.item.inventory.InventoryHolding;
|
||||
import WayofTime.bloodmagic.item.sigil.ItemSigilHolding;
|
||||
import WayofTime.bloodmagic.registry.ModItems;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
|
@ -27,14 +28,14 @@ public class GuiHolding extends GuiContainer
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int param1, int param2)
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
|
||||
{
|
||||
//the parameters for drawString are: string, x, y, color
|
||||
fontRendererObj.drawString(TextHelper.localize("item.BloodMagic.sigil.holding.name"), 53, 4, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
|
||||
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouse)
|
||||
{
|
||||
//draw your Gui here, only thing you need to change is the path
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
@ -42,15 +43,10 @@ public class GuiHolding extends GuiContainer
|
|||
int x = (width - xSize) / 2;
|
||||
int y = (height - ySize) / 2;
|
||||
this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
|
||||
|
||||
if (player != null && player.getHeldItemMainhand() != null && player.getHeldItemMainhand().getItem() instanceof ItemSigilHolding)
|
||||
if (player.getHeldItemMainhand() != null && player.getHeldItemMainhand().getItem() == ModItems.sigilHolding)
|
||||
{
|
||||
if (ItemSigilHolding.getCurrentSigil(player.getHeldItemMainhand()) != null)
|
||||
{
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(texture);
|
||||
this.drawTexturedModalRect(4 + x + 36 * ItemSigilHolding.getCurrentItemOrdinal(player.getHeldItemMainhand()), y + 13, 0, 123, 24, 24);
|
||||
}
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.drawTexturedModalRect(4 + x + 36 * ItemSigilHolding.getCurrentItemOrdinal(player.getHeldItemMainhand()), y + 13, 0, 123, 24, 24);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,13 +13,17 @@ import WayofTime.bloodmagic.item.ItemRitualReader;
|
|||
import WayofTime.bloodmagic.item.sigil.ItemSigilHolding;
|
||||
import WayofTime.bloodmagic.network.BloodMagicPacketHandler;
|
||||
import WayofTime.bloodmagic.network.SigilHoldingPacketProcessor;
|
||||
import WayofTime.bloodmagic.registry.ModItems;
|
||||
import WayofTime.bloodmagic.tile.TileMasterRitualStone;
|
||||
import WayofTime.bloodmagic.util.GhostItemHelper;
|
||||
import WayofTime.bloodmagic.util.handler.BMKeyBinding;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -31,6 +35,7 @@ import net.minecraft.util.math.BlockPos;
|
|||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.MouseEvent;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
||||
|
@ -41,6 +46,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
|||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -138,6 +144,61 @@ public class ClientHandler
|
|||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onKey(InputEvent event)
|
||||
{
|
||||
if (!minecraft.inGameHasFocus)
|
||||
return;
|
||||
|
||||
for (BMKeyBinding key : keyBindings)
|
||||
{
|
||||
if (key.isPressed())
|
||||
key.handleKeyPress();
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onGuiRender(RenderGameOverlayEvent.Pre event)
|
||||
{
|
||||
if (event.getType() == RenderGameOverlayEvent.ElementType.HOTBAR)
|
||||
{
|
||||
ItemStack sigilHolding = minecraft.thePlayer.getHeldItemMainhand();
|
||||
// TODO - Clean this mess
|
||||
// Check mainhand for Sigil of Holding
|
||||
if (sigilHolding == null)
|
||||
return;
|
||||
if (sigilHolding.getItem() != ModItems.sigilHolding)
|
||||
sigilHolding = minecraft.thePlayer.getHeldItemOffhand();
|
||||
// Check offhand for Sigil of Holding
|
||||
if (sigilHolding == null)
|
||||
return;
|
||||
if (sigilHolding.getItem() != ModItems.sigilHolding)
|
||||
return;
|
||||
|
||||
Gui ingameGui = minecraft.ingameGUI;
|
||||
|
||||
minecraft.getTextureManager().bindTexture(new ResourceLocation(Constants.Mod.MODID, "textures/gui/widgets.png"));
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F);
|
||||
ingameGui.drawTexturedModalRect(event.getResolution().getScaledWidth() / 2 + 100, event.getResolution().getScaledHeight() - 22, 0, 0, 102, 22);
|
||||
int currentSlot = ItemSigilHolding.getCurrentItemOrdinal(sigilHolding);
|
||||
ingameGui.drawTexturedModalRect(event.getResolution().getScaledWidth() / 2 + 99 + (currentSlot * 20), event.getResolution().getScaledHeight() - 23, 0, 22, 24, 24);
|
||||
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
ItemStack[] holdingInv = ItemSigilHolding.getInternalInventory(sigilHolding);
|
||||
int xOffset = 0;
|
||||
if (holdingInv != null)
|
||||
{
|
||||
for (ItemStack sigil : holdingInv)
|
||||
{
|
||||
renderHotbarItem(event.getResolution().getScaledWidth() / 2 + 103 + xOffset, event.getResolution().getScaledHeight() - 18, event.getPartialTicks(), minecraft.thePlayer, sigil);
|
||||
xOffset += 20;
|
||||
}
|
||||
}
|
||||
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
}
|
||||
}
|
||||
|
||||
private void cycleSigil(ItemStack stack, EntityPlayer player, int dWheel)
|
||||
{
|
||||
int mode = ItemSigilHolding.getCurrentItemOrdinal(stack);
|
||||
|
@ -232,16 +293,27 @@ public class ClientHandler
|
|||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onKey(InputEvent event)
|
||||
protected void renderHotbarItem(int x, int y, float partialTicks, EntityPlayer player, @Nullable ItemStack stack)
|
||||
{
|
||||
if (!minecraft.inGameHasFocus)
|
||||
return;
|
||||
|
||||
for (BMKeyBinding key : keyBindings)
|
||||
if (stack != null)
|
||||
{
|
||||
if (key.isPressed())
|
||||
key.handleKeyPress();
|
||||
float animation = (float) stack.animationsToGo - partialTicks;
|
||||
|
||||
if (animation > 0.0F)
|
||||
{
|
||||
GlStateManager.pushMatrix();
|
||||
float f1 = 1.0F + animation / 5.0F;
|
||||
GlStateManager.translate((float) (x + 8), (float) (y + 12), 0.0F);
|
||||
GlStateManager.scale(1.0F / f1, (f1 + 1.0F) / 2.0F, 1.0F);
|
||||
GlStateManager.translate((float) (-(x + 8)), (float) (-(y + 12)), 0.0F);
|
||||
}
|
||||
|
||||
minecraft.getRenderItem().renderItemAndEffectIntoGUI(player, stack, x, y);
|
||||
|
||||
if (animation > 0.0F)
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
minecraft.getRenderItem().renderItemOverlays(minecraft.fontRendererObj, stack, x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
BIN
src/main/resources/assets/bloodmagic/textures/gui/widgets.png
Normal file
BIN
src/main/resources/assets/bloodmagic/textures/gui/widgets.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
Loading…
Reference in a new issue