there can be more than 3 dimensions, fixes #336

This commit is contained in:
gnembon committed 2020-06-20 11:18:39 -03:00
1 parent 3700377686
commit 5cb019d5b5
3 files changed
+39 -12

No files matched your search

@@ -127,6 +127,7 @@ import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.Vec3i;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.StructureFeature;
import net.minecraft.world.SpawnHelper;
@@ -3219,7 +3220,20 @@ public class CarpetExpression
innerSource = outerSource.withWorld(outerSource.getMinecraftServer().getWorld(World.OVERWORLD)); //ow
break;
default:
throw new InternalExpressionException("Incorrect dimension string: "+dimString);
RegistryKey<World> dim = null;
Identifier id = new Identifier(dimString);
// not using RegistryKey.of since that one creates on check
for (RegistryKey<World> world : (outerSource.getMinecraftServer().getWorldRegistryKeys()))
{
if (id.equals(world.getValue()))
{
dim = world;
break;
}
}
if (dim == null)
throw new InternalExpressionException("Incorrect dimension string: "+dimString);
innerSource = outerSource.withWorld(outerSource.getMinecraftServer().getWorld(dim));
}
}
((CarpetContext) c).s = innerSource;