Merge branch 'master' of https://github.com/paulevsGitch/BetterEnd
This commit is contained in:
commit
74d334e7dd
5 changed files with 115 additions and 12 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;
|
||||||
|
@ -139,7 +140,7 @@ public class GeyserFeature extends DefaultFeature {
|
||||||
BlocksHelper.setWithoutUpdate(world, pos, WATER);
|
BlocksHelper.setWithoutUpdate(world, pos, WATER);
|
||||||
Mutable mut = new Mutable().set(pos);
|
Mutable mut = new Mutable().set(pos);
|
||||||
count = getYOnSurface(world, pos.getX(), pos.getZ()) - pos.getY();
|
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);
|
BlocksHelper.setWithoutUpdate(world, mut, WATER);
|
||||||
for (Direction dir: BlocksHelper.HORIZONTAL) {
|
for (Direction dir: BlocksHelper.HORIZONTAL) {
|
||||||
BlocksHelper.setWithoutUpdate(world, mut.offset(dir), WATER);
|
BlocksHelper.setWithoutUpdate(world, mut.offset(dir), WATER);
|
||||||
|
@ -161,6 +162,14 @@ 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));
|
||||||
|
world.getBlockTickScheduler().schedule(mut, Blocks.BUBBLE_COLUMN, MHelper.randRange(8, 32, random));
|
||||||
|
mut.setY(mut.getY() + 1);
|
||||||
|
state = world.getBlockState(mut);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import com.google.common.collect.Sets;
|
||||||
|
|
||||||
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.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.BlockPos.Mutable;
|
import net.minecraft.util.math.BlockPos.Mutable;
|
||||||
|
@ -38,7 +39,7 @@ public class SulphuricCaveFeature extends DefaultFeature {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Mutable bpos = new Mutable();
|
Mutable mut = new Mutable();
|
||||||
pos = new BlockPos(pos.getX(), MHelper.randRange(bottom, top, random), pos.getZ());
|
pos = new BlockPos(pos.getX(), MHelper.randRange(bottom, top, random), pos.getZ());
|
||||||
|
|
||||||
OpenSimplexNoise noise = new OpenSimplexNoise(MHelper.getSeed(534, pos.getX(), 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++) {
|
for (int x = x1; x <= x2; x++) {
|
||||||
int xsq = x - pos.getX();
|
int xsq = x - pos.getX();
|
||||||
xsq *= xsq;
|
xsq *= xsq;
|
||||||
bpos.setX(x);
|
mut.setX(x);
|
||||||
for (int z = z1; z <= z2; z++) {
|
for (int z = z1; z <= z2; z++) {
|
||||||
int zsq = z - pos.getZ();
|
int zsq = z - pos.getZ();
|
||||||
zsq *= zsq;
|
zsq *= zsq;
|
||||||
bpos.setZ(z);
|
mut.setZ(z);
|
||||||
for (int y = y1; y <= y2; y++) {
|
for (int y = y1; y <= y2; y++) {
|
||||||
int ysq = y - pos.getY();
|
int ysq = y - pos.getY();
|
||||||
ysq *= 1.6;
|
ysq *= 1.6;
|
||||||
ysq *= ysq;
|
ysq *= ysq;
|
||||||
bpos.setY(y);
|
mut.setY(y);
|
||||||
double r = noise.eval(x * 0.1, y * 0.1, z * 0.1) * nr + hr;
|
double r = noise.eval(x * 0.1, y * 0.1, z * 0.1) * nr + hr;
|
||||||
double r2 = r + 5;
|
double r2 = r + 5;
|
||||||
double dist = xsq + ysq + zsq;
|
double dist = xsq + ysq + zsq;
|
||||||
if (dist < r * r) {
|
if (dist < r * r) {
|
||||||
BlockState state = world.getBlockState(bpos);
|
BlockState state = world.getBlockState(mut);
|
||||||
if (isReplaceable(state)) {
|
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) {
|
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;
|
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) {
|
if (v > 0.4) {
|
||||||
brimstone.add(bpos.toImmutable());
|
brimstone.add(mut.toImmutable());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
BlocksHelper.setWithoutUpdate(world, bpos, rock);
|
BlocksHelper.setWithoutUpdate(world, mut, rock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,6 +97,34 @@ public class SulphuricCaveFeature extends DefaultFeature {
|
||||||
placeBrimstone(world, blockPos, random);
|
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));
|
BlocksHelper.fixBlocks(world, new BlockPos(x1, y1, z1), new BlockPos(x2, y2, z2));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -104,6 +133,7 @@ public class SulphuricCaveFeature extends DefaultFeature {
|
||||||
private boolean isReplaceable(BlockState state) {
|
private boolean isReplaceable(BlockState state) {
|
||||||
return state.isIn(EndTags.GEN_TERRAIN)
|
return state.isIn(EndTags.GEN_TERRAIN)
|
||||||
|| state.isOf(EndBlocks.HYDROTHERMAL_VENT)
|
|| state.isOf(EndBlocks.HYDROTHERMAL_VENT)
|
||||||
|
|| state.isOf(Blocks.BUBBLE_COLUMN)
|
||||||
|| state.isOf(EndBlocks.SULPHUR_CRYSTAL)
|
|| state.isOf(EndBlocks.SULPHUR_CRYSTAL)
|
||||||
|| state.getMaterial().isReplaceable()
|
|| state.getMaterial().isReplaceable()
|
||||||
|| state.getMaterial().equals(Material.PLANT)
|
|| state.getMaterial().equals(Material.PLANT)
|
||||||
|
|
|
@ -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