Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.16.5] Help with custom container (error when put a item in an slot)
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 0
Luis_ST

[1.16.5] Help with custom container (error when put a item in an slot)

By Luis_ST, Tuesday at 04:15 PM in Modder Support

  • Reply to this topic
  • Start new topic
  • Prev
  • 1
  • 2
  • Next
  • Page 1 of 2  

Recommended Posts

Luis_ST    5

Luis_ST

Luis_ST    5

  • Diamond Finder
  • Luis_ST
  • Members
  • 5
  • 356 posts
Posted Tuesday at 04:15 PM

I have a custom container. which consists of a crafting part and a storage.

when i try to shift an item into the slot i got an error and i dont know why.

because my container theoretically consists of 28 chest slots and 9 crafting input slots and one crafting output.

so a total of 38 slots.

But if I use 38 as the size of the NonNullList in my tileentity, I get an ArrayIndexOutOfBoundsException.

I tried something and found out that my inventory has a size of 74 slots, but I only use 38 in the constructor of my container.

when i put an item in a slot i get an error:

according to the error, the slot has the id -999 which can not be

So why do I get this error and what's wrong with my container:

[17:11:27] [Render thread/FATAL] [minecraft/Minecraft]: Reported exception thrown!
net.minecraft.crash.ReportedException: Container click
	at net.minecraft.client.gui.screen.Screen.wrapScreenError(Screen.java:434) ~[forge-1.16.5-36.0.1_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.MouseHelper.mouseButtonCallback(MouseHelper.java:96) ~[forge-1.16.5-36.0.1_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.MouseHelper.lambda$null$4(MouseHelper.java:185) ~[forge-1.16.5-36.0.1_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.util.concurrent.ThreadTaskExecutor.execute(ThreadTaskExecutor.java:86) ~[forge-1.16.5-36.0.1_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.client.MouseHelper.lambda$registerCallbacks$5(MouseHelper.java:184) ~[forge-1.16.5-36.0.1_mapped_snapshot_20201028-1.16.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 com.mojang.blaze3d.systems.RenderSystem.flipFrame(RenderSystem.java:93) ~[forge-1.16.5-36.0.1_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.MainWindow.flipFrame(MainWindow.java:305) ~[forge-1.16.5-36.0.1_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1022) ~[forge-1.16.5-36.0.1_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.Minecraft.run(Minecraft.java:612) ~[forge-1.16.5-36.0.1_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.main.Main.main(Main.java:184) ~[forge-1.16.5-36.0.1_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] {}
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64) ~[?:?] {}
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] {}
	at java.lang.reflect.Method.invoke(Method.java:564) ~[?:?] {}
	at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:52) ~[forge-1.16.5-36.0.1_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-8.0.9.jar:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-8.0.9.jar:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-8.0.9.jar:?] {}
	at cpw.mods.modlauncher.Launcher.run(Launcher.java:82) [modlauncher-8.0.9.jar:?] {}
	at cpw.mods.modlauncher.Launcher.main(Launcher.java:66) [modlauncher-8.0.9.jar:?] {}
	at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:105) [forge-1.16.5-36.0.1_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {}
Caused by: java.lang.ArrayIndexOutOfBoundsException
[17:11:27] [Render thread/INFO] [STDOUT/]: [net.minecraft.util.registry.Bootstrap:printToSYSOUT:130]: ---- Minecraft Crash Report ----
// You should try our sister game, Minceraft!

Time: 23.02.21, 17:11
Description: Container click

java.lang.ArrayIndexOutOfBoundsException: null


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Thread: Render thread
Stacktrace:
	at net.minecraft.inventory.container.Container.slotClick(Container.java:182) ~[forge:?] {re:classloading}
-- Click info --
Details:
	Menu Type: cave:crafting_station
	Menu Class: net.luis.cave.common.inventory.container.CraftingStationContainer
	Slot Count: 74
	Slot: -999
	Button: 10
	Type: QUICK_CRAFT
Stacktrace:
	at net.minecraft.inventory.container.Container.slotClick(Container.java:182) ~[forge-1.16.5-36.0.1_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading}
	at net.minecraft.client.multiplayer.PlayerController.windowClick(PlayerController.java:409) ~[forge-1.16.5-36.0.1_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.gui.screen.inventory.ContainerScreen.handleMouseClick(ContainerScreen.java:558) ~[forge-1.16.5-36.0.1_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.gui.screen.inventory.ContainerScreen.mouseReleased(ContainerScreen.java:515) ~[forge-1.16.5-36.0.1_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.MouseHelper.lambda$mouseButtonCallback$1(MouseHelper.java:98) ~[forge-1.16.5-36.0.1_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.gui.screen.Screen.wrapScreenError(Screen.java:427) ~[forge-1.16.5-36.0.1_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.MouseHelper.mouseButtonCallback(MouseHelper.java:96) ~[forge-1.16.5-36.0.1_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.MouseHelper.lambda$null$4(MouseHelper.java:185) ~[forge-1.16.5-36.0.1_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.util.concurrent.ThreadTaskExecutor.execute(ThreadTaskExecutor.java:86) ~[forge-1.16.5-36.0.1_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.client.MouseHelper.lambda$registerCallbacks$5(MouseHelper.java:184) ~[forge-1.16.5-36.0.1_mapped_snapshot_20201028-1.16.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 com.mojang.blaze3d.systems.RenderSystem.flipFrame(RenderSystem.java:93) ~[forge-1.16.5-36.0.1_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.MainWindow.flipFrame(MainWindow.java:305) ~[forge-1.16.5-36.0.1_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1022) ~[forge-1.16.5-36.0.1_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.Minecraft.run(Minecraft.java:612) ~[forge-1.16.5-36.0.1_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.main.Main.main(Main.java:184) ~[forge-1.16.5-36.0.1_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] {}
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64) ~[?:?] {}
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] {}
	at java.lang.reflect.Method.invoke(Method.java:564) ~[?:?] {}
	at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:52) ~[forge-1.16.5-36.0.1_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-8.0.9.jar:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-8.0.9.jar:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-8.0.9.jar:?] {}
	at cpw.mods.modlauncher.Launcher.run(Launcher.java:82) [modlauncher-8.0.9.jar:?] {}
	at cpw.mods.modlauncher.Launcher.main(Launcher.java:66) [modlauncher-8.0.9.jar:?] {}
	at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:105) [forge-1.16.5-36.0.1_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {

 

  • Quote

Share this post


Link to post
Share on other sites

Draco18s    2414

Draco18s

Draco18s    2414

  • Reality Controller
  • Draco18s
  • Members
  • 2414
  • 15994 posts
Posted Tuesday at 04:33 PM

Post your code.

  • Quote

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Share this post


Link to post
Share on other sites

Luis_ST    5

Luis_ST

Luis_ST    5

  • Diamond Finder
  • Luis_ST
  • Members
  • 5
  • 356 posts
Posted Tuesday at 04:42 PM
6 minutes ago, Draco18s said:

Post your code.

container:

https://github.com/Luis-st/Forge-1.16.5-36.0.1-mdk/blob/main/forge-1.16.5-36.0.1-mdk/src/main/java/net/luis/cave/common/inventory/container/CraftingStationContainer.java

tileentity:

https://github.com/Luis-st/Forge-1.16.5-36.0.1-mdk/blob/main/forge-1.16.5-36.0.1-mdk/src/main/java/net/luis/cave/common/tileentity/CraftingStationTileEntity.java

 

I think these are all relevant classes

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7688

diesieben07

diesieben07    7688

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7688
  • 56257 posts
Posted Tuesday at 05:59 PM

The index calculation here is wrong: https://github.com/Luis-st/Forge-1.16.5-36.0.1-mdk/blob/b801410326b0e641c1e7e0a07136049f86ec0154/forge-1.16.5-36.0.1-mdk/src/main/java/net/luis/cave/common/inventory/container/CraftingStationContainer.java#L59

  • Quote

Share this post


Link to post
Share on other sites

Luis_ST    5

Luis_ST

Luis_ST    5

  • Diamond Finder
  • Luis_ST
  • Members
  • 5
  • 356 posts
Posted yesterday at 07:01 AM (edited)
13 hours ago, diesieben07 said:

The index calculation here is wrong:

okay thanks, i still have a problem i can't craft all items at once (with shift in the output slot).

I think it's because of the TransferStackInSlot method but what do I have to change?

https://github.com/Luis-st/Forge-1.16.5-36.0.1-mdk/blob/main/forge-1.16.5-36.0.1-mdk/src/main/java/net/luis/cave/common/inventory/container/CraftingStationContainer.java

 

general: when I shift items into an inventory, the item is always placed in the slot with the smallest index. Am I right ?

Edited yesterday at 07:04 AM by Luis_ST
  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7688

diesieben07

diesieben07    7688

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7688
  • 56257 posts
Posted yesterday at 08:23 AM
1 hour ago, Luis_ST said:

general: when I shift items into an inventory, the item is always placed in the slot with the smallest index. Am I right ?

You control how shift-clicking works using the transferStackInSlot method.

  • Quote

Share this post


Link to post
Share on other sites

Luis_ST    5

Luis_ST

Luis_ST    5

  • Diamond Finder
  • Luis_ST
  • Members
  • 5
  • 356 posts
Posted yesterday at 08:46 AM (edited)
22 minutes ago, diesieben07 said:

You control how shift-clicking works using the transferStackInSlot method.

i am trying to combine the methods of chestcontainer and the workbenchcontainer

 

another question about container.

in which class does minecraft create the creativ inventory? (edit: because I cannot find the class in the container package)

since i want to create a container with as many slots as possible i have already succeeded (the container has 200 slots).

but it looks a bit strange because of the width.

I would like to know how minecraft creates the creative inventory because it has the normal width and a scrollbar.

and i want to do something like that for a block

Edited yesterday at 08:47 AM by Luis_ST
  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7688

diesieben07

diesieben07    7688

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7688
  • 56257 posts
Posted yesterday at 11:13 AM
2 hours ago, Luis_ST said:

in which class does minecraft create the creativ inventory? (edit: because I cannot find the class in the container package)

CreativeScreen

 

2 hours ago, Luis_ST said:

I would like to know how minecraft creates the creative inventory because it has the normal width and a scrollbar.

and i want to do something like that for a block

You're in for a world of pain. The best way I know to achieve this is as follows:

  1. Add all the slots you would need.
  2. Position invisible slots off-screen (Slot#xPos = -999 or something like that).
  3. When scrolling, move the slots around so that they are in the correct position according the scroll position. Note that you must do this on client and server, so the client needs to send a packet to the server regarding the new scroll position.
  • Quote

Share this post


Link to post
Share on other sites

Luis_ST    5

Luis_ST

Luis_ST    5

  • Diamond Finder
  • Luis_ST
  • Members
  • 5
  • 356 posts
Posted yesterday at 12:43 PM
49 minutes ago, diesieben07 said:
  • Add all the slots you would need.
  • Position invisible slots off-screen (Slot#xPos = -999 or something like that).
  • When scrolling, move the slots around so that they are in the correct position according the scroll position.

okay thank you i think i should manage that somehow

 

one more question about the scrollbar

I looked into the vanilla container using a scrollbar (stonecutter container) and

if I understand correctly, the scrollbar is a graphic element. I don't have to add the scrollbar to the container.

if that's true how do i find out if the player moves the scrollbar?

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7688

diesieben07

diesieben07    7688

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7688
  • 56257 posts
Posted yesterday at 01:21 PM

The stonecutter doesn't have scrollable slots, just a scrollable area (you can't take the items in the scrollable area or put items in).

 

36 minutes ago, Luis_ST said:

if that's true how do i find out if the player moves the scrollbar?

Look at StonecutterScreen.

  • Thanks 1
  • Quote

Share this post


Link to post
Share on other sites

Luis_ST    5

Luis_ST

Luis_ST    5

  • Diamond Finder
  • Luis_ST
  • Members
  • 5
  • 356 posts
Posted yesterday at 02:35 PM
1 hour ago, diesieben07 said:

Look at StonecutterScreen.

thanks, I'll try the way you explained it

  • Quote

Share this post


Link to post
Share on other sites

Hippl    0

Hippl

Hippl    0

  • Tree Puncher
  • Hippl
  • Members
  • 0
  • 2 posts
Posted yesterday at 02:53 PM (edited)

GL

Edited yesterday at 02:53 PM by Hippl
  • Quote

Share this post


Link to post
Share on other sites

Luis_ST    5

Luis_ST

Luis_ST    5

  • Diamond Finder
  • Luis_ST
  • Members
  • 5
  • 356 posts
Posted 8 hours ago
On 2/24/2021 at 12:13 PM, diesieben07 said:
  • Add all the slots you would need.
  • Position invisible slots off-screen (Slot#xPos = -999 or something like that).

I have the container and the screen as you described it and it works (what I have created so far).

But now I'm stuck I don't know how to reposition the slots and how to sync this between server and client.

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7688

diesieben07

diesieben07    7688

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7688
  • 56257 posts
Posted 8 hours ago

Reposition the slots by changing their position.

Sync this, by sending a packet.

  • Quote

Share this post


Link to post
Share on other sites

Luis_ST    5

Luis_ST

Luis_ST    5

  • Diamond Finder
  • Luis_ST
  • Members
  • 5
  • 356 posts
Posted 8 hours ago
14 minutes ago, diesieben07 said:

Reposition the slots by changing their position.

Currently I am creating a new slot in my constructor with two for loops.

so it would be a good idea to save the slots in a slot array (maybe also in a two-dimensional array)?!

or is there a better way?

 

18 minutes ago, diesieben07 said:

Sync this, by sending a packet.

what kind of packet?

  • Quote

Share this post


Link to post
Share on other sites

Draco18s    2414

Draco18s

Draco18s    2414

  • Reality Controller
  • Draco18s
  • Members
  • 2414
  • 15994 posts
Posted 8 hours ago
2 minutes ago, Luis_ST said:

what kind of packet?

A custom one.

  • Quote

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Share this post


Link to post
Share on other sites

diesieben07    7688

diesieben07

diesieben07    7688

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7688
  • 56257 posts
Posted 8 hours ago
14 minutes ago, Luis_ST said:

so it would be a good idea to save the slots in a slot array (maybe also in a two-dimensional array)?!

Container#inventorySlots already exists.

  • Quote

Share this post


Link to post
Share on other sites

Luis_ST    5

Luis_ST

Luis_ST    5

  • Diamond Finder
  • Luis_ST
  • Members
  • 5
  • 356 posts
Posted 7 hours ago (edited)
31 minutes ago, Draco18s said:

A custom one.

okay thanks, i'll try this later, i need first a solution to the problem with repositioning the slots.

because I currently have no idea how to move the slots (I know how, but not how exactly, I'm thinking about how the methods should work that I want to use for this).

 

19 minutes ago, diesieben07 said:

Container#inventorySlots already exists.

would be a possibility but does not change the fact that every time the player uses the scrollbar I have to reposition 16 slots.

that's why i'm thinking about creating a slot group then i would only have to reposition two groups each time.

which would simplify the whole thing from my current point of view.

 

so every time I only have to check in which direction the bar was moved and then move the slot group in the same direction

 

1. is this a good solution / possible solution?

2. is there A better way to move many slots at once?

Edited 7 hours ago by Luis_ST
  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7688

diesieben07

diesieben07    7688

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7688
  • 56257 posts
Posted 7 hours ago

No, to move a number of slots you need to move all of them. There is no shortcut. Simply write a for loop.

  • Quote

Share this post


Link to post
Share on other sites

Luis_ST    5

Luis_ST

Luis_ST    5

  • Diamond Finder
  • Luis_ST
  • Members
  • 5
  • 356 posts
Posted 6 hours ago
1 hour ago, diesieben07 said:

No, to move a number of slots you need to move all of them. There is no shortcut. Simply write a for loop.

okay i found a way.

one more question do I have to create my own slot because posX and poxY are final in the slot class.

so i can't edit them

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7688

diesieben07

diesieben07    7688

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7688
  • 56257 posts
Posted 6 hours ago

You can do one of the following:

  • Make new Slot instances and replace the existing ones.
  • Set the fields using reflection.
  • Use an Access Transformer.
  • Quote

Share this post


Link to post
Share on other sites

Luis_ST    5

Luis_ST

Luis_ST    5

  • Diamond Finder
  • Luis_ST
  • Members
  • 5
  • 356 posts
Posted 6 hours ago
1 minute ago, diesieben07 said:
  • Make new Slot instances and replace the existing ones.
  • Set the fields using reflection.
  • Use an Access Transformer

i think it's easier to create my own slot

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7688

diesieben07

diesieben07    7688

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7688
  • 56257 posts
Posted 6 hours ago
Just now, Luis_ST said:

i think it's easier to create my own slot

Making your own Slot class will not magically make the fields not final. You cannot override fields.

  • Quote

Share this post


Link to post
Share on other sites

Luis_ST    5

Luis_ST

Luis_ST    5

  • Diamond Finder
  • Luis_ST
  • Members
  • 5
  • 356 posts
Posted 6 hours ago
1 minute ago, diesieben07 said:

Making your own Slot class will not magically make the fields not final. You cannot override fields.

this is exactly the problem i just ran into. i try reflection

  • Quote

Share this post


Link to post
Share on other sites

Luis_ST    5

Luis_ST

Luis_ST    5

  • Diamond Finder
  • Luis_ST
  • Members
  • 5
  • 356 posts
Posted 6 hours ago
7 minutes ago, diesieben07 said:

Making your own Slot class will not magically make the fields not final. You cannot override fields.

this should be correct right?

	private static final Field yPos = ObfuscationReflectionHelper.findField(Slot.class, "field_75221_f");
	
	private static void setSlotPosY(Slot slot, int newPosY) {
		
		yPos.setAccessible(true);
		try {
			
			yPos.setInt(slot, newPosY);
			
		} catch (IllegalArgumentException | IllegalAccessException e) {
			
			e.printStackTrace();
			
		}
		
	}

 

  • Quote

Share this post


Link to post
Share on other sites
  • Prev
  • 1
  • 2
  • Next
  • Page 1 of 2  

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

    • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 0
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • Centmap
      Forge Mods Folder

      By Centmap · Posted 41 minutes ago

      so i created a "1.16.5" folder in the folder "mod" as usual but it doesn't use the mods. Can anyone help me ?
    • Skyriis
      [SOLVED][1.16.5] Adding a Button to KeyBindings

      By Skyriis · Posted 1 hour ago

      That worked.   Here is my solution @SubscribeEvent public static void onOpenGui(final GuiScreenEvent.InitGuiEvent.Post event) { if (!(event.getGui() instanceof ControlsScreen)) return; final ControlsScreen controlsScreen = (ControlsScreen) event.getGui(); final KeyBindingList replacement = new KeyBindingListReplacement(controlsScreen, event.getGui().getMinecraft()); final KeyBindingList old = ObfuscationReflectionHelper.getPrivateValue(ControlsScreen.class, controlsScreen, "field_146494_r"); controlsScreen.getEventListeners().remove(old); ObfuscationReflectionHelper.setPrivateValue(ControlsScreen.class, controlsScreen, replacement, "field_146494_r"); try { Method addChildMethod = ObfuscationReflectionHelper.findMethod(Screen.class, "func_230481_d_", IGuiEventListener.class); addChildMethod.setAccessible(true); addChildMethod.invoke(controlsScreen, replacement); addChildMethod.setAccessible(false); } catch (IllegalAccessException | InvocationTargetException e) { e.printStackTrace(); } }  
    • DrCowiber
      Failed To Start Minecraft Server

      By DrCowiber · Posted 1 hour ago

      im using this run.sh file, which contains: java -Xmx6G -Xms6G -jar minecraft_server.1.16.5.jar --nogui Edit: When I first posted about this I was using the serverRun.jar, which the first log file I posted is what the output was
    • Tez
      [1.15.2] Couln't not resolve dependency: net.minecraftforge:forge:1.15.2-31.2.0:userdev

      By Tez · Posted 2 hours ago

      I'm new to mod coding so i've watch tutorial in youtube in setup workspace step i got this error , i've try many solutions to fix but it still not working try update gradle to 6.8.3 but still not working try update java and still not working too here's my stacktrace: Stacktrace
    • diesieben07
      Failed To Start Minecraft Server

      By diesieben07 · Posted 2 hours ago

      Please show how exactly you are starting the server.
  • Topics

    • Centmap
      0
      Forge Mods Folder

      By Centmap
      Started 41 minutes ago

    • Skyriis
      8
      [SOLVED][1.16.5] Adding a Button to KeyBindings

      By Skyriis
      Started 23 hours ago

    • DrCowiber
      8
      Failed To Start Minecraft Server

      By DrCowiber
      Started 21 hours ago

    • Tez
      0
      [1.15.2] Couln't not resolve dependency: net.minecraftforge:forge:1.15.2-31.2.0:userdev

      By Tez
      Started 2 hours ago

    • Mysterious minecrafter
      1
      game keeps crashing while initializings

      By Mysterious minecrafter
      Started 4 hours ago

  • Who's Online (See full list)

    • Centmap
    • redlynx
    • GermanBucket
    • smitokyo
    • KingBlake122308
    • Skyriis
    • sleepier
    • Zeher_Monkey
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.16.5] Help with custom container (error when put a item in an slot)
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community