Fix schematic deployment crash caused by some Mekanism blocks

This commit is contained in:
reidbhuntley 2021-05-29 22:09:58 -04:00
parent 51c0e347b8
commit 2bedc94bc6
2 changed files with 105 additions and 3 deletions

View file

@ -1,20 +1,40 @@
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;
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;
@ -52,11 +72,11 @@ public class WrappedChunkProvider extends AbstractChunkProvider {
return getChunk(x, z);
}
public WrappedChunk getChunk(int x, int z) {
public IChunk getChunk(int x, int z) {
long pos = ChunkPos.asLong(x, z);
if (chunks == null)
return null;
return new EmptierChunk();
return chunks.computeIfAbsent(pos, $ -> new WrappedChunk(world, x, z));
}

View file

@ -0,0 +1,82 @@
package com.simibubi.create.foundation.utility.worldWrappers.chunk;
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.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.lighting.WorldLightManager;
import net.minecraft.world.server.ChunkHolder;
import javax.annotation.Nullable;
import java.util.List;
import java.util.function.Predicate;
public class EmptierChunk extends Chunk {
public EmptierChunk() {
super(null, null, null);
}
public BlockState getBlockState(BlockPos p_180495_1_) {
return Blocks.VOID_AIR.getDefaultState();
}
@Nullable
public BlockState setBlockState(BlockPos p_177436_1_, BlockState p_177436_2_, boolean p_177436_3_) {
return null;
}
public FluidState getFluidState(BlockPos p_204610_1_) {
return Fluids.EMPTY.getDefaultState();
}
@Nullable
public WorldLightManager getWorldLightManager() {
return null;
}
public int getLightValue(BlockPos p_217298_1_) {
return 0;
}
public void addEntity(Entity p_76612_1_) { }
public void removeEntity(Entity p_76622_1_) { }
public void removeEntityAtIndex(Entity p_76608_1_, int p_76608_2_) { }
@Nullable
public TileEntity getTileEntity(BlockPos p_177424_1_, Chunk.CreateEntityType p_177424_2_) {
return null;
}
public void addTileEntity(TileEntity p_150813_1_) { }
public void addTileEntity(BlockPos p_177426_1_, TileEntity p_177426_2_) { }
public void removeTileEntity(BlockPos p_177425_1_) { }
public void markDirty() { }
public void getEntitiesWithinAABBForEntity(@Nullable Entity p_177414_1_, AxisAlignedBB p_177414_2_, List<Entity> p_177414_3_, Predicate<? super Entity> p_177414_4_) { }
public <T extends Entity> void getEntitiesOfTypeWithinAABB(Class<? extends T> p_177430_1_, AxisAlignedBB p_177430_2_, List<T> p_177430_3_, Predicate<? super T> p_177430_4_) { }
public boolean isEmpty() {
return true;
}
public boolean isEmptyBetween(int p_76606_1_, int p_76606_2_) {
return true;
}
public ChunkHolder.LocationType getLocationType() {
return ChunkHolder.LocationType.BORDER;
}
}