partial implementation of rockmelt fluid
Some checks failed
build / build (push) Failing after 6m48s

This commit is contained in:
CosmoOrSth
2025-11-04 18:02:34 +05:30
parent df1a6135ab
commit cb307f1017
16 changed files with 5480 additions and 4 deletions

View File

@@ -1,10 +1,12 @@
package com.smithy.scorched_earth;
import com.smithy.scorched_earth.fluid_renderers.RockmeltRenderer;
import net.fabricmc.api.ClientModInitializer;
public class ScorchedEarthClient implements ClientModInitializer {
@Override
public void onInitializeClient() {
// This entrypoint is suitable for setting up client-specific logic, such as rendering.
RockmeltRenderer.register();
}
}

View File

@@ -0,0 +1,17 @@
package com.smithy.scorched_earth.fluid_renderers;
import com.smithy.scorched_earth.registry.FluidRegistries;
import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandlerRegistry;
import net.fabricmc.fabric.api.client.render.fluid.v1.SimpleFluidRenderHandler;
import net.minecraft.util.Identifier;
public class RockmeltRenderer {
public static void register() {
FluidRenderHandlerRegistry.INSTANCE.register(FluidRegistries.STILL_ROCKMELT, FluidRegistries.FLOWING_ROCKMELT, new SimpleFluidRenderHandler(
new Identifier("scorched_earth:block/rockmelt_still"),
new Identifier("scorched_earth:block/rockmelt_flowing")
));
}
}

View File

@@ -1,5 +1,8 @@
package com.smithy.scorched_earth;
import com.smithy.scorched_earth.blocks.FluidBlocks;
import com.smithy.scorched_earth.items.BucketItems;
import com.smithy.scorched_earth.registry.FluidRegistries;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.minecraft.item.ItemGroups;
@@ -23,6 +26,9 @@ public class ScorchedEarth implements ModInitializer {
// However, some things (like resources) may still be uninitialized.
// Proceed with mild caution.
BlockRegistries.register();
FluidRegistries.register();
BucketItems.register();
FluidBlocks.register();
ItemGroupEvents.modifyEntriesEvent(ItemGroups.NATURAL)
.register((content) -> {

View File

@@ -0,0 +1,22 @@
package com.smithy.scorched_earth.blocks;
import com.smithy.scorched_earth.ScorchedEarth;
import com.smithy.scorched_earth.registry.FluidRegistries;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.block.FluidBlock;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.util.Identifier;
public class FluidBlocks {
public static Block ROCKMELT;
public static void register() {
ROCKMELT = Registry.register(Registries.BLOCK, new Identifier(ScorchedEarth.MOD_ID, "rockmelt"),
new FluidBlock(FluidRegistries.STILL_ROCKMELT, FabricBlockSettings.copy(Blocks.LAVA)));
}
}

View File

@@ -0,0 +1,250 @@
package com.smithy.scorched_earth.fluids;
import com.smithy.scorched_earth.blocks.FluidBlocks;
import com.smithy.scorched_earth.items.BucketItems;
import com.smithy.scorched_earth.registry.FluidRegistries;
import net.minecraft.block.*;
import net.minecraft.fluid.*;
import net.minecraft.item.Item;
import net.minecraft.item.Items;
import net.minecraft.particle.ParticleEffect;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.registry.tag.FluidTags;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvent;
import net.minecraft.sound.SoundEvents;
import net.minecraft.state.StateManager;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.random.Random;
import net.minecraft.world.*;
import org.jetbrains.annotations.Nullable;
import java.util.Optional;
public abstract class RockmeltFluid extends FlowableFluid {
@Override
public Fluid getFlowing() {
return FluidRegistries.FLOWING_ROCKMELT;
}
@Override
public Fluid getStill() {
return FluidRegistries.STILL_ROCKMELT;
}
@Override
public Item getBucketItem() {
return BucketItems.ROCKMELT_BUCKET;
}
@Override
public void randomDisplayTick(World world, BlockPos pos, FluidState state, Random random) {
BlockPos blockPos = pos.up();
if (world.getBlockState(blockPos).isAir() && !world.getBlockState(blockPos).isOpaqueFullCube(world, blockPos)) {
if (random.nextInt(100) == 0) {
double d = pos.getX() + random.nextDouble();
double e = pos.getY() + 1.0;
double f = pos.getZ() + random.nextDouble();
world.addParticle(ParticleTypes.LAVA, d, e, f, 0.0, 0.0, 0.0);
world.playSound(d, e, f, SoundEvents.BLOCK_LAVA_POP, SoundCategory.BLOCKS, 0.2F + random.nextFloat() * 0.2F, 0.9F + random.nextFloat() * 0.15F, false);
}
if (random.nextInt(200) == 0) {
world.playSound(
pos.getX(),
pos.getY(),
pos.getZ(),
SoundEvents.BLOCK_LAVA_AMBIENT,
SoundCategory.BLOCKS,
0.2F + random.nextFloat() * 0.2F,
0.9F + random.nextFloat() * 0.15F,
false
);
}
}
}
@Override
public void onRandomTick(World world, BlockPos pos, FluidState state, Random random) {
if (world.getGameRules().getBoolean(GameRules.DO_FIRE_TICK)) {
int i = random.nextInt(3);
if (i > 0) {
BlockPos blockPos = pos;
for (int j = 0; j < i; j++) {
blockPos = blockPos.add(random.nextInt(3) - 1, 1, random.nextInt(3) - 1);
if (!world.canSetBlock(blockPos)) {
return;
}
BlockState blockState = world.getBlockState(blockPos);
if (blockState.isAir()) {
if (this.canLightFire(world, blockPos)) {
world.setBlockState(blockPos, AbstractFireBlock.getState(world, blockPos));
return;
}
} else if (blockState.blocksMovement()) {
return;
}
}
} else {
for (int k = 0; k < 3; k++) {
BlockPos blockPos2 = pos.add(random.nextInt(3) - 1, 0, random.nextInt(3) - 1);
if (!world.canSetBlock(blockPos2)) {
return;
}
if (world.isAir(blockPos2.up()) && this.hasBurnableBlock(world, blockPos2)) {
world.setBlockState(blockPos2.up(), AbstractFireBlock.getState(world, blockPos2));
}
}
}
}
}
private boolean canLightFire(WorldView world, BlockPos pos) {
for (Direction direction : Direction.values()) {
if (this.hasBurnableBlock(world, pos.offset(direction))) {
return true;
}
}
return false;
}
private boolean hasBurnableBlock(WorldView world, BlockPos pos) {
return pos.getY() >= world.getBottomY() && pos.getY() < world.getTopY() && !world.isChunkLoaded(pos) ? false : world.getBlockState(pos).isBurnable();
}
@Nullable
@Override
public ParticleEffect getParticle() {
return ParticleTypes.DRIPPING_LAVA;
}
@Override
protected void beforeBreakingBlock(WorldAccess world, BlockPos pos, BlockState state) {
this.playExtinguishEvent(world, pos);
}
@Override
public int getFlowSpeed(WorldView world) {
return world.getDimension().ultrawarm() ? 4 : 2;
}
@Override
public BlockState toBlockState(FluidState state) {
return FluidBlocks.ROCKMELT.getDefaultState().with(FluidBlock.LEVEL, getBlockStateLevel(state));
}
@Override
public boolean matchesType(Fluid fluid) {
return fluid == FluidRegistries.STILL_ROCKMELT || fluid == FluidRegistries.FLOWING_ROCKMELT;
}
@Override
public int getLevelDecreasePerBlock(WorldView world) {
return world.getDimension().ultrawarm() ? 1 : 2;
}
@Override
public boolean canBeReplacedWith(FluidState state, BlockView world, BlockPos pos, Fluid fluid, Direction direction) {
return state.getHeight(world, pos) >= 0.44444445F && fluid.isIn(FluidTags.WATER);
}
@Override
public int getTickRate(WorldView world) {
return world.getDimension().ultrawarm() ? 10 : 30;
}
@Override
public int getNextTickDelay(World world, BlockPos pos, FluidState oldState, FluidState newState) {
int i = this.getTickRate(world);
if (!oldState.isEmpty()
&& !newState.isEmpty()
&& !(Boolean)oldState.get(FALLING)
&& !(Boolean)newState.get(FALLING)
&& newState.getHeight(world, pos) > oldState.getHeight(world, pos)
&& world.getRandom().nextInt(4) != 0) {
i *= 4;
}
return i;
}
private void playExtinguishEvent(WorldAccess world, BlockPos pos) {
world.syncWorldEvent(WorldEvents.LAVA_EXTINGUISHED, pos, 0);
}
@Override
protected boolean isInfinite(World world) {
return false;
}
/* @Override
protected void flow(WorldAccess world, BlockPos pos, BlockState state, Direction direction, FluidState fluidState) {
if (direction == Direction.DOWN) {
FluidState fluidState2 = world.getFluidState(pos);
if (this.isIn(FluidTags.LAVA) && fluidState2.isIn(FluidTags.WATER)) {
if (state.getBlock() instanceof FluidBlock) {
world.setBlockState(pos, Blocks.STONE.getDefaultState(), Block.NOTIFY_ALL);
}
this.playExtinguishEvent(world, pos);
return;
}
}
super.flow(world, pos, state, direction, fluidState);
} */
@Override
protected boolean hasRandomTicks() {
return true;
}
@Override
protected float getBlastResistance() {
return 100.0F;
}
@Override
public Optional<SoundEvent> getBucketFillSound() {
return Optional.of(SoundEvents.ITEM_BUCKET_FILL_LAVA);
}
public static class Flowing extends RockmeltFluid {
@Override
protected void appendProperties(StateManager.Builder<Fluid, FluidState> builder) {
super.appendProperties(builder);
builder.add(LEVEL);
}
@Override
public int getLevel(FluidState state) {
return (Integer)state.get(LEVEL);
}
@Override
public boolean isStill(FluidState state) {
return false;
}
}
public static class Still extends RockmeltFluid {
@Override
public int getLevel(FluidState state) {
return 8;
}
@Override
public boolean isStill(FluidState state) {
return true;
}
}
}

View File

@@ -0,0 +1,21 @@
package com.smithy.scorched_earth.items;
import com.smithy.scorched_earth.ScorchedEarth;
import com.smithy.scorched_earth.registry.FluidRegistries;
import net.minecraft.item.BucketItem;
import net.minecraft.item.Item;
import net.minecraft.item.Items;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.util.Identifier;
public class BucketItems {
public static Item ROCKMELT_BUCKET;
public static void register() {
ROCKMELT_BUCKET = Registry.register(Registries.ITEM, new Identifier(ScorchedEarth.MOD_ID, "rockmelt_bucket"),
new BucketItem(FluidRegistries.STILL_ROCKMELT, new Item.Settings().recipeRemainder(Items.BUCKET).maxCount(1)));
}
}

View File

@@ -0,0 +1,20 @@
package com.smithy.scorched_earth.registry;
import com.smithy.scorched_earth.ScorchedEarth;
import com.smithy.scorched_earth.fluids.RockmeltFluid;
import net.minecraft.fluid.FlowableFluid;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.util.Identifier;
public class FluidRegistries {
public static FlowableFluid STILL_ROCKMELT;
public static FlowableFluid FLOWING_ROCKMELT;
public static void register() {
STILL_ROCKMELT = Registry.register(Registries.FLUID, new Identifier(ScorchedEarth.MOD_ID, "rockmelt"), new RockmeltFluid.Still());
FLOWING_ROCKMELT = Registry.register(Registries.FLUID, new Identifier(ScorchedEarth.MOD_ID, "flowing_rockmelt"), new RockmeltFluid.Flowing());
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@@ -0,0 +1,11 @@
{
"animation": {
"frametime": 8,
"interpolate": true,
"frames": [
0,
1,
2
]
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@@ -0,0 +1,11 @@
{
"animation": {
"frametime": 8,
"interpolate": true,
"frames": [
0,
1,
2
]
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,3 @@
{
"feature"
}

View File

@@ -0,0 +1,20 @@
{
"ultrawarm": true,
"natural": true,
"piglin_safe": false,
"respawn_anchor_works": false,
"bed_works": true,
"has_raids": true,
"has_skylight": true,
"has_ceiling": false,
"coordinate_scale": 1,
"ambient_light": 0,
"fixed_time": 6000,
"logical_height": 2032,
"effects": "minecraft:the_nether",
"infiniburn": "#minecraft:infiniburn_overworld",
"min_y": -64,
"height": 2032,
"monster_spawn_light_level": 0,
"monster_spawn_block_light_limit": 0
}

View File

@@ -1,14 +1,27 @@
{
"dimensions": {
"minecraft:overworld": {
"type": "minecraft:overworld",
"type": "scorched_earth:scorched_type",
"generator": {
"type": "minecraft:noise",
"settings": "scorched_earth:scorched_earth",
"biome_source": {
"type": "minecraft:multi_noise",
"preset": "minecraft:overworld"
},
"settings": "minecraft:overworld"
"biomes": [
{
"biome": "minecraft:ocean",
"parameters": {
"temperature": 0,
"humidity": 0,
"continentalness": 0,
"erosion": 0,
"weirdness": 0,
"depth": 0,
"offset": 0
}
}
]
}
}
}
}