fix: tool durability not decreasing; smelting recipe for quartz had bad value

This commit is contained in:
minjaesong
2024-02-11 02:09:52 +09:00
parent 87081b0a33
commit 273e56cb35
8 changed files with 12 additions and 15 deletions

View File

@@ -1,3 +0,0 @@
{
}

View File

@@ -52,6 +52,7 @@
"ITEM_PICK_STEEL": "Steel Pickaxe",
"ITEM_PICK_STONE": "Stone Pickaxe",
"ITEM_PICK_WOODEN": "Wooden Pickaxe",
"ITEM_ROCK_SALT": "Rock Salt",
"ITEM_SEED_BIRCH": "Birch Seeds",
"ITEM_SEED_EBONY": "Ebony Nuts",
"ITEM_SEED_OAK": "Oak Acorn",

View File

@@ -52,6 +52,7 @@
"ITEM_PICK_STEEL": "강철 곡괭이",
"ITEM_PICK_STONE": "돌 곡괭이",
"ITEM_PICK_WOODEN": "나무 곡괭이",
"ITEM_ROCK_SALT": "암염",
"ITEM_SEED_BIRCH": "백단 씨앗",
"ITEM_SEED_EBONY": "흑단 씨앗",
"ITEM_SEED_OAK": "도토리",

View File

@@ -3,6 +3,7 @@ package net.torvald.terrarum.gameitems
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.TextureRegion
import net.torvald.terrarum.*
import net.torvald.terrarum.App.printdbg
import net.torvald.terrarum.ReferencingRanges.PREFIX_ACTORITEM
import net.torvald.terrarum.ReferencingRanges.PREFIX_DYNAMICITEM
import net.torvald.terrarum.ReferencingRanges.PREFIX_VIRTUALTILE

View File

@@ -96,16 +96,9 @@ class ItemCodex {
* Returns the item in the Codex. If the item is static, its clone will be returned (you are free to modify the returned item).
* However, if the item is dynamic, the item itself will be returned.
*
* The returned object is a clone of the original object. Modifying fields will NOT affect the game.
* The returned object is mutable. Modifying fields WILL affect the game.
*/
operator fun get(code: ItemID?): GameItem? {
return get0(code)?.clone()
}
/**
* Same as `get` but the object is mutable.
*/
fun get0(code: ItemID?): GameItem? {
if (code == null) return null
if (code.startsWith("$PREFIX_DYNAMICITEM:"))
@@ -119,7 +112,7 @@ class ItemCodex {
}
else // generic item
return itemCodex[code] // from CSV
}
}
fun dynamicToStaticID(dynamicID: ItemID) = dynamicToStaticTable[dynamicID]!!
fun fixtureToItemID(fixture: FixtureBase) = fixtureToSpawnerItemID[fixture.javaClass.canonicalName]!!

View File

@@ -50,8 +50,8 @@ class EntryPoint : ModuleEntryPoint() {
// add smelting recipe for sands
BlockCodex.filter { it.hasTag("SAND") }.forEach { (itemID, _) ->
ItemCodex.get0(itemID)!!.tags.add("SMELTABLE")
ItemCodex.get0(itemID)!!.smeltingProduct = "basegame:148"
ItemCodex[itemID]!!.tags.add("SMELTABLE")
ItemCodex[itemID]!!.smeltingProduct = "basegame:148"
}
println("\n[Basegame.EntryPoint] Welcome back!")

View File

@@ -249,6 +249,10 @@ class FixtureSmelterBasic : FixtureBase, CraftingStation {
if (progress >= CALORIES_PER_ROASTING) {
val smeltingProduct = oreItemProp.smeltingProduct!!
// check if the item even exists
if (ItemCodex[smeltingProduct] == null) throw NullPointerException("No item prop for $smeltingProduct")
if (productItem == null)
productItem = InventoryPair(smeltingProduct, 1L)
else

View File

@@ -155,7 +155,7 @@ class OreLead(originalID: ItemID) : OreItemBase(originalID, true) {
class GemQuartz(originalID: ItemID) : OreItemBase(originalID, true) {
override var originalName = "ITEM_GEM_QUARTZ"
override var smeltingProduct: ItemID? = "item@basegame:149"
override var smeltingProduct: ItemID? = "basegame:149"
override val itemImage: TextureRegion
get() = CommonResourcePool.getAsItemSheet("basegame.items").get(13,6)
}