From 017126d422e8e3651e8573694484740ef0d69930 Mon Sep 17 00:00:00 2001 From: luacs1998 Date: Sat, 13 Dec 2014 14:08:45 +0800 Subject: [PATCH 01/21] Some fixes and tweaks for PR #309 Apologies for the inconvenience. --- .../main/java/com/sk89q/worldedit/forge/ForgePlatform.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 d4021ff922..f98f754f91 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 @@ -153,8 +153,8 @@ public void registerCommands(Dispatcher dispatcher) { for (final CommandMapping command : dispatcher.getCommands()) { CommandWrapper wrapper = new CommandWrapper(command); mcMan.registerCommand(wrapper); - ForgeWorldEdit.inst.getPermissionsProvider().registerPermission(wrapper, command.getDescription().getPermissions().get(0)); - if (command.getDescription().getPermissions().size() > 1) { + if (command.getDescription().getPermissions().size() > 0) { + ForgeWorldEdit.inst.getPermissionsProvider().registerPermission(wrapper, command.getDescription().getPermissions().get(0)); for (int i = 1; i < command.getDescription().getPermissions().size(); i++) { ForgeWorldEdit.inst.getPermissionsProvider().registerPermission(null, command.getDescription().getPermissions().get(i)); } @@ -194,7 +194,7 @@ public Map getCapabilities() { capabilities.put(Capability.CONFIGURATION, Preference.PREFER_OTHERS); capabilities.put(Capability.WORLDEDIT_CUI, Preference.NORMAL); capabilities.put(Capability.GAME_HOOKS, Preference.NORMAL); - capabilities.put(Capability.PERMISSIONS, Preference.PREFER_OTHERS); + capabilities.put(Capability.PERMISSIONS, Preference.NORMAL); capabilities.put(Capability.USER_COMMANDS, Preference.NORMAL); capabilities.put(Capability.WORLD_EDITING, Preference.PREFERRED); return capabilities; From 6a6c590a07f42d637bef6e44c710d2129785fc68 Mon Sep 17 00:00:00 2001 From: zml Date: Sat, 10 Jan 2015 16:57:53 -0800 Subject: [PATCH 02/21] WEPIF: Use UUIDs wherever possible in PermissionsExResolver --- worldedit-bukkit/build.gradle | 6 +++--- .../main/java/com/sk89q/wepif/PermissionsExResolver.java | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/worldedit-bukkit/build.gradle b/worldedit-bukkit/build.gradle index 440dbd027c..ed882a1c0a 100644 --- a/worldedit-bukkit/build.gradle +++ b/worldedit-bukkit/build.gradle @@ -3,9 +3,9 @@ apply plugin: 'idea' dependencies { compile project(':worldedit-core') - compile 'com.sk89q:dummypermscompat:1.7' - compile 'org.sk89q.bukkit:bukkit-classloader-check:1.7.2-R0.3' - compile 'org.bukkit:bukkit:1.7.2-R0.3' + compile 'com.sk89q:dummypermscompat:1.8' + compile 'org.sk89q.bukkit:bukkit-classloader-check:1.7.9-R0.2' + compile 'org.bukkit:bukkit:1.7.9-R0.2' testCompile 'org.mockito:mockito-core:1.9.0-rc1' } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/wepif/PermissionsExResolver.java b/worldedit-bukkit/src/main/java/com/sk89q/wepif/PermissionsExResolver.java index ece76df9df..a50d6b1505 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/wepif/PermissionsExResolver.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/wepif/PermissionsExResolver.java @@ -57,7 +57,7 @@ public boolean hasPermission(String worldName, String name, String permission) { public boolean hasPermission(OfflinePlayer player, String permission) { Permissible permissible = getPermissible(player); if (permissible == null) { - return manager.has(player.getName(), permission, null); + return manager.has(player.getUniqueId(), permission, null); } else { return permissible.hasPermission(permission); } @@ -65,18 +65,18 @@ public boolean hasPermission(OfflinePlayer player, String permission) { @Override public boolean hasPermission(String worldName, OfflinePlayer player, String permission) { - return hasPermission(worldName, player.getName(), permission); + return manager.has(player.getUniqueId(), permission, worldName); } @Override public boolean inGroup(OfflinePlayer player, String group) { - return super.inGroup(player, group) || manager.getUser(player.getName()).inGroup(group); + return super.inGroup(player, group) || manager.getUser(player.getUniqueId()).inGroup(group); } @Override public String[] getGroups(OfflinePlayer player) { if (getPermissible(player) == null) { - PermissionUser user = manager.getUser(player.getName()); + PermissionUser user = manager.getUser(player.getUniqueId()); if (user == null) { return new String[0]; } From 139009dfbb796ae6a514147b74a2381a65418b6b Mon Sep 17 00:00:00 2001 From: zml Date: Sat, 10 Jan 2015 17:09:29 -0800 Subject: [PATCH 03/21] Update shadow plugin version to fix Forge issues --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 5dba7102cb..172911e8cb 100644 --- a/build.gradle +++ b/build.gradle @@ -20,7 +20,7 @@ buildscript { } dependencies { - classpath 'com.github.jengelman.gradle.plugins:shadow:1.1.1' + classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.0' classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:3.0.1' classpath 'org.ajoberstar:gradle-git:0.12.0' } @@ -123,4 +123,4 @@ subprojects { } } } -} \ No newline at end of file +} From 121d77ccf6b479922ad2ef0eaba8b93b46a623c5 Mon Sep 17 00:00:00 2001 From: sk89q Date: Sat, 10 Jan 2015 17:16:02 -0800 Subject: [PATCH 04/21] Tell people to use setupDevWorkspace rather than setupDecompWorkspace --- COMPILING.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/COMPILING.md b/COMPILING.md index 80e20b3913..bd9bf91e9b 100644 --- a/COMPILING.md +++ b/COMPILING.md @@ -14,7 +14,7 @@ The build process uses Gradle, which you do *not* need to download. WorldEdit is ### On Windows 1. Shift + right click the folder with WorldEdit's files and click "Open command prompt". -2. `gradlew clean setupDecompWorkspace` +2. `gradlew clean setupDevWorkspace` 3. `gradlew build` ### On Linux, BSD, or Mac OS X @@ -40,3 +40,5 @@ If you want to use WorldEdit, use the `-shadow` version. * `gradlew idea` will generate an [IntelliJ IDEA](http://www.jetbrains.com/idea/) module for the Forge module. * `gradlew eclipse` will generate an [Eclipse](https://www.eclipse.org/downloads/) project for the Forge version. * Use `setupCIWorkspace` instead of `setupDevWorkspace` if you are doing this on a CI server. + +Note: Rather than `setupDevWorkspace`, `setupDecompWorkspace` would you give better decompiled code for developing the Forge mod, but it is currently incompatible with multi-module projects like WorldEdit. From 98a7257c478cb9ee3152de30a3921c831fae10ed Mon Sep 17 00:00:00 2001 From: sk89q Date: Mon, 12 Jan 2015 21:52:06 -0800 Subject: [PATCH 05/21] Fix a typo in EditSession.java --- .../src/main/java/com/sk89q/worldedit/EditSession.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java index 19420c31af..3253fb61a8 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java @@ -178,7 +178,7 @@ public EditSession(LocalWorld world, int maxBlocks, @Nullable BlockBag blockBag) if (world != null) { Extent extent; - // This extents are ALWAYS used + // These extents are ALWAYS used extent = fastModeExtent = new FastModeExtent(world, false); extent = survivalExtent = new SurvivalModeExtent(extent, world); extent = quirkExtent = new BlockQuirkExtent(extent, world); From 372a520382fabeb2d093ee094be39e7722a4ed5b Mon Sep 17 00:00:00 2001 From: Kenzie Togami Date: Tue, 13 Jan 2015 22:32:02 -0800 Subject: [PATCH 06/21] Directly access entity list This replaces the very slow chunk dance that was being used. --- .../com/sk89q/worldedit/bukkit/BukkitWorld.java | 14 ++++---------- .../com/sk89q/worldedit/forge/ForgeWorld.java | 16 ++++------------ 2 files changed, 8 insertions(+), 22 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java index c95e4130df..4aaf558a6e 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java @@ -87,17 +87,11 @@ public BukkitWorld(World world) { public List getEntities(Region region) { World world = getWorld(); + List ents = world.getEntities(); List entities = new ArrayList(); - for (Vector2D pt : region.getChunks()) { - if (!world.isChunkLoaded(pt.getBlockX(), pt.getBlockZ())) { - continue; - } - - final Entity[] ents = world.getChunkAt(pt.getBlockX(), pt.getBlockZ()).getEntities(); - for (Entity ent : ents) { - if (region.contains(BukkitUtil.toVector(ent.getLocation()))) { - entities.add(BukkitAdapter.adapt(ent)); - } + for (Entity ent : ents) { + if (region.contains(BukkitUtil.toVector(ent.getLocation()))) { + entities.add(BukkitAdapter.adapt(ent)); } } return entities; 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 92edac931d..f4d56f862a 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 @@ -373,18 +373,10 @@ public boolean equals(Object o) { public List getEntities(Region region) { List entities = new ArrayList(); World world = getWorld(); - for (Vector2D pt : region.getChunks()) { - if (!world.getChunkProvider().chunkExists(pt.getBlockX(), pt.getBlockZ())) { - continue; - } - - Chunk chunk = world.getChunkProvider().provideChunk(pt.getBlockX(), pt.getBlockZ()); - for (List entitySubList : chunk.entityLists) { - for (net.minecraft.entity.Entity entity : entitySubList) { - if (region.contains(new Vector(entity.posX, entity.posY, entity.posZ))) { - entities.add(new ForgeEntity(entity)); - } - } + List ents = world.loadedEntityList; + for (net.minecraft.entity.Entity entity : ents) { + if (region.contains(new Vector(entity.posX, entity.posY, entity.posZ))) { + entities.add(new ForgeEntity(entity)); } } return entities; From d1631a9ca4339d982356ab2872784d738e66ad6a Mon Sep 17 00:00:00 2001 From: wizjany Date: Mon, 19 Jan 2015 14:15:31 -0500 Subject: [PATCH 07/21] Restore entity counter to //remove and grammatified //butcher similarly. --- .../java/com/sk89q/worldedit/command/UtilityCommands.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java index 3ed223f53c..7b79436f5f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java @@ -436,11 +436,7 @@ public void butcher(Actor actor, CommandContext args) throws WorldEditException killed += visitor.getAffected(); } - if (radius < 0) { - actor.print("Killed " + killed + " mobs."); - } else { - actor.print("Killed " + killed + " mobs in a radius of " + radius + "."); - } + actor.print("Killed " + killed + (killed != 1 ? " mobs" : "mob") + (radius < 0 ? "" : "in a radius of " + radius) + "."); if (editSession != null) { session.remember(editSession); @@ -500,7 +496,7 @@ public void remove(Actor actor, CommandContext args) throws WorldEditException, removed += visitor.getAffected(); } - actor.print("Marked " + (removed != 1 ? "entities" : "entity") + " for removal."); + actor.print("Marked " + removed + (removed != 1 ? " entities" : " entity") + " for removal."); if (editSession != null) { session.remember(editSession); From dc6ffae500233b2b090714eee00386c9f18f385c Mon Sep 17 00:00:00 2001 From: TomyLobo Date: Wed, 21 Jan 2015 09:46:35 +0100 Subject: [PATCH 08/21] Fixed /butcher text in the case of only one mob being killed. --- .../main/java/com/sk89q/worldedit/command/UtilityCommands.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java index 7b79436f5f..0c72f4cbaa 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java @@ -436,7 +436,7 @@ public void butcher(Actor actor, CommandContext args) throws WorldEditException killed += visitor.getAffected(); } - actor.print("Killed " + killed + (killed != 1 ? " mobs" : "mob") + (radius < 0 ? "" : "in a radius of " + radius) + "."); + actor.print("Killed " + killed + (killed != 1 ? " mobs" : " mob") + (radius < 0 ? "" : " in a radius of " + radius) + "."); if (editSession != null) { session.remember(editSession); From ec9c77c31bd06114197d13ce55452de11bddfbb1 Mon Sep 17 00:00:00 2001 From: wizjany Date: Thu, 22 Jan 2015 15:48:45 -0500 Subject: [PATCH 09/21] Excluded armor stands from //butcher by default. Someone got lazy and just made armor stands a living entity instead of extracting an ArmorEquippable interface. --- .../com/sk89q/worldedit/bukkit/BukkitEntityType.java | 12 +++++++++--- .../com/sk89q/worldedit/command/BrushCommands.java | 12 ++++-------- .../com/sk89q/worldedit/command/UtilityCommands.java | 5 +++-- .../worldedit/command/util/CreatureButcher.java | 8 ++++++++ .../sk89q/worldedit/entity/metadata/EntityType.java | 6 ++++++ .../com/sk89q/worldedit/forge/ForgeEntityType.java | 5 +++++ 6 files changed, 35 insertions(+), 13 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitEntityType.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitEntityType.java index d80526c83b..57e57c29b0 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitEntityType.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitEntityType.java @@ -38,13 +38,14 @@ import org.bukkit.entity.TNTPrimed; import org.bukkit.entity.Tameable; import org.bukkit.entity.Villager; +import org.bukkit.entity.minecart.ExplosiveMinecart; import static com.google.common.base.Preconditions.checkNotNull; class BukkitEntityType implements EntityType { - private static final org.bukkit.entity.EntityType tntMinecartType = - Enums.findByValue(org.bukkit.entity.EntityType.class, "MINECART_TNT"); + private static final org.bukkit.entity.EntityType armorStandType = + Enums.findByValue(org.bukkit.entity.EntityType.class, "ARMOR_STAND"); private final Entity entity; @@ -95,7 +96,7 @@ public boolean isMinecart() { @Override public boolean isTNT() { - return entity instanceof TNTPrimed || entity.getType() == tntMinecartType; + return entity instanceof TNTPrimed || entity instanceof ExplosiveMinecart; } @Override @@ -137,4 +138,9 @@ public boolean isTamed() { public boolean isTagged() { return entity instanceof LivingEntity && ((LivingEntity) entity).getCustomName() != null; } + + @Override + public boolean isArmorStand() { + return entity.getType() == armorStandType; + } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java index 1ce10523ed..a6f2c2d249 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java @@ -22,12 +22,7 @@ import com.sk89q.minecraft.util.commands.Command; import com.sk89q.minecraft.util.commands.CommandContext; import com.sk89q.minecraft.util.commands.CommandPermissions; -import com.sk89q.worldedit.EditSession; -import com.sk89q.worldedit.LocalConfiguration; -import com.sk89q.worldedit.LocalSession; -import com.sk89q.worldedit.Vector; -import com.sk89q.worldedit.WorldEdit; -import com.sk89q.worldedit.WorldEditException; +import com.sk89q.worldedit.*; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BlockID; import com.sk89q.worldedit.command.tool.BrushTool; @@ -229,10 +224,10 @@ public void gravityBrush(Player player, LocalSession session, EditSession editSe @Command( aliases = { "butcher", "kill" }, usage = "[radius]", - flags = "plangbtf", + flags = "plangbtfr", desc = "Butcher brush", help = "Kills nearby mobs within the specified radius.\n" + - "Flags:" + + "Flags:\n" + " -p also kills pets.\n" + " -n also kills NPCs.\n" + " -g also kills Golems.\n" + @@ -240,6 +235,7 @@ public void gravityBrush(Player player, LocalSession session, EditSession editSe " -b also kills ambient mobs.\n" + " -t also kills mobs with name tags.\n" + " -f compounds all previous flags.\n" + + " -r also destroys armor stands.\n" + " -l currently does nothing.", min = 0, max = 1 diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java index 0c72f4cbaa..86ee9d232f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java @@ -366,11 +366,11 @@ public void extinguish(Player player, LocalSession session, EditSession editSess @Command( aliases = { "butcher" }, usage = "[radius]", - flags = "plangbtf", + flags = "plangbtfr", desc = "Kill all or nearby mobs", help = "Kills nearby mobs, based on radius, if none is given uses default in configuration.\n" + - "Flags:" + + "Flags:\n" + " -p also kills pets.\n" + " -n also kills NPCs.\n" + " -g also kills Golems.\n" + @@ -378,6 +378,7 @@ public void extinguish(Player player, LocalSession session, EditSession editSess " -b also kills ambient mobs.\n" + " -t also kills mobs with name tags.\n" + " -f compounds all previous flags.\n" + + " -r also destroys armor stands.\n" + " -l currently does nothing.", min = 0, max = 1 diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/CreatureButcher.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/CreatureButcher.java index 822389bbe2..7623d338e1 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/CreatureButcher.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/CreatureButcher.java @@ -41,6 +41,7 @@ final class Flags { public static final int AMBIENT = 1 << 4; public static final int TAGGED = 1 << 5; public static final int FRIENDLY = PETS | NPCS | ANIMALS | GOLEMS | AMBIENT | TAGGED; + public static final int ARMOR_STAND = 1 << 6; public static final int WITH_LIGHTNING = 1 << 20; private Flags() { @@ -74,6 +75,8 @@ public void fromCommand(CommandContext args) { or(Flags.ANIMALS , args.hasFlag('a'), "worldedit.butcher.animals"); or(Flags.AMBIENT , args.hasFlag('b'), "worldedit.butcher.ambient"); or(Flags.TAGGED , args.hasFlag('t'), "worldedit.butcher.tagged"); + or(Flags.ARMOR_STAND , args.hasFlag('r'), "worldedit.butcher.armorstands"); + or(Flags.WITH_LIGHTNING, args.hasFlag('l'), "worldedit.butcher.lightning"); } @@ -87,6 +90,7 @@ public boolean apply(Entity entity) throws WorldEditException { boolean killGolems = (flags & Flags.GOLEMS) != 0; boolean killAmbient = (flags & Flags.AMBIENT) != 0; boolean killTagged = (flags & Flags.TAGGED) != 0; + boolean killArmorStands = (flags & Flags.ARMOR_STAND) != 0; EntityType type = entity.getFacet(EntityType.class); @@ -126,6 +130,10 @@ public boolean apply(Entity entity) throws WorldEditException { return false; } + if (!killArmorStands && type.isArmorStand()) { + return false; + } + entity.remove(); return true; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/entity/metadata/EntityType.java b/worldedit-core/src/main/java/com/sk89q/worldedit/entity/metadata/EntityType.java index a122254145..f13cfd8089 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/entity/metadata/EntityType.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/entity/metadata/EntityType.java @@ -148,4 +148,10 @@ public interface EntityType { */ boolean isTagged(); + /** + * Test whether the entity is an armor stand. + * + * @return true if an armor stand + */ + boolean isArmorStand(); } 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 9db2e7431b..4888c748d0 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 @@ -135,4 +135,9 @@ public boolean isTamed() { public boolean isTagged() { return entity instanceof EntityLiving && ((EntityLiving) entity).hasCustomNameTag(); } + + @Override + public boolean isArmorStand() { + return false; // TODO re-add when forge version is updated to 1.8: entity instanceof EntityArmorStand; + } } From ddc741147e49391a61c1a575de78a755f1592ee8 Mon Sep 17 00:00:00 2001 From: wizjany Date: Fri, 23 Jan 2015 00:28:05 -0500 Subject: [PATCH 10/21] Fix button rotation, add support for up/down flipping and restore unit test functionality. --- .../com/sk89q/worldedit/blocks/BlockData.java | 62 +++++++++++++++---- .../com/sk89q/worldedit/blocks/BlockType.java | 4 ++ .../worldedit/world/registry/blocks.json | 8 +-- .../transform/BlockTransformExtentTest.java | 2 - 4 files changed, 59 insertions(+), 17 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BlockData.java b/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BlockData.java index f7f4608927..23bc912620 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BlockData.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BlockData.java @@ -95,12 +95,22 @@ public static int rotate90(int type, int data) { } break; - case BlockID.LEVER: case BlockID.STONE_BUTTON: - case BlockID.WOODEN_BUTTON: + case BlockID.WOODEN_BUTTON: { + int thrown = data & 0x8; + switch (data & ~0x8) { + case 1: return 3 | thrown; + case 2: return 4 | thrown; + case 3: return 2 | thrown; + case 4: return 1 | thrown; + // 0 and 5 are vertical + } + break; + } + + case BlockID.LEVER: { int thrown = data & 0x8; - int withoutThrown = data & ~0x8; - switch (withoutThrown) { + switch (data & ~0x8) { case 1: return 3 | thrown; case 2: return 4 | thrown; case 3: return 2 | thrown; @@ -111,6 +121,7 @@ public static int rotate90(int type, int data) { case 0: return 7 | thrown; } break; + } case BlockID.WOODEN_DOOR: case BlockID.IRON_DOOR: @@ -316,12 +327,22 @@ public static int rotate90Reverse(int type, int data) { } break; - case BlockID.LEVER: case BlockID.STONE_BUTTON: - case BlockID.WOODEN_BUTTON: + case BlockID.WOODEN_BUTTON: { int thrown = data & 0x8; - int withoutThrown = data & ~0x8; - switch (withoutThrown) { + switch (data & ~0x8) { + case 3: return 1 | thrown; + case 4: return 2 | thrown; + case 2: return 3 | thrown; + case 1: return 4 | thrown; + // 0 and 5 are vertical + } + break; + } + + case BlockID.LEVER: { + int thrown = data & 0x8; + switch (data & ~0x8) { case 3: return 1 | thrown; case 4: return 2 | thrown; case 2: return 3 | thrown; @@ -332,6 +353,7 @@ public static int rotate90Reverse(int type, int data) { case 7: return 0 | thrown; } break; + } case BlockID.WOODEN_DOOR: case BlockID.IRON_DOOR: @@ -509,11 +531,29 @@ public static int flip(int type, int data, FlipDirection direction) { case BlockID.REDSTONE_TORCH_OFF: case BlockID.REDSTONE_TORCH_ON: if (data < 1 || data > 4) break; - /* FALL-THROUGH */ + switch (data) { + case 1: return data + flipX; + case 2: return data - flipX; + case 3: return data + flipZ; + case 4: return data - flipZ; + } + break; - case BlockID.LEVER: case BlockID.STONE_BUTTON: - case BlockID.WOODEN_BUTTON: + case BlockID.WOODEN_BUTTON: { + switch (data & ~0x8) { + case 1: return data + flipX; + case 2: return data - flipX; + case 3: return data + flipZ; + case 4: return data - flipZ; + case 0: + case 5: + return data ^ (flipY * 5); + } + break; + } + + case BlockID.LEVER: switch (data & ~0x8) { case 1: return data + flipX; case 2: return data - flipX; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BlockType.java b/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BlockType.java index e898eb6005..eb83208a7e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BlockType.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BlockType.java @@ -1842,6 +1842,10 @@ public static BaseItemStack getBlockDrop(int id, short data) { addCardinals(BlockID.STONE_BUTTON, offset + 4, offset + 1, offset + 3, offset + 2); addCardinals(BlockID.WOODEN_BUTTON, offset + 4, offset + 1, offset + 3, offset + 2); } + dataAttachments.put(typeDataKey(BlockID.STONE_BUTTON, 0), PlayerDirection.UP); + dataAttachments.put(typeDataKey(BlockID.STONE_BUTTON, 5), PlayerDirection.DOWN); + dataAttachments.put(typeDataKey(BlockID.WOODEN_BUTTON, 0), PlayerDirection.UP); + dataAttachments.put(typeDataKey(BlockID.WOODEN_BUTTON, 5), PlayerDirection.DOWN); nonDataAttachments.put(BlockID.CACTUS, PlayerDirection.DOWN); nonDataAttachments.put(BlockID.REED, PlayerDirection.DOWN); nonDataAttachments.put(BlockID.CAKE_BLOCK, PlayerDirection.DOWN); diff --git a/worldedit-core/src/main/resources/com/sk89q/worldedit/world/registry/blocks.json b/worldedit-core/src/main/resources/com/sk89q/worldedit/world/registry/blocks.json index f4a08d7362..f745e2a097 100644 --- a/worldedit-core/src/main/resources/com/sk89q/worldedit/world/registry/blocks.json +++ b/worldedit-core/src/main/resources/com/sk89q/worldedit/world/registry/blocks.json @@ -2755,8 +2755,8 @@ "values": { "down": { "data": 0, "direction": [0, -1, 0] }, "east": { "data": 1, "direction": [1, 0, 0] }, - "south": { "data": 2, "direction": [0, 0, 1] }, - "west": { "data": 3, "direction": [-1, 0, 0] }, + "west": { "data": 2, "direction": [-1, 0, 0] }, + "south": { "data": 3, "direction": [0, 0, 1] }, "north": { "data": 4, "direction": [0, 0, -1] }, "up": { "data": 5, "direction": [0, 1, 0] } } @@ -4943,8 +4943,8 @@ "values": { "down": { "data": 0, "direction": [0, -1, 0] }, "east": { "data": 1, "direction": [1, 0, 0] }, - "south": { "data": 2, "direction": [0, 0, 1] }, - "west": { "data": 3, "direction": [-1, 0, 0] }, + "west": { "data": 2, "direction": [-1, 0, 0] }, + "south": { "data": 3, "direction": [0, 0, 1] }, "north": { "data": 4, "direction": [0, 0, -1] }, "up": { "data": 5, "direction": [0, 1, 0] } } diff --git a/worldedit-core/src/test/java/com/sk89q/worldedit/extent/transform/BlockTransformExtentTest.java b/worldedit-core/src/test/java/com/sk89q/worldedit/extent/transform/BlockTransformExtentTest.java index b3ae0763fe..7da91e5f72 100644 --- a/worldedit-core/src/test/java/com/sk89q/worldedit/extent/transform/BlockTransformExtentTest.java +++ b/worldedit-core/src/test/java/com/sk89q/worldedit/extent/transform/BlockTransformExtentTest.java @@ -46,8 +46,6 @@ public void setUp() throws Exception { ignored.add(BlockType.BED); // Broken in existing rotation code? ignored.add(BlockType.WOODEN_DOOR); // Complicated ignored.add(BlockType.IRON_DOOR); // Complicated - ignored.add(BlockType.STONE_BUTTON); // Existing rotation code doesn't handle down/up directions - ignored.add(BlockType.WOODEN_BUTTON); // Existing rotation code doesn't handle down/up directions ignored.add(BlockType.END_PORTAL); // Not supported in existing rotation code } From 06f59c6576e8ca7bd36e6c66a3a935f06935f968 Mon Sep 17 00:00:00 2001 From: Kenzie Togami Date: Thu, 12 Feb 2015 13:30:49 -0800 Subject: [PATCH 11/21] Force Guava 18 --- build.gradle | 6 ++++++ worldedit-core/build.gradle | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 172911e8cb..1e5ef96344 100644 --- a/build.gradle +++ b/build.gradle @@ -19,6 +19,12 @@ buildscript { jcenter() } + configurations.all { + resolutionStrategy { + force 'com.google.guava:guava:18.0' + } + } + dependencies { classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.0' classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:3.0.1' diff --git a/worldedit-core/build.gradle b/worldedit-core/build.gradle index 079e3c1248..66ec06d399 100644 --- a/worldedit-core/build.gradle +++ b/worldedit-core/build.gradle @@ -5,7 +5,7 @@ dependencies { compile 'de.schlichtherle:truezip:6.8.3' compile 'rhino:js:1.7R2' compile 'org.yaml:snakeyaml:1.9' - compile 'com.google.guava:guava:17.0' + compile 'com.google.guava:guava:18.0' compile 'com.sk89q:jchronic:0.2.4a' compile 'com.google.code.findbugs:jsr305:1.3.9' compile 'com.thoughtworks.paranamer:paranamer:2.6' From 7257c7bb2b0cb22c7411ad9abc506454f1d9a044 Mon Sep 17 00:00:00 2001 From: sk89q Date: Fri, 20 Feb 2015 21:09:48 -0800 Subject: [PATCH 12/21] Don't transform entity positions if the isIdentity() == true. --- .../function/entity/ExtentEntityCopy.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/entity/ExtentEntityCopy.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/entity/ExtentEntityCopy.java index d172d10c6a..dde39bc015 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/entity/ExtentEntityCopy.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/entity/ExtentEntityCopy.java @@ -88,13 +88,19 @@ public void setRemoving(boolean removing) { public boolean apply(Entity entity) throws WorldEditException { BaseEntity state = entity.getState(); if (state != null) { - Location location = entity.getLocation(); - Vector newPosition = transform.apply(location.toVector().subtract(from)); - Vector newDirection = transform.apply(location.getDirection()).subtract(transform.apply(Vector.ZERO)).normalize(); - Location newLocation = new Location(destination, newPosition.add(to), newDirection); - - // Some entities store their position data in NBT - state = transformNbtData(state); + Location newLocation; + + if (!transform.isIdentity()) { + Location location = entity.getLocation(); + Vector newPosition = transform.apply(location.toVector().subtract(from)); + Vector newDirection = transform.apply(location.getDirection()).subtract(transform.apply(Vector.ZERO)).normalize(); + newLocation = new Location(destination, newPosition.add(to), newDirection); + + // Some entities store their position data in NBT + state = transformNbtData(state); + } else { + newLocation = entity.getLocation(); + } boolean success = destination.createEntity(newLocation, state) != null; From 20093440583af0b3d871be6732fe54fb9629b004 Mon Sep 17 00:00:00 2001 From: sk89q Date: Fri, 20 Feb 2015 21:23:54 -0800 Subject: [PATCH 13/21] Fix entity rotation. --- .../sk89q/worldedit/function/entity/ExtentEntityCopy.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/entity/ExtentEntityCopy.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/entity/ExtentEntityCopy.java index dde39bc015..134e10bd9f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/entity/ExtentEntityCopy.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/entity/ExtentEntityCopy.java @@ -92,9 +92,10 @@ public boolean apply(Entity entity) throws WorldEditException { if (!transform.isIdentity()) { Location location = entity.getLocation(); - Vector newPosition = transform.apply(location.toVector().subtract(from)); + Vector pivot = from.round().add(0.5, 0.5, 0.5); + Vector newPosition = transform.apply(location.toVector().subtract(pivot)); Vector newDirection = transform.apply(location.getDirection()).subtract(transform.apply(Vector.ZERO)).normalize(); - newLocation = new Location(destination, newPosition.add(to), newDirection); + newLocation = new Location(destination, newPosition.add(to.round().add(0.5, 0.5, 0.5)), newDirection); // Some entities store their position data in NBT state = transformNbtData(state); From 8b2bf84b5e6107310cf9901e209b81168932da9c Mon Sep 17 00:00:00 2001 From: Dumbo52 Date: Sat, 21 Feb 2015 17:52:22 -0500 Subject: [PATCH 14/21] Fix imprecise rotations bug. The bug this fixes is documented here: http://youtrack.sk89q.com/issue/WORLDEDIT-3220 --- .../com/sk89q/worldedit/math/MathUtils.java | 58 +++++++++++++++++++ .../math/transform/AffineTransform.java | 16 +++-- 2 files changed, 65 insertions(+), 9 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/MathUtils.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/MathUtils.java index 65a72a72c7..80f310af55 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/MathUtils.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/MathUtils.java @@ -47,4 +47,62 @@ public static int divisorMod(int a, int n) { return (int) (a - n * Math.floor(Math.floor(a) / n)); } + /** + * Returns the cosine of an angle given in degrees. This is better than + * just {@code Math.cos(Math.toRadians(degrees))} because it provides a + * more accurate result for angles divisible by 90 degrees. + * + * @param degrees the angle + * @return the cosine of the given angle + */ + public static double dCos(double degrees) { + int dInt = (int) degrees; + if (degrees == dInt && dInt % 90 == 0) { + dInt %= 360; + if (dInt < 0) { + dInt += 360; + } + switch (dInt) { + case 0: + return 1.0; + case 90: + return 0.0; + case 180: + return -1.0; + case 270: + return 0.0; + } + } + return Math.cos(Math.toRadians(degrees)); + } + + /** + * Returns the sine of an angle given in degrees. This is better than just + * {@code Math.cos(Math.toRadians(degrees))} because it provides a more + * accurate result for angles divisible by 90 degrees. + * + * @param degrees the angle + * @return the sine of the given angle + */ + public static double dSin(double degrees) { + int dInt = (int) degrees; + if (degrees == dInt && dInt % 90 == 0) { + dInt %= 360; + if (dInt < 0) { + dInt += 360; + } + switch (dInt) { + case 0: + return 0.0; + case 90: + return 1.0; + case 180: + return 0.0; + case 270: + return -1.0; + } + } + return Math.cos(Math.toRadians(degrees)); + } + } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/AffineTransform.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/AffineTransform.java index aabcbd1ad0..41d85904a6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/AffineTransform.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/AffineTransform.java @@ -20,6 +20,7 @@ package com.sk89q.worldedit.math.transform; import com.sk89q.worldedit.Vector; +import com.sk89q.worldedit.math.MathUtils; /** * An affine transform. @@ -244,9 +245,8 @@ public AffineTransform translate(double x, double y, double z) { } public AffineTransform rotateX(double theta) { - theta = Math.toRadians(theta); - double cot = Math.cos(theta); - double sit = Math.sin(theta); + double cot = MathUtils.dCos(theta); + double sit = MathUtils.dSin(theta); return concatenate( new AffineTransform( 1, 0, 0, 0, @@ -255,9 +255,8 @@ public AffineTransform rotateX(double theta) { } public AffineTransform rotateY(double theta) { - theta = Math.toRadians(theta); - double cot = Math.cos(theta); - double sit = Math.sin(theta); + double cot = MathUtils.dCos(theta); + double sit = MathUtils.dSin(theta); return concatenate( new AffineTransform( cot, 0, sit, 0, @@ -266,9 +265,8 @@ public AffineTransform rotateY(double theta) { } public AffineTransform rotateZ(double theta) { - theta = Math.toRadians(theta); - double cot = Math.cos(theta); - double sit = Math.sin(theta); + double cot = MathUtils.dCos(theta); + double sit = MathUtils.dSin(theta); return concatenate( new AffineTransform( cot, -sit, 0, 0, From 55f1f42ebf50ca2b4ba9a1348bfb1056163d29ba Mon Sep 17 00:00:00 2001 From: Dumbo52 Date: Sat, 28 Feb 2015 18:46:49 -0500 Subject: [PATCH 15/21] Add stone to usesData HashSet. --- .../src/main/java/com/sk89q/worldedit/blocks/BlockType.java | 1 + 1 file changed, 1 insertion(+) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BlockType.java b/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BlockType.java index eb83208a7e..81af750206 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BlockType.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BlockType.java @@ -728,6 +728,7 @@ public double centralTopLimit() { */ private static final Set usesData = new HashSet(); static { + usesData.add(BlockID.STONE); usesData.add(BlockID.DIRT); usesData.add(BlockID.WOOD); usesData.add(BlockID.SAPLING); From 440cee35393ecc385fefe9732e05a893497f78ee Mon Sep 17 00:00:00 2001 From: Dumbo52 Date: Fri, 6 Mar 2015 01:42:22 -0500 Subject: [PATCH 16/21] Add banners to usesDamageValue HashSet. --- .../src/main/java/com/sk89q/worldedit/blocks/ItemType.java | 1 + 1 file changed, 1 insertion(+) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/ItemType.java b/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/ItemType.java index 36b90e1332..e312ae2868 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/ItemType.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/ItemType.java @@ -680,6 +680,7 @@ public static boolean shouldNotStack(int id) { usesDamageValue.add(ItemID.GOLD_APPLE); usesDamageValue.add(ItemID.RAW_FISH); usesDamageValue.add(ItemID.COOKED_FISH); + usesDamageValue.add(ItemID.BANNER); } /** From 2fedcf8019b0bd07ecd0c470a2ec36bd3b53077e Mon Sep 17 00:00:00 2001 From: Wizjany Date: Fri, 6 Mar 2015 15:22:55 -0500 Subject: [PATCH 17/21] Add rotation values to lit redstone torches. Fixes WORLDEDIT-3273. --- .../com/sk89q/worldedit/world/registry/blocks.json | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/worldedit-core/src/main/resources/com/sk89q/worldedit/world/registry/blocks.json b/worldedit-core/src/main/resources/com/sk89q/worldedit/world/registry/blocks.json index f745e2a097..9dd4bc7bff 100644 --- a/worldedit-core/src/main/resources/com/sk89q/worldedit/world/registry/blocks.json +++ b/worldedit-core/src/main/resources/com/sk89q/worldedit/world/registry/blocks.json @@ -2720,6 +2720,17 @@ "legacyId": 76, "id": "minecraft:redstone_torch", "unlocalizedName": "tile.notGate", + "states": { + "facing": { + "values": { + "east": { "data": 1, "direction": [1, 0, 0] }, + "west": { "data": 2, "direction": [-1, 0, 0] }, + "north": { "data": 3, "direction": [0, 0, -1] }, + "south": { "data": 4, "direction": [0, 0, 1] }, + "up": { "data": 5, "direction": [0, 1, 0] } + } + } + }, "material": { "renderedAsNormalBlock": false, "fullCube": false, @@ -6010,4 +6021,4 @@ "replacedDuringPlacement": false } } -] \ No newline at end of file +] From 0d347a3837b20b47f46cf8c1051a0a63cc33708c Mon Sep 17 00:00:00 2001 From: flamin_scotsman Date: Tue, 10 Mar 2015 21:51:35 +0000 Subject: [PATCH 18/21] Fix incorrect instantiation of BlockBag and EditSession in two of the tools. Used EditSessionFactory rather than getting the EditSession from the local session. --- .../com/sk89q/worldedit/command/tool/BlockReplacer.java | 7 +++---- .../java/com/sk89q/worldedit/command/tool/QueryTool.java | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockReplacer.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockReplacer.java index d1af045bbe..8d4f718c4d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockReplacer.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockReplacer.java @@ -46,10 +46,9 @@ public boolean canUse(Actor player) { @Override public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) { -BlockBag bag = session.getBlockBag(player); + BlockBag bag = session.getBlockBag(player); - World world = (World) clicked.getExtent(); - EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, -1, bag, player); + EditSession editSession = session.createEditSession(player); try { editSession.setBlock(clicked.toVector(), targetBlock); @@ -68,7 +67,7 @@ public boolean actPrimary(Platform server, LocalConfiguration config, Player pla @Override public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) { World world = (World) clicked.getExtent(); - EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, -1, player); + EditSession editSession = session.createEditSession(player); targetBlock = (editSession).getBlock(clicked.toVector()); BlockType type = BlockType.fromID(targetBlock.getType()); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/QueryTool.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/QueryTool.java index 6aa5262a01..aa039de9c9 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/QueryTool.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/QueryTool.java @@ -43,7 +43,7 @@ public boolean canUse(Actor player) { public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) { World world = (World) clicked.getExtent(); - EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, 0, player); + EditSession editSession = session.createEditSession(player); BaseBlock block = (editSession).rawGetBlock(clicked.toVector()); BlockType type = BlockType.fromID(block.getType()); From f71d037a35476d11ff56745cbcea67ceeb940478 Mon Sep 17 00:00:00 2001 From: flamin_scotsman Date: Tue, 10 Mar 2015 21:55:51 +0000 Subject: [PATCH 19/21] Change cycler tool to use EditSession rather than changing the world directly --- .../worldedit/command/tool/BlockDataCyler.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockDataCyler.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockDataCyler.java index 41bff5f2a8..60045d3da3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockDataCyler.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockDataCyler.java @@ -19,9 +19,12 @@ 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.MaxChangedBlocksException; import com.sk89q.worldedit.blocks.BaseBlock; +import com.sk89q.worldedit.blocks.BlockData; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Platform; @@ -54,12 +57,19 @@ private boolean handleCycle(Platform server, LocalConfiguration config, } int increment = forward ? 1 : -1; - data = (new BaseBlock(type, data)).cycleData(increment); + BaseBlock block = new BaseBlock(type, BlockData.cycle(type, data, increment)); + EditSession editSession = session.createEditSession(player); if (data < 0) { player.printError("That block's data cannot be cycled!"); } else { - world.setBlockData(clicked.toVector(), data); + try { + editSession.setBlock(clicked.toVector(), block); + } catch (MaxChangedBlocksException e) { + player.printError("Max blocks change limit reached."); + } finally { + session.remember(editSession); + } } return true; From 604b1d8515e2658af1cd0aa6670228dd28b366ed Mon Sep 17 00:00:00 2001 From: wizjany Date: Tue, 10 Mar 2015 23:47:56 -0400 Subject: [PATCH 20/21] Added Bukkit adapter for 1.8.3. --- .../bukkit/adapter/impl/Spigot_v1_8_R2.class | Bin 0 -> 14811 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 worldedit-bukkit/src/main/resources/com/sk89q/worldedit/bukkit/adapter/impl/Spigot_v1_8_R2.class diff --git a/worldedit-bukkit/src/main/resources/com/sk89q/worldedit/bukkit/adapter/impl/Spigot_v1_8_R2.class b/worldedit-bukkit/src/main/resources/com/sk89q/worldedit/bukkit/adapter/impl/Spigot_v1_8_R2.class new file mode 100644 index 0000000000000000000000000000000000000000..4364089e01c6f5c256ae8b284fe826b48c49a0ec GIT binary patch literal 14811 zcmbVT33yc16+Y)?CNFt;Y{4kQ8Z}@DU_cQyi3kCL(Ig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=FNXOO$J(r+?K6+j{wrO6jmX2)+dZCYAl-BFF(-b+xGETNHwdCaV(_S2HUj|5b z*Kehu!Rnnf0~WmkF=Z=a%2hz()rcwE5Kpe9X1$4593MUs%^dLLDMDE8{pc`a}+36AWtl9(JrKY-6Dpn5L+;|$6Hp9=Bj zOn3tjob)Yz4!*V4i8pe@x7RvL)4ClpPXFri3?9=Ogr9eNJ? n1nm=w&NTRJoQ~NKz7-@p4WETr?|y!Rn{)BQL3ORVev$8gorx3D literal 0 HcmV?d00001 From d5914e52e1ab1de54be2afa04aaaa9221e214b81 Mon Sep 17 00:00:00 2001 From: flamin_scotsman Date: Fri, 13 Mar 2015 16:04:55 +0000 Subject: [PATCH 21/21] Fix ExceptionHandler compareTo method. The previous implementation violated the contract that compareTo must be behave the same way when operands are reversed and that it is transitive. Any classes that were not equal, or a superclass of another were returned as being "less than". The new implementation tests if classes are superclasses of each other, otherwise falls back to alphabetical sorting on canonical name. While this did not manifest in 1.6, the replacement sort algorithm in 1.8 (TimSort) caused the sorting to appear random due to apparently contiguous sections being consumed, then sorted in bulk. --- .../util/command/parametric/ExceptionConverterHelper.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/ExceptionConverterHelper.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/ExceptionConverterHelper.java index 177e5a8999..2341e5816a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/ExceptionConverterHelper.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/ExceptionConverterHelper.java @@ -100,8 +100,10 @@ public int compareTo(ExceptionHandler o) { return 0; } else if (cls.isAssignableFrom(o.cls)) { return 1; - } else { + } else if (o.cls.isAssignableFrom(cls)) { return -1; + } else { + return cls.getCanonicalName().compareTo(o.cls.getCanonicalName()); } } }