Jump to content

AntiRix

Members
  • Posts

    69
  • Joined

  • Last visited

Everything posted by AntiRix

  1. I'm upgrading my mod from 1.9 to 1.15.2 which involves quite a lot of differences, and I'm having trouble getting my custom GUI to render. I've got keybinds working so it displays the gui, which I can tell because it displays the cursor ready for interaction, but the gui isn't being rendered so it's completely transparent. Any idea why this could be? ModGUI gui = new ModGUI(); mc.displayGuiScreen(gui); ... public ModGUI() { super(new StringTextComponent("ModGUI")); buttons.add(new Button(32, 32, 32, 100, "Click Me", (button) -> { System.out.println("Clicked"); })); }
  2. I didn't lie. It's going to be the same process for both 1.12.2 and 1.9, but my mod is 1.9. Even if you don't support 1.9 code, you by default support the concept by saying you support 1.12.2, even if you won't provide 1.9-compatible code. To put it more simply, you are able to help me without the need for code whatsoever, by just telling me what I'm doing wrong. For example, "You could set both results to DENY for PlayerInteractEvent.LeftClickBlock and cancel the event on the client to prevent the left-click interaction.". This tells me what to do, without any code. This essentially means the help you provide is version-agnostic. It is not reasonable to refuse people help unless they rewrite thousands of lines of code.
  3. That's not a reasonable request. Here's the jar in my build path, proving the project is 1.12.2:
  4. Hi, I'm using the following code to prevent the player breaking carrots which aren't fully-grown, but it's not preventing the block breaking even though all of the conditions have been met. Why could this be? @SubscribeEvent public void onBlockBreak(PlayerInteractEvent.LeftClickBlock event) { if (!event.getWorld().isRemote) return; IBlockState state = event.getWorld().getBlockState(event.getPos()); for (Object o : state.getProperties().entrySet()) { Map.Entry e = (Map.Entry)o; if (e.getKey() instanceof PropertyInteger) { PropertyInteger prop = (PropertyInteger)e.getKey(); if (prop.getName().equals("age")) { int age = state.getValue(prop); if (age < 7) { event.setUseBlock(Result.DENY); event.setUseItem(Result.DENY); event.setCanceled(true); } return; } } } }
  5. If I have the following at the beginning of the method, nothing happens. if (!mc.theWorld.isRemote) return; If I have the following, properties are retrieved but it still doesn't cancel the breaking, even though age < 7 is true: if (mc.theWorld.isRemote) return; This makes no sense considering what you just said
  6. I've adjusted the code, but now it seems the block doesn't even have any properties. @SubscribeEvent public void onBlockBreak(PlayerInteractEvent.LeftClickBlock event) { IBlockState state = mc.theWorld.getBlockState(event.getPos()); mc.thePlayer.addChatMessage(new TextComponentString("onBlockBreak")); for (Object o : state.getProperties().entrySet()) { Map.Entry e = (Map.Entry)o; if (e.getKey() instanceof PropertyInteger) { PropertyInteger prop = (PropertyInteger)e.getKey(); mc.thePlayer.addChatMessage(new TextComponentString(prop.getName() + ": " + state.getValue(prop))); if (prop.getName().equals("age")) { int age = state.getValue(prop); if (age < 7) { event.setUseBlock(Result.DENY); event.setUseItem(Result.DENY); event.setCanceled(true); } return; } } } }
  7. Ok, so how should I approach cancelling block break events with a client-side mod only, on multiplayer?
  8. Does that include the internal server? It works fine on singleplayer.
  9. I had 1.12.2 already set up so might as well go with that. The mod isn't for the server itself, it's a client-side mod, but one which isn't working on multiplayer for some reason.
  10. Hi, I'm using the following code to prevent the player breaking carrots which aren't fully-grown. It works fine on singleplayer, but not at all on multiplayer, in fact on multiplayer the event isn't being fired at all. Why could this be? @SubscribeEvent public void onBlockBreak(BreakEvent event) { IBlockState state = event.getState(); net.minecraft.block.Block block = state.getBlock(); for (Object o : state.getProperties().entrySet()) { Map.Entry e = (Map.Entry)o; if (e.getKey() instanceof PropertyInteger) { PropertyInteger prop = (PropertyInteger)e.getKey(); if (prop.getName().equals("age")) { int age = state.getValue(prop); if (age < 7) event.setCanceled(true); } } } }
  11. Hi, I'm using the following code to prevent the player breaking carrots which aren't fully-grown. It works fine on singleplayer, but not at all on multiplayer. Why could this be? @SubscribeEvent public void onBlockBreak(BreakEvent event) { IBlockState state = event.getState(); net.minecraft.block.Block block = state.getBlock(); for (Object o : state.getProperties().entrySet()) { Map.Entry e = (Map.Entry)o; if (e.getKey() instanceof PropertyInteger) { PropertyInteger prop = (PropertyInteger)e.getKey(); if (prop.getName().equals("age")) { int age = state.getValue(prop); if (age < 7) event.setCanceled(true); } } } }
  12. Figured it out. My original code is correct so I didn't need to do any of what you suggested. There was just a logical error in my code where the window ID was being reset to 0, so it was trying to perform the click on the wrong inventory.
  13. If you have no further insight, it would be courteous to say that so I'm not waiting for a week.
  14. Getting sick of this now. func_187098_a clicks the slot client-side. It also sends a CPacketClickWindow to the server. What else do I have to do?
  15. Is nobody able to help me with this?
  16. I thought that I'd need to do something on the server, but I can't find the right method. I tried adding a packet to the queue with the slot and stack in that slot, but it didn't work. Can't find any help on the internet because I'm not doing a common thing. Also can't log outgoing packets because overriding that queuing method and logging the packets doesn't do anything. Tried sending CPacketClickWindow Tried updating player controller Still the same result
  17. I'm trying to move an item from a specific slot in the player inventory to a specific slot in another open inventory. When you place an item in the open inventory, the server updates the inventory, which I need to achieve. I'm using this to pick it up from my inventory: Minecraft.getMinecraft().playerController.func_187098_a(p.inventoryContainer.windowId, 45 + _book_slot, 0, ClickType.PICKUP, p); And this to place it in the other inventory: Minecraft.getMinecraft().playerController.func_187098_a(enchantment_table_window_id, 13, 0, ClickType.PICKUP, p); 5000ms apart, so there are no timing issues. The item is picked up and placed as expected. However, it doesn't cause the server to update the inventory. If I click that item, it just moves straight back into my inventory. There's clearly a desync here, but I don't know what I'm missing.
  18. My goal is to create tiles of the entire world which will be loaded in a fancy configuration on my website to create a map, so it's not loading one huge image which may look ugly while loading on slow connections. Here's the full explanation of what I'm trying to do 1. Get at least some blocks rendered to a PNG so I know it's possible 2. Render a few chunks together, and calculate the bounding box of those chunks, making sure it's >= the tile size I want eg. looking to have 400x400 tiles, and a configuration of 3x3 chunks creates an image of 500x500 3. When I have a set number of chunks which fulfils this requirement, I'll render lots of these images to PNG files to cover the entire map An example of one of these large images: 4. I'll then write an external program to cut these images down into the target 400x400 tiles for use on my website, as seen below. It'll create an image of 400x400 from the 0,0, and then begin another one at 400,0. It'll use the remaining 100px of that image, then take 300px from the image to the right of it. I'll have no problem figuring this part out - I've done plenty of .NET graphics manipulation. This external program does not interact with the mod in any way. It simply manipulates its output ready for use.
  19. I still need desperate help with this, if anyone's watching this thread. I've combined a hook by Cadiboo with the OpenGL code by V0idWa1k3r to create this: @SubscribeEvent public void onPostRebuildChunk(final RebuildChunkPostEvent event) { //BufferBuilder buffer_builder = event.getGenerator().getRegionRenderCacheBuilder().getWorldRendererByLayer(BlockRenderLayer.SOLID); // Define the width and the height of the framebuffer, the texture and as a result the final png file. int width = 256; int height = 256; // Get the framebuffer object that was already in use since we have to restore the state when we are done Framebuffer fbo = Minecraft.getMinecraft().getFramebuffer(); // // Create a new framebuffer object with the width and the height defined. The last parameter defines whether to use depth or not. // Framebuffer framebuffer = new Framebuffer(width, height, true); // // // Bind the created framebuffer as the active framebuffer. The last parameter also adjusts the viewport to the dimensions of our framebuffer. // framebuffer.bindFramebuffer(true); // // // These are not really needed, however I prefer do draw over black. By default the texture would be white. // GlStateManager.clearColor(0, 0, 0, 1); // // // No need to clear depth/stencil since those are clean as is since nothing has been drawn yet. // GlStateManager.clear(GL11.GL_COLOR_BUFFER_BIT); // // GlStateManager.pushMatrix(); // // // MAKE ISOMETRIC HERE // // // Draw the actual entity. You might want to play with positions and scaling. // //GuiInventory.drawEntityOnScreen(200, 200, 100, 0, 0, new EntitySheep(Minecraft.getMinecraft().world)); // Tessellator.getInstance().draw(); // randomly guessing how to get the BufferBuilder to draw to the screen here // GlStateManager.popMatrix(); // // // Allocate a buffer for GL to dump pixels into. // IntBuffer pixels = BufferUtils.createIntBuffer(width * height); // // // Bind the framebuffer's texture. // GlStateManager.bindTexture(framebuffer.framebufferTexture); // // // Dump the pixels onto the IntBuffer. Note that the pixel format is BGRA and the pixel type is 8 bits per color. // GlStateManager.glGetTexImage(GL11.GL_TEXTURE_2D, 0, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, pixels); // // // Allocate the array to hold pixel values. // int[] vals = new int[width * height]; // // // Copy the buffer to the array. // pixels.get(vals); // // // Rearrange pixel values to correct positions so they can be read by the BufferedImage correctly. // TextureUtil.processPixelValues(vals, width, height); // // // Create the BufferedImage object. // BufferedImage bufferedimage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // // // Copy the pixels from the array onto the BufferedImage. // bufferedimage.setRGB(0, 0, width, height, vals, 0, width); // // // Create a file to store the image within. Here the file will be outputted to the game's base directory with a name of img.png. // File f = new File("C:\\Users\\Ricky\\Desktop\\CHUNKS.png"); // // try { // f.createNewFile(); // // // Finally write the buffered image into the file. // ImageIO.write(bufferedimage, "png", f); // } catch (IOException e) { // // TODO Auto-generated catch block // e.printStackTrace(); // } // // // Delete the framebuffer from memory. It is no longer needed. // framebuffer.deleteFramebuffer(); // // // If the game had a buffer bound. In most cases it did but who knows what could be the case with mods and such. // if (fbo != null) // { // // Restore the original framebuffer. The parameter set to true also restores the viewport. // fbo.bindFramebuffer(true); // } // else // { // // If the game didn't have a framebuffer bound we need to restore the default one. It's ID is always 0. // GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, 0); // // // We also need to restore the viewport back in this case. // GlStateManager.viewport(0, 0, Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight); // } } But it's crashing when instantiating a FrameBuffer, saying "No OpenGL context found in the current thread".
  20. Yes, with isometric projection, and where lighting and shadows are preserved so the images can be stitched together afterwards with no apparent joins.
  21. Because I'm completely flying blind with this, this is the best guess I can come up with: RenderChunk r = new RenderChunk(mc.world, mc.renderGlobal, 0); ChunkCompileTaskGenerator generator = new ChunkCompileTaskGenerator(r, Type.REBUILD_CHUNK, 10.0); r.rebuildChunk(mc.player.chunkCoordX, mc.player.chunkCoordY, mc.player.chunkCoordZ, generator); BufferBuilder builder = generator.getRegionRenderCacheBuilder().getWorldRendererByLayerId(0); As guaranteed and expected, this crashes the game. The index property of RenderChunk doesn't appear to do anything. I assume I just have to have the same value for getWorldRendererByLayerId(). I can't trace the meaning of the 3rd double parameter of ChunkCompileTaskGenerator() either, so I've just used a random double value. I have no clue what you'd need a distance to render a chunk for. The code is completely uncommented and so convoluted that it's impossible to decipher what anything's doing. It's so frustrating and I've been trying for hours. There is zero help on the internet for anything to do with rendering to a file. Aside from that, are you sure I'm able to achieve what I want with this method? I'm trying to create the following, including lighting.
  22. Ok, I've found what you're referring to: for (; this.gameSettings.keyBindTogglePerspective.isPressed(); this.renderGlobal.setDisplayListEntitiesDirty()) { ++this.gameSettings.thirdPersonView; if (this.gameSettings.thirdPersonView > 2) { this.gameSettings.thirdPersonView = 0; } if (this.gameSettings.thirdPersonView == 0) { this.entityRenderer.loadEntityShader(this.getRenderViewEntity()); } else if (this.gameSettings.thirdPersonView == 1) { this.entityRenderer.loadEntityShader((Entity)null); } } if (block.getDefaultState().getRenderType() != EnumBlockRenderType.INVISIBLE) { BufferBuilder bufferbuilder = generator.getRegionRenderCacheBuilder().getWorldRendererByLayerId(j); if (!compiledchunk.isLayerStarted(blockrenderlayer1)) { compiledchunk.setLayerStarted(blockrenderlayer1); this.preRenderBlocks(bufferbuilder, blockpos); } aboolean[j] |= blockrendererdispatcher.renderBlock(iblockstate, blockpos$mutableblockpos, this.region, bufferbuilder); } loadEntityShader doesn't mean anything - it's just loading shaders. I can't see where I'm meant to be going with that. I assume if modifying the client directly, that I'd need to insert code before the line aboolean[j].... One thing I don't understand though - where am I meant to get the BufferBuilder from? I can't steal variables from inside a method.
×
×
  • Create New...

Important Information

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