mojira.dev
MC-44331

Interacting with invalid villagers crashes the game

Trading with green villagers crashes the game 😞

---- Minecraft Crash Report ----
// Would you like a cupcake?

Time: 09.01.14 16:16
Description: Ticking memory connection

java.lang.ArrayIndexOutOfBoundsException: 5
	at yg.cf(SourceFile:357)
	at yg.c_(SourceFile:397)
	at ne.a(SourceFile:522)
	at yg.a(SourceFile:155)
	at sf.c(SourceFile:852)
	at yr.r(SourceFile:878)
	at np.a(SourceFile:613)
	at jh.a(SourceFile:55)
	at jh.a(SourceFile:10)
	at et.a(SourceFile:166)
	at nk.c(SourceFile:135)
	at net.minecraft.server.MinecraftServer.u(SourceFile:546)
	at net.minecraft.server.MinecraftServer.t(SourceFile:462)
	at bvc.t(SourceFile:123)
	at net.minecraft.server.MinecraftServer.run(SourceFile:380)
	at lr.run(SourceFile:648)


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

-- Head --
Stacktrace:
	at yg.cf(SourceFile:357)
	at yg.c_(SourceFile:397)
	at ne.a(SourceFile:522)
	at yg.a(SourceFile:155)
	at sf.c(SourceFile:852)
	at yr.r(SourceFile:878)
	at np.a(SourceFile:613)
	at jh.a(SourceFile:55)
	at jh.a(SourceFile:10)
	at et.a(SourceFile:166)

-- Ticking connection --
Details:
	Connection: et@1b28891c
Stacktrace:
	at nk.c(SourceFile:135)
	at net.minecraft.server.MinecraftServer.u(SourceFile:546)
	at net.minecraft.server.MinecraftServer.t(SourceFile:462)
	at bvc.t(SourceFile:123)
	at net.minecraft.server.MinecraftServer.run(SourceFile:380)
	at lr.run(SourceFile:648)

-- System Details --
Details:
	Minecraft Version: 14w02a
	Operating System: Windows 8 (amd64) version 6.2
	Java Version: 1.7.0_45, Oracle Corporation
	Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
	Memory: 5959963704 bytes (5683 MB) / 8565817344 bytes (8169 MB) up to 11453595648 bytes (10923 MB)
	JVM Flags: 3 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xms8G -Xmx12G
	IntCache: cache: 0, tcache: 0, allocated: 12, tallocated: 94
	Profiler Position: N/A (disabled)
	Player Count: 1 / 8; [ne['Galaxy_2Alex'/1467087, l='New World', x=-692,86, y=65,42, z=681,97]]
	Type: Integrated Server (map_client.txt)
	Is Modded: Probably not. Jar signature remains and both client + server brands are untouched.

Linked issues

Attachments

Comments 19

Can also confirm; this is a bit problematic for adventure maps which often use them. Also, if MC-24755 is true, then these can also exist in cheat-free maps.

Sample command to get one:

/summon Villager ~ ~ ~ {Profession:5}

The crash is because the game recognizes the profession only for texture purposes; the attached crash report occurs because the game tries looking up a nonexistent offer table (instead of aborting when it realizes no offers exist).

I find the "Renaming" bit a bit dubious; you can't rename villagers, and attempting to do so will just open up the offers interface (which will crash on a freshly-summoned green villager, as it will try generating offers). If a green villager has pre-existing offers, its default name will appear as "Villager", and giving them a CustomName doesn't cause issues either. It seems purely to be a trade issue.

It appears this was resolved by removing green villagers from the list of possible villager types. When attempting to summon one with Wolfie's code, you instead receive a farmer. This is because the numbers cycle through the available professions, and with green villagers removed, it cycles back to farmer. The texture still exists in the files, but it is now unused. I must honestly say I can not accept this as a valid solution. While normally inaccessible, they are extremely commonly used in custom maps and provide a sixth variation of villager to retexture as well. Not only does removing them impede uniqueness of trader, it limits a map makers variety of NPC.

If I am out of line, I'll accept that, but this resolution seems as if it'd cause more problems than resolving. If others agree this requires a proper resolution, be sure to speak up with your own valid reasoning.

Green Villagers did actually have a trade, but when they remade the whole system, they must have deleted their trades, their trade was allways 7-9 peaces of gold for a emerald.

9 more comments
/summon Villager ~ ~ ~ {Profession:-1}

gives

Description: Handling packet

java.lang.ArrayIndexOutOfBoundsException: -1
	at abq.cf(SourceFile:447)
	at abq.c_(SourceFile:487)
	at oh.a(SourceFile:583)
	at abq.a(SourceFile:205)
	at uk.e(SourceFile:833)
	at acc.t(SourceFile:894)
	at os.a(SourceFile:636)
	at kg.a(SourceFile:37)
	at kg.a(SourceFile:10)
	at fo.a(SourceFile:163)
	at on.c(SourceFile:134)
	at net.minecraft.server.MinecraftServer.w(SourceFile:580)
	at net.minecraft.server.MinecraftServer.v(SourceFile:496)
	at cis.v(SourceFile:132)
	at net.minecraft.server.MinecraftServer.run(SourceFile:412)
	at mu.run(SourceFile:682)

Hmmm likely some leftover code?

Green villagers were actually profession 5. So I'm not sure what's going on.
http://minecraft.gamepedia.com/Villager#Professions_and_Careers

My guess is like the wii says, the texture still exists but the villager has been removed - which is probably why the game crashes because there's nothing there to technically trade with.

No, simply omiting the range check of the profession for values from 0 .. 4.

I doubt this will be fixed as I don't see how it's valid. Not my call though.
This is unrelated but could you reopen MC-48535

Old Raccoon

migrated

Confirmed

crash

Minecraft 14w02a, Minecraft 14w02b, Minecraft 14w11b, Minecraft 14w17a

Minecraft 14w02c, Minecraft 14w20a

Retrieved