Jump to content

henne90gen

Members
  • Posts

    9
  • Joined

  • Last visited

Everything posted by henne90gen

  1. Ah ok. I'll have to do it manually then. Thanks for your help.
  2. I tried all the GuiScreenEvent.Keyboard* classes. Nothing makes the keybinding.isPressed method return true. They are definitely being called, but the keybinding is not being triggered. The inventory screen for example worked right away, but as I said, the ChestScreen is giving me some trouble.
  3. Hello, I have implemented keybindings for my mod like this: public void clientSetup(final FMLClientSetupEvent event) { int keyCode = 297; String description = "description"; keybinding = new KeyBinding(description, KeyConflictContext.UNIVERSAL, KeyModifier.NONE, InputMappings.Type.KEYSYM, keyCode, "category"); ClientRegistry.registerKeyBinding(keybinding); } @SubscribeEvent public void keyPressed(InputEvent.KeyInputEvent event) { if (keybinding.isPressed()) { // do something } } I first register the keybinding in the FMLClientSetupEvent and then I use the isPressed method inside of a KeyInputEvent to find out whether the keybinding has been pressed. This works great in most cases. The only problem is, that it does not work in ChestScreens. Does anybody know why that could be the case? Henne
  4. Ok, I thought so. Thanks for everyones help.
  5. Thanks for the tip. Checking all chests every couple ticks works much better than my initial workaround. However, I can't get the content of the chest this way. At least not the way I tried it. TileEntity tileEntity = world.getTileEntity(pos); if (tileEntity instanceof ChestTileEntity) { ChestTileEntity chestTileEntity = (ChestTileEntity) tileEntity; for (int i = 0; i < chestTileEntity.getSizeInventory(); i++) { ItemStack stack = chestTileEntity.getStackInSlot(i); // count items here } } This only gives me an empty inventory.
  6. Yeah, it's more of a workaround. I didn't expect to find a client side solution that takes into account other players breaking chests. It would be nice though to at least be able to get notified when the current player (the one that is being played by the client) breaks a block.
  7. I found a solution for my problem. I'm now using the PlayerInteractEvent.LeftClickBlock to detect when a player clicks on a block. Every time the event fires, I check the surrounding 3x3x3 blocks whether they are chests or not. If a block is not a chest, I simply check my database, whether I have a chest saved for that position and delete it if that's the case. The only downside to this is, that the player has to click on a neighboring block after breaking the chest block. So if anyone knows about a better way of doing this, then please let me know.
  8. I'm creating a mod that keeps track of the items in the players chests and I want it to work on vanilla servers as well. Whenever a player opens a chest I write the contents of the chest to a "database". That's why I need to know when the player destroys a chest, so that I can delete that chest from the "database"
  9. Hi, I want to be notified on the client side, every time the player breaks a block. However, I wasn't able to find an event that covers that case. Does anyone know how to achieve this?
×
×
  • Create New...

Important Information

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