-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7f0383d
commit eec8aa4
Showing
7 changed files
with
135 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
src/main/kotlin/dev/hybridlabs/aquatic/fluid/BrineFluid.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Fluid?, FluidState?>) { | ||
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 | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/kotlin/dev/hybridlabs/aquatic/fluid/HybridAquaticFluids.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters