Update CraftBukkit to Minecraft 1.4.4.

By: Travis Watkins <amaranth@ubuntu.com>
This commit is contained in:
CraftBukkit/Spigot 2012-11-06 06:05:28 -06:00
parent f6c50c0851
commit 3f728bab1a
11 changed files with 25 additions and 192 deletions

View file

@ -4,7 +4,7 @@
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<packaging>jar</packaging>
<version>1.4.2-R0.3-SNAPSHOT</version>
<version>1.4.4-R0.1-SNAPSHOT</version>
<name>CraftBukkit</name>
<url>http://www.bukkit.org</url>
@ -51,14 +51,14 @@
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.4.2-R0.3-SNAPSHOT</version>
<version>1.4.4-R0.1-SNAPSHOT</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>minecraft-server</artifactId>
<version>1.4.2</version>
<version>1.4.4</version>
<type>jar</type>
<scope>compile</scope>
</dependency>

View file

@ -1,170 +0,0 @@
package org.bukkit.craftbukkit;
import java.util.HashMap;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.zip.Deflater;
import net.minecraft.server.EntityPlayer;
import net.minecraft.server.Packet;
import net.minecraft.server.Packet51MapChunk;
import net.minecraft.server.Packet56MapChunkBulk;
public final class ChunkCompressionThread implements Runnable {
private static final ChunkCompressionThread instance = new ChunkCompressionThread();
private static boolean isRunning = false;
private final int QUEUE_CAPACITY = 1024 * 10;
private final HashMap<EntityPlayer, Integer> queueSizePerPlayer = new HashMap<EntityPlayer, Integer>();
private final BlockingQueue<QueuedPacket> packetQueue = new LinkedBlockingQueue<QueuedPacket>(QUEUE_CAPACITY);
private final int CHUNK_SIZE = 16 * 256 * 16 * 5 / 2;
private final int REDUCED_DEFLATE_THRESHOLD = CHUNK_SIZE / 4;
private final int DEFLATE_LEVEL_CHUNKS = 6;
private final int DEFLATE_LEVEL_PARTS = 1;
private final Deflater deflater = new Deflater();
private byte[] deflateBuffer = new byte[CHUNK_SIZE + 100];
public static void startThread() {
if (!isRunning) {
isRunning = true;
new Thread(instance).start();
}
}
public void run() {
while (true) {
try {
handleQueuedPacket(packetQueue.take());
} catch (InterruptedException ie) {
} catch (Exception e) {
e.printStackTrace();
}
}
}
private void handleQueuedPacket(QueuedPacket queuedPacket) {
addToPlayerQueueSize(queuedPacket.player, -1);
// Compress the packet if necessary
if (queuedPacket.compress == 1) {
handleMapChunk((Packet51MapChunk) queuedPacket.packet);
} else if (queuedPacket.compress == 2) {
handleMapChunkBulk((Packet56MapChunkBulk) queuedPacket.packet);
}
sendToNetworkQueue(queuedPacket);
}
private void handleMapChunkBulk(Packet56MapChunkBulk packet) {
if (packet.buffer != null) {
return;
}
int dataSize = packet.buildBuffer.length;
if (deflateBuffer.length < dataSize + 100) {
deflateBuffer = new byte[dataSize + 100];
}
deflater.reset();
deflater.setLevel(dataSize < REDUCED_DEFLATE_THRESHOLD ? DEFLATE_LEVEL_PARTS : DEFLATE_LEVEL_CHUNKS);
deflater.setInput(packet.buildBuffer);
deflater.finish();
int size = deflater.deflate(deflateBuffer);
if (size == 0) {
size = deflater.deflate(deflateBuffer);
}
// copy compressed data to packet
packet.buffer = new byte[size];
packet.size = size;
System.arraycopy(deflateBuffer, 0, packet.buffer, 0, size);
}
private void handleMapChunk(Packet51MapChunk packet) {
// If 'packet.buffer' is set then this packet has already been compressed.
if (packet.buffer != null) {
return;
}
int dataSize = packet.inflatedBuffer.length;
if (deflateBuffer.length < dataSize + 100) {
deflateBuffer = new byte[dataSize + 100];
}
deflater.reset();
deflater.setLevel(dataSize < REDUCED_DEFLATE_THRESHOLD ? DEFLATE_LEVEL_PARTS : DEFLATE_LEVEL_CHUNKS);
deflater.setInput(packet.inflatedBuffer);
deflater.finish();
int size = deflater.deflate(deflateBuffer);
if (size == 0) {
size = deflater.deflate(deflateBuffer);
}
// copy compressed data to packet
packet.buffer = new byte[size];
packet.size = size;
System.arraycopy(deflateBuffer, 0, packet.buffer, 0, size);
}
private void sendToNetworkQueue(QueuedPacket queuedPacket) {
queuedPacket.player.netServerHandler.networkManager.queue(queuedPacket.packet);
}
public static void sendPacket(EntityPlayer player, Packet packet) {
int compressType = 0;
if (packet instanceof Packet51MapChunk) {
compressType = 1;
} else if (packet instanceof Packet56MapChunkBulk) {
compressType = 2;
}
instance.addQueuedPacket(new QueuedPacket(player, packet, compressType));
}
private void addToPlayerQueueSize(EntityPlayer player, int amount) {
synchronized (queueSizePerPlayer) {
Integer count = queueSizePerPlayer.get(player);
amount += (count == null) ? 0 : count;
if (amount == 0) {
queueSizePerPlayer.remove(player);
} else {
queueSizePerPlayer.put(player, amount);
}
}
}
public static int getPlayerQueueSize(EntityPlayer player) {
synchronized (instance.queueSizePerPlayer) {
Integer count = instance.queueSizePerPlayer.get(player);
return count == null ? 0 : count;
}
}
private void addQueuedPacket(QueuedPacket task) {
addToPlayerQueueSize(task.player, +1);
while (true) {
try {
packetQueue.put(task);
return;
} catch (InterruptedException e) {
}
}
}
private static class QueuedPacket {
final EntityPlayer player;
final Packet packet;
final int compress;
QueuedPacket(EntityPlayer player, Packet packet, int compress) {
this.player = player;
this.packet = packet;
this.compress = compress;
}
}
}

View file

@ -204,8 +204,6 @@ public final class CraftServer implements Server {
loadPlugins();
enablePlugins(PluginLoadOrder.STARTUP);
ChunkCompressionThread.startThread();
}
private File getConfigFile() {

View file

@ -419,11 +419,11 @@ public class CraftWorld implements World {
}
public long getFullTime() {
return world.F();
return world.getDayTime();
}
public void setFullTime(long time) {
world.setTime(time);
world.setDayTime(time);
// Forces the client to update to the new time immediately
for (Player p : getPlayers()) {

View file

@ -93,7 +93,7 @@ public class PortalTravelAgent implements TravelAgent {
for (int k1 = i1 - this.searchRadius; k1 <= i1 + this.searchRadius; ++k1) {
double d3 = (double) k1 + 0.5D - location.getZ();
for (int l1 = world.O() - 1; l1 >= 0; --l1) {
for (int l1 = world.P() - 1; l1 >= 0; --l1) {
if (world.getTypeId(j1, l1, k1) == Block.PORTAL.id) {
while (world.getTypeId(j1, l1 - 1, k1) == Block.PORTAL.id) {
--l1;
@ -200,7 +200,7 @@ public class PortalTravelAgent implements TravelAgent {
d2 = (double) j2 + 0.5D - location.getZ();
label271:
for (l2 = world.O() - 1; l2 >= 0; --l2) {
for (l2 = world.P() - 1; l2 >= 0; --l2) {
if (world.isEmpty(i2, l2, j2)) {
while (l2 > 0 && world.isEmpty(i2, l2 - 1, j2)) {
--l2;
@ -251,7 +251,7 @@ public class PortalTravelAgent implements TravelAgent {
d2 = (double) j2 + 0.5D - location.getZ();
label219:
for (l2 = world.O() - 1; l2 >= 0; --l2) {
for (l2 = world.P() - 1; l2 >= 0; --l2) {
if (world.isEmpty(i2, l2, j2)) {
while (l2 > 0 && world.isEmpty(i2, l2 - 1, j2)) {
--l2;
@ -312,8 +312,8 @@ public class PortalTravelAgent implements TravelAgent {
i1 = 70;
}
if (i1 > world.O() - 10) {
i1 = world.O() - 10;
if (i1 > world.P() - 10) {
i1 = world.P() - 10;
}
j5 = i1;

View file

@ -1,5 +1,7 @@
package org.bukkit.craftbukkit.block;
import net.minecraft.server.Item;
import net.minecraft.server.ItemStack;
import org.bukkit.Effect;
import org.bukkit.Material;
import org.bukkit.block.Block;
@ -21,14 +23,14 @@ public class CraftJukebox extends CraftBlockState implements Jukebox {
}
public Material getPlaying() {
return Material.getMaterial(jukebox.record);
return Material.getMaterial(jukebox.record.id);
}
public void setPlaying(Material record) {
if (record == null) {
record = Material.AIR;
}
jukebox.record = record.getId();
jukebox.record = new ItemStack(Item.byId[record.getId()], 1);
jukebox.update();
if (record == Material.AIR) {
world.getHandle().setData(getX(), getY(), getZ(), 0);

View file

@ -308,7 +308,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
}
public boolean isBlocking() {
return getHandle().be();
return getHandle().bh();
}
public boolean setWindowProperty(InventoryView.Property prop, int value) {

View file

@ -301,6 +301,6 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
}
public boolean hasLineOfSight(Entity other) {
return getHandle().az().canSee(((CraftEntity) other).getHandle()); // az should be getEntitySenses
return getHandle().aA().canSee(((CraftEntity) other).getHandle()); // az should be getEntitySenses
}
}

View file

@ -12,8 +12,8 @@ public abstract class CraftProjectile extends AbstractProjectile implements Proj
}
public LivingEntity getShooter() {
if (getHandle().shooter instanceof EntityLiving) {
return (LivingEntity) getHandle().shooter.getBukkitEntity();
if (getHandle().getShooter() instanceof EntityLiving) {
return (LivingEntity) getHandle().getShooter().getBukkitEntity();
}
return null;
@ -22,6 +22,9 @@ public abstract class CraftProjectile extends AbstractProjectile implements Proj
public void setShooter(LivingEntity shooter) {
if (shooter instanceof CraftLivingEntity) {
getHandle().shooter = (EntityLiving) ((CraftLivingEntity) shooter).entity;
if (shooter instanceof CraftHumanEntity) {
getHandle().shooterName = ((CraftHumanEntity) shooter).getName();
}
}
}

View file

@ -64,7 +64,7 @@ public class CraftContainer extends Container {
}
@Override
public boolean b(EntityHuman entityhuman) {
public boolean c(EntityHuman entityhuman) {
if (cachedType == view.getType() && cachedSize == getSize() && cachedTitle.equals(view.getTitle())) {
return true;
}
@ -79,8 +79,8 @@ public class CraftContainer extends Container {
int type = getNotchInventoryType(cachedType);
IInventory top = ((CraftInventory)view.getTopInventory()).getInventory();
IInventory bottom = ((CraftInventory)view.getBottomInventory()).getInventory();
this.a.clear();
this.b.clear();
this.c.clear();
if (typeChanged) {
setupSlots(top, bottom);
}
@ -281,7 +281,7 @@ public class CraftContainer extends Container {
// End copy from ContainerBrewingStand
}
public boolean c(EntityHuman entity) {
public boolean a(EntityHuman entity) {
return true;
}
}

View file

@ -108,7 +108,7 @@ public class CraftInventoryCustom extends CraftInventory {
public void update() {}
public boolean a(EntityHuman entityhuman) {
public boolean a_(EntityHuman entityhuman) {
return true;
}