Merge remote-tracking branch 'origin/master' into feature/sponge-new

This commit is contained in:
Wyatt Childers 2016-05-18 19:49:16 -04:00
commit 7dc9a9aece
35 changed files with 11685 additions and 3515 deletions

View File

@ -58,11 +58,11 @@ subprojects {
apply plugin: 'com.jfrog.artifactory-upload'
group = 'com.sk89q.worldedit'
version = '6.1.1-SNAPSHOT'
version = '6.1.3-SNAPSHOT'
ext.internalVersion = version + ";" + gitCommitHash
sourceCompatibility = 1.6
targetCompatibility = 1.6
sourceCompatibility = 1.7
targetCompatibility = 1.7
checkstyle.configFile = new File(rootProject.projectDir, "config/checkstyle/checkstyle.xml")

Binary file not shown.

View File

@ -1,6 +1,6 @@
#Mon Feb 22 17:40:44 PST 2016
#Thu May 05 15:11:12 PDT 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.11-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-bin.zip

46
gradlew vendored
View File

@ -6,12 +6,30 @@
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
@ -30,6 +48,7 @@ die ( ) {
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
@ -40,26 +59,11 @@ case "`uname`" in
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
@ -85,7 +89,7 @@ location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then

6
gradlew.bat vendored
View File

@ -8,14 +8,14 @@
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

View File

@ -8,7 +8,7 @@ repositories {
dependencies {
compile project(':worldedit-core')
compile 'com.sk89q:dummypermscompat:1.8'
compile 'org.bukkit:bukkit:1.8.8-R0.1-SNAPSHOT' // zzz
compile 'org.bukkit:bukkit:1.9.4-R0.1-SNAPSHOT' // zzz
testCompile 'org.mockito:mockito-core:1.9.0-rc1'
}

View File

@ -37,6 +37,7 @@ import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerGameModeChangeEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.EquipmentSlot;
/**
* Handles all events thrown in relation to a Player
@ -116,6 +117,15 @@ public class WorldEditListener implements Listener {
return;
}
try {
if (event.getHand() == EquipmentSlot.OFF_HAND) {
return; // TODO api needs to be able to get either hand depending on event
// for now just ignore all off hand interacts
}
} catch (NoSuchMethodError ignored) {
} catch (NoSuchFieldError ignored) {
}
final LocalPlayer player = plugin.wrapPlayer(event.getPlayer());
final World world = player.getWorld();
final WorldEdit we = plugin.getWorldEdit();

View File

@ -48,6 +48,8 @@ import com.sk89q.worldedit.regions.CylinderRegion;
import com.sk89q.worldedit.regions.Polygonal2DRegion;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.regions.RegionSelector;
import com.sk89q.worldedit.util.Java8Detector;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -117,6 +119,9 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter {
WorldEdit.getInstance().getEventBus().post(new PlatformReadyEvent());
loadAdapter(); // Need an adapter to work with special blocks with NBT data
// Check Java version
Java8Detector.notifyIfNot8();
}
private void loadConfig() {

View File

@ -22,6 +22,7 @@ package com.sk89q.worldedit.blocks;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.StringTag;
import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.util.gson.GsonUtil;
import java.util.HashMap;
import java.util.Map;
@ -33,6 +34,8 @@ public class SignBlock extends BaseBlock implements TileEntityBlock {
private String[] text;
private static String EMPTY = "{\"text\":\"\"}";
/**
* Construct the sign without text.
*
@ -41,7 +44,7 @@ public class SignBlock extends BaseBlock implements TileEntityBlock {
*/
public SignBlock(int type, int data) {
super(type, data);
this.text = new String[] { "", "", "", "" };
this.text = new String[] { EMPTY, EMPTY, EMPTY, EMPTY };
}
/**
@ -54,7 +57,15 @@ public class SignBlock extends BaseBlock implements TileEntityBlock {
public SignBlock(int type, int data, String[] text) {
super(type, data);
if (text == null) {
this.text = new String[] { "", "", "", "" };
this.text = new String[] { EMPTY, EMPTY, EMPTY, EMPTY };
return;
}
for (int i = 0; i < text.length; i++) {
if (text[i].isEmpty()) {
text[i] = EMPTY;
} else {
text[i] = "{\"text\":\"" + GsonUtil.stringValue(text[i]) + "\"}";
}
}
this.text = text;
}
@ -110,7 +121,7 @@ public class SignBlock extends BaseBlock implements TileEntityBlock {
Tag t;
text = new String[] { "", "", "", "" };
text = new String[] { EMPTY, EMPTY, EMPTY, EMPTY };
t = values.get("id");
if (!(t instanceof StringTag) || !((StringTag) t).getValue().equals("Sign")) {

View File

@ -23,6 +23,7 @@ import com.sk89q.util.StringUtil;
import com.sk89q.worldedit.PlayerDirection;
import javax.annotation.Nullable;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
@ -497,6 +498,11 @@ public enum BlockType {
static {
shouldPlaceFinal.add(BlockID.SIGN_POST);
shouldPlaceFinal.add(BlockID.WOODEN_DOOR);
shouldPlaceFinal.add(BlockID.ACACIA_DOOR);
shouldPlaceFinal.add(BlockID.BIRCH_DOOR);
shouldPlaceFinal.add(BlockID.JUNGLE_DOOR);
shouldPlaceFinal.add(BlockID.DARK_OAK_DOOR);
shouldPlaceFinal.add(BlockID.SPRUCE_DOOR);
shouldPlaceFinal.add(BlockID.WALL_SIGN);
shouldPlaceFinal.add(BlockID.IRON_DOOR);
shouldPlaceFinal.add(BlockID.CACTUS);
@ -920,6 +926,11 @@ public enum BlockType {
isRedstoneBlock.add(BlockID.STONE_BUTTON);
isRedstoneBlock.add(BlockID.REDSTONE_WIRE);
isRedstoneBlock.add(BlockID.WOODEN_DOOR);
isRedstoneBlock.add(BlockID.ACACIA_DOOR);
isRedstoneBlock.add(BlockID.BIRCH_DOOR);
isRedstoneBlock.add(BlockID.JUNGLE_DOOR);
isRedstoneBlock.add(BlockID.DARK_OAK_DOOR);
isRedstoneBlock.add(BlockID.SPRUCE_DOOR);
isRedstoneBlock.add(BlockID.IRON_DOOR);
isRedstoneBlock.add(BlockID.TNT);
isRedstoneBlock.add(BlockID.DISPENSER);
@ -1510,6 +1521,12 @@ public enum BlockType {
addIdentity(BlockID.PACKED_ICE);
addIdentities(BlockID.STAINED_GLASS_PANE, 16);
addIdentities(BlockID.DOUBLE_PLANT, 6);
addIdentities(BlockID.ACACIA_DOOR, 8); // rule 2
addIdentities(BlockID.BIRCH_DOOR, 8); // rule 2
addIdentities(BlockID.JUNGLE_DOOR, 8); // rule 2
addIdentities(BlockID.DARK_OAK_DOOR, 8); // rule 2
addIdentities(BlockID.SPRUCE_DOOR, 8); // rule 2
}
/**

View File

@ -263,7 +263,7 @@ public class SchematicCommands {
File dir = worldEdit.getWorkingDirectoryFile(worldEdit.getConfiguration().saveDir);
List<File> fileList = allFiles(dir);
if (fileList.isEmpty()) {
if (fileList == null || fileList.isEmpty()) {
actor.printError("No schematics found.");
return;
}

View File

@ -395,6 +395,10 @@ public class UtilityCommands {
// there might be a better way to do this but my brain is fried right now
if (args.argsLength() > 0) { // user inputted radius, override the default
radius = args.getInteger(0);
if (radius < -1) {
actor.printError("Use -1 to remove all mobs in loaded chunks");
return;
}
if (config.butcherMaxRadius != -1) { // clamp if there is a max
if (radius == -1) {
radius = config.butcherMaxRadius;

View File

@ -22,11 +22,22 @@ package com.sk89q.worldedit.command.tool;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.blocks.*;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BlockID;
import com.sk89q.worldedit.blocks.BlockType;
import com.sk89q.worldedit.blocks.ClothColor;
import com.sk89q.worldedit.blocks.MobSpawnerBlock;
import com.sk89q.worldedit.blocks.NoteBlock;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.registry.BundledBlockData;
import com.sk89q.worldedit.world.registry.State;
import com.sk89q.worldedit.world.registry.StateValue;
import java.util.Map;
import java.util.Map.Entry;
/**
* Looks up information about a block.
@ -64,6 +75,28 @@ public class QueryTool implements BlockTool {
+ ClothColor.fromID(block.getData()).getName());
}
Map<String, ? extends State> states = BundledBlockData.getInstance().getStatesById(block.getId());
if (states == null || states.isEmpty()) return true;
StringBuilder builder = new StringBuilder();
builder.append("States: ");
boolean first = true;
for (Entry<String, ? extends State> e : states.entrySet()) {
String name = e.getKey();
State state = e.getValue();
if (!first) {
builder.append(", ");
}
first = false;
String valName = "";
for (Entry<String, ? extends StateValue> entry : state.valueMap().entrySet()) {
if (entry.getValue().isSet(block)) {
valName = entry.getKey();
}
}
builder.append("\u00A79").append(name).append(": \u00A7f").append(valName != null ? valName : "set");
}
player.printRaw(builder.toString());
return true;
}

View File

@ -154,6 +154,11 @@ public class MultiStageReorder extends AbstractDelegateExtent implements Reorder
switch (type) {
case BlockID.WOODEN_DOOR:
case BlockID.ACACIA_DOOR:
case BlockID.BIRCH_DOOR:
case BlockID.JUNGLE_DOOR:
case BlockID.DARK_OAK_DOOR:
case BlockID.SPRUCE_DOOR:
case BlockID.IRON_DOOR:
if ((data & 0x8) == 0) {
// Deal with lower door halves being attached to the floor AND the upper half

View File

@ -0,0 +1,46 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.util;
import com.google.common.base.Joiner;
import com.sk89q.worldedit.WorldEdit;
public final class Java8Detector {
public static void notifyIfNot8() {
String[] ver = System.getProperty("java.version").split("\\.");
int major = Integer.parseInt(ver[1]);
if (major <= 7) {
// Implicitly java 7 because we compile against 7, so this won't
// even launch on 6.
WorldEdit.logger.warning(
"WorldEdit has detected you are using Java 7"
+ " (based on detected version "
+ Joiner.on('.').join(ver) + ").");
WorldEdit.logger.warning(
"WorldEdit will stop supporting Java less than version 8 in the future,"
+ " due to Java 7 being EOL since April 2015."
+ " Please update your server to Java 8.");
}
}
private Java8Detector() {
}
}

View File

@ -19,6 +19,7 @@
package com.sk89q.worldedit.util.gson;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.sk89q.worldedit.Vector;
@ -41,4 +42,8 @@ public final class GsonUtil {
return gsonBuilder;
}
private static final Gson gson = new Gson();
public static String stringValue(String s) {
return gson.toJson(s);
}
}

View File

@ -27,6 +27,7 @@ import com.sk89q.worldedit.math.transform.Transform;
import com.sk89q.worldedit.world.registry.BlockRegistry;
import com.sk89q.worldedit.world.registry.LegacyBlockRegistry;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import java.util.HashSet;
@ -35,6 +36,8 @@ import java.util.Set;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
@Ignore("Old BlockData class needs to be updated manually. Current block definitions are in blocks.json, " +
"which is automatically generated and generally accurate.")
public class BlockTransformExtentTest {
private static final Transform ROTATE_90 = new AffineTransform().rotateY(-90);

View File

@ -26,13 +26,13 @@ repositories {
}
}
version = "6.1.1"
ext.forgeVersion = "11.15.1.1760"
version = "6.1.2"
ext.forgeVersion = "12.16.1.1891"
ext.internalVersion = version + ";" + gitCommitHash
minecraft {
version = "1.8.9-${project.forgeVersion}"
mappings = "snapshot_20160111"
version = "1.9-${project.forgeVersion}"
mappings = "snapshot_20160505"
runDir = 'run'
replaceIn "com/sk89q/worldedit/forge/ForgeWorldEdit.java"

View File

@ -25,8 +25,10 @@ import java.util.Arrays;
import java.util.List;
import javax.annotation.Nullable;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommand;
import net.minecraft.command.ICommandSender;
import net.minecraft.server.MinecraftServer;
public class CommandWrapper extends CommandBase {
private CommandMapping command;
@ -46,7 +48,8 @@ public class CommandWrapper extends CommandBase {
}
@Override
public void processCommand(ICommandSender var1, String[] var2) {}
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
}
@Override
public String getCommandUsage(ICommandSender icommandsender) {
@ -59,7 +62,7 @@ public class CommandWrapper extends CommandBase {
}
@Override
public boolean canCommandSenderUseCommand(ICommandSender sender) {
public boolean checkPermission(MinecraftServer server, ICommandSender sender) {
return true;
}

View File

@ -21,8 +21,9 @@ package com.sk89q.worldedit.forge;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.world.World;
import net.minecraft.util.BlockPos;
import net.minecraft.util.Vec3;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
final class ForgeAdapter {
@ -33,7 +34,7 @@ final class ForgeAdapter {
return new ForgeWorld(world);
}
public static Vector adapt(Vec3 vector) {
public static Vector adapt(Vec3d vector) {
return new Vector(vector.xCoord, vector.yCoord, vector.zCoord);
}
@ -41,8 +42,8 @@ final class ForgeAdapter {
return new Vector(pos.getX(), pos.getY(), pos.getZ());
}
public static Vec3 toVec3(Vector vector) {
return new Vec3(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
public static Vec3d toVec3(Vector vector) {
return new Vec3d(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
}
public static BlockPos toBlockPos(Vector vector) {

View File

@ -19,29 +19,20 @@
package com.sk89q.worldedit.forge;
import com.google.common.collect.HashBiMap;
import com.sk89q.worldedit.world.biome.BaseBiome;
import com.sk89q.worldedit.world.biome.BiomeData;
import com.sk89q.worldedit.world.registry.BiomeRegistry;
import net.minecraft.world.biome.BiomeGenBase;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Provides access to biome data in Forge.
*/
class ForgeBiomeRegistry implements BiomeRegistry {
private static Map<Integer, BiomeGenBase> biomes = Collections.emptyMap();
private static Map<Integer, BiomeData> biomeData = Collections.emptyMap();
@Nullable
@Override
public BaseBiome createFromId(int id) {
return new BaseBiome(id);
@ -50,38 +41,15 @@ class ForgeBiomeRegistry implements BiomeRegistry {
@Override
public List<BaseBiome> getBiomes() {
List<BaseBiome> list = new ArrayList<BaseBiome>();
for (int biome : biomes.keySet()) {
list.add(new BaseBiome(biome));
for (BiomeGenBase biome : BiomeGenBase.REGISTRY) {
list.add(new BaseBiome(BiomeGenBase.getIdForBiome(biome)));
}
return list;
}
@Nullable
@Override
public BiomeData getData(BaseBiome biome) {
return biomeData.get(biome.getId());
}
/**
* Populate the internal static list of biomes.
*
* <p>If called repeatedly, the last call will overwrite all previous
* calls.</p>
*/
static void populate() {
Map<Integer, BiomeGenBase> biomes = HashBiMap.create();
Map<Integer, BiomeData> biomeData = new HashMap<Integer, BiomeData>();
for (BiomeGenBase biome : BiomeGenBase.getBiomeGenArray()) {
if ((biome == null) || (biomes.containsValue(biome))) {
continue;
}
biomes.put(biome.biomeID, biome);
biomeData.put(biome.biomeID, new ForgeBiomeData(biome));
}
ForgeBiomeRegistry.biomes = biomes;
ForgeBiomeRegistry.biomeData = biomeData;
return new ForgeBiomeData(BiomeGenBase.getBiome(biome.getId()));
}
/**
@ -101,7 +69,7 @@ class ForgeBiomeRegistry implements BiomeRegistry {
@Override
public String getName() {
return biome.biomeName;
return biome.getBiomeName();
}
}

View File

@ -25,6 +25,7 @@ import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.IMerchant;
import net.minecraft.entity.INpc;
import net.minecraft.entity.IProjectile;
import net.minecraft.entity.item.EntityArmorStand;
import net.minecraft.entity.item.EntityBoat;
import net.minecraft.entity.item.EntityEnderEye;
import net.minecraft.entity.item.EntityFallingBlock;
@ -38,7 +39,6 @@ import net.minecraft.entity.monster.EntityGolem;
import net.minecraft.entity.passive.EntityAmbientCreature;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.passive.EntityTameable;
import net.minecraft.entity.passive.IAnimals;
import net.minecraft.entity.player.EntityPlayer;
import static com.google.common.base.Preconditions.checkNotNull;
@ -139,6 +139,6 @@ public class ForgeEntityType implements EntityType {
@Override
public boolean isArmorStand() {
return false; // TODO re-add when forge version is updated to 1.8: entity instanceof EntityArmorStand;
return entity instanceof EntityArmorStand;
}
}

View File

@ -43,8 +43,8 @@ public interface ForgePermissionsProvider {
public boolean hasPermission(EntityPlayerMP player, String permission) {
ForgeConfiguration configuration = platform.getConfiguration();
return configuration.cheatMode ||
FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().canSendCommands(player.getGameProfile()) ||
(configuration.creativeEnable && player.theItemInWorldManager.getGameType() == GameType.CREATIVE);
FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().canSendCommands(player.getGameProfile()) ||
(configuration.creativeEnable && player.interactionManager.getGameType() == GameType.CREATIVE);
}
@Override

View File

@ -35,7 +35,7 @@ import net.minecraft.entity.EntityList;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.Item;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.management.ServerConfigurationManager;
import net.minecraft.server.management.PlayerList;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.fml.common.FMLCommonHandler;
@ -43,7 +43,6 @@ import net.minecraftforge.fml.common.FMLCommonHandler;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.EnumMap;
import java.util.List;
@ -77,8 +76,7 @@ class ForgePlatform extends AbstractPlatform implements MultiUserPlatform {
}
}
for (Object itemObj : Item.itemRegistry) {
Item item = (Item) itemObj;
for (Item item : Item.REGISTRY) {
if (item == null) continue;
if (item.getUnlocalizedName() == null) continue;
if (item.getUnlocalizedName().startsWith("item.")) {
@ -94,7 +92,7 @@ class ForgePlatform extends AbstractPlatform implements MultiUserPlatform {
@Override
public boolean isValidMobType(String type) {
return EntityList.stringToClassMapping.containsKey(type);
return EntityList.NAME_TO_CLASS.containsKey(type);
}
@Override
@ -109,8 +107,8 @@ class ForgePlatform extends AbstractPlatform implements MultiUserPlatform {
@Override
public List<? extends com.sk89q.worldedit.world.World> getWorlds() {
List<WorldServer> worlds = Arrays.asList(DimensionManager.getWorlds());
List<com.sk89q.worldedit.world.World> ret = new ArrayList<com.sk89q.worldedit.world.World>(worlds.size());
WorldServer[] worlds = DimensionManager.getWorlds();
List<com.sk89q.worldedit.world.World> ret = new ArrayList<com.sk89q.worldedit.world.World>(worlds.length);
for (WorldServer world : worlds) {
ret.add(new ForgeWorld(world));
}
@ -123,7 +121,7 @@ class ForgePlatform extends AbstractPlatform implements MultiUserPlatform {
if (player instanceof ForgePlayer) {
return player;
} else {
EntityPlayerMP entity = server.getConfigurationManager().getPlayerByUsername(player.getName());
EntityPlayerMP entity = server.getPlayerList().getPlayerByUsername(player.getName());
return entity != null ? new ForgePlayer(this, entity) : null;
}
}
@ -202,9 +200,8 @@ class ForgePlatform extends AbstractPlatform implements MultiUserPlatform {
@Override
public Collection<Actor> getConnectedUsers() {
List<Actor> users = new ArrayList<Actor>();
ServerConfigurationManager scm = server.getConfigurationManager();
for (String name : scm.getAllUsernames()) {
EntityPlayerMP entity = scm.getPlayerByUsername(name);
PlayerList scm = server.getPlayerList();
for (EntityPlayerMP entity : scm.getPlayerList()) {
if (entity != null) {
users.add(new ForgePlayer(this, entity));
}

View File

@ -30,18 +30,17 @@ import com.sk89q.worldedit.internal.cui.CUIEvent;
import com.sk89q.worldedit.session.SessionKey;
import com.sk89q.worldedit.util.Location;
import io.netty.buffer.Unpooled;
import java.util.UUID;
import javax.annotation.Nullable;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketBuffer;
import net.minecraft.network.play.server.S3FPacketCustomPayload;
import net.minecraft.util.ChatComponentText;
import io.netty.buffer.Unpooled;
import net.minecraft.util.EnumChatFormatting;
import javax.annotation.Nullable;
import java.util.UUID;
import net.minecraft.network.play.server.SPacketCustomPayload;
import net.minecraft.util.EnumHand;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextFormatting;
public class ForgePlayer extends AbstractPlayerActor {
@ -61,7 +60,7 @@ public class ForgePlayer extends AbstractPlayerActor {
@Override
public int getItemInHand() {
ItemStack is = this.player.getCurrentEquippedItem();
ItemStack is = this.player.getHeldItem(EnumHand.MAIN_HAND);
return is == null ? 0 : Item.getIdFromItem(is.getItem());
}
@ -85,6 +84,7 @@ public class ForgePlayer extends AbstractPlayerActor {
this.player.rotationPitch);
}
@SuppressWarnings("deprecation")
@Override
public WorldVector getPosition() {
return new WorldVector(LocalWorldAdapter.adapt(ForgeWorldEdit.inst.getWorld(this.player.worldObj)), this.player.posX, this.player.posY, this.player.posZ);
@ -118,36 +118,36 @@ public class ForgePlayer extends AbstractPlayerActor {
send = send + "|" + StringUtil.joinString(params, "|");
}
PacketBuffer buffer = new PacketBuffer(Unpooled.copiedBuffer(send.getBytes(WECUIPacketHandler.UTF_8_CHARSET)));
S3FPacketCustomPayload packet = new S3FPacketCustomPayload(ForgeWorldEdit.CUI_PLUGIN_CHANNEL, buffer);
SPacketCustomPayload packet = new SPacketCustomPayload(ForgeWorldEdit.CUI_PLUGIN_CHANNEL, buffer);
this.player.playerNetServerHandler.sendPacket(packet);
}
@Override
public void printRaw(String msg) {
for (String part : msg.split("\n")) {
this.player.addChatMessage(new ChatComponentText(part));
this.player.addChatMessage(new TextComponentString(part));
}
}
@Override
public void printDebug(String msg) {
sendColorized(msg, EnumChatFormatting.GRAY);
sendColorized(msg, TextFormatting.GRAY);
}
@Override
public void print(String msg) {
sendColorized(msg, EnumChatFormatting.LIGHT_PURPLE);
sendColorized(msg, TextFormatting.LIGHT_PURPLE);
}
@Override
public void printError(String msg) {
sendColorized(msg, EnumChatFormatting.RED);
sendColorized(msg, TextFormatting.RED);
}
private void sendColorized(String msg, EnumChatFormatting formatting) {
private void sendColorized(String msg, TextFormatting formatting) {
for (String part : msg.split("\n")) {
ChatComponentText component = new ChatComponentText(part);
component.getChatStyle().setColor(formatting);
TextComponentString component = new TextComponentString(part);
component.getStyle().setColor(formatting);
this.player.addChatMessage(component);
}
}

View File

@ -58,16 +58,17 @@ import net.minecraft.init.Blocks;
import net.minecraft.inventory.IInventory;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.ChunkCoordIntPair;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.ChunkProviderServer;
import net.minecraft.world.gen.feature.WorldGenBigMushroom;
import net.minecraft.world.gen.feature.WorldGenBigTree;
import net.minecraft.world.gen.feature.WorldGenBirchTree;
import net.minecraft.world.gen.feature.WorldGenCanopyTree;
import net.minecraft.world.gen.feature.WorldGenForest;
import net.minecraft.world.gen.feature.WorldGenMegaJungle;
import net.minecraft.world.gen.feature.WorldGenMegaPineTree;
import net.minecraft.world.gen.feature.WorldGenSavannaTree;
@ -89,9 +90,9 @@ public class ForgeWorld extends AbstractWorld {
private static final int UPDATE = 1, NOTIFY = 2, NOTIFY_CLIENT = 4;
private static final Logger logger = Logger.getLogger(ForgeWorld.class.getCanonicalName());
private static final IBlockState JUNGLE_LOG = Blocks.log.getDefaultState().withProperty(BlockOldLog.VARIANT, BlockPlanks.EnumType.JUNGLE);
private static final IBlockState JUNGLE_LEAF = Blocks.leaves.getDefaultState().withProperty(BlockOldLeaf.VARIANT, BlockPlanks.EnumType.JUNGLE).withProperty(BlockLeaves.CHECK_DECAY, Boolean.valueOf(false));
private static final IBlockState JUNGLE_SHRUB = Blocks.leaves.getDefaultState().withProperty(BlockOldLeaf.VARIANT, BlockPlanks.EnumType.OAK).withProperty(BlockLeaves.CHECK_DECAY, Boolean.valueOf(false));
private static final IBlockState JUNGLE_LOG = Blocks.LOG.getDefaultState().withProperty(BlockOldLog.VARIANT, BlockPlanks.EnumType.JUNGLE);
private static final IBlockState JUNGLE_LEAF = Blocks.LEAVES.getDefaultState().withProperty(BlockOldLeaf.VARIANT, BlockPlanks.EnumType.JUNGLE).withProperty(BlockLeaves.CHECK_DECAY, Boolean.valueOf(false));
private static final IBlockState JUNGLE_SHRUB = Blocks.LEAVES.getDefaultState().withProperty(BlockOldLeaf.VARIANT, BlockPlanks.EnumType.OAK).withProperty(BlockLeaves.CHECK_DECAY, Boolean.valueOf(false));
private final WeakReference<World> worldRef;
@ -204,7 +205,7 @@ public class ForgeWorld extends AbstractWorld {
@Override
public BaseBiome getBiome(Vector2D position) {
checkNotNull(position);
return new BaseBiome(getWorld().getBiomeGenForCoords(new BlockPos(position.getBlockX(), 0, position.getBlockZ())).biomeID);
return new BaseBiome(BiomeGenBase.getIdForBiome(getWorld().getBiomeGenForCoords(new BlockPos(position.getBlockX(), 0, position.getBlockZ()))));
}
@Override
@ -258,8 +259,6 @@ public class ForgeWorld extends AbstractWorld {
return false;
}
ChunkProviderServer chunkServer = (ChunkProviderServer) provider;
IChunkProvider chunkProvider = chunkServer.serverChunkGenerator;
for (Vector2D coord : chunks) {
long pos = ChunkCoordIntPair.chunkXZ2Int(coord.getBlockX(), coord.getBlockZ());
Chunk mcChunk;
@ -269,12 +268,12 @@ public class ForgeWorld extends AbstractWorld {
}
chunkServer.droppedChunksSet.remove(pos);
chunkServer.id2ChunkMap.remove(pos);
mcChunk = chunkProvider.provideChunk(coord.getBlockX(), coord.getBlockZ());
mcChunk = chunkServer.provideChunk(coord.getBlockX(), coord.getBlockZ());
chunkServer.id2ChunkMap.add(pos, mcChunk);
chunkServer.loadedChunks.add(mcChunk);
if (mcChunk != null) {
mcChunk.onChunkLoad();
mcChunk.populateChunk(chunkProvider, chunkProvider, coord.getBlockX(), coord.getBlockZ());
mcChunk.populateChunk(chunkServer, chunkServer.chunkGenerator);
}
}
} catch (Throwable t) {
@ -308,18 +307,18 @@ public class ForgeWorld extends AbstractWorld {
case BIG_TREE: return new WorldGenBigTree(true);
case REDWOOD: return new WorldGenTaiga2(true);
case TALL_REDWOOD: return new WorldGenTaiga1();
case BIRCH: return new WorldGenForest(true, false);
case BIRCH: return new WorldGenBirchTree(true, false);
case JUNGLE: return new WorldGenMegaJungle(true, 10, 20, JUNGLE_LOG, JUNGLE_LEAF);
case SMALL_JUNGLE: return new WorldGenTrees(true, 4 + random.nextInt(7), JUNGLE_LOG, JUNGLE_LEAF, false);
case SHORT_JUNGLE: return new WorldGenTrees(true, 4 + random.nextInt(7), JUNGLE_LOG, JUNGLE_LEAF, true);
case JUNGLE_BUSH: return new WorldGenShrub(JUNGLE_LOG, JUNGLE_SHRUB);
case RED_MUSHROOM: return new WorldGenBigMushroom(Blocks.brown_mushroom_block);
case BROWN_MUSHROOM: return new WorldGenBigMushroom(Blocks.red_mushroom_block);
case RED_MUSHROOM: return new WorldGenBigMushroom(Blocks.BROWN_MUSHROOM_BLOCK);
case BROWN_MUSHROOM: return new WorldGenBigMushroom(Blocks.RED_MUSHROOM_BLOCK);
case SWAMP: return new WorldGenSwamp();
case ACACIA: return new WorldGenSavannaTree(true);
case DARK_OAK: return new WorldGenCanopyTree(true);
case MEGA_REDWOOD: return new WorldGenMegaPineTree(false, random.nextBoolean());
case TALL_BIRCH: return new WorldGenForest(true, true);
case TALL_BIRCH: return new WorldGenBirchTree(true, true);
case RANDOM:
case PINE:
case RANDOM_REDWOOD:
@ -390,9 +389,7 @@ public class ForgeWorld extends AbstractWorld {
@Override
public List<? extends Entity> getEntities(Region region) {
List<Entity> entities = new ArrayList<Entity>();
World world = getWorld();
List<net.minecraft.entity.Entity> ents = world.loadedEntityList;
for (net.minecraft.entity.Entity entity : ents) {
for (net.minecraft.entity.Entity entity : getWorld().loadedEntityList) {
if (region.contains(new Vector(entity.posX, entity.posY, entity.posZ))) {
entities.add(new ForgeEntity(entity));
}

View File

@ -29,6 +29,7 @@ import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.event.platform.PlatformReadyEvent;
import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.internal.LocalWorldAdapter;
import com.sk89q.worldedit.util.Java8Detector;
import java.io.File;
import java.util.Map;
@ -39,7 +40,6 @@ import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.CommandEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
@ -61,6 +61,10 @@ import static com.google.common.base.Preconditions.checkNotNull;
*/
@Mod(modid = ForgeWorldEdit.MOD_ID, name = "WorldEdit", version = "%VERSION%", acceptableRemoteVersions = "*")
public class ForgeWorldEdit {
static {
Java8Detector.notifyIfNot8();
}
public static Logger logger;
public static final String MOD_ID = "worldedit";
@ -110,8 +114,6 @@ public class ForgeWorldEdit {
WorldEdit.getInstance().getPlatformManager().unregister(platform);
}
ForgeBiomeRegistry.populate();
this.platform = new ForgePlatform(this);
WorldEdit.getInstance().getPlatformManager().register(platform);
@ -135,13 +137,13 @@ public class ForgeWorldEdit {
@SubscribeEvent
public void onCommandEvent(CommandEvent event) {
if ((event.sender instanceof EntityPlayerMP)) {
if (((EntityPlayerMP) event.sender).worldObj.isRemote) return;
String[] split = new String[event.parameters.length + 1];
System.arraycopy(event.parameters, 0, split, 1, event.parameters.length);
split[0] = event.command.getCommandName();
if ((event.getSender() instanceof EntityPlayerMP)) {
if (((EntityPlayerMP) event.getSender()).worldObj.isRemote) return;
String[] split = new String[event.getParameters().length + 1];
System.arraycopy(event.getParameters(), 0, split, 1, event.getParameters().length);
split[0] = event.getCommand().getCommandName();
com.sk89q.worldedit.event.platform.CommandEvent weEvent =
new com.sk89q.worldedit.event.platform.CommandEvent(wrap((EntityPlayerMP) event.sender), Joiner.on(" ").join(split));
new com.sk89q.worldedit.event.platform.CommandEvent(wrap((EntityPlayerMP) event.getSender()), Joiner.on(" ").join(split));
WorldEdit.getInstance().getEventBus().post(weEvent);
}
}
@ -152,48 +154,51 @@ public class ForgeWorldEdit {
return;
}
if (!platform.isHookingEvents()) return; // We have to be told to catch these events
if (!platform.isHookingEvents())
return; // We have to be told to catch these events
if (event.useItem == Result.DENY || event.entity.worldObj.isRemote) return;
boolean isLeftDeny = event instanceof PlayerInteractEvent.LeftClickBlock
&& ((PlayerInteractEvent.LeftClickBlock) event)
.getUseItem() == Result.DENY;
boolean isRightDeny =
event instanceof PlayerInteractEvent.RightClickBlock
&& ((PlayerInteractEvent.RightClickBlock) event)
.getUseItem() == Result.DENY;
if (isLeftDeny || isRightDeny || event.getEntity().worldObj.isRemote) {
return;
}
WorldEdit we = WorldEdit.getInstance();
ForgePlayer player = wrap((EntityPlayerMP) event.entityPlayer);
ForgeWorld world = getWorld(event.entityPlayer.worldObj);
ForgePlayer player = wrap((EntityPlayerMP) event.getEntityPlayer());
ForgeWorld world = getWorld(event.getEntityPlayer().worldObj);
Action action = event.action;
switch (action) {
case LEFT_CLICK_BLOCK: {
WorldVector pos = new WorldVector(LocalWorldAdapter.adapt(world), event.pos.getX(), event.pos.getY(), event.pos.getZ());
if (event instanceof PlayerInteractEvent.LeftClickBlock) {
@SuppressWarnings("deprecation")
WorldVector pos = new WorldVector(LocalWorldAdapter.adapt(world),
event.getPos().getX(), event.getPos().getY(), event.getPos().getZ());
if (we.handleBlockLeftClick(player, pos)) {
event.setCanceled(true);
}
if (we.handleArmSwing(player)) {
event.setCanceled(true);
}
break;
if (we.handleBlockLeftClick(player, pos)) {
event.setCanceled(true);
}
case RIGHT_CLICK_BLOCK: {
WorldVector pos = new WorldVector(LocalWorldAdapter.adapt(world), event.pos.getX(), event.pos.getY(), event.pos.getZ());
if (we.handleBlockRightClick(player, pos)) {
event.setCanceled(true);
}
if (we.handleRightClick(player)) {
event.setCanceled(true);
}
break;
if (we.handleArmSwing(player)) {
event.setCanceled(true);
}
case RIGHT_CLICK_AIR: {
if (we.handleRightClick(player)) {
event.setCanceled(true);
}
} else if (event instanceof PlayerInteractEvent.RightClickBlock) {
@SuppressWarnings("deprecation")
WorldVector pos = new WorldVector(LocalWorldAdapter.adapt(world),
event.getPos().getX(), event.getPos().getY(), event.getPos().getZ());
break;
if (we.handleBlockRightClick(player, pos)) {
event.setCanceled(true);
}
if (we.handleRightClick(player)) {
event.setCanceled(true);
}
} else if (event instanceof PlayerInteractEvent.RightClickEmpty) {
if (we.handleRightClick(player)) {
event.setCanceled(true);
}
}
}
@ -201,7 +206,7 @@ public class ForgeWorldEdit {
public static ItemStack toForgeItemStack(BaseItemStack item) {
ItemStack ret = new ItemStack(Item.getItemById(item.getType()), item.getAmount(), item.getData());
for (Map.Entry<Integer, Integer> entry : item.getEnchantments().entrySet()) {
ret.addEnchantment(net.minecraft.enchantment.Enchantment.getEnchantmentById(entry.getKey()), entry.getValue());
ret.addEnchantment(net.minecraft.enchantment.Enchantment.getEnchantmentByID(entry.getKey()), entry.getValue());
}
return ret;

View File

@ -213,7 +213,7 @@ final class NBTConverter {
}
public static CompoundTag fromNative(NBTTagCompound other) {
@SuppressWarnings("unchecked") Set<String> tags = other.getKeySet();
Set<String> tags = other.getKeySet();
Map<String, Tag> map = new HashMap<String, Tag>();
for (String tagName : tags) {
map.put(tagName, fromNative(other.getTag(tagName)));

View File

@ -58,12 +58,11 @@ public class ThreadSafeCache {
Set<UUID> onlineIds = new HashSet<UUID>();
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
if (server == null || server.getConfigurationManager() == null) {
if (server == null || server.getPlayerList() == null) {
return;
}
for (Object object : FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().playerEntityList) {
if (object != null) {
EntityPlayerMP player = (EntityPlayerMP) object;
for (EntityPlayerMP player : server.getPlayerList().getPlayerList()) {
if (player != null) {
onlineIds.add(player.getUniqueID());
}
}

View File

@ -21,16 +21,14 @@ package com.sk89q.worldedit.forge;
import com.sk89q.worldedit.Vector;
import java.lang.reflect.Constructor;
import javax.annotation.Nullable;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagInt;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import javax.annotation.Nullable;
import java.lang.reflect.Constructor;
import static com.google.common.base.Preconditions.checkNotNull;
/**
@ -98,7 +96,7 @@ final class TileEntityUtils {
static void setTileEntity(World world, Vector position, @Nullable NBTTagCompound tag) {
if (tag != null) {
updateForSet(tag, position);
TileEntity tileEntity = TileEntity.createAndLoadEntity(tag);
TileEntity tileEntity = TileEntity.createTileEntity(world.getMinecraftServer(), tag);
if (tileEntity != null) {
world.setTileEntity(new BlockPos(position.getBlockX(), position.getBlockY(), position.getBlockZ()), tileEntity);
}

View File

@ -26,7 +26,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.NetHandlerPlayServer;
import net.minecraft.network.PacketBuffer;
import net.minecraft.network.ThreadQuickExitException;
import net.minecraft.network.play.server.S3FPacketCustomPayload;
import net.minecraft.network.play.server.SPacketCustomPayload;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.network.FMLEventChannel;
import net.minecraftforge.fml.common.network.FMLNetworkEvent.ClientCustomPacketEvent;
@ -44,7 +44,7 @@ public class WECUIPacketHandler {
@SubscribeEvent
public void onPacketData(ServerCustomPacketEvent event) {
if (event.packet.channel().equals(ForgeWorldEdit.CUI_PLUGIN_CHANNEL)) {
if (event.getPacket().channel().equals(ForgeWorldEdit.CUI_PLUGIN_CHANNEL)) {
EntityPlayerMP player = getPlayerFromEvent(event);
LocalSession session = ForgeWorldEdit.inst.getSession((EntityPlayerMP) player);
@ -52,7 +52,7 @@ public class WECUIPacketHandler {
return;
}
String text = event.packet.payload().toString(UTF_8_CHARSET);
String text = event.getPacket().payload().toString(UTF_8_CHARSET);
session.handleCUIInitializationMessage(text);
session.describeCUI(ForgeWorldEdit.inst.wrap(player));
}
@ -61,12 +61,12 @@ public class WECUIPacketHandler {
@SubscribeEvent
public void callProcessPacket(ClientCustomPacketEvent event) {
try {
new S3FPacketCustomPayload(event.packet.channel(), new PacketBuffer(event.packet.payload())).processPacket(event.handler);
new SPacketCustomPayload(event.getPacket().channel(), new PacketBuffer(event.getPacket().payload())).processPacket(event.getHandler());
} catch (ThreadQuickExitException suppress) {
}
}
private static EntityPlayerMP getPlayerFromEvent(ServerCustomPacketEvent event) {
return ((NetHandlerPlayServer) event.handler).playerEntity;
return ((NetHandlerPlayServer) event.getHandler()).playerEntity;
}
}

View File

@ -32,7 +32,6 @@ public class GuiReferenceCard extends GuiScreen {
private int backgroundHeight = 256;
@Override
@SuppressWarnings("unchecked")
public void initGui() {
this.buttonList.add(this.closeButton = new GuiButton(0, (this.width - this.backgroundWidth + 100) / 2, (this.height + this.backgroundHeight - 60) / 2, this.backgroundWidth - 100, 20, "Close"));
}

View File

@ -1,4 +1,4 @@
public net.minecraft.world.gen.ChunkProviderServer field_73248_b # droppedChunksSet
public net.minecraft.world.gen.ChunkProviderServer field_73244_f # id2ChunkMap
public net.minecraft.world.gen.ChunkProviderServer field_73245_g # loadedChunks
public net.minecraft.world.gen.ChunkProviderServer field_73246_d # serverChunkGenerator
public net.minecraft.world.gen.ChunkProviderServer field_186029_c # chunkGenerator