-
[1.12.2] Custom player inventory
Wow, another question. I have this piece of code that should render my GUI depending on current resolution. @SubscribeEvent //render extended health bar; public void renderGUI(RenderGameOverlayEvent event) { if (event.getType() == RenderGameOverlayEvent.ElementType.TEXT) { Minecraft mc = Minecraft.getMinecraft(); ScaledResolution screen = new ScaledResolution(mc); int scFactor = Math.min((int) (screen.getScaledWidth() / originalWidth), (int) (screen.getScaledHeight() / originalHeight)); //int width = (int) (hpBarWidth / originalWidth * screen.getScaledWidth()), height = (int) (hpBarHeight / originalHeight * screen.getScaledHeight()); int x = (int) (hpBarX / originalWidth * screen.getScaledWidth()), y = (int) (hpBarY / originalHeight * screen.getScaledHeight()); int currentWidth = (int) ((hpBarWidth / mc.player.getMaxHealth()) * mc.player.getHealth()); GlStateManager.enableAlpha(); GlStateManager.enableBlend(); GlStateManager.alphaFunc(516, 0.1F); mc.renderEngine.bindTexture(hpBar); GL11.glPushMatrix(); drawTexturedModalRect(x, y, 0, 0, hpBarWidth, hpBarHeight); drawTexturedModalRect(x, y, 0, hpBarHeight, currentWidth, hpBarHeight); drawTexturedModalRect(x, y, 0, hpBarHeight * 2, hpBarWidth, hpBarHeight); drawTexturedModalRect(x, y, 0, hpBarHeight * 3, hpBarWidth, hpBarHeight); GlStateManager.scale(scFactor, scFactor, scFactor); GL11.glPopMatrix(); GlStateManager.disableBlend(); GlStateManager.disableAlpha(); } } But seems like somewhy screen.getScaledWidth() and screen.getScaledHeight() both return zero that turns all screen adaptation system to nonsense. Probably I miss something about their implementation otherwise I don't understand how can they return zero values.
-
[1.12.2] Custom player inventory
As I said NullPointer refers to oldInventoryExt.getStackInSlot(i) so I guess it is the slot content to return null. For ur 2nd, 3rd and 4th questions the answer is "yes". Also what do you mean by "proper copying". getStackInSlot returns itemstack and insertItem inserts itemstack directly to the inventory capability storage.
-
[1.12.2] Custom player inventory
Meanwhile I'm having some issues with cloning inventory capability. MC throws a NullPointerException to the 5th line any time I'm trying to resurrect after death. ICustomInventoryCap inventoryExt = player.getCapability(CustomInventoryProvider.CUSTOM_INVENTORY_CAP, null); ICustomInventoryCap oldInventoryExt = event.getOriginal().getCapability(CustomInventoryProvider.CUSTOM_INVENTORY_CAP, null); for (int i = 0; i < inventoryExt.getSlots(); i++) { System.out.println (oldInventoryExt.getStackInSlot(i).getDisplayName()); inventoryExt.insertItem(i, oldInventoryExt.getStackInSlot(i), false); } Probably I'm doing something wrong trying to clone, nevertheless I have another capability which clones itself pretty well using the same algorithm.
-
[1.12.2] Minecraft textures alpha borders?
Problem's solved. That was wrong image saving options to cause a problem. Topic can be closed.
-
[1.12.2] Minecraft textures alpha borders?
Then for some unknown reasons mc keeps ignoring translucent pixels.
-
[1.12.2] Minecraft textures alpha borders?
Yes, it is so. Yet somehow these guys below support translucency. Probably is there anyway to tinker with it?
-
[1.12.2] Minecraft textures alpha borders?
I've experimented with some values and it appears that Minecraft ignores pixels with alpha below 50%. Nevertheless, will it render pixels over 50% alpha as semi-transparent or will just turn them to full opacity?
-
[1.12.2] Minecraft textures alpha borders?
So what I'm trying to do now is to render my custom health bar which is constructed of several layers rendered one after another. One of those layers is a semi-transparent texture with it's alpha levels in the 51-103 gaps. Suddenly I found out that Minecraft refuses to accept these alpha levels and it completely drops alpha levels to 0. As result one layer completely disappears. Here's a code piece for rendering the health bar. GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glAlphaFunc(GL11.GL_GREATER, 0.05f); float oneUnit = (int) (bar_width / mc.player.getMaxHealth()); int currentWidth = (int) (oneUnit * mc.player.getHealth()); drawTexturedModalRect(0, 0, 0, 0, tex_width, tex_height); drawTexturedModalRect(8,0, 8, tex_height, currentWidth, tex_height); drawTexturedModalRect(8, 0, 8, tex_height * 2, tex_width, tex_height); drawTexturedModalRect(0, 0, 0, tex_height * 3, tex_width, tex_height); drawCenteredString(mc.fontRenderer, (int) mc.player.getHealth() + "/" + (int) mc.player.getMaxHealth(), 250, 0 , color); GL11.glDisable(GL11.GL_BLEND); How should I implement my semi-transparent gui?
-
[1.12.2] Custom player inventory
Thanks, I'll give it a shot.
-
[1.12.2] Custom player inventory
Do you mean InventoryEffectRenderer?
-
[1.12.2] Custom player inventory
So I've created my Interface that extends IItemHandler and is implemented with my default implementation which has methods for inventory handling. I've created my own capability using @CapabilityInject(myInterface.class) and created my InventoryProvider which has (de)serializeNBT methods I'm currently working on. Am I doing it right? And how then should implement the gui itself, how should I handle packets between client and server?
-
[1.12.2] Custom player inventory
Standard actions with inventory like drag&drop, stacking, tooltip on hovering etc.
-
[1.12.2] Custom player inventory
If I understood your questions correctly: 1. As I wrote, GUI will be opened instead of the vanilla one when pressing "Open Inventory" key which is E by default. 2. My container will hold actual player's inventory, his equipment slots, his items hotbar and skills hotbar contents.
-
[1.12.2] Custom player inventory
So I want to create my own version of the player's inventory and it's gui which will be advanced with more tabs further (just like CustomNPCs does). And at this part I am confused at the very beginning. I've tried to look up at the vanilla sources but it was abit complicated to figure out the whole sequence. So I need someone to point me the right stages for: 1. Creating own inventory as the container with custom item, equipment and hotbar slots. 2. Creating appropriate GUI which will handle all the actions with inventory. 3. Catching the event of opening vanilla inventory to substitute it with mine. Thanks in advance.
-
How do I make Guis
I guess, the main problem for him is gui rendering and packet exchanging because it's always the hardest part. Building gui itself or detecting the key is a breeze.
IPS spam blocked by CleanTalk.