diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/WrapperFactory.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/WrapperFactory.java index dd71daf24..7b885fc5f 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/WrapperFactory.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/WrapperFactory.java @@ -32,6 +32,7 @@ import com.seibel.distanthorizons.common.wrappers.world.ServerLevelWrapper; import com.seibel.distanthorizons.common.wrappers.worldGeneration.BatchGenerationEnvironment; import com.seibel.distanthorizons.core.level.IDhLevel; import com.seibel.distanthorizons.core.level.IDhServerLevel; +import com.seibel.distanthorizons.core.util.LodUtil; import com.seibel.distanthorizons.core.wrapperInterfaces.IWrapperFactory; import com.seibel.distanthorizons.core.wrapperInterfaces.block.IBlockStateWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper; @@ -83,10 +84,21 @@ public class WrapperFactory implements IWrapperFactory @Override public IBiomeWrapper deserializeBiomeWrapper(String str, ILevelWrapper levelWrapper) throws IOException { return BiomeWrapper.deserialize(str, levelWrapper); } + @Override + public IBiomeWrapper getPlainsBiomeWrapper(ILevelWrapper levelWrapper) // TODO is there a way we could get this without the levelWrapper? it isn't necessary but would clean up the code a bit + { + try + { + return BiomeWrapper.deserialize(BiomeWrapper.PLAINS_RESOURCE_LOCATION_STRING, levelWrapper); + } + catch (IOException e) + { + throw new LodUtil.AssertFailureException("Unable to parse plains resource string ["+BiomeWrapper.PLAINS_RESOURCE_LOCATION_STRING+"], error:\n " + e.getMessage()); + } + } @Override public IBlockStateWrapper deserializeBlockStateWrapper(String str, ILevelWrapper levelWrapper) throws IOException { return BlockStateWrapper.deserialize(str, levelWrapper); } - @Override public IBlockStateWrapper getAirBlockStateWrapper() { return BlockStateWrapper.AIR; } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BiomeWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BiomeWrapper.java index 9b8f889f6..2d5f95ca8 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BiomeWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BiomeWrapper.java @@ -249,6 +249,7 @@ public class BiomeWrapper implements IBiomeWrapper return this.serialString; } + // TODO would it be worth while to cache these objects in a ConcurrentHashMap? public static IBiomeWrapper deserialize(String resourceLocationString, ILevelWrapper levelWrapper) throws IOException { if (resourceLocationString.equals(EMPTY_BIOME_STRING)) @@ -274,7 +275,16 @@ public class BiomeWrapper implements IBiomeWrapper { throw new IOException("Unable to parse resource location string: [" + resourceLocationString + "]."); } - ResourceLocation resourceLocation = new ResourceLocation(resourceLocationString.substring(0, separatorIndex), resourceLocationString.substring(separatorIndex + 1)); + + ResourceLocation resourceLocation; + try + { + resourceLocation = new ResourceLocation(resourceLocationString.substring(0, separatorIndex), resourceLocationString.substring(separatorIndex + 1)); + } + catch (Exception e) + { + throw new IOException("No Resource Location found for the string: [" + resourceLocationString + "] Error: ["+e.getMessage()+"]."); + } try diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java index 4b2d1e0c5..5e5fca6b1 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java @@ -336,6 +336,7 @@ public class BlockStateWrapper implements IBlockStateWrapper } + // TODO would it be worth while to cache these objects in a ConcurrentHashMap? /** will only work if a level is currently loaded */ public static IBlockStateWrapper deserialize(String resourceStateString, ILevelWrapper levelWrapper) throws IOException { @@ -357,13 +358,21 @@ public class BlockStateWrapper implements IBlockStateWrapper } // parse the resource location - int resourceSeparatorIndex = resourceStateString.indexOf(RESOURCE_LOCATION_SEPARATOR); - if (resourceSeparatorIndex == -1) + int separatorIndex = resourceStateString.indexOf(RESOURCE_LOCATION_SEPARATOR); + if (separatorIndex == -1) { throw new IOException("Unable to parse Resource Location out of string: [" + resourceStateString + "]."); } - ResourceLocation resourceLocation = new ResourceLocation(resourceStateString.substring(0, resourceSeparatorIndex), resourceStateString.substring(resourceSeparatorIndex + 1)); + ResourceLocation resourceLocation; + try + { + resourceLocation = new ResourceLocation(resourceStateString.substring(0, separatorIndex), resourceStateString.substring(separatorIndex + 1)); + } + catch (Exception e) + { + throw new IOException("No Resource Location found for the string: [" + resourceStateString + "] Error: ["+e.getMessage()+"]."); + } // attempt to get the BlockState from all possible BlockStates diff --git a/coreSubProjects b/coreSubProjects index f33bfa1d6..7cfcfb069 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit f33bfa1d696de9cdc628d1b232cd7b8b89f83942 +Subproject commit 7cfcfb0695cae172df7ec48e0bb30cc57246fa3f