mirror of
https://github.com/EngineHub/WorldEdit.git
synced 2024-12-15 04:41:37 +08:00
Skip notify if chunk section doesn't exist (#1794)
* Skip notify if chunk section doesn't exist * Include forge in this change * Pass chunk to mark/notify directly, update adapters. Co-authored-by: wizjany <wizjany@gmail.com>
This commit is contained in:
parent
43da91ad92
commit
728a152395
Binary file not shown.
@ -138,11 +138,11 @@ default void setCurrentSideEffectSet(SideEffectSet sideEffectSet) {
|
||||
|
||||
boolean updateTileEntity(NP position, CompoundTag tag);
|
||||
|
||||
void notifyBlockUpdate(NP position, NBS oldState, NBS newState);
|
||||
void notifyBlockUpdate(NC chunk, NP position, NBS oldState, NBS newState);
|
||||
|
||||
boolean isChunkTicking(NC chunk);
|
||||
|
||||
void markBlockChanged(NP position);
|
||||
void markBlockChanged(NC chunk, NP position);
|
||||
|
||||
void notifyNeighbors(NP pos, NBS oldState, NBS newState);
|
||||
|
||||
@ -166,10 +166,10 @@ default void markAndNotifyBlock(NP pos, NC chunk, NBS oldState, NBS newState, Si
|
||||
// Remove redundant branches
|
||||
if (isChunkTicking(chunk)) {
|
||||
if (sideEffectSet.shouldApply(SideEffect.ENTITY_AI)) {
|
||||
notifyBlockUpdate(pos, oldState, newState);
|
||||
notifyBlockUpdate(chunk, pos, oldState, newState);
|
||||
} else {
|
||||
// If we want to skip entity AI, just mark the block for sending
|
||||
markBlockChanged(pos);
|
||||
markBlockChanged(chunk, pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
import com.sk89q.worldedit.internal.wna.WorldNativeAccess;
|
||||
import com.sk89q.worldedit.util.SideEffect;
|
||||
import com.sk89q.worldedit.util.SideEffectSet;
|
||||
import com.sk89q.worldedit.world.storage.ChunkStore;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
@ -115,8 +116,10 @@ public boolean updateTileEntity(BlockPos position, com.sk89q.jnbt.CompoundTag ta
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyBlockUpdate(BlockPos position, BlockState oldState, BlockState newState) {
|
||||
getWorld().updateListeners(position, oldState, newState, UPDATE | NOTIFY);
|
||||
public void notifyBlockUpdate(WorldChunk chunk, BlockPos position, BlockState oldState, BlockState newState) {
|
||||
if (chunk.getSectionArray()[position.getY() >> ChunkStore.CHUNK_SHIFTS] != null) {
|
||||
getWorld().updateListeners(position, oldState, newState, UPDATE | NOTIFY);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -125,8 +128,10 @@ public boolean isChunkTicking(WorldChunk chunk) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markBlockChanged(BlockPos position) {
|
||||
((ServerChunkManager) getWorld().getChunkManager()).markForUpdate(position);
|
||||
public void markBlockChanged(WorldChunk chunk, BlockPos position) {
|
||||
if (chunk.getSectionArray()[position.getY() >> ChunkStore.CHUNK_SHIFTS] != null) {
|
||||
((ServerChunkManager) getWorld().getChunkManager()).markForUpdate(position);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -25,6 +25,7 @@
|
||||
import com.sk89q.worldedit.internal.wna.WorldNativeAccess;
|
||||
import com.sk89q.worldedit.util.SideEffect;
|
||||
import com.sk89q.worldedit.util.SideEffectSet;
|
||||
import com.sk89q.worldedit.world.storage.ChunkStore;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
@ -104,8 +105,10 @@ public boolean updateTileEntity(BlockPos position, CompoundTag tag) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyBlockUpdate(BlockPos position, BlockState oldState, BlockState newState) {
|
||||
getWorld().notifyBlockUpdate(position, oldState, newState, UPDATE | NOTIFY);
|
||||
public void notifyBlockUpdate(Chunk chunk, BlockPos position, BlockState oldState, BlockState newState) {
|
||||
if (chunk.getSections()[position.getY() >> ChunkStore.CHUNK_SHIFTS] != null) {
|
||||
getWorld().notifyBlockUpdate(position, oldState, newState, UPDATE | NOTIFY);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -114,8 +117,10 @@ public boolean isChunkTicking(Chunk chunk) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markBlockChanged(BlockPos position) {
|
||||
((ServerChunkProvider) getWorld().getChunkProvider()).markBlockChanged(position);
|
||||
public void markBlockChanged(Chunk chunk, BlockPos position) {
|
||||
if (chunk.getSections()[position.getY() >> ChunkStore.CHUNK_SHIFTS] != null) {
|
||||
((ServerChunkProvider) getWorld().getChunkProvider()).markBlockChanged(position);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user