Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated for Forge 1.12 #13

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 18 additions & 34 deletions src/main/java/cpw/mods/retro/WorldRetrogen.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -35,8 +27,8 @@
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;
Expand All @@ -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.13)")
@ParametersAreNonnullByDefault
public class WorldRetrogen {
private List<Marker> markers = Lists.newArrayList();
Expand Down Expand Up @@ -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
Expand All @@ -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(CommandBase.joinNiceStringFromCollection(targets)));
}
}
});
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
}

Expand All @@ -373,7 +357,7 @@ public void onChunkSave(ChunkDataEvent.Save chunkevt)
if (completedWork.containsKey(w))
{
ListMultimap<ChunkPos, String> doneChunks = completedWork.get(w);
List<String> retroClassList = doneChunks.get(chunkevt.getChunk().getChunkCoordIntPair());
List<String> retroClassList = doneChunks.get(chunkevt.getChunk().getPos());
if (retroClassList.isEmpty())
return;
NBTTagCompound data = chunkevt.getData();
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/TestGenerator.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down