Fix TE creation assuming other mods don't crash with SchematicWorld instances (#565)

This commit is contained in:
grimmauld 2020-12-21 09:28:41 +01:00
parent 9336931f30
commit f3653d6b15

View file

@ -8,6 +8,7 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.function.Predicate; import java.util.function.Predicate;
import com.simibubi.create.Create;
import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld; import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@ -86,12 +87,16 @@ public class SchematicWorld extends WrappedWorld {
BlockState blockState = getBlockState(pos); BlockState blockState = getBlockState(pos);
if (blockState.hasTileEntity()) { if (blockState.hasTileEntity()) {
TileEntity tileEntity = blockState.createTileEntity(this); try {
if (tileEntity != null) { TileEntity tileEntity = blockState.createTileEntity(this);
tileEntity.setLocation(this, pos); if (tileEntity != null) {
tileEntities.put(pos, tileEntity); tileEntity.setLocation(this, pos);
tileEntities.put(pos, tileEntity);
}
return tileEntity;
} catch (Exception e) {
Create.logger.debug("Could not create TE of block " + blockState + ": " + e);
} }
return tileEntity;
} }
return null; return null;
} }