diff options
author | raphfrk <raphfrk@gmail.com> | 2011-05-21 20:27:34 +0100 |
---|---|---|
committer | EvilSeph <evilseph@unaligned.org> | 2011-06-08 19:05:01 -0400 |
commit | 83209173634426f5f348747770c23d4dd3159d20 (patch) | |
tree | 47dabceb8565540d65b09179f130c5556d68c50a /src/main/java/org | |
parent | 1a1fc953cbbb9c4a2012eb0687cb477ec9b7b5a6 (diff) | |
download | craftbukkit-83209173634426f5f348747770c23d4dd3159d20.tar craftbukkit-83209173634426f5f348747770c23d4dd3159d20.tar.gz craftbukkit-83209173634426f5f348747770c23d4dd3159d20.tar.lz craftbukkit-83209173634426f5f348747770c23d4dd3159d20.tar.xz craftbukkit-83209173634426f5f348747770c23d4dd3159d20.zip |
Adds update chunk method for sending fake chunk updates to the client. This is to match the sendBlockChange method.
Diffstat (limited to 'src/main/java/org')
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index a9084f9f..ef9822e9 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -2,11 +2,13 @@ package org.bukkit.craftbukkit.entity; import java.net.InetSocketAddress; import java.net.SocketAddress; +import java.util.zip.Deflater; import net.minecraft.server.EntityHuman; import net.minecraft.server.EntityPlayer; import net.minecraft.server.ItemInWorldManager; import net.minecraft.server.Packet200Statistic; import net.minecraft.server.Packet3Chat; +import net.minecraft.server.Packet51MapChunk; import net.minecraft.server.Packet53BlockChange; import net.minecraft.server.Packet54PlayNoteBlock; import net.minecraft.server.Packet6SpawnPosition; @@ -164,6 +166,33 @@ public class CraftPlayer extends CraftHumanEntity implements Player { getHandle().netServerHandler.sendPacket(packet); } + public boolean sendChunkChange(Location loc, int sx, int sy, int sz, byte[] data) { + int x = loc.getBlockX(); + int y = loc.getBlockY(); + int z = loc.getBlockZ(); + + int cx = x >> 4; + int cz = z >> 4; + + if (sx <= 0 || sy <= 0 || sz <= 0) { + return false; + } + + if ((x + sx - 1) >> 4 != cx || (z + sz - 1) >> 4 != cz || y < 0 || y + sy > 128) { + return false; + } + + if (data.length != (sx * sy * sz * 5) / 2) { + return false; + } + + Packet51MapChunk packet = new Packet51MapChunk(x, y, z, sx, sy, sz, data); + + getHandle().netServerHandler.sendPacket(packet); + + return true; + } + @Override public boolean teleport(Location location) { WorldServer oldWorld = ((CraftWorld)getWorld()).getHandle(); |