From b890204f44f5bb969ba62d3b54d0a07c4fe77766 Mon Sep 17 00:00:00 2001 From: reidbhuntley Date: Sun, 30 May 2021 01:40:24 -0400 Subject: [PATCH] Fix schematic init crash caused by updating null ChunkSections --- .../worldWrappers/WrappedChunkProvider.java | 19 ------------------- .../utility/worldWrappers/WrappedWorld.java | 14 +++++++++++--- 2 files changed, 11 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedChunkProvider.java b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedChunkProvider.java index 43a4bbde7..dbc75fcfd 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedChunkProvider.java +++ b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedChunkProvider.java @@ -1,10 +1,7 @@ package com.simibubi.create.foundation.utility.worldWrappers; -import java.util.Arrays; import java.util.HashMap; -import java.util.List; import java.util.Map; -import java.util.function.Predicate; import java.util.stream.Stream; import javax.annotation.Nullable; @@ -12,29 +9,13 @@ import javax.annotation.Nullable; import com.simibubi.create.foundation.utility.worldWrappers.chunk.EmptierChunk; import com.simibubi.create.foundation.utility.worldWrappers.chunk.WrappedChunk; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.entity.Entity; -import net.minecraft.fluid.FluidState; -import net.minecraft.fluid.Fluids; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Util; -import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkPos; -import net.minecraft.util.registry.Registry; import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; -import net.minecraft.world.biome.Biome; -import net.minecraft.world.biome.BiomeContainer; -import net.minecraft.world.biome.BiomeRegistry; import net.minecraft.world.chunk.AbstractChunkProvider; -import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.ChunkStatus; -import net.minecraft.world.chunk.EmptyChunk; import net.minecraft.world.chunk.IChunk; import net.minecraft.world.lighting.WorldLightManager; -import net.minecraft.world.server.ChunkHolder; public class WrappedChunkProvider extends AbstractChunkProvider { private PlacementSimulationWorld world; diff --git a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedWorld.java b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedWorld.java index a5984048c..7d14d0061 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedWorld.java +++ b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedWorld.java @@ -21,11 +21,14 @@ import net.minecraft.util.Direction; import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundEvent; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.SectionPos; import net.minecraft.util.registry.DynamicRegistries; import net.minecraft.world.ITickList; import net.minecraft.world.World; import net.minecraft.world.biome.Biome; import net.minecraft.world.chunk.AbstractChunkProvider; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.ChunkSection; import net.minecraft.world.lighting.WorldLightManager; import net.minecraft.world.storage.ISpawnWorldInfo; import net.minecraft.world.storage.MapData; @@ -51,12 +54,12 @@ public class WrappedWorld extends World { public World getWorld() { return world; } - + @Override public WorldLightManager getLightingProvider() { return world.getLightingProvider(); } - + @Override public BlockState getBlockState(@Nullable BlockPos pos) { return world.getBlockState(pos); @@ -84,7 +87,12 @@ public class WrappedWorld extends World { @Override public void notifyBlockUpdate(BlockPos pos, BlockState oldState, BlockState newState, int flags) { - world.notifyBlockUpdate(pos, oldState, newState, flags); + Chunk chunk = world.getChunkProvider().getWorldChunk(pos.getX() >> 4, pos.getZ() >> 4); + if (chunk != null) { + ChunkSection chunksection = chunk.getSections()[SectionPos.toChunk(pos.getY())]; + if (chunksection != null) + world.notifyBlockUpdate(pos, oldState, newState, flags); + } } @Override