Skip to content

Commit

Permalink
Improve placement behaviour of custom blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Malfrador committed Jan 23, 2025
1 parent d7fc3f7 commit 657e6f5
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
--- a/net/minecraft/world/level/block/BaseCoralPlantTypeBlock.java
+++ b/net/minecraft/world/level/block/BaseCoralPlantTypeBlock.java
@@ -33,12 +_,14 @@
protected abstract MapCodec<? extends BaseCoralPlantTypeBlock> codec();

protected void tryScheduleDieTick(BlockState state, BlockGetter level, ScheduledTickAccess scheduledTickAccess, RandomSource random, BlockPos pos) {
+ if (true) return; // Papyrus - Disable coral plant death
if (!scanForWater(state, level, pos)) {
scheduledTickAccess.scheduleTick(pos, this, 60 + random.nextInt(40));
}
}

protected static boolean scanForWater(BlockState state, BlockGetter level, BlockPos pos) {
+ if (true) return true; // Papyrus - Disable coral plant death
if (state.getValue(WATERLOGGED)) {
return true;
} else {
@@ -75,6 +_,7 @@
BlockState neighborState,
RandomSource random
) {
+ if (true) return state; // Papyrus - Disable coral plant death
if (state.getValue(WATERLOGGED)) {
scheduledTickAccess.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(level));
}
@@ -86,6 +_,7 @@

@Override
protected boolean canSurvive(BlockState state, LevelReader level, BlockPos pos) {
+ if (true) return true; // Papyrus - Disable state change
BlockPos blockPos = pos.below();
return level.getBlockState(blockPos).isFaceSturdy(level, blockPos, Direction.UP);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--- a/net/minecraft/world/level/block/BaseCoralWallFanBlock.java
+++ b/net/minecraft/world/level/block/BaseCoralWallFanBlock.java
@@ -77,6 +_,7 @@
BlockState neighborState,
RandomSource random
) {
+ if (true) return state; // Papyrus - Disable state change
if (state.getValue(WATERLOGGED)) {
scheduledTickAccess.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(level));
}
@@ -86,6 +_,7 @@

@Override
protected boolean canSurvive(BlockState state, LevelReader level, BlockPos pos) {
+ if (true) return true; // Papyrus - Disable state change
Direction direction = state.getValue(FACING);
BlockPos blockPos = pos.relative(direction.getOpposite());
BlockState blockState = level.getBlockState(blockPos);
Original file line number Diff line number Diff line change
@@ -1,5 +1,46 @@
--- a/net/minecraft/world/level/block/ChorusPlantBlock.java
+++ b/net/minecraft/world/level/block/ChorusPlantBlock.java
@@ -38,11 +_,13 @@

@Override
public BlockState getStateForPlacement(BlockPlaceContext context) {
+ if (true) return this.defaultBlockState(); // Papyrus - Always return default state
if (io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableChorusPlantUpdates) return this.defaultBlockState(); // Paper - add option to disable block updates
return getStateWithConnections(context.getLevel(), context.getClickedPos(), this.defaultBlockState());
}

public static BlockState getStateWithConnections(BlockGetter level, BlockPos pos, BlockState state) {
+ if (true) return state; // Papyrus - Always return state
BlockState blockState = level.getBlockState(pos.below());
BlockState blockState1 = level.getBlockState(pos.above());
BlockState blockState2 = level.getBlockState(pos.north());
@@ -69,7 +_,7 @@
BlockState neighborState,
RandomSource random
) {
- if (io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableChorusPlantUpdates) return state; // Paper - add option to disable block updates
+ if (true) return state; // Papyrus - Always return state
if (!state.canSurvive(level, pos)) {
scheduledTickAccess.scheduleTick(pos, this, 1);
return super.updateShape(state, level, scheduledTickAccess, pos, direction, neighborPos, neighborState, random);
@@ -83,7 +_,7 @@

@Override
protected void tick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) {
- if (io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableChorusPlantUpdates) return; // Paper - add option to disable block updates
+ if (true) return; // Papyrus - Always return
if (!state.canSurvive(level, pos)) {
level.destroyBlock(pos, true);
}
@@ -91,7 +_,7 @@

@Override
protected boolean canSurvive(BlockState state, LevelReader level, BlockPos pos) {
- if (io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableChorusPlantUpdates) return true; // Paper - add option to disable block updates
+ if (true) return true; // Papyrus - Always return true
BlockState blockState = level.getBlockState(pos.below());
boolean flag = !level.getBlockState(pos.above()).isAir() && !blockState.isAir();

@@ -120,6 +_,6 @@

@Override
Expand Down

0 comments on commit 657e6f5

Please sign in to comment.