Look up resource templates at loot time instead of caching them on ResourceType

ResourceType.template was filled in the enum constructor, which can run
before ItemTemplate.templates is loaded, leaving it null. lootBuilding was
its only reader and threw on the first non-gold resource.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
MagicBotandClaude Opus 5.5 committed 2026-10-18 09:38:55 -04:00
1 parent ef6fe4aa5b
commit 875809efe0
2 files changed
+6 -4

No files matched your search

+6 -1
View File
@@ -218,7 +218,12 @@ public enum BuildingManager {
for (mbEnums.ResourceType resourceType : EnumSet.allOf(mbEnums.ResourceType.class)) {
if (!player.charItemManager.hasRoomInventory(resourceType.template.item_wt)) {
ItemTemplate resourceTemplate = ItemTemplate.templates.get(resourceType.templateID);
if (resourceTemplate == null)
continue;
if (!player.charItemManager.hasRoomInventory(resourceTemplate.item_wt)) {
ChatManager.chatSystemInfo(player, "You can not carry any more of that item.");
return false;
}
-3
View File
@@ -15,7 +15,6 @@ import engine.math.Vector2f;
import engine.math.Vector3f;
import engine.math.Vector3fImmutable;
import engine.objects.AbstractCharacter;
import engine.objects.ItemTemplate;
import engine.objects.Shrine;
import engine.objects.Zone;
import engine.powers.EffectsBase;
@@ -2763,7 +2762,6 @@ public class mbEnums {
public static HashMap<Integer, ResourceType> templateHashLookup = new HashMap<>();
public static HashMap<Integer, ResourceType> resourceHashLookup = new HashMap<>();
public int templateID;
public ItemTemplate template;
public int resourceHash;
public int templateHash;
public int deposit_limit;
@@ -2771,7 +2769,6 @@ public class mbEnums {
ResourceType(int templateID, int resourceHash, int templateHash, int deposit_limit, int mine_production) {
this.templateID = templateID;
this.template = ItemTemplate.templates.get(this.templateID);
this.resourceHash = resourceHash;
this.templateHash = templateHash;
this.deposit_limit = deposit_limit;