Fix schematic init crash caused by updating null ChunkSections

This commit is contained in:
reidbhuntley 2021-05-30 01:40:24 -04:00
parent 2bedc94bc6
commit b890204f44
2 changed files with 11 additions and 22 deletions

View file

@ -1,10 +1,7 @@
package com.simibubi.create.foundation.utility.worldWrappers; package com.simibubi.create.foundation.utility.worldWrappers;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.function.Predicate;
import java.util.stream.Stream; import java.util.stream.Stream;
import javax.annotation.Nullable; 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.EmptierChunk;
import com.simibubi.create.foundation.utility.worldWrappers.chunk.WrappedChunk; 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.BlockPos;
import net.minecraft.util.math.ChunkPos; import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.IBlockReader; 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.AbstractChunkProvider;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.ChunkStatus; import net.minecraft.world.chunk.ChunkStatus;
import net.minecraft.world.chunk.EmptyChunk;
import net.minecraft.world.chunk.IChunk; import net.minecraft.world.chunk.IChunk;
import net.minecraft.world.lighting.WorldLightManager; import net.minecraft.world.lighting.WorldLightManager;
import net.minecraft.world.server.ChunkHolder;
public class WrappedChunkProvider extends AbstractChunkProvider { public class WrappedChunkProvider extends AbstractChunkProvider {
private PlacementSimulationWorld world; private PlacementSimulationWorld world;

View file

@ -21,11 +21,14 @@ import net.minecraft.util.Direction;
import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvent; import net.minecraft.util.SoundEvent;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.SectionPos;
import net.minecraft.util.registry.DynamicRegistries; import net.minecraft.util.registry.DynamicRegistries;
import net.minecraft.world.ITickList; import net.minecraft.world.ITickList;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
import net.minecraft.world.chunk.AbstractChunkProvider; 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.lighting.WorldLightManager;
import net.minecraft.world.storage.ISpawnWorldInfo; import net.minecraft.world.storage.ISpawnWorldInfo;
import net.minecraft.world.storage.MapData; import net.minecraft.world.storage.MapData;
@ -84,8 +87,13 @@ public class WrappedWorld extends World {
@Override @Override
public void notifyBlockUpdate(BlockPos pos, BlockState oldState, BlockState newState, int flags) { public void notifyBlockUpdate(BlockPos pos, BlockState oldState, BlockState newState, int 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); world.notifyBlockUpdate(pos, oldState, newState, flags);
} }
}
@Override @Override
public ITickList<Block> getPendingBlockTicks() { public ITickList<Block> getPendingBlockTicks() {