diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/LootPoolAppender.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/LootPoolAppender.kt index 1b473af22..9f1ff7ec8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/LootPoolAppender.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/LootPoolAppender.kt @@ -43,35 +43,14 @@ class LootPoolAppender(conditions: Array, pools: Stream> - private val forgeHooksLootContext by lazy { - val field = ForgeHooks::class.java.getDeclaredField("lootContext") - field.isAccessible = true - field - } - - private val lootTableContextConstructor by lazy { - val clazz = ForgeHooks::class.java.declaredClasses.firstOrNull { it.name.contains("LootTableContext") } ?: throw NoSuchElementException("Unable to find ForgeHooks\$LootTableContext!") - val constructor = clazz.getDeclaredConstructor(ResourceLocation::class.java, Boolean::class.java) - constructor.isAccessible = true - constructor - } - init { val serializer = Deserializers.createLootTableSerializer().create() - val notExistingLocation = ResourceLocation("null", "null") lootPoolCodec = Codec.list(Codec.PASSTHROUGH.flatXmap({ - val dequeueHolder = forgeHooksLootContext.get(null) as ThreadLocal> - val deque = dequeueHolder.get() ?: java.util.ArrayDeque() - dequeueHolder.set(deque) - try { - deque.push(lootTableContextConstructor.newInstance(notExistingLocation, true)) DataResult.success(serializer.fromJson(it.convert(JsonOps.INSTANCE).value, LootPool::class.java)) } catch(err: JsonSyntaxException) { DataResult.error { err.message } - } finally { - deque.pop() } }, { try {