Jump to content

Asmodesu

Members
  • Posts

    19
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Asmodesu's Achievements

Tree Puncher

Tree Puncher (2/8)

1

Reputation

  1. 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.
  2. 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.
  3. 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.
  4. Problem's solved. That was wrong image saving options to cause a problem. Topic can be closed.
  5. Then for some unknown reasons mc keeps ignoring translucent pixels.
  6. Yes, it is so. Yet somehow these guys below support translucency. Probably is there anyway to tinker with it?
  7. 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?
  8. 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?
  9. 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?
  10. Standard actions with inventory like drag&drop, stacking, tooltip on hovering etc.
  11. 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.
  12. 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.
  13. 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.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.