diff --git a/worldedit-forge/build.gradle b/worldedit-forge/build.gradle index 331008ad4..f95b9d4fb 100644 --- a/worldedit-forge/build.gradle +++ b/worldedit-forge/build.gradle @@ -7,25 +7,30 @@ buildscript { } dependencies { - classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT' + classpath 'net.minecraftforge.gradle:ForgeGradle:2.1-SNAPSHOT' } } -apply plugin: 'forge' +apply plugin: 'net.minecraftforge.gradle.forge' dependencies { compile project(':worldedit-core') - compile 'org.spongepowered:spongeapi:2.1-SNAPSHOT' + compile 'org.spongepowered:spongeapi:3.1.0-SNAPSHOT' testCompile group: 'org.mockito', name: 'mockito-core', version:'1.9.0-rc1' } repositories { - maven { url ="https://repo.spongepowered.org/maven" } + maven { + name = "Sponge" + url = "https://repo.spongepowered.org/maven" + } } +ext.forgeVersion = "11.15.0.1695" minecraft { - ext.forgeVersion = "11.14.0.1281" - version = "1.8-$forgeVersion-1.8" + version = "1.8.9-${project.forgeVersion}" + mappings = "snapshot_20160111" + runDir = 'run' replaceIn "com/sk89q/worldedit/forge/ForgeWorldEdit.java" replace "%VERSION%", project.version @@ -37,7 +42,7 @@ processResources { from (sourceSets.main.resources.srcDirs) { expand 'version': project.version, 'mcVersion': project.minecraft.version, - 'forgeVersion': project.minecraft.forgeVersion, + 'forgeVersion': project.forgeVersion, 'internalVersion': project.internalVersion include 'mcmod.info' } @@ -60,8 +65,8 @@ shadowJar { } } -reobf.reobf(shadowJar) { spec -> - spec.classpath = sourceSets.main.compileClasspath; +reobf { + shadowJar } task deobfJar(type: Jar) { diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ClientProxy.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ClientProxy.java index e029085ab..688728a63 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ClientProxy.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ClientProxy.java @@ -19,14 +19,14 @@ package com.sk89q.worldedit.forge; -import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.common.MinecraftForge; public class ClientProxy extends CommonProxy { @Override public void registerHandlers() { super.registerHandlers(); - FMLCommonHandler.instance().bus().register(new KeyHandler()); + MinecraftForge.EVENT_BUS.register(new KeyHandler()); } } 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 fb5c55550..daf76bad6 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 @@ -79,7 +79,7 @@ public class CommandWrapper extends CommandBase { } @Override - public int compareTo(@Nullable Object o) { + public int compareTo(@Nullable ICommand o) { if (o == null) { return 0; } else if (o instanceof ICommand) { 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 325bcc8ef..6b3f5e655 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 @@ -41,9 +41,14 @@ import com.sk89q.worldedit.world.biome.BaseBiome; import com.sk89q.worldedit.world.registry.WorldData; import net.minecraft.block.Block; +import net.minecraft.block.BlockLeaves; +import net.minecraft.block.BlockOldLeaf; +import net.minecraft.block.BlockOldLog; +import net.minecraft.block.BlockPlanks; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EntityList; import net.minecraft.entity.item.EntityItem; +import net.minecraft.init.Blocks; import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -90,9 +95,14 @@ import static com.google.common.base.Preconditions.checkNotNull; */ public class ForgeWorld extends AbstractWorld { + private static final Random random = new Random(); private static final int UPDATE = 1, NOTIFY = 2, NOTIFY_CLIENT = 4; private static final Logger logger = Logger.getLogger(ForgeWorld.class.getCanonicalName()); - private static final Random random = new Random(); + + 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; /** @@ -348,12 +358,12 @@ public class ForgeWorld extends AbstractWorld { case REDWOOD: return new WorldGenTaiga2(true); case TALL_REDWOOD: return new WorldGenTaiga1(); case BIRCH: return new WorldGenForest(true, false); - case JUNGLE: return new WorldGenMegaJungle(true, 10, 20, 3, 3); - case SMALL_JUNGLE: return new WorldGenTrees(true, 4 + random.nextInt(7), 3, 3, false); - case SHORT_JUNGLE: return new WorldGenTrees(true, 4 + random.nextInt(7), 3, 3, true); - case JUNGLE_BUSH: return new WorldGenShrub(3, 0); - case RED_MUSHROOM: return new WorldGenBigMushroom(1); - case BROWN_MUSHROOM: return new WorldGenBigMushroom(0); + 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 SWAMP: return new WorldGenSwamp(); case ACACIA: return new WorldGenSavannaTree(true); case DARK_OAK: return new WorldGenCanopyTree(true); @@ -427,7 +437,6 @@ public class ForgeWorld extends AbstractWorld { } @Override - @SuppressWarnings("unchecked") public List getEntities(Region region) { List entities = new ArrayList(); World world = getWorld(); @@ -443,8 +452,8 @@ public class ForgeWorld extends AbstractWorld { @Override public List getEntities() { List entities = new ArrayList(); - for (Object entity : getWorld().loadedEntityList) { - entities.add(new ForgeEntity((net.minecraft.entity.Entity) entity)); + for (net.minecraft.entity.Entity entity : getWorld().loadedEntityList) { + entities.add(new ForgeEntity(entity)); } return entities; } 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 40d0bda24..2ba05bf28 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 @@ -19,6 +19,8 @@ package com.sk89q.worldedit.forge; +import org.apache.logging.log4j.Logger; + import com.google.common.base.Joiner; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.WorldEdit; @@ -28,6 +30,8 @@ import com.sk89q.worldedit.event.platform.PlatformReadyEvent; import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.internal.LocalWorldAdapter; +import java.io.File; +import java.util.Map; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -35,7 +39,7 @@ 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.fml.common.FMLCommonHandler; +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; @@ -50,13 +54,7 @@ import net.minecraftforge.fml.common.event.FMLServerStoppingEvent; import net.minecraftforge.fml.common.eventhandler.Event.Result; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import org.apache.logging.log4j.Logger; - -import java.io.File; -import java.util.Map; - import static com.google.common.base.Preconditions.checkNotNull; -import static net.minecraftforge.event.entity.player.PlayerInteractEvent.Action; /** * The Forge implementation of WorldEdit. @@ -90,7 +88,7 @@ public class ForgeWorldEdit { config = new ForgeConfiguration(this); config.load(); - FMLCommonHandler.instance().bus().register(ThreadSafeCache.getInstance()); + MinecraftForge.EVENT_BUS.register(ThreadSafeCache.getInstance()); } @EventHandler @@ -203,7 +201,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.enchantmentsList[((Integer) entry.getKey())], (Integer) 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/WECUIPacketHandler.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/WECUIPacketHandler.java index 3acc1f6e5..a4ae912aa 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 @@ -19,13 +19,13 @@ package com.sk89q.worldedit.forge; -import java.nio.charset.Charset; +import com.sk89q.worldedit.LocalSession; +import java.nio.charset.Charset; 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.S20PacketEntityProperties; import net.minecraft.network.play.server.S3FPacketCustomPayload; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.network.FMLEventChannel; @@ -33,8 +33,6 @@ import net.minecraftforge.fml.common.network.FMLNetworkEvent.ClientCustomPacketE import net.minecraftforge.fml.common.network.FMLNetworkEvent.ServerCustomPacketEvent; import net.minecraftforge.fml.common.network.NetworkRegistry; -import com.sk89q.worldedit.LocalSession; - public class WECUIPacketHandler { public static final Charset UTF_8_CHARSET = Charset.forName("UTF-8"); public static FMLEventChannel WECUI_CHANNEL;