Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-05 11:00:05 +01:00
Now compiles on Spout and basic block setting works
Dieser Commit ist enthalten in:
Ursprung
a800ced4b9
Commit
718457b1ff
2
pom.xml
2
pom.xml
@ -279,7 +279,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spout</groupId>
|
<groupId>org.spout</groupId>
|
||||||
<artifactId>vanilla</artifactId>
|
<artifactId>vanilla</artifactId>
|
||||||
<version>1.3.2-SNAPSHOT</version>
|
<version>1.4.7-SNAPSHOT</version>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
@ -31,15 +31,15 @@ import com.sk89q.worldedit.cui.CUIEvent;
|
|||||||
|
|
||||||
import org.spout.api.Client;
|
import org.spout.api.Client;
|
||||||
import org.spout.api.chat.style.ChatStyle;
|
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.geo.discrete.Point;
|
||||||
import org.spout.api.inventory.Inventory;
|
|
||||||
import org.spout.api.inventory.ItemStack;
|
import org.spout.api.inventory.ItemStack;
|
||||||
import org.spout.api.entity.Player;
|
import org.spout.api.entity.Player;
|
||||||
import org.spout.vanilla.component.inventory.PlayerInventory;
|
import org.spout.vanilla.api.inventory.Slot;
|
||||||
import org.spout.vanilla.component.living.neutral.Human;
|
import org.spout.vanilla.plugin.component.inventory.PlayerInventory;
|
||||||
import org.spout.vanilla.material.VanillaMaterial;
|
import org.spout.vanilla.plugin.component.living.neutral.Human;
|
||||||
import org.spout.vanilla.material.VanillaMaterials;
|
import org.spout.vanilla.api.material.VanillaMaterial;
|
||||||
|
import org.spout.vanilla.plugin.material.VanillaMaterials;
|
||||||
|
|
||||||
public class SpoutPlayer extends LocalPlayer {
|
public class SpoutPlayer extends LocalPlayer {
|
||||||
private Player player;
|
private Player player;
|
||||||
@ -55,8 +55,11 @@ public class SpoutPlayer extends LocalPlayer {
|
|||||||
@Override
|
@Override
|
||||||
public int getItemInHand() {
|
public int getItemInHand() {
|
||||||
if (player.has(Human.class)) {
|
if (player.has(Human.class)) {
|
||||||
return ((VanillaMaterial) player.get(PlayerInventory.class).getQuickbar()
|
Slot slot = player.get(PlayerInventory.class).getQuickbar().getSelectedSlot();
|
||||||
.getCurrentItem().getMaterial()).getMinecraftId();
|
if (slot.get() == null) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return ((VanillaMaterial) slot.get().getMaterial()).getMinecraftId();
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -33,9 +33,9 @@ import org.spout.api.inventory.Inventory;
|
|||||||
import org.spout.api.inventory.ItemStack;
|
import org.spout.api.inventory.ItemStack;
|
||||||
import org.spout.api.material.Material;
|
import org.spout.api.material.Material;
|
||||||
import org.spout.api.entity.Player;
|
import org.spout.api.entity.Player;
|
||||||
import org.spout.vanilla.component.inventory.PlayerInventory;
|
import org.spout.vanilla.plugin.component.inventory.PlayerInventory;
|
||||||
import org.spout.vanilla.component.living.neutral.Human;
|
import org.spout.vanilla.plugin.component.living.neutral.Human;
|
||||||
import org.spout.vanilla.material.VanillaMaterials;
|
import org.spout.vanilla.plugin.material.VanillaMaterials;
|
||||||
|
|
||||||
public class SpoutPlayerBlockBag extends BlockBag {
|
public class SpoutPlayerBlockBag extends BlockBag {
|
||||||
/**
|
/**
|
||||||
|
@ -32,7 +32,7 @@ import org.spout.api.geo.World;
|
|||||||
import org.spout.api.material.Material;
|
import org.spout.api.material.Material;
|
||||||
import org.spout.api.material.MaterialRegistry;
|
import org.spout.api.material.MaterialRegistry;
|
||||||
import org.spout.api.scheduler.TaskPriority;
|
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.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -76,7 +76,7 @@ public class SpoutServerInterface extends ServerInterface {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int schedule(long delay, long period, Runnable task) {
|
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
|
@Override
|
||||||
|
@ -50,17 +50,18 @@ import org.spout.api.inventory.ItemStack;
|
|||||||
import org.spout.api.material.BlockMaterial;
|
import org.spout.api.material.BlockMaterial;
|
||||||
import org.spout.api.material.Material;
|
import org.spout.api.material.Material;
|
||||||
import org.spout.api.math.Vector3;
|
import org.spout.api.math.Vector3;
|
||||||
import org.spout.vanilla.component.substance.Item;
|
import org.spout.vanilla.plugin.component.substance.Item;
|
||||||
import org.spout.vanilla.component.substance.Painting;
|
import org.spout.vanilla.plugin.component.substance.Painting;
|
||||||
import org.spout.vanilla.component.substance.XPOrb;
|
import org.spout.vanilla.plugin.component.substance.XPOrb;
|
||||||
import org.spout.vanilla.component.substance.object.Tnt;
|
import org.spout.vanilla.plugin.component.substance.object.Tnt;
|
||||||
import org.spout.vanilla.component.substance.object.projectile.Arrow;
|
import org.spout.vanilla.plugin.component.substance.object.projectile.Arrow;
|
||||||
import org.spout.vanilla.component.substance.object.vehicle.Boat;
|
import org.spout.vanilla.plugin.component.substance.object.vehicle.Boat;
|
||||||
import org.spout.vanilla.component.substance.object.vehicle.Minecart;
|
import org.spout.vanilla.plugin.component.substance.object.vehicle.Minecart;
|
||||||
import org.spout.vanilla.material.VanillaMaterial;
|
import org.spout.vanilla.api.material.VanillaMaterial;
|
||||||
import org.spout.vanilla.material.VanillaMaterials;
|
import org.spout.vanilla.plugin.material.VanillaMaterials;
|
||||||
import org.spout.vanilla.world.generator.normal.object.tree.TreeObject;
|
import org.spout.vanilla.plugin.world.generator.normal.object.tree.TreeObject;
|
||||||
import org.spout.vanilla.world.generator.normal.object.tree.SmallTreeObject;
|
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 javax.annotation.Nullable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -97,6 +98,24 @@ public class SpoutWorld extends LocalWorld {
|
|||||||
return world.getName();
|
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.
|
* Set block type.
|
||||||
*
|
*
|
||||||
@ -106,7 +125,7 @@ public class SpoutWorld extends LocalWorld {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlockType(Vector pt, int type) {
|
public boolean setBlockType(Vector pt, int type) {
|
||||||
Material mat = VanillaMaterials.getMaterial((short) type);
|
Material mat = getSpoutMaterial(type);
|
||||||
if (mat != null && mat instanceof BlockMaterial) {
|
if (mat != null && mat instanceof BlockMaterial) {
|
||||||
final int x = pt.getBlockX();
|
final int x = pt.getBlockX();
|
||||||
final int y = pt.getBlockY();
|
final int y = pt.getBlockY();
|
||||||
@ -137,7 +156,7 @@ public class SpoutWorld extends LocalWorld {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean setTypeIdAndData(Vector pt, int type, int data) {
|
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) {
|
if (mat != null && mat instanceof BlockMaterial) {
|
||||||
final int x = pt.getBlockX();
|
final int x = pt.getBlockX();
|
||||||
final int y = pt.getBlockY();
|
final int y = pt.getBlockY();
|
||||||
@ -454,6 +473,7 @@ public class SpoutWorld extends LocalWorld {
|
|||||||
@Override
|
@Override
|
||||||
public boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, Vector pt)
|
public boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, Vector pt)
|
||||||
throws MaxChangedBlocksException {
|
throws MaxChangedBlocksException {
|
||||||
|
//VanillaObjects.byName()
|
||||||
TreeObject tree = new SmallTreeObject(); //TODO: properly check for tree type
|
TreeObject tree = new SmallTreeObject(); //TODO: properly check for tree type
|
||||||
if (!tree.canPlaceObject(world, pt.getBlockX(), pt.getBlockY(), pt.getBlockZ())) {
|
if (!tree.canPlaceObject(world, pt.getBlockX(), pt.getBlockY(), pt.getBlockZ())) {
|
||||||
return false;
|
return false;
|
||||||
@ -722,7 +742,7 @@ public class SpoutWorld extends LocalWorld {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isValidBlockType(int type) {
|
public boolean isValidBlockType(int type) {
|
||||||
return VanillaMaterials.getMaterial((short)type) instanceof BlockMaterial;
|
return getSpoutMaterial(type) instanceof BlockMaterial;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -745,7 +765,7 @@ public class SpoutWorld extends LocalWorld {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMaxY() {
|
public int getMaxY() {
|
||||||
return world.getHeight() - 1;
|
return world.getHeight() - 1; //TODO: We have infinite-height worlds now
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -51,6 +51,11 @@ public class WorldEditCUIMessage implements Message {
|
|||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAsync() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getChannelId() {
|
public int getChannelId() {
|
||||||
return DEFAULT_CHANNEL;
|
return DEFAULT_CHANNEL;
|
||||||
|
@ -144,7 +144,7 @@ public class WorldEditListener implements Listener {
|
|||||||
public void run() {
|
public void run() {
|
||||||
ignoreLeftClickAir = false;
|
ignoreLeftClickAir = false;
|
||||||
}
|
}
|
||||||
}, 100, TaskPriority.NORMAL);
|
}, 100, TaskPriority.NORMAL).getTaskId();
|
||||||
|
|
||||||
if (taskId != -1) {
|
if (taskId != -1) {
|
||||||
ignoreLeftClickAir = true;
|
ignoreLeftClickAir = true;
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren