From fec86048ed4d53372cc86ae880c2d27364422a1e Mon Sep 17 00:00:00 2001 From: austin Date: Wed, 14 May 2025 14:51:34 -0400 Subject: [PATCH] spawn item charges --- assets/Data/entity/objects/furniture.json | 9 +++++++++ docs/src/progress/renderertodo.md | 1 + .../data/common/item/SpawnItemDescription.java | 13 +++++++++++++ src/main/java/electrosphere/data/item/Item.java | 14 +++++++++++++- .../java/electrosphere/data/item/ItemDataMap.java | 7 ++++++- 5 files changed, 42 insertions(+), 2 deletions(-) diff --git a/assets/Data/entity/objects/furniture.json b/assets/Data/entity/objects/furniture.json index 35489fc6..88656000 100644 --- a/assets/Data/entity/objects/furniture.json +++ b/assets/Data/entity/objects/furniture.json @@ -132,6 +132,15 @@ "model": { "path" : "Models/objects/furniture/door1.glb" } + }, + "recipe" : { + "craftingTag" : "HAND", + "ingredients": [ + { + "itemType": "mat:Log", + "count": 1 + } + ] } }, "furnitureData" : { diff --git a/docs/src/progress/renderertodo.md b/docs/src/progress/renderertodo.md index c1a79913..801de6ac 100644 --- a/docs/src/progress/renderertodo.md +++ b/docs/src/progress/renderertodo.md @@ -1769,6 +1769,7 @@ Fix content serialization bug with attached items Fix playing audio without item defined in natural inventory panel Fix window framebuffer scrunching bug Recipes for spawn items defined in parent entity +Spawn items have stack/charge diff --git a/src/main/java/electrosphere/data/common/item/SpawnItemDescription.java b/src/main/java/electrosphere/data/common/item/SpawnItemDescription.java index 749a1655..045b8cae 100644 --- a/src/main/java/electrosphere/data/common/item/SpawnItemDescription.java +++ b/src/main/java/electrosphere/data/common/item/SpawnItemDescription.java @@ -23,6 +23,11 @@ public class SpawnItemDescription { */ RecipeData recipe; + /** + * The maximum stack of this item + */ + Integer maxStack; + /** * Gets the item icon for this spawn item * @return The item icon @@ -46,6 +51,14 @@ public class SpawnItemDescription { public RecipeData getRecipeData(){ return recipe; } + + /** + * Gets the maximum allowed stack of this item + * @return The maximum allowed stack + */ + public Integer getMaxStack(){ + return maxStack; + } } diff --git a/src/main/java/electrosphere/data/item/Item.java b/src/main/java/electrosphere/data/item/Item.java index 55b96f79..c4534593 100644 --- a/src/main/java/electrosphere/data/item/Item.java +++ b/src/main/java/electrosphere/data/item/Item.java @@ -35,6 +35,11 @@ public class Item extends CommonEntityType { */ static final int MAX_BLOCK_STACK = 250; + /** + * Default max stack for spawn items + */ + static final int SPAWN_ITEM_DEFAULT_MAX_STACK = 1; + /** * The array of default tokens for all items */ @@ -99,7 +104,14 @@ public class Item extends CommonEntityType { Item rVal = new Item(); rVal.setId("spawn:" + objectData.getId()); - rVal.setDisplayName(objectData.getDisplayName() + " Spawner"); + rVal.setDisplayName(objectData.getDisplayName()); + + //max stack + if(description.getMaxStack() != null){ + rVal.setMaxStack(description.getMaxStack()); + } else { + rVal.setMaxStack(Item.SPAWN_ITEM_DEFAULT_MAX_STACK); + } if(description.getItemIcon() != null){ diff --git a/src/main/java/electrosphere/data/item/ItemDataMap.java b/src/main/java/electrosphere/data/item/ItemDataMap.java index cdd13f9a..fdef65fc 100644 --- a/src/main/java/electrosphere/data/item/ItemDataMap.java +++ b/src/main/java/electrosphere/data/item/ItemDataMap.java @@ -23,6 +23,11 @@ import electrosphere.util.FileUtils; * A structure for efficiently looking up items */ public class ItemDataMap { + + /** + * Default product count for spawn item crafting recipes + */ + static final int SPAWN_ITEM_DEFAULT_PRODUCT_COUNT = 1; /** * The map of item id -> item data @@ -134,7 +139,7 @@ public class ItemDataMap { itemDataMap.putType(spawnItem.getId(), spawnItem); //add recipe if present if(objectData.getSpawnItem().getRecipeData() != null){ - RecipeData recipeData = RecipeData.createSpawnItemRecipe(objectData.getSpawnItem().getRecipeData(), spawnItem, 1); + RecipeData recipeData = RecipeData.createSpawnItemRecipe(objectData.getSpawnItem().getRecipeData(), spawnItem, ItemDataMap.SPAWN_ITEM_DEFAULT_PRODUCT_COUNT); recipeMap.registerRecipe(recipeData); } }