mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-12 19:44:05 +09:00
walls now work
This commit is contained in:
@@ -45,18 +45,15 @@ class ActorInventory(@Transient val actor: Pocketed, var maxCapacity: Int, var c
|
||||
init {
|
||||
}
|
||||
|
||||
fun add(itemID: ItemID, count: Int = 1) = if (ItemCodex[itemID] == null) throw NullPointerException("Item not found: "+itemID) else add(ItemCodex[itemID]!!, count)
|
||||
fun add(itemID: ItemID, count: Int = 1) {
|
||||
if (ItemCodex[itemID] == null)
|
||||
throw NullPointerException("Item not found: $itemID")
|
||||
else
|
||||
add(ItemCodex[itemID]!!, count)
|
||||
}
|
||||
fun add(item: GameItem, count: Int = 1) {
|
||||
|
||||
println("[ActorInventory] add $item, $count")
|
||||
|
||||
|
||||
// not wall-able walls
|
||||
if (item.inventoryCategory == GameItem.Category.WALL &&
|
||||
(!item.dynamicID.startsWith("wall@") || !BlockCodex[item.dynamicID.substring(5)].isWallable)) {
|
||||
throw IllegalArgumentException("Wall ID ${item.dynamicID} is not wall-able.")
|
||||
}
|
||||
|
||||
println("[ActorInventory] add-by-elem $item, $count")
|
||||
|
||||
// other invalid values
|
||||
if (count == 0)
|
||||
|
||||
@@ -78,7 +78,7 @@ object PlayerBuilderSigrid {
|
||||
CreateTileAtlas.tags.forEach { t, _ ->
|
||||
inventory.add(t, 9995)
|
||||
try {
|
||||
inventory.add("wall@"+t, 9995)
|
||||
inventory.add("wall@"+t, 9995) // this code will try to add nonexisting wall items, do not get surprised with NPEs
|
||||
}
|
||||
catch (e: Throwable) {
|
||||
System.err.println("[PlayerBuilder] $e")
|
||||
|
||||
Reference in New Issue
Block a user