From 9d7878c5304ffb96f8048a41c4a92f4aa648ccca Mon Sep 17 00:00:00 2001 From: Mike Primm Date: Sun, 26 Apr 2020 21:28:12 -0500 Subject: [PATCH] More 1.13.2 fixes --- .../org/dynmap/forge_1_13_2/DynmapPlugin.java | 12 ++- .../forge_1_13_2/ForgeMapChunkCache.java | 82 ++++++++++--------- 2 files changed, 47 insertions(+), 47 deletions(-) diff --git a/forge-1.13.2/src/main/java/org/dynmap/forge_1_13_2/DynmapPlugin.java b/forge-1.13.2/src/main/java/org/dynmap/forge_1_13_2/DynmapPlugin.java index 692f3c28..0b6f2f92 100644 --- a/forge-1.13.2/src/main/java/org/dynmap/forge_1_13_2/DynmapPlugin.java +++ b/forge-1.13.2/src/main/java/org/dynmap/forge_1_13_2/DynmapPlugin.java @@ -67,8 +67,8 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.ServerChatEvent; import net.minecraftforge.event.world.ChunkEvent; import net.minecraftforge.event.world.WorldEvent; -import net.minecraftforge.fml.ModContainer; import net.minecraftforge.fml.ModList; +import net.minecraftforge.fml.ModContainer; import net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerChangedDimensionEvent; import net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent; import net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerLoggedOutEvent; @@ -1012,10 +1012,8 @@ public class DynmapPlugin ModFileInfo mfi = ModList.get().getModFileById(name); // Try case sensitive lookup if (mfi != null) { File f = mfi.getFile().getFilePath().toFile(); - Log.info("getModContainferFile(" + name + ")=" + f.getAbsolutePath()); return f; } - Log.info("getModContainferFile(" + name + ")=null"); return null; } @Override @@ -1037,8 +1035,8 @@ public class DynmapPlugin @Override public InputStream openResource(String modid, String rname) { if (modid != null) { - ModContainer mc = ModList.get().getModContainerById(modid).get(); - Object mod = (mc != null) ? mc.getMod() : null; + Optional mc = ModList.get().getModContainerById(modid); + Object mod = (mc.isPresent()) ? mc.get().getMod() : null; if (mod != null) { InputStream is = mod.getClass().getClassLoader().getResourceAsStream(rname); if (is != null) { @@ -1048,8 +1046,8 @@ public class DynmapPlugin } List mcl = ModList.get().getMods(); for (ModInfo mci : mcl) { - ModContainer mc = ModList.get().getModContainerById(mci.getModId()).get(); - Object mod = (mc != null) ? mc.getMod() : null; + Optional mc = ModList.get().getModContainerById(mci.getModId()); + Object mod = (mc.isPresent()) ? mc.get().getMod() : null; if (mod == null) continue; InputStream is = mod.getClass().getClassLoader().getResourceAsStream(rname); if (is != null) { diff --git a/forge-1.13.2/src/main/java/org/dynmap/forge_1_13_2/ForgeMapChunkCache.java b/forge-1.13.2/src/main/java/org/dynmap/forge_1_13_2/ForgeMapChunkCache.java index 730bf29c..0b8e6062 100644 --- a/forge-1.13.2/src/main/java/org/dynmap/forge_1_13_2/ForgeMapChunkCache.java +++ b/forge-1.13.2/src/main/java/org/dynmap/forge_1_13_2/ForgeMapChunkCache.java @@ -61,7 +61,7 @@ public class ForgeMapChunkCache extends MapChunkCache private static Field updateEntityTick = null; /* AnvilChunkLoader fields */ private static Field chunksToRemove = null; // Map - private static Field pendingAnvilChunksCoordinates = null; // Set + //private static Field pendingAnvilChunksCoordinates = null; // Set private static Method writechunktonbt = null; // writeChunkToNBT(Chunk c, World w, NBTTagCompound nbt) /* AnvilChunkLoaderPending fields */ @@ -87,7 +87,7 @@ public class ForgeMapChunkCache extends MapChunkCache private byte[][] sameneighborbiomecnt; private BiomeMap[][] biomemap; private boolean[][] isSectionNotEmpty; /* Indexed by snapshot index, then by section index */ - private Set queue = null; + private it.unimi.dsi.fastutil.longs.LongSet queue = null; private static final BlockStep unstep[] = { BlockStep.X_MINUS, BlockStep.Y_MINUS, BlockStep.Z_MINUS, BlockStep.X_PLUS, BlockStep.Y_PLUS, BlockStep.Z_PLUS @@ -887,7 +887,7 @@ public class ForgeMapChunkCache extends MapChunkCache Field[] f = ChunkProviderServer.class.getDeclaredFields(); for(int i = 0; i < f.length; i++) { - if((unloadqueue == null) && f[i].getType().isAssignableFrom(java.util.Set.class)) { + if((unloadqueue == null) && f[i].getType().isAssignableFrom(it.unimi.dsi.fastutil.longs.LongSet.class)) { unloadqueue = f[i]; //Log.info("Found unloadqueue - " + f[i].getName()); unloadqueue.setAccessible(true); @@ -911,13 +911,15 @@ public class ForgeMapChunkCache extends MapChunkCache f = AnvilChunkLoader.class.getDeclaredFields(); for(int i = 0; i < f.length; i++) { if((chunksToRemove == null) && (f[i].getType().equals(Map.class))) { - chunksToRemove = f[i]; + chunksToRemove = f[i]; + //Log.info("Found chunksToRemove - " + f[i].getName()); chunksToRemove.setAccessible(true); } - else if((pendingAnvilChunksCoordinates == null) && (f[i].getType().equals(Set.class))) { - pendingAnvilChunksCoordinates = f[i]; - pendingAnvilChunksCoordinates.setAccessible(true); - } +// else if((pendingAnvilChunksCoordinates == null) && (f[i].getType().equals(it.unimi.dsi.fastutil.longs.LongSet.class))) { +// //Log.info("Found pendingAnvilChunksCoordinates - " + f[i].getName()); +// pendingAnvilChunksCoordinates = f[i]; +// pendingAnvilChunksCoordinates.setAccessible(true); +// } } // Get writeChunkToNBT method Method[] ma = AnvilChunkLoader.class.getDeclaredMethods(); @@ -925,6 +927,7 @@ public class ForgeMapChunkCache extends MapChunkCache Class[] p = m.getParameterTypes(); if ((p.length == 3) && (p[0].equals(Chunk.class)) && (p[1].equals(World.class)) && (p[2].equals(NBTTagCompound.class))) { writechunktonbt = m; + //Log.info("Found writechunktonbt- " + m.getName()); m.setAccessible(true); break; } @@ -961,7 +964,6 @@ public class ForgeMapChunkCache extends MapChunkCache if (cp instanceof ChunkProviderServer) { cps = (ChunkProviderServer)cp; - Log.info("World " + dw.getName() + " has chunk provider " + cps.getClass().getName()); } else { @@ -1023,7 +1025,7 @@ public class ForgeMapChunkCache extends MapChunkCache { if ((unloadqueue != null) && (cps != null)) { - queue = (Set)unloadqueue.get(cps); + queue = (it.unimi.dsi.fastutil.longs.LongSet) unloadqueue.get(cps); } } catch (IllegalArgumentException iax) @@ -1039,7 +1041,7 @@ public class ForgeMapChunkCache extends MapChunkCache public NBTTagCompound readChunk(int x, int z) { if((cps == null) || (!(cps.chunkLoader instanceof AnvilChunkLoader)) || - (((chunksToRemove == null) || (pendingAnvilChunksCoordinates == null)))) { + (((chunksToRemove == null) /*|| (pendingAnvilChunksCoordinates == null) */))) { if (!didError) { Log.severe("**** DYNMAP CANNOT READ CHUNKS (UNSUPPORTED CHUNK LOADER) ****"); didError = true; @@ -1049,41 +1051,41 @@ public class ForgeMapChunkCache extends MapChunkCache try { AnvilChunkLoader acl = (AnvilChunkLoader)cps.chunkLoader; Map chunkstoremove = null; - Set pendingcoords = null; + //it.unimi.dsi.fastutil.longs.LongSet pendingcoords; chunkstoremove = (Map)chunksToRemove.get(acl); - pendingcoords = (Set)pendingAnvilChunksCoordinates.get(acl); + //pendingcoords = (it.unimi.dsi.fastutil.longs.LongSet) pendingAnvilChunksCoordinates.get(acl); NBTTagCompound rslt = null; ChunkPos coord = new ChunkPos(x, z); - if (pendingcoords.contains(coord)) { - for (Object o : chunkstoremove.values()) { - if (chunkCoord == null) { - Field[] f = o.getClass().getDeclaredFields(); - for(Field ff : f) { - if((chunkCoord == null) && (ff.getType().equals(ChunkPos.class))) { - chunkCoord = ff; - chunkCoord.setAccessible(true); - } - else if((nbtTag == null) && (ff.getType().equals(NBTTagCompound.class))) { - nbtTag = ff; - nbtTag.setAccessible(true); - } - } - if ((chunkCoord == null) || (nbtTag == null)) { - Log.severe("Error getting chunkCoord and nbtTag for Forge"); - return null; - } - } - ChunkPos occ = (ChunkPos)chunkCoord.get(o); + // if (pendingcoords.contains(coord.asLong()) { + // for (Object o : chunkstoremove.values()) { + // if (chunkCoord == null) { + // Field[] f = o.getClass().getDeclaredFields(); + // for(Field ff : f) { + // if((chunkCoord == null) && (ff.getType().equals(ChunkPos.class))) { + // chunkCoord = ff; + // chunkCoord.setAccessible(true); + // } + // else if((nbtTag == null) && (ff.getType().equals(NBTTagCompound.class))) { + // nbtTag = ff; + // nbtTag.setAccessible(true); + // } + // } + // if ((chunkCoord == null) || (nbtTag == null)) { + // Log.severe("Error getting chunkCoord and nbtTag for Forge"); + // return null; + // } + // } + // ChunkPos occ = (ChunkPos)chunkCoord.get(o); - if (occ.equals(coord)) { - rslt = (NBTTagCompound)nbtTag.get(o); - break; - } - } - } + // if (occ.equals(coord)) { + // rslt = (NBTTagCompound)nbtTag.get(o); + // break; + // } + // } + // } if (rslt == null) { DataInputStream str = RegionFileCache.getChunkInputStream(acl.chunkSaveLocation, x, z); @@ -1232,7 +1234,7 @@ public class ForgeMapChunkCache extends MapChunkCache if (queue != null) { long coord = ChunkPos.asLong(chunk.x, chunk.z); - isunloadpending = queue.contains(Long.valueOf(coord)); + isunloadpending = queue.contains(coord); } return isunloadpending; }