-
Notifications
You must be signed in to change notification settings - Fork 10
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
Hexeption
wants to merge
8
commits into
cpw:master
Choose a base branch
from
Hexeption:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7565309
Updated for Forge 1.12
Hexeption 8e85bce
Fixed a typeo
Hexeption 2992e67
Re-Added 'sender.sendMessage(new TextComponentString(CommandBase.join…
Hexeption d0f9b83
Updated to lates Forge
Hexeption b020d07
Updated Tests for Forge 1.12
Hexeption 0f72049
Update WorldRetrogen.java
Hexeption c48d26f
Update WorldRetrogen.java
Hexeption 3dc6d3f
Updated to latest dev version
Hexeption File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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]") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will not work with Minecraft 1.12.1; |
||
@ParametersAreNonnullByDefault | ||
public class WorldRetrogen { | ||
private List<Marker> 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(CommandBase.joinNiceStringFromCollection(targets))); | ||
} | ||
} | ||
}); | ||
|
@@ -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<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(); | ||
|
@@ -450,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); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency and to handle subversions of 1.12, the
acceptedMinecraftVersions
string should probably be set to[1.9,1.13)
.