diff --git a/assets/mods/basegame/crafting/testrecipe.json b/assets/mods/basegame/crafting/testrecipe.json index f5c6bd7c5..a8eb4a4f8 100644 --- a/assets/mods/basegame/crafting/testrecipe.json +++ b/assets/mods/basegame/crafting/testrecipe.json @@ -2,21 +2,21 @@ "basegame:176": { /* A recipe for Wooden Platform */ "workbench": "", /* Optional workbench TAGS separated by commas (e.g. smelter, saw) */ "ingredients": [ /* Multiple ingredients denotes alternative recipes */ - [2, 1, "$WOOD", 1, "$ROCK"] /* This recipe only requires one Wooden Plank */ + [2, 1, "$WOOD", 5000, "$ROCK"] /* This recipe only requires one Wooden Plank */ ] }, "basegame:176": { /* alternative recipes can be added like this */ "workbench": "SOME_WORKBENCH", "ingredients": [ - [5, 1, "$ROCKWOOD"] + [5, 5000, "basegame:161"] ] }, "basegame:161": { "workbench": "", "ingredients": [ - [4, 1, "$WOOD"] + [4, 1, "$WOOD", 2, "$ROCK"] ] } } \ No newline at end of file diff --git a/assets/mods/basegame/items/itemid.csv b/assets/mods/basegame/items/itemid.csv index 710e683bb..fa7775389 100644 --- a/assets/mods/basegame/items/itemid.csv +++ b/assets/mods/basegame/items/itemid.csv @@ -7,5 +7,8 @@ id;classname 7;net.torvald.terrarum.modulebasegame.gameitems.WireGraphDebugger 8;net.torvald.terrarum.modulebasegame.gameitems.ItemLogicSignalEmitter 9;net.torvald.terrarum.modulebasegame.gameitems.WireCutterAll +10;net.torvald.terrarum.modulebasegame.gameitems.ItemTypewriter -999;net.torvald.terrarum.modulebasegame.gameitems.ItemTapestry + +999998;net.torvald.terrarum.modulebasegame.gameitems.ItemTestDoor +999999;net.torvald.terrarum.modulebasegame.gameitems.ItemTapestry diff --git a/assets/mods/basegame/sprites/fixtures/typewriter.tga b/assets/mods/basegame/sprites/fixtures/typewriter.tga new file mode 100644 index 000000000..404b70be8 --- /dev/null +++ b/assets/mods/basegame/sprites/fixtures/typewriter.tga @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0baeb8a3b7ccaf80e420e9ac14fb6bb8059384c4cdd5495188534ba1cbf9151b +size 24594 diff --git a/src/net/torvald/terrarum/modulebasegame/gameactors/FixtureTypewriter.kt b/src/net/torvald/terrarum/modulebasegame/gameactors/FixtureTypewriter.kt new file mode 100644 index 000000000..1c9d206c6 --- /dev/null +++ b/src/net/torvald/terrarum/modulebasegame/gameactors/FixtureTypewriter.kt @@ -0,0 +1,42 @@ +package net.torvald.terrarum.modulebasegame.gameactors + +import net.torvald.terrarum.gameactors.AVKey +import net.torvald.terrarum.langpack.Lang + +/** + * Created by minjaesong on 2022-08-26. + */ +class FixtureTypewriter : FixtureBase { + + var typewriterKeymapName = "us_qwerty" // used to control the keyboard input behaviour + private set + + private var carriagePosition = 0 + + // constructor used when new typewriter is created + constructor(keymapName: String) : this() { + typewriterKeymapName = keymapName + } + + // constructor used when the game loads from the savefile + constructor() : super( + BlockBox(BlockBox.NO_COLLISION, 1, 1), + nameFun = { Lang["ITEM_TYPEWRITER"] } + ) { + + density = 2000.0 + + setHitboxDimension(16, 16, 8, 0) + + makeNewSprite(FixtureBase.getSpritesheet("basegame", "sprites/fixtures/typewriter.tga", 32, 16)).let { + it.setRowsAndFrames(1,1) + } + + actorValue[AVKey.BASEMASS] = 3.6 + } + + companion object { + const val TYPEWRITER_COLUMNS = 64 + } + +} \ No newline at end of file diff --git a/src/net/torvald/terrarum/modulebasegame/gameitems/ItemTypewriter.kt b/src/net/torvald/terrarum/modulebasegame/gameitems/ItemTypewriter.kt new file mode 100644 index 000000000..bcd0a119b --- /dev/null +++ b/src/net/torvald/terrarum/modulebasegame/gameitems/ItemTypewriter.kt @@ -0,0 +1,30 @@ +package net.torvald.terrarum.modulebasegame.gameitems + +import com.badlogic.gdx.graphics.g2d.TextureRegion +import net.torvald.terrarum.gameitems.ItemID +import net.torvald.terrarum.itemproperties.Material +import net.torvald.terrarum.modulebasegame.gameactors.FixtureTikiTorch + +/** + * Created by minjaesong on 2022-08-26. + */ +class ItemTypewriter(originalID: ItemID) : FixtureItemBase(originalID, "net.torvald.terrarum.modulebasegame.gameactors.FixtureTypewriter") { + + override var dynamicID: ItemID = originalID + override val originalName = "ITEM_TYPEWRITER" + override var baseMass = FixtureTikiTorch.MASS + override var stackable = true + override var inventoryCategory = Category.MISC + override val isUnique = false + override val isDynamic = false + override val material = Material() + override val itemImage: TextureRegion + get() = getItemImageFromSheet("basegame", "sprites/fixtures/typewriter.tga", 32, 16) + + override var baseToolSize: Double? = baseMass + + init { + equipPosition = EquipPosition.HAND_GRIP + } + +} \ No newline at end of file diff --git a/src/net/torvald/terrarum/serialise/Common.kt b/src/net/torvald/terrarum/serialise/Common.kt index 6582ee997..57bb17e05 100644 --- a/src/net/torvald/terrarum/serialise/Common.kt +++ b/src/net/torvald/terrarum/serialise/Common.kt @@ -56,8 +56,8 @@ object Common { json.writeValue(obj?.toString()) } - override fun read(json: Json, jsonData: JsonValue, type: Class<*>?): BigInteger { - return BigInteger(jsonData.asString()) + override fun read(json: Json, jsonData: JsonValue, type: Class<*>?): BigInteger? { + return if (jsonData.isNull) null else BigInteger(jsonData.asString()) } }) // ZipCodedStr @@ -186,8 +186,8 @@ object Common { json.writeValue(obj.toString()) } - override fun read(json: Json, jsonData: JsonValue, type: Class<*>?): UUID { - return UUID.fromString(jsonData.asString()) + override fun read(json: Json, jsonData: JsonValue, type: Class<*>?): UUID? { + return if (jsonData.isNull) null else UUID.fromString(jsonData.asString()) } }) // HQRNG @@ -209,8 +209,8 @@ object Common { json.writeValue(bytesToZipdStr(obj.iterator())) } - override fun read(json: Json, jsonData: JsonValue, type: Class<*>?): ByteArray { - return strToBytes(StringReader(jsonData.asString())).toByteArray() + override fun read(json: Json, jsonData: JsonValue, type: Class<*>?): ByteArray? { + return if (jsonData.isNull) return null else strToBytes(StringReader(jsonData.asString())).toByteArray() } }) } diff --git a/work_files/graphics/sprites/fixtures/typewriter.kra b/work_files/graphics/sprites/fixtures/typewriter.kra new file mode 100644 index 000000000..5f04153ac --- /dev/null +++ b/work_files/graphics/sprites/fixtures/typewriter.kra @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d6acee84531bcf2a4fae6586e67227b8c54d8f3b6358ed131526b6973cc9d87e +size 118348