Jump to content

Recommended Posts

Posted (edited)

I looked at someone else's code, and was able to kind of figure it out, but I'm getting IndexOutOfBound Exceptions. 
 

public static class Factory implements IContainerFactory<CustomContainer> {

			@Override
			public CustomContainer create(int windowId, PlayerInventory playerInv, PacketBuffer extraData) {
				return new CustomContainer(windowId, getEntityFromBuf(extraData));
			}

			private CustomEntity getEntityFromBuf(PacketBuffer buf) {
				if (buf == null) {
					return null;
				}
				return DistExecutor.unsafeCallWhenOn(Dist.CLIENT, () -> () -> {
					Entity entity = Minecraft.getInstance().world.getEntityByID(buf.readVarInt());
					if (entity instanceof CustomEntity) {
						return (CustomEntity) entity;
					}
					return null;
				});
			}
		}

In case this is needed: 

public CustomContainer(int id, CustomEntity en) {
			super(RegistryHandler.Custom_CONTAINER.get(), id);
			this.en = en;
		}

And this is the stack trace

[m[1;31m[20:13:06] [Render thread/FATAL] [minecraft/ThreadTaskExecutor]: Error executing task on Client
java.lang.RuntimeException: java.lang.IndexOutOfBoundsException
	at net.minecraftforge.fml.DistExecutor.unsafeCallWhenOn(DistExecutor.java:76) ~[forge-1.16.1-32.0.75_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading}
	at com.david.test.entities.CustomEntity$CustomContainer$Factory.getEntityFromBuf(CustomEntity.java:212) ~[main/:?] {re:classloading}
	at com.david.test.entities.CustomEntity$CustomContainer$Factory.create(CustomEntity.java:205) ~[main/:?] {re:classloading}
	at com.david.test.entities.CustomEntity$CustomContainer$Factory.create(CustomEntity.java:1) ~[main/:?] {re:classloading}
	at net.minecraft.inventory.container.ContainerType.create(ContainerType.java:53) ~[forge-1.16.1-32.0.75_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraftforge.fml.network.FMLPlayMessages$OpenContainer.lambda$handle$0(FMLPlayMessages.java:285) ~[forge-1.16.1-32.0.75_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading}
	at java.util.Optional.ifPresent(Optional.java:183) ~[?:?] {}
	at net.minecraftforge.fml.network.FMLPlayMessages$OpenContainer.lambda$handle$1(FMLPlayMessages.java:284) ~[forge-1.16.1-32.0.75_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading}
	at net.minecraftforge.fml.network.NetworkEvent$Context.enqueueWork(NetworkEvent.java:215) ~[forge-1.16.1-32.0.75_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading}
	at net.minecraftforge.fml.network.FMLPlayMessages$OpenContainer.handle(FMLPlayMessages.java:282) ~[forge-1.16.1-32.0.75_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading}
	at net.minecraftforge.fml.network.simple.IndexedMessageCodec.lambda$tryDecode$3(IndexedMessageCodec.java:128) ~[forge-1.16.1-32.0.75_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading}
	at java.util.Optional.ifPresent(Optional.java:183) ~[?:?] {}
	at net.minecraftforge.fml.network.simple.IndexedMessageCodec.tryDecode(IndexedMessageCodec.java:128) ~[forge-1.16.1-32.0.75_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading}
	at net.minecraftforge.fml.network.simple.IndexedMessageCodec.consume(IndexedMessageCodec.java:162) ~[forge-1.16.1-32.0.75_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading}
	at net.minecraftforge.fml.network.simple.SimpleChannel.networkEventListener(SimpleChannel.java:80) ~[forge-1.16.1-32.0.75_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading}
	at net.minecraftforge.eventbus.EventBus.doCastFilter(EventBus.java:212) ~[eventbus-2.2.0-service.jar:?] {}
	at net.minecraftforge.eventbus.EventBus.lambda$addListener$11(EventBus.java:204) ~[eventbus-2.2.0-service.jar:?] {}
	at net.minecraftforge.eventbus.EventBus.post(EventBus.java:258) ~[eventbus-2.2.0-service.jar:?] {}
	at net.minecraftforge.fml.network.NetworkInstance.dispatch(NetworkInstance.java:84) ~[forge-1.16.1-32.0.75_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading}
	at net.minecraftforge.fml.network.NetworkHooks.lambda$onCustomPayload$1(NetworkHooks.java:73) ~[forge-1.16.1-32.0.75_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading}
	at java.util.Optional.map(Optional.java:265) ~[?:?] {}
	at net.minecraftforge.fml.network.NetworkHooks.onCustomPayload(NetworkHooks.java:73) ~[forge-1.16.1-32.0.75_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading}
	at net.minecraft.client.network.play.ClientPlayNetHandler.handleCustomPayload(ClientPlayNetHandler.java:2076) ~[forge-1.16.1-32.0.75_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.network.play.server.SCustomPayloadPlayPacket.processPacket(SCustomPayloadPlayPacket.java:68) ~[forge-1.16.1-32.0.75_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading}
	at net.minecraft.network.play.server.SCustomPayloadPlayPacket.processPacket(SCustomPayloadPlayPacket.java:11) ~[forge-1.16.1-32.0.75_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading}
	at net.minecraft.network.PacketThreadUtil.lambda$checkThreadAndEnqueue$0(PacketThreadUtil.java:19) ~[forge-1.16.1-32.0.75_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading}
	at net.minecraft.util.concurrent.ThreadTaskExecutor.run(ThreadTaskExecutor.java:139) ~[forge-1.16.1-32.0.75_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.util.concurrent.RecursiveEventLoop.run(RecursiveEventLoop.java:22) ~[forge-1.16.1-32.0.75_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading}
	at net.minecraft.util.concurrent.ThreadTaskExecutor.driveOne(ThreadTaskExecutor.java:109) ~[forge-1.16.1-32.0.75_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.util.concurrent.ThreadTaskExecutor.drainTasks(ThreadTaskExecutor.java:97) ~[forge-1.16.1-32.0.75_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:959) ~[forge-1.16.1-32.0.75_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.Minecraft.run(Minecraft.java:587) ~[forge-1.16.1-32.0.75_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.main.Main.main(Main.java:184) ~[forge-1.16.1-32.0.75_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] {}
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?] {}
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] {}
	at java.lang.reflect.Method.invoke(Method.java:567) ~[?:?] {}
	at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:55) ~[forge-1.16.1-32.0.75_mapped_snapshot_20200514-1.16-recomp.jar:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-5.1.2.jar:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-5.1.2.jar:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-5.1.2.jar:?] {}
	at cpw.mods.modlauncher.Launcher.run(Launcher.java:81) [modlauncher-5.1.2.jar:?] {}
	at cpw.mods.modlauncher.Launcher.main(Launcher.java:65) [modlauncher-5.1.2.jar:?] {}
	at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:105) [forge-1.16.1-32.0.75_mapped_snapshot_20200514-1.16-recomp.jar:?] {}
Caused by: java.lang.IndexOutOfBoundsException
	at io.netty.buffer.EmptyByteBuf.readByte(EmptyByteBuf.java:531) ~[netty-all-4.1.25.Final.jar:4.1.25.Final] {}
	at net.minecraft.network.PacketBuffer.readByte(PacketBuffer.java:790) ~[forge-1.16.1-32.0.75_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading}
	at net.minecraft.network.PacketBuffer.readVarInt(PacketBuffer.java:213) ~[forge-1.16.1-32.0.75_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading}
	at com.david.test.entities.CustomEntity$CustomContainer$Factory.lambda$1(CustomEntity.java:213) ~[main/:?] {re:classloading}
	at net.minecraftforge.fml.DistExecutor.unsafeCallWhenOn(DistExecutor.java:72) ~[forge-1.16.1-32.0.75_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading}
	... 43 more

I'm assuming its a problem with the method getting the CustomEntity from a PacketBuffer, but I have no idea what the problem is. 

Edited by DavidQF555
Posted
  • Give the code for when you open the Gui (the call to `NetworkHooks#openGui`). Your error is most likely from either not writing the data to the packet buffer, or calling the read and write methods of mismatched types (writeInt and readVarInt are two different methods with different effects).
     
  • You do not need to use DistExecutor. You already have an instance of PlayerInventory, which has a PlayerEntity in the `player` variable, which has the player's World in the `world` variable.
     
  • I suggest you inline your `getEntityFromBuf` method into the `create` method if there are no other classes calling that method, as it is unnecessary. I also suggest double-checking your code in CustomContainer, if there are places that will error if `null` is the entity passed into the constructor.
  • 10 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Just shows this if this is what you mean:  Data  assets/minecraft/models/item/bamboo_mosaic_slab.json  Data  assets/minecraft/models/item/turtle_helmet_quartz_trim.json  Processor failed, invalid outputs:    /home/aron/.minecraft/libraries/net/minecraft/client/1.20.1-20230612.114412/client-1.20.1-20230612.114412- slim.jar      Expected: de86b035d2da0f78940796bb95c39a932ed84834      Actual:   aea60124ca903ecbb2e825805e318f9d89ac867c    /home/aron/.minecraft/libraries/net/minecraft/client/1.20.1-20230612.114412/client-1.20.1-20230612.114412- extra.jar      Expected: 8c5a95cbce940cfdb304376ae9fea47968d02587      Actual:   76e87dbc119daed8dc1861c17160e0c4b6f34d2e There was an error during installation Also I gave the .jar file full permissions too.
    • I checked the hash like you said and it came back as OK each time, also may I ask what you mean by debug mode during installation?  
    • My name is Clara Bennett, and I almost let cryptocurrency destroy me.  Two years ago, after selling my green e-commerce startup, I plunged headfirst into the crypto world. yield farming , I was all in. I believed I wasn’t just investing; I was participating in the next great technological revolution. Within months, my portfolio skyrocketed to $200,000. I even started sketching ideas for a blockchain-based microloan platform to empower small entrepreneurs around the world. Crypto felt like pure freedom and limitless potential. I thought I was untouchable. I thought wrong. It happened through a single email. It looked like a standard security update from my wallet provider polished, routine, and harmless. I interacted with it briefly, thinking it was legitimate. Hours later, I checked my account and realized my entire wallet had been drained. Every token, every coin, gone. I sat there in disbelief, replaying the moment over and over. I had built my career on being cautious with technology, yet somehow, I had still been compromised. The blockchain’s promise of "irreversible transactions" now felt like a cruel joke  .Devastated and desperate, I scoured forums for solutions. Most people told me there was no hope once crypto is gone, it’s gone. Still, I refused to give up. That’s when I stumbled across FUNDS RETRIEVER ENGINEER . I decided to reach out. From the beginning, they were empathetic, and honest about the challenges. They explained their process step-by-step, focusing on tracing transactions, tracking down phishing operators, and leveraging advanced blockchain analytics. It wasn't an overnight fix. It took weeks of meticulous investigation, technical recovery work, and legal coordination .But in the end, their persistence paid off. FUNDS RETRIEVER ENGINEER  was able to trace the stolen funds across multiple wallets and exchanges. Through a combination of technical expertise and strategic action, they managed to recover the full amount I had lost. Today, my crypto portfolio is intact once again. More importantly, I’ve regained my confidence though I am now much wiser and far more cautious. I learned the hard way that while crypto offers incredible opportunities, it also demands extreme vigilance. Thanks to FUNDS RETRIEVER ENGINEER , I recovered my lost funds and  also reclaimed my future in the digital economy. For help  W H A T S A P P:  +1  8  0 2 9 5 2 3 4 7 0 E   m  a I L       F U N D S R  E T R  I E V E R  [@]  E  N  G  I  N  E  E  R.  C  O  M
    • 1. Did you try to remove your system cache or something? 2. Also check jar hash before installing (if it's ok): sha1sum jar_name.jar > jar_name.jar.sha1 sha1sum -c jar_name.jar.sha1 Do this a few times with some interval. This can find out if your hash can be different somehow (garbage files inside).  Also try using sha224sum / sha256sum / sha384sum / sha512sum / shasum. And do you have any debug mode during installation?   UPDATED: and it can be just fixing by chmod'ing jar file. Check its -lZ 
  • Topics

×
×
  • Create New...

Important Information

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