Add non null params to the super call on DummyWorld, add try/catch around its construction in case something else goes bad

This commit is contained in:
Thiakil committed 2019-06-08 12:51:16 +08:00
1 parent a30326ba41
commit 55e8980b4a
2 files changed
+72 -3

No files matched your search

@@ -410,7 +410,10 @@ public final class OreDictManager {
return false;
}
};
DummyWorld dummyWorld = new DummyWorld();
DummyWorld dummyWorld = null;
try {
dummyWorld = new DummyWorld();
} catch (Exception ignored){}
InventoryCrafting tempCrafting = new InventoryCrafting(tempContainer, 3, 3);
@@ -1,9 +1,19 @@
package mekanism.common.world;
import java.io.File;
import javax.annotation.Nullable;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.profiler.Profiler;
import net.minecraft.world.DimensionType;
import net.minecraft.world.MinecraftException;
import net.minecraft.world.World;
import net.minecraft.world.WorldProvider;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.chunk.storage.IChunkLoader;
import net.minecraft.world.gen.structure.template.TemplateManager;
import net.minecraft.world.storage.IPlayerFileData;
import net.minecraft.world.storage.ISaveHandler;
import net.minecraft.world.storage.WorldInfo;
/**
* Dummy object for providing something to CraftingManager#findMatchingRecipe during startup, to prevent in-dev non-null assertions from breaking things
@@ -11,12 +21,12 @@ import net.minecraft.world.chunk.IChunkProvider;
public class DummyWorld extends World {
public DummyWorld() {
super(null, null, new WorldProvider() {
super(new DummySaveHandler(), new DummyWorldInfo(), new WorldProvider() {
@Override
public DimensionType getDimensionType() {
return DimensionType.OVERWORLD;
}
}, null, false);
}, new Profiler(), false);
}
@Override
@@ -28,4 +38,60 @@ public class DummyWorld extends World {
protected boolean isChunkLoaded(int x, int z, boolean allowEmpty) {
return false;
}
public static class DummyWorldInfo extends WorldInfo{}
public static class DummySaveHandler implements ISaveHandler{
@Nullable
@Override
public WorldInfo loadWorldInfo() {
return null;
}
@Override
public void checkSessionLock() throws MinecraftException {
}
@Override
public IChunkLoader getChunkLoader(WorldProvider provider) {
throw new UnsupportedOperationException();
}
@Override
public void saveWorldInfoWithPlayer(WorldInfo worldInformation, NBTTagCompound tagCompound) {
}
@Override
public void saveWorldInfo(WorldInfo worldInformation) {
}
@Override
public IPlayerFileData getPlayerNBTManager() {
throw new UnsupportedOperationException();
}
@Override
public void flush() {
}
@Override
public File getWorldDirectory() {
throw new UnsupportedOperationException();
}
@Override
public File getMapFileFromName(String mapName) {
throw new UnsupportedOperationException();
}
@Override
public TemplateManager getStructureTemplateManager() {
throw new UnsupportedOperationException();
}
}
}