From eec8aa454c8b1a186372a34c7ecc7c9cb690737d Mon Sep 17 00:00:00 2001 From: MysticKoko <132279944+MysticKoko@users.noreply.github.com> Date: Thu, 28 Nov 2024 00:01:13 +0200 Subject: [PATCH] Secret stuff --- .../dev/hybridlabs/aquatic/HybridAquatic.kt | 2 + .../aquatic/block/HybridAquaticBlocks.kt | 5 + .../aquatic/data/client/ModelProvider.kt | 1 + .../hybridlabs/aquatic/fluid/BrineFluid.kt | 104 ++++++++++++++++++ .../aquatic/fluid/HybridAquaticFluids.kt | 19 ++++ .../aquatic/item/HybridAquaticItemGroups.kt | 3 +- .../aquatic/item/HybridAquaticItems.kt | 2 + 7 files changed, 135 insertions(+), 1 deletion(-) create mode 100644 src/main/kotlin/dev/hybridlabs/aquatic/fluid/BrineFluid.kt create mode 100644 src/main/kotlin/dev/hybridlabs/aquatic/fluid/HybridAquaticFluids.kt diff --git a/src/main/kotlin/dev/hybridlabs/aquatic/HybridAquatic.kt b/src/main/kotlin/dev/hybridlabs/aquatic/HybridAquatic.kt index 3aabaac88..ed8c667dc 100644 --- a/src/main/kotlin/dev/hybridlabs/aquatic/HybridAquatic.kt +++ b/src/main/kotlin/dev/hybridlabs/aquatic/HybridAquatic.kt @@ -9,6 +9,7 @@ import dev.hybridlabs.aquatic.effect.HybridAquaticStatusEffects import dev.hybridlabs.aquatic.enchantment.HybridAquaticEnchantments import dev.hybridlabs.aquatic.entity.HybridAquaticEntityTypes import dev.hybridlabs.aquatic.entity.SpawnRestrictionRegistry +import dev.hybridlabs.aquatic.fluid.HybridAquaticFluids import dev.hybridlabs.aquatic.item.HybridAquaticItemGroups import dev.hybridlabs.aquatic.item.HybridAquaticItems import dev.hybridlabs.aquatic.loot.LootTableModifications @@ -41,6 +42,7 @@ object HybridAquatic : ModInitializer { logger.info("Initializing $MOD_ID") HybridAquaticBlocks + HybridAquaticFluids HybridAquaticBlockEntityTypes StrippableBlockRegistry.register(HybridAquaticBlocks.DRIFTWOOD_LOG, HybridAquaticBlocks.STRIPPED_DRIFTWOOD_LOG) diff --git a/src/main/kotlin/dev/hybridlabs/aquatic/block/HybridAquaticBlocks.kt b/src/main/kotlin/dev/hybridlabs/aquatic/block/HybridAquaticBlocks.kt index 184476c8d..e6098ccfc 100644 --- a/src/main/kotlin/dev/hybridlabs/aquatic/block/HybridAquaticBlocks.kt +++ b/src/main/kotlin/dev/hybridlabs/aquatic/block/HybridAquaticBlocks.kt @@ -3,6 +3,7 @@ package dev.hybridlabs.aquatic.block import com.google.common.collect.ImmutableSet import dev.hybridlabs.aquatic.HybridAquatic import dev.hybridlabs.aquatic.block.wood.HybridAquaticWoodTypes +import dev.hybridlabs.aquatic.fluid.HybridAquaticFluids import net.fabricmc.fabric.api.`object`.builder.v1.block.FabricBlockSettings import net.minecraft.block.* import net.minecraft.block.entity.BlockEntity @@ -35,6 +36,9 @@ object HybridAquaticBlocks { .pistonBehavior(PistonBehavior.DESTROY) )) + val BRINE = register("brine", FluidBlock(HybridAquaticFluids.BRINE, AbstractBlock.Settings.create().mapColor(MapColor.WATER_BLUE).replaceable().noCollision().strength(100.0f).pistonBehavior(PistonBehavior.DESTROY).dropsNothing().liquid().sounds(BlockSoundGroup.INTENTIONALLY_EMPTY))) + + val BASKING_SHARK_PLUSHIE = register("basking_shark_plushie", createPlushieBlock(PlushieBlock.Variant.BASKING_SHARK, Blocks.GRAY_WOOL)) val BULL_SHARK_PLUSHIE = register("bull_shark_plushie", createPlushieBlock(PlushieBlock.Variant.BULL_SHARK, Blocks.LIGHT_GRAY_WOOL)) val FRILLED_SHARK_PLUSHIE = register("frilled_shark_plushie", createPlushieBlock(PlushieBlock.Variant.FRILLED_SHARK, Blocks.GRAY_WOOL)) @@ -203,6 +207,7 @@ object HybridAquaticBlocks { .instrument(Instrument.CUSTOM_HEAD) ) } + private fun register(id: String, block: Block): Block { return Registry.register(Registries.BLOCK, Identifier(HybridAquatic.MOD_ID, id), block) } diff --git a/src/main/kotlin/dev/hybridlabs/aquatic/data/client/ModelProvider.kt b/src/main/kotlin/dev/hybridlabs/aquatic/data/client/ModelProvider.kt index fd98e2086..4c2222b27 100644 --- a/src/main/kotlin/dev/hybridlabs/aquatic/data/client/ModelProvider.kt +++ b/src/main/kotlin/dev/hybridlabs/aquatic/data/client/ModelProvider.kt @@ -123,6 +123,7 @@ class ModelProvider(output: FabricDataOutput) : FabricModelProvider(output) { HybridAquaticItems.GLOW_SLIME, HybridAquaticItems.SHARK_TOOTH, HybridAquaticItems.SPONGE_CHUNK, + HybridAquaticItems.BRINE_BUCKET, HybridAquaticItems.PEARL, HybridAquaticItems.BLACK_PEARL, HybridAquaticItems.SULFUR, diff --git a/src/main/kotlin/dev/hybridlabs/aquatic/fluid/BrineFluid.kt b/src/main/kotlin/dev/hybridlabs/aquatic/fluid/BrineFluid.kt new file mode 100644 index 000000000..5b1a59a21 --- /dev/null +++ b/src/main/kotlin/dev/hybridlabs/aquatic/fluid/BrineFluid.kt @@ -0,0 +1,104 @@ +package dev.hybridlabs.aquatic.fluid + +import dev.hybridlabs.aquatic.block.HybridAquaticBlocks +import dev.hybridlabs.aquatic.item.HybridAquaticItems +import net.minecraft.block.Block +import net.minecraft.block.BlockState +import net.minecraft.block.FluidBlock +import net.minecraft.fluid.FlowableFluid +import net.minecraft.fluid.Fluid +import net.minecraft.fluid.FluidState +import net.minecraft.item.Item +import net.minecraft.state.StateManager +import net.minecraft.util.math.BlockPos +import net.minecraft.util.math.Direction +import net.minecraft.world.BlockView +import net.minecraft.world.World +import net.minecraft.world.WorldAccess +import net.minecraft.world.WorldView + +open class BrineFluid : FlowableFluid() { + override fun isInfinite(world: World?): Boolean { + return false + } + + override fun beforeBreakingBlock(world: WorldAccess, pos: BlockPos?, state: BlockState) { + val blockEntity = if (state.hasBlockEntity()) world.getBlockEntity(pos) else null + Block.dropStacks(state, world, pos, blockEntity) + } + + override fun getFlowSpeed(world: WorldView?): Int { + return 3 + } + + override fun getLevelDecreasePerBlock(world: WorldView?): Int { + return 2 + } + + override fun getLevel(state: FluidState?): Int { + return 8 + } + + override fun getTickRate(world: WorldView?): Int { + return 5 + } + + override fun getBlastResistance(): Float { + return 100F + } + + override fun canBeReplacedWith( + state: FluidState?, + world: BlockView?, + pos: BlockPos?, + fluid: Fluid?, + direction: Direction? + ): Boolean { + return false + } + + override fun getStill(): Fluid { + return HybridAquaticFluids.BRINE + } + + override fun getFlowing(): Fluid { + return HybridAquaticFluids.FLOWING_BRINE + } + + override fun getBucketItem(): Item { + return HybridAquaticItems.BRINE_BUCKET + } + + public override fun toBlockState(state: FluidState?): BlockState { + return HybridAquaticBlocks.BRINE.defaultState.with(FluidBlock.LEVEL, getBlockStateLevel(state)) as BlockState + } + + override fun isStill(state: FluidState?): Boolean { + return false + } + + internal class Flowing : BrineFluid() { + override fun appendProperties(builder: StateManager.Builder) { + super.appendProperties(builder) + builder.add(LEVEL) + } + + override fun getLevel(state: FluidState): Int { + return state.get(LEVEL) + } + + override fun isStill(state: FluidState?): Boolean { + return false + } + } + + internal class Still : BrineFluid() { + override fun getLevel(state: FluidState?): Int { + return 8 + } + + override fun isStill(state: FluidState?): Boolean { + return true + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/dev/hybridlabs/aquatic/fluid/HybridAquaticFluids.kt b/src/main/kotlin/dev/hybridlabs/aquatic/fluid/HybridAquaticFluids.kt new file mode 100644 index 000000000..f0023094b --- /dev/null +++ b/src/main/kotlin/dev/hybridlabs/aquatic/fluid/HybridAquaticFluids.kt @@ -0,0 +1,19 @@ +package dev.hybridlabs.aquatic.fluid + +import dev.hybridlabs.aquatic.HybridAquatic +import net.minecraft.fluid.FlowableFluid +import net.minecraft.fluid.Fluid +import net.minecraft.registry.Registries +import net.minecraft.registry.Registry +import net.minecraft.util.Identifier + +object HybridAquaticFluids { + + val BRINE = register("brine", BrineFluid()) as FlowableFluid + + val FLOWING_BRINE = register("flowing_brine", BrineFluid()) as FlowableFluid + + private fun register(id: String, fluid: Fluid): Fluid { + return Registry.register(Registries.FLUID, Identifier(HybridAquatic.MOD_ID, id), fluid) + } +} \ No newline at end of file diff --git a/src/main/kotlin/dev/hybridlabs/aquatic/item/HybridAquaticItemGroups.kt b/src/main/kotlin/dev/hybridlabs/aquatic/item/HybridAquaticItemGroups.kt index 77283a89b..f894c7ca8 100644 --- a/src/main/kotlin/dev/hybridlabs/aquatic/item/HybridAquaticItemGroups.kt +++ b/src/main/kotlin/dev/hybridlabs/aquatic/item/HybridAquaticItemGroups.kt @@ -191,7 +191,8 @@ object HybridAquaticItemGroups { entries.add(HybridAquaticItems.CREEPERMAGNET_HOOK) entries.add(HybridAquaticItems.OMINOUS_HOOK) - // fishing net + // tools + entries.add(HybridAquaticItems.BRINE_BUCKET) entries.add(HybridAquaticItems.SEASHELL_SPEAR) entries.add(HybridAquaticItems.SEASHELL_PICKAXE) entries.add(HybridAquaticItems.SEASHELL_AXE) diff --git a/src/main/kotlin/dev/hybridlabs/aquatic/item/HybridAquaticItems.kt b/src/main/kotlin/dev/hybridlabs/aquatic/item/HybridAquaticItems.kt index 97ecc8aac..a31e576d9 100644 --- a/src/main/kotlin/dev/hybridlabs/aquatic/item/HybridAquaticItems.kt +++ b/src/main/kotlin/dev/hybridlabs/aquatic/item/HybridAquaticItems.kt @@ -5,6 +5,7 @@ package dev.hybridlabs.aquatic.item import dev.hybridlabs.aquatic.HybridAquatic import dev.hybridlabs.aquatic.block.HybridAquaticBlocks import dev.hybridlabs.aquatic.entity.HybridAquaticEntityTypes +import dev.hybridlabs.aquatic.fluid.BrineFluid import net.fabricmc.fabric.api.item.v1.FabricItemSettings import net.minecraft.block.Block import net.minecraft.entity.EntityType @@ -46,6 +47,7 @@ object HybridAquaticItems { val PEARL = register("pearl", Item(FabricItemSettings())) val BLACK_PEARL = register("black_pearl", Item(FabricItemSettings())) val CUTTLEBONE = register("cuttlebone", Item(FabricItemSettings())) + val BRINE_BUCKET = register("brine_bucket", BucketItem(BrineFluid(), FabricItemSettings())) val SEASHELL_SPEAR = register("seashell_spear", SwordItem(HybridAquaticToolMaterials.SEASHELL, 3,