Jump to content

Zemelua

Members
  • Posts

    190
  • Joined

  • Last visited

Everything posted by Zemelua

  1. Does it mean to send a packet(server-> tracking and self) within the handle of packet(player A-> server)? Then how do I get player A in the handle of the packet(server-> Tracking and self) ?
  2. I think this is a question that has been asked many times, but it is difficult to understand, so I will ask it. I want to update player A's capability when A presses a specific key. In addition, all players A, B, and C get the capability of each player and render them on the screen. The keystrokes, capabilities, and rendering code are all implemented. Then use packets, · Change the capability of A on the server when A pressed key · When the A's capability of the server changes, change the A capability on the A, B, C clients · Gets and renders the capability of all players on the server when rendered on the client. I don't know how to do these, so please help me.
  3. Color4f is my class, but what I'm doing is the same as the code provided. Replacing it didn't change anything. The problem I'm having is the image below ("Name Ta" is the nameplate). 1st picture: If there is water behind, it will be rendered overlapping with the water. The nameplate is darker through the entity, while the texture isn't (it looks a bit darker, because the nameplate background overlaps). 2nd picture: The texture is not darkened through the block.
  4. I know I should refer to FontRenderer#func_238441_a_, but it's complicated to dig deeper the code. This method draws both background and text. The background is probably drawn with TrenderEffect#renderEffect(FontRenderer: L344), but I don't know where the letters are drawn.
  5. The texture became transparent to the background.
  6. double d0 = entityRenderer.getRenderManager().squareDistanceTo(entity); if (net.minecraftforge.client.ForgeHooksClient.isNameplateInRenderDistance(entity, d0) && this.minecraft.pointedEntity == entity) { this.profiler.startSection("otherHealth"); matrixStack.push(); matrixStack.translate(0.0D, entity.getHeight() + 0.5F, 0.0D); matrixStack.rotate(entityRenderer.getRenderManager().getCameraOrientation()); matrixStack.scale(-0.025F, -0.025F, 0.025F); RenderSystem.enableBlend(); RenderSystem.disableDepthTest(); RenderSystem.disableAlphaTest(); int health = MathHelper.ceil(entity.getHealth()); int maxHealth = MathHelper.ceil(entity.getMaxHealth()); int absorb = MathHelper.ceil(entity.getAbsorptionAmount()); int rowCount = (int) Math.ceil(health / 20D) - 1; int hideHealth = Math.max(rowCount * 20, 0); int hideAbsorb = Math.max((int) Math.ceil(absorb / 20D) - 1, 0); ITextComponent rowText = new StringTextComponent("x" + rowCount); String amountString = String.valueOf(health); if (absorb > 0) amountString = amountString + "+" + absorb; amountString = amountString + "/" + maxHealth; ITextComponent amountText = new StringTextComponent(amountString); int xStart = - (81 + 5 + this.minecraft.fontRenderer.getStringPropertyWidth(amountText)) / 2; int BACKGROUND_X_DRAW_START = xStart; int BACKGROUND_X_DRAW_END = -xStart; int ICONS_X_DRAW = xStart; int ICONS_Y_DRAW = 0; int ICONS_BACKGROUND_U_OFFSET = 51; int ICONS_BACKGROUND_V_OFFSET = 0; int ICONS_BACKGROUND_U_SIZE = 9; int ICONS_BACKGROUND_V_SIZE = 9; int ICONS_FOREGROUND_U_OFFSET = 87; int ICONS_FOREGROUND_V_OFFSET = 0; int ICONS_FOREGROUND_U_SIZE = 9; int ICONS_FOREGROUND_V_SIZE = 9; int ICONS_ABSORB_U_OFFSET = 195; int ICONS_ABSORB_V_OFFSET = 0; int ICONS_ABSORB_U_SIZE = 9; int ICONS_ABSORB_V_SIZE = 9; int TEXT_X_DRAW = xStart + 81 + 5; int TEXT_Y_DRAW = 0; this.minecraft.getTextureManager().bindTexture(UMUClientIngameGUI.GUI_ICONS_LOCATION); float color = Minecraft.getInstance().gameSettings.getTextBackgroundOpacity(0.25F); Color4f color4f = Color4f.fromInt((int) (color * 255.0F) << 24); float red = color4f.getRed(); float green = color4f.getGreen(); float blue = color4f.getBlue(); float alpha = color4f.getAlpha(); Matrix4f matrix = matrixStack.getLast().getMatrix(); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder buffer = tessellator.getBuffer(); RenderSystem.disableTexture(); buffer.begin(7, DefaultVertexFormats.POSITION_COLOR); buffer.pos(matrix, BACKGROUND_X_DRAW_START - 2.0F, 10.0F, 0.01F).color(red, green, blue, alpha).endVertex(); buffer.pos(matrix, BACKGROUND_X_DRAW_END + 2.0F, 10.0F, 0.01F).color(red, green, blue, alpha).endVertex(); buffer.pos(matrix, BACKGROUND_X_DRAW_END + 2.0F, -2.0F, 0.01F).color(red, green, blue, alpha).endVertex(); buffer.pos(matrix, BACKGROUND_X_DRAW_START - 2.0F, -2.0F, 0.01F).color(red, green, blue, alpha).endVertex(); tessellator.draw(); RenderSystem.enableTexture(); for (int i = 0; i < 10; i++) { int iconHealth = health - hideHealth - i * 2; int iconAbsorb = absorb - hideAbsorb - i * 2; int ICON_X_DRAW = ICONS_X_DRAW + i * 8; int ICON_BACKGROUND_U_OFFSET = ICONS_BACKGROUND_U_OFFSET; int ICON_FOREGROUND_U_OFFSET = ICONS_FOREGROUND_U_OFFSET; int ICON_ABSORB_U_OFFSET = ICONS_ABSORB_U_OFFSET; if (!(maxHealth - hideHealth - i * 2 > 0)) ICON_BACKGROUND_U_OFFSET = 999; if (iconHealth > 0) { if (iconHealth <= 1) ICON_FOREGROUND_U_OFFSET += 9; } else { ICON_FOREGROUND_U_OFFSET = 999; } if (iconAbsorb > 0) { if (iconAbsorb <= 1) ICON_ABSORB_U_OFFSET += 9; } else { ICON_ABSORB_U_OFFSET = 999; } this.blit(matrixStack, ICON_X_DRAW, ICONS_Y_DRAW, ICON_BACKGROUND_U_OFFSET, ICONS_BACKGROUND_V_OFFSET, ICONS_BACKGROUND_U_SIZE, ICONS_BACKGROUND_V_SIZE); this.blit(matrixStack, ICON_X_DRAW, ICONS_Y_DRAW, ICON_FOREGROUND_U_OFFSET, ICONS_FOREGROUND_V_OFFSET, ICONS_FOREGROUND_U_SIZE, ICONS_FOREGROUND_V_SIZE); this.blit(matrixStack, ICON_X_DRAW, ICONS_Y_DRAW, ICON_ABSORB_U_OFFSET, ICONS_ABSORB_V_OFFSET, ICONS_ABSORB_U_SIZE, ICONS_ABSORB_V_SIZE ); } if (rowCount != 0) { this.minecraft.fontRenderer.drawText(matrixStack, rowText, TEXT_X_DRAW, TEXT_Y_DRAW, WHITE); TEXT_X_DRAW += (this.minecraft.fontRenderer.getStringPropertyWidth(rowText) + 5); } this.minecraft.fontRenderer.drawText(matrixStack, amountText, TEXT_X_DRAW, TEXT_Y_DRAW, WHITE); matrixStack.pop(); this.profiler.endSection(); } It is now also visible through blocks. However, there are still two problems. 1. When there is water or clouds behind, the rendered texture will appear to be below the water or clouds. 2. It is displayed through the block, but unlike the nameplate, the color does not darken.
  7. I want to draw a texture on a black background as well as a nameplate. However, there are issues such as not being visible across blocks and entities. Therefore, I would like to refer to RenderSystem and bufferBuilder for rendering nameplates. But if you follow the code, it's very complicated and unclear. Where in the code is the RenderSystem, bufferBuilder for rendering nameplates?
  8. I'm trying to create a mod (client only) that shows the health of entities in sight. Like the player's overlay health, I want to animate things like highlights, so I need to keep fields lastSystemTime and etc. To implement this, I have two ways: 1. Create a HealthRenderer class that holds fields lastSystemTime and etc, create a map with the corresponding entity, and retrieve the HealthRenderer class and draw when the entity is in view. 2. Attach Health Renderer class to each entity by capability If the capacity isn't available in the client-only mod, I'll use 1, but I'll have to keep fields about all the entities that have been in sight, and check the map every time it's rendered. Can capability be available in client-only mods? Or is there a better alternative to 1 and 2?
  9. Almost the same as this sample mod. I want to turn off the IME when I open the chat gui.
  10. I found a good mod that uses JNA( https://github.com/Axeryok/CocoaInput ), so I'll refer to it. I have one question, I think Minecraft#getWindow.getWindow here is probably a method of fabric mod. Is there a method of Forge that is the same as this? And if not, how can I get this?
  11. In my mod I'm trying to use a dll file to do something that pure java can't do. I have some basic knowledge about JNA, -What happens to the dll file when compiled -How to get the mod dll file I'm stuck without knowing. Does anyone know about this? Or is there a sample mod that uses a dll file with JNA?
  12. I want to display a texture like a name tag. Specifically, it displays the texture on a black background of nametag with the same transparency as the characters on the name tag. I've just looked at the vanilla code that displays the name tag, but I'm running into a problem. Textures appear semi-transparent when they overlap clouds or the ocean. To be honest, I don't understand the rendering system. I've followed the method that vanilla displays the characters in a name tag, but it's too complicated. I understand that MatrixStack is a class for rotating and moving objects to display, but Buffer? RenderSystem? Is there a tutorial to understand those rendering systems? Also, which vanilla method is used to set the transparency etc. to display 1. characters, 2. black translucent background of the name tag? Current code: public void renderFocusedHealth(MatrixStack matrixStack, EntityRenderer<?> entityRenderer, Entity entity) { double d0 = entityRenderer.getRenderManager().squareDistanceTo(entity); if (net.minecraftforge.client.ForgeHooksClient.isNameplateInRenderDistance(entity, d0) && this.minecraft.pointedEntity == entity) { float f = entity.getHeight() + 0.5F; matrixStack.push(); matrixStack.translate(0.0D, (double) f, 0.0D); matrixStack.rotate(entityRenderer.getRenderManager().getCameraOrientation()); matrixStack.scale(-0.025F, -0.025F, 0.025F); this.minecraft.getTextureManager().bindTexture(UMUClientIngameGUI.GUI_ICONS_LOCATION); blit(matrixStack, 0, 0, 87, 0, 9, 9); matrixStack.pop(); } } @SubscribeEvent public void onRenderNameplate(RenderNameplateEvent event) { renderFocusedHealth(event.getMatrixStack(), event.getEntityRenderer(), event.getEntity()); }
  13. I want to check if the entity's name tag is displayed, but EntityRenderer#canRenderName is protected. Are there other way to check it ?
  14. I also searched but couldn't find ... isn't there other way to do this?
  15. I'm trying to make Japanese input easier now. It may not be related to Minecraft, but I have two questions. 1. How can I force IME to be enabled when the chat screen is opened and disabled when it is closed? 2. The character string being input (before conversion) in IME will not be displayed on the chat screen (it will be displayed after confirmation). For this reason, I want to get the string I'm typing and add it to ChatScreen.inputField. How can I get it? public static void onChatOpen(GuiOpenEvent event) { if (event.getGui() instanceof ChatScreen) { // enable IME, how? // InputContext.getInstance().setCompositionEnabled(true); <- always throw exception... } }
  16. Yes, that's the problem. I should be updating the inventory of the slot itself with updateInventory(), but what else is linking the inventory to the slot? Can I update it then?
  17. 1. Prepare two Backpacks. 2. With one Backpack on your chest, open the BelongingsScreen. 3. In the BelongingsScreen, remove the equipped Backpack and equip another one. 4. Place any items in the backpack slot. 5. Close the Screen as it is. 6. When you open the Screen again with the second Backpack equipped, the items you should have put in are missing.
  18. I fixed. Backpacks should always have Capability. .orElseThrow(() -> new IllegalStateException("Backpack inventory is Empty!")) It's confusing, but there are two types, Backpack and Functional Backpack, and Backpack doesn't require a side argument. In the test, I used only Backpack, so there was no problem. I've solved these issues, but I'm still not solving the issue where inventory isn't applied ... https://github.com/Zemelua/UMU-Mod/blob/main/src/main/java/io/github/zemelua/umumod/inventory/container/AbstractUMUPlayerContainer.java#L37 It's possible that there's a problem with the arguments I'm passing on this line, but I'm not sure what's wrong. The method of implementing IContainerListener and updating the inventory as a listener also didn't work. (It looks like I need to update backpack's inventory before slotClick() is done.)
  19. I've been working on this issue for over a week and I don't know the cause at all ... I think it's a hassle, but could anyone help identify the cause? Please......
  20. My explanation was insufficient. The problem I'm having is that if I change the chest backpack with the BelongingsUMUPlayerContainer open, its contents will appear in the backpack slot. However, if I make changes to the backpack slot in that state, the changes are not saved when I close the container. When I reopen it, it will return to the state before I made the change. In AbstractBelongingSlot, unlike the SlotItemHandler class, itemHandler field is dynamic (not final). When SlotItemHandler class references an itemHandler, it's basically via getItemHandler(), so I can override it to return a dynamic inventory. However, some methods that are not related to the inventory contents refer directly to the itemHandler field. In other words, the itemHandler field is fine with dynamic inventory, but I'm just passing another baseItemHandler to get some elements. Its contents are not used. You don't have to worry about it.
  21. But in fact it is not saved. When is the container and screen synced? And what do you think is the reason why it isn't done? https://github.com/Zemelua/UMU-Mod/blob/main/src/main/java/io/github/zemelua/umumod/inventory/container/BelongingsUMUPlayerContainer.java
  22. I have a backpack item with ItemStackHandler capability. A player can change the item's inventory on screen. The container gets the ItemStackHandler capability from the backpack in the player's chest slot and dynamically changes the inventory. so it needs to be synchronized with the client backpack when the container is opened or the inventory changes. How do I use packets to synchronize the server ItemStack capability with the client ItemStack capability? My code is here .
  23. private void renderFluid(MatrixStack matrixStack, Tank tank) { // 33; int x = tank.getXPos(); int y = tank.getYPos(); // FluidStack fluidStack = tank.getStack(); FluidStack fluidStack = new FluidStack(Fluids.WATER, 1); TextureAtlasSprite fluidSprite = this.minecraft.getAtlasSpriteGetter(PlayerContainer.LOCATION_BLOCKS_TEXTURE) .apply(fluidStack.getFluid().getAttributes().getStillTexture(fluidStack) ); if (!fluidStack.isEmpty()) { this.minecraft.getTextureManager().bindTexture( fluidSprite.getAtlasTexture().getTextureLocation() ); } AbstractGui.blit(matrixStack, this.guiLeft + x, this.guiTop + y, this.getBlitOffset(), 16, 16, fluidSprite); } I was able to draw the texture of water for the time being. However, I haven't drawn the overlay yet, so it remains gray. How do I apply the overlay to make it blue?
  24. I did a little research and coded it with reference to the mod that draws the liquid in the GUI in the same way, but the liquid is not drawn, only the noise-like thing is displayed small. What's wrong? ~~ private void renderFluid(MatrixStack matrixStack, Tank tank) { int x = tank.getXPos(); int y = tank.getYPos(); FluidStack fluidStack = tank.getStack(); this.minecraft.getTextureManager().bindTexture( this.minecraft.getAtlasSpriteGetter(PlayerContainer.LOCATION_BLOCKS_TEXTURE).apply( fluidStack.getFluid().getAttributes().getStillTexture(fluidStack) ).getAtlasTexture().getTextureLocation() ); AbstractGUI.blit(matrixStack, x, y, this.getBlitOffset(), 0, 0, 16, 16, 16, 16); } ~~
×
×
  • Create New...

Important Information

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