Dragon Mounts: Legacy

Dragon Mounts: Legacy

20M Downloads

1.19.2 - No eggs appearing in chests

nicpasqua opened this issue ยท 6 comments

commented

I have changed the config file as necessary and still have not found any. I decided to test turning all of the spawn rates up to 100% and still have not come across a single one after checking 10 different structures.

commented

Can confirm that no eggs spawn on server when loot table is set to true for Minecraft 1.19.2.

Log:

 [Server thread/ERROR] [net.minecraft.network.protocol.PacketUtils/]: Failed to handle packet net.minecraft.network.protocol.game.ServerboundUseItemOnPacket@3a30ff15, suppressing error
java.lang.NullPointerException: Cannot invoke "net.minecraft.resources.ResourceLocation.toString()" because the return value of "com.github.kay9.dragonmounts.dragon.breed.DragonBreed.id()" is null
	at com.github.kay9.dragonmounts.dragon.DMLEggBlock$Item.create(DMLEggBlock.java:186) ~[dragonmounts-1.19.2-1.1.4a.jar%23112!/:1.19.2-1.1.4a]
	at com.github.kay9.dragonmounts.data.loot.DragonEggLootMod.doApply(DragonEggLootMod.java:33) ~[dragonmounts-1.19.2-1.1.4a.jar%23112!/:1.19.2-1.1.4a]
	at net.minecraftforge.common.loot.LootModifier.apply(LootModifier.java:58) ~[forge-1.19.2-43.1.1-universal.jar%23135!/:?]
	at net.minecraftforge.common.ForgeHooks.modifyLoot(ForgeHooks.java:1234) ~[forge-1.19.2-43.1.1-universal.jar%23135!/:?]
	at net.minecraft.world.level.storage.loot.LootTable.m_230922_(LootTable.java:90) ~[server-1.19.2-20220805.130853-srg.jar%23130!/:?]
	at net.minecraft.world.level.storage.loot.LootTable.m_79123_(LootTable.java:110) ~[server-1.19.2-20220805.130853-srg.jar%23130!/:?]
	at net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity.m_59640_(RandomizableContainerBlockEntity.java:82) ~[server-1.19.2-20220805.130853-srg.jar%23130!/:?]
	at net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity.m_7208_(RandomizableContainerBlockEntity.java:160) ~[server-1.19.2-20220805.130853-srg.jar%23130!/:?]
	at net.minecraft.server.level.ServerPlayer.m_5893_(ServerPlayer.java:966) ~[server-1.19.2-20220805.130853-srg.jar%23130!/:?]
	at net.minecraft.world.level.block.ChestBlock.m_6227_(ChestBlock.java:236) ~[server-1.19.2-20220805.130853-srg.jar%23130!/:?]
	at net.minecraft.world.level.block.state.BlockBehaviour$BlockStateBase.m_60664_(BlockBehaviour.java:714) ~[server-1.19.2-20220805.130853-srg.jar%23130!/:?]
	at net.minecraft.server.level.ServerPlayerGameMode.m_7179_(ServerPlayerGameMode.java:340) ~[server-1.19.2-20220805.130853-srg.jar%23130!/:?]
	at net.minecraft.server.network.ServerGamePacketListenerImpl.m_6371_(ServerGamePacketListenerImpl.java:1060) ~[server-1.19.2-20220805.130853-srg.jar%23130!/:?]
	at net.minecraft.network.protocol.game.ServerboundUseItemOnPacket.m_5797_(ServerboundUseItemOnPacket.java:34) ~[server-1.19.2-20220805.130853-srg.jar%23130!/:?]
	at net.minecraft.network.protocol.game.ServerboundUseItemOnPacket.m_5797_(ServerboundUseItemOnPacket.java:8) ~[server-1.19.2-20220805.130853-srg.jar%23130!/:?]
	at net.minecraft.network.protocol.PacketUtils.m_131356_(PacketUtils.java:22) ~[server-1.19.2-20220805.130853-srg.jar%23130!/:?]
	at net.minecraft.server.TickTask.run(TickTask.java:18) ~[server-1.19.2-20220805.130853-srg.jar%23130!/:?]
	at net.minecraft.util.thread.BlockableEventLoop.m_6367_(BlockableEventLoop.java:157) ~[server-1.19.2-20220805.130853-srg.jar%23130!/:?]
	at net.minecraft.util.thread.ReentrantBlockableEventLoop.m_6367_(ReentrantBlockableEventLoop.java:23) ~[server-1.19.2-20220805.130853-srg.jar%23130!/:?]
	at net.minecraft.server.MinecraftServer.m_6367_(MinecraftServer.java:763) ~[server-1.19.2-20220805.130853-srg.jar%23130!/:?]
	at net.minecraft.server.MinecraftServer.m_6367_(MinecraftServer.java:157) ~[server-1.19.2-20220805.130853-srg.jar%23130!/:?]
	at net.minecraft.util.thread.BlockableEventLoop.m_7245_(BlockableEventLoop.java:131) ~[server-1.19.2-20220805.130853-srg.jar%23130!/:?]
	at net.minecraft.server.MinecraftServer.m_129961_(MinecraftServer.java:746) ~[server-1.19.2-20220805.130853-srg.jar%23130!/:?]
	at net.minecraft.server.MinecraftServer.m_7245_(MinecraftServer.java:740) ~[server-1.19.2-20220805.130853-srg.jar%23130!/:?]
	at net.minecraft.util.thread.BlockableEventLoop.m_18701_(BlockableEventLoop.java:140) ~[server-1.19.2-20220805.130853-srg.jar%23130!/:?]
	at net.minecraft.server.MinecraftServer.m_130012_(MinecraftServer.java:726) ~[server-1.19.2-20220805.130853-srg.jar%23130!/:?]
	at net.minecraft.server.MinecraftServer.m_130011_(MinecraftServer.java:658) ~[server-1.19.2-20220805.130853-srg.jar%23130!/:?]
	at net.minecraft.server.MinecraftServer.m_206580_(MinecraftServer.java:244) ~[server-1.19.2-20220805.130853-srg.jar%23130!/:?]
	at java.lang.Thread.run(Thread.java:833) [?:?]

`
Steps to Reproduce:
Locate dungeon chest and open

Description of issue:
Upon open dungeon chest, server does not crash but gives above error and no loot is generated. Other attempts to locate dragon eggs has produced result this same error.

commented

Can confirm this also. No other mods in place.
Modded toml file to allow eggs in loot chests. Checked loads. No eggs

commented

I encountered this problem too. It seems BreedRegistry has not yet completed the dragon_breeds resources load when DragonEggLootMod is instantiated and hence the breed field of all DragonEggLootMod instances refers FIRE_BUILTIN. Possibly, the FIRE_BUILTIN instance is later replaced by the data from the dragon_breeds resources and so DragonBreed#id() returns null.

I applied following patch to the 119 branch and it works now.

diff --git a/src/main/java/com/github/kay9/dragonmounts/data/loot/DragonEggLootMod.java b/src/main/java/com/github/kay9/dragonmounts/data/loot/DragonEggLootMod.java
index 08cff35..4d69bb2 100644
--- a/src/main/java/com/github/kay9/dragonmounts/data/loot/DragonEggLootMod.java
+++ b/src/main/java/com/github/kay9/dragonmounts/data/loot/DragonEggLootMod.java
@@ -17,20 +17,27 @@ import org.jetbrains.annotations.NotNull;
 public class DragonEggLootMod extends LootModifier
 {
     public static final Codec<DragonEggLootMod> CODEC = RecordCodecBuilder.create(i -> codecStart(i)
-            .and(BreedRegistry.CODEC.fieldOf("breed").forGetter(m -> m.breed))
+            .and(Codec.STRING.fieldOf("breed").forGetter(DragonEggLootMod::getBreed))
             .apply(i, DragonEggLootMod::new));
 
-    private final DragonBreed breed;
+    private final String breed;
 
-    public DragonEggLootMod(LootItemCondition[] conditions, DragonBreed breed)
+    public DragonEggLootMod(LootItemCondition[] conditions, String breed)
     {
         super(conditions);
         this.breed = breed;
     }
 
+    public String getBreed() {
+        return breed;
+    }
+
     protected @NotNull ObjectArrayList<ItemStack> doApply(ObjectArrayList<ItemStack> generatedLoot, LootContext context)
     {
-        if (DMLConfig.useLootTables()) generatedLoot.add(DMLEggBlock.Item.create(breed, breed.hatchTime()));
+        if (DMLConfig.useLootTables()) {
+            DragonBreed breed = BreedRegistry.get(this.breed);
+            generatedLoot.add(DMLEggBlock.Item.create(breed, breed.hatchTime()));
+        }
         return generatedLoot;
     }
 
diff --git a/src/main/java/com/github/kay9/dragonmounts/data/providers/LootModifierProvider.java b/src/main/java/com/github/kay9/dragonmounts/data/providers/LootModifierProvider.java
index b6aed39..30948d0 100644
--- a/src/main/java/com/github/kay9/dragonmounts/data/providers/LootModifierProvider.java
+++ b/src/main/java/com/github/kay9/dragonmounts/data/providers/LootModifierProvider.java
@@ -44,6 +44,6 @@ class LootModifierProvider extends GlobalLootModifierProvider
                 LootItemRandomChanceCondition.randomChance(chance).build()
         };
 
-        super.add(path, new DragonEggLootMod(conditions, breed));
+        super.add(path, new DragonEggLootMod(conditions, breed.id().toString()));
     }
 }
commented

I encountered this problem too. It seems BreedRegistry has not yet completed the dragon_breeds resources load when DragonEggLootMod is instantiated and hence the breed field of all DragonEggLootMod instances refers FIRE_BUILTIN. Possibly, the FIRE_BUILTIN instance is later replaced by the data from the dragon_breeds resources and so DragonBreed#id() returns null.

I applied following patch to the 119 branch and it works now.

diff --git a/src/main/java/com/github/kay9/dragonmounts/data/loot/DragonEggLootMod.java b/src/main/java/com/github/kay9/dragonmounts/data/loot/DragonEggLootMod.java
index 08cff35..4d69bb2 100644
--- a/src/main/java/com/github/kay9/dragonmounts/data/loot/DragonEggLootMod.java
+++ b/src/main/java/com/github/kay9/dragonmounts/data/loot/DragonEggLootMod.java
@@ -17,20 +17,27 @@ import org.jetbrains.annotations.NotNull;
 public class DragonEggLootMod extends LootModifier
 {
     public static final Codec<DragonEggLootMod> CODEC = RecordCodecBuilder.create(i -> codecStart(i)
-            .and(BreedRegistry.CODEC.fieldOf("breed").forGetter(m -> m.breed))
+            .and(Codec.STRING.fieldOf("breed").forGetter(DragonEggLootMod::getBreed))
             .apply(i, DragonEggLootMod::new));
 
-    private final DragonBreed breed;
+    private final String breed;
 
-    public DragonEggLootMod(LootItemCondition[] conditions, DragonBreed breed)
+    public DragonEggLootMod(LootItemCondition[] conditions, String breed)
     {
         super(conditions);
         this.breed = breed;
     }
 
+    public String getBreed() {
+        return breed;
+    }
+
     protected @NotNull ObjectArrayList<ItemStack> doApply(ObjectArrayList<ItemStack> generatedLoot, LootContext context)
     {
-        if (DMLConfig.useLootTables()) generatedLoot.add(DMLEggBlock.Item.create(breed, breed.hatchTime()));
+        if (DMLConfig.useLootTables()) {
+            DragonBreed breed = BreedRegistry.get(this.breed);
+            generatedLoot.add(DMLEggBlock.Item.create(breed, breed.hatchTime()));
+        }
         return generatedLoot;
     }
 
diff --git a/src/main/java/com/github/kay9/dragonmounts/data/providers/LootModifierProvider.java b/src/main/java/com/github/kay9/dragonmounts/data/providers/LootModifierProvider.java
index b6aed39..30948d0 100644
--- a/src/main/java/com/github/kay9/dragonmounts/data/providers/LootModifierProvider.java
+++ b/src/main/java/com/github/kay9/dragonmounts/data/providers/LootModifierProvider.java
@@ -44,6 +44,6 @@ class LootModifierProvider extends GlobalLootModifierProvider
                 LootItemRandomChanceCondition.randomChance(chance).build()
         };
 
-        super.add(path, new DragonEggLootMod(conditions, breed));
+        super.add(path, new DragonEggLootMod(conditions, breed.id().toString()));
     }
 }

I encountered this problem too. It seems BreedRegistry has not yet completed the dragon_breeds resources load when DragonEggLootMod is instantiated and hence the breed field of all DragonEggLootMod instances refers FIRE_BUILTIN. Possibly, the FIRE_BUILTIN instance is later replaced by the data from the dragon_breeds resources and so DragonBreed#id() returns null.

I applied following patch to the 119 branch and it works now.

diff --git a/src/main/java/com/github/kay9/dragonmounts/data/loot/DragonEggLootMod.java b/src/main/java/com/github/kay9/dragonmounts/data/loot/DragonEggLootMod.java
index 08cff35..4d69bb2 100644
--- a/src/main/java/com/github/kay9/dragonmounts/data/loot/DragonEggLootMod.java
+++ b/src/main/java/com/github/kay9/dragonmounts/data/loot/DragonEggLootMod.java
@@ -17,20 +17,27 @@ import org.jetbrains.annotations.NotNull;
 public class DragonEggLootMod extends LootModifier
 {
     public static final Codec<DragonEggLootMod> CODEC = RecordCodecBuilder.create(i -> codecStart(i)
-            .and(BreedRegistry.CODEC.fieldOf("breed").forGetter(m -> m.breed))
+            .and(Codec.STRING.fieldOf("breed").forGetter(DragonEggLootMod::getBreed))
             .apply(i, DragonEggLootMod::new));
 
-    private final DragonBreed breed;
+    private final String breed;
 
-    public DragonEggLootMod(LootItemCondition[] conditions, DragonBreed breed)
+    public DragonEggLootMod(LootItemCondition[] conditions, String breed)
     {
         super(conditions);
         this.breed = breed;
     }
 
+    public String getBreed() {
+        return breed;
+    }
+
     protected @NotNull ObjectArrayList<ItemStack> doApply(ObjectArrayList<ItemStack> generatedLoot, LootContext context)
     {
-        if (DMLConfig.useLootTables()) generatedLoot.add(DMLEggBlock.Item.create(breed, breed.hatchTime()));
+        if (DMLConfig.useLootTables()) {
+            DragonBreed breed = BreedRegistry.get(this.breed);
+            generatedLoot.add(DMLEggBlock.Item.create(breed, breed.hatchTime()));
+        }
         return generatedLoot;
     }
 
diff --git a/src/main/java/com/github/kay9/dragonmounts/data/providers/LootModifierProvider.java b/src/main/java/com/github/kay9/dragonmounts/data/providers/LootModifierProvider.java
index b6aed39..30948d0 100644
--- a/src/main/java/com/github/kay9/dragonmounts/data/providers/LootModifierProvider.java
+++ b/src/main/java/com/github/kay9/dragonmounts/data/providers/LootModifierProvider.java
@@ -44,6 +44,6 @@ class LootModifierProvider extends GlobalLootModifierProvider
                 LootItemRandomChanceCondition.randomChance(chance).build()
         };
 
-        super.add(path, new DragonEggLootMod(conditions, breed));
+        super.add(path, new DragonEggLootMod(conditions, breed.id().toString()));
     }
 }

is there anyway i could get the fixed version of this?

commented

Duplicate of #99

commented

Ditto, any way to make this update available to the 1.19.2'ers?