diff --git a/src/main/java/ru/betterend/blocks/BlockHydrothermalVent.java b/src/main/java/ru/betterend/blocks/BlockHydrothermalVent.java index a638d0fd..1af7533b 100644 --- a/src/main/java/ru/betterend/blocks/BlockHydrothermalVent.java +++ b/src/main/java/ru/betterend/blocks/BlockHydrothermalVent.java @@ -1,20 +1,28 @@ package ru.betterend.blocks; +import java.util.Random; + +import org.jetbrains.annotations.Nullable; + import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; import net.minecraft.block.Block; import net.minecraft.block.BlockEntityProvider; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; +import net.minecraft.block.BubbleColumnBlock; import net.minecraft.block.FluidFillable; import net.minecraft.block.Material; import net.minecraft.block.ShapeContext; import net.minecraft.block.Waterloggable; import net.minecraft.block.entity.BlockEntity; +import net.minecraft.entity.LivingEntity; import net.minecraft.fluid.Fluid; import net.minecraft.fluid.FluidState; import net.minecraft.fluid.Fluids; import net.minecraft.item.ItemPlacementContext; +import net.minecraft.item.ItemStack; +import net.minecraft.server.world.ServerWorld; import net.minecraft.sound.BlockSoundGroup; import net.minecraft.state.StateManager; import net.minecraft.state.property.BooleanProperty; @@ -23,6 +31,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.util.shape.VoxelShape; import net.minecraft.world.BlockView; +import net.minecraft.world.World; import net.minecraft.world.WorldAccess; import net.minecraft.world.WorldView; import ru.betterend.blocks.basis.BlockBaseNotFull; @@ -73,9 +82,10 @@ public class BlockHydrothermalVent extends BlockBaseNotFull implements BlockEnti if (!canPlaceAt(state, world, pos)) { return Blocks.WATER.getDefaultState(); } - else { - return state; + else if (state.get(WATERLOGGED) && facing == Direction.UP && neighborState.isOf(Blocks.WATER)) { + world.getBlockTickScheduler().schedule(pos, this, 20); } + return state; } @Override @@ -94,4 +104,16 @@ public class BlockHydrothermalVent extends BlockBaseNotFull implements BlockEnti public BlockEntity createBlockEntity(BlockView world) { return new BlockEntityHydrothermalVent(); } + + @Override + public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { + BubbleColumnBlock.update(world, pos.up(), false); + } + + @Override + public void onPlaced(World world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack itemStack) { + if (world instanceof ServerWorld && state.get(WATERLOGGED) && world.getBlockState(pos.up()).isOf(Blocks.WATER)) { + scheduledTick(state,(ServerWorld) world, pos, world.random); + } + } } diff --git a/src/main/java/ru/betterend/mixin/common/BubbleColumnBlockMixin.java b/src/main/java/ru/betterend/mixin/common/BubbleColumnBlockMixin.java new file mode 100644 index 00000000..968b1ffa --- /dev/null +++ b/src/main/java/ru/betterend/mixin/common/BubbleColumnBlockMixin.java @@ -0,0 +1,41 @@ +package ru.betterend.mixin.common; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.BubbleColumnBlock; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.BlockView; +import net.minecraft.world.WorldView; +import ru.betterend.registry.EndBlocks; + +@Mixin(value = BubbleColumnBlock.class, priority = 100) +public abstract class BubbleColumnBlockMixin extends Block { + public BubbleColumnBlockMixin(Settings settings) { + super(settings); + } + + @Inject(method = "canPlaceAt", at = @At("HEAD"), cancellable = true) + private void beCanPlace(BlockState state, WorldView world, BlockPos pos, CallbackInfoReturnable info) { + BlockState blockState = world.getBlockState(pos.down()); + if (blockState.isOf(EndBlocks.HYDROTHERMAL_VENT)) { + info.setReturnValue(true); + info.cancel(); + } + } + + @Inject(method = "calculateDrag", at = @At("RETURN"), cancellable = true) + private static void beCalculateDrag(BlockView world, BlockPos pos, CallbackInfoReturnable info) { + if (info.getReturnValue()) { + BlockState state = world.getBlockState(pos.down()); + if (state.isOf(EndBlocks.HYDROTHERMAL_VENT)) { + info.setReturnValue(false); + info.cancel(); + } + } + } +} diff --git a/src/main/java/ru/betterend/world/features/terrain/GeyserFeature.java b/src/main/java/ru/betterend/world/features/terrain/GeyserFeature.java index 7b46cc8d..630ca1a0 100644 --- a/src/main/java/ru/betterend/world/features/terrain/GeyserFeature.java +++ b/src/main/java/ru/betterend/world/features/terrain/GeyserFeature.java @@ -5,6 +5,7 @@ import java.util.function.Function; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; +import net.minecraft.block.BubbleColumnBlock; import net.minecraft.block.Material; import net.minecraft.client.util.math.Vector3f; import net.minecraft.util.math.BlockPos; @@ -139,7 +140,7 @@ public class GeyserFeature extends DefaultFeature { BlocksHelper.setWithoutUpdate(world, pos, WATER); Mutable mut = new Mutable().set(pos); count = getYOnSurface(world, pos.getX(), pos.getZ()) - pos.getY(); - for (int i = 0; i < count; i++) { + for (int i = 0; i <= count; i++) { BlocksHelper.setWithoutUpdate(world, mut, WATER); for (Direction dir: BlocksHelper.HORIZONTAL) { BlocksHelper.setWithoutUpdate(world, mut.offset(dir), WATER); @@ -161,6 +162,14 @@ public class GeyserFeature extends DefaultFeature { mut.setY(mut.getY() + 1); } BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.HYDROTHERMAL_VENT); + mut.setY(mut.getY() + 1); + state = world.getBlockState(mut); + while (state.isOf(Blocks.WATER)) { + BlocksHelper.setWithoutUpdate(world, mut, Blocks.BUBBLE_COLUMN.getDefaultState().with(BubbleColumnBlock.DRAG, false)); + world.getBlockTickScheduler().schedule(mut, Blocks.BUBBLE_COLUMN, MHelper.randRange(8, 32, random)); + mut.setY(mut.getY() + 1); + state = world.getBlockState(mut); + } } } diff --git a/src/main/java/ru/betterend/world/features/terrain/SulphuricCaveFeature.java b/src/main/java/ru/betterend/world/features/terrain/SulphuricCaveFeature.java index 282af535..c08cb175 100644 --- a/src/main/java/ru/betterend/world/features/terrain/SulphuricCaveFeature.java +++ b/src/main/java/ru/betterend/world/features/terrain/SulphuricCaveFeature.java @@ -7,6 +7,7 @@ import com.google.common.collect.Sets; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; +import net.minecraft.block.BubbleColumnBlock; import net.minecraft.block.Material; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos.Mutable; @@ -38,7 +39,7 @@ public class SulphuricCaveFeature extends DefaultFeature { return false; } - Mutable bpos = new Mutable(); + Mutable mut = new Mutable(); pos = new BlockPos(pos.getX(), MHelper.randRange(bottom, top, random), pos.getZ()); OpenSimplexNoise noise = new OpenSimplexNoise(MHelper.getSeed(534, pos.getX(), pos.getZ())); @@ -59,33 +60,33 @@ public class SulphuricCaveFeature extends DefaultFeature { for (int x = x1; x <= x2; x++) { int xsq = x - pos.getX(); xsq *= xsq; - bpos.setX(x); + mut.setX(x); for (int z = z1; z <= z2; z++) { int zsq = z - pos.getZ(); zsq *= zsq; - bpos.setZ(z); + mut.setZ(z); for (int y = y1; y <= y2; y++) { int ysq = y - pos.getY(); ysq *= 1.6; ysq *= ysq; - bpos.setY(y); + mut.setY(y); double r = noise.eval(x * 0.1, y * 0.1, z * 0.1) * nr + hr; double r2 = r + 5; double dist = xsq + ysq + zsq; if (dist < r * r) { - BlockState state = world.getBlockState(bpos); + BlockState state = world.getBlockState(mut); if (isReplaceable(state)) { - BlocksHelper.setWithoutUpdate(world, bpos, y < waterLevel ? WATER : CAVE_AIR); + BlocksHelper.setWithoutUpdate(world, mut, y < waterLevel ? WATER : CAVE_AIR); } } else if (dist < r2 * r2) { - if (world.getBlockState(bpos).isIn(EndTags.GEN_TERRAIN)) { + if (world.getBlockState(mut).isIn(EndTags.GEN_TERRAIN)) { double v = noise.eval(x * 0.1, y * 0.1, z * 0.1) + noise.eval(x * 0.03, y * 0.03, z * 0.03) * 0.5; if (v > 0.4) { - brimstone.add(bpos.toImmutable()); + brimstone.add(mut.toImmutable()); } else { - BlocksHelper.setWithoutUpdate(world, bpos, rock); + BlocksHelper.setWithoutUpdate(world, mut, rock); } } } @@ -96,6 +97,34 @@ public class SulphuricCaveFeature extends DefaultFeature { placeBrimstone(world, blockPos, random); }); + if (random.nextInt(4) == 0) { + int count = MHelper.randRange(5, 20, random); + for (int i = 0; i < count; i++) { + mut.set(pos).move(MHelper.floor(random.nextGaussian() * 2 + 0.5), 0, MHelper.floor(random.nextGaussian() * 2 + 0.5)); + int dist = MHelper.floor(6 - MHelper.length(mut.getX() - pos.getX(), mut.getZ() - pos.getZ())) + random.nextInt(2); + BlockState state = world.getBlockState(mut); + while (state.isOf(Blocks.WATER)) { + mut.setY(mut.getY() - 1); + state = world.getBlockState(mut); + } + if (state.isIn(EndTags.GEN_TERRAIN) || state.isOf(Blocks.AIR)) { + for (int j = 0; j <= dist; j++) { + BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.SULPHURIC_ROCK.stone); + mut.setY(mut.getY() + 1); + } + BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.HYDROTHERMAL_VENT); + mut.setY(mut.getY() + 1); + state = world.getBlockState(mut); + while (state.isOf(Blocks.WATER)) { + BlocksHelper.setWithoutUpdate(world, mut, Blocks.BUBBLE_COLUMN.getDefaultState().with(BubbleColumnBlock.DRAG, false)); + world.getBlockTickScheduler().schedule(mut, Blocks.BUBBLE_COLUMN, MHelper.randRange(8, 32, random)); + mut.setY(mut.getY() + 1); + state = world.getBlockState(mut); + } + } + } + } + BlocksHelper.fixBlocks(world, new BlockPos(x1, y1, z1), new BlockPos(x2, y2, z2)); return true; @@ -104,6 +133,7 @@ public class SulphuricCaveFeature extends DefaultFeature { private boolean isReplaceable(BlockState state) { return state.isIn(EndTags.GEN_TERRAIN) || state.isOf(EndBlocks.HYDROTHERMAL_VENT) + || state.isOf(Blocks.BUBBLE_COLUMN) || state.isOf(EndBlocks.SULPHUR_CRYSTAL) || state.getMaterial().isReplaceable() || state.getMaterial().equals(Material.PLANT) diff --git a/src/main/resources/betterend.mixins.common.json b/src/main/resources/betterend.mixins.common.json index 9308e018..96268298 100644 --- a/src/main/resources/betterend.mixins.common.json +++ b/src/main/resources/betterend.mixins.common.json @@ -11,6 +11,7 @@ "AnvilScreenHandlerMixin", "ServerPlayerEntityMixin", "ChorusPlantFeatureMixin", + "BubbleColumnBlockMixin", "ChorusFlowerBlockMixin", "LandPathNodeMakerMixin", "ChorusPlantBlockMixin",