Jump to content

[1.7.10] - Spawner won't accept EntityHorse


Palinator2

Recommended Posts

I have an Item which places a vanilla spawner and changes the spawner's "SpawnData" NBT to the prefered entity.

 

This works great for all mobs expect the entity EntityHorse (horses). Am I missing some required NBT tags?

 

Actual code:

 

private final void changeSpawnerEntityID(final TileEntityMobSpawner paramTileEntityMobSpawner) {
        if(null != paramTileEntityMobSpawner) {
            final MobSpawnerBaseLogic mobSpawnerBaseLogic = paramTileEntityMobSpawner.func_145881_a();
            if (mob.getEntityID().isEmpty()) {
                mobSpawnerBaseLogic.readFromNBT(null);
            } else {
                mobSpawnerBaseLogic.setEntityName(mob.getEntityID()); // "EntityHorse"
                if (mob.isSybType()) {
                    final NBTTagCompound spawnerNbt = new NBTTagCompound();
                    paramTileEntityMobSpawner.writeToNBT(spawnerNbt);
                    final NBTTagCompound entityNbt = spawnerNbt.getCompoundTag("SpawnData");
                    writeEntityToNbt(entityNbt);
                    spawnerNbt.setTag("SpawnData", entityNbt);
                    paramTileEntityMobSpawner.readFromNBT(spawnerNbt);
                }
            }
        }
    }

    private final void writeEntityToNbt(NBTTagCompound paramNBTTagCompound) {
        if (paramNBTTagCompound == null) {
            paramNBTTagCompound = new NBTTagCompound();
        }
        final String[] data = mob.getSubTypeKeys(); // { "i:Type:0", "i:Variant:256", "b:SkeletonTrap:0" }
        for (final String d : data) {
            final String[] a = d.split(":");// { "i", "Type", "0" } ...
            if (a.length == 3) {
                final String key = a[1];
                if ("i".equals(a[0])) {
                    final Integer value = Integer.parseInt(a[2]);
                    paramNBTTagCompound.setInteger(key,  value);
                } else if ("b".equals(a[0])) {
                    final Byte value = Byte.parseByte(a[2]);
                    paramNBTTagCompound.setByte(key,  value);
                }
            }
        }
    }

 

throws:

 

 

 

[17:21:48] [Client thread/FATAL]: Reported exception thrown!
net.minecraft.util.ReportedException: Rendering Block Entity
at net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher.renderTileEntityAt(SourceFile:107) ~[TileEntityRendererDispatcher.class:?]
at net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher.renderTileEntity(SourceFile:92) ~[TileEntityRendererDispatcher.class:?]
at net.minecraft.client.renderer.RenderGlobal.renderEntities(RenderGlobal.java:483) ~[RenderGlobal.class:?]
at net.minecraft.client.renderer.EntityRenderer.renderWorld(EntityRenderer.java:1224) ~[EntityRenderer.class:?]
at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1011) ~[EntityRenderer.class:?]
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1001) ~[Minecraft.class:?]
at net.minecraft.client.Minecraft.run(Minecraft.java:898) [Minecraft.class:?]
at net.minecraft.client.main.Main.main(SourceFile:148) [Main.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_51]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_51]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_51]
at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_51]
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?]
at GradleStart.main(Unknown Source) [start/:?]
Caused by: java.lang.NullPointerException
at net.minecraft.tileentity.MobSpawnerBaseLogic.func_98265_a(SourceFile:110) ~[MobSpawnerBaseLogic.class:?]
at net.minecraft.tileentity.MobSpawnerBaseLogic.func_98281_h(SourceFile:236) ~[MobSpawnerBaseLogic.class:?]
at net.minecraft.client.renderer.tileentity.TileEntityMobSpawnerRenderer.func_147517_a(SourceFile:20) ~[TileEntityMobSpawnerRenderer.class:?]
at net.minecraft.client.renderer.tileentity.TileEntityMobSpawnerRenderer.renderTileEntityAt(SourceFile:15) ~[TileEntityMobSpawnerRenderer.class:?]
at net.minecraft.client.renderer.tileentity.TileEntityMobSpawnerRenderer.renderTileEntityAt(SourceFile:10) ~[TileEntityMobSpawnerRenderer.class:?]
at net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher.renderTileEntityAt(SourceFile:100) ~[TileEntityRendererDispatcher.class:?]
... 15 more

 

 

Link to comment
Share on other sites

Do not call readFromNBT with a null argument, ever.

What do you have on line 110 of MobSpawnerBaseLogic?

 

readFromNBT(null) has been removed (was never called anyway ^^)

Line 110 of MobSpawnerBaseLogic is the original vanilla code (I haven't touched the spawner's logic in any way).

Every other mob (even the XPOrb entity) is easily set up in the spawner except the HorseEntity.

Link to comment
Share on other sites

I know it is vanilla code. But every decompile is slightly different. Line 110 is in a completely different method in my workspace.

 

Sure if you can tell me how I can find this out because line 110 in the compiled class file don't refer to line 110 in the source file and debugging the code with a breakpoint at the method and/or class is not working (the world keeps loading but newer gets to 100% so I can't play a world but anyway the breakpoints are ignored if I disable them and enable them after I entered a world and use the item to place the spawner and modify it).

 

Breakpoints in my own code work but not in the source class files.

Link to comment
Share on other sites

If you run again to generate the error in the console in Eclipse, then you can click on the line number in the error message to be taken to the place where the error occurred. Better yet, if you set a break point, then you can step through the offending code in the debugger to see what's what.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Link to comment
Share on other sites

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



×
×
  • Create New...

Important Information

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