Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/29/20 in all areas

  1. https://wiki.mcjty.eu/modding/index.php?title=YouTube-Tutorials#Episode_2:_The_First_Block.2C_Capabilities.2C_Container.2C_Gui Containers dont really require anything special in constructor in regards to tile entities. You are not forced to open it on right click of a tile entity. You can also just open the container when right clicking an item etc.. Just depends on where you call the NetworkHooks method to open it. Most minecraft containers require the player or player inventory as parameter (in constructor) because they access said inventory. But you are free to do whatever you want. So ye. Kinda trying to answer you where there isnt much to talk about. You can re-use the same container and containerscreen classes for different container types. Just keep that in mind (this is done eg. with the vanilla chests)
    1 point
  2. All of you faced this problem. And now me, too. I wrote some code to catch Keyboard events. like: @SideOnly(Side.CLIENT) @SubscribeEvent(priority = EventPriority.NORMAL, receiveCanceled = true) public void onEvent(InputEvent.KeyInputEvent event) { if (itemIsHoldinHand.equals(ItemHoldInHand.NONE)) { //Do nothing if it is not hold return; } String keyBindingDescKey = "key.attack"; // make local copy of key binding array KeyBinding[] keyBindings = Minecraft.getMinecraft().gameSettings.keyBindings; for (KeyBinding binding : keyBindings) { if (keyBindingDescKey.equals(binding.getDescriptionKey()) && /*IMPORTANT to do this on second check because its counter based and will reset other key actions when it hits*/ binding.isPressed()) { return; } } } This code works well as the attack key is bound to a keyboard key like: R, A, ... But at default the attack key is bound to KeyCode: -100 (Left mouse button) But thats not the main problem, I knew that there is another event for catching mousecation like: @SideOnly(Side.CLIENT) @SubscribeEvent(priority = EventPriority.NORMAL, receiveCanceled = true) public void onEvent(InputEvent.MouseInputEvent event) { if (itemIsHoldinHand.equals(ItemHoldInHand.NONE)) { //Do nothing if it is not hold return; } ... String keyBindingDescKey = "key.attack"; // make local copy of key binding array KeyBinding[] keyBindings = Minecraft.getMinecraft().gameSettings.keyBindings; for (KeyBinding binding : keyBindings) { if (keyBindingDescKey.equals(binding.getDescriptionKey()) && /*This same pattern never hits....*/ binding.isPressed()) { return; } } } But doing the same thing as before results in nothing. Even trying to do: @SideOnly(Side.CLIENT) @SubscribeEvent(priority = EventPriority.NORMAL, receiveCanceled = true) public void onEvent(InputEvent.MouseInputEvent event) { if (itemIsHoldinHand.equals(ItemHoldInHand.NONE)) { //Do nothing if it is not hold return; } boolean isPressed = Minecraft.getMinecraft().gameSettings.keyBindAttack.isPressed(); if(isPressed){ System.out.println("Hell yeah"); } } Is getting me no result. So I am asking you guys . Is there any pattern, how to or possibility to access the left mouse click (user friendly) PS: I did add it to the EVENT_BUS MinecraftForge.EVENT_BUS.register(ModItems.ItemGun);
    1 point
×
×
  • Create New...

Important Information

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