Fixed entity offset

This commit is contained in:
boy0001 2015-02-23 19:53:37 +11:00
parent f8f7dec5f6
commit c9cbc904c3
2 changed files with 14 additions and 9 deletions

View File

@ -8,7 +8,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>
<artifactId>PlotSquared</artifactId> <artifactId>PlotSquared</artifactId>
<version>2.7.4</version> <version>2.8</version>
<name>PlotSquared</name> <name>PlotSquared</name>
<packaging>jar</packaging> <packaging>jar</packaging>
<build> <build>

View File

@ -48,7 +48,6 @@ import com.intellectualcrafters.plot.object.BlockLoc;
import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.RegionWrapper; import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.object.entity.EntityWrapper; import com.intellectualcrafters.plot.object.entity.EntityWrapper;
@ -199,9 +198,9 @@ public class BukkitChunkManager extends ChunkManager {
chunks.add(chunk); chunks.add(chunk);
chunk.load(false); chunk.load(false);
saveEntitiesIn(chunk, region); saveEntitiesIn(chunk, region);
restoreEntities(world, relX, relZ);
} }
} }
restoreEntities(world, relX, relZ);
// Copy blocks // Copy blocks
final MutableInt mx = new MutableInt(sx); final MutableInt mx = new MutableInt(sx);
final Integer currentIndex = index.toInteger(); final Integer currentIndex = index.toInteger();
@ -389,10 +388,10 @@ public class BukkitChunkManager extends ChunkManager {
} }
public static void saveEntitiesIn(final Chunk chunk, final RegionWrapper region) { public static void saveEntitiesIn(final Chunk chunk, final RegionWrapper region) {
saveEntitiesIn(chunk, region, 0, 0); saveEntitiesIn(chunk, region, 0, 0, false);
} }
public static void saveEntitiesIn(final Chunk chunk, final RegionWrapper region, int offset_x, int offset_z) { public static void saveEntitiesIn(final Chunk chunk, final RegionWrapper region, int offset_x, int offset_z, boolean delete) {
for (final Entity entity : chunk.getEntities()) { for (final Entity entity : chunk.getEntities()) {
final Location loc = BukkitUtil.getLocation(entity); final Location loc = BukkitUtil.getLocation(entity);
final int x = loc.getX(); final int x = loc.getX();
@ -405,8 +404,13 @@ public class BukkitChunkManager extends ChunkManager {
} }
final EntityWrapper wrap = new EntityWrapper(entity, (short) 2); final EntityWrapper wrap = new EntityWrapper(entity, (short) 2);
wrap.x += offset_x; wrap.x += offset_x;
wrap.x += offset_z; wrap.z += offset_z;
entities.add(wrap); entities.add(wrap);
if (delete) {
if (!(entity instanceof Player)) {
entity.remove();
}
}
} }
} }
@ -774,13 +778,12 @@ public class BukkitChunkManager extends ChunkManager {
} }
public static void swapChunk(World world, Chunk pos1, Chunk pos2, RegionWrapper r1, RegionWrapper r2) { public static void swapChunk(World world, Chunk pos1, Chunk pos2, RegionWrapper r1, RegionWrapper r2) {
System.out.print("SWAPPING: " + pos1 +" and " + pos2);
initMaps(); initMaps();
int relX = (r2.minX - r1.minX); int relX = (r2.minX - r1.minX);
int relZ = (r2.minZ - r1.minZ); int relZ = (r2.minZ - r1.minZ);
saveEntitiesIn(pos1, r1, relX, relZ); saveEntitiesIn(pos1, r1, relX, relZ, true);
saveEntitiesIn(pos2, r2, -relX, -relZ); saveEntitiesIn(pos2, r2, -relX, -relZ, true);
int sx = pos1.getX() << 4; int sx = pos1.getX() << 4;
int sz = pos1.getZ() << 4; int sz = pos1.getZ() << 4;
@ -851,6 +854,8 @@ public class BukkitChunkManager extends ChunkManager {
swapChunk(world, chunk1, chunk2, region1, region2); swapChunk(world, chunk1, chunk2, region1, region2);
} }
} }
clearAllEntities(MainUtil.getPlot(worldname, pos1));
clearAllEntities(MainUtil.getPlot(worldname, pos2));
// FIXME swap plots // FIXME swap plots
} }
} }