From a762635c7b79b6a7caff4f9c9b3cbcc94ec3e8fa Mon Sep 17 00:00:00 2001 From: thepigcat Date: Mon, 16 Dec 2024 23:04:03 +0100 Subject: [PATCH] improve bacteria format --- .../103d9f3f36b01595f1aa5172191e60eff02e6924 | 12 +- .../9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e | 4 +- .../nautec/models/block/laser_engraver.json | 219 ------------------ .../nautec/nautec/bacteria/cyanobacteria.json | 5 +- .../data/nautec/nautec/bacteria/empty.json | 5 +- .../nautec/nautec/bacteria/halobacteria.json | 5 +- .../nautec/nautec/bacteria/methanogens.json | 5 +- .../nautec/nautec/bacteria/thermophiles.json | 5 +- .../data/nautec/recipe/brown_polymer.json | 2 +- .../nautec/api/bacteria/Bacteria.java | 27 ++- .../content/bacteria/BacteriaStats.java | 2 +- .../content/bacteria/SimpleBacteria.java | 7 +- .../components/ComponentBacteriaStorage.java | 8 +- .../registries/NTBacteriaSerializers.java | 6 +- 14 files changed, 43 insertions(+), 269 deletions(-) delete mode 100644 src/generated/resources/assets/nautec/models/block/laser_engraver.json diff --git a/src/generated/resources/.cache/103d9f3f36b01595f1aa5172191e60eff02e6924 b/src/generated/resources/.cache/103d9f3f36b01595f1aa5172191e60eff02e6924 index ae51199f..42046eb3 100644 --- a/src/generated/resources/.cache/103d9f3f36b01595f1aa5172191e60eff02e6924 +++ b/src/generated/resources/.cache/103d9f3f36b01595f1aa5172191e60eff02e6924 @@ -1,9 +1,9 @@ -// 1.21.1 2024-12-15T19:56:36.86193986 Registries -11e8f3f3b45aef17b576f8e4300b9fae4cd6e280 data/nautec/nautec/bacteria/cyanobacteria.json -d4475a8b82f7770de97b81720473cecd8b4f2dbb data/nautec/nautec/bacteria/empty.json -bc60969c4b2a8b2f687868560505ee2c7ee85f06 data/nautec/nautec/bacteria/halobacteria.json -4322c5e7f092ccaf11c4339d235ec95a16127e0f data/nautec/nautec/bacteria/methanogens.json -e003902eea186523f2b67072664f3be16c394e45 data/nautec/nautec/bacteria/thermophiles.json +// 1.21.1 2024-12-16T23:03:28.632599872 Registries +81ae891c9f56e166f6748e3ee80edccaf52a3c73 data/nautec/nautec/bacteria/cyanobacteria.json +895816a71ba92ab2662725824d004e3c1a462196 data/nautec/nautec/bacteria/empty.json +ed5540fa74500b1db6f27d6c30eeac50ee4f8f9c data/nautec/nautec/bacteria/halobacteria.json +24a515c8c46fbb92431a9aad10ae4c8684ed142f data/nautec/nautec/bacteria/methanogens.json +5d152052e74ab6e5dc7a780c1e2af000469b6e6d data/nautec/nautec/bacteria/thermophiles.json d3949aab832fc1b72c2512c35586c2682dea4d4d data/nautec/worldgen/configured_feature/prismarine_sand_beach.json e9f0c0ce377bc6f731c3b36673e845152a53327d data/nautec/worldgen/configured_feature/prismarine_sand_ocean.json 685d14b2486e0da05c931e69fe78236dd9523cbf data/nautec/worldgen/placed_feature/prismarine_sand_beach.json diff --git a/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e b/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e index 5b661cbd..04268fb2 100644 --- a/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e +++ b/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e @@ -1,4 +1,4 @@ -// 1.21.1 2024-12-16T16:09:32.183077884 Recipes +// 1.21.1 2024-12-16T22:58:24.975013206 Recipes ebae64ded4bb31c5b0cf21d6f4a5df5c4bce9ab0 data/nautec/advancement/recipes/building_blocks/brown_polymer_block.json 056382c183d52a8f0d17b4992017b217f7444060 data/nautec/advancement/recipes/building_blocks/brown_polymer_from_block.json e1102abc52970c4638811a9f3aed423c343b2976 data/nautec/advancement/recipes/building_blocks/chiseled_dark_prismarine.json @@ -67,7 +67,7 @@ ba5f2ec03f05fc1f52d3c03f544988e459826d69 data/nautec/recipe/augmentation_station 1ed2e8bdcfab093c605a5a5f7c9fcd6c709be258 data/nautec/recipe/banner_from_brown_polymer.json a9c53478ce9eefdcdd917217c32a19cc7fe8344c data/nautec/recipe/bed_from_brown_polymer.json 8ed31c62db2e3f744332a5027d264e3758d46c82 data/nautec/recipe/book_from_brown_polymer.json -b2cb1d73b9e1e2104af451250ff4464197c45531 data/nautec/recipe/brown_polymer.json +1414dd3fe07a9bcdb87c1dcda433476089f02a10 data/nautec/recipe/brown_polymer.json 6818283cb29f588a3b5c60460db0ac59ff0c287e data/nautec/recipe/brown_polymer_block.json 8234eaba36308abfceeda4158ae8975eb16e3c0b data/nautec/recipe/brown_polymer_from_block.json 5d8fdeabdc238a5b557a2a159a9ccb30e723703b data/nautec/recipe/cast_iron_ingot.json diff --git a/src/generated/resources/assets/nautec/models/block/laser_engraver.json b/src/generated/resources/assets/nautec/models/block/laser_engraver.json deleted file mode 100644 index 7dede832..00000000 --- a/src/generated/resources/assets/nautec/models/block/laser_engraver.json +++ /dev/null @@ -1,219 +0,0 @@ -{ - "credit": "Made with Blockbench", - "textures": { - "1": "nautec:block/laser_engraver_holder", - "2": "nautec:block/charging_station", - "3": "nautec:block/charging_station1", - "particle": "nautec:block/charging_station" - }, - "elements": [ - { - "from": [0, 0, 2], - "to": [16, 2, 14], - "rotation": {"angle": 0, "axis": "x", "origin": [2, 2, 2]}, - "faces": { - "north": {"uv": [16, 4, 0, 6], "texture": "#2"}, - "east": {"uv": [0, 0, 12, 2], "texture": "#2"}, - "south": {"uv": [0, 0, 16, 2], "texture": "#2"}, - "west": {"uv": [4, 0, 16, 2], "texture": "#2"}, - "up": {"uv": [0, 4, 16, 16], "texture": "#2"}, - "down": {"uv": [0, 0, 16, 12], "texture": "#2"} - } - }, - { - "from": [10, 2, 4], - "to": [12, 4, 12], - "rotation": {"angle": 0, "axis": "x", "origin": [3, 4, 2]}, - "faces": { - "north": {"uv": [0, 8, 2, 6], "texture": "#1"}, - "east": {"uv": [0, 0, 8, 2], "texture": "#1"}, - "south": {"uv": [0, 0, 2, 2], "texture": "#1"}, - "west": {"uv": [8, 2, 0, 0], "texture": "#1"}, - "up": {"uv": [2, 8, 0, 0], "texture": "#1"}, - "down": {"uv": [0, 0, 2, 8], "texture": "#1"} - } - }, - { - "from": [6, 2, 10], - "to": [10, 4, 12], - "rotation": {"angle": 0, "axis": "x", "origin": [1, 4, 2]}, - "faces": { - "north": {"uv": [6, 2, 2, 0], "texture": "#1"}, - "east": {"uv": [0, 0, 2, 2], "texture": "#1"}, - "south": {"uv": [0, 0, 4, 2], "texture": "#1"}, - "west": {"uv": [0, 0, 2, 2], "texture": "#1"}, - "up": {"uv": [2, 2, 6, 0], "texture": "#1"}, - "down": {"uv": [0, 0, 4, 2], "texture": "#1"} - } - }, - { - "from": [6, 2, 4], - "to": [10, 4, 6], - "rotation": {"angle": 0, "axis": "x", "origin": [1, 4, -4]}, - "faces": { - "north": {"uv": [1, 8, 5, 6], "texture": "#1"}, - "east": {"uv": [0, 0, 2, 2], "texture": "#1"}, - "south": {"uv": [2, 6, 6, 8], "texture": "#1"}, - "west": {"uv": [0, 0, 2, 2], "texture": "#1"}, - "up": {"uv": [2, 8, 6, 6], "texture": "#1"}, - "down": {"uv": [0, 0, 4, 2], "texture": "#1"} - } - }, - { - "from": [4, 2, 4], - "to": [6, 4, 12], - "rotation": {"angle": 0, "axis": "x", "origin": [-3, 4, 2]}, - "faces": { - "north": {"uv": [6, 8, 8, 6], "texture": "#1"}, - "east": {"uv": [6, 8, 8, 0], "rotation": 90, "texture": "#1"}, - "south": {"uv": [0, 0, 2, 2], "texture": "#1"}, - "west": {"uv": [8, 0, 6, 8], "rotation": 90, "texture": "#1"}, - "up": {"uv": [8, 8, 6, 0], "texture": "#1"}, - "down": {"uv": [0, 0, 2, 8], "texture": "#1"} - } - }, - { - "from": [0, 0, 14], - "to": [16, 16, 16], - "rotation": {"angle": 0, "axis": "x", "origin": [16, 2, 16]}, - "faces": { - "north": {"uv": [0, 0, 16, 16], "texture": "#3"}, - "east": {"uv": [0, 0, 2, 16], "texture": "#3"}, - "south": {"uv": [0, 0, 16, 16], "texture": "#3"}, - "west": {"uv": [0, 0, 2, 16], "texture": "#3"}, - "up": {"uv": [0, 2, 16, 4], "texture": "#3"}, - "down": {"uv": [0, 2, 16, 4], "texture": "#3"} - } - }, - { - "from": [14, 0, 0], - "to": [16, 16, 2], - "rotation": {"angle": 0, "axis": "x", "origin": [16, 2, 2]}, - "faces": { - "north": {"uv": [1, 0, 3, 16], "texture": "#3"}, - "east": {"uv": [3, 0, 1, 16], "texture": "#3"}, - "south": {"uv": [2, 0, 0, 16], "texture": "#3"}, - "west": {"uv": [0, 0, 2, 16], "texture": "#3"}, - "up": {"uv": [3, 6, 1, 8], "texture": "#3"}, - "down": {"uv": [2, 2, 4, 4], "texture": "#3"} - } - }, - { - "from": [0, 0, 0], - "to": [2, 16, 2], - "rotation": {"angle": 0, "axis": "x", "origin": [2, 2, 2]}, - "faces": { - "north": {"uv": [13, 0, 15, 16], "texture": "#3"}, - "east": {"uv": [0, 0, 2, 16], "texture": "#3"}, - "south": {"uv": [13, 0, 15, 16], "texture": "#3"}, - "west": {"uv": [0, 0, 2, 16], "texture": "#3"}, - "up": {"uv": [3, 3, 1, 5], "texture": "#3"}, - "down": {"uv": [2, 2, 4, 4], "texture": "#3"} - } - }, - { - "from": [14, 14, 2], - "to": [16, 16, 14], - "rotation": {"angle": 0, "axis": "x", "origin": [16, 2, 4]}, - "faces": { - "north": {"uv": [0, 0, 2, 2], "texture": "#3"}, - "east": {"uv": [1, 0, 3, 12], "rotation": 90, "texture": "#3"}, - "south": {"uv": [0, 0, 2, 2], "texture": "#3"}, - "west": {"uv": [13, 1, 15, 13], "rotation": 90, "texture": "#3"}, - "up": {"uv": [3, 0, 1, 12], "texture": "#3"}, - "down": {"uv": [1, 0, 3, 12], "texture": "#3"} - } - }, - { - "from": [0, 14, 2], - "to": [2, 16, 14], - "rotation": {"angle": 0, "axis": "x", "origin": [2, 2, 4]}, - "faces": { - "north": {"uv": [1, 4, 3, 16], "rotation": 180, "texture": "#3"}, - "east": {"uv": [1, 15, 3, 3], "rotation": 90, "texture": "#3"}, - "south": {"uv": [1, 4, 3, 16], "rotation": 180, "texture": "#3"}, - "west": {"uv": [1, 12, 3, 0], "rotation": 90, "texture": "#3"}, - "up": {"uv": [1, 3, 3, 15], "rotation": 180, "texture": "#3"}, - "down": {"uv": [1, 4, 3, 16], "rotation": 180, "texture": "#3"} - } - }, - { - "from": [12, 14, 7], - "to": [14, 16, 9], - "rotation": {"angle": 0, "axis": "y", "origin": [12, 14, 7]}, - "faces": { - "north": {"uv": [13, 7, 15, 9], "texture": "#3"}, - "east": {"uv": [13, 7, 15, 9], "texture": "#3"}, - "south": {"uv": [13, 7, 15, 9], "texture": "#3"}, - "west": {"uv": [13, 7, 15, 9], "texture": "#3"}, - "up": {"uv": [13, 7, 15, 9], "texture": "#3"}, - "down": {"uv": [13, 7, 15, 9], "texture": "#3"} - } - }, - { - "from": [2, 14, 7], - "to": [4, 16, 9], - "rotation": {"angle": 0, "axis": "y", "origin": [4, 14, 7]}, - "faces": { - "north": {"uv": [1, 4, 3, 6], "texture": "#3"}, - "east": {"uv": [1, 4, 3, 6], "texture": "#3"}, - "south": {"uv": [1, 4, 3, 6], "texture": "#3"}, - "west": {"uv": [1, 4, 3, 6], "texture": "#3"}, - "up": {"uv": [1, 4, 3, 6], "texture": "#3"}, - "down": {"uv": [1, 4, 3, 6], "texture": "#3"} - } - }, - { - "from": [4, 14, 4], - "to": [6, 16, 12], - "rotation": {"angle": 0, "axis": "y", "origin": [4, 14, 4]}, - "faces": { - "north": {"uv": [1, 12, 3, 14], "texture": "#3"}, - "east": {"uv": [1, 3, 3, 11], "rotation": 90, "texture": "#3"}, - "south": {"uv": [0, 0, 2, 2], "texture": "#3"}, - "west": {"uv": [1, 5, 3, 13], "rotation": 90, "texture": "#3"}, - "up": {"uv": [15, 15, 13, 7], "texture": "#3"}, - "down": {"uv": [3, 3, 1, 11], "texture": "#3"} - } - }, - { - "from": [6, 14, 10], - "to": [10, 16, 12], - "rotation": {"angle": 0, "axis": "y", "origin": [4, 14, 9]}, - "faces": { - "north": {"uv": [1, 5, 3, 9], "rotation": 90, "texture": "#3"}, - "east": {"uv": [0, 0, 2, 2], "texture": "#3"}, - "south": {"uv": [1, 6, 3, 10], "rotation": 90, "texture": "#3"}, - "west": {"uv": [0, 0, 2, 2], "texture": "#3"}, - "up": {"uv": [1, 5, 3, 9], "rotation": 90, "texture": "#3"}, - "down": {"uv": [3, 5, 1, 9], "rotation": 90, "texture": "#3"} - } - }, - { - "from": [6, 14, 4], - "to": [10, 16, 6], - "rotation": {"angle": 0, "axis": "y", "origin": [4, 14, 3]}, - "faces": { - "north": {"uv": [3, 5, 1, 9], "rotation": 90, "texture": "#3"}, - "east": {"uv": [0, 0, 2, 2], "texture": "#3"}, - "south": {"uv": [1, 9, 3, 13], "rotation": 90, "texture": "#3"}, - "west": {"uv": [0, 0, 2, 2], "texture": "#3"}, - "up": {"uv": [3, 5, 1, 9], "rotation": 90, "texture": "#3"}, - "down": {"uv": [1, 6, 3, 10], "rotation": 90, "texture": "#3"} - } - }, - { - "from": [10, 14, 4], - "to": [12, 16, 12], - "rotation": {"angle": 0, "axis": "y", "origin": [10, 14, 9]}, - "faces": { - "north": {"uv": [0, 0, 2, 2], "texture": "#3"}, - "east": {"uv": [1, 3, 3, 11], "rotation": 90, "texture": "#3"}, - "south": {"uv": [1, 0, 3, 2], "texture": "#3"}, - "west": {"uv": [1, 4, 3, 12], "rotation": 90, "texture": "#3"}, - "up": {"uv": [1, 2, 3, 10], "texture": "#3"}, - "down": {"uv": [1, 2, 3, 10], "texture": "#3"} - } - } - ] -} \ No newline at end of file diff --git a/src/generated/resources/data/nautec/nautec/bacteria/cyanobacteria.json b/src/generated/resources/data/nautec/nautec/bacteria/cyanobacteria.json index 9a973a7e..17b8b0f1 100644 --- a/src/generated/resources/data/nautec/nautec/bacteria/cyanobacteria.json +++ b/src/generated/resources/data/nautec/nautec/bacteria/cyanobacteria.json @@ -1,12 +1,11 @@ { "type": "nautec:simple", - "id": "nautec:cyanobacteria", "stats": { - "type": "minecraft:iron_ingot", "color": -13434881, "growth_rate": 0.0, "lifespan": 0, "mutation_resistance": 0.0, - "production_rate": 0.0 + "production_rate": 0.0, + "resource": "minecraft:iron_ingot" } } \ No newline at end of file diff --git a/src/generated/resources/data/nautec/nautec/bacteria/empty.json b/src/generated/resources/data/nautec/nautec/bacteria/empty.json index dd2dab64..c6a735da 100644 --- a/src/generated/resources/data/nautec/nautec/bacteria/empty.json +++ b/src/generated/resources/data/nautec/nautec/bacteria/empty.json @@ -1,12 +1,11 @@ { "type": "nautec:simple", - "id": "nautec:empty", "stats": { - "type": "minecraft:air", "color": 0, "growth_rate": 0.0, "lifespan": 0, "mutation_resistance": 0.0, - "production_rate": 0.0 + "production_rate": 0.0, + "resource": "minecraft:air" } } \ No newline at end of file diff --git a/src/generated/resources/data/nautec/nautec/bacteria/halobacteria.json b/src/generated/resources/data/nautec/nautec/bacteria/halobacteria.json index c3132da7..65504394 100644 --- a/src/generated/resources/data/nautec/nautec/bacteria/halobacteria.json +++ b/src/generated/resources/data/nautec/nautec/bacteria/halobacteria.json @@ -1,12 +1,11 @@ { "type": "nautec:simple", - "id": "nautec:halobacteria", "stats": { - "type": "minecraft:gold_ingot", "color": -6912, "growth_rate": 0.0, "lifespan": 0, "mutation_resistance": 0.0, - "production_rate": 0.0 + "production_rate": 0.0, + "resource": "minecraft:gold_ingot" } } \ No newline at end of file diff --git a/src/generated/resources/data/nautec/nautec/bacteria/methanogens.json b/src/generated/resources/data/nautec/nautec/bacteria/methanogens.json index 34dcce06..49a730c4 100644 --- a/src/generated/resources/data/nautec/nautec/bacteria/methanogens.json +++ b/src/generated/resources/data/nautec/nautec/bacteria/methanogens.json @@ -1,12 +1,11 @@ { "type": "nautec:simple", - "id": "nautec:methanogens", "stats": { - "type": "minecraft:cooked_beef", "color": -1328403, "growth_rate": 0.0, "lifespan": 0, "mutation_resistance": 0.0, - "production_rate": 0.0 + "production_rate": 0.0, + "resource": "minecraft:cooked_beef" } } \ No newline at end of file diff --git a/src/generated/resources/data/nautec/nautec/bacteria/thermophiles.json b/src/generated/resources/data/nautec/nautec/bacteria/thermophiles.json index 39beb56a..c58cc991 100644 --- a/src/generated/resources/data/nautec/nautec/bacteria/thermophiles.json +++ b/src/generated/resources/data/nautec/nautec/bacteria/thermophiles.json @@ -1,12 +1,11 @@ { "type": "nautec:simple", - "id": "nautec:thermophiles", "stats": { - "type": "minecraft:lava_bucket", "color": -65536, "growth_rate": 0.0, "lifespan": 0, "mutation_resistance": 0.0, - "production_rate": 0.0 + "production_rate": 0.0, + "resource": "minecraft:lava_bucket" } } \ No newline at end of file diff --git a/src/generated/resources/data/nautec/recipe/brown_polymer.json b/src/generated/resources/data/nautec/recipe/brown_polymer.json index cbe924dd..a739c16d 100644 --- a/src/generated/resources/data/nautec/recipe/brown_polymer.json +++ b/src/generated/resources/data/nautec/recipe/brown_polymer.json @@ -10,7 +10,7 @@ } ], "result": { - "count": 1, + "count": 2, "id": "nautec:brown_polymer" } } \ No newline at end of file diff --git a/src/main/java/com/portingdeadmods/nautec/api/bacteria/Bacteria.java b/src/main/java/com/portingdeadmods/nautec/api/bacteria/Bacteria.java index e749d8f7..dc0334bb 100644 --- a/src/main/java/com/portingdeadmods/nautec/api/bacteria/Bacteria.java +++ b/src/main/java/com/portingdeadmods/nautec/api/bacteria/Bacteria.java @@ -4,28 +4,31 @@ import com.portingdeadmods.nautec.NTRegistries; import com.portingdeadmods.nautec.content.bacteria.BacteriaStats; import com.portingdeadmods.nautec.content.bacteria.SimpleBacteria; +import io.netty.buffer.ByteBuf; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.codec.ByteBufCodecs; import net.minecraft.network.codec.StreamCodec; +import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.Items; +/** +Bacteria! We begin with only one! +Bacteria! Two's what we then become! +Bacteria! Each of us becomes two more! +Bacteria! We are stronger than before! +Bacteria! We keep growing at this rate! +Bacteria! No longer shall we wait! +Bacteria! The plan now unfolds! +Bacteria! We will take over the world! + */ public interface Bacteria { + Codec> BACTERIA_TYPE_CODEC = ResourceKey.codec(NTRegistries.BACTERIA_KEY); + StreamCodec> BACTERIA_TYPE_STREAM_CODEC = ResourceKey.streamCodec(NTRegistries.BACTERIA_KEY); + Codec CODEC = NTRegistries.BACTERIA_SERIALIZER.byNameCodec().dispatch(Bacteria::getSerializer, BacteriaSerializer::mapCodec); StreamCodec STREAM_CODEC = ByteBufCodecs.registry(NTRegistries.BACTERIA_SERIALIZER_KEY).dispatch(Bacteria::getSerializer, BacteriaSerializer::streamCodec); - /* - Bacteria! We begin with only one! - Bacteria! Two's what we then become! - Bacteria! Each of us becomes two more! - Bacteria! We are stronger than before! - Bacteria! We keep growing at this rate! - Bacteria! No longer shall we wait! - Bacteria! The plan now unfolds! - Bacteria! We will take over the world! - */ - ResourceLocation id(); - BaseBacteriaStats stats(); BacteriaSerializer getSerializer(); diff --git a/src/main/java/com/portingdeadmods/nautec/content/bacteria/BacteriaStats.java b/src/main/java/com/portingdeadmods/nautec/content/bacteria/BacteriaStats.java index 5ba8fe92..4b3f3aec 100644 --- a/src/main/java/com/portingdeadmods/nautec/content/bacteria/BacteriaStats.java +++ b/src/main/java/com/portingdeadmods/nautec/content/bacteria/BacteriaStats.java @@ -20,7 +20,7 @@ public record BacteriaStats(Item resource, int color) implements BaseBacteriaStats { public static final Codec CODEC = RecordCodecBuilder.create( instance -> instance.group( - CodecUtils.ITEM_CODEC.fieldOf("type").forGetter(BacteriaStats::resource), + CodecUtils.ITEM_CODEC.fieldOf("resource").forGetter(BacteriaStats::resource), Codec.FLOAT.fieldOf("growth_rate").forGetter(BacteriaStats::growthRate), Codec.FLOAT.fieldOf("mutation_resistance").forGetter(BacteriaStats::mutationResistance), Codec.FLOAT.fieldOf("production_rate").forGetter(BacteriaStats::productionRate), diff --git a/src/main/java/com/portingdeadmods/nautec/content/bacteria/SimpleBacteria.java b/src/main/java/com/portingdeadmods/nautec/content/bacteria/SimpleBacteria.java index 048f26a2..804f3893 100644 --- a/src/main/java/com/portingdeadmods/nautec/content/bacteria/SimpleBacteria.java +++ b/src/main/java/com/portingdeadmods/nautec/content/bacteria/SimpleBacteria.java @@ -10,7 +10,7 @@ import net.minecraft.world.item.Item; import net.minecraft.world.item.Items; -public record SimpleBacteria(ResourceLocation id, BacteriaStats stats) implements Bacteria { +public record SimpleBacteria(BacteriaStats stats) implements Bacteria { public static Builder of() { return new Builder(); } @@ -23,12 +23,9 @@ public BacteriaSerializer getSerializer() { public static final class Serializer implements BacteriaSerializer { public static final Serializer INSTANCE = new Serializer(); public static final MapCodec MAP_CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group( - ResourceLocation.CODEC.fieldOf("id").forGetter(SimpleBacteria::id), BacteriaStats.CODEC.fieldOf("stats").forGetter(SimpleBacteria::stats) ).apply(instance, SimpleBacteria::new)); public static final StreamCodec STREAM_CODEC = StreamCodec.composite( - ResourceLocation.STREAM_CODEC, - SimpleBacteria::id, BacteriaStats.STREAM_CODEC, SimpleBacteria::stats, SimpleBacteria::new @@ -87,7 +84,7 @@ public Builder color(int color) { } public Bacteria build(ResourceLocation location) { - return new SimpleBacteria(location, new BacteriaStats(resource, growthRate, mutationResistance, productionRate, lifespan, color)); + return new SimpleBacteria(new BacteriaStats(resource, growthRate, mutationResistance, productionRate, lifespan, color)); } } } diff --git a/src/main/java/com/portingdeadmods/nautec/data/components/ComponentBacteriaStorage.java b/src/main/java/com/portingdeadmods/nautec/data/components/ComponentBacteriaStorage.java index d4bc8364..e010e238 100644 --- a/src/main/java/com/portingdeadmods/nautec/data/components/ComponentBacteriaStorage.java +++ b/src/main/java/com/portingdeadmods/nautec/data/components/ComponentBacteriaStorage.java @@ -5,24 +5,22 @@ import com.portingdeadmods.nautec.NTRegistries; import com.portingdeadmods.nautec.api.bacteria.Bacteria; import com.portingdeadmods.nautec.registries.NTBacterias; -import com.portingdeadmods.nautec.utils.BacteriaHelper; -import net.minecraft.core.HolderLookup; +import io.netty.buffer.ByteBuf; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.codec.ByteBufCodecs; import net.minecraft.network.codec.StreamCodec; import net.minecraft.resources.ResourceKey; import java.util.Objects; -import java.util.function.Function; public record ComponentBacteriaStorage(ResourceKey bacteria, long bacteriaAmount) { public static final ComponentBacteriaStorage EMPTY = new ComponentBacteriaStorage(NTBacterias.EMPTY, 0); public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( - ResourceKey.codec(NTRegistries.BACTERIA_KEY).fieldOf("bacteriaType").forGetter(ComponentBacteriaStorage::bacteria), + Bacteria.BACTERIA_TYPE_CODEC.fieldOf("bacteriaType").forGetter(ComponentBacteriaStorage::bacteria), Codec.LONG.fieldOf("bacteriaAmount").forGetter(ComponentBacteriaStorage::bacteriaAmount) ).apply(instance, ComponentBacteriaStorage::new)); public static final StreamCodec STREAM_CODEC = StreamCodec.composite( - ResourceKey.streamCodec(NTRegistries.BACTERIA_KEY), + Bacteria.BACTERIA_TYPE_STREAM_CODEC, ComponentBacteriaStorage::bacteria, ByteBufCodecs.VAR_LONG, ComponentBacteriaStorage::bacteriaAmount, diff --git a/src/main/java/com/portingdeadmods/nautec/registries/NTBacteriaSerializers.java b/src/main/java/com/portingdeadmods/nautec/registries/NTBacteriaSerializers.java index d2159efb..03b6babc 100644 --- a/src/main/java/com/portingdeadmods/nautec/registries/NTBacteriaSerializers.java +++ b/src/main/java/com/portingdeadmods/nautec/registries/NTBacteriaSerializers.java @@ -6,10 +6,10 @@ import com.portingdeadmods.nautec.content.bacteria.SimpleBacteria; import net.neoforged.neoforge.registries.DeferredRegister; -import java.util.function.Supplier; - public final class NTBacteriaSerializers { public static final DeferredRegister> SERIALIZERS = DeferredRegister.create(NTRegistries.BACTERIA_SERIALIZER, Nautec.MODID); - public static final Supplier SIMPLE = SERIALIZERS.register("simple", () -> SimpleBacteria.Serializer.INSTANCE); + static { + SERIALIZERS.register("simple", () -> SimpleBacteria.Serializer.INSTANCE); + } }