From 756530985559f12e636592f21f178ba39a2589d6 Mon Sep 17 00:00:00 2001 From: Hexeption Date: Thu, 15 Jun 2017 01:06:12 +0100 Subject: [PATCH 1/8] Updated for Forge 1.12 --- .../java/cpw/mods/retro/WorldRetrogen.java | 54 +++++++------------ 1 file changed, 19 insertions(+), 35 deletions(-) diff --git a/src/main/java/cpw/mods/retro/WorldRetrogen.java b/src/main/java/cpw/mods/retro/WorldRetrogen.java index f1d2461..800cd1e 100644 --- a/src/main/java/cpw/mods/retro/WorldRetrogen.java +++ b/src/main/java/cpw/mods/retro/WorldRetrogen.java @@ -18,15 +18,7 @@ package cpw.mods.retro; -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; -import com.google.common.collect.ListMultimap; -import com.google.common.collect.Lists; -import com.google.common.collect.MapMaker; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; +import com.google.common.collect.*; import com.google.common.collect.Sets.SetView; import net.minecraft.command.CommandBase; import net.minecraft.command.CommandException; @@ -35,14 +27,14 @@ import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagString; import net.minecraft.server.MinecraftServer; -import net.minecraft.util.text.TextComponentString; import net.minecraft.util.math.ChunkPos; +import net.minecraft.util.text.TextComponentString; import net.minecraft.world.World; import net.minecraft.world.WorldServer; import net.minecraft.world.chunk.Chunk; -import net.minecraft.world.chunk.IChunkGenerator; import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.gen.ChunkProviderServer; +import net.minecraft.world.gen.IChunkGenerator; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.config.Property; @@ -61,18 +53,13 @@ import net.minecraftforge.fml.common.registry.GameRegistry; import org.apache.logging.log4j.Level; -import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; -import java.util.Iterator; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.Map.Entry; -import java.util.Random; -import java.util.Set; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.Semaphore; -@Mod(modid="simpleretrogen", name="Simple Retrogen", acceptableRemoteVersions="*", acceptedMinecraftVersions = "[1.9,1.11)") +@Mod(modid="simpleretrogen", name="Simple Retrogen", acceptableRemoteVersions="*", acceptedMinecraftVersions = "[1.9,1.12)") @ParametersAreNonnullByDefault public class WorldRetrogen { private List markers = Lists.newArrayList(); @@ -168,23 +155,21 @@ public void serverStarting(FMLServerStartingEvent evt) { evt.registerServerCommand(new CommandBase() { @Override - @Nonnull - public String getCommandName() + public int getRequiredPermissionLevel() { - return "listretrogenclasstargets"; + return 0; } @Override - @Nonnull - public String getCommandUsage(ICommandSender sender) - { - return "List retrogens"; + public String getName() { + + return "listretrogenclasstargets"; } @Override - public int getRequiredPermissionLevel() - { - return 0; + public String getUsage(ICommandSender sender) { + + return "List retrogens"; } @Override @@ -199,9 +184,9 @@ public void execute(MinecraftServer server, ICommandSender sender, String[] args } } if (targets.isEmpty()) { - sender.addChatMessage(new TextComponentString("There are no retrogen target classes")); + sender.sendMessage(new TextComponentString("There are no retrogen target classes")); } else { - sender.addChatMessage(new TextComponentString(CommandBase.joinNiceStringFromCollection(targets))); + sender.sendMessage(new TextComponentString("There are no retrogen target classes")); } } }); @@ -312,8 +297,7 @@ private class TargetWorldWrapper implements IWorldGenerator { private String tag; @Override - public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) - { + public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) { FMLLog.fine("Passing generation for %s through to underlying generator", tag); delegate.generate(random, chunkX, chunkZ, world, chunkGenerator, chunkProvider); ChunkPos chunkCoordIntPair = new ChunkPos(chunkX, chunkZ); @@ -348,14 +332,14 @@ public void onChunkLoad(ChunkDataEvent.Load chunkevt) { if (retros.containsKey(retro)) { - queueRetrogen(retro, w, chk.getChunkCoordIntPair()); + queueRetrogen(retro, w, chk.getPos()); } } } for (String retro : existingGens) { - completeRetrogen(chk.getChunkCoordIntPair(), w, retro); + completeRetrogen(chk.getPos(), w, retro); } } @@ -373,7 +357,7 @@ public void onChunkSave(ChunkDataEvent.Save chunkevt) if (completedWork.containsKey(w)) { ListMultimap doneChunks = completedWork.get(w); - List retroClassList = doneChunks.get(chunkevt.getChunk().getChunkCoordIntPair()); + List retroClassList = doneChunks.get(chunkevt.getChunk().getPos()); if (retroClassList.isEmpty()) return; NBTTagCompound data = chunkevt.getData(); From 8e85bce1990353cda5c6da0ea1a9f6b162039c80 Mon Sep 17 00:00:00 2001 From: Hexeption Date: Thu, 15 Jun 2017 01:16:34 +0100 Subject: [PATCH 2/8] Fixed a typeo --- src/main/java/cpw/mods/retro/WorldRetrogen.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/cpw/mods/retro/WorldRetrogen.java b/src/main/java/cpw/mods/retro/WorldRetrogen.java index 800cd1e..463b3ef 100644 --- a/src/main/java/cpw/mods/retro/WorldRetrogen.java +++ b/src/main/java/cpw/mods/retro/WorldRetrogen.java @@ -59,7 +59,7 @@ import java.util.concurrent.ConcurrentMap; import java.util.concurrent.Semaphore; -@Mod(modid="simpleretrogen", name="Simple Retrogen", acceptableRemoteVersions="*", acceptedMinecraftVersions = "[1.9,1.12)") +@Mod(modid="simpleretrogen", name="Simple Retrogen", acceptableRemoteVersions="*", acceptedMinecraftVersions = "[1.9,1.12]") @ParametersAreNonnullByDefault public class WorldRetrogen { private List markers = Lists.newArrayList(); From 2992e67cadad9a42a891588c0adaf97306d982a2 Mon Sep 17 00:00:00 2001 From: Hexeption Date: Thu, 15 Jun 2017 01:53:50 +0100 Subject: [PATCH 3/8] Re-Added 'sender.sendMessage(new TextComponentString(CommandBase.joinNiceStringFromCollection(targets)))' --- src/main/java/cpw/mods/retro/WorldRetrogen.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/cpw/mods/retro/WorldRetrogen.java b/src/main/java/cpw/mods/retro/WorldRetrogen.java index 463b3ef..c458fe8 100644 --- a/src/main/java/cpw/mods/retro/WorldRetrogen.java +++ b/src/main/java/cpw/mods/retro/WorldRetrogen.java @@ -186,7 +186,7 @@ public void execute(MinecraftServer server, ICommandSender sender, String[] args if (targets.isEmpty()) { sender.sendMessage(new TextComponentString("There are no retrogen target classes")); } else { - sender.sendMessage(new TextComponentString("There are no retrogen target classes")); + sender.sendMessage(new TextComponentString(CommandBase.joinNiceStringFromCollection(targets))); } } }); From d0f9b836b6458b4bd856f43d7ad7da63e3001bd1 Mon Sep 17 00:00:00 2001 From: Hexeption Date: Tue, 20 Jun 2017 13:58:49 +0100 Subject: [PATCH 4/8] Updated to lates Forge Signed-off-by: Hexeption --- src/main/java/cpw/mods/retro/WorldRetrogen.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/cpw/mods/retro/WorldRetrogen.java b/src/main/java/cpw/mods/retro/WorldRetrogen.java index c458fe8..ef87b70 100644 --- a/src/main/java/cpw/mods/retro/WorldRetrogen.java +++ b/src/main/java/cpw/mods/retro/WorldRetrogen.java @@ -434,12 +434,12 @@ private void runRetrogen(WorldServer world, ChunkPos chunkCoords, String retroCl Random fmlRandom = new Random(worldSeed); long xSeed = fmlRandom.nextLong() >> 2 + 1L; long zSeed = fmlRandom.nextLong() >> 2 + 1L; - long chunkSeed = (xSeed * chunkCoords.chunkXPos + zSeed * chunkCoords.chunkZPos) ^ worldSeed; + long chunkSeed = (xSeed * chunkCoords.x + zSeed * chunkCoords.z) ^ worldSeed; fmlRandom.setSeed(chunkSeed); ChunkProviderServer providerServer = world.getChunkProvider(); IChunkGenerator generator = ObfuscationReflectionHelper.getPrivateValue(ChunkProviderServer.class, providerServer, "field_186029_c", "chunkGenerator"); - delegates.get(retroClass).delegate.generate(fmlRandom, chunkCoords.chunkXPos, chunkCoords.chunkZPos, world, generator, providerServer); + delegates.get(retroClass).delegate.generate(fmlRandom, chunkCoords.x, chunkCoords.z, world, generator, providerServer); FMLLog.fine("Retrogenerated chunk for %s", retroClass); completeRetrogen(chunkCoords, world, retroClass); } From b020d071961fd1fb17c464ebe08fd81f843a2a86 Mon Sep 17 00:00:00 2001 From: Hexeption Date: Wed, 19 Jul 2017 21:19:47 +0100 Subject: [PATCH 5/8] Updated Tests for Forge 1.12 Signed-off-by: Hexeption --- src/test/java/TestGenerator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/TestGenerator.java b/src/test/java/TestGenerator.java index 3ffe04d..4d31099 100644 --- a/src/test/java/TestGenerator.java +++ b/src/test/java/TestGenerator.java @@ -1,6 +1,6 @@ import net.minecraft.world.World; -import net.minecraft.world.chunk.IChunkGenerator; import net.minecraft.world.chunk.IChunkProvider; +import net.minecraft.world.gen.IChunkGenerator; import net.minecraftforge.fml.common.IWorldGenerator; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; From 0f720492ee0fe9cb1f9715acf3e356179c33a5b7 Mon Sep 17 00:00:00 2001 From: Hexeption Date: Mon, 7 Aug 2017 18:39:04 +0100 Subject: [PATCH 6/8] Update WorldRetrogen.java --- src/main/java/cpw/mods/retro/WorldRetrogen.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/cpw/mods/retro/WorldRetrogen.java b/src/main/java/cpw/mods/retro/WorldRetrogen.java index ef87b70..6663fb5 100644 --- a/src/main/java/cpw/mods/retro/WorldRetrogen.java +++ b/src/main/java/cpw/mods/retro/WorldRetrogen.java @@ -59,7 +59,7 @@ import java.util.concurrent.ConcurrentMap; import java.util.concurrent.Semaphore; -@Mod(modid="simpleretrogen", name="Simple Retrogen", acceptableRemoteVersions="*", acceptedMinecraftVersions = "[1.9,1.12]") +@Mod(modid="simpleretrogen", name="Simple Retrogen", acceptableRemoteVersions="*", acceptedMinecraftVersions = "[1.9,1.13]") @ParametersAreNonnullByDefault public class WorldRetrogen { private List markers = Lists.newArrayList(); From c48d26fc53b8ca31dabe96a6d7fd06782d4edc0b Mon Sep 17 00:00:00 2001 From: Hexeption Date: Tue, 8 Aug 2017 18:12:46 +0100 Subject: [PATCH 7/8] Update WorldRetrogen.java --- src/main/java/cpw/mods/retro/WorldRetrogen.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/cpw/mods/retro/WorldRetrogen.java b/src/main/java/cpw/mods/retro/WorldRetrogen.java index 6663fb5..426f028 100644 --- a/src/main/java/cpw/mods/retro/WorldRetrogen.java +++ b/src/main/java/cpw/mods/retro/WorldRetrogen.java @@ -59,7 +59,7 @@ import java.util.concurrent.ConcurrentMap; import java.util.concurrent.Semaphore; -@Mod(modid="simpleretrogen", name="Simple Retrogen", acceptableRemoteVersions="*", acceptedMinecraftVersions = "[1.9,1.13]") +@Mod(modid="simpleretrogen", name="Simple Retrogen", acceptableRemoteVersions="*", acceptedMinecraftVersions = "[1.9,1.13)") @ParametersAreNonnullByDefault public class WorldRetrogen { private List markers = Lists.newArrayList(); From 3dc6d3fcff828127f3c386d24e4cc716ad8911a2 Mon Sep 17 00:00:00 2001 From: Hexeption Date: Tue, 17 Oct 2017 03:30:13 +0100 Subject: [PATCH 8/8] Updated to latest dev version --- src/main/java/cpw/mods/retro/WorldRetrogen.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/cpw/mods/retro/WorldRetrogen.java b/src/main/java/cpw/mods/retro/WorldRetrogen.java index 426f028..95dec20 100644 --- a/src/main/java/cpw/mods/retro/WorldRetrogen.java +++ b/src/main/java/cpw/mods/retro/WorldRetrogen.java @@ -32,9 +32,9 @@ import net.minecraft.world.World; import net.minecraft.world.WorldServer; import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.IChunkGenerator; import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.gen.ChunkProviderServer; -import net.minecraft.world.gen.IChunkGenerator; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.config.Property; @@ -434,12 +434,12 @@ private void runRetrogen(WorldServer world, ChunkPos chunkCoords, String retroCl Random fmlRandom = new Random(worldSeed); long xSeed = fmlRandom.nextLong() >> 2 + 1L; long zSeed = fmlRandom.nextLong() >> 2 + 1L; - long chunkSeed = (xSeed * chunkCoords.x + zSeed * chunkCoords.z) ^ worldSeed; + long chunkSeed = (xSeed * chunkCoords.chunkXPos + zSeed * chunkCoords.chunkZPos) ^ worldSeed; fmlRandom.setSeed(chunkSeed); ChunkProviderServer providerServer = world.getChunkProvider(); IChunkGenerator generator = ObfuscationReflectionHelper.getPrivateValue(ChunkProviderServer.class, providerServer, "field_186029_c", "chunkGenerator"); - delegates.get(retroClass).delegate.generate(fmlRandom, chunkCoords.x, chunkCoords.z, world, generator, providerServer); + delegates.get(retroClass).delegate.generate(fmlRandom, chunkCoords.chunkXPos, chunkCoords.chunkZPos, world, generator, providerServer); FMLLog.fine("Retrogenerated chunk for %s", retroClass); completeRetrogen(chunkCoords, world, retroClass); }