• Recently Browsing

    No registered users viewing this page.

  • Posts

    • addButton(new Button(relX + 18, relY + 15, 5, 20, "PURGE", button -> PacketHandler.sendToServer(new PacketButtonClicked(tileEntity.getPos()))));  ????   if that's not right, im gonna snap
    • Was confused at first but I got that figured out! For those that find this thread in the future, parameters are as follows: blit(screenX, screenY, textureX, textureY, width, height)   Certainly. You'll have to excuse the non-cached reflection, I'm trying to at least have it work properly first private static final ResourceLocation HORSE_GUI_TEXTURES = new ResourceLocation("textures/gui/container/horse.png"); private static final Function<IInventory, Slot> SLOT_CREATOR = i -> new Slot(i, 2, 8, 54); @SubscribeEvent public static void addSlotServerSide(PlayerContainerEvent.Open event) { Container container = event.getContainer(); if (container instanceof HorseInventoryContainer) { addSlotToHorseContainer((HorseInventoryContainer) container, SLOT_CREATOR); } } @SubscribeEvent public static void addSlotClientSide(GuiOpenEvent event) { Screen screen = event.getGui(); if (screen instanceof HorseInventoryScreen) { addSlotToHorseContainer(((HorseInventoryScreen) screen).getContainer(), SLOT_CREATOR); } } private static void addSlotToHorseContainer(HorseInventoryContainer container, Function<IInventory, Slot> slotCreator) { try { Field fieldHorseInventory = HorseInventoryContainer.class.getDeclaredField("horseInventory"); IInventory horseInventory = (IInventory) ReflectionUtil.getFieldValue(fieldHorseInventory, container); addSlotReflectively(container, slotCreator.apply(horseInventory)); } catch (ReflectiveOperationException e) { e.printStackTrace(); } } private static void addSlotReflectively(Container container, Slot slot) { try { Method methodAddSlot = Container.class.getDeclaredMethod("addSlot", Slot.class); methodAddSlot.setAccessible(true); methodAddSlot.invoke(container, slot); } catch (ReflectiveOperationException e) { e.printStackTrace(); } } // Some rendering code... this works fine, irrelevant to the slot adding, figured I'd include it anyways @SubscribeEvent public static void renderExtraSlot(GuiContainerEvent.DrawBackground event) { ContainerScreen<?> screen = event.getGuiContainer(); if (screen instanceof HorseInventoryScreen) { GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F); Minecraft.getInstance().getTextureManager().bindTexture(HORSE_GUI_TEXTURES); int ySize = screen.getYSize(); int i = (screen.width - screen.getXSize()) / 2; int j = (screen.height - ySize) / 2; // screen x, screen y, texture x, texture y, width, height screen.blit(i + 7, j + 53, 0, ySize, 18, 18); } }   Relevant stacktrace(s): java.lang.ArrayIndexOutOfBoundsException: 2 at java.util.Arrays$ArrayList.set(Arrays.java:3846) ~[?:1.8.0_221] {} at net.minecraft.util.NonNullList.set(NonNullList.java:50) ~[forge-1.14.4-28.1.96_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading} at net.minecraft.inventory.Inventory.setInventorySlotContents(Inventory.java:114) ~[forge-1.14.4-28.1.96_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading} at net.minecraft.inventory.container.Slot.putStack(Slot.java:84) ~[forge-1.14.4-28.1.96_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading} at net.minecraft.inventory.container.Container.slotClick(Container.java:273) ~[forge-1.14.4-28.1.96_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading} at net.minecraft.client.multiplayer.PlayerController.windowClick(PlayerController.java:397) ~[forge-1.14.4-28.1.96_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.gui.screen.inventory.ContainerScreen.handleMouseClick(ContainerScreen.java:534) ~[forge-1.14.4-28.1.96_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.gui.screen.inventory.ContainerScreen.mouseReleased(ContainerScreen.java:501) ~[forge-1.14.4-28.1.96_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.MouseHelper.lambda$mouseButtonCallback$1(MouseHelper.java:93) ~[forge-1.14.4-28.1.96_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.gui.screen.Screen.wrapScreenError(Screen.java:441) ~[forge-1.14.4-28.1.96_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.MouseHelper.mouseButtonCallback(MouseHelper.java:91) ~[forge-1.14.4-28.1.96_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at org.lwjgl.glfw.GLFWMouseButtonCallbackI.callback(GLFWMouseButtonCallbackI.java:36) ~[lwjgl-glfw-3.2.2.jar:build 10] {} at org.lwjgl.system.JNI.invokeV(Native Method) ~[lwjgl-3.2.2.jar:build 10] {} at org.lwjgl.glfw.GLFW.glfwPollEvents(GLFW.java:3101) ~[lwjgl-glfw-3.2.2.jar:build 10] {} at net.minecraft.client.MainWindow.poll(MainWindow.java:403) ~[forge-1.14.4-28.1.96_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.MainWindow.update(MainWindow.java:273) ~[forge-1.14.4-28.1.96_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.updateDisplay(Minecraft.java:982) ~[forge-1.14.4-28.1.96_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:946) ~[forge-1.14.4-28.1.96_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.run(Minecraft.java:384) ~[forge-1.14.4-28.1.96_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.main.Main.main(Main.java:128) ~[forge-1.14.4-28.1.96_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_221] {} at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_221] {} at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_221] {} at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_221] {} at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:55) ~[forge-1.14.4-28.1.96_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-4.1.0.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-4.1.0.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-4.1.0.jar:?] {} at cpw.mods.modlauncher.Launcher.run(Launcher.java:81) [modlauncher-4.1.0.jar:?] {} at cpw.mods.modlauncher.Launcher.main(Launcher.java:65) [modlauncher-4.1.0.jar:?] {} at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:101) [forge-1.14.4-28.1.96_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {} -- Head -- Thread: Client thread Stacktrace: at java.util.Arrays$ArrayList.set(Arrays.java:3846) at net.minecraft.util.NonNullList.set(NonNullList.java:50) at net.minecraft.inventory.Inventory.setInventorySlotContents(Inventory.java:114) at net.minecraft.inventory.container.Slot.putStack(Slot.java:84) at net.minecraft.inventory.container.Container.slotClick(Container.java:273) at net.minecraft.client.multiplayer.PlayerController.windowClick(PlayerController.java:397) at net.minecraft.client.gui.screen.inventory.ContainerScreen.handleMouseClick(ContainerScreen.java:534) at net.minecraft.client.gui.screen.inventory.ContainerScreen.mouseReleased(ContainerScreen.java:501) at net.minecraft.client.MouseHelper.lambda$mouseButtonCallback$1(MouseHelper.java:93) -- Affected screen -- Details: Screen name: net.minecraft.client.gui.screen.inventory.HorseInventoryScreen Stacktrace: at net.minecraft.client.gui.screen.Screen.wrapScreenError(Screen.java:441) at net.minecraft.client.MouseHelper.mouseButtonCallback(MouseHelper.java:91) at org.lwjgl.glfw.GLFWMouseButtonCallbackI.callback(GLFWMouseButtonCallbackI.java:36) at org.lwjgl.system.JNI.invokeV(Native Method) at org.lwjgl.glfw.GLFW.glfwPollEvents(GLFW.java:3101) at net.minecraft.client.MainWindow.poll(MainWindow.java:403) at net.minecraft.client.MainWindow.update(MainWindow.java:273)   Worth noting that the listener class is annotated with @EventBusSubscriber(modid = MY_MOD_ID)
    • This does absolutely nothing. Nobody will ever call this method. Use @Override when you intend to override a method. If it gives you an error, you are not actually overriding.
    • Yes. Although distribution is the wrong word here. This is about logical sides (integrated server uses PlayerContainerEvent.Open).   I am not sure how you would approach it. Ideally you'd have to somehow tell the client where to put the slot. If other mods modify the same container in the same way, this could lead to the server and client adding the slots in different order.   Probably look at vanilla for examples.   Use the tt button in the formatting toolbar.   Post your code and the stacktrace.
    • I posted this already, but sure, I'll do it again. https://github.com/Draco18s/ReasonableRealism/blob/1.14.4/src/main/java/com/draco18s/industry/client/gui/FilterGuiContainer.java#L83 That line is what you put in the "send stuff to server here" location. Or I should say, a line like that. You'll have to massage it to fit your class names, data details, and so on.
  • Topics

  • Who's Online (See full list)