Jump to content

Zee

Members
  • Posts

    11
  • Joined

  • Last visited

Zee's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. I double check the path, there is not problem with that. but i solve it. thx all. problem is here: ResourceLocation icon_party = new ResourceLocation(Reference.MODID, "textures/icon_party.png"); Should be: ResourceLocation icon_party = new ResourceLocation ( Reference.MODID + ":textures/icon_party.png"); //or ResourceLocation icon_party = new ResourceLocation ("<modid>:textures/icon_party.png");
  2. I already try that. It does not fix the texture. i add this line because, there was a drawString() before drawTexturedModalRect(). This is how i call this playInventoryLockGUI: public void onOpenGUI (GuiOpenEvent event) { GuiScreen gui = event.getGui(); if ( (gui instanceof GuiInventory) && (!(gui instanceof playInventoryLockGUI))){ gui = new playInventoryLockGUI(Reference.mc().thePlayer); event.setGui(gui); } }
  3. I added but still same, a purple square on screen.
  4. As title, when I use drawTexturedModalRect(), it draw a purple square on the screen. Could anyone tell me what's wrong with my code? public class playInventoryLockGUI extends GuiInventory { final ResourceLocation icon_party = new ResourceLocation(Reference.MODID, "textures/icon_party.png"); int u = 1; int v = 1; public playInventoryLockGUI(EntityPlayer player) { super(player); } @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { super.drawScreen(mouseX, mouseY, partialTicks); this.mc.renderEngine.bindTexture(icon_party); GlStateManager.color(2.0f, 2.0f, 2.0f); GlStateManager.pushMatrix(); { GlStateManager.scale(0.5f, 0.5f, 1f); drawTexturedModalRect(200, 200, u, v, 26, 26 ); } GlStateManager.popMatrix(); } } Screenshot: Texture:
  5. Thx Jay Avery and Animefan8888, both work perfect. @SubscribeEvent(priority = EventPriority.NORMAL) public void keyHotbar(KeyInputEvent event){ if (Reference.mc().gameSettings.keyBindDrop.isPressed() && (isInventorySlotlocked[Reference.mc().thePlayer.inventory.currentItem])){ } } @SubscribeEvent(priority = EventPriority.NORMAL) public void keyHotbarTest(KeyInputEvent event) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException{ if ((Keyboard.isKeyDown(Reference.mc().gameSettings.keyBindDrop.getKeyCode())) && (isInventorySlotlocked[Reference.mc().thePlayer.inventory.currentItem])){ Method unPressed_KeyBinding = Reference.mc().gameSettings.keyBindDrop.getClass().getDeclaredMethod("unpressKey"); unPressed_KeyBinding.setAccessible(true); unPressed_KeyBinding.invoke(Reference.mc().gameSettings.keyBindDrop); } }
  6. Thank you, diesieben07! KeyInputEvent work, but my code is a little bug. When i press "Q" all the key will be unpressed. @SubscribeEvent(priority = EventPriority.NORMAL) public void keyHotbar(KeyInputEvent event){ if ((Keyboard.isKeyDown(Reference.mc().gameSettings.keyBindDrop.getKeyCode())) && (isInventorySlotlocked[Reference.mc().thePlayer.inventory.currentItem])){ Reference.mc().gameSettings.keyBindDrop.unPressAllKeys(); } }
  7. It is client side only mod, it allow player lock they inventory. prevent player drop their item from their inventory accidental. Example if this player's hotbar 0 - 8 is marked as locked, then he cannot drop item from his hot bar by press "Q". I'm able to prevent player drop item in multiplayer, minecaft version 1.10 by using ItemTossEvent, but can't do that in 1.11
  8. I don't want it work on server side, I want cancel the key press event, when player press "Q" in client side. Value in boolean array are all true, which is not allow to drop items. boolean array: //--------------------------------------------------------------------------------------------- public static boolean [] isInventorySlotlocked = new boolean [41] public InventoryLock(){ this.InventroyLockInit(); } public static void InventroyLockInit (){ Arrays.fill(isInventorySlotlocked, true); } register: //--------------------------------------------------------------------------------------------- public class ClientProxy extends CommonProxy { @Override public void registerEvents(){ MinecraftForge.EVENT_BUS.register(new InventoryLock()); }
  9. I post first one accidental, I dont even know I posted it.
  10. I'm trying to prevent player press "Q" to drop from their hotbar. but i can only catch ItemTossEvent in single player. Forge Version: forge-1.11-13.19.1.2189 @SubscribeEvent public void guiHotbar(ItemTossEvent event){ EntityPlayer player = event.getPlayer(); if (isInventorySlotlocked[player.inventory.currentItem]){ event.setCanceled(true); } } Or Should I use KeyboardInputEvent in multiplayer? and how can i detect a key press and get its key value.
×
×
  • Create New...

Important Information

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