diff --git a/.travis.yml b/.travis.yml index 9321cf073..7013c738a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,6 @@ script: ./gradlew build -s jdk: - oraclejdk8 - oraclejdk7 - - openjdk6 # Caching for Gradle files, prevents hitting Maven too much. before_cache: - find $HOME/.gradle/ -name '*.lock' -print -exec rm -f {} \; diff --git a/build.gradle b/build.gradle index 144b8de13..21b89dafb 100644 --- a/build.gradle +++ b/build.gradle @@ -61,8 +61,8 @@ subprojects { version = '6.1.1-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") diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 5ccda13e9..ca78035ef 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index b2c6e7a02..c76e8f2d8 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -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 diff --git a/gradlew b/gradlew index 9d82f7891..27309d923 100755 --- a/gradlew +++ b/gradlew @@ -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 diff --git a/gradlew.bat b/gradlew.bat index 72d362daf..f6d5974e7 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -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 diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java index be6378380..4ffde3d85 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java @@ -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() { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/Java8Detector.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/Java8Detector.java new file mode 100644 index 000000000..71a05d667 --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/Java8Detector.java @@ -0,0 +1,46 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * 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 . + */ +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() { + } + +} diff --git a/worldedit-forge/build.gradle b/worldedit-forge/build.gradle index 41e0f4126..b7cae2c0e 100644 --- a/worldedit-forge/build.gradle +++ b/worldedit-forge/build.gradle @@ -27,12 +27,12 @@ repositories { } version = "6.1.1" -ext.forgeVersion = "11.15.1.1760" +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" diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/CommandWrapper.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/CommandWrapper.java index 2b555c851..eef6df939 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/CommandWrapper.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/CommandWrapper.java @@ -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; } diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeAdapter.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeAdapter.java index 9c64b9403..57b8e1f2e 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeAdapter.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeAdapter.java @@ -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) { diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeBiomeRegistry.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeBiomeRegistry.java index 6de863048..6dd3d515d 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeBiomeRegistry.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeBiomeRegistry.java @@ -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 biomes = Collections.emptyMap(); - private static Map 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 getBiomes() { List list = new ArrayList(); - 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. - * - *

If called repeatedly, the last call will overwrite all previous - * calls.

- */ - static void populate() { - Map biomes = HashBiMap.create(); - Map biomeData = new HashMap(); - - 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(); } } diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeEntityType.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeEntityType.java index c56375105..a7a4b3cbd 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeEntityType.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeEntityType.java @@ -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; } } diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePermissionsProvider.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePermissionsProvider.java index c68131265..0c9b0542f 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePermissionsProvider.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePermissionsProvider.java @@ -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 diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlatform.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlatform.java index 7edb92b3a..5adab0ec0 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlatform.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlatform.java @@ -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 getWorlds() { - List worlds = Arrays.asList(DimensionManager.getWorlds()); - List ret = new ArrayList(worlds.size()); + WorldServer[] worlds = DimensionManager.getWorlds(); + List ret = new ArrayList(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 getConnectedUsers() { List users = new ArrayList(); - 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)); } diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlayer.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlayer.java index 4553c1694..d01c7f6e6 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlayer.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlayer.java @@ -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); } } diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorld.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorld.java index e89c46112..73db996d1 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorld.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorld.java @@ -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 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 getEntities(Region region) { List entities = new ArrayList(); - World world = getWorld(); - List 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)); } diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorldEdit.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorldEdit.java index 5ae29054e..46300364f 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorldEdit.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorldEdit.java @@ -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 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; diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/NBTConverter.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/NBTConverter.java index 69f4ab6ad..d24d83bb0 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/NBTConverter.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/NBTConverter.java @@ -213,7 +213,7 @@ final class NBTConverter { } public static CompoundTag fromNative(NBTTagCompound other) { - @SuppressWarnings("unchecked") Set tags = other.getKeySet(); + Set tags = other.getKeySet(); Map map = new HashMap(); for (String tagName : tags) { map.put(tagName, fromNative(other.getTag(tagName))); diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ThreadSafeCache.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ThreadSafeCache.java index 0ca19c5b0..bd33ac01b 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ThreadSafeCache.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ThreadSafeCache.java @@ -58,12 +58,11 @@ public class ThreadSafeCache { Set onlineIds = new HashSet(); 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()); } } diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/TileEntityUtils.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/TileEntityUtils.java index 328420b27..0ac31b951 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/TileEntityUtils.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/TileEntityUtils.java @@ -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); } diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/WECUIPacketHandler.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/WECUIPacketHandler.java index 24da15c53..1a89fc5db 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/WECUIPacketHandler.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/WECUIPacketHandler.java @@ -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; } } \ No newline at end of file diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/gui/GuiReferenceCard.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/gui/GuiReferenceCard.java index 592c0dadb..97ff555cd 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/gui/GuiReferenceCard.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/gui/GuiReferenceCard.java @@ -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")); } diff --git a/worldedit-forge/src/main/resources/META-INF/worldedit_at.cfg b/worldedit-forge/src/main/resources/META-INF/worldedit_at.cfg index 33f039ce3..a15c42170 100644 --- a/worldedit-forge/src/main/resources/META-INF/worldedit_at.cfg +++ b/worldedit-forge/src/main/resources/META-INF/worldedit_at.cfg @@ -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