Vents bubble columns
This commit is contained in:
parent
554a3d6401
commit
64846da8c2
4 changed files with 74 additions and 2 deletions
|
@ -1,20 +1,28 @@
|
||||||
package ru.betterend.blocks;
|
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.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockEntityProvider;
|
import net.minecraft.block.BlockEntityProvider;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
|
import net.minecraft.block.BubbleColumnBlock;
|
||||||
import net.minecraft.block.FluidFillable;
|
import net.minecraft.block.FluidFillable;
|
||||||
import net.minecraft.block.Material;
|
import net.minecraft.block.Material;
|
||||||
import net.minecraft.block.ShapeContext;
|
import net.minecraft.block.ShapeContext;
|
||||||
import net.minecraft.block.Waterloggable;
|
import net.minecraft.block.Waterloggable;
|
||||||
import net.minecraft.block.entity.BlockEntity;
|
import net.minecraft.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.fluid.Fluid;
|
import net.minecraft.fluid.Fluid;
|
||||||
import net.minecraft.fluid.FluidState;
|
import net.minecraft.fluid.FluidState;
|
||||||
import net.minecraft.fluid.Fluids;
|
import net.minecraft.fluid.Fluids;
|
||||||
import net.minecraft.item.ItemPlacementContext;
|
import net.minecraft.item.ItemPlacementContext;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.server.world.ServerWorld;
|
||||||
import net.minecraft.sound.BlockSoundGroup;
|
import net.minecraft.sound.BlockSoundGroup;
|
||||||
import net.minecraft.state.StateManager;
|
import net.minecraft.state.StateManager;
|
||||||
import net.minecraft.state.property.BooleanProperty;
|
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.math.Direction;
|
||||||
import net.minecraft.util.shape.VoxelShape;
|
import net.minecraft.util.shape.VoxelShape;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.BlockView;
|
||||||
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.WorldAccess;
|
import net.minecraft.world.WorldAccess;
|
||||||
import net.minecraft.world.WorldView;
|
import net.minecraft.world.WorldView;
|
||||||
import ru.betterend.blocks.basis.BlockBaseNotFull;
|
import ru.betterend.blocks.basis.BlockBaseNotFull;
|
||||||
|
@ -73,9 +82,10 @@ public class BlockHydrothermalVent extends BlockBaseNotFull implements BlockEnti
|
||||||
if (!canPlaceAt(state, world, pos)) {
|
if (!canPlaceAt(state, world, pos)) {
|
||||||
return Blocks.WATER.getDefaultState();
|
return Blocks.WATER.getDefaultState();
|
||||||
}
|
}
|
||||||
else {
|
else if (state.get(WATERLOGGED) && facing == Direction.UP && neighborState.isOf(Blocks.WATER)) {
|
||||||
return state;
|
world.getBlockTickScheduler().schedule(pos, this, 20);
|
||||||
}
|
}
|
||||||
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -94,4 +104,16 @@ public class BlockHydrothermalVent extends BlockBaseNotFull implements BlockEnti
|
||||||
public BlockEntity createBlockEntity(BlockView world) {
|
public BlockEntity createBlockEntity(BlockView world) {
|
||||||
return new BlockEntityHydrothermalVent();
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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<Boolean> 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<Boolean> info) {
|
||||||
|
if (info.getReturnValue()) {
|
||||||
|
BlockState state = world.getBlockState(pos.down());
|
||||||
|
if (state.isOf(EndBlocks.HYDROTHERMAL_VENT)) {
|
||||||
|
info.setReturnValue(false);
|
||||||
|
info.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,6 +5,7 @@ import java.util.function.Function;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
|
import net.minecraft.block.BubbleColumnBlock;
|
||||||
import net.minecraft.block.Material;
|
import net.minecraft.block.Material;
|
||||||
import net.minecraft.client.util.math.Vector3f;
|
import net.minecraft.client.util.math.Vector3f;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
@ -161,6 +162,13 @@ public class GeyserFeature extends DefaultFeature {
|
||||||
mut.setY(mut.getY() + 1);
|
mut.setY(mut.getY() + 1);
|
||||||
}
|
}
|
||||||
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.HYDROTHERMAL_VENT);
|
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));
|
||||||
|
mut.setY(mut.getY() + 1);
|
||||||
|
state = world.getBlockState(mut);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
"AnvilScreenHandlerMixin",
|
"AnvilScreenHandlerMixin",
|
||||||
"ServerPlayerEntityMixin",
|
"ServerPlayerEntityMixin",
|
||||||
"ChorusPlantFeatureMixin",
|
"ChorusPlantFeatureMixin",
|
||||||
|
"BubbleColumnBlockMixin",
|
||||||
"ChorusFlowerBlockMixin",
|
"ChorusFlowerBlockMixin",
|
||||||
"LandPathNodeMakerMixin",
|
"LandPathNodeMakerMixin",
|
||||||
"ChorusPlantBlockMixin",
|
"ChorusPlantBlockMixin",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue