Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make chunk sections only be considered all air if filled with Blocks.AIR only #471

Merged
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--- a/net/minecraft/world/level/chunk/LevelChunkSection.java
+++ b/net/minecraft/world/level/chunk/LevelChunkSection.java
@@ -65,7 +_,7 @@

FluidState fluidstate = blockstate.getFluidState();
FluidState fluidstate1 = p_62995_.getFluidState();
- if (!blockstate.isAir()) {
+ if (!blockstate.isEmpty()) { // Neo: Fix MC-232360 for modded blocks (Makes modded isAir blocks not be replaced with Blocks.AIR in all-air chunk sections)
--this.nonEmptyBlockCount;
if (blockstate.isRandomlyTicking()) {
--this.tickingBlockCount;
@@ -76,7 +_,7 @@
--this.tickingFluidCount;
}

- if (!p_62995_.isAir()) {
+ if (!p_62995_.isEmpty()) { // Neo: Fix MC-232360 for modded blocks (Makes modded isAir blocks not be replaced with Blocks.AIR in all-air chunk sections)
++this.nonEmptyBlockCount;
if (p_62995_.isRandomlyTicking()) {
++this.tickingBlockCount;
Original file line number Diff line number Diff line change
Expand Up @@ -947,4 +947,14 @@ default BlockState getAppearance(BlockState state, BlockAndTintGetter level, Blo
default PushReaction getPistonPushReaction(BlockState state) {
return null;
}

/**
* Return true if the state is able to be replaced with Blocks.AIR in chunk sections that is entirely made of blocks that return true for isEmpty
*
* @param state The current state
* @return True if the block should be allowed to be optimized away into Blocks.AIR
*/
default boolean isEmpty(BlockState state) {
return state.is(Blocks.AIR) || state.is(Blocks.CAVE_AIR) || state.is(Blocks.VOID_AIR);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -721,4 +721,13 @@ default boolean canBeHydrated(BlockGetter getter, BlockPos pos, FluidState fluid
default BlockState getAppearance(BlockAndTintGetter level, BlockPos pos, Direction side, @Nullable BlockState queryState, @Nullable BlockPos queryPos) {
return self().getBlock().getAppearance(self(), level, pos, side, queryState, queryPos);
}

/**
* Return true if the state is able to be replaced with Blocks.AIR in chunk sections that is entirely made of blocks that return true for isEmpty
*
* @return True if the block should be allowed to be optimized away into Blocks.AIR
*/
default boolean isEmpty() {
return self().getBlock().isEmpty(self());
}
}
Loading