spawn item charges

This commit is contained in:
austin 2025-05-14 14:51:34 -04:00
parent 2f51269148
commit fec86048ed
5 changed files with 42 additions and 2 deletions

View File

@ -132,6 +132,15 @@
"model": {
"path" : "Models/objects/furniture/door1.glb"
}
},
"recipe" : {
"craftingTag" : "HAND",
"ingredients": [
{
"itemType": "mat:Log",
"count": 1
}
]
}
},
"furnitureData" : {

View File

@ -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

View File

@ -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;
}
}

View File

@ -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){

View File

@ -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);
}
}