From 718457b1ff7f6bce1c4b7e36b852ddb09ee26028 Mon Sep 17 00:00:00 2001 From: zml2008 Date: Sat, 19 Jan 2013 18:29:53 -0800 Subject: [PATCH] Now compiles on Spout and basic block setting works --- pom.xml | 2 +- .../sk89q/worldedit/spout/SpoutPlayer.java | 19 ++++--- .../worldedit/spout/SpoutPlayerBlockBag.java | 6 +-- .../worldedit/spout/SpoutServerInterface.java | 4 +- .../com/sk89q/worldedit/spout/SpoutWorld.java | 50 +++++++++++++------ .../worldedit/spout/WorldEditCUIMessage.java | 5 ++ .../worldedit/spout/WorldEditListener.java | 2 +- 7 files changed, 58 insertions(+), 30 deletions(-) diff --git a/pom.xml b/pom.xml index 8d7627e08..da6f4ea8c 100644 --- a/pom.xml +++ b/pom.xml @@ -279,7 +279,7 @@ org.spout vanilla - 1.3.2-SNAPSHOT + 1.4.7-SNAPSHOT true diff --git a/src/spout/java/com/sk89q/worldedit/spout/SpoutPlayer.java b/src/spout/java/com/sk89q/worldedit/spout/SpoutPlayer.java index a87e50dd4..c8be33c54 100644 --- a/src/spout/java/com/sk89q/worldedit/spout/SpoutPlayer.java +++ b/src/spout/java/com/sk89q/worldedit/spout/SpoutPlayer.java @@ -31,15 +31,15 @@ import com.sk89q.worldedit.cui.CUIEvent; import org.spout.api.Client; import org.spout.api.chat.style.ChatStyle; -import org.spout.api.component.components.TransformComponent; +import org.spout.api.component.impl.TransformComponent; import org.spout.api.geo.discrete.Point; -import org.spout.api.inventory.Inventory; import org.spout.api.inventory.ItemStack; import org.spout.api.entity.Player; -import org.spout.vanilla.component.inventory.PlayerInventory; -import org.spout.vanilla.component.living.neutral.Human; -import org.spout.vanilla.material.VanillaMaterial; -import org.spout.vanilla.material.VanillaMaterials; +import org.spout.vanilla.api.inventory.Slot; +import org.spout.vanilla.plugin.component.inventory.PlayerInventory; +import org.spout.vanilla.plugin.component.living.neutral.Human; +import org.spout.vanilla.api.material.VanillaMaterial; +import org.spout.vanilla.plugin.material.VanillaMaterials; public class SpoutPlayer extends LocalPlayer { private Player player; @@ -55,8 +55,11 @@ public class SpoutPlayer extends LocalPlayer { @Override public int getItemInHand() { if (player.has(Human.class)) { - return ((VanillaMaterial) player.get(PlayerInventory.class).getQuickbar() - .getCurrentItem().getMaterial()).getMinecraftId(); + Slot slot = player.get(PlayerInventory.class).getQuickbar().getSelectedSlot(); + if (slot.get() == null) { + return 0; + } + return ((VanillaMaterial) slot.get().getMaterial()).getMinecraftId(); } else { return 0; } diff --git a/src/spout/java/com/sk89q/worldedit/spout/SpoutPlayerBlockBag.java b/src/spout/java/com/sk89q/worldedit/spout/SpoutPlayerBlockBag.java index d81c4547a..9da5ab045 100644 --- a/src/spout/java/com/sk89q/worldedit/spout/SpoutPlayerBlockBag.java +++ b/src/spout/java/com/sk89q/worldedit/spout/SpoutPlayerBlockBag.java @@ -33,9 +33,9 @@ import org.spout.api.inventory.Inventory; import org.spout.api.inventory.ItemStack; import org.spout.api.material.Material; import org.spout.api.entity.Player; -import org.spout.vanilla.component.inventory.PlayerInventory; -import org.spout.vanilla.component.living.neutral.Human; -import org.spout.vanilla.material.VanillaMaterials; +import org.spout.vanilla.plugin.component.inventory.PlayerInventory; +import org.spout.vanilla.plugin.component.living.neutral.Human; +import org.spout.vanilla.plugin.material.VanillaMaterials; public class SpoutPlayerBlockBag extends BlockBag { /** diff --git a/src/spout/java/com/sk89q/worldedit/spout/SpoutServerInterface.java b/src/spout/java/com/sk89q/worldedit/spout/SpoutServerInterface.java index 65ec39fb3..2dd1331e9 100644 --- a/src/spout/java/com/sk89q/worldedit/spout/SpoutServerInterface.java +++ b/src/spout/java/com/sk89q/worldedit/spout/SpoutServerInterface.java @@ -32,7 +32,7 @@ import org.spout.api.geo.World; import org.spout.api.material.Material; import org.spout.api.material.MaterialRegistry; import org.spout.api.scheduler.TaskPriority; -import org.spout.vanilla.material.VanillaMaterial; +import org.spout.vanilla.api.material.VanillaMaterial; import java.lang.reflect.Method; import java.util.ArrayList; @@ -76,7 +76,7 @@ public class SpoutServerInterface extends ServerInterface { @Override public int schedule(long delay, long period, Runnable task) { - return game.getScheduler().scheduleSyncRepeatingTask(plugin, task, delay * 50, period * 50, TaskPriority.NORMAL); + return game.getScheduler().scheduleSyncRepeatingTask(plugin, task, delay * 50, period * 50, TaskPriority.NORMAL).getTaskId(); } @Override diff --git a/src/spout/java/com/sk89q/worldedit/spout/SpoutWorld.java b/src/spout/java/com/sk89q/worldedit/spout/SpoutWorld.java index 28b870c01..1561f1460 100644 --- a/src/spout/java/com/sk89q/worldedit/spout/SpoutWorld.java +++ b/src/spout/java/com/sk89q/worldedit/spout/SpoutWorld.java @@ -50,17 +50,18 @@ import org.spout.api.inventory.ItemStack; import org.spout.api.material.BlockMaterial; import org.spout.api.material.Material; import org.spout.api.math.Vector3; -import org.spout.vanilla.component.substance.Item; -import org.spout.vanilla.component.substance.Painting; -import org.spout.vanilla.component.substance.XPOrb; -import org.spout.vanilla.component.substance.object.Tnt; -import org.spout.vanilla.component.substance.object.projectile.Arrow; -import org.spout.vanilla.component.substance.object.vehicle.Boat; -import org.spout.vanilla.component.substance.object.vehicle.Minecart; -import org.spout.vanilla.material.VanillaMaterial; -import org.spout.vanilla.material.VanillaMaterials; -import org.spout.vanilla.world.generator.normal.object.tree.TreeObject; -import org.spout.vanilla.world.generator.normal.object.tree.SmallTreeObject; +import org.spout.vanilla.plugin.component.substance.Item; +import org.spout.vanilla.plugin.component.substance.Painting; +import org.spout.vanilla.plugin.component.substance.XPOrb; +import org.spout.vanilla.plugin.component.substance.object.Tnt; +import org.spout.vanilla.plugin.component.substance.object.projectile.Arrow; +import org.spout.vanilla.plugin.component.substance.object.vehicle.Boat; +import org.spout.vanilla.plugin.component.substance.object.vehicle.Minecart; +import org.spout.vanilla.api.material.VanillaMaterial; +import org.spout.vanilla.plugin.material.VanillaMaterials; +import org.spout.vanilla.plugin.world.generator.normal.object.tree.TreeObject; +import org.spout.vanilla.plugin.world.generator.normal.object.tree.SmallTreeObject; +import org.spout.vanilla.plugin.world.generator.object.VanillaObjects; import javax.annotation.Nullable; import java.util.ArrayList; @@ -97,6 +98,24 @@ public class SpoutWorld extends LocalWorld { return world.getName(); } + public Material getSpoutMaterial(int id) { + switch (id) { + case 0: + return BlockMaterial.AIR; + default: + return VanillaMaterials.getMaterial((short) id); + } + } + + public Material getSpoutMaterial(int id, int data) { + switch (id) { + case 0: + return BlockMaterial.AIR; + default: + return VanillaMaterials.getMaterial((short) id, (short) data); + } + } + /** * Set block type. * @@ -106,7 +125,7 @@ public class SpoutWorld extends LocalWorld { */ @Override public boolean setBlockType(Vector pt, int type) { - Material mat = VanillaMaterials.getMaterial((short) type); + Material mat = getSpoutMaterial(type); if (mat != null && mat instanceof BlockMaterial) { final int x = pt.getBlockX(); final int y = pt.getBlockY(); @@ -137,7 +156,7 @@ public class SpoutWorld extends LocalWorld { */ @Override public boolean setTypeIdAndData(Vector pt, int type, int data) { - Material mat = VanillaMaterials.getMaterial((short) type, (short) data); + Material mat = getSpoutMaterial(type, data); if (mat != null && mat instanceof BlockMaterial) { final int x = pt.getBlockX(); final int y = pt.getBlockY(); @@ -454,6 +473,7 @@ public class SpoutWorld extends LocalWorld { @Override public boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, Vector pt) throws MaxChangedBlocksException { + //VanillaObjects.byName() TreeObject tree = new SmallTreeObject(); //TODO: properly check for tree type if (!tree.canPlaceObject(world, pt.getBlockX(), pt.getBlockY(), pt.getBlockZ())) { return false; @@ -722,7 +742,7 @@ public class SpoutWorld extends LocalWorld { */ @Override public boolean isValidBlockType(int type) { - return VanillaMaterials.getMaterial((short)type) instanceof BlockMaterial; + return getSpoutMaterial(type) instanceof BlockMaterial; } @Override @@ -745,7 +765,7 @@ public class SpoutWorld extends LocalWorld { @Override public int getMaxY() { - return world.getHeight() - 1; + return world.getHeight() - 1; //TODO: We have infinite-height worlds now } @Override diff --git a/src/spout/java/com/sk89q/worldedit/spout/WorldEditCUIMessage.java b/src/spout/java/com/sk89q/worldedit/spout/WorldEditCUIMessage.java index 345a140da..ccc8ae5ac 100644 --- a/src/spout/java/com/sk89q/worldedit/spout/WorldEditCUIMessage.java +++ b/src/spout/java/com/sk89q/worldedit/spout/WorldEditCUIMessage.java @@ -51,6 +51,11 @@ public class WorldEditCUIMessage implements Message { .toString(); } + @Override + public boolean isAsync() { + return false; + } + @Override public int getChannelId() { return DEFAULT_CHANNEL; diff --git a/src/spout/java/com/sk89q/worldedit/spout/WorldEditListener.java b/src/spout/java/com/sk89q/worldedit/spout/WorldEditListener.java index 59f7b7151..ebc5597ff 100644 --- a/src/spout/java/com/sk89q/worldedit/spout/WorldEditListener.java +++ b/src/spout/java/com/sk89q/worldedit/spout/WorldEditListener.java @@ -144,7 +144,7 @@ public class WorldEditListener implements Listener { public void run() { ignoreLeftClickAir = false; } - }, 100, TaskPriority.NORMAL); + }, 100, TaskPriority.NORMAL).getTaskId(); if (taskId != -1) { ignoreLeftClickAir = true;