Changes to CrystalMountains
This commit is contained in:
parent
1909aea351
commit
84f9c7de9e
7 changed files with 1586 additions and 1612 deletions
|
@ -0,0 +1,122 @@
|
||||||
|
package org.betterx.betterend.blocks;
|
||||||
|
|
||||||
|
import org.betterx.bclib.client.render.BCLRenderLayer;
|
||||||
|
import org.betterx.bclib.interfaces.RenderLayerProvider;
|
||||||
|
import org.betterx.betterend.registry.EndBlocks;
|
||||||
|
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.core.Direction;
|
||||||
|
import net.minecraft.server.level.ServerLevel;
|
||||||
|
import net.minecraft.util.RandomSource;
|
||||||
|
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||||
|
import net.minecraft.world.level.BlockGetter;
|
||||||
|
import net.minecraft.world.level.Level;
|
||||||
|
import net.minecraft.world.level.LevelAccessor;
|
||||||
|
import net.minecraft.world.level.block.*;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import net.minecraft.world.level.block.state.StateDefinition;
|
||||||
|
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||||
|
import net.minecraft.world.level.block.state.properties.BooleanProperty;
|
||||||
|
import net.minecraft.world.level.material.FluidState;
|
||||||
|
import net.minecraft.world.level.material.Fluids;
|
||||||
|
import net.minecraft.world.level.material.Material;
|
||||||
|
import net.minecraft.world.level.material.MaterialColor;
|
||||||
|
|
||||||
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
|
|
||||||
|
public class CrystalMossCoverBlock extends MultifaceBlock implements BonemealableBlock, SimpleWaterloggedBlock, RenderLayerProvider {
|
||||||
|
private static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
|
||||||
|
private final MultifaceSpreader spreader = new MultifaceSpreader(this);
|
||||||
|
|
||||||
|
public CrystalMossCoverBlock(MaterialColor color) {
|
||||||
|
super(FabricBlockSettings.of(Material.REPLACEABLE_PLANT, color)
|
||||||
|
.noCollission()
|
||||||
|
.strength(0.2f)
|
||||||
|
.sound(SoundType.GLOW_LICHEN)
|
||||||
|
.lightLevel(GlowLichenBlock.emission(7)));
|
||||||
|
this.registerDefaultState(this.defaultBlockState().setValue(WATERLOGGED, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
||||||
|
super.createBlockStateDefinition(builder);
|
||||||
|
builder.add(WATERLOGGED);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState updateShape(
|
||||||
|
BlockState blockState,
|
||||||
|
Direction direction,
|
||||||
|
BlockState blockState2,
|
||||||
|
LevelAccessor levelAccessor,
|
||||||
|
BlockPos blockPos,
|
||||||
|
BlockPos blockPos2
|
||||||
|
) {
|
||||||
|
if (blockState.getValue(WATERLOGGED).booleanValue()) {
|
||||||
|
levelAccessor.scheduleTick(blockPos, Fluids.WATER, Fluids.WATER.getTickDelay(levelAccessor));
|
||||||
|
}
|
||||||
|
return super.updateShape(blockState, direction, blockState2, levelAccessor, blockPos, blockPos2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canBeReplaced(BlockState blockState, BlockPlaceContext blockPlaceContext) {
|
||||||
|
return !blockPlaceContext.getItemInHand().is(EndBlocks.CRYSTAL_MOSS_COVER.asItem()) || super.canBeReplaced(
|
||||||
|
blockState,
|
||||||
|
blockPlaceContext
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isValidBonemealTarget(
|
||||||
|
BlockGetter blockGetter,
|
||||||
|
BlockPos blockPos,
|
||||||
|
BlockState blockState,
|
||||||
|
boolean bl
|
||||||
|
) {
|
||||||
|
return Direction.stream()
|
||||||
|
.anyMatch(direction -> this.spreader.canSpreadInAnyDirection(
|
||||||
|
blockState,
|
||||||
|
blockGetter,
|
||||||
|
blockPos,
|
||||||
|
direction.getOpposite()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isBonemealSuccess(Level level, RandomSource randomSource, BlockPos blockPos, BlockState blockState) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void performBonemeal(
|
||||||
|
ServerLevel serverLevel,
|
||||||
|
RandomSource randomSource,
|
||||||
|
BlockPos blockPos,
|
||||||
|
BlockState blockState
|
||||||
|
) {
|
||||||
|
this.spreader.spreadFromRandomFaceTowardRandomDirection(blockState, serverLevel, blockPos, randomSource);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FluidState getFluidState(BlockState blockState) {
|
||||||
|
if (blockState.getValue(WATERLOGGED).booleanValue()) {
|
||||||
|
return Fluids.WATER.getSource(false);
|
||||||
|
}
|
||||||
|
return super.getFluidState(blockState);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean propagatesSkylightDown(BlockState blockState, BlockGetter blockGetter, BlockPos blockPos) {
|
||||||
|
return blockState.getFluidState().isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MultifaceSpreader getSpreader() {
|
||||||
|
return this.spreader;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BCLRenderLayer getRenderLayer() {
|
||||||
|
return BCLRenderLayer.CUTOUT;
|
||||||
|
}
|
||||||
|
}
|
|
@ -41,6 +41,10 @@ public class EndBlocks {
|
||||||
"crystal_moss",
|
"crystal_moss",
|
||||||
new EndTerrainBlock(MaterialColor.COLOR_PINK)
|
new EndTerrainBlock(MaterialColor.COLOR_PINK)
|
||||||
);
|
);
|
||||||
|
public static final Block CRYSTAL_MOSS_COVER = registerBlock(
|
||||||
|
"crystal_moss_cover",
|
||||||
|
new CrystalMossCoverBlock(MaterialColor.COLOR_PINK)
|
||||||
|
);
|
||||||
public static final Block SHADOW_GRASS = registerBlock("shadow_grass", new ShadowGrassBlock());
|
public static final Block SHADOW_GRASS = registerBlock("shadow_grass", new ShadowGrassBlock());
|
||||||
public static final Block PINK_MOSS = registerBlock("pink_moss", new EndTerrainBlock(MaterialColor.COLOR_PINK));
|
public static final Block PINK_MOSS = registerBlock("pink_moss", new EndTerrainBlock(MaterialColor.COLOR_PINK));
|
||||||
public static final Block AMBER_MOSS = registerBlock("amber_moss", new EndTerrainBlock(MaterialColor.COLOR_ORANGE));
|
public static final Block AMBER_MOSS = registerBlock("amber_moss", new EndTerrainBlock(MaterialColor.COLOR_ORANGE));
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package org.betterx.betterend.world.structures.piece;
|
package org.betterx.betterend.world.structures.piece;
|
||||||
|
|
||||||
import org.betterx.bclib.util.MHelper;
|
import org.betterx.bclib.util.MHelper;
|
||||||
|
import org.betterx.betterend.blocks.CrystalMossCoverBlock;
|
||||||
import org.betterx.betterend.registry.EndBlocks;
|
import org.betterx.betterend.registry.EndBlocks;
|
||||||
import org.betterx.betterend.registry.EndStructures;
|
import org.betterx.betterend.registry.EndStructures;
|
||||||
import org.betterx.betterend.util.GlobalState;
|
import org.betterx.betterend.util.GlobalState;
|
||||||
|
@ -9,6 +10,7 @@ import org.betterx.worlds.together.tag.v3.CommonBlockTags;
|
||||||
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||||
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.core.Holder;
|
import net.minecraft.core.Holder;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
|
@ -36,6 +38,7 @@ public class CrystalMountainPiece extends MountainPiece {
|
||||||
|
|
||||||
public CrystalMountainPiece(StructurePieceSerializationContext type, CompoundTag tag) {
|
public CrystalMountainPiece(StructurePieceSerializationContext type, CompoundTag tag) {
|
||||||
super(EndStructures.MOUNTAIN_PIECE, tag);
|
super(EndStructures.MOUNTAIN_PIECE, tag);
|
||||||
|
top = EndBlocks.CRYSTAL_MOSS.defaultBlockState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -97,16 +100,21 @@ public class CrystalMountainPiece extends MountainPiece {
|
||||||
|
|
||||||
final double noise = SplitNoiseCondition.DEFAULT.getNoise(px, pz);
|
final double noise = SplitNoiseCondition.DEFAULT.getNoise(px, pz);
|
||||||
boolean needCover = noise > 0;
|
boolean needCover = noise > 0;
|
||||||
boolean needSurroundCover = noise > -0.2;
|
boolean needSurroundCover = Math.abs(noise) < 0.2;
|
||||||
for (int y = minY - 1; y < maxYI; y++) {
|
for (int y = minY - 1; y < maxYI; y++) {
|
||||||
pos.setY(y);
|
pos.setY(y);
|
||||||
if (needCover && y == cover) {
|
if (needCover && y == cover) {
|
||||||
chunk.setBlockState(pos, top, false);
|
chunk.setBlockState(pos, top, false);
|
||||||
} else {
|
} else {
|
||||||
chunk.setBlockState(pos, Blocks.END_STONE.defaultBlockState(), false);
|
chunk.setBlockState(pos, Blocks.END_STONE.defaultBlockState(), false);
|
||||||
if (needSurroundCover) {
|
}
|
||||||
chunk.setBlockState(pos.above(), Blocks.SCULK_VEIN.defaultBlockState(), false);
|
if (needSurroundCover && chunk.getBlockState(pos.above()).is(Blocks.AIR)) {
|
||||||
}
|
chunk.setBlockState(
|
||||||
|
pos.above(),
|
||||||
|
EndBlocks.CRYSTAL_MOSS_COVER.defaultBlockState().setValue(
|
||||||
|
CrystalMossCoverBlock.getFaceProperty(Direction.DOWN), true),
|
||||||
|
false
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent": "item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "betterend:block/crystal_moss_cover"
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"animation": {
|
"animation": {
|
||||||
"frametime": 20,
|
"frametime": 32,
|
||||||
"interpolate": true
|
"interpolate": true
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue