3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-12-25 18:40:05 +01:00

Update to Forge 1.7.10-10.13.1.1225

Dieser Commit ist enthalten in:
Kenzie Togami 2014-10-12 12:27:51 -07:00
Ursprung 2214bcc948
Commit 1c89f4bffa
17 geänderte Dateien mit 167 neuen und 161 gelöschten Zeilen

Datei anzeigen

@ -2,10 +2,10 @@ language: java
notifications: notifications:
email: false email: false
before_install: chmod +x gradlew before_install: chmod +x gradlew
install: true install: ./gradlew setupCIWorkspace -S
matrix: matrix:
include: include:
- jdk: oraclejdk7 - jdk: oraclejdk7
script: mvn clean package script: mvn clean package
- jdk: oraclejdk7 - jdk: oraclejdk7
script: gradle build script: ./gradlew build -S

Datei anzeigen

@ -65,11 +65,12 @@ command:
Build WorldEdit for Forge with: Build WorldEdit for Forge with:
gradle setupDecompWorkspace
gradle build gradle build
Once complete, you will find the release .jar in the folder *build/libs*. Once complete, you will find the release .jar in the folder *build/libs*.
### Other Tasks ### Other Tasks
* `gradle setupDecompWorkspace idea` will generate an [IntelliJ IDEA](http://www.jetbrains.com/idea/) workspace * `gradle idea` will generate an [IntelliJ IDEA](http://www.jetbrains.com/idea/) workspace
* `gradle setupDecompWorkspace eclipse` will generate an [Eclipse](https://www.eclipse.org/downloads/) workspace * `gradle eclipse` will generate an [Eclipse](https://www.eclipse.org/downloads/) workspace

Datei anzeigen

@ -6,20 +6,27 @@
buildscript { buildscript {
repositories { repositories {
mavenCentral() mavenCentral()
maven { url = "http://files.minecraftforge.net/maven" } maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:1.0-SNAPSHOT' classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT'
classpath 'com.github.jengelman.gradle.plugins:shadow:0.8' classpath 'com.github.jengelman.gradle.plugins:shadow:1.1.1'
} }
} }
apply plugin: 'java' apply plugin: 'java'
apply plugin: 'maven' apply plugin: 'maven'
apply plugin: 'forge' apply plugin: 'forge'
apply plugin: 'shadow' apply plugin: 'com.github.johnrengelman.shadow'
group = 'com.sk89q' group = 'com.sk89q'
version = '6.0.0-SNAPSHOT' + System.getProperty("worldedit.build.suffix", "") version = '6.0.0-SNAPSHOT' + System.getProperty("worldedit.build.suffix", "")
@ -66,8 +73,8 @@ sourceSets {
} }
minecraft { minecraft {
version = "1.6.4-9.11.1.964" ext.forgeVersion = "10.13.1.1225"
forgeVersion = "9.11.1.964" version = "1.7.10-$forgeVersion"
replaceIn "com/sk89q/worldedit/forge/ForgeWorldEdit.java" replaceIn "com/sk89q/worldedit/forge/ForgeWorldEdit.java"
replace "%VERSION%", project.version replace "%VERSION%", project.version
@ -86,34 +93,29 @@ processResources {
} }
// shade needed runtime dependencies // shade needed runtime dependencies
shadow { shadowJar {
//artifactAttached false classifier 'shadow'
destinationDir "${buildDir}/libs/" dependencies {
artifactSet { include(dependency('com.sk89q:jchronic:0.2.4a'))
include '*:jchronic:jar:' include(dependency('com.thoughtworks.paranamer:paranamer:2.6'))
include '*:paranamer:jar:' include(dependency('com.sk89q.lib:jlibnoise:1.0.0'))
include '*:jlibnoise:jar:'
} }
exclude 'GradleStart**'
exclude '.cache'
}
// ensure reobf happens
reobf.reobf(shadowJar) { spec ->
spec.classpath = sourceSets.main.compileClasspath;
} }
task deleteOrig(type: Delete) { task deleteOrig(type: Delete) {
delete "${project.tasks.jar.getArchivePath().getPath()}" delete project.tasks.jar.archivePath.getPath()
}
task renameShaded(type: Copy) {
from file("${buildDir}/libs")
into file("${buildDir}/libs")
rename { String fileName ->
fileName.replace('-shadow', '')
}
} }
task deleteShaded(type: Delete) { task deleteShaded(type: Delete) {
delete "${project.tasks.jar.getArchivePath().getPath().replace('.jar', '-shadow.jar')}" delete project.tasks.shadowJar.archivePath.getPath()
} }
// follow all the steps shadowJar.dependsOn(deleteShaded)
build.dependsOn(deleteShaded) build.dependsOn(shadowJar)
deleteShaded.dependsOn(renameShaded)
renameShaded.dependsOn(deleteOrig)
deleteOrig.dependsOn(shadowJar)

Datei anzeigen

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.11-bin.zip distributionUrl=http\://services.gradle.org/distributions/gradle-2.0-bin.zip

Datei anzeigen

@ -19,13 +19,22 @@
package com.sk89q.worldedit.forge; package com.sk89q.worldedit.forge;
import com.google.common.base.Throwables;
import com.google.common.collect.HashBiMap; import com.google.common.collect.HashBiMap;
import com.sk89q.worldedit.world.biome.BaseBiome; import com.sk89q.worldedit.world.biome.BaseBiome;
import com.sk89q.worldedit.world.biome.BiomeData; import com.sk89q.worldedit.world.biome.BiomeData;
import com.sk89q.worldedit.world.registry.BiomeRegistry; import com.sk89q.worldedit.world.registry.BiomeRegistry;
import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.biome.BiomeGenBase;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.Type;
import java.util.Arrays;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
@ -36,7 +45,6 @@ import java.util.Map;
* Provides access to biome data in Forge. * Provides access to biome data in Forge.
*/ */
class ForgeBiomeRegistry implements BiomeRegistry { class ForgeBiomeRegistry implements BiomeRegistry {
private static Map<Integer, BiomeGenBase> biomes = Collections.emptyMap(); private static Map<Integer, BiomeGenBase> biomes = Collections.emptyMap();
private static Map<Integer, BiomeData> biomeData = Collections.emptyMap(); private static Map<Integer, BiomeData> biomeData = Collections.emptyMap();
@ -71,7 +79,7 @@ class ForgeBiomeRegistry implements BiomeRegistry {
Map<Integer, BiomeGenBase> biomes = HashBiMap.create(); Map<Integer, BiomeGenBase> biomes = HashBiMap.create();
Map<Integer, BiomeData> biomeData = new HashMap<Integer, BiomeData>(); Map<Integer, BiomeData> biomeData = new HashMap<Integer, BiomeData>();
for (BiomeGenBase biome : BiomeGenBase.biomeList) { for (BiomeGenBase biome : BiomeGenBase.getBiomeGenArray()) {
if ((biome == null) || (biomes.containsValue(biome))) { if ((biome == null) || (biomes.containsValue(biome))) {
continue; continue;
} }

Datei anzeigen

@ -27,7 +27,7 @@ import net.minecraft.entity.INpc;
import net.minecraft.entity.IProjectile; import net.minecraft.entity.IProjectile;
import net.minecraft.entity.item.EntityBoat; import net.minecraft.entity.item.EntityBoat;
import net.minecraft.entity.item.EntityEnderEye; import net.minecraft.entity.item.EntityEnderEye;
import net.minecraft.entity.item.EntityFallingSand; import net.minecraft.entity.item.EntityFallingBlock;
import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.item.EntityItemFrame; import net.minecraft.entity.item.EntityItemFrame;
import net.minecraft.entity.item.EntityMinecart; import net.minecraft.entity.item.EntityMinecart;
@ -68,7 +68,7 @@ public class ForgeEntityType implements EntityType {
@Override @Override
public boolean isFallingBlock() { public boolean isFallingBlock() {
return entity instanceof EntityFallingSand; return entity instanceof EntityFallingBlock;
} }
@Override @Override

Datei anzeigen

@ -20,8 +20,8 @@
package com.sk89q.worldedit.forge; package com.sk89q.worldedit.forge;
import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.ServerInterface;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.AbstractPlatform;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.extension.platform.MultiUserPlatform; import com.sk89q.worldedit.extension.platform.MultiUserPlatform;
@ -51,17 +51,15 @@ import java.util.EnumMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
class ForgePlatform extends ServerInterface implements MultiUserPlatform { class ForgePlatform extends AbstractPlatform implements MultiUserPlatform {
private final ForgeWorldEdit mod; private final ForgeWorldEdit mod;
private final MinecraftServer server; private final MinecraftServer server;
private final ForgeBiomeRegistry biomes;
private boolean hookingEvents = false; private boolean hookingEvents = false;
ForgePlatform(ForgeWorldEdit mod) { ForgePlatform(ForgeWorldEdit mod) {
this.mod = mod; this.mod = mod;
this.server = FMLCommonHandler.instance().getMinecraftServerInstance(); this.server = FMLCommonHandler.instance().getMinecraftServerInstance();
this.biomes = new ForgeBiomeRegistry();
} }
boolean isHookingEvents() { boolean isHookingEvents() {
@ -71,16 +69,17 @@ class ForgePlatform extends ServerInterface implements MultiUserPlatform {
@Override @Override
public int resolveItem(String name) { public int resolveItem(String name) {
if (name == null) return 0; if (name == null) return 0;
for (Item item : Item.itemsList) { for (Object itemObj : Item.itemRegistry) {
Item item = (Item) itemObj;
if (item == null) continue; if (item == null) continue;
if (item.getUnlocalizedName() == null) continue; if (item.getUnlocalizedName() == null) continue;
if (item.getUnlocalizedName().startsWith("item.")) { if (item.getUnlocalizedName().startsWith("item.")) {
if (item.getUnlocalizedName().equalsIgnoreCase("item." + name)) return item.itemID; if (item.getUnlocalizedName().equalsIgnoreCase("item." + name)) return Item.getIdFromItem(item);
} }
if (item.getUnlocalizedName().startsWith("tile.")) { if (item.getUnlocalizedName().startsWith("tile.")) {
if (item.getUnlocalizedName().equalsIgnoreCase("tile." + name)) return item.itemID; if (item.getUnlocalizedName().equalsIgnoreCase("tile." + name)) return Item.getIdFromItem(item);
} }
if (item.getUnlocalizedName().equalsIgnoreCase(name)) return item.itemID; if (item.getUnlocalizedName().equalsIgnoreCase(name)) return Item.getIdFromItem(item);
} }
return 0; return 0;
} }
@ -115,7 +114,7 @@ class ForgePlatform extends ServerInterface implements MultiUserPlatform {
if (player instanceof ForgePlayer) { if (player instanceof ForgePlayer) {
return player; return player;
} else { } else {
EntityPlayerMP entity = server.getConfigurationManager().getPlayerForUsername(player.getName()); EntityPlayerMP entity = server.getConfigurationManager().func_152612_a(player.getName());
return entity != null ? new ForgePlayer(entity) : null; return entity != null ? new ForgePlayer(entity) : null;
} }
} }
@ -143,7 +142,6 @@ class ForgePlatform extends ServerInterface implements MultiUserPlatform {
for (final CommandMapping command : dispatcher.getCommands()) { for (final CommandMapping command : dispatcher.getCommands()) {
final Description description = command.getDescription(); final Description description = command.getDescription();
mcMan.registerCommand(new CommandBase() { mcMan.registerCommand(new CommandBase() {
@Override @Override
public String getCommandName() { public String getCommandName() {
@ -220,7 +218,7 @@ class ForgePlatform extends ServerInterface implements MultiUserPlatform {
List<Actor> users = new ArrayList<Actor>(); List<Actor> users = new ArrayList<Actor>();
ServerConfigurationManager scm = server.getConfigurationManager(); ServerConfigurationManager scm = server.getConfigurationManager();
for (String name : scm.getAllUsernames()) { for (String name : scm.getAllUsernames()) {
EntityPlayerMP entity = scm.getPlayerForUsername(name); EntityPlayerMP entity = scm.func_152612_a(name);
if (entity != null) { if (entity != null) {
users.add(new ForgePlayer(entity)); users.add(new ForgePlayer(entity));
} }

Datei anzeigen

@ -29,12 +29,15 @@ import com.sk89q.worldedit.internal.LocalWorldAdapter;
import com.sk89q.worldedit.internal.cui.CUIEvent; import com.sk89q.worldedit.internal.cui.CUIEvent;
import com.sk89q.worldedit.session.SessionKey; import com.sk89q.worldedit.session.SessionKey;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.network.packet.Packet250CustomPayload; import net.minecraft.network.play.server.S3FPacketCustomPayload;
import net.minecraft.util.ChatMessageComponent; import net.minecraft.util.ChatComponentText;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.UUID; import java.util.UUID;
public class ForgePlayer extends AbstractPlayerActor { public class ForgePlayer extends AbstractPlayerActor {
@ -54,12 +57,12 @@ public class ForgePlayer extends AbstractPlayerActor {
@Override @Override
public int getItemInHand() { public int getItemInHand() {
ItemStack is = this.player.getCurrentEquippedItem(); ItemStack is = this.player.getCurrentEquippedItem();
return is == null ? 0 : is.itemID; return is == null ? 0 : Item.getIdFromItem(is.getItem());
} }
@Override @Override
public String getName() { public String getName() {
return this.player.username; return this.player.getCommandSenderName();
} }
@Override @Override
@ -99,7 +102,7 @@ public class ForgePlayer extends AbstractPlayerActor {
@Override @Override
public void giveItem(int type, int amt) { public void giveItem(int type, int amt) {
this.player.inventory.addItemStackToInventory(new ItemStack(type, amt, 0)); this.player.inventory.addItemStackToInventory(new ItemStack(Item.getItemById(type), amt, 0));
} }
@Override @Override
@ -109,35 +112,35 @@ public class ForgePlayer extends AbstractPlayerActor {
if (params.length > 0) { if (params.length > 0) {
send = send + "|" + StringUtil.joinString(params, "|"); send = send + "|" + StringUtil.joinString(params, "|");
} }
Packet250CustomPayload packet = new Packet250CustomPayload(ForgeWorldEdit.CUI_PLUGIN_CHANNEL, send.getBytes(WECUIPacketHandler.UTF_8_CHARSET)); S3FPacketCustomPayload packet = new S3FPacketCustomPayload(ForgeWorldEdit.CUI_PLUGIN_CHANNEL, send.getBytes(WECUIPacketHandler.UTF_8_CHARSET));
this.player.playerNetServerHandler.sendPacketToPlayer(packet); this.player.playerNetServerHandler.sendPacket(packet);
} }
@Override @Override
public void printRaw(String msg) { public void printRaw(String msg) {
for (String part : msg.split("\n")) { for (String part : msg.split("\n")) {
this.player.sendChatToPlayer(ChatMessageComponent.createFromText(part)); this.player.addChatMessage(new ChatComponentText(part));
} }
} }
@Override @Override
public void printDebug(String msg) { public void printDebug(String msg) {
for (String part : msg.split("\n")) { for (String part : msg.split("\n")) {
this.player.sendChatToPlayer(ChatMessageComponent.createFromText("\u00a77" + part)); this.player.addChatMessage(new ChatComponentText("\u00a77" + part));
} }
} }
@Override @Override
public void print(String msg) { public void print(String msg) {
for (String part : msg.split("\n")) { for (String part : msg.split("\n")) {
this.player.sendChatToPlayer(ChatMessageComponent.createFromText("\u00a7d" + part)); this.player.addChatMessage(new ChatComponentText("\u00a7d" + part));
} }
} }
@Override @Override
public void printError(String msg) { public void printError(String msg) {
for (String part : msg.split("\n")) { for (String part : msg.split("\n")) {
this.player.sendChatToPlayer(ChatMessageComponent.createFromText("\u00a7c" + part)); this.player.addChatMessage(new ChatComponentText("\u00a7c" + part));
} }
} }
@ -169,7 +172,7 @@ public class ForgePlayer extends AbstractPlayerActor {
@Override @Override
public SessionKey getSessionKey() { public SessionKey getSessionKey() {
return new SessionKeyImpl(player.getUniqueID(), player.username); return new SessionKeyImpl(player.getUniqueID(), player.getCommandSenderName());
} }
private static class SessionKeyImpl implements SessionKey { private static class SessionKeyImpl implements SessionKey {

Datei anzeigen

@ -22,6 +22,7 @@ package com.sk89q.worldedit.forge;
import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.blocks.BaseItemStack;
import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLCommonHandler;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import java.util.Map; import java.util.Map;
@ -33,11 +34,11 @@ public final class ForgeUtil {
public static boolean hasPermission(EntityPlayerMP player, String perm) { public static boolean hasPermission(EntityPlayerMP player, String perm) {
// TODO fix WEPIF // TODO fix WEPIF
return FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().isPlayerOpped(player.username); return FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().func_152596_g(player.getGameProfile());
} }
public static ItemStack toForgeItemStack(BaseItemStack item) { public static ItemStack toForgeItemStack(BaseItemStack item) {
ItemStack ret = new ItemStack(item.getType(), item.getAmount(), item.getData()); ItemStack ret = new ItemStack(Item.getItemById(item.getType()), item.getAmount(), item.getData());
for (Map.Entry<Integer, Integer> entry : item.getEnchantments().entrySet()) { for (Map.Entry<Integer, Integer> entry : item.getEnchantments().entrySet()) {
ret.addEnchantment(net.minecraft.enchantment.Enchantment.enchantmentsList[((Integer) entry.getKey())], (Integer) entry.getValue()); ret.addEnchantment(net.minecraft.enchantment.Enchantment.enchantmentsList[((Integer) entry.getKey())], (Integer) entry.getValue());
} }

Datei anzeigen

@ -129,10 +129,10 @@ public class ForgeWorld extends AbstractWorld {
int previousId = 0; int previousId = 0;
if (notifyAndLight) { if (notifyAndLight) {
previousId = chunk.getBlockID(x & 15, y, z & 15); previousId = Block.getIdFromBlock(chunk.getBlock(x & 15, y, z & 15));
} }
boolean successful = chunk.setBlockIDWithMetadata(x & 15, y, z & 15, block.getId(), block.getData()); boolean successful = chunk.func_150807_a(x & 15, y, z & 15, Block.getBlockById(block.getId()), block.getData());
// Create the TileEntity // Create the TileEntity
if (successful) { if (successful) {
@ -145,13 +145,13 @@ public class ForgeWorld extends AbstractWorld {
} }
if (notifyAndLight) { if (notifyAndLight) {
world.updateAllLightTypes(x, y, z); world.func_147451_t(x, y, z);
world.markBlockForUpdate(x, y, z); world.markBlockForUpdate(x, y, z);
world.notifyBlockChange(x, y, z, previousId); world.notifyBlockChange(x, y, z, Block.getBlockById(previousId));
Block mcBlock = Block.blocksList[block.getId()]; Block mcBlock = Block.getBlockById(previousId);
if (mcBlock != null && mcBlock.hasComparatorInputOverride()) { if (mcBlock != null && mcBlock.hasComparatorInputOverride()) {
world.func_96440_m(x, y, z, block.getId()); world.func_147453_f(x, y, z, Block.getBlockById(block.getId()));
} }
} }
@ -167,7 +167,7 @@ public class ForgeWorld extends AbstractWorld {
@Override @Override
public boolean clearContainerBlockContents(Vector position) { public boolean clearContainerBlockContents(Vector position) {
checkNotNull(position); checkNotNull(position);
TileEntity tile = getWorld().getBlockTileEntity(position.getBlockX(), position.getBlockY(), position.getBlockZ()); TileEntity tile = getWorld().getTileEntity(position.getBlockX(), position.getBlockY(), position.getBlockZ());
if ((tile instanceof IInventory)) { if ((tile instanceof IInventory)) {
IInventory inv = (IInventory) tile; IInventory inv = (IInventory) tile;
int size = inv.getSizeInventory(); int size = inv.getSizeInventory();
@ -322,15 +322,15 @@ public class ForgeWorld extends AbstractWorld {
@Override @Override
public boolean isValidBlockType(int id) { public boolean isValidBlockType(int id) {
return (id == 0) || (net.minecraft.block.Block.blocksList[id] != null); return (id == 0) || (net.minecraft.block.Block.getBlockById(id) != null);
} }
@Override @Override
public BaseBlock getBlock(Vector position) { public BaseBlock getBlock(Vector position) {
World world = getWorld(); World world = getWorld();
int id = world.getBlockId(position.getBlockX(), position.getBlockY(), position.getBlockZ()); int id = Block.getIdFromBlock(world.getBlock(position.getBlockX(), position.getBlockY(), position.getBlockZ()));
int data = world.getBlockMetadata(position.getBlockX(), position.getBlockY(), position.getBlockZ()); int data = world.getBlockMetadata(position.getBlockX(), position.getBlockY(), position.getBlockZ());
TileEntity tile = getWorld().getBlockTileEntity(position.getBlockX(), position.getBlockY(), position.getBlockZ()); TileEntity tile = getWorld().getTileEntity(position.getBlockX(), position.getBlockY(), position.getBlockZ());
if (tile != null) { if (tile != null) {
return new TileEntityBaseBlock(id, data, tile); return new TileEntityBaseBlock(id, data, tile);
@ -342,7 +342,7 @@ public class ForgeWorld extends AbstractWorld {
@Override @Override
public BaseBlock getLazyBlock(Vector position) { public BaseBlock getLazyBlock(Vector position) {
World world = getWorld(); World world = getWorld();
int id = world.getBlockId(position.getBlockX(), position.getBlockY(), position.getBlockZ()); int id = Block.getIdFromBlock(world.getBlock(position.getBlockX(), position.getBlockY(), position.getBlockZ()));
int data = world.getBlockMetadata(position.getBlockX(), position.getBlockY(), position.getBlockZ()); int data = world.getBlockMetadata(position.getBlockX(), position.getBlockY(), position.getBlockZ());
return new LazyBlock(id, data, this, position); return new LazyBlock(id, data, this, position);
} }

Datei anzeigen

@ -28,7 +28,8 @@ import com.sk89q.worldedit.WorldVector;
import com.sk89q.worldedit.event.platform.PlatformReadyEvent; import com.sk89q.worldedit.event.platform.PlatformReadyEvent;
import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.internal.LocalWorldAdapter; import com.sk89q.worldedit.internal.LocalWorldAdapter;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.Mod.Instance;
@ -38,15 +39,12 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerAboutToStartEvent; import cpw.mods.fml.common.event.FMLServerAboutToStartEvent;
import cpw.mods.fml.common.event.FMLServerStartedEvent; import cpw.mods.fml.common.event.FMLServerStartedEvent;
import cpw.mods.fml.common.event.FMLServerStoppingEvent; import cpw.mods.fml.common.event.FMLServerStoppingEvent;
import cpw.mods.fml.common.network.NetworkMod; import cpw.mods.fml.common.eventhandler.Event.Result;
import cpw.mods.fml.common.registry.TickRegistry; import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.relauncher.Side;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.CommandEvent; import net.minecraftforge.event.CommandEvent;
import net.minecraftforge.event.Event.Result;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -54,8 +52,8 @@ import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.logging.Level; import org.apache.logging.log4j.Level;
import java.util.logging.Logger; import org.apache.logging.log4j.Logger;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static net.minecraftforge.event.entity.player.PlayerInteractEvent.Action; import static net.minecraftforge.event.entity.player.PlayerInteractEvent.Action;
@ -64,10 +62,9 @@ import static net.minecraftforge.event.entity.player.PlayerInteractEvent.Action;
* The Forge implementation of WorldEdit. * The Forge implementation of WorldEdit.
*/ */
@Mod(modid = "WorldEdit", name = "WorldEdit", version = "%VERSION%") @Mod(modid = "WorldEdit", name = "WorldEdit", version = "%VERSION%")
@NetworkMod(channels="WECUI", packetHandler=WECUIPacketHandler.class)
public class ForgeWorldEdit { public class ForgeWorldEdit {
private static final Logger logger = Logger.getLogger(ForgeWorldEdit.class.getCanonicalName()); public static Logger logger;
public static final String CUI_PLUGIN_CHANNEL = "WECUI"; public static final String CUI_PLUGIN_CHANNEL = "WECUI";
@Instance("WorldEdit") @Instance("WorldEdit")
@ -79,9 +76,7 @@ public class ForgeWorldEdit {
@EventHandler @EventHandler
public void preInit(FMLPreInitializationEvent event) { public void preInit(FMLPreInitializationEvent event) {
// Redirect all loggers under com.sk89q to FML's logger logger = event.getModLog();
Logger.getLogger("com.sk89q").setParent(FMLLog.getLogger());
// Setup working directory // Setup working directory
workingDir = new File(event.getModConfigurationDirectory() + File.separator + "worldedit"); workingDir = new File(event.getModConfigurationDirectory() + File.separator + "worldedit");
workingDir.mkdir(); workingDir.mkdir();
@ -92,7 +87,7 @@ public class ForgeWorldEdit {
config = new ForgeConfiguration(this); config = new ForgeConfiguration(this);
config.load(); config.load();
TickRegistry.registerTickHandler(ThreadSafeCache.getInstance(), Side.SERVER); FMLCommonHandler.instance().bus().register(ThreadSafeCache.getInstance());
} }
@EventHandler @EventHandler
@ -108,7 +103,7 @@ public class ForgeWorldEdit {
@EventHandler @EventHandler
public void serverAboutToStart(FMLServerAboutToStartEvent event) { public void serverAboutToStart(FMLServerAboutToStartEvent event) {
if (this.platform != null) { if (this.platform != null) {
logger.warning("FMLServerStartingEvent occurred when FMLServerStoppingEvent hasn't"); logger.warn("FMLServerStartingEvent occurred when FMLServerStoppingEvent hasn't");
WorldEdit.getInstance().getPlatformManager().unregister(platform); WorldEdit.getInstance().getPlatformManager().unregister(platform);
} }
@ -129,7 +124,7 @@ public class ForgeWorldEdit {
WorldEdit.getInstance().getEventBus().post(new PlatformReadyEvent()); WorldEdit.getInstance().getEventBus().post(new PlatformReadyEvent());
} }
@ForgeSubscribe @SubscribeEvent
public void onCommandEvent(CommandEvent event) { public void onCommandEvent(CommandEvent event) {
if ((event.sender instanceof EntityPlayerMP)) { if ((event.sender instanceof EntityPlayerMP)) {
if (((EntityPlayerMP) event.sender).worldObj.isRemote) return; if (((EntityPlayerMP) event.sender).worldObj.isRemote) return;
@ -142,7 +137,7 @@ public class ForgeWorldEdit {
} }
} }
@ForgeSubscribe @SubscribeEvent
public void onPlayerInteract(PlayerInteractEvent event) { public void onPlayerInteract(PlayerInteractEvent event) {
if (platform == null) { if (platform == null) {
return; return;
@ -278,7 +273,7 @@ public class ForgeWorldEdit {
ByteStreams.copy(inputStream, outputStream); ByteStreams.copy(inputStream, outputStream);
logger.info("Default configuration file written: " + name); logger.info("Default configuration file written: " + name);
} catch (IOException e) { } catch (IOException e) {
logger.log(Level.WARNING, "Failed to extract defaults", e); logger.log(Level.WARN, "Failed to extract defaults", e);
} finally { } finally {
try { try {
closer.close(); closer.close();

Datei anzeigen

@ -76,11 +76,11 @@ final class NBTConverter {
public static NBTTagIntArray toNative(IntArrayTag tag) { public static NBTTagIntArray toNative(IntArrayTag tag) {
int[] value = tag.getValue(); int[] value = tag.getValue();
return new NBTTagIntArray(tag.getName(), Arrays.copyOf(value, value.length)); return new NBTTagIntArray(Arrays.copyOf(value, value.length));
} }
public static NBTTagList toNative(ListTag tag) { public static NBTTagList toNative(ListTag tag) {
NBTTagList list = new NBTTagList(tag.getName()); NBTTagList list = new NBTTagList();
for (Tag child : tag.getValue()) { for (Tag child : tag.getValue()) {
if (child instanceof EndTag) { if (child instanceof EndTag) {
continue; continue;
@ -95,28 +95,28 @@ final class NBTConverter {
} }
public static NBTTagLong toNative(LongTag tag) { public static NBTTagLong toNative(LongTag tag) {
return new NBTTagLong(tag.getName(), tag.getValue()); return new NBTTagLong(tag.getValue());
} }
public static NBTTagString toNative(StringTag tag) { public static NBTTagString toNative(StringTag tag) {
return new NBTTagString(tag.getName(), tag.getValue()); return new NBTTagString(tag.getValue());
} }
public static NBTTagInt toNative(IntTag tag) { public static NBTTagInt toNative(IntTag tag) {
return new NBTTagInt(tag.getName(), tag.getValue()); return new NBTTagInt(tag.getValue());
} }
public static NBTTagByte toNative(ByteTag tag) { public static NBTTagByte toNative(ByteTag tag) {
return new NBTTagByte(tag.getName(), tag.getValue()); return new NBTTagByte(tag.getValue());
} }
public static NBTTagByteArray toNative(ByteArrayTag tag) { public static NBTTagByteArray toNative(ByteArrayTag tag) {
byte[] value = tag.getValue(); byte[] value = tag.getValue();
return new NBTTagByteArray(tag.getName(), Arrays.copyOf(value, value.length)); return new NBTTagByteArray(Arrays.copyOf(value, value.length));
} }
public static NBTTagCompound toNative(CompoundTag tag) { public static NBTTagCompound toNative(CompoundTag tag) {
NBTTagCompound compound = new NBTTagCompound(tag.getName()); NBTTagCompound compound = new NBTTagCompound();
for (Entry<String, Tag> child : tag.getValue().entrySet()) { for (Entry<String, Tag> child : tag.getValue().entrySet()) {
compound.setTag(child.getKey(), toNative(child.getValue())); compound.setTag(child.getKey(), toNative(child.getValue()));
} }
@ -124,15 +124,15 @@ final class NBTConverter {
} }
public static NBTTagFloat toNative(FloatTag tag) { public static NBTTagFloat toNative(FloatTag tag) {
return new NBTTagFloat(tag.getName(), tag.getValue()); return new NBTTagFloat(tag.getValue());
} }
public static NBTTagShort toNative(ShortTag tag) { public static NBTTagShort toNative(ShortTag tag) {
return new NBTTagShort(tag.getName(), tag.getValue()); return new NBTTagShort(tag.getValue());
} }
public static NBTTagDouble toNative(DoubleTag tag) { public static NBTTagDouble toNative(DoubleTag tag) {
return new NBTTagDouble(tag.getName(), tag.getValue()); return new NBTTagDouble(tag.getValue());
} }
public static Tag fromNative(NBTBase other) { public static Tag fromNative(NBTBase other) {
@ -177,22 +177,20 @@ final class NBTConverter {
} }
public static IntArrayTag fromNative(NBTTagIntArray other) { public static IntArrayTag fromNative(NBTTagIntArray other) {
int[] value = other.intArray; int[] value = other.func_150302_c();
return new IntArrayTag(other.getName(), Arrays.copyOf(value, value.length)); return new IntArrayTag(Arrays.copyOf(value, value.length));
} }
public static ListTag fromNative(NBTTagList other) { public static ListTag fromNative(NBTTagList other) {
other = (NBTTagList) other.copy();
List<Tag> list = new ArrayList<Tag>(); List<Tag> list = new ArrayList<Tag>();
Class<? extends Tag> listClass = StringTag.class; Class<? extends Tag> listClass = StringTag.class;
for (int i = 0; i < other.tagCount(); i++) { for (int i = 0; i < other.tagCount(); i++) {
if (other.tagAt(i) instanceof NBTTagEnd) { Tag child = fromNative(other.removeTag(0));
continue;
}
Tag child = fromNative(other.tagAt(i));
list.add(child); list.add(child);
listClass = child.getClass(); listClass = child.getClass();
} }
return new ListTag(other.getName(), listClass, list); return new ListTag(listClass, list);
} }
public static EndTag fromNative(NBTTagEnd other) { public static EndTag fromNative(NBTTagEnd other) {
@ -200,45 +198,45 @@ final class NBTConverter {
} }
public static LongTag fromNative(NBTTagLong other) { public static LongTag fromNative(NBTTagLong other) {
return new LongTag(other.getName(), other.data); return new LongTag(other.func_150291_c());
} }
public static StringTag fromNative(NBTTagString other) { public static StringTag fromNative(NBTTagString other) {
return new StringTag(other.getName(), other.data); return new StringTag(other.func_150285_a_());
} }
public static IntTag fromNative(NBTTagInt other) { public static IntTag fromNative(NBTTagInt other) {
return new IntTag(other.getName(), other.data); return new IntTag(other.func_150287_d());
} }
public static ByteTag fromNative(NBTTagByte other) { public static ByteTag fromNative(NBTTagByte other) {
return new ByteTag(other.getName(), other.data); return new ByteTag(other.func_150290_f());
} }
public static ByteArrayTag fromNative(NBTTagByteArray other) { public static ByteArrayTag fromNative(NBTTagByteArray other) {
byte[] value = other.byteArray; byte[] value = other.func_150292_c();
return new ByteArrayTag(other.getName(), Arrays.copyOf(value, value.length)); return new ByteArrayTag(Arrays.copyOf(value, value.length));
} }
public static CompoundTag fromNative(NBTTagCompound other) { public static CompoundTag fromNative(NBTTagCompound other) {
@SuppressWarnings("unchecked") Collection<NBTBase> tags = other.getTags(); @SuppressWarnings("unchecked") Collection<String> tags = other.func_150296_c();
Map<String, Tag> map = new HashMap<String, Tag>(); Map<String, Tag> map = new HashMap<String, Tag>();
for (NBTBase tag : tags) { for (String tagName : tags) {
map.put(tag.getName(), fromNative(tag)); map.put(tagName, fromNative(other.getTag(tagName)));
} }
return new CompoundTag(other.getName(), map); return new CompoundTag(map);
} }
public static FloatTag fromNative(NBTTagFloat other) { public static FloatTag fromNative(NBTTagFloat other) {
return new FloatTag(other.getName(), other.data); return new FloatTag(other.func_150288_h());
} }
public static ShortTag fromNative(NBTTagShort other) { public static ShortTag fromNative(NBTTagShort other) {
return new ShortTag(other.getName(), other.data); return new ShortTag(other.func_150289_e());
} }
public static DoubleTag fromNative(NBTTagDouble other) { public static DoubleTag fromNative(NBTTagDouble other) {
return new DoubleTag(other.getName(), other.data); return new DoubleTag(other.func_150286_g());
} }
} }

Datei anzeigen

@ -20,12 +20,11 @@
package com.sk89q.worldedit.forge; package com.sk89q.worldedit.forge;
import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.ITickHandler; import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.TickType; import cpw.mods.fml.common.gameevent.TickEvent;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import java.util.Collections; import java.util.Collections;
import java.util.EnumSet;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
@ -34,7 +33,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
/** /**
* Caches data that cannot be accessed from another thread safely. * Caches data that cannot be accessed from another thread safely.
*/ */
class ThreadSafeCache implements ITickHandler { public class ThreadSafeCache {
private static final long REFRESH_DELAY = 1000 * 30; private static final long REFRESH_DELAY = 1000 * 30;
private static final ThreadSafeCache INSTANCE = new ThreadSafeCache(); private static final ThreadSafeCache INSTANCE = new ThreadSafeCache();
@ -50,13 +49,16 @@ class ThreadSafeCache implements ITickHandler {
return onlineIds; return onlineIds;
} }
@Override @SubscribeEvent
public void tickStart(EnumSet<TickType> type, Object... tickData) { public void tickStart(TickEvent event) {
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
if (now - lastRefresh > REFRESH_DELAY) { if (now - lastRefresh > REFRESH_DELAY) {
Set<UUID> onlineIds = new HashSet<UUID>(); Set<UUID> onlineIds = new HashSet<UUID>();
if (FMLCommonHandler.instance().getMinecraftServerInstance() == null) {
return;
}
for (Object object : FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().playerEntityList) { for (Object object : FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().playerEntityList) {
if (object != null) { if (object != null) {
EntityPlayerMP player = (EntityPlayerMP) object; EntityPlayerMP player = (EntityPlayerMP) object;
@ -70,20 +72,6 @@ class ThreadSafeCache implements ITickHandler {
} }
} }
@Override
public void tickEnd(EnumSet<TickType> type, Object... tickData) {
}
@Override
public EnumSet<TickType> ticks() {
return EnumSet.of(TickType.SERVER);
}
@Override
public String getLabel() {
return "WorldEdit Cache";
}
public static ThreadSafeCache getInstance() { public static ThreadSafeCache getInstance() {
return INSTANCE; return INSTANCE;
} }

Datei anzeigen

@ -49,9 +49,9 @@ final class TileEntityUtils {
checkNotNull(tag); checkNotNull(tag);
checkNotNull(position); checkNotNull(position);
tag.setTag("x", new NBTTagInt("x", position.getBlockX())); tag.setTag("x", new NBTTagInt(position.getBlockX()));
tag.setTag("y", new NBTTagInt("y", position.getBlockY())); tag.setTag("y", new NBTTagInt(position.getBlockY()));
tag.setTag("z", new NBTTagInt("z", position.getBlockZ())); tag.setTag("z", new NBTTagInt(position.getBlockZ()));
return tag; return tag;
} }
@ -81,7 +81,7 @@ final class TileEntityUtils {
tileEntity.readFromNBT(tag); tileEntity.readFromNBT(tag);
} }
world.setBlockTileEntity(position.getBlockX(), position.getBlockY(), position.getBlockZ(), tileEntity); world.setTileEntity(position.getBlockX(), position.getBlockY(), position.getBlockZ(), tileEntity);
} }
/** /**
@ -97,7 +97,7 @@ final class TileEntityUtils {
updateForSet(tag, position); updateForSet(tag, position);
TileEntity tileEntity = TileEntity.createAndLoadEntity(tag); TileEntity tileEntity = TileEntity.createAndLoadEntity(tag);
if (tileEntity != null) { if (tileEntity != null) {
world.setBlockTileEntity(position.getBlockX(), position.getBlockY(), position.getBlockZ(), tileEntity); world.setTileEntity(position.getBlockX(), position.getBlockY(), position.getBlockZ(), tileEntity);
} }
} }
} }

Datei anzeigen

@ -22,28 +22,42 @@ package com.sk89q.worldedit.forge;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.INetworkManager; import net.minecraft.network.NetHandlerPlayServer;
import net.minecraft.network.packet.Packet250CustomPayload; import net.minecraft.network.play.client.C17PacketCustomPayload;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import cpw.mods.fml.common.network.IPacketHandler; import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.network.Player; import cpw.mods.fml.common.network.FMLEventChannel;
import cpw.mods.fml.common.network.FMLNetworkEvent.ServerCustomPacketEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
public class WECUIPacketHandler implements IPacketHandler { public class WECUIPacketHandler {
public static final Charset UTF_8_CHARSET = Charset.forName("UTF-8"); public static final Charset UTF_8_CHARSET = Charset.forName("UTF-8");
private static FMLEventChannel WECUI_CHANNEL;
@Override public static void init() {
public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) { WECUI_CHANNEL = NetworkRegistry.INSTANCE.newEventDrivenChannel(ForgeWorldEdit.CUI_PLUGIN_CHANNEL);
if (player instanceof EntityPlayerMP) { WECUI_CHANNEL.register(new WECUIPacketHandler());
}
@SubscribeEvent
public void onPacketData(ServerCustomPacketEvent event) {
C17PacketCustomPayload rawPacket = (C17PacketCustomPayload) event.packet.toC17Packet();
if (event.packet.channel().equals(ForgeWorldEdit.CUI_PLUGIN_CHANNEL)) {
EntityPlayerMP player = getPlayerFromEvent(event);
LocalSession session = ForgeWorldEdit.inst.getSession((EntityPlayerMP) player); LocalSession session = ForgeWorldEdit.inst.getSession((EntityPlayerMP) player);
if (session.hasCUISupport()) { if (session.hasCUISupport()) {
return; return;
} }
String text = new String(packet.data, UTF_8_CHARSET); String text = new String(rawPacket.func_149558_e(), UTF_8_CHARSET);
session.handleCUIInitializationMessage(text); session.handleCUIInitializationMessage(text);
} }
} }
private static EntityPlayerMP getPlayerFromEvent(ServerCustomPacketEvent event) {
return ((NetHandlerPlayServer) event.handler).playerEntity;
}
} }

Datei anzeigen

@ -1,6 +1,4 @@
{ [{
"modinfoversion": 2,
"modlist": [{
"modid": "WorldEdit", "modid": "WorldEdit",
"name": "WorldEdit", "name": "WorldEdit",
"description": "WorldEdit is an easy-to-use in-game world editor for Minecraft, supporting both single player and multiplayer.", "description": "WorldEdit is an easy-to-use in-game world editor for Minecraft, supporting both single player and multiplayer.",
@ -19,5 +17,4 @@
"Forge@[${forgeVersion},)" "Forge@[${forgeVersion},)"
], ],
"dependants": [] "dependants": []
}] }]
}

Datei anzeigen

@ -51,6 +51,7 @@
<allow pkg="cpw"/> <allow pkg="cpw"/>
<allow pkg="net.minecraft"/> <allow pkg="net.minecraft"/>
<allow pkg="net.minecraftforge"/> <allow pkg="net.minecraftforge"/>
<allow pkg="org.apache.logging.log4j"/>
</subpackage> </subpackage>
</subpackage> </subpackage>
</import-control> </import-control>