Jump to content

AntiRix

Members
  • Posts

    69
  • Joined

  • Last visited

Recent Profile Visitors

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

AntiRix's Achievements

Stone Miner

Stone Miner (3/8)

1

Reputation

  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?
×
×
  • Create New...

Important Information

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