Update CraftBukkit to Minecraft 1.3.1
This commit is contained in:
committed by
Travis Watkins
parent
08e2923bd4
commit
a43d621c01
@@ -1,9 +1,12 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
// CraftBukkit start
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -16,50 +19,28 @@ import org.bukkit.event.inventory.InventoryType;
|
||||
|
||||
public class EntityPlayer extends EntityHuman implements ICrafting {
|
||||
|
||||
private LocaleLanguage locale = new LocaleLanguage("en_US");
|
||||
public NetServerHandler netServerHandler;
|
||||
public MinecraftServer server;
|
||||
public ItemInWorldManager itemInWorldManager;
|
||||
public double d;
|
||||
public double e;
|
||||
public List chunkCoordIntPairQueue = new LinkedList();
|
||||
public Set playerChunkCoordIntPairs = new HashSet();
|
||||
private int cf = -99999999;
|
||||
private int cg = -99999999;
|
||||
private boolean ch = true;
|
||||
public int lastSentExp = -99999999; // CraftBukkit - priv to pub
|
||||
public int invulnerableTicks = 60; // CraftBukkit - private to public; temporary until we get an API out
|
||||
private ItemStack[] ck = new ItemStack[] { null, null, null, null, null};
|
||||
public final List chunkCoordIntPairQueue = new LinkedList();
|
||||
public final List g = new LinkedList();
|
||||
private int ch = -99999999;
|
||||
private int ci = -99999999;
|
||||
private boolean cj = true;
|
||||
public int lastSentExp = -99999999; // CraftBukkit - private -> public
|
||||
public int invulnerableTicks = 60; // CraftBukkit - private -> public
|
||||
private int cm = 0;
|
||||
private int cn = 0;
|
||||
private boolean co = true;
|
||||
private ItemStack[] cp = new ItemStack[] { null, null, null, null, null};
|
||||
private int containerCounter = 0;
|
||||
public boolean h;
|
||||
public int ping;
|
||||
public boolean viewingCredits = false;
|
||||
|
||||
public EntityPlayer(MinecraftServer minecraftserver, World world, String s, ItemInWorldManager iteminworldmanager) {
|
||||
super(world);
|
||||
iteminworldmanager.player = this;
|
||||
this.itemInWorldManager = iteminworldmanager;
|
||||
ChunkCoordinates chunkcoordinates = world.getSpawn();
|
||||
int i = chunkcoordinates.x;
|
||||
int j = chunkcoordinates.z;
|
||||
int k = chunkcoordinates.y;
|
||||
|
||||
if (!world.worldProvider.e) {
|
||||
i += this.random.nextInt(20) - 10;
|
||||
k = world.g(i, j);
|
||||
j += this.random.nextInt(20) - 10;
|
||||
}
|
||||
|
||||
this.setPositionRotation((double) i + 0.5D, (double) k, (double) j + 0.5D, 0.0F, 0.0F);
|
||||
this.server = minecraftserver;
|
||||
this.bP = 0.0F;
|
||||
this.name = s;
|
||||
this.height = 0.0F;
|
||||
|
||||
// CraftBukkit start
|
||||
this.displayName = this.name;
|
||||
this.listName = this.name;
|
||||
}
|
||||
|
||||
// CraftBukkit start
|
||||
public String displayName;
|
||||
public String listName;
|
||||
public org.bukkit.Location compassTarget;
|
||||
@@ -69,23 +50,48 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
||||
public boolean keepLevel = false;
|
||||
// CraftBukkit end
|
||||
|
||||
public EntityPlayer(MinecraftServer minecraftserver, World world, String s, ItemInWorldManager iteminworldmanager) {
|
||||
super(world);
|
||||
iteminworldmanager.player = this;
|
||||
this.itemInWorldManager = iteminworldmanager;
|
||||
this.cm = minecraftserver.getServerConfigurationManager().o();
|
||||
ChunkCoordinates chunkcoordinates = world.getSpawn();
|
||||
int i = chunkcoordinates.x;
|
||||
int j = chunkcoordinates.z;
|
||||
int k = chunkcoordinates.y;
|
||||
|
||||
if (!world.worldProvider.e && world.getWorldData().getGameType() != EnumGamemode.ADVENTURE) {
|
||||
i += this.random.nextInt(20) - 10;
|
||||
k = world.h(i, j);
|
||||
j += this.random.nextInt(20) - 10;
|
||||
}
|
||||
|
||||
this.setPositionRotation((double) i + 0.5D, (double) k, (double) j + 0.5D, 0.0F, 0.0F);
|
||||
this.server = minecraftserver;
|
||||
this.W = 0.0F;
|
||||
this.name = s;
|
||||
this.height = 0.0F;
|
||||
this.displayName = this.name; // CraftBukkit
|
||||
this.listName = this.name; // CraftBukkit
|
||||
}
|
||||
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
super.a(nbttagcompound);
|
||||
if (nbttagcompound.hasKey("playerGameType")) {
|
||||
this.itemInWorldManager.setGameMode(nbttagcompound.getInt("playerGameType"));
|
||||
this.itemInWorldManager.setGameMode(EnumGamemode.a(nbttagcompound.getInt("playerGameType")));
|
||||
}
|
||||
this.getBukkitEntity().readExtraData(nbttagcompound); // CraftBukkit
|
||||
}
|
||||
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
super.b(nbttagcompound);
|
||||
nbttagcompound.setInt("playerGameType", this.itemInWorldManager.getGameMode());
|
||||
nbttagcompound.setInt("playerGameType", this.itemInWorldManager.getGameMode().a());
|
||||
this.getBukkitEntity().setExtraData(nbttagcompound); // CraftBukkit
|
||||
}
|
||||
|
||||
// CraftBukkit start - world fallback code, either respawn location or global spawn
|
||||
public void spawnIn(World world) {
|
||||
super.spawnIn(world);
|
||||
// CraftBukkit start - world fallback code, either respawn location or global spawn
|
||||
if (world == null) {
|
||||
this.dead = false;
|
||||
ChunkCoordinates position = null;
|
||||
@@ -105,8 +111,8 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
||||
}
|
||||
this.dimension = ((WorldServer) this.world).dimension;
|
||||
this.itemInWorldManager.a((WorldServer) world);
|
||||
// CraftBukkit end
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
public void levelDown(int i) {
|
||||
super.levelDown(i);
|
||||
@@ -118,10 +124,10 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
||||
}
|
||||
|
||||
public ItemStack[] getEquipment() {
|
||||
return this.ck;
|
||||
return this.cp;
|
||||
}
|
||||
|
||||
protected void A() {
|
||||
protected void d_() {
|
||||
this.height = 0.0F;
|
||||
}
|
||||
|
||||
@@ -129,22 +135,150 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
||||
return 1.62F;
|
||||
}
|
||||
|
||||
public void F_() {
|
||||
this.itemInWorldManager.c();
|
||||
public void h_() {
|
||||
this.itemInWorldManager.a();
|
||||
--this.invulnerableTicks;
|
||||
this.activeContainer.a();
|
||||
this.activeContainer.b();
|
||||
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
ItemStack itemstack = this.c(i);
|
||||
int i;
|
||||
|
||||
if (itemstack != this.ck[i]) {
|
||||
this.server.getTracker(this.dimension).a(this, new Packet5EntityEquipment(this.id, i, itemstack));
|
||||
this.ck[i] = itemstack;
|
||||
for (i = 0; i < 5; ++i) {
|
||||
ItemStack itemstack = this.b(i);
|
||||
|
||||
if (itemstack != this.cp[i]) {
|
||||
this.q().getTracker().a(this, new Packet5EntityEquipment(this.id, i, itemstack));
|
||||
this.cp[i] = itemstack;
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.chunkCoordIntPairQueue.isEmpty()) {
|
||||
ArrayList arraylist = new ArrayList();
|
||||
Iterator iterator = this.chunkCoordIntPairQueue.iterator();
|
||||
ArrayList arraylist1 = new ArrayList();
|
||||
|
||||
while (iterator.hasNext() && arraylist.size() < 5) {
|
||||
ChunkCoordIntPair chunkcoordintpair = (ChunkCoordIntPair) iterator.next();
|
||||
|
||||
iterator.remove();
|
||||
if (chunkcoordintpair != null && this.world.isLoaded(chunkcoordintpair.x << 4, 0, chunkcoordintpair.z << 4)) {
|
||||
arraylist.add(this.world.getChunkAt(chunkcoordintpair.x, chunkcoordintpair.z));
|
||||
arraylist1.addAll(((WorldServer) this.world).getTileEntities(chunkcoordintpair.x * 16, 0, chunkcoordintpair.z * 16, chunkcoordintpair.x * 16 + 16, 256, chunkcoordintpair.z * 16 + 16));
|
||||
}
|
||||
}
|
||||
|
||||
if (!arraylist.isEmpty()) {
|
||||
this.netServerHandler.sendPacket(new Packet56MapChunkBulk(arraylist));
|
||||
Iterator iterator1 = arraylist1.iterator();
|
||||
|
||||
while (iterator1.hasNext()) {
|
||||
TileEntity tileentity = (TileEntity) iterator1.next();
|
||||
|
||||
this.a(tileentity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.g.isEmpty()) {
|
||||
i = Math.min(this.g.size(), 127);
|
||||
int[] aint = new int[i];
|
||||
Iterator iterator2 = this.g.iterator();
|
||||
int j = 0;
|
||||
|
||||
while (iterator2.hasNext() && j < i) {
|
||||
aint[j++] = ((Integer) iterator2.next()).intValue();
|
||||
iterator2.remove();
|
||||
}
|
||||
|
||||
this.netServerHandler.sendPacket(new Packet29DestroyEntity(aint));
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack c(int i) {
|
||||
public void g() {
|
||||
super.h_();
|
||||
|
||||
for (int i = 0; i < this.inventory.getSize(); ++i) {
|
||||
ItemStack itemstack = this.inventory.getItem(i);
|
||||
|
||||
if (itemstack != null && Item.byId[itemstack.id].m_() && this.netServerHandler.lowPriorityCount() <= 2) {
|
||||
Packet packet = ((ItemWorldMapBase) Item.byId[itemstack.id]).c(itemstack, this.world, this);
|
||||
|
||||
if (packet != null) {
|
||||
this.netServerHandler.sendPacket(packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.bX) {
|
||||
// if (this.server.getAllowNether()) { // CraftBukkit
|
||||
if (this.activeContainer != this.defaultContainer) {
|
||||
this.closeInventory();
|
||||
}
|
||||
|
||||
if (this.vehicle != null) {
|
||||
this.mount(this.vehicle);
|
||||
} else {
|
||||
this.bY += 0.0125F;
|
||||
if (this.bY >= 1.0F) {
|
||||
this.bY = 1.0F;
|
||||
this.bW = 10;
|
||||
boolean flag = false;
|
||||
byte b0;
|
||||
|
||||
if (this.dimension == -1) {
|
||||
b0 = 0;
|
||||
} else {
|
||||
b0 = -1;
|
||||
}
|
||||
|
||||
this.server.getServerConfigurationManager().changeDimension(this, b0);
|
||||
this.lastSentExp = -1;
|
||||
this.ch = -1;
|
||||
this.ci = -1;
|
||||
this.a((Statistic) AchievementList.x);
|
||||
}
|
||||
}
|
||||
|
||||
this.bX = false;
|
||||
// } // CraftBukkit
|
||||
} else {
|
||||
if (this.bY > 0.0F) {
|
||||
this.bY -= 0.05F;
|
||||
}
|
||||
|
||||
if (this.bY < 0.0F) {
|
||||
this.bY = 0.0F;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.bW > 0) {
|
||||
--this.bW;
|
||||
}
|
||||
|
||||
if (this.getHealth() != this.ch || this.ci != this.foodData.a() || this.foodData.e() == 0.0F != this.cj) {
|
||||
this.netServerHandler.sendPacket(new Packet8UpdateHealth(this.getHealth(), this.foodData.a(), this.foodData.e()));
|
||||
this.ch = this.getHealth();
|
||||
this.ci = this.foodData.a();
|
||||
this.cj = this.foodData.e() == 0.0F;
|
||||
}
|
||||
|
||||
if (this.expTotal != this.lastSentExp) {
|
||||
this.lastSentExp = this.expTotal;
|
||||
this.netServerHandler.sendPacket(new Packet43SetExperience(this.exp, this.expTotal, this.expLevel));
|
||||
}
|
||||
|
||||
// CraftBukkit start
|
||||
if (this.oldLevel == -1) {
|
||||
this.oldLevel = this.expLevel;
|
||||
}
|
||||
|
||||
if (this.oldLevel != this.expLevel) {
|
||||
CraftEventFactory.callPlayerLevelChangeEvent(this.world.getServer().getPlayer((EntityPlayer) this), this.oldLevel, this.expLevel);
|
||||
this.oldLevel = this.expLevel;
|
||||
}
|
||||
// CraftBukkit end
|
||||
}
|
||||
|
||||
public ItemStack b(int i) {
|
||||
return i == 0 ? this.inventory.getItemInHand() : this.inventory.armor[i - 1];
|
||||
}
|
||||
|
||||
@@ -169,7 +303,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
||||
String deathMessage = event.getDeathMessage();
|
||||
|
||||
if (deathMessage != null && deathMessage.length() > 0) {
|
||||
this.server.serverConfigurationManager.sendAll(new Packet3Chat(event.getDeathMessage()));
|
||||
this.server.getServerConfigurationManager().sendAll(new Packet3Chat(event.getDeathMessage()));
|
||||
}
|
||||
|
||||
// CraftBukkit - we clean the player's inventory after the EntityDeathEvent is called so plugins can get the exact state of the inventory.
|
||||
@@ -189,7 +323,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
||||
if (this.invulnerableTicks > 0) {
|
||||
return false;
|
||||
} else {
|
||||
// CraftBukkit - this.b.pvpMode -> this.world.pvpMode
|
||||
// CraftBukkit - this.server.getPvP() -> this.world.pvpMode
|
||||
if (!this.world.pvpMode && damagesource instanceof EntityDamageSource) {
|
||||
Entity entity = damagesource.getEntity();
|
||||
|
||||
@@ -210,142 +344,11 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean C() {
|
||||
return this.server.pvpMode;
|
||||
protected boolean h() {
|
||||
return this.server.getPvP();
|
||||
}
|
||||
|
||||
public void heal(int i) {
|
||||
super.heal(i);
|
||||
}
|
||||
|
||||
public void a(boolean flag) {
|
||||
super.F_();
|
||||
|
||||
for (int i = 0; i < this.inventory.getSize(); ++i) {
|
||||
ItemStack itemstack = this.inventory.getItem(i);
|
||||
|
||||
if (itemstack != null && Item.byId[itemstack.id].t_() && this.netServerHandler.lowPriorityCount() <= 2) {
|
||||
Packet packet = ((ItemWorldMapBase) Item.byId[itemstack.id]).c(itemstack, this.world, this);
|
||||
|
||||
if (packet != null) {
|
||||
this.netServerHandler.sendPacket(packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (flag && !this.chunkCoordIntPairQueue.isEmpty()) {
|
||||
ChunkCoordIntPair chunkcoordintpair = (ChunkCoordIntPair) this.chunkCoordIntPairQueue.get(0);
|
||||
double d0 = chunkcoordintpair.a(this);
|
||||
|
||||
for (int j = 0; j < this.chunkCoordIntPairQueue.size(); ++j) {
|
||||
ChunkCoordIntPair chunkcoordintpair1 = (ChunkCoordIntPair) this.chunkCoordIntPairQueue.get(j);
|
||||
double d1 = chunkcoordintpair1.a(this);
|
||||
|
||||
if (d1 < d0) {
|
||||
chunkcoordintpair = chunkcoordintpair1;
|
||||
d0 = d1;
|
||||
}
|
||||
}
|
||||
|
||||
if (chunkcoordintpair != null) {
|
||||
boolean flag1 = false;
|
||||
|
||||
// CraftBukkit - Add check against Chunk Packets in the ChunkCompressionThread.
|
||||
if (this.netServerHandler.lowPriorityCount() + org.bukkit.craftbukkit.ChunkCompressionThread.getPlayerQueueSize(this) < 4) {
|
||||
flag1 = true;
|
||||
}
|
||||
|
||||
if (flag1) {
|
||||
WorldServer worldserver = this.server.getWorldServer(this.dimension);
|
||||
|
||||
if (worldserver.isLoaded(chunkcoordintpair.x << 4, 0, chunkcoordintpair.z << 4)) {
|
||||
Chunk chunk = worldserver.getChunkAt(chunkcoordintpair.x, chunkcoordintpair.z);
|
||||
|
||||
if (chunk.done) {
|
||||
this.chunkCoordIntPairQueue.remove(chunkcoordintpair);
|
||||
this.netServerHandler.sendPacket(new Packet51MapChunk(worldserver.getChunkAt(chunkcoordintpair.x, chunkcoordintpair.z), true, 0));
|
||||
List list = worldserver.getTileEntities(chunkcoordintpair.x * 16, 0, chunkcoordintpair.z * 16, chunkcoordintpair.x * 16 + 16, 256, chunkcoordintpair.z * 16 + 16);
|
||||
|
||||
for (int k = 0; k < list.size(); ++k) {
|
||||
this.a((TileEntity) list.get(k));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.J) {
|
||||
//if (this.server.propertyManager.getBoolean("allow-nether", true)) { // CraftBukkit
|
||||
if (this.activeContainer != this.defaultContainer) {
|
||||
this.closeInventory();
|
||||
}
|
||||
|
||||
if (this.vehicle != null) {
|
||||
this.mount(this.vehicle);
|
||||
} else {
|
||||
this.K += 0.0125F;
|
||||
if (this.K >= 1.0F) {
|
||||
this.K = 1.0F;
|
||||
this.I = 10;
|
||||
boolean flag2 = false;
|
||||
byte b0;
|
||||
|
||||
if (this.dimension == -1) {
|
||||
b0 = 0;
|
||||
} else {
|
||||
b0 = -1;
|
||||
}
|
||||
|
||||
this.server.serverConfigurationManager.changeDimension(this, b0);
|
||||
this.lastSentExp = -1;
|
||||
this.cf = -1;
|
||||
this.cg = -1;
|
||||
this.a((Statistic) AchievementList.x);
|
||||
}
|
||||
}
|
||||
|
||||
this.J = false;
|
||||
//} // CraftBukkit
|
||||
} else {
|
||||
if (this.K > 0.0F) {
|
||||
this.K -= 0.05F;
|
||||
}
|
||||
|
||||
if (this.K < 0.0F) {
|
||||
this.K = 0.0F;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.I > 0) {
|
||||
--this.I;
|
||||
}
|
||||
|
||||
if (this.getHealth() != this.cf || this.cg != this.foodData.a() || this.foodData.c() == 0.0F != this.ch) {
|
||||
this.netServerHandler.sendPacket(new Packet8UpdateHealth(this.getHealth(), this.foodData.a(), this.foodData.c()));
|
||||
this.cf = this.getHealth();
|
||||
this.cg = this.foodData.a();
|
||||
this.ch = this.foodData.c() == 0.0F;
|
||||
}
|
||||
|
||||
if (this.expTotal != this.lastSentExp) {
|
||||
this.lastSentExp = this.expTotal;
|
||||
this.netServerHandler.sendPacket(new Packet43SetExperience(this.exp, this.expTotal, this.expLevel));
|
||||
}
|
||||
|
||||
// CraftBukkit start
|
||||
if (this.oldLevel == -1) {
|
||||
this.oldLevel = this.expLevel;
|
||||
}
|
||||
|
||||
if (this.oldLevel != this.expLevel) {
|
||||
CraftEventFactory.callPlayerLevelChangeEvent(this.world.getServer().getPlayer((EntityPlayer) this), this.oldLevel, this.expLevel);
|
||||
this.oldLevel = this.expLevel;
|
||||
}
|
||||
// CraftBukkit end
|
||||
}
|
||||
|
||||
public void e(int i) {
|
||||
public void c(int i) {
|
||||
if (this.dimension == 1 && i == 1) {
|
||||
this.a((Statistic) AchievementList.C);
|
||||
this.world.kill(this);
|
||||
@@ -354,23 +357,23 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
||||
} else {
|
||||
this.a((Statistic) AchievementList.B);
|
||||
/* CraftBukkit start - removed to fix our handling of The End portals
|
||||
ChunkCoordinates chunkcoordinates = this.b.getWorldServer(i).d();
|
||||
ChunkCoordinates chunkcoordinates = this.server.getWorldServer(i).getDimensionSpawn();
|
||||
|
||||
if (chunkcoordinates != null) {
|
||||
this.netServerHandler.a((double) chunkcoordinates.x, (double) chunkcoordinates.y, (double) chunkcoordinates.z, 0.0F, 0.0F);
|
||||
}
|
||||
// CraftBukkit end */
|
||||
|
||||
this.server.serverConfigurationManager.changeDimension(this, 1);
|
||||
this.server.getServerConfigurationManager().changeDimension(this, 1);
|
||||
this.lastSentExp = -1;
|
||||
this.cf = -1;
|
||||
this.cg = -1;
|
||||
this.ch = -1;
|
||||
this.ci = -1;
|
||||
}
|
||||
}
|
||||
|
||||
private void a(TileEntity tileentity) {
|
||||
if (tileentity != null) {
|
||||
Packet packet = tileentity.d();
|
||||
Packet packet = tileentity.e();
|
||||
|
||||
if (packet != null) {
|
||||
this.netServerHandler.sendPacket(packet);
|
||||
@@ -380,7 +383,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
||||
|
||||
public void receive(Entity entity, int i) {
|
||||
if (!entity.dead) {
|
||||
EntityTracker entitytracker = this.server.getTracker(this.dimension);
|
||||
EntityTracker entitytracker = this.q().getTracker();
|
||||
|
||||
if (entity instanceof EntityItem) {
|
||||
entitytracker.a(entity, new Packet22Collect(entity.id, this.id));
|
||||
@@ -396,29 +399,24 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
||||
}
|
||||
|
||||
super.receive(entity, i);
|
||||
this.activeContainer.a();
|
||||
this.activeContainer.b();
|
||||
}
|
||||
|
||||
public void C_() {
|
||||
if (!this.t) {
|
||||
this.u = -1;
|
||||
this.t = true;
|
||||
EntityTracker entitytracker = this.server.getTracker(this.dimension);
|
||||
|
||||
entitytracker.a(this, new Packet18ArmAnimation(this, 1));
|
||||
public void i() {
|
||||
if (!this.bH) {
|
||||
this.bI = -1;
|
||||
this.bH = true;
|
||||
this.q().getTracker().a(this, new Packet18ArmAnimation(this, 1));
|
||||
}
|
||||
}
|
||||
|
||||
public void E() {}
|
||||
|
||||
public EnumBedResult a(int i, int j, int k) {
|
||||
EnumBedResult enumbedresult = super.a(i, j, k);
|
||||
|
||||
if (enumbedresult == EnumBedResult.OK) {
|
||||
EntityTracker entitytracker = this.server.getTracker(this.dimension);
|
||||
Packet17EntityLocationAction packet17entitylocationaction = new Packet17EntityLocationAction(this, 0, i, j, k);
|
||||
|
||||
entitytracker.a(this, packet17entitylocationaction);
|
||||
this.q().getTracker().a(this, packet17entitylocationaction);
|
||||
this.netServerHandler.a(this.locX, this.locY, this.locZ, this.yaw, this.pitch);
|
||||
this.netServerHandler.sendPacket(packet17entitylocationaction);
|
||||
}
|
||||
@@ -428,9 +426,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
||||
|
||||
public void a(boolean flag, boolean flag1, boolean flag2) {
|
||||
if (this.isSleeping()) {
|
||||
EntityTracker entitytracker = this.server.getTracker(this.dimension);
|
||||
|
||||
entitytracker.sendPacketToEntity(this, new Packet18ArmAnimation(this, 3));
|
||||
this.q().getTracker().sendPacketToEntity(this, new Packet18ArmAnimation(this, 3));
|
||||
}
|
||||
|
||||
super.a(flag, flag1, flag2);
|
||||
@@ -493,6 +489,10 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
||||
}
|
||||
|
||||
public void openContainer(IInventory iinventory) {
|
||||
if (this.activeContainer != this.defaultContainer) {
|
||||
this.closeInventory();
|
||||
}
|
||||
|
||||
// CraftBukkit start - INVENTORY_OPEN hook
|
||||
Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerChest(this.inventory, iinventory));
|
||||
if(container == null) return;
|
||||
@@ -544,6 +544,35 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
||||
this.activeContainer.addSlotListener(this);
|
||||
}
|
||||
|
||||
public void openTrade(IMerchant imerchant) {
|
||||
// CraftBukkit start - INVENTORY_OPEN hook
|
||||
Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerMerchant(this.inventory, imerchant, this.world));
|
||||
if(container == null) return;
|
||||
// CraftBukkit end
|
||||
|
||||
this.nextContainerCounter();
|
||||
this.activeContainer = container; // CraftBukkit - User container passed to event
|
||||
this.activeContainer.windowId = this.containerCounter;
|
||||
this.activeContainer.addSlotListener(this);
|
||||
InventoryMerchant inventorymerchant = ((ContainerMerchant) this.activeContainer).getMerchantInventory();
|
||||
|
||||
this.netServerHandler.sendPacket(new Packet100OpenWindow(this.containerCounter, 6, inventorymerchant.getName(), inventorymerchant.getSize()));
|
||||
MerchantRecipeList merchantrecipelist = imerchant.getOffers(this);
|
||||
|
||||
if (merchantrecipelist != null) {
|
||||
try {
|
||||
ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream();
|
||||
DataOutputStream dataoutputstream = new DataOutputStream(bytearrayoutputstream);
|
||||
|
||||
dataoutputstream.writeInt(this.containerCounter);
|
||||
merchantrecipelist.a(dataoutputstream);
|
||||
this.netServerHandler.sendPacket(new Packet250CustomPayload("MC|TrList", bytearrayoutputstream.toByteArray()));
|
||||
} catch (IOException ioexception) {
|
||||
ioexception.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void a(Container container, int i, ItemStack itemstack) {
|
||||
if (!(container.getSlot(i) instanceof SlotResult)) {
|
||||
if (!this.h) {
|
||||
@@ -553,7 +582,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
||||
}
|
||||
|
||||
public void updateInventory(Container container) {
|
||||
this.a(container, container.b());
|
||||
this.a(container, container.a());
|
||||
}
|
||||
|
||||
public void a(Container container, List list) {
|
||||
@@ -570,11 +599,9 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
||||
this.netServerHandler.sendPacket(new Packet105CraftProgressBar(container.windowId, i, j));
|
||||
}
|
||||
|
||||
public void carriedChanged(ItemStack itemstack) {}
|
||||
|
||||
public void closeInventory() {
|
||||
this.netServerHandler.sendPacket(new Packet101CloseWindow(this.activeContainer.windowId));
|
||||
this.H();
|
||||
this.l();
|
||||
}
|
||||
|
||||
public void broadcastCarriedItem() {
|
||||
@@ -583,7 +610,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
||||
}
|
||||
}
|
||||
|
||||
public void H() {
|
||||
public void l() {
|
||||
this.activeContainer.a((EntityHuman) this);
|
||||
this.activeContainer = this.defaultContainer;
|
||||
}
|
||||
@@ -601,7 +628,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
||||
}
|
||||
}
|
||||
|
||||
public void I() {
|
||||
public void m() {
|
||||
if (this.vehicle != null) {
|
||||
this.mount(this.vehicle);
|
||||
}
|
||||
@@ -615,32 +642,35 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
||||
}
|
||||
}
|
||||
|
||||
public void D_() {
|
||||
this.cf = -99999999;
|
||||
public void n() {
|
||||
this.ch = -99999999;
|
||||
this.lastSentExp = -1; // CraftBukkit - Added to reset
|
||||
}
|
||||
|
||||
public void a(String s) {
|
||||
public void c(String s) {
|
||||
LocaleLanguage localelanguage = LocaleLanguage.a();
|
||||
String s1 = localelanguage.b(s);
|
||||
|
||||
this.netServerHandler.sendPacket(new Packet3Chat(s1));
|
||||
}
|
||||
|
||||
protected void K() {
|
||||
protected void o() {
|
||||
this.netServerHandler.sendPacket(new Packet38EntityStatus(this.id, (byte) 9));
|
||||
super.K();
|
||||
super.o();
|
||||
}
|
||||
|
||||
public void a(ItemStack itemstack, int i) {
|
||||
super.a(itemstack, i);
|
||||
if (itemstack != null && itemstack.getItem() != null && itemstack.getItem().d(itemstack) == EnumAnimation.b) {
|
||||
EntityTracker entitytracker = this.server.getTracker(this.dimension);
|
||||
|
||||
entitytracker.sendPacketToEntity(this, new Packet18ArmAnimation(this, 5));
|
||||
if (itemstack != null && itemstack.getItem() != null && itemstack.getItem().b(itemstack) == EnumAnimation.b) {
|
||||
this.q().getTracker().sendPacketToEntity(this, new Packet18ArmAnimation(this, 5));
|
||||
}
|
||||
}
|
||||
|
||||
protected void a(MobEffect mobeffect) {
|
||||
super.a(mobeffect);
|
||||
this.netServerHandler.sendPacket(new Packet41MobEffect(this.id, mobeffect));
|
||||
}
|
||||
|
||||
protected void b(MobEffect mobeffect) {
|
||||
super.b(mobeffect);
|
||||
this.netServerHandler.sendPacket(new Packet41MobEffect(this.id, mobeffect));
|
||||
@@ -648,11 +678,6 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
||||
|
||||
protected void c(MobEffect mobeffect) {
|
||||
super.c(mobeffect);
|
||||
this.netServerHandler.sendPacket(new Packet41MobEffect(this.id, mobeffect));
|
||||
}
|
||||
|
||||
protected void d(MobEffect mobeffect) {
|
||||
super.d(mobeffect);
|
||||
this.netServerHandler.sendPacket(new Packet42RemoveMobEffect(this.id, mobeffect));
|
||||
}
|
||||
|
||||
@@ -660,16 +685,12 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
||||
this.netServerHandler.a(d0, d1, d2, this.yaw, this.pitch);
|
||||
}
|
||||
|
||||
public void c(Entity entity) {
|
||||
EntityTracker entitytracker = this.server.getTracker(this.dimension);
|
||||
|
||||
entitytracker.sendPacketToEntity(this, new Packet18ArmAnimation(entity, 6));
|
||||
public void b(Entity entity) {
|
||||
this.q().getTracker().sendPacketToEntity(this, new Packet18ArmAnimation(entity, 6));
|
||||
}
|
||||
|
||||
public void d(Entity entity) {
|
||||
EntityTracker entitytracker = this.server.getTracker(this.dimension);
|
||||
|
||||
entitytracker.sendPacketToEntity(this, new Packet18ArmAnimation(entity, 7));
|
||||
public void c(Entity entity) {
|
||||
this.q().getTracker().sendPacketToEntity(this, new Packet18ArmAnimation(entity, 7));
|
||||
}
|
||||
|
||||
public void updateAbilities() {
|
||||
@@ -678,6 +699,63 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
||||
}
|
||||
}
|
||||
|
||||
public WorldServer q() {
|
||||
return (WorldServer) this.world;
|
||||
}
|
||||
|
||||
public void a(EnumGamemode enumgamemode) {
|
||||
this.itemInWorldManager.setGameMode(enumgamemode);
|
||||
this.netServerHandler.sendPacket(new Packet70Bed(3, enumgamemode.a()));
|
||||
}
|
||||
|
||||
public void sendMessage(String s) {
|
||||
this.netServerHandler.sendPacket(new Packet3Chat(s));
|
||||
}
|
||||
|
||||
public boolean b(String s) {
|
||||
return "seed".equals(s) && !this.server.S() ? true : this.server.getServerConfigurationManager().isOp(this.name);
|
||||
}
|
||||
|
||||
public String r() {
|
||||
String s = this.netServerHandler.networkManager.getSocketAddress().toString();
|
||||
|
||||
s = s.substring(s.indexOf("/") + 1);
|
||||
s = s.substring(0, s.indexOf(":"));
|
||||
return s;
|
||||
}
|
||||
|
||||
public void a(Packet204LocaleAndViewDistance packet204localeandviewdistance) {
|
||||
if (this.locale.b().containsKey(packet204localeandviewdistance.d())) {
|
||||
this.locale.a(packet204localeandviewdistance.d());
|
||||
}
|
||||
|
||||
int i = 256 >> packet204localeandviewdistance.f();
|
||||
|
||||
if (i > 3 && i < 15) {
|
||||
this.cm = i;
|
||||
}
|
||||
|
||||
this.cn = packet204localeandviewdistance.g();
|
||||
this.co = packet204localeandviewdistance.h();
|
||||
if (this.server.H() && this.server.G().equals(this.name)) {
|
||||
this.server.c(packet204localeandviewdistance.i());
|
||||
}
|
||||
}
|
||||
|
||||
public LocaleLanguage getLocale() {
|
||||
return this.locale;
|
||||
}
|
||||
|
||||
public int getChatFlags() {
|
||||
return this.cn;
|
||||
}
|
||||
|
||||
public void a(String s, int i) {
|
||||
String s1 = s + "\0" + i; // CraftBukkit - fix decompile error
|
||||
|
||||
this.netServerHandler.sendPacket(new Packet250CustomPayload("MC|TPack", s1.getBytes()));
|
||||
}
|
||||
|
||||
// CraftBukkit start
|
||||
public long timeOffset = 0;
|
||||
public boolean relativeTime = true;
|
||||
|
||||
Reference in New Issue
Block a user