Added MultiBlock packet.
Tweaked performance for chunks that are < 64 changes for HungerGames.
This commit is contained in:
parent
0a1f4ecfd5
commit
e2646a982f
@ -14,6 +14,8 @@ import net.minecraft.server.v1_6_R3.ChunkCoordIntPair;
|
||||
import net.minecraft.server.v1_6_R3.ChunkSection;
|
||||
import net.minecraft.server.v1_6_R3.IContainer;
|
||||
import net.minecraft.server.v1_6_R3.MinecraftServer;
|
||||
import net.minecraft.server.v1_6_R3.Packet52MultiBlockChange;
|
||||
import net.minecraft.server.v1_6_R3.PlayerChunkMap;
|
||||
import net.minecraft.server.v1_6_R3.RegionFile;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@ -188,9 +190,17 @@ public class MapUtil
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void SendChunkForPlayer(int x, int z, Player player)
|
||||
{
|
||||
System.out.println("Sending Chunk " + x + ", " + z);
|
||||
((CraftPlayer)player).getHandle().chunkCoordIntPairQueue.add(new ChunkCoordIntPair(x, z));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void SendMultiBlockForPlayer(int x, int z, short[] dirtyBlocks, int dirtyCount, World world, Player player)
|
||||
{
|
||||
System.out.println("Sending MultiBlockChunk " + x + ", " + z);
|
||||
((CraftPlayer)player).getHandle().playerConnection.sendPacket(new Packet52MultiBlockChange(x, z, dirtyBlocks, dirtyCount, ((CraftWorld)world).getHandle()));
|
||||
}
|
||||
|
||||
public static void UnloadWorld(JavaPlugin plugin, World world)
|
||||
{
|
||||
world.setAutoSave(false);
|
||||
|
@ -2,6 +2,8 @@ package nautilus.game.arcade.game.games.hungergames;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.server.v1_6_R3.PlayerChunkMap;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
|
||||
@ -10,6 +12,8 @@ public class ChunkChange
|
||||
public Chunk Chunk;
|
||||
public long Time;
|
||||
public ArrayList<BlockChange> Changes;
|
||||
public short[] DirtyBlocks = new short[64];
|
||||
public short DirtyCount = 0;
|
||||
|
||||
public ChunkChange(Location loc, int id, byte data)
|
||||
{
|
||||
@ -25,5 +29,24 @@ public class ChunkChange
|
||||
public void AddChange(Location loc, int id, byte data)
|
||||
{
|
||||
Changes.add(new BlockChange(loc, id, data));
|
||||
|
||||
if (DirtyCount < 63)
|
||||
{
|
||||
short short1 = (short)((loc.getBlockX() & 0xF) << 12 | (loc.getBlockZ() & 0xF) << 8 | loc.getBlockY());
|
||||
|
||||
for (int l = 0; l < DirtyCount; l++)
|
||||
{
|
||||
if (DirtyBlocks[l] == short1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
DirtyBlocks[(DirtyCount++)] = short1;
|
||||
}
|
||||
else
|
||||
{
|
||||
DirtyCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -769,8 +769,11 @@ public class HungerGames extends SoloGame
|
||||
|
||||
//change.Changes contains Location/Id/Data for all pending changes in this chunk
|
||||
|
||||
//XXX Simply replace this line with the the Multiblocks packet.
|
||||
MapUtil.SendChunkForPlayer(change.Chunk.getX(), change.Chunk.getZ(), player);
|
||||
//XXX Simply replace this line with the the Multiblocks packet.
|
||||
if (change.DirtyCount >= 63)
|
||||
MapUtil.SendChunkForPlayer(change.Chunk.getX(), change.Chunk.getZ(), player);
|
||||
else
|
||||
MapUtil.SendMultiBlockForPlayer(change.Chunk.getX(), change.Chunk.getZ(), change.DirtyBlocks, change.DirtyCount, change.Chunk.getWorld(), player);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user