getIWorldLoad(int dimensionId)

Searches loaded worlds-  If not found
attempts to search unloaded worlds and force loads them to return an iWorld object
This commit is contained in:
Kam committed 2024-02-12 04:10:38 -05:00
1 parent 3ea96ab14f
commit 455f2b9fd6
2 files changed
+18 -1

No files matched your search

@@ -21,6 +21,7 @@ import net.minecraft.item.*;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.server.MinecraftServer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EntityDamageSource;
import net.minecraft.util.math.BlockPos;
@@ -422,6 +423,22 @@ public class NpcAPI extends AbstractNpcAPI {
throw new CustomNPCsException("Unknown dimension id: " + dimensionId);
}
public IWorld getIWorldLoad(int dimensionId) {
try {
IWorld iWorld = this.getIWorld(dimensionId);
if(iWorld != null)
return iWorld;
}
catch (CustomNPCsException ignored){}
WorldServer worldServer = CustomNpcs.getServer().worldServerForDimension(dimensionId);
if (worldServer != null) {
return this.getIWorld(worldServer);
}
throw new CustomNPCsException("Unknown dimension id: " + dimensionId);
}
public IContainer getIContainer(IInventory inventory) {
return new ScriptContainer(inventory);
}