mojira.dev
MC-250939

Game crashes when a goat horn with an invalid sound variant is used / java.lang.ArrayIndexOutOfBoundsException: Index <index> out of bounds for length 8

When a player tries to play a goat horn with a sound variant of less than 0 or more than 7, the game crashes.

How to reproduce:

  1. Use the command: /give @s goat_horn{SoundVariant:8}

  2. Right click the goat horn you are given.

Stack trace:

Description: Unexpected error

java.lang.ArrayIndexOutOfBoundsException: Index 8 out of bounds for length 8
	at com.google.common.collect.RegularImmutableList.get(RegularImmutableList.java:77)
	at byb.a(SourceFile:93)
	at byl.a(SourceFile:276)
	at err.a(SourceFile:387)
	at err.a(SourceFile:278)
	at err.a(SourceFile:379)
	at edb.aS(SourceFile:1723)
	at edb.aU(SourceFile:1956)
	at edb.q(SourceFile:1783)
	at edb.f(SourceFile:1093)
	at edb.e(SourceFile:730)
	at net.minecraft.client.main.Main.main(SourceFile:237)

Attachments

Comments 3

Interestingly the additional line on the item works fine (shows the translation key for the variant); perhaps it would be best if invalid types just turn into sound variant 0.

Can confirm. Defining your own "item.goat_horn.sound.8" in sounds.json does not seem to avert this issue either.

Can confirm for negative sound variant values. Must have just forgotten to check if the index (in presumably a sounds array) is valid before trying to call and play the sound.

[Mod] ManosSef

slicedlime

Confirmed

Very Important

Crash

goat-horn

22w17a

22w18a

Retrieved