Update forge classes

This commit is contained in:
Jesse Boyd 2016-07-23 08:57:15 +10:00
parent 2f76cb59e3
commit d562b6cf66
23 changed files with 222 additions and 138 deletions

View File

@ -151,7 +151,7 @@ public class FaweBukkit implements IFawe, Listener {
if (this.version == null) {
try {
this.version = new int[3];
final String[] split = Bukkit.getBukkitVersion().split("-")[0].split("\\.");
final String[] split = plugin.getDescription().getVersion().split("-")[0].split("\\.");
this.version[0] = Integer.parseInt(split[0]);
this.version[1] = Integer.parseInt(split[1]);
if (split.length == 3) {

View File

@ -36,8 +36,6 @@ import net.minecraft.server.v1_10_R1.BlockPosition;
import net.minecraft.server.v1_10_R1.Blocks;
import net.minecraft.server.v1_10_R1.ChunkCoordIntPair;
import net.minecraft.server.v1_10_R1.ChunkSection;
import net.minecraft.server.v1_10_R1.DataBits;
import net.minecraft.server.v1_10_R1.DataPalette;
import net.minecraft.server.v1_10_R1.DataPaletteBlock;
import net.minecraft.server.v1_10_R1.Entity;
import net.minecraft.server.v1_10_R1.EntityHuman;
@ -666,13 +664,6 @@ public class BukkitQueue_1_10 extends BukkitQueue_0<Chunk, ChunkSection[], DataP
continue;
}
DataPaletteBlock nibble = section.getBlocks();
Field fieldBits = nibble.getClass().getDeclaredField("b");
fieldBits.setAccessible(true);
DataBits bits = (DataBits) fieldBits.get(nibble);
Field fieldPalette = nibble.getClass().getDeclaredField("c");
fieldPalette.setAccessible(true);
DataPalette palette = (DataPalette) fieldPalette.get(nibble);
int nonEmptyBlockCount = 0;
for (int y = 0; y < 16; y++) {
for (int z = 0; z < 16; z++) {

View File

@ -156,9 +156,9 @@ public class Fawe {
* Write something to the console
* @param s
*/
public static void debug(final String s) {
public static void debug(final Object s) {
if (INSTANCE != null) {
INSTANCE.IMP.debug(s);
INSTANCE.IMP.debug(StringMan.getString(s));
} else {
System.out.print(s);
}
@ -409,7 +409,6 @@ public class Fawe {
}
final long alert = (max * Settings.MAX_MEMORY_PERCENT) / 100;
mp.setUsageThreshold(alert);
}
}
} catch (Throwable e) {

View File

@ -4,6 +4,7 @@ import com.boydti.fawe.Fawe;
import com.boydti.fawe.configuration.MemorySection;
import com.boydti.fawe.configuration.file.YamlConfiguration;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.RunnableVal3;
import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.StringMan;
import com.sk89q.worldedit.extension.platform.Actor;
@ -358,4 +359,55 @@ public enum BBC {
}
}
public static String getColorName(char code) {
switch (code) {
case '0': return "BLACK";
case '1': return "DARK_BLUE";
case '2': return "DARK_GREEN";
case '3': return "DARK_AQUA";
case '4': return "DARK_RED";
case '5': return "DARK_PURPLE";
case '6': return "GOLD";
default:
case '7': return "GRAY";
case '8': return "DARK_GRAY";
case '9': return "BLUE";
case 'a': return "GREEN";
case 'b': return "AQUA";
case 'c': return "RED";
case 'd': return "LIGHT_PURPLE";
case 'e': return "YELLOW";
case 'f': return "WHITE";
case 'k': return "OBFUSCATED";
case 'l': return "BOLD";
case 'm': return "STRIKETHROUGH";
case 'n': return "UNDERLINE";
case 'o': return "ITALIC";
case 'r': return "RESET";
}
}
/**
*
* @param m
* @param runPart Part, Color, NewLine
*/
public static void splitMessage(String m, RunnableVal3<String, String, Boolean> runPart) {
m = color(m);
String color = "GRAY";
boolean newline = false;
for (String line : m.split("\n")) {
boolean hasColor = line.charAt(0) == '\u00A7';
String[] splitColor = line.split("\u00A7");
for (String part : splitColor) {
if (hasColor) {
color = getColorName(part.charAt(0));
part = part.substring(1);
}
runPart.run(part, color, newline);
hasColor = true;
}
newline = true;
}
}
}

View File

@ -3,10 +3,10 @@ package com.boydti.fawe.example;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FaweChunk;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.object.IntegerPair;
import com.boydti.fawe.object.RunnableVal;
import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.SetQueue;
import com.boydti.fawe.util.TaskManager;

View File

@ -18,7 +18,6 @@ apply plugin: 'com.github.johnrengelman.shadow'
dependencies {
compile project(':core')
compile 'org.spongepowered:spongeapi:4.+'
compile 'org.mcstats.sponge:metrics:R8-SNAPSHOT'
compile 'com.sk89q.worldedit:worldedit-forge-mc1.8.9:6.1.1'
}

View File

@ -17,12 +17,15 @@ import com.sk89q.worldedit.world.World;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import javax.management.InstanceAlreadyExistsException;
import net.minecraft.command.ServerCommandManager;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.server.MinecraftServer;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.ModMetadata;
import org.apache.logging.log4j.Logger;
public class FaweForge implements IFawe {
@ -30,11 +33,13 @@ public class FaweForge implements IFawe {
private final ForgeMain parent;
private final File directory;
private final Logger logger;
private final ModMetadata mod;
public FaweForge(ForgeMain plugin, Logger logger, File directory) {
public FaweForge(ForgeMain plugin, Logger logger, ModMetadata mod, File directory) {
this.parent = plugin;
this.logger = logger;
this.directory = directory;
this.mod = mod;
try {
Fawe.set(this);
} catch (InstanceAlreadyExistsException e) {
@ -52,16 +57,17 @@ public class FaweForge implements IFawe {
return directory;
}
private HashMap<String, FaweCommand> commands = new HashMap<>();
@Override
public void setupCommand(String label, FaweCommand cmd) {
if (TaskManager.IMP != null) {
TaskManager.IMP.task(new Runnable() {
@Override
public void run() {
ServerCommandManager scm = (ServerCommandManager) FMLCommonHandler.instance().getMinecraftServerInstance().getCommandManager();
scm.registerCommand(new ForgeCommand(label, cmd));
}
});
this.commands.put(label, cmd);
}
public void insertCommands() {
for (Map.Entry<String, FaweCommand> entry : commands.entrySet()) {
ServerCommandManager scm = (ServerCommandManager) FMLCommonHandler.instance().getMinecraftServerInstance().getCommandManager();
scm.registerCommand(new ForgeCommand(entry.getKey(), entry.getValue()));
}
}
@ -96,7 +102,7 @@ public class FaweForge implements IFawe {
@Override
public int[] getVersion() {
String[] version = FMLCommonHandler.instance().getMinecraftServerInstance().getMinecraftVersion().split("\\.");
String[] version = this.mod.version.split("\\.");
return new int[] {Integer.parseInt(version[0]), Integer.parseInt(version[1]), Integer.parseInt(version[2])};
}

View File

@ -12,6 +12,7 @@ import net.minecraftforge.event.entity.EntityJoinWorldEvent;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
import net.minecraftforge.fml.common.event.FMLServerStoppingEvent;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
@ -29,7 +30,12 @@ public class ForgeMain {
File directory = new File(event.getModConfigurationDirectory() + File.separator + "FastAsyncWorldEdit");
MinecraftForge.EVENT_BUS.register(this);
FMLCommonHandler.instance().bus().register(this);
this.IMP = new com.boydti.fawe.forge.FaweForge(this, event.getModLog(), directory);
this.IMP = new FaweForge(this, event.getModLog(), event.getModMetadata(), directory);
}
@Mod.EventHandler
public void serverLoad(FMLServerStartingEvent event) {
IMP.insertCommands();
}
@SubscribeEvent(priority = EventPriority.HIGHEST)

View File

@ -10,7 +10,6 @@ import com.sk89q.worldedit.forge.ForgeWorldEdit;
import java.util.UUID;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextComponentBase;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.world.World;
@ -52,10 +51,9 @@ public class ForgePlayer extends FawePlayer<EntityPlayerMP> {
@Override
public void sendMessage(String msg) {
for (String part : msg.split("\n")) {
part = BBC.color(part);
TextComponentBase text = new TextComponentString(part);
this.parent.addChatMessage(text);
msg = BBC.color(msg);
for (String line : msg.split("\n")) {
this.parent.addChatMessage(new TextComponentString(line));
}
}

View File

@ -42,7 +42,6 @@ import net.minecraft.network.play.server.SPacketDestroyEntities;
import net.minecraft.server.management.PlayerChunkMap;
import net.minecraft.server.management.PlayerChunkMapEntry;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BitArray;
import net.minecraft.util.ClassInheritanceMultiMap;
import net.minecraft.util.IntHashMap;
import net.minecraft.util.math.BlockPos;
@ -51,7 +50,6 @@ import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraft.world.chunk.BlockStateContainer;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.IBlockStatePalette;
import net.minecraft.world.chunk.IChunkGenerator;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.chunk.NibbleArray;
@ -61,20 +59,23 @@ import net.minecraftforge.fml.common.FMLCommonHandler;
public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlockStorage[], BlockStateContainer> {
private Method methodFromNative;
private Method methodToNative;
private static Method methodFromNative;
private static Method methodToNative;
public ForgeQueue_All(String world) {
super(world);
try {
Class<?> converter = Class.forName("com.sk89q.worldedit.forge.NBTConverter");
this.methodFromNative = converter.getDeclaredMethod("toNative", Tag.class);
this.methodToNative = converter.getDeclaredMethod("fromNative", NBTBase.class);
methodFromNative.setAccessible(true);
methodToNative.setAccessible(true);
} catch (Throwable e) {
throw new RuntimeException(e);
if (methodFromNative == null) {
try {
Class<?> converter = Class.forName("com.sk89q.worldedit.forge.NBTConverter");
this.methodFromNative = converter.getDeclaredMethod("toNative", Tag.class);
this.methodToNative = converter.getDeclaredMethod("fromNative", NBTBase.class);
methodFromNative.setAccessible(true);
methodToNative.setAccessible(true);
} catch (Throwable e) {
throw new RuntimeException(e);
}
}
getImpWorld();
}
private BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(0, 0, 0);
@ -300,7 +301,7 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
ForgeChunk_All fs = (ForgeChunk_All) fc;
net.minecraft.world.chunk.Chunk nmsChunk = fs.getChunk();
nmsChunk.setModified(true);
net.minecraft.world.World nmsWorld = nmsChunk.getWorld();
net.minecraft.world.World nmsWorld = getWorld();
try {
boolean flag = !nmsWorld.provider.getHasNoSky();
// Sections
@ -412,8 +413,9 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
section = sections[j] = new ExtendedBlockStorage(j << 4, flag);
setPalette(section, fs.sectionPalettes[j]);
setCount(0, count - fs.getAir(j), section);
continue;
} else {
sections[j] = new ExtendedBlockStorage(j << 4, flag);
sections[j] = section = new ExtendedBlockStorage(j << 4, flag);
}
} else if (count >= 4096) {
if (fs.sectionPalettes != null && fs.sectionPalettes[j] != null) {
@ -421,17 +423,10 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
setCount(0, count - fs.getAir(j), section);
continue;
} else {
sections[j] = new ExtendedBlockStorage(j << 4, flag);
sections[j] = section = new ExtendedBlockStorage(j << 4, flag);
}
}
BlockStateContainer nibble = section.getData();
Field fieldBits = BlockStateContainer.class.getDeclaredField("storage");
fieldBits.setAccessible(true);
BitArray bits = (BitArray) fieldBits.get(nibble);
Field fieldPalette = BlockStateContainer.class.getDeclaredField("palette");
fieldPalette.setAccessible(true);
IBlockStatePalette palette = (IBlockStatePalette) fieldPalette.get(nibble);
int nonEmptyBlockCount = 0;
for (int y = 0; y < 16; y++) {
for (int z = 0; z < 16; z++) {
@ -550,6 +545,7 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
if (field.getType() == IntHashMap.class) {
field.setAccessible(true);
entries = (IntHashMap<EntityTrackerEntry>) field.get(tracker);
break;
}
}
for (ClassInheritanceMultiMap<Entity> slice : entitieSlices) {
@ -619,7 +615,7 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
@Override
public boolean hasSky() {
return nmsWorld.provider.getHasNoSky();
return !nmsWorld.provider.getHasNoSky();
}
@Override

View File

@ -17,7 +17,6 @@ apply plugin: 'com.github.johnrengelman.shadow'
dependencies {
compile project(':core')
compile 'org.mcstats.sponge:metrics:R8-SNAPSHOT'
compile 'com.sk89q.worldedit:worldedit-forge-mc1.7.10:6.1.1-20151030.011615-19'
compile 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT'
}

View File

@ -13,10 +13,14 @@ import com.boydti.fawe.util.TaskManager;
import com.boydti.fawe.wrappers.WorldWrapper;
import com.sk89q.worldedit.forge.ForgeWorld;
import com.sk89q.worldedit.world.World;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.ModMetadata;
import java.io.File;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import javax.management.InstanceAlreadyExistsException;
import net.minecraft.command.ServerCommandManager;
@ -29,11 +33,13 @@ public class FaweForge implements IFawe {
private final ForgeMain parent;
private final File directory;
private final Logger logger;
private final ModMetadata mod;
public FaweForge(ForgeMain plugin, Logger logger, File directory) {
public FaweForge(ForgeMain plugin, Logger logger, ModMetadata mod, File directory) {
this.parent = plugin;
this.logger = logger;
this.directory = directory;
this.mod = mod;
try {
Fawe.set(this);
} catch (InstanceAlreadyExistsException e) {
@ -51,16 +57,17 @@ public class FaweForge implements IFawe {
return directory;
}
private HashMap<String, FaweCommand> commands = new HashMap<>();
@Override
public void setupCommand(final String label, final FaweCommand cmd) {
if (TaskManager.IMP != null) {
TaskManager.IMP.task(new Runnable() {
@Override
public void run() {
ServerCommandManager scm = (ServerCommandManager) MinecraftServer.getServer().getCommandManager();
scm.registerCommand(new ForgeCommand(label, cmd));
}
});
public void setupCommand(String label, FaweCommand cmd) {
this.commands.put(label, cmd);
}
public void insertCommands() {
for (Map.Entry<String, FaweCommand> entry : commands.entrySet()) {
ServerCommandManager scm = (ServerCommandManager) FMLCommonHandler.instance().getMinecraftServerInstance().getCommandManager();
scm.registerCommand(new ForgeCommand(entry.getKey(), entry.getValue()));
}
}
@ -92,7 +99,7 @@ public class FaweForge implements IFawe {
@Override
public int[] getVersion() {
String[] version = MinecraftServer.getServer().getMinecraftVersion().split("\\.");
String[] version = this.mod.version.split("\\.");
return new int[] {Integer.parseInt(version[0]), Integer.parseInt(version[1]), Integer.parseInt(version[2])};
}

View File

@ -6,6 +6,7 @@ import com.boydti.fawe.object.FawePlayer;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.event.FMLServerStoppingEvent;
import cpw.mods.fml.common.eventhandler.EventPriority;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
@ -30,7 +31,12 @@ public class ForgeMain {
File directory = new File(event.getModConfigurationDirectory() + File.separator + "FastAsyncWorldEdit");
MinecraftForge.EVENT_BUS.register(this);
FMLCommonHandler.instance().bus().register(this);
this.IMP = new FaweForge(this, event.getModLog(), directory);
this.IMP = new FaweForge(this, event.getModLog(), event.getModMetadata(), directory);
}
@Mod.EventHandler
public void serverLoad(FMLServerStartingEvent event) {
IMP.insertCommands();
}
@SubscribeEvent(priority = EventPriority.HIGHEST)

View File

@ -54,20 +54,23 @@ import net.minecraft.world.gen.ChunkProviderServer;
public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlockStorage[], ExtendedBlockStorage> {
private Method methodFromNative;
private Method methodToNative;
private static Method methodFromNative;
private static Method methodToNative;
public ForgeQueue_All(String world) {
super(world);
try {
Class<?> converter = Class.forName("com.sk89q.worldedit.forge.NBTConverter");
this.methodFromNative = converter.getDeclaredMethod("toNative", Tag.class);
this.methodToNative = converter.getDeclaredMethod("fromNative", NBTBase.class);
methodFromNative.setAccessible(true);
methodToNative.setAccessible(true);
} catch (Throwable e) {
throw new RuntimeException(e);
if (methodFromNative == null) {
try {
Class<?> converter = Class.forName("com.sk89q.worldedit.forge.NBTConverter");
this.methodFromNative = converter.getDeclaredMethod("toNative", Tag.class);
this.methodToNative = converter.getDeclaredMethod("fromNative", NBTBase.class);
methodFromNative.setAccessible(true);
methodToNative.setAccessible(true);
} catch (Throwable e) {
throw new RuntimeException(e);
}
}
getImpWorld();
}
@Override
@ -242,6 +245,7 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
if (field.getType() == IntHashMap.class) {
field.setAccessible(true);
entries = (IntHashMap) field.get(tracker);
break;
}
}
for (Collection<Entity> slice : entitieSlices) {
@ -605,7 +609,7 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
@Override
public boolean hasSky() {
return nmsWorld.provider.hasNoSky;
return !nmsWorld.provider.hasNoSky;
}
@Override

View File

@ -18,7 +18,6 @@ apply plugin: 'com.github.johnrengelman.shadow'
dependencies {
compile project(':core')
compile 'org.spongepowered:spongeapi:4.+'
compile 'org.mcstats.sponge:metrics:R8-SNAPSHOT'
compile 'com.sk89q.worldedit:worldedit-forge-mc1.8.9:6.1.1'
}

View File

@ -6,8 +6,8 @@ import com.boydti.fawe.IFawe;
import com.boydti.fawe.forge.v0.ForgeQueue_All;
import com.boydti.fawe.object.FaweCommand;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.regions.FaweMaskManager;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.regions.FaweMaskManager;
import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.TaskManager;
import com.boydti.fawe.wrappers.WorldWrapper;
@ -17,24 +17,29 @@ import com.sk89q.worldedit.world.World;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import javax.management.InstanceAlreadyExistsException;
import net.minecraft.command.ServerCommandManager;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.server.MinecraftServer;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.ModMetadata;
import org.apache.logging.log4j.Logger;
import org.primesoft.blockshub.IBlocksHubApi;
public class FaweForge implements IFawe {
private final ForgeMain parent;
private final File directory;
private final Logger logger;
private final ModMetadata mod;
public FaweForge(ForgeMain plugin, Logger logger, File directory) {
public FaweForge(ForgeMain plugin, Logger logger, ModMetadata mod, File directory) {
this.parent = plugin;
this.logger = logger;
this.directory = directory;
this.mod = mod;
try {
Fawe.set(this);
} catch (InstanceAlreadyExistsException e) {
@ -52,16 +57,17 @@ public class FaweForge implements IFawe {
return directory;
}
private HashMap<String, FaweCommand> commands = new HashMap<>();
@Override
public void setupCommand(String label, FaweCommand cmd) {
if (TaskManager.IMP != null) {
TaskManager.IMP.task(new Runnable() {
@Override
public void run() {
ServerCommandManager scm = (ServerCommandManager) MinecraftServer.getServer().getCommandManager();
scm.registerCommand(new ForgeCommand(label, cmd));
}
});
this.commands.put(label, cmd);
}
public void insertCommands() {
for (Map.Entry<String, FaweCommand> entry : commands.entrySet()) {
ServerCommandManager scm = (ServerCommandManager) FMLCommonHandler.instance().getMinecraftServerInstance().getCommandManager();
scm.registerCommand(new ForgeCommand(entry.getKey(), entry.getValue()));
}
}
@ -96,7 +102,7 @@ public class FaweForge implements IFawe {
@Override
public int[] getVersion() {
String[] version = MinecraftServer.getServer().getMinecraftVersion().split("\\.");
String[] version = this.mod.version.split("\\.");
return new int[] {Integer.parseInt(version[0]), Integer.parseInt(version[1]), Integer.parseInt(version[2])};
}

View File

@ -13,6 +13,7 @@ import net.minecraftforge.event.entity.EntityJoinWorldEvent;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
import net.minecraftforge.fml.common.event.FMLServerStoppingEvent;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
@ -30,7 +31,12 @@ public class ForgeMain {
File directory = new File(event.getModConfigurationDirectory() + File.separator + "FastAsyncWorldEdit");
MinecraftForge.EVENT_BUS.register(this);
FMLCommonHandler.instance().bus().register(this);
this.IMP = new com.boydti.fawe.forge.FaweForge(this, event.getModLog(), directory);
this.IMP = new FaweForge(this, event.getModLog(), event.getModMetadata(), directory);
}
@Mod.EventHandler
public void serverLoad(FMLServerStartingEvent event) {
IMP.insertCommands();
}
@SubscribeEvent(priority = EventPriority.HIGHEST)

View File

@ -52,20 +52,23 @@ import net.minecraft.world.gen.ChunkProviderServer;
public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlockStorage[], char[]> {
private Method methodFromNative;
private Method methodToNative;
private static Method methodFromNative;
private static Method methodToNative;
public ForgeQueue_All(String world) {
super(world);
try {
Class<?> converter = Class.forName("com.sk89q.worldedit.forge.NBTConverter");
this.methodFromNative = converter.getDeclaredMethod("toNative", Tag.class);
this.methodToNative = converter.getDeclaredMethod("fromNative", NBTBase.class);
methodFromNative.setAccessible(true);
methodToNative.setAccessible(true);
} catch (Throwable e) {
throw new RuntimeException(e);
if (methodFromNative == null) {
try {
Class<?> converter = Class.forName("com.sk89q.worldedit.forge.NBTConverter");
this.methodFromNative = converter.getDeclaredMethod("toNative", Tag.class);
this.methodToNative = converter.getDeclaredMethod("fromNative", NBTBase.class);
methodFromNative.setAccessible(true);
methodToNative.setAccessible(true);
} catch (Throwable e) {
throw new RuntimeException(e);
}
}
getImpWorld();
}
private BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(0, 0, 0);
@ -481,6 +484,7 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
if (field.getType() == IntHashMap.class) {
field.setAccessible(true);
entries = (IntHashMap<EntityTrackerEntry>) field.get(tracker);
break;
}
}
for (ClassInheritanceMultiMap<Entity> slice : entitieSlices) {
@ -567,7 +571,7 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
@Override
public boolean hasSky() {
return nmsWorld.provider.getHasNoSky();
return !nmsWorld.provider.getHasNoSky();
}
@Override

View File

@ -18,7 +18,6 @@ apply plugin: 'com.github.johnrengelman.shadow'
dependencies {
compile project(':core')
compile 'org.spongepowered:spongeapi:4.+'
compile 'org.mcstats.sponge:metrics:R8-SNAPSHOT'
compile 'com.sk89q.worldedit:worldedit-forge-mc1.8.9:6.1.1'
}

View File

@ -17,12 +17,15 @@ import com.sk89q.worldedit.world.World;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import javax.management.InstanceAlreadyExistsException;
import net.minecraft.command.ServerCommandManager;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.server.MinecraftServer;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.ModMetadata;
import org.apache.logging.log4j.Logger;
public class FaweForge implements IFawe {
@ -30,11 +33,13 @@ public class FaweForge implements IFawe {
private final ForgeMain parent;
private final File directory;
private final Logger logger;
private final ModMetadata mod;
public FaweForge(ForgeMain plugin, Logger logger, File directory) {
public FaweForge(ForgeMain plugin, Logger logger, ModMetadata mod, File directory) {
this.parent = plugin;
this.logger = logger;
this.directory = directory;
this.mod = mod;
try {
Fawe.set(this);
} catch (InstanceAlreadyExistsException e) {
@ -52,16 +57,17 @@ public class FaweForge implements IFawe {
return directory;
}
private HashMap<String, FaweCommand> commands = new HashMap<>();
@Override
public void setupCommand(String label, FaweCommand cmd) {
if (TaskManager.IMP != null) {
TaskManager.IMP.task(new Runnable() {
@Override
public void run() {
ServerCommandManager scm = (ServerCommandManager) FMLCommonHandler.instance().getMinecraftServerInstance().getCommandManager();
scm.registerCommand(new ForgeCommand(label, cmd));
}
});
this.commands.put(label, cmd);
}
public void insertCommands() {
for (Map.Entry<String, FaweCommand> entry : commands.entrySet()) {
ServerCommandManager scm = (ServerCommandManager) FMLCommonHandler.instance().getMinecraftServerInstance().getCommandManager();
scm.registerCommand(new ForgeCommand(entry.getKey(), entry.getValue()));
}
}
@ -96,7 +102,7 @@ public class FaweForge implements IFawe {
@Override
public int[] getVersion() {
String[] version = FMLCommonHandler.instance().getMinecraftServerInstance().getMinecraftVersion().split("\\.");
String[] version = this.mod.version.split("\\.");
return new int[] {Integer.parseInt(version[0]), Integer.parseInt(version[1]), Integer.parseInt(version[2])};
}

View File

@ -12,6 +12,7 @@ import net.minecraftforge.event.entity.EntityJoinWorldEvent;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
import net.minecraftforge.fml.common.event.FMLServerStoppingEvent;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
@ -29,7 +30,12 @@ public class ForgeMain {
File directory = new File(event.getModConfigurationDirectory() + File.separator + "FastAsyncWorldEdit");
MinecraftForge.EVENT_BUS.register(this);
FMLCommonHandler.instance().bus().register(this);
this.IMP = new com.boydti.fawe.forge.FaweForge(this, event.getModLog(), directory);
this.IMP = new FaweForge(this, event.getModLog(), event.getModMetadata(), directory);
}
@Mod.EventHandler
public void serverLoad(FMLServerStartingEvent event) {
IMP.insertCommands();
}
@SubscribeEvent(priority = EventPriority.HIGHEST)

View File

@ -42,7 +42,6 @@ import net.minecraft.network.play.server.SPacketDestroyEntities;
import net.minecraft.server.management.PlayerChunkMap;
import net.minecraft.server.management.PlayerChunkMapEntry;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BitArray;
import net.minecraft.util.ClassInheritanceMultiMap;
import net.minecraft.util.IntHashMap;
import net.minecraft.util.math.BlockPos;
@ -51,7 +50,6 @@ import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraft.world.chunk.BlockStateContainer;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.IBlockStatePalette;
import net.minecraft.world.chunk.IChunkGenerator;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.chunk.NibbleArray;
@ -61,20 +59,23 @@ import net.minecraftforge.fml.common.FMLCommonHandler;
public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlockStorage[], BlockStateContainer> {
private Method methodFromNative;
private Method methodToNative;
private static Method methodFromNative;
private static Method methodToNative;
public ForgeQueue_All(String world) {
super(world);
try {
Class<?> converter = Class.forName("com.sk89q.worldedit.forge.NBTConverter");
this.methodFromNative = converter.getDeclaredMethod("toNative", Tag.class);
this.methodToNative = converter.getDeclaredMethod("fromNative", NBTBase.class);
methodFromNative.setAccessible(true);
methodToNative.setAccessible(true);
} catch (Throwable e) {
throw new RuntimeException(e);
if (methodFromNative == null) {
try {
Class<?> converter = Class.forName("com.sk89q.worldedit.forge.NBTConverter");
this.methodFromNative = converter.getDeclaredMethod("toNative", Tag.class);
this.methodToNative = converter.getDeclaredMethod("fromNative", NBTBase.class);
methodFromNative.setAccessible(true);
methodToNative.setAccessible(true);
} catch (Throwable e) {
throw new RuntimeException(e);
}
}
getImpWorld();
}
private BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(0, 0, 0);
@ -412,8 +413,9 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
section = sections[j] = new ExtendedBlockStorage(j << 4, flag);
setPalette(section, fs.sectionPalettes[j]);
setCount(0, count - fs.getAir(j), section);
continue;
} else {
sections[j] = new ExtendedBlockStorage(j << 4, flag);
sections[j] = section = new ExtendedBlockStorage(j << 4, flag);
}
} else if (count >= 4096) {
if (fs.sectionPalettes != null && fs.sectionPalettes[j] != null) {
@ -421,17 +423,10 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
setCount(0, count - fs.getAir(j), section);
continue;
} else {
sections[j] = new ExtendedBlockStorage(j << 4, flag);
sections[j] = section = new ExtendedBlockStorage(j << 4, flag);
}
}
BlockStateContainer nibble = section.getData();
Field fieldBits = BlockStateContainer.class.getDeclaredField("storage");
fieldBits.setAccessible(true);
BitArray bits = (BitArray) fieldBits.get(nibble);
Field fieldPalette = BlockStateContainer.class.getDeclaredField("palette");
fieldPalette.setAccessible(true);
IBlockStatePalette palette = (IBlockStatePalette) fieldPalette.get(nibble);
int nonEmptyBlockCount = 0;
for (int y = 0; y < 16; y++) {
for (int z = 0; z < 16; z++) {
@ -550,6 +545,7 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
if (field.getType() == IntHashMap.class) {
field.setAccessible(true);
entries = (IntHashMap<EntityTrackerEntry>) field.get(tracker);
break;
}
}
for (ClassInheritanceMultiMap<Entity> slice : entitieSlices) {
@ -619,7 +615,7 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
@Override
public boolean hasSky() {
return nmsWorld.provider.getHasNoSky();
return !nmsWorld.provider.getHasNoSky();
}
@Override

View File

@ -24,7 +24,6 @@ apply plugin: 'com.github.johnrengelman.shadow'
dependencies {
compile project(':core')
compile 'org.spongepowered:spongeapi:4.+'
compile 'org.mcstats.sponge:metrics:R8-SNAPSHOT'
compile 'com.sk89q.worldedit:worldedit-forge-mc1.8.9:6.1.1'
}