mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-11 20:13:55 +00:00
Current progress with update
This commit is contained in:
@ -31,7 +31,9 @@ import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
||||
import com.sk89q.worldedit.bukkit.adapter.CachedBukkitAdapter;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.internal.Constants;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.registry.state.*;
|
||||
import com.sk89q.worldedit.util.Direction;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
@ -411,15 +413,15 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit
|
||||
}
|
||||
return new CompoundTag(values);
|
||||
} else if (foreign instanceof NBTTagByte) {
|
||||
return new ByteTag(((NBTTagByte) foreign).g()); // getByte
|
||||
return new ByteTag(((NBTTagByte) foreign).asByte()); // getByte
|
||||
} else if (foreign instanceof NBTTagByteArray) {
|
||||
return new ByteArrayTag(((NBTTagByteArray) foreign).c()); // data
|
||||
} else if (foreign instanceof NBTTagDouble) {
|
||||
return new DoubleTag(((NBTTagDouble) foreign).asDouble()); // getDouble
|
||||
} else if (foreign instanceof NBTTagFloat) {
|
||||
return new FloatTag(((NBTTagFloat) foreign).i()); // getFloat
|
||||
return new FloatTag(((NBTTagFloat) foreign).asByte()); // getFloat
|
||||
} else if (foreign instanceof NBTTagInt) {
|
||||
return new IntTag(((NBTTagInt) foreign).e()); // getInt
|
||||
return new IntTag(((NBTTagInt) foreign).asInt()); // getInt
|
||||
} else if (foreign instanceof NBTTagIntArray) {
|
||||
return new IntArrayTag(((NBTTagIntArray) foreign).d()); // data
|
||||
} else if (foreign instanceof NBTTagList) {
|
||||
@ -430,11 +432,11 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit
|
||||
return new ListTag(ByteTag.class, new ArrayList<ByteTag>());
|
||||
}
|
||||
} else if (foreign instanceof NBTTagLong) {
|
||||
return new LongTag(((NBTTagLong) foreign).d()); // getLong
|
||||
return new LongTag(((NBTTagLong) foreign).asLong()); // getLong
|
||||
} else if (foreign instanceof NBTTagShort) {
|
||||
return new ShortTag(((NBTTagShort) foreign).f()); // getShort
|
||||
return new ShortTag(((NBTTagShort) foreign).asShort()); // getShort
|
||||
} else if (foreign instanceof NBTTagString) {
|
||||
return new StringTag(foreign.b_()); // data
|
||||
return new StringTag(foreign.asString()); // data
|
||||
} else if (foreign instanceof NBTTagEnd) {
|
||||
return EndTag.INSTANCE;
|
||||
} else {
|
||||
@ -539,4 +541,10 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit
|
||||
BlockMaterial_1_13 material = (BlockMaterial_1_13) state.getMaterial();
|
||||
return material.getCraftBlockData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendFakeNBT(Player player, BlockVector3 pos, CompoundTag nbtData) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
@ -3,7 +3,8 @@ package com.boydti.fawe.bukkit.filter;
|
||||
import com.boydti.fawe.regions.general.CuboidRegionFilter;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.sk89q.worldedit.BlockVector2D;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Collection;
|
||||
import me.ryanhamshire.GriefPrevention.Claim;
|
||||
@ -34,8 +35,8 @@ public class GriefPreventionFilter extends CuboidRegionFilter {
|
||||
org.bukkit.Location bot = claim.getGreaterBoundaryCorner();
|
||||
if (world.equals(bot.getWorld())) {
|
||||
org.bukkit.Location top = claim.getGreaterBoundaryCorner();
|
||||
BlockVector2D pos1 = new BlockVector2D(bot.getBlockX(), bot.getBlockZ());
|
||||
BlockVector2D pos2 = new BlockVector2D(top.getBlockX(), top.getBlockZ());
|
||||
BlockVector2 pos1 = new BlockVector2(bot.getBlockX(), bot.getBlockZ());
|
||||
BlockVector2 pos2 = new BlockVector2(top.getBlockX(), top.getBlockZ());
|
||||
add(pos1, pos2);
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import com.boydti.fawe.FaweAPI;
|
||||
import com.boydti.fawe.object.RunnableVal;
|
||||
import com.boydti.fawe.regions.general.CuboidRegionFilter;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
@ -33,14 +33,14 @@ public class WorldGuardFilter extends CuboidRegionFilter {
|
||||
public void run(Object value) {
|
||||
WorldGuardFilter.this.manager = WorldGuard.getInstance().getPlatform().getRegionContainer().get(FaweAPI.getWorld(world.getName()));
|
||||
for (ProtectedRegion region : manager.getRegions().values()) {
|
||||
BlockVector min = region.getMinimumPoint();
|
||||
BlockVector max = region.getMaximumPoint();
|
||||
BlockVector3 min = region.getMinimumPoint();
|
||||
BlockVector3 max = region.getMaximumPoint();
|
||||
if (max.getBlockX() - min.getBlockX() > 1024 || max.getBlockZ() - min.getBlockZ() > 1024) {
|
||||
Fawe.debug("Large or complex region shapes cannot be optimized. Filtering will be slower");
|
||||
large = true;
|
||||
break;
|
||||
}
|
||||
add(min.toVector2D(), max.toVector2D());
|
||||
add(min.toBlockVector2(), max.toBlockVector2());
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -49,8 +49,8 @@ public class WorldGuardFilter extends CuboidRegionFilter {
|
||||
@Override
|
||||
public boolean containsChunk(int chunkX, int chunkZ) {
|
||||
if (!large) return super.containsChunk(chunkX, chunkZ);
|
||||
BlockVector pos1 = new BlockVector(chunkX << 4, 0, chunkZ << 4);
|
||||
BlockVector pos2 = new BlockVector(pos1.getBlockX() + 15, 255, pos1.getBlockZ() + 15);
|
||||
BlockVector3 pos1 = new BlockVector3(chunkX << 4, 0, chunkZ << 4);
|
||||
BlockVector3 pos2 = new BlockVector3(pos1.getBlockX() + 15, 255, pos1.getBlockZ() + 15);
|
||||
ProtectedCuboidRegion chunkRegion = new ProtectedCuboidRegion("unimportant", pos1, pos2);
|
||||
ApplicableRegionSet set = manager.getApplicableRegions(chunkRegion);
|
||||
return set.size() > 0 && !set.getRegions().iterator().next().getId().equals("__global__");
|
||||
@ -59,8 +59,8 @@ public class WorldGuardFilter extends CuboidRegionFilter {
|
||||
@Override
|
||||
public boolean containsRegion(int mcaX, int mcaZ) {
|
||||
if (!large) return super.containsRegion(mcaX, mcaZ);
|
||||
BlockVector pos1 = new BlockVector(mcaX << 9, 0, mcaZ << 9);
|
||||
BlockVector pos2 = new BlockVector(pos1.getBlockX() + 511, 255, pos1.getBlockZ() + 511);
|
||||
BlockVector3 pos1 = new BlockVector3(mcaX << 9, 0, mcaZ << 9);
|
||||
BlockVector3 pos2 = new BlockVector3(pos1.getBlockX() + 511, 255, pos1.getBlockZ() + 511);
|
||||
ProtectedCuboidRegion regionRegion = new ProtectedCuboidRegion("unimportant", pos1, pos2);
|
||||
ApplicableRegionSet set = manager.getApplicableRegions(regionRegion);
|
||||
return set.size() > 0 && !set.getRegions().iterator().next().getId().equals("__global__");
|
||||
|
@ -14,6 +14,9 @@ import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.command.tool.BrushTool;
|
||||
import com.sk89q.worldedit.command.tool.InvalidToolBindException;
|
||||
import com.sk89q.worldedit.command.tool.brush.Brush;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
@ -246,14 +249,14 @@ public class BukkitImageListener implements Listener {
|
||||
|
||||
if (worldX < 0 || worldX > width || worldZ < 0 || worldZ > length) return;
|
||||
|
||||
Vector wPos = new Vector(worldX, 0, worldZ);
|
||||
|
||||
fp.runAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
BlockVector3 wPos = new BlockVector3(worldX, 0, worldZ);
|
||||
viewer.refresh();
|
||||
int topY = generator.getNearestSurfaceTerrainBlock(wPos.getBlockX(), wPos.getBlockZ(), 255, 0, 255);
|
||||
wPos.mutY(topY);
|
||||
wPos = wPos.withY(topY);
|
||||
|
||||
EditSession es = new EditSessionBuilder(fp.getWorld()).player(fp).combineStages(false).autoQueue(false).blockBag(null).limitUnlimited().build();
|
||||
ExtentTraverser last = new ExtentTraverser(es.getExtent()).last();
|
||||
|
@ -22,7 +22,6 @@ import com.comphenix.protocol.wrappers.ChunkCoordIntPair;
|
||||
import com.comphenix.protocol.wrappers.EnumWrappers;
|
||||
import com.comphenix.protocol.wrappers.WrappedBlockData;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
@ -31,6 +30,9 @@ import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.event.platform.BlockInteractEvent;
|
||||
import com.sk89q.worldedit.event.platform.Interaction;
|
||||
import com.sk89q.worldedit.extension.platform.PlatformManager;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.List;
|
||||
|
||||
@ -62,12 +64,12 @@ public class CFIPacketListener implements Listener {
|
||||
this.protocolmanager = ProtocolLibrary.getProtocolManager();
|
||||
|
||||
// Direct digging to the virtual world
|
||||
registerBlockEvent(PacketType.Play.Client.BLOCK_DIG, false, new RunnableVal3<PacketEvent, VirtualWorld, Vector>() {
|
||||
registerBlockEvent(PacketType.Play.Client.BLOCK_DIG, false, new RunnableVal3<PacketEvent, VirtualWorld, BlockVector3>() {
|
||||
@Override
|
||||
public void run(PacketEvent event, VirtualWorld gen, Vector pt) {
|
||||
public void run(PacketEvent event, VirtualWorld gen, BlockVector3 pt) {
|
||||
try {
|
||||
Player plr = event.getPlayer();
|
||||
Vector realPos = pt.add(gen.getOrigin());
|
||||
BlockVector3 realPos = pt.add(gen.getOrigin().toBlockPoint());
|
||||
if (!sendBlockChange(plr, gen, pt, Interaction.HIT)) {
|
||||
gen.setBlock(pt, EditSession.nullBlock);
|
||||
}
|
||||
@ -78,9 +80,9 @@ public class CFIPacketListener implements Listener {
|
||||
});
|
||||
|
||||
// Direct placing to the virtual world
|
||||
RunnableVal3<PacketEvent, VirtualWorld, Vector> placeTask = new RunnableVal3<PacketEvent, VirtualWorld, Vector>() {
|
||||
RunnableVal3<PacketEvent, VirtualWorld, BlockVector3> placeTask = new RunnableVal3<PacketEvent, VirtualWorld, BlockVector3>() {
|
||||
@Override
|
||||
public void run(PacketEvent event, VirtualWorld gen, Vector pt) {
|
||||
public void run(PacketEvent event, VirtualWorld gen, BlockVector3 pt) {
|
||||
try {
|
||||
Player plr = event.getPlayer();
|
||||
List<EnumWrappers.Hand> hands = event.getPacket().getHands().getValues();
|
||||
@ -113,9 +115,9 @@ public class CFIPacketListener implements Listener {
|
||||
registerBlockEvent(PacketType.Play.Client.USE_ITEM, true, placeTask);
|
||||
|
||||
// Cancel block change packets where the real world overlaps with the virtual one
|
||||
registerBlockEvent(PacketType.Play.Server.BLOCK_CHANGE, false, new RunnableVal3<PacketEvent, VirtualWorld, Vector>() {
|
||||
registerBlockEvent(PacketType.Play.Server.BLOCK_CHANGE, false, new RunnableVal3<PacketEvent, VirtualWorld, BlockVector3>() {
|
||||
@Override
|
||||
public void run(PacketEvent event, VirtualWorld gen, Vector pt) {
|
||||
public void run(PacketEvent event, VirtualWorld gen, BlockVector3 pt) {
|
||||
// Do nothing
|
||||
}
|
||||
});
|
||||
@ -128,7 +130,7 @@ public class CFIPacketListener implements Listener {
|
||||
|
||||
VirtualWorld gen = getGenerator(event);
|
||||
if (gen != null) {
|
||||
Vector origin = gen.getOrigin();
|
||||
BlockVector3 origin = gen.getOrigin().toBlockPoint();
|
||||
PacketContainer packet = event.getPacket();
|
||||
StructureModifier<Integer> ints = packet.getIntegers();
|
||||
int cx = ints.read(0);
|
||||
@ -137,7 +139,7 @@ public class CFIPacketListener implements Listener {
|
||||
int ocx = origin.getBlockX() >> 4;
|
||||
int ocz = origin.getBlockZ() >> 4;
|
||||
|
||||
if (gen.contains(new Vector((cx - ocx) << 4, 0, (cz - ocz) << 4))) {
|
||||
if (gen.contains(new BlockVector3((cx - ocx) << 4, 0, (cz - ocz) << 4))) {
|
||||
event.setCancelled(true);
|
||||
|
||||
Player plr = event.getPlayer();
|
||||
@ -163,8 +165,8 @@ public class CFIPacketListener implements Listener {
|
||||
Location pos = player.getLocation();
|
||||
VirtualWorld gen = getGenerator(event);
|
||||
if (gen != null) {
|
||||
Vector origin = gen.getOrigin();
|
||||
Vector pt = new Vector(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ());
|
||||
BlockVector3 origin = gen.getOrigin().toBlockPoint();
|
||||
BlockVector3 pt = new BlockVector3(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ());
|
||||
|
||||
StructureModifier<Integer> ints = event.getPacket().getIntegers();
|
||||
int id = ints.read(0);
|
||||
@ -188,12 +190,12 @@ public class CFIPacketListener implements Listener {
|
||||
Location pos = player.getLocation();
|
||||
VirtualWorld gen = getGenerator(event);
|
||||
if (gen != null) {
|
||||
Vector origin = gen.getOrigin();
|
||||
Vector from = new Vector(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ());
|
||||
BlockVector3 origin = gen.getOrigin().toBlockPoint();
|
||||
BlockVector3 from = new BlockVector3(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ());
|
||||
|
||||
PacketContainer packet = event.getPacket();
|
||||
StructureModifier<Double> doubles = packet.getDoubles();
|
||||
Vector to = new Vector(doubles.read(0), doubles.read(1), doubles.read(2));
|
||||
BlockVector3 to = new BlockVector3(doubles.read(0), doubles.read(1), doubles.read(2));
|
||||
if (gen.contains(to.subtract(origin)) && from.distanceSq(to) < 8) {
|
||||
int id = packet.getIntegers().read(0);
|
||||
PacketContainer reply = new PacketContainer(PacketType.Play.Client.TELEPORT_ACCEPT);
|
||||
@ -220,10 +222,10 @@ public class CFIPacketListener implements Listener {
|
||||
if (gen != null) {
|
||||
PacketContainer packet = event.getPacket();
|
||||
ChunkCoordIntPair chunk = packet.getChunkCoordIntPairs().read(0);
|
||||
Vector origin = gen.getOrigin();
|
||||
BlockVector3 origin = gen.getOrigin().toBlockPoint();
|
||||
int cx = chunk.getChunkX() - (origin.getBlockX() >> 4);
|
||||
int cz = chunk.getChunkZ() - (origin.getBlockX() >> 4);
|
||||
if (gen.contains(new Vector(cx << 4, 0, cz << 4))) {
|
||||
if (gen.contains(new BlockVector3(cx << 4, 0, cz << 4))) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@ -246,14 +248,14 @@ public class CFIPacketListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean sendBlockChange(Player plr, VirtualWorld gen, Vector pt, Interaction action) {
|
||||
private boolean sendBlockChange(Player plr, VirtualWorld gen, BlockVector3 pt, Interaction action) {
|
||||
PlatformManager platform = WorldEdit.getInstance().getPlatformManager();
|
||||
com.sk89q.worldedit.entity.Player actor = FawePlayer.wrap(plr).getPlayer();
|
||||
com.sk89q.worldedit.util.Location location = new com.sk89q.worldedit.util.Location(actor.getWorld(), pt);
|
||||
com.sk89q.worldedit.util.Location location = new com.sk89q.worldedit.util.Location(actor.getWorld(), pt.toVector3());
|
||||
BlockInteractEvent toCall = new BlockInteractEvent(actor, location, action);
|
||||
platform.handleBlockInteract(toCall);
|
||||
if (toCall.isCancelled() || action == Interaction.OPEN) {
|
||||
Vector realPos = pt.add(gen.getOrigin());
|
||||
BlockVector3 realPos = pt.add(gen.getOrigin().toBlockPoint());
|
||||
BlockStateHolder block = gen.getBlock(pt);
|
||||
sendBlockChange(plr, realPos, block);
|
||||
return true;
|
||||
@ -261,7 +263,7 @@ public class CFIPacketListener implements Listener {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void sendBlockChange(Player plr, Vector pt, BlockStateHolder block) {
|
||||
private void sendBlockChange(Player plr, BlockVector3 pt, BlockStateHolder block) {
|
||||
plr.sendBlockChange(new Location(plr.getWorld(), pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()), BukkitAdapter.adapt(block));
|
||||
}
|
||||
|
||||
@ -280,20 +282,20 @@ public class CFIPacketListener implements Listener {
|
||||
return null;
|
||||
}
|
||||
|
||||
private Vector getRelPos(PacketEvent event, VirtualWorld generator) {
|
||||
private BlockVector3 getRelPos(PacketEvent event, VirtualWorld generator) {
|
||||
PacketContainer packet = event.getPacket();
|
||||
StructureModifier<BlockPosition> position = packet.getBlockPositionModifier();
|
||||
BlockPosition loc = position.readSafely(0);
|
||||
if (loc == null) return null;
|
||||
Vector origin = generator.getOrigin();
|
||||
Vector pt = new Vector(loc.getX() - origin.getBlockX(), loc.getY() - origin.getBlockY(), loc.getZ() - origin.getBlockZ());
|
||||
BlockVector3 origin = generator.getOrigin().toBlockPoint();
|
||||
BlockVector3 pt = new BlockVector3(loc.getX() - origin.getBlockX(), loc.getY() - origin.getBlockY(), loc.getZ() - origin.getBlockZ());
|
||||
return pt;
|
||||
}
|
||||
|
||||
private void handleBlockEvent(PacketEvent event, boolean relative, RunnableVal3<PacketEvent, VirtualWorld, Vector> task) {
|
||||
private void handleBlockEvent(PacketEvent event, boolean relative, RunnableVal3<PacketEvent, VirtualWorld, BlockVector3> task) {
|
||||
VirtualWorld gen = getGenerator(event);
|
||||
if (gen != null) {
|
||||
Vector pt = getRelPos(event, gen);
|
||||
BlockVector3 pt = getRelPos(event, gen);
|
||||
if (pt != null) {
|
||||
if (relative) pt = getRelative(event, pt);
|
||||
if (gen.contains(pt)) {
|
||||
@ -304,7 +306,7 @@ public class CFIPacketListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
private void registerBlockEvent(PacketType type, boolean relative, RunnableVal3<PacketEvent, VirtualWorld, Vector> task) {
|
||||
private void registerBlockEvent(PacketType type, boolean relative, RunnableVal3<PacketEvent, VirtualWorld, BlockVector3> task) {
|
||||
protocolmanager.addPacketListener(new PacketAdapter(plugin, ListenerPriority.NORMAL, type) {
|
||||
@Override
|
||||
public void onPacketReceiving(final PacketEvent event) {
|
||||
@ -318,7 +320,7 @@ public class CFIPacketListener implements Listener {
|
||||
});
|
||||
}
|
||||
|
||||
private Vector getRelative(PacketEvent container, Vector pt) {
|
||||
private BlockVector3 getRelative(PacketEvent container, BlockVector3 pt) {
|
||||
PacketContainer packet = container.getPacket();
|
||||
StructureModifier<EnumWrappers.Direction> dirs = packet.getDirections();
|
||||
EnumWrappers.Direction dir = dirs.readSafely(0);
|
||||
|
@ -1,7 +1,8 @@
|
||||
package com.boydti.fawe.bukkit.regions;
|
||||
|
||||
import com.boydti.fawe.regions.FaweMask;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
public class BukkitMask extends FaweMask {
|
||||
@ -11,6 +12,6 @@ public class BukkitMask extends FaweMask {
|
||||
}
|
||||
|
||||
public BukkitMask(Location pos1, Location pos2, String name) {
|
||||
super(new BlockVector(pos1.getBlockX(), pos1.getBlockY(), pos1.getBlockZ()), new BlockVector(pos2.getBlockX(), pos2.getBlockY(), pos2.getBlockZ()), name);
|
||||
super(new BlockVector3(pos1.getBlockX(), pos1.getBlockY(), pos1.getBlockZ()), new BlockVector3(pos2.getBlockX(), pos2.getBlockY(), pos2.getBlockZ()), name);
|
||||
}
|
||||
}
|
@ -5,8 +5,8 @@ import com.boydti.fawe.bukkit.wrapper.AsyncWorld;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.object.queue.NullFaweQueue;
|
||||
import com.boydti.fawe.regions.FaweMask;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
@ -55,8 +55,8 @@ public class FreeBuildRegion extends BukkitMaskManager {
|
||||
World bukkitWorld = player.parent.getWorld();
|
||||
AsyncWorld asyncWorld = AsyncWorld.wrap(bukkitWorld);
|
||||
|
||||
Vector vec1 = new Vector(0, 0, 0);
|
||||
Vector vec2 = vec1;
|
||||
BlockVector3 vec1 = new BlockVector3(0, 0, 0);
|
||||
BlockVector3 vec2 = vec1;
|
||||
Location pos1 = BukkitAdapter.adapt(bukkitWorld, vec1);
|
||||
Location pos2 = BukkitAdapter.adapt(bukkitWorld, vec2);
|
||||
|
||||
|
@ -3,7 +3,8 @@ package com.boydti.fawe.bukkit.regions;
|
||||
import com.boydti.fawe.bukkit.FaweBukkit;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.regions.FaweMask;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
import java.util.List;
|
||||
import net.sacredlabyrinth.Phaed.PreciousStones.PreciousStones;
|
||||
import net.sacredlabyrinth.Phaed.PreciousStones.field.Field;
|
||||
@ -40,8 +41,8 @@ public class PreciousStonesFeature extends BukkitMaskManager implements Listener
|
||||
boolean member = fp.hasPermission("fawe.preciousstones.member");
|
||||
for (final Field myField : fields) {
|
||||
if (isAllowed(player, myField, type, member)) {
|
||||
BlockVector pos1 = new BlockVector(myField.getMinx(), myField.getMiny(), myField.getMinz());
|
||||
BlockVector pos2 = new BlockVector(myField.getMaxx(), myField.getMaxy(), myField.getMaxz());
|
||||
BlockVector3 pos1 = new BlockVector3(myField.getMinx(), myField.getMiny(), myField.getMinz());
|
||||
BlockVector3 pos2 = new BlockVector3(myField.getMaxx(), myField.getMaxy(), myField.getMaxz());
|
||||
return new FaweMask(pos1, pos2, "FIELD: " + myField) {
|
||||
@Override
|
||||
public boolean isValid(FawePlayer player, MaskType type) {
|
||||
|
@ -7,8 +7,8 @@ import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.object.RegionWrapper;
|
||||
import com.boydti.fawe.regions.FaweMask;
|
||||
import com.boydti.fawe.regions.general.RegionFilter;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.regions.AbstractRegion;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Polygonal2DRegion;
|
||||
@ -61,7 +61,7 @@ public class Worldguard extends BukkitMaskManager implements Listener {
|
||||
if (global != null && isAllowed(player, global)) {
|
||||
return global;
|
||||
}
|
||||
final ApplicableRegionSet regions = manager.getApplicableRegions(new Vector(loc.getX(), loc.getY(), loc.getZ()));
|
||||
final ApplicableRegionSet regions = manager.getApplicableRegions(new BlockVector3(loc.getX(), loc.getY(), loc.getZ()));
|
||||
for (final ProtectedRegion region : regions) {
|
||||
if (isAllowed(player, region)) {
|
||||
return region;
|
||||
@ -145,27 +145,27 @@ public class Worldguard extends BukkitMaskManager implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getMinimumPoint() {
|
||||
public BlockVector3 getMinimumPoint() {
|
||||
return region.getMinimumPoint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getMaximumPoint() {
|
||||
public BlockVector3 getMaximumPoint() {
|
||||
return region.getMaximumPoint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void expand(Vector... changes) {
|
||||
public void expand(BlockVector3... changes) {
|
||||
throw new UnsupportedOperationException("Region is immutable");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contract(Vector... changes) {
|
||||
public void contract(BlockVector3... changes) {
|
||||
throw new UnsupportedOperationException("Region is immutable");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Vector position) {
|
||||
public boolean contains(BlockVector3 position) {
|
||||
return region.contains(position);
|
||||
}
|
||||
}
|
||||
@ -179,8 +179,8 @@ public class Worldguard extends BukkitMaskManager implements Listener {
|
||||
}
|
||||
if (region instanceof ProtectedPolygonalRegion) {
|
||||
ProtectedPolygonalRegion casted = (ProtectedPolygonalRegion) region;
|
||||
BlockVector max = region.getMaximumPoint();
|
||||
BlockVector min = region.getMinimumPoint();
|
||||
BlockVector3 max = region.getMaximumPoint();
|
||||
BlockVector3 min = region.getMinimumPoint();
|
||||
return new Polygonal2DRegion(null, casted.getPoints(), min.getBlockY(), max.getBlockY());
|
||||
}
|
||||
return new AdaptedRegion(region);
|
||||
|
@ -5,7 +5,7 @@ import com.boydti.fawe.bukkit.filter.WorldGuardFilter;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.regions.FaweMask;
|
||||
import com.boydti.fawe.regions.general.RegionFilter;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.AbstractRegion;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
@ -65,45 +65,45 @@ public class WorldguardFlag extends BukkitMaskManager implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getMinimumPoint() {
|
||||
Vector point = null;
|
||||
public BlockVector3 getMinimumPoint() {
|
||||
BlockVector3 point = null;
|
||||
for (Map.Entry<String, ProtectedRegion> entry : manager.getRegions().entrySet()) {
|
||||
Vector p = entry.getValue().getMinimumPoint();
|
||||
BlockVector3 p = entry.getValue().getMinimumPoint();
|
||||
if (point == null) {
|
||||
point = p;
|
||||
continue;
|
||||
}
|
||||
point = Vector.getMinimum(point, p);
|
||||
point = point.getMinimum(p);
|
||||
}
|
||||
return point;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getMaximumPoint() {
|
||||
Vector point = null;
|
||||
public BlockVector3 getMaximumPoint() {
|
||||
BlockVector3 point = null;
|
||||
for (Map.Entry<String, ProtectedRegion> entry : manager.getRegions().entrySet()) {
|
||||
Vector p = entry.getValue().getMaximumPoint();
|
||||
BlockVector3 p = entry.getValue().getMaximumPoint();
|
||||
if (point == null) {
|
||||
point = p;
|
||||
continue;
|
||||
}
|
||||
point = Vector.getMaximum(point, p);
|
||||
point = point.getMaximum(p);
|
||||
}
|
||||
return point;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void expand(Vector... changes) {
|
||||
public void expand(BlockVector3... changes) {
|
||||
throw new UnsupportedOperationException("Region is immutable");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contract(Vector... changes) {
|
||||
public void contract(BlockVector3... changes) {
|
||||
throw new UnsupportedOperationException("Region is immutable");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Vector position) {
|
||||
public boolean contains(BlockVector3 position) {
|
||||
// Make sure that all these flags are not denied. Denies override allows. WorldGuardExtraFlags can add Flags.WORLDEDIT
|
||||
return manager.getApplicableRegions(position).testState(localplayer, Flags.BUILD, Flags.BLOCK_PLACE, Flags.BLOCK_BREAK);
|
||||
}
|
||||
|
@ -13,11 +13,12 @@ import com.comphenix.protocol.wrappers.BlockPosition;
|
||||
import com.comphenix.protocol.wrappers.nbt.NbtBase;
|
||||
import com.comphenix.protocol.wrappers.nbt.NbtCompound;
|
||||
import com.comphenix.protocol.wrappers.nbt.NbtFactory;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.internal.cui.CUIEvent;
|
||||
import com.sk89q.worldedit.internal.cui.SelectionPointEvent;
|
||||
import com.sk89q.worldedit.internal.cui.SelectionShapeEvent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -33,10 +34,10 @@ import org.bukkit.entity.Player;
|
||||
public class StructureCUI extends CUI {
|
||||
private boolean cuboid = true;
|
||||
|
||||
private Vector pos1;
|
||||
private Vector pos2;
|
||||
private BlockVector3 pos1;
|
||||
private BlockVector3 pos2;
|
||||
|
||||
private Vector remove;
|
||||
private BlockVector3 remove;
|
||||
private NbtCompound removeTag;
|
||||
private BlockState state;
|
||||
|
||||
@ -56,7 +57,7 @@ public class StructureCUI extends CUI {
|
||||
int x = Integer.parseInt(param[1]);
|
||||
int y = Integer.parseInt(param[2]);
|
||||
int z = Integer.parseInt(param[3]);
|
||||
Vector pos = new Vector(x, y, z);
|
||||
BlockVector3 pos = new BlockVector3(x, y, z);
|
||||
if (id == 0) {
|
||||
pos1 = pos;
|
||||
} else {
|
||||
@ -123,7 +124,7 @@ public class StructureCUI extends CUI {
|
||||
}
|
||||
}
|
||||
|
||||
private void sendNbt(Vector pos, NbtCompound compound) {
|
||||
private void sendNbt(BlockVector3 pos, NbtCompound compound) {
|
||||
Player player = this.<Player>getPlayer().parent;
|
||||
ProtocolManager manager = ProtocolLibrary.getProtocolManager();
|
||||
|
||||
@ -158,8 +159,8 @@ public class StructureCUI extends CUI {
|
||||
remove = null;
|
||||
}
|
||||
if (pos1 == null || pos2 == null) return;
|
||||
Vector min = Vector.getMinimum(pos1, pos2);
|
||||
Vector max = Vector.getMaximum(pos1, pos2);
|
||||
BlockVector3 min = pos1.getMinimum(pos2);
|
||||
BlockVector3 max = pos1.getMaximum(pos2);
|
||||
|
||||
// Position
|
||||
double rotX = playerLoc.getYaw();
|
||||
@ -187,7 +188,7 @@ public class StructureCUI extends CUI {
|
||||
NbtCompound compound = constructStructureNbt(x, y, z, posX, posY, posZ, sizeX, sizeY, sizeZ);
|
||||
|
||||
Block block = player.getWorld().getBlockAt(x, y, z);
|
||||
remove = new Vector(x, y, z);
|
||||
remove = new BlockVector3(x, y, z);
|
||||
state = BukkitAdapter.adapt(block.getBlockData());
|
||||
removeTag = compound;
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
//import com.sk89q.jnbt.StringTag;
|
||||
//import com.sk89q.jnbt.Tag;
|
||||
//import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
//import com.sk89q.worldedit.world.block.BlockState;
|
||||
//import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
||||
//import com.sk89q.worldedit.entity.BaseEntity;
|
||||
//import com.sk89q.worldedit.internal.Constants;
|
||||
|
@ -19,12 +19,13 @@
|
||||
|
||||
package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
||||
import com.sk89q.worldedit.bukkit.adapter.IBukkitAdapter;
|
||||
import com.sk89q.worldedit.bukkit.adapter.SimpleBukkitAdapter;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
@ -34,6 +35,7 @@ import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.entity.EntityType;
|
||||
import com.sk89q.worldedit.world.gamemode.GameMode;
|
||||
import com.sk89q.worldedit.world.item.ItemType;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -84,7 +86,11 @@ public enum BukkitAdapter {
|
||||
return getAdapter().adapt(location);
|
||||
}
|
||||
|
||||
public static org.bukkit.Location adapt(org.bukkit.World world, Vector position) {
|
||||
public static org.bukkit.Location adapt(org.bukkit.World world, Vector3 position) {
|
||||
return getAdapter().adapt(world, position);
|
||||
}
|
||||
|
||||
public static org.bukkit.Location adapt(org.bukkit.World world, BlockVector3 position) {
|
||||
return getAdapter().adapt(world, position);
|
||||
}
|
||||
|
||||
@ -92,10 +98,14 @@ public enum BukkitAdapter {
|
||||
return getAdapter().adapt(world, location);
|
||||
}
|
||||
|
||||
public static Vector asVector(org.bukkit.Location location) {
|
||||
public static Vector3 asVector(org.bukkit.Location location) {
|
||||
return getAdapter().asVector(location);
|
||||
}
|
||||
|
||||
public static BlockVector3 asBlockVector(org.bukkit.Location location) {
|
||||
return getAdapter().asBlockVector(location);
|
||||
}
|
||||
|
||||
public static Entity adapt(org.bukkit.entity.Entity entity) {
|
||||
return getAdapter().adapt(entity);
|
||||
}
|
||||
|
@ -22,20 +22,26 @@ package com.sk89q.worldedit.bukkit;
|
||||
import com.boydti.fawe.object.RunnableVal;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.sk89q.util.StringUtil;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.extension.platform.AbstractPlayerActor;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.internal.cui.CUIEvent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.session.SessionKey;
|
||||
import com.sk89q.worldedit.util.HandSide;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.gamemode.GameMode;
|
||||
import com.sk89q.worldedit.world.gamemode.GameModes;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -147,7 +153,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPosition(Vector pos, float pitch, float yaw) {
|
||||
public void setPosition(Vector3 pos, float pitch, float yaw) {
|
||||
player.teleport(new Location(player.getWorld(), pos.getX(), pos.getY(),
|
||||
pos.getZ(), yaw, pitch));
|
||||
}
|
||||
@ -205,7 +211,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
|
||||
return;
|
||||
}
|
||||
|
||||
setPosition(new Vector(x + 0.5, y, z + 0.5));
|
||||
setPosition(new Vector3(x + 0.5, y, z + 0.5));
|
||||
player.setFlying(true);
|
||||
}
|
||||
|
||||
@ -217,7 +223,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
|
||||
@Override
|
||||
public com.sk89q.worldedit.util.Location getLocation() {
|
||||
Location nativeLocation = player.getLocation();
|
||||
Vector position = BukkitAdapter.asVector(nativeLocation);
|
||||
Vector3 position = BukkitAdapter.asVector(nativeLocation);
|
||||
return new com.sk89q.worldedit.util.Location(
|
||||
getWorld(),
|
||||
position,
|
||||
|
@ -21,13 +21,20 @@ package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.blocks.LazyBlock;
|
||||
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.history.change.BlockChange;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.TreeGenerator;
|
||||
import com.sk89q.worldedit.world.AbstractWorld;
|
||||
@ -35,6 +42,7 @@ import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.weather.WeatherType;
|
||||
import com.sk89q.worldedit.world.weather.WeatherTypes;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.TreeType;
|
||||
import org.bukkit.World;
|
||||
@ -53,8 +61,6 @@ import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
public class BukkitWorld extends AbstractWorld {
|
||||
|
||||
private static final Logger logger = WorldEdit.logger;
|
||||
@ -84,7 +90,7 @@ public class BukkitWorld extends AbstractWorld {
|
||||
List<Entity> ents = world.getEntities();
|
||||
List<com.sk89q.worldedit.entity.Entity> entities = new ArrayList<>();
|
||||
for (Entity ent : ents) {
|
||||
if (region.contains(BukkitAdapter.asVector(ent.getLocation()))) {
|
||||
if (region.contains(BukkitAdapter.asBlockVector(ent.getLocation()))) {
|
||||
addEntities(ent, entities);
|
||||
}
|
||||
}
|
||||
@ -185,7 +191,7 @@ public class BukkitWorld extends AbstractWorld {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlockLightLevel(Vector pt) {
|
||||
public int getBlockLightLevel(BlockVector3 pt) {
|
||||
return getWorld().getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).getLightLevel();
|
||||
}
|
||||
|
||||
@ -193,14 +199,14 @@ public class BukkitWorld extends AbstractWorld {
|
||||
public boolean regenerate(Region region, EditSession editSession) {
|
||||
com.sk89q.worldedit.world.block.BlockStateHolder[] history = new com.sk89q.worldedit.world.block.BlockState[16 * 16 * (getMaxY() + 1)];
|
||||
|
||||
for (Vector2D chunk : region.getChunks()) {
|
||||
Vector min = new Vector(chunk.getBlockX() * 16, 0, chunk.getBlockZ() * 16);
|
||||
for (BlockVector2 chunk : region.getChunks()) {
|
||||
BlockVector3 min = new BlockVector3(chunk.getBlockX() * 16, 0, chunk.getBlockZ() * 16);
|
||||
|
||||
// First save all the blocks inside
|
||||
for (int x = 0; x < 16; ++x) {
|
||||
for (int y = 0; y < (getMaxY() + 1); ++y) {
|
||||
for (int z = 0; z < 16; ++z) {
|
||||
Vector pt = min.add(x, y, z);
|
||||
BlockVector3 pt = min.add(x, y, z);
|
||||
int index = y * 16 * 16 + z * 16 + x;
|
||||
history[index] = editSession.getFullBlock(pt);
|
||||
}
|
||||
@ -217,14 +223,14 @@ public class BukkitWorld extends AbstractWorld {
|
||||
for (int x = 0; x < 16; ++x) {
|
||||
for (int y = 0; y < (getMaxY() + 1); ++y) {
|
||||
for (int z = 0; z < 16; ++z) {
|
||||
Vector pt = min.add(x, y, z);
|
||||
BlockVector3 pt = min.add(x, y, z);
|
||||
int index = y * 16 * 16 + z * 16 + x;
|
||||
|
||||
// We have to restore the block if it was outside
|
||||
if (!region.contains(pt)) {
|
||||
editSession.smartSetBlock(pt, history[index]);
|
||||
} else { // Otherwise fool with history
|
||||
editSession.getChangeSet().add(new BlockChange(pt.toBlockVector(), history[index], editSession.getFullBlock(pt)));
|
||||
editSession.getChangeSet().add(new BlockChange(pt, history[index], editSession.getFullBlock(pt)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -263,7 +269,7 @@ public class BukkitWorld extends AbstractWorld {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean clearContainerBlockContents(Vector pt) {
|
||||
public boolean clearContainerBlockContents(BlockVector3 pt) {
|
||||
Block block = getWorld().getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
|
||||
if (block == null) {
|
||||
return false;
|
||||
@ -317,7 +323,7 @@ public class BukkitWorld extends AbstractWorld {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, Vector pt) {
|
||||
public boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, BlockVector3 pt) {
|
||||
World world = getWorld();
|
||||
TreeType bukkitType = toBukkitTreeType(type);
|
||||
return type != null && world.generateTree(BukkitAdapter.adapt(world, pt), bukkitType,
|
||||
@ -325,13 +331,13 @@ public class BukkitWorld extends AbstractWorld {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dropItem(Vector pt, BaseItemStack item) {
|
||||
public void dropItem(Vector3 pt, BaseItemStack item) {
|
||||
World world = getWorld();
|
||||
world.dropItemNaturally(BukkitAdapter.adapt(world, pt), BukkitAdapter.adapt(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkLoadedChunk(Vector pt) {
|
||||
public void checkLoadedChunk(BlockVector3 pt) {
|
||||
World world = getWorld();
|
||||
|
||||
if (!world.isChunkLoaded(pt.getBlockX() >> 4, pt.getBlockZ() >> 4)) {
|
||||
@ -363,15 +369,15 @@ public class BukkitWorld extends AbstractWorld {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fixAfterFastMode(Iterable<BlockVector2D> chunks) {
|
||||
public void fixAfterFastMode(Iterable<BlockVector2> chunks) {
|
||||
World world = getWorld();
|
||||
for (BlockVector2D chunkPos : chunks) {
|
||||
for (BlockVector2 chunkPos : chunks) {
|
||||
world.refreshChunk(chunkPos.getBlockX(), chunkPos.getBlockZ());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playEffect(Vector position, int type, int data) {
|
||||
public boolean playEffect(Vector3 position, int type, int data) {
|
||||
World world = getWorld();
|
||||
|
||||
final Effect effect = effects.get(type);
|
||||
@ -430,18 +436,18 @@ public class BukkitWorld extends AbstractWorld {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void simulateBlockMine(Vector pt) {
|
||||
public void simulateBlockMine(BlockVector3 pt) {
|
||||
getWorld().getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).breakNaturally();
|
||||
}
|
||||
|
||||
@Override
|
||||
public com.sk89q.worldedit.world.block.BlockState getBlock(Vector position) {
|
||||
public com.sk89q.worldedit.world.block.BlockState getBlock(BlockVector3 position) {
|
||||
Block bukkitBlock = getWorld().getBlockAt(position.getBlockX(), position.getBlockY(), position.getBlockZ());
|
||||
return BukkitAdapter.adapt(bukkitBlock.getBlockData());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(Vector position, BlockStateHolder block, boolean notifyAndLight) {
|
||||
public boolean setBlock(BlockVector3 position, BlockStateHolder block, boolean notifyAndLight) throws WorldEditException {
|
||||
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||
if (adapter != null) {
|
||||
try {
|
||||
@ -467,12 +473,12 @@ public class BukkitWorld extends AbstractWorld {
|
||||
}
|
||||
|
||||
@Override
|
||||
public com.sk89q.worldedit.world.block.BlockState getLazyBlock(Vector position) {
|
||||
public com.sk89q.worldedit.world.block.BlockState getLazyBlock(BlockVector3 position) {
|
||||
return getBlock(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public com.sk89q.worldedit.world.block.BlockState getFullBlock(Vector position) {
|
||||
public com.sk89q.worldedit.world.block.BlockState getFullBlock(BlockVector3 position) {
|
||||
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||
if (adapter != null) {
|
||||
return adapter.getBlock(BukkitAdapter.adapt(getWorld(), position));
|
||||
@ -482,7 +488,7 @@ public class BukkitWorld extends AbstractWorld {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBiome getBiome(Vector2D position) {
|
||||
public BaseBiome getBiome(BlockVector2 position) {
|
||||
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||
if (adapter != null) {
|
||||
int id = adapter.getBiomeId(getWorld().getBiome(position.getBlockX(), position.getBlockZ()));
|
||||
@ -493,7 +499,7 @@ public class BukkitWorld extends AbstractWorld {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(Vector2D position, BaseBiome biome) {
|
||||
public boolean setBiome(BlockVector2 position, BaseBiome biome) {
|
||||
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||
if (adapter != null) {
|
||||
Biome bukkitBiome = adapter.getBiome(biome.getId());
|
||||
|
@ -21,8 +21,8 @@ package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
import org.bukkit.BlockChangeDelegate;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
@ -40,7 +40,7 @@ public class EditSessionBlockChangeDelegate implements BlockChangeDelegate {
|
||||
@Override
|
||||
public boolean setBlockData(int x, int y, int z, BlockData blockData) {
|
||||
try {
|
||||
editSession.setBlock(new Vector(x, y, z), BukkitAdapter.adapt(blockData));
|
||||
editSession.setBlock(new BlockVector3(x, y, z), BukkitAdapter.adapt(blockData));
|
||||
} catch (MaxChangedBlocksException e) {
|
||||
return false;
|
||||
}
|
||||
@ -49,7 +49,7 @@ public class EditSessionBlockChangeDelegate implements BlockChangeDelegate {
|
||||
|
||||
@Override
|
||||
public BlockData getBlockData(int x, int y, int z) {
|
||||
return BukkitAdapter.adapt(editSession.getBlock(new Vector(x, y, z)));
|
||||
return BukkitAdapter.adapt(editSession.getBlock(new BlockVector3(x, y, z)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -59,7 +59,7 @@ public class EditSessionBlockChangeDelegate implements BlockChangeDelegate {
|
||||
|
||||
@Override
|
||||
public boolean isEmpty(int x, int y, int z) {
|
||||
return editSession.getBlock(new Vector(x, y, z)).getBlockType().getMaterial().isAir();
|
||||
return editSession.getBlock(new BlockVector3(x, y, z)).getBlockType().getMaterial().isAir();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,6 +23,10 @@ import com.sk89q.jnbt.Tag;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BlockMaterial;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
@ -104,6 +108,14 @@ public interface BukkitImplAdapter<T> extends IBukkitAdapter {
|
||||
default BlockMaterial getMaterial(BlockType blockType) {
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Send the given NBT data to the player.
|
||||
*
|
||||
* @param player The player
|
||||
* @param pos The position
|
||||
* @param nbtData The NBT Data
|
||||
*/
|
||||
void sendFakeNBT(Player player, BlockVector3 pos, CompoundTag nbtData);
|
||||
|
||||
default BlockMaterial getMaterial(BlockState blockState) {
|
||||
return null;
|
||||
|
@ -1,10 +1,11 @@
|
||||
package com.sk89q.worldedit.bukkit.adapter;
|
||||
|
||||
import com.sk89q.worldedit.NotABlockException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.bukkit.*;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
@ -96,7 +97,7 @@ public interface IBukkitAdapter {
|
||||
*/
|
||||
default Location adapt(org.bukkit.Location location) {
|
||||
checkNotNull(location);
|
||||
Vector position = asVector(location);
|
||||
Vector3 position = asVector(location);
|
||||
return new com.sk89q.worldedit.util.Location(
|
||||
adapt(location.getWorld()),
|
||||
position,
|
||||
@ -112,7 +113,7 @@ public interface IBukkitAdapter {
|
||||
*/
|
||||
default org.bukkit.Location adapt(Location location) {
|
||||
checkNotNull(location);
|
||||
Vector position = location.toVector();
|
||||
Vector3 position = location.toVector();
|
||||
return new org.bukkit.Location(
|
||||
adapt((World) location.getExtent()),
|
||||
position.getX(), position.getY(), position.getZ(),
|
||||
@ -127,13 +128,17 @@ public interface IBukkitAdapter {
|
||||
* @param position the WorldEdit position
|
||||
* @return a Bukkit location
|
||||
*/
|
||||
default org.bukkit.Location adapt(org.bukkit.World world, Vector position) {
|
||||
default org.bukkit.Location adapt(org.bukkit.World world, Vector3 position) {
|
||||
checkNotNull(world);
|
||||
checkNotNull(position);
|
||||
return new org.bukkit.Location(
|
||||
world,
|
||||
position.getX(), position.getY(), position.getZ());
|
||||
}
|
||||
|
||||
default org.bukkit.Location adapt(org.bukkit.World world, BlockVector3 position){
|
||||
return adapt(world, position.toVector3());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a Bukkit location from a WorldEdit location with a Bukkit world.
|
||||
@ -158,9 +163,20 @@ public interface IBukkitAdapter {
|
||||
* @param location The Bukkit location
|
||||
* @return a WorldEdit vector
|
||||
*/
|
||||
default Vector asVector(org.bukkit.Location location) {
|
||||
default Vector3 asVector(org.bukkit.Location location) {
|
||||
checkNotNull(location);
|
||||
return new Vector(location.getX(), location.getY(), location.getZ());
|
||||
return new Vector3(location.getX(), location.getY(), location.getZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a WorldEdit BlockVector from a Bukkit location.
|
||||
*
|
||||
* @param location The Bukkit location
|
||||
* @return a WorldEdit vector
|
||||
*/
|
||||
default BlockVector3 asBlockVector(org.bukkit.Location location) {
|
||||
checkNotNull(location);
|
||||
return new BlockVector3(location.getX(), location.getY(), location.getZ());
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user