diff --git a/src/generated/resources/.cache/103d9f3f36b01595f1aa5172191e60eff02e6924 b/src/generated/resources/.cache/103d9f3f36b01595f1aa5172191e60eff02e6924 index 42046eb3..4b327f0a 100644 --- a/src/generated/resources/.cache/103d9f3f36b01595f1aa5172191e60eff02e6924 +++ b/src/generated/resources/.cache/103d9f3f36b01595f1aa5172191e60eff02e6924 @@ -1,9 +1,9 @@ -// 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 +// 1.21.1 2024-12-19T15:16:06.7633778 Registries +4cc74761a420946768852a3c4e5fba64de831555 data/nautec/nautec/bacteria/cyanobacteria.json +2ceb7d9533a35c6cb05ba68915ecaf868def152a data/nautec/nautec/bacteria/empty.json +ce644e1811997ff67d2f7df856532017272a7b22 data/nautec/nautec/bacteria/halobacteria.json +36808ce13b558579e40af12e305adf733c501003 data/nautec/nautec/bacteria/methanogens.json +165e8d4b95ee84a6c951b35561ba6808bf60c49c 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 04268fb2..17172009 100644 --- a/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e +++ b/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e @@ -1,4 +1,4 @@ -// 1.21.1 2024-12-16T22:58:24.975013206 Recipes +// 1.21.1 2024-12-19T15:16:06.7611986 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 @@ -44,9 +44,9 @@ e8c7d011fc8d7584ae12c127a368e794c349cc43 data/nautec/advancement/recipes/misc/la 5a63e821107905c4834ef94b9dda1d99041e5cc0 data/nautec/advancement/recipes/misc/long_distance_laser.json fa6493a3ef0380850872951ce297171d1708ce63 data/nautec/advancement/recipes/misc/mixer.json 94885315f77dd2362883172287de15e80f1a6e7b data/nautec/advancement/recipes/misc/nautec_guide.json -8b0963164bc58a64ef675d369ac6f4221b8cbebb data/nautec/advancement/recipes/misc/prism_monocle.json 002f4581bd2e95a74b869395702f7a95e2b2c5f5 data/nautec/advancement/recipes/misc/prismarine_relay.json 1eb85648ed5c154f0a465c787ef1cfd4542c3572 data/nautec/advancement/recipes/misc/prismatic_battery.json +8b0963164bc58a64ef675d369ac6f4221b8cbebb data/nautec/advancement/recipes/misc/prism_monocle.json df1f62063c751d0d6939426505f6bb14f6ae7382 data/nautec/advancement/recipes/misc/whisk.json 83490bc77ed0236455b903949d3ef5ee0430d7ed data/nautec/recipe/aquarine_axe.json 2705880f2aec0f82cf5d58ffa1736dbeea7b7452 data/nautec/recipe/aquarine_boots.json @@ -106,8 +106,8 @@ a4bdb97abe0834d405f7584452f78242585e02ff data/nautec/recipe/laser_channeling_coi 4925f952a200ae56a4e1ad04a45897be4988aad4 data/nautec/recipe/mixer.json 674df651148d747a200794f496996b82ca94e72f data/nautec/recipe/nautec_guide.json f9596d9be4a76ba5e91496e7396018daa20cccfc data/nautec/recipe/polished_prismarine.json -4fe8f6115c759c654e132afedec76d846f0a89d5 data/nautec/recipe/prism_monocle.json ac628b97c097227e3af94f13cbe35a2cf3ee3124 data/nautec/recipe/prismarine_relay.json 4745c9855337a311cb5b7211168927a61645d193 data/nautec/recipe/prismatic_battery.json +4fe8f6115c759c654e132afedec76d846f0a89d5 data/nautec/recipe/prism_monocle.json 0e781b8c85808d8ee2691a5c39404da2b6a8f061 data/nautec/recipe/valve.json 266c89a0698de108847ad3b60be50d230822cee4 data/nautec/recipe/whisk.json diff --git a/src/generated/resources/.cache/c622617f6fabf890a00b9275cd5f643584a8a2c8 b/src/generated/resources/.cache/c622617f6fabf890a00b9275cd5f643584a8a2c8 index a70d3900..a7705e3d 100644 --- a/src/generated/resources/.cache/c622617f6fabf890a00b9275cd5f643584a8a2c8 +++ b/src/generated/resources/.cache/c622617f6fabf890a00b9275cd5f643584a8a2c8 @@ -1,2 +1,2 @@ -// 1.21.1 2024-12-16T12:56:36.5452448 Languages: en_us -cb59c9cda54c192d94a6d91598a550f3a0a55062 assets/nautec/lang/en_us.json +// 1.21.1 2024-12-19T15:27:30.4978381 Languages: en_us +26ff82214c574807b043b3a8a0cc2117f9429b33 assets/nautec/lang/en_us.json diff --git a/src/generated/resources/assets/nautec/lang/en_us.json b/src/generated/resources/assets/nautec/lang/en_us.json index d38adaf3..b716efaa 100644 --- a/src/generated/resources/assets/nautec/lang/en_us.json +++ b/src/generated/resources/assets/nautec/lang/en_us.json @@ -11,6 +11,11 @@ "augment_type.nautec.dolphin_fin": "Dolphin Fin", "augment_type.nautec.drowned_lung": "Drowned Lung", "augment_type.nautec.guardian_eye": "Guardian Eye", + "bacteria.nautec.cyanobacteria": "Cyanobacteria / Blue-Green algae", + "bacteria.nautec.empty": "Empty", + "bacteria.nautec.halobacteria": "Halobacteria", + "bacteria.nautec.methanogens": "Methanogens", + "bacteria.nautec.thermophiles": "Thermophiles", "block.nautec.aquarine_steel_block": "Aquarine Steel Block", "block.nautec.aquatic_catalyst": "Aquatic Catalyst", "block.nautec.augmentation_station": "Augmentation Station", @@ -228,9 +233,5 @@ "nautec.tool.shovel.ability": "Ability: Mine in a 3x3 Area", "nautec.tool.status": "Status: ", "nautec.tool.sword.ability": "Ability: Deal 70% more damage and spawn lightnings at targets", - "nautec:cyanobacteria": "Cyanobacteria", - "nautec:halobacteria": "Halobacteria", - "nautec:methanogens": "Methanogens", - "nautec:thermophiles": "Thermophiles", "nautec_guide.desc.0": "Nautec's Guide" } \ No newline at end of file diff --git a/src/generated/resources/assets/nautec/models/item/breaker.json b/src/generated/resources/assets/nautec/models/item/breaker.json new file mode 100644 index 00000000..8dd2b7a5 --- /dev/null +++ b/src/generated/resources/assets/nautec/models/item/breaker.json @@ -0,0 +1,3 @@ +{ + "parent": "nautec:block/breaker" +} \ 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 17b8b0f1..03b1bc91 100644 --- a/src/generated/resources/data/nautec/nautec/bacteria/cyanobacteria.json +++ b/src/generated/resources/data/nautec/nautec/bacteria/cyanobacteria.json @@ -1,6 +1,7 @@ { "type": "nautec:simple", "stats": { + "colony_size": 0.0, "color": -13434881, "growth_rate": 0.0, "lifespan": 0, diff --git a/src/generated/resources/data/nautec/nautec/bacteria/empty.json b/src/generated/resources/data/nautec/nautec/bacteria/empty.json index c6a735da..ee4bd21c 100644 --- a/src/generated/resources/data/nautec/nautec/bacteria/empty.json +++ b/src/generated/resources/data/nautec/nautec/bacteria/empty.json @@ -1,6 +1,7 @@ { "type": "nautec:simple", "stats": { + "colony_size": 0.0, "color": 0, "growth_rate": 0.0, "lifespan": 0, diff --git a/src/generated/resources/data/nautec/nautec/bacteria/halobacteria.json b/src/generated/resources/data/nautec/nautec/bacteria/halobacteria.json index 65504394..e23a7fc0 100644 --- a/src/generated/resources/data/nautec/nautec/bacteria/halobacteria.json +++ b/src/generated/resources/data/nautec/nautec/bacteria/halobacteria.json @@ -1,6 +1,7 @@ { "type": "nautec:simple", "stats": { + "colony_size": 0.0, "color": -6912, "growth_rate": 0.0, "lifespan": 0, diff --git a/src/generated/resources/data/nautec/nautec/bacteria/methanogens.json b/src/generated/resources/data/nautec/nautec/bacteria/methanogens.json index 49a730c4..82c2146a 100644 --- a/src/generated/resources/data/nautec/nautec/bacteria/methanogens.json +++ b/src/generated/resources/data/nautec/nautec/bacteria/methanogens.json @@ -1,6 +1,7 @@ { "type": "nautec:simple", "stats": { + "colony_size": 0.0, "color": -1328403, "growth_rate": 0.0, "lifespan": 0, diff --git a/src/generated/resources/data/nautec/nautec/bacteria/thermophiles.json b/src/generated/resources/data/nautec/nautec/bacteria/thermophiles.json index c58cc991..3d5847a3 100644 --- a/src/generated/resources/data/nautec/nautec/bacteria/thermophiles.json +++ b/src/generated/resources/data/nautec/nautec/bacteria/thermophiles.json @@ -1,6 +1,7 @@ { "type": "nautec:simple", "stats": { + "colony_size": 0.0, "color": -65536, "growth_rate": 0.0, "lifespan": 0, diff --git a/src/main/java/com/portingdeadmods/nautec/NTConfig.java b/src/main/java/com/portingdeadmods/nautec/NTConfig.java index e11c0062..1b137c5f 100644 --- a/src/main/java/com/portingdeadmods/nautec/NTConfig.java +++ b/src/main/java/com/portingdeadmods/nautec/NTConfig.java @@ -76,6 +76,27 @@ public final class NTConfig { .comment("The y depth the fisher checks for water") .defineInRange("fisherDepth", 2, 1, Integer.MAX_VALUE); + // Biology + private static final ModConfigSpec.DoubleValue BACTERIA_GROWTH_RATE_CAP = BUILDER + .comment("The maximum rate at which bacteria can grow") + .defineInRange("bacteriaGrowthRateCap", 5, 0, Float.MAX_VALUE); + + private static final ModConfigSpec.DoubleValue BACTERIA_PRODUCTION_RATE_CAP = BUILDER + .comment("The maximum rate at which bacteria can produce") + .defineInRange("bacteriaProductionRateCap", 2, 0, Float.MAX_VALUE); + + private static final ModConfigSpec.DoubleValue BACTERIA_MUTATION_RESISTANCE_CAP = BUILDER + .comment("The maximum rate at which bacteria can resist mutation") + .defineInRange("bacteriaMutationResistanceCap", 1, 0, Float.MAX_VALUE); + + private static final ModConfigSpec.DoubleValue BACTERIA_COLONY_SIZE_CAP = BUILDER + .comment("The maximum size a bacteria colony can grow to") + .defineInRange("bacteriaColonySizeCap", 100d, 0, Float.MAX_VALUE); + + private static final ModConfigSpec.IntValue BACTERIA_LIFESPAN_CAP = BUILDER + .comment("The maximum lifespan of a bacteria colony") + .defineInRange("bacteriaLifespanCap", 24000, 0, Integer.MAX_VALUE); + static final ModConfigSpec SPEC = BUILDER.build(); public static int kelpHeight; @@ -102,6 +123,13 @@ public final class NTConfig { public static int fisherRunDuration; public static int fisherRadius; public static int fisherDepth; + + public static float bacteriaGrowthRateCap; + public static float bacteriaProductionRateCap; + public static float bacteriaMutationResistanceCap; + public static float bacteriaColonySizeCap; + public static int bacteriaLifespanCap; + @SubscribeEvent static void onLoad(final ModConfigEvent event) { kelpHeight = KELP_HEIGHT.get(); @@ -129,6 +157,12 @@ static void onLoad(final ModConfigEvent event) { fisherRunDuration = FISHER_DURATION.getAsInt(); fisherDepth = FISHER_DEPTH.getAsInt(); fisherRadius = FISHER_RADIUS.getAsInt(); + + bacteriaGrowthRateCap = (float) BACTERIA_GROWTH_RATE_CAP.getAsDouble(); + bacteriaProductionRateCap = (float) BACTERIA_PRODUCTION_RATE_CAP.getAsDouble(); + bacteriaMutationResistanceCap = (float) BACTERIA_MUTATION_RESISTANCE_CAP.getAsDouble(); + bacteriaColonySizeCap = (float) BACTERIA_COLONY_SIZE_CAP.getAsDouble(); + bacteriaLifespanCap = BACTERIA_LIFESPAN_CAP.get(); } } diff --git a/src/main/java/com/portingdeadmods/nautec/api/bacteria/BaseBacteriaStats.java b/src/main/java/com/portingdeadmods/nautec/api/bacteria/BaseBacteriaStats.java index a0045bfe..0205d49a 100644 --- a/src/main/java/com/portingdeadmods/nautec/api/bacteria/BaseBacteriaStats.java +++ b/src/main/java/com/portingdeadmods/nautec/api/bacteria/BaseBacteriaStats.java @@ -14,9 +14,22 @@ public interface BaseBacteriaStats { float productionRate(); + float colonySize(); + int lifespan(); int color(); List<Component> statsTooltip(); + + // Mutator + BaseBacteriaStats rollGrowthRate(); + BaseBacteriaStats rollMutationResistance(); + BaseBacteriaStats rollProductionRate(); + BaseBacteriaStats rollLifespan(); + BaseBacteriaStats rollStats(); + + // Incubator + BaseBacteriaStats grow(); + BaseBacteriaStats shrink(); } 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 4b3f3aec..1ac197e2 100644 --- a/src/main/java/com/portingdeadmods/nautec/content/bacteria/BacteriaStats.java +++ b/src/main/java/com/portingdeadmods/nautec/content/bacteria/BacteriaStats.java @@ -3,12 +3,17 @@ import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; import com.portingdeadmods.nautec.api.bacteria.BaseBacteriaStats; +import com.portingdeadmods.nautec.utils.ComponentUtils; +import com.portingdeadmods.nautec.utils.RNGUtils; import com.portingdeadmods.nautec.utils.codec.CodecUtils; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.chat.Component; import net.minecraft.network.codec.ByteBufCodecs; import net.minecraft.network.codec.StreamCodec; import net.minecraft.world.item.Item; +import net.neoforged.neoforge.network.codec.NeoForgeStreamCodecs; + +import static com.portingdeadmods.nautec.NTConfig.*; import java.util.List; @@ -16,6 +21,7 @@ public record BacteriaStats(Item resource, float growthRate, float mutationResistance, float productionRate, + float colonySize, int lifespan, int color) implements BaseBacteriaStats { public static final Codec<BacteriaStats> CODEC = RecordCodecBuilder.create( @@ -24,12 +30,13 @@ public record BacteriaStats(Item 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), + Codec.FLOAT.fieldOf("colony_size").forGetter(BacteriaStats::colonySize), Codec.INT.fieldOf("lifespan").forGetter(BacteriaStats::lifespan), Codec.INT.fieldOf("color").forGetter(BacteriaStats::color) ).apply(instance, BacteriaStats::new) ); - public static final StreamCodec<RegistryFriendlyByteBuf, BacteriaStats> STREAM_CODEC = StreamCodec.composite( + public static final StreamCodec<RegistryFriendlyByteBuf, BacteriaStats> STREAM_CODEC = NeoForgeStreamCodecs.composite( CodecUtils.ITEM_STREAM_CODEC, BacteriaStats::resource, ByteBufCodecs.FLOAT, @@ -38,6 +45,8 @@ public record BacteriaStats(Item resource, BacteriaStats::mutationResistance, ByteBufCodecs.FLOAT, BacteriaStats::productionRate, + ByteBufCodecs.FLOAT, + BacteriaStats::colonySize, ByteBufCodecs.INT, BacteriaStats::lifespan, ByteBufCodecs.INT, @@ -48,8 +57,62 @@ public record BacteriaStats(Item resource, @Override public List<Component> statsTooltip() { return List.of( - Component.literal("Resource: "+resource.getDefaultInstance().getDisplayName().getString()), - Component.literal("Growth Rate: "+growthRate) + ComponentUtils.stringStatShow("Resource", resource.getDefaultInstance().getDisplayName().getString()), + ComponentUtils.countableStatShow("Growth Rate", growthRate, bacteriaGrowthRateCap), + ComponentUtils.countableStatShow("Mutation Resistance", mutationResistance, bacteriaMutationResistanceCap), + ComponentUtils.countableStatShow("Production Rate", productionRate, bacteriaProductionRateCap), + ComponentUtils.countableStatShow("Colony Size", colonySize, bacteriaColonySizeCap), + ComponentUtils.countableStatShow("Lifespan", lifespan, bacteriaLifespanCap) ); } + + @Override + public BaseBacteriaStats rollGrowthRate() { + float newGR = growthRate + (RNGUtils.floatInRangeOf(growthRate) / (10 * (1 + mutationResistance))); + newGR = Math.min(newGR, bacteriaGrowthRateCap); + + return new BacteriaStats(resource, newGR, mutationResistance, productionRate, colonySize, lifespan, color); + } + + @Override + public BaseBacteriaStats rollMutationResistance() { + float newMR = mutationResistance + RNGUtils.biasedInRange(0, 0.1f, mutationResistance) / 10 * (bacteriaMutationResistanceCap - mutationResistance); + + return new BacteriaStats(resource, growthRate, newMR, productionRate, colonySize, lifespan, color); + } + + @Override + public BaseBacteriaStats rollProductionRate() { + float newPR = productionRate + RNGUtils.floatInRangeOf(productionRate) / 10 * (1 + mutationResistance); + newPR = Math.min(newPR, bacteriaProductionRateCap); + + return new BacteriaStats(resource, growthRate, mutationResistance, newPR, colonySize, lifespan, color); + } + + @Override + public BaseBacteriaStats rollLifespan() { + int newLS = lifespan + (int) (RNGUtils.uniformRandInt(-10, 10) / (1 + mutationResistance)); + newLS = Math.min(newLS, bacteriaLifespanCap); + + return new BacteriaStats(resource, growthRate, mutationResistance, productionRate, colonySize, newLS, color); + } + + @Override + public BaseBacteriaStats rollStats() { + return rollGrowthRate().rollMutationResistance().rollProductionRate().rollLifespan(); + } + + @Override + public BaseBacteriaStats grow() { + float newCS = colonySize + RNGUtils.floatInRangeOf(0, growthRate); + newCS = Math.min(newCS, bacteriaColonySizeCap); + + return new BacteriaStats(resource, growthRate, mutationResistance, productionRate, newCS, lifespan, color); + } + + @Override + public BaseBacteriaStats shrink() { + float newCS = colonySize - colonySize * RNGUtils.uniformRandFloat(25) - 1; + return new BacteriaStats(resource, growthRate, mutationResistance, productionRate, newCS, lifespan, color); + } } 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 804f3893..7dc52751 100644 --- a/src/main/java/com/portingdeadmods/nautec/content/bacteria/SimpleBacteria.java +++ b/src/main/java/com/portingdeadmods/nautec/content/bacteria/SimpleBacteria.java @@ -50,6 +50,7 @@ public static class Builder { private float growthRate; private float mutationResistance; private float productionRate; + private float colonySize; private int lifespan; private int color; @@ -73,6 +74,11 @@ public Builder productionRate(float productionRate) { return this; } + public Builder colonySize(float colonySize) { + this.colonySize = colonySize; + return this; + } + public Builder lifespan(int lifespan) { this.lifespan = lifespan; return this; @@ -84,7 +90,7 @@ public Builder color(int color) { } public Bacteria build(ResourceLocation location) { - return new SimpleBacteria(new BacteriaStats(resource, growthRate, mutationResistance, productionRate, lifespan, color)); + return new SimpleBacteria(new BacteriaStats(resource, growthRate, mutationResistance, productionRate, colonySize, lifespan, color)); } } } diff --git a/src/main/java/com/portingdeadmods/nautec/content/blockentities/BreakerBlockEntity.java b/src/main/java/com/portingdeadmods/nautec/content/blockentities/BreakerBlockEntity.java new file mode 100644 index 00000000..ceb6ff07 --- /dev/null +++ b/src/main/java/com/portingdeadmods/nautec/content/blockentities/BreakerBlockEntity.java @@ -0,0 +1,81 @@ +package com.portingdeadmods.nautec.content.blockentities; + +import com.portingdeadmods.nautec.NTConfig; +import com.portingdeadmods.nautec.api.blockentities.LaserBlockEntity; +import com.portingdeadmods.nautec.capabilities.IOActions; +import com.portingdeadmods.nautec.registries.NTBlockEntityTypes; +import it.unimi.dsi.fastutil.Pair; +import it.unimi.dsi.fastutil.objects.ObjectSet; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.storage.loot.LootParams; +import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets; +import net.minecraft.world.level.storage.loot.parameters.LootContextParams; +import net.minecraft.world.phys.Vec3; +import net.neoforged.neoforge.capabilities.BlockCapability; +import org.jetbrains.annotations.Nullable; + +import java.util.List; +import java.util.Map; + +public class BreakerBlockEntity extends LaserBlockEntity { + private boolean running; + private int counter; + public BreakerBlockEntity(BlockPos blockPos, BlockState blockState) { + super(NTBlockEntityTypes.BREAKER_BLOCK.get(), blockPos, blockState); + } + + @Override + public ObjectSet<Direction> getLaserInputs() { + return ObjectSet.of(Direction.UP, Direction.DOWN, Direction.EAST, Direction.NORTH,Direction.WEST, Direction.SOUTH); + } + + @Override + public ObjectSet<Direction> getLaserOutputs() { + return ObjectSet.of(); + } + + @Override + public <T> Map<Direction, Pair<IOActions, int[]>> getSidedInteractions(BlockCapability<T, @Nullable Direction> capability) { + return Map.of(); + } + + @Override + public void commonTick() { + super.commonTick(); + if (level instanceof ServerLevel && getPower() >= 1){ + if (running) { + if (counter >= 20) { + counter = 0; + running = false; + spawnLoot(); + } + counter++; + } else running = true; + } + } + + private void spawnLoot() { + BlockState block = level.getBlockState(worldPosition.below()); + List<ItemStack> stacks = block.getDrops(new LootParams.Builder((ServerLevel) level).withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(worldPosition)).withParameter(LootContextParams.TOOL, Items.DIAMOND_PICKAXE.getDefaultInstance())); + if (!stacks.isEmpty()) { + level.removeBlock(worldPosition.below(), false); + for (ItemStack stack : stacks) { + Vec3 pos = getItemSpawnPos(); + ItemEntity itemEntity = new ItemEntity(level, pos.x, pos.y, pos.z, stack); + level.addFreshEntity(itemEntity); + } + } + + } + private Vec3 getItemSpawnPos(){ + return new Vec3(worldPosition.getX() + 0.5, worldPosition.getY() + 1.5, worldPosition.getZ() + 0.5); + } +} diff --git a/src/main/java/com/portingdeadmods/nautec/content/blocks/BreakerBlock.java b/src/main/java/com/portingdeadmods/nautec/content/blocks/BreakerBlock.java new file mode 100644 index 00000000..3355db1f --- /dev/null +++ b/src/main/java/com/portingdeadmods/nautec/content/blocks/BreakerBlock.java @@ -0,0 +1,24 @@ +package com.portingdeadmods.nautec.content.blocks; + +import com.mojang.serialization.MapCodec; +import com.portingdeadmods.nautec.api.blockentities.ContainerBlockEntity; +import com.portingdeadmods.nautec.api.blocks.blockentities.LaserBlock; +import com.portingdeadmods.nautec.registries.NTBlockEntityTypes; +import net.minecraft.world.level.block.BaseEntityBlock; +import net.minecraft.world.level.block.entity.BlockEntityType; + +public class BreakerBlock extends LaserBlock { + public BreakerBlock(Properties properties) { + super(properties); + } + + @Override + public BlockEntityType<? extends ContainerBlockEntity> getBlockEntityType() { + return NTBlockEntityTypes.BREAKER_BLOCK.get(); + } + + @Override + protected MapCodec<? extends BaseEntityBlock> codec() { + return simpleCodec(BreakerBlock::new); + } +} diff --git a/src/main/java/com/portingdeadmods/nautec/content/items/PetriDishItem.java b/src/main/java/com/portingdeadmods/nautec/content/items/PetriDishItem.java index 096e12c2..d842af4e 100644 --- a/src/main/java/com/portingdeadmods/nautec/content/items/PetriDishItem.java +++ b/src/main/java/com/portingdeadmods/nautec/content/items/PetriDishItem.java @@ -28,11 +28,11 @@ public void appendHoverText(ItemStack stack, TooltipContext context, List<Compon ResourceKey<Bacteria> bacteriaType = stack.get(NTDataComponents.BACTERIA).bacteria(); Bacteria bacteria = BacteriaHelper.getBacteria(context.registries(), bacteriaType); if (bacteria != null) { - tooltipComponents.add(Component.literal("Name: ").append(Utils.registryTranslation(bacteriaType)).withStyle(ChatFormatting.GRAY)); + tooltipComponents.add(Component.literal("Name: ").append(Utils.registryTranslation(bacteriaType)).withStyle(ChatFormatting.WHITE)); if (bacteriaType != NTBacterias.EMPTY) { MutableComponent statsCaption = Component.literal("Stats: "); if (Boolean.TRUE.equals(stack.get(NTDataComponents.ANALYZED))) { - tooltipComponents.add(statsCaption.withStyle(ChatFormatting.GRAY)); + tooltipComponents.add(statsCaption.withStyle(ChatFormatting.WHITE)); for (Component tooltipComponent : bacteria.stats().statsTooltip()) { tooltipComponents.add(Component.literal(" ".repeat(2)).append(tooltipComponent).withStyle(ChatFormatting.GRAY)); } diff --git a/src/main/java/com/portingdeadmods/nautec/datagen/EnUsProvider.java b/src/main/java/com/portingdeadmods/nautec/datagen/EnUsProvider.java index 13d1c107..db2066bf 100644 --- a/src/main/java/com/portingdeadmods/nautec/datagen/EnUsProvider.java +++ b/src/main/java/com/portingdeadmods/nautec/datagen/EnUsProvider.java @@ -7,12 +7,14 @@ import com.portingdeadmods.nautec.registries.NTFluids; import com.portingdeadmods.nautec.utils.Utils; import net.minecraft.data.PackOutput; +import net.minecraft.resources.ResourceKey; import net.neoforged.neoforge.fluids.FluidType; import net.neoforged.neoforge.registries.NeoForgeRegistries; import java.util.function.Supplier; import static com.portingdeadmods.nautec.registries.NTItems.*; +import static com.portingdeadmods.nautec.registries.NTBacterias.*; public class EnUsProvider extends AbstractModonomiconLanguageProvider { public EnUsProvider(PackOutput output, ModonomiconLanguageProvider cacheProvider) { @@ -151,10 +153,12 @@ protected void addTranslations() { add("nautec.tool.disabled", "Shift + Right Click to Enable"); // Bacteria - add("nautec:cyanobacteria", "Cyanobacteria"); - add("nautec:halobacteria", "Halobacteria"); - add("nautec:thermophiles", "Thermophiles"); - add("nautec:methanogens", "Methanogens"); + addBacteria(METHANOGENS, "Methanogens"); + addBacteria(THERMOPHILES, "Thermophiles"); + addBacteria(HALOBACTERIA, "Halobacteria"); + addBacteria(CYANOBACTERIA, "Cyanobacteria / Blue-Green algae"); + addBacteria(EMPTY, "Empty"); + } private void addFluidType(Supplier<? extends FluidType> fluidType, String val) { @@ -169,6 +173,10 @@ private void addItem(String key, String val) { add("item.nautec." + key, val); } + private void addBacteria(ResourceKey<?> key, String val) { + add(key.registry().getPath() + "." + key.location().getNamespace() + "." + key.location().getPath(), val); + } + private void addBlock(String key, String val) { add("block.nautec." + key, val); } diff --git a/src/main/java/com/portingdeadmods/nautec/registries/NTBlockEntityTypes.java b/src/main/java/com/portingdeadmods/nautec/registries/NTBlockEntityTypes.java index f8390e6f..db44e12f 100644 --- a/src/main/java/com/portingdeadmods/nautec/registries/NTBlockEntityTypes.java +++ b/src/main/java/com/portingdeadmods/nautec/registries/NTBlockEntityTypes.java @@ -46,6 +46,9 @@ public final class NTBlockEntityTypes { public static final Supplier<BlockEntityType<OilBarrelBlockEntity>> OIL_BARREL = BLOCK_ENTITIES.register("oil_barrel", () -> BlockEntityType.Builder.of(OilBarrelBlockEntity::new, NTBlocks.OIL_BARREL.get()).build(null)); + public static final Supplier<BlockEntityType<BreakerBlockEntity>> BREAKER_BLOCK = BLOCK_ENTITIES.register("breaker", + () -> BlockEntityType.Builder.of(BreakerBlockEntity::new, + NTBlocks.BREAKER_BLOCK.get()).build(null)); // Biology public static final Supplier<BlockEntityType<MutatorBlockEntity>> MUTATOR = BLOCK_ENTITIES.register("mutator", diff --git a/src/main/java/com/portingdeadmods/nautec/registries/NTBlocks.java b/src/main/java/com/portingdeadmods/nautec/registries/NTBlocks.java index 8f017327..ce9827b8 100644 --- a/src/main/java/com/portingdeadmods/nautec/registries/NTBlocks.java +++ b/src/main/java/com/portingdeadmods/nautec/registries/NTBlocks.java @@ -67,6 +67,8 @@ public final class NTBlocks { BlockBehaviour.Properties.ofFullCopy(Blocks.IRON_BLOCK)); public static final DeferredBlock<FishingStationBlock> FISHING_STATION = registerBlockAndItem("fishing_station", FishingStationBlock::new, BlockBehaviour.Properties.ofFullCopy(Blocks.IRON_BLOCK)); + public static final DeferredBlock<BreakerBlock> BREAKER_BLOCK = registerBlockAndItem("breaker", BreakerBlock::new, + BlockBehaviour.Properties.ofFullCopy(Blocks.IRON_BLOCK)); // Biology public static final DeferredBlock<MutatorBlock> MUTATOR = registerBlockAndItem("mutator", MutatorBlock::new, diff --git a/src/main/java/com/portingdeadmods/nautec/utils/ComponentUtils.java b/src/main/java/com/portingdeadmods/nautec/utils/ComponentUtils.java new file mode 100644 index 00000000..15f34498 --- /dev/null +++ b/src/main/java/com/portingdeadmods/nautec/utils/ComponentUtils.java @@ -0,0 +1,30 @@ +package com.portingdeadmods.nautec.utils; + +import net.minecraft.ChatFormatting; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.MutableComponent; + +public final class ComponentUtils { + public static MutableComponent colored(String text, ChatFormatting col) { + return Component.literal(text).withStyle(col); + } + + public static MutableComponent countableStatShow(String name, Number val, Number max) { + MutableComponent mc1 = colored(name, ChatFormatting.YELLOW) + .append(Component.literal(": ").withStyle(ChatFormatting.WHITE)); + + if (val.doubleValue() < max.doubleValue()) { + mc1.append(colored(val.toString(), ChatFormatting.GREEN)); + } else { + mc1.append(colored(val.toString(), ChatFormatting.RED)); + } + + return mc1; + } + + public static MutableComponent stringStatShow(String name, String val) { + return colored(name, ChatFormatting.YELLOW) + .append(Component.literal(": ").withStyle(ChatFormatting.WHITE)) + .append(colored(val, ChatFormatting.GREEN)); + } +} diff --git a/src/main/java/com/portingdeadmods/nautec/utils/RNGUtils.java b/src/main/java/com/portingdeadmods/nautec/utils/RNGUtils.java index 46978fb2..2ab417c4 100644 --- a/src/main/java/com/portingdeadmods/nautec/utils/RNGUtils.java +++ b/src/main/java/com/portingdeadmods/nautec/utils/RNGUtils.java @@ -1,6 +1,10 @@ package com.portingdeadmods.nautec.utils; public final class RNGUtils { + public static float random() { + return (float) Math.random(); + } + public static int uniformRandInt(int min, int max) { return (int) (Math.random() * (max - min + 1) + min); } @@ -9,28 +13,28 @@ public static int uniformRandInt(int max) { return uniformRandInt(0, max); } - public static double uniformRandDouble(double min, double max) { - return Math.random() * (max - min) + min; + public static float uniformRandFloat(float min, float max) { + return (float) Math.random() * (max - min) + min; } - public static double uniformRandDouble(double max) { - return uniformRandDouble(0, max); + public static float uniformRandFloat(float max) { + return uniformRandFloat(0, max); } public static int intInRangeOf(int val, int range) { - return (int) (uniformRandInt(-val, val) * Math.random() + range); + return (int) (uniformRandInt(-val, val) * random() + range); } - public static int intInRangeOf(int val) { - return intInRangeOf(val, 0); + public static int intInRangeOf(int range) { + return intInRangeOf(0, range); } - public static double doubleInRangeOf(double val, double range) { - return uniformRandDouble(-val, val) * Math.random() + range; + public static float floatInRangeOf(float val, float range) { + return uniformRandFloat(-val, val) * random() + range; } - public static double doubleInRangeOf(double val) { - return doubleInRangeOf(val, 0); + public static float floatInRangeOf(float range) { + return floatInRangeOf(0, range); } /* @@ -38,18 +42,33 @@ public static double doubleInRangeOf(double val) { * 1 -> always in the positive range * 0 -> neutral */ - public static double biasedInRangeOf(double val, double range, double bias) { - double absBias = Math.abs(bias); + public static float biasedInRangeOf(float val, float range, float bias) { + float absBias = Math.abs(bias); if (bias < 0) { - return uniformRandDouble(-range, range * (1 - absBias)) + val; + return uniformRandFloat(-range, range * (1 - absBias)) + val; } else if (bias > 0) { - return uniformRandDouble(-range * (1 - absBias), range) + val; + return uniformRandFloat(-range * (1 - absBias), range) + val; } - return uniformRandDouble(-range, range) + val; + return uniformRandFloat(-range, range) + val; } - public static double biasedInRangeOf(double range, double bias) { + public static float biasedInRangeOf(float range, float bias) { return biasedInRangeOf(0, range, bias); } + + public static float biasedInRange(float rangeStart, float rangeEnd, float bias) { + float absBias = Math.abs(bias); + float middlePoint = (rangeStart + rangeEnd) / 2; + + float left = middlePoint - rangeStart; + float right = rangeEnd - middlePoint; + + if (bias < 0) { + return uniformRandFloat(left, right * (1 - absBias)) + middlePoint; + } else if (bias > 0) { + return uniformRandFloat(left * (1 - absBias), right) + middlePoint; + } + return uniformRandFloat(left, right) + middlePoint; + } }