Added 1.7 files.

Removed 1.6 files.
This commit is contained in:
Jonathan Williams 2014-03-19 00:58:43 -07:00
parent 24f1c6c722
commit 98baef09bf
51 changed files with 7456 additions and 6552 deletions

Binary file not shown.

View File

@ -1,80 +0,0 @@
package net.minecraft.server.v1_6_R3;
import net.minecraft.server.v1_6_R3.PendingConnection;
import org.bukkit.craftbukkit.v1_6_R3.CraftServer;
import org.bukkit.craftbukkit.v1_6_R3.util.Waitable;
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
import org.bukkit.event.player.PlayerPreLoginEvent;
@SuppressWarnings("deprecation")
public class AsyncLoginThread extends Thread
{
final PendingConnection pendingConnection;
// CraftBukkit start
CraftServer server;
AsyncLoginThread(PendingConnection pendingconnection, CraftServer server)
{
this.server = server;
// CraftBukkit end
this.pendingConnection = pendingconnection;
}
public void run()
{
try
{
// CraftBukkit start
if (this.pendingConnection.getSocket() == null) {
return;
}
AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(PendingConnection.d(this.pendingConnection), this.pendingConnection.getSocket().getInetAddress());
this.server.getPluginManager().callEvent(asyncEvent);
if (PlayerPreLoginEvent.getHandlerList().getRegisteredListeners().length != 0)
{
final PlayerPreLoginEvent event = new PlayerPreLoginEvent(PendingConnection.d(this.pendingConnection), this.pendingConnection.getSocket().getInetAddress());
if (asyncEvent.getResult() != PlayerPreLoginEvent.Result.ALLOWED)
{
event.disallow(asyncEvent.getResult(), asyncEvent.getKickMessage());
}
Waitable<PlayerPreLoginEvent.Result> waitable = new Waitable<PlayerPreLoginEvent.Result>()
{
@Override
protected PlayerPreLoginEvent.Result evaluate()
{
AsyncLoginThread.this.server.getPluginManager().callEvent(event);
return event.getResult();
}};
PendingConnection.b(this.pendingConnection).processQueue.add(waitable);
if (waitable.get() != PlayerPreLoginEvent.Result.ALLOWED)
{
this.pendingConnection.disconnect(event.getKickMessage());
return;
}
}
else
{
if (asyncEvent.getLoginResult() != AsyncPlayerPreLoginEvent.Result.ALLOWED)
{
this.pendingConnection.disconnect(asyncEvent.getKickMessage());
return;
}
}
// CraftBukkit end
PendingConnection.a(this.pendingConnection, true);
// CraftBukkit start
}
catch (Exception exception)
{
this.pendingConnection.disconnect("Failed to verify username!");
server.getLogger().log(java.util.logging.Level.WARNING, "Exception verifying " + PendingConnection.d(this.pendingConnection), exception);
// CraftBukkit end
}
}
}

View File

@ -1,315 +0,0 @@
package net.minecraft.server.v1_6_R3;
import java.util.Random;
import java.util.UUID;
import org.bukkit.craftbukkit.v1_6_R3.CraftServer;
import org.bukkit.craftbukkit.v1_6_R3.TrigMath;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftEntity;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
import org.bukkit.event.entity.EntityUnleashEvent;
import org.bukkit.event.entity.EntityUnleashEvent.UnleashReason;
import org.bukkit.plugin.PluginManager;
public abstract class EntityCreature extends EntityInsentient
{
public static final UUID h = UUID.fromString("E199AD21-BA8A-4C53-8D13-6182D5C69D3A");
public static final AttributeModifier i = new AttributeModifier(h, "Fleeing speed bonus", 2.0D, 2).a(false);
public PathEntity pathEntity;
public Entity target;
protected boolean bn;
protected int bo;
private ChunkCoordinates bq = new ChunkCoordinates(0, 0, 0);
private float br = -1.0F;
private PathfinderGoal bs = new PathfinderGoalMoveTowardsRestriction(this, 1.0D);
private boolean bt;
public EntityCreature(World world)
{
super(world);
}
protected boolean bJ() {
return false;
}
protected void bl() {
this.world.methodProfiler.a("ai");
if ((this.bo > 0) && (--this.bo == 0)) {
AttributeInstance attributeinstance = getAttributeInstance(GenericAttributes.d);
attributeinstance.b(i);
}
this.bn = bJ();
float f11 = 16.0F;
if (this.target == null)
{
Entity target = findTarget();
if (target != null) {
EntityTargetEvent event = new EntityTargetEvent(getBukkitEntity(), target.getBukkitEntity(), EntityTargetEvent.TargetReason.CLOSEST_PLAYER);
this.world.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
if (event.getTarget() == null)
this.target = null;
else {
this.target = ((CraftEntity)event.getTarget()).getHandle();
}
}
}
if (this.target != null)
this.pathEntity = this.world.findPath(this, this.target, f11, true, false, false, true);
}
else if (this.target.isAlive()) {
float f1 = this.target.d(this);
if (o(this.target))
a(this.target, f1);
}
else
{
EntityTargetEvent event = new EntityTargetEvent(getBukkitEntity(), null, EntityTargetEvent.TargetReason.TARGET_DIED);
this.world.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
if (event.getTarget() == null)
this.target = null;
else {
this.target = ((CraftEntity)event.getTarget()).getHandle();
}
}
}
this.world.methodProfiler.b();
if ((!this.bn) && (this.target != null) && ((this.pathEntity == null) || (this.random.nextInt(20) == 0)))
this.pathEntity = this.world.findPath(this, this.target, f11, true, false, false, true);
else if ((!this.bn) && (((this.pathEntity == null) && (this.random.nextInt(180) == 0)) || (((this.random.nextInt(120) == 0) || (this.bo > 0)) && (this.aV < 100)))) {
bK();
}
int i = MathHelper.floor(this.boundingBox.b + 0.5D);
boolean flag = H();
boolean flag1 = J();
this.pitch = 0.0F;
if ((this.pathEntity != null) && (this.random.nextInt(100) != 0)) {
this.world.methodProfiler.a("followpath");
Vec3D vec3d = this.pathEntity.a(this);
double d0 = this.width * 2.0F;
while ((vec3d != null) && (vec3d.d(this.locX, vec3d.d, this.locZ) < d0 * d0)) {
this.pathEntity.a();
if (this.pathEntity.b()) {
vec3d = null;
this.pathEntity = null;
} else {
vec3d = this.pathEntity.a(this);
}
}
this.bd = false;
if (vec3d != null) {
double d1 = vec3d.c - this.locX;
double d2 = vec3d.e - this.locZ;
double d3 = vec3d.d - i;
float f2 = (float)(TrigMath.atan2(d2, d1) * 180.0D / 3.141592741012573D) - 90.0F;
float f3 = MathHelper.g(f2 - this.yaw);
this.bf = ((float)getAttributeInstance(GenericAttributes.d).getValue());
if (f3 > 30.0F) {
f3 = 30.0F;
}
if (f3 < -30.0F) {
f3 = -30.0F;
}
this.yaw += f3;
if ((this.bn) && (this.target != null)) {
double d4 = this.target.locX - this.locX;
double d5 = this.target.locZ - this.locZ;
float f4 = this.yaw;
this.yaw = ((float)(Math.atan2(d5, d4) * 180.0D / 3.141592741012573D) - 90.0F);
f3 = (f4 - this.yaw + 90.0F) * 3.141593F / 180.0F;
this.be = (-MathHelper.sin(f3) * this.bf * 1.0F);
this.bf = (MathHelper.cos(f3) * this.bf * 1.0F);
}
if (d3 > 0.0D) {
this.bd = true;
}
}
if (this.target != null) {
a(this.target, 30.0F, 30.0F);
}
if ((this.positionChanged) && (!bM())) {
this.bd = true;
}
if ((this.random.nextFloat() < 0.8F) && ((flag) || (flag1))) {
this.bd = true;
}
this.world.methodProfiler.b();
} else {
super.bl();
this.pathEntity = null;
}
}
protected void bK() {
this.world.methodProfiler.a("stroll");
boolean flag = false;
int i = -1;
int j = -1;
int k = -1;
float f = -99999.0F;
for (int l = 0; l < 10; l++) {
int i1 = MathHelper.floor(this.locX + this.random.nextInt(13) - 6.0D);
int j1 = MathHelper.floor(this.locY + this.random.nextInt(7) - 3.0D);
int k1 = MathHelper.floor(this.locZ + this.random.nextInt(13) - 6.0D);
float f1 = a(i1, j1, k1);
if (f1 > f) {
f = f1;
i = i1;
j = j1;
k = k1;
flag = true;
}
}
if (flag) {
this.pathEntity = this.world.a(this, i, j, k, 10.0F, true, false, false, true);
}
this.world.methodProfiler.b();
}
protected void a(Entity entity, float f) {
}
public float a(int i, int j, int k) {
return 0.0F;
}
protected Entity findTarget() {
return null;
}
public boolean canSpawn() {
int i = MathHelper.floor(this.locX);
int j = MathHelper.floor(this.boundingBox.b);
int k = MathHelper.floor(this.locZ);
return (super.canSpawn()) && (a(i, j, k) >= 0.0F);
}
public boolean bM() {
return this.pathEntity != null;
}
public void setPathEntity(PathEntity pathentity) {
this.pathEntity = pathentity;
}
public Entity bN() {
return this.target;
}
public void setTarget(Entity entity) {
this.target = entity;
}
public boolean bO() {
return b(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ));
}
public boolean b(int i, int j, int k) {
return this.br == -1.0F;
}
public void b(int i, int j, int k, int l) {
this.bq.b(i, j, k);
this.br = l;
}
public ChunkCoordinates bP() {
return this.bq;
}
public float bQ() {
return this.br;
}
public void bR() {
this.br = -1.0F;
}
public boolean bS() {
return this.br != -1.0F;
}
protected void bF() {
super.bF();
if ((bH()) && (getLeashHolder() != null) && (getLeashHolder().world == this.world) && this.PullWhileLeashed) {
Entity entity = getLeashHolder();
b((int)entity.locX, (int)entity.locY, (int)entity.locZ, 5);
float f = d(entity);
if (((this instanceof EntityTameableAnimal)) && (((EntityTameableAnimal)this).isSitting())) {
if (f > 10.0F) {
this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE));
unleash(true, true);
}
return;
}
if (!this.bt) {
this.goalSelector.a(2, this.bs);
getNavigation().a(false);
this.bt = true;
}
o(f);
if (f > 4.0F) {
getNavigation().a(entity, 1.0D);
}
if (f > 6.0F) {
double d0 = (entity.locX - this.locX) / f;
double d1 = (entity.locY - this.locY) / f;
double d2 = (entity.locZ - this.locZ) / f;
this.motX += d0 * Math.abs(d0) * 0.4D;
this.motY += d1 * Math.abs(d1) * 0.4D;
this.motZ += d2 * Math.abs(d2) * 0.4D;
}
if (f > 10.0F) {
this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE));
unleash(true, true);
}
} else if ((!bH()) && (this.bt)) {
this.bt = false;
this.goalSelector.a(this.bs);
getNavigation().a(true);
bR();
}
}
protected void o(float f)
{
}
}

View File

@ -1,246 +0,0 @@
package net.minecraft.server.v1_6_R3;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.Random;
import org.bukkit.craftbukkit.v1_6_R3.event.CraftEventFactory;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
public class EntityFallingBlock extends Entity
{
public int id;
public int data;
public int c;
public boolean dropItem;
private boolean f;
private boolean hurtEntities;
private int fallHurtMax;
private float fallHurtAmount;
public NBTTagCompound tileEntityData;
public boolean spectating;
public EntityFallingBlock(World world)
{
super(world);
this.dropItem = true;
this.fallHurtMax = 40;
this.fallHurtAmount = 2.0F;
}
public EntityFallingBlock(World world, double d0, double d1, double d2, int i) {
this(world, d0, d1, d2, i, 0);
}
public EntityFallingBlock(World world, double d0, double d1, double d2, int i, int j) {
super(world);
this.dropItem = true;
this.fallHurtMax = 40;
this.fallHurtAmount = 2.0F;
this.id = i;
this.data = j;
this.m = true;
a(0.98F, 0.98F);
this.height = (this.length / 2.0F);
setPosition(d0, d1, d2);
this.motX = 0.0D;
this.motY = 0.0D;
this.motZ = 0.0D;
this.lastX = d0;
this.lastY = d1;
this.lastZ = d2;
}
protected boolean e_() {
return false;
}
protected void a() {
}
public boolean L() {
return !this.dead && !spectating;
}
public void l_() {
if (this.id == 0) {
die();
} else {
this.lastX = this.locX;
this.lastY = this.locY;
this.lastZ = this.locZ;
this.c += 1;
this.motY -= 0.03999999910593033D;
move(this.motX, this.motY, this.motZ);
this.motX *= 0.9800000190734863D;
this.motY *= 0.9800000190734863D;
this.motZ *= 0.9800000190734863D;
if (!this.world.isStatic) {
int i = MathHelper.floor(this.locX);
int j = MathHelper.floor(this.locY);
int k = MathHelper.floor(this.locZ);
if (this.c == 1)
{
if ((this.c != 1) || (this.world.getTypeId(i, j, k) != this.id) || (this.world.getData(i, j, k) != this.data) || (CraftEventFactory.callEntityChangeBlockEvent(this, i, j, k, 0, 0).isCancelled())) {
die();
return;
}
this.world.setAir(i, j, k);
}
if (this.onGround) {
this.motX *= 0.699999988079071D;
this.motZ *= 0.699999988079071D;
this.motY *= -0.5D;
if (this.world.getTypeId(i, j, k) != Block.PISTON_MOVING.id) {
die();
if ((!this.f) && (this.world.mayPlace(this.id, i, j, k, true, 1, (Entity)null, (ItemStack)null)) && (!BlockSand.canFall(this.world, i, j - 1, k)) && (i >= -30000000) && (k >= -30000000) && (i < 30000000) && (k < 30000000) && (j > 0) && (j < 256) && ((this.world.getTypeId(i, j, k) != this.id) || (this.world.getData(i, j, k) != this.data))) {
if (CraftEventFactory.callEntityChangeBlockEvent(this, i, j, k, this.id, this.data).isCancelled()) {
return;
}
this.world.setTypeIdAndData(i, j, k, this.id, this.data, 3);
if ((Block.byId[this.id] instanceof BlockSand)) {
((BlockSand)Block.byId[this.id]).a_(this.world, i, j, k, this.data);
}
if ((this.tileEntityData != null) && ((Block.byId[this.id] instanceof IContainer))) {
TileEntity tileentity = this.world.getTileEntity(i, j, k);
if (tileentity != null) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
tileentity.b(nbttagcompound);
Iterator iterator = this.tileEntityData.c().iterator();
while (iterator.hasNext()) {
NBTBase nbtbase = (NBTBase)iterator.next();
if ((!nbtbase.getName().equals("x")) && (!nbtbase.getName().equals("y")) && (!nbtbase.getName().equals("z"))) {
nbttagcompound.set(nbtbase.getName(), nbtbase.clone());
}
}
tileentity.a(nbttagcompound);
tileentity.update();
}
}
} else if ((this.dropItem) && (!this.f)) {
a(new ItemStack(this.id, 1, Block.byId[this.id].getDropData(this.data)), 0.0F);
}
}
} else if (((this.c > 100) && (!this.world.isStatic) && ((j < 1) || (j > 256))) || (this.c > 600)) {
if (this.dropItem) {
a(new ItemStack(this.id, 1, Block.byId[this.id].getDropData(this.data)), 0.0F);
}
die();
}
}
}
}
protected void b(float f) {
if (this.hurtEntities) {
int i = MathHelper.f(f - 1.0F);
if (i > 0) {
ArrayList arraylist = new ArrayList(this.world.getEntities(this, this.boundingBox));
DamageSource damagesource = this.id == Block.ANVIL.id ? DamageSource.ANVIL : DamageSource.FALLING_BLOCK;
Iterator iterator = arraylist.iterator();
while (iterator.hasNext()) {
Entity entity = (Entity)iterator.next();
float damage = Math.min(MathHelper.d(i * this.fallHurtAmount), this.fallHurtMax);
EntityDamageEvent event = CraftEventFactory.callEntityDamageEvent(this, entity, EntityDamageEvent.DamageCause.FALLING_BLOCK, damage);
if (!event.isCancelled())
{
entity.damageEntity(damagesource, (float)event.getDamage());
}
}
if ((this.id == Block.ANVIL.id) && (this.random.nextFloat() < 0.0500000007450581D + i * 0.05D)) {
int j = this.data >> 2;
int k = this.data & 0x3;
j++;
if (j > 2)
this.f = true;
else
this.data = (k | j << 2);
}
}
}
}
protected void b(NBTTagCompound nbttagcompound)
{
nbttagcompound.setByte("Tile", (byte)this.id);
nbttagcompound.setInt("TileID", this.id);
nbttagcompound.setByte("Data", (byte)this.data);
nbttagcompound.setByte("Time", (byte)this.c);
nbttagcompound.setBoolean("DropItem", this.dropItem);
nbttagcompound.setBoolean("HurtEntities", this.hurtEntities);
nbttagcompound.setFloat("FallHurtAmount", this.fallHurtAmount);
nbttagcompound.setInt("FallHurtMax", this.fallHurtMax);
if (this.tileEntityData != null)
nbttagcompound.setCompound("TileEntityData", this.tileEntityData);
}
protected void a(NBTTagCompound nbttagcompound)
{
if (nbttagcompound.hasKey("TileID"))
this.id = nbttagcompound.getInt("TileID");
else {
this.id = (nbttagcompound.getByte("Tile") & 0xFF);
}
this.data = (nbttagcompound.getByte("Data") & 0xFF);
this.c = (nbttagcompound.getByte("Time") & 0xFF);
if (nbttagcompound.hasKey("HurtEntities")) {
this.hurtEntities = nbttagcompound.getBoolean("HurtEntities");
this.fallHurtAmount = nbttagcompound.getFloat("FallHurtAmount");
this.fallHurtMax = nbttagcompound.getInt("FallHurtMax");
} else if (this.id == Block.ANVIL.id) {
this.hurtEntities = true;
}
if (nbttagcompound.hasKey("DropItem")) {
this.dropItem = nbttagcompound.getBoolean("DropItem");
}
if (nbttagcompound.hasKey("TileEntityData")) {
this.tileEntityData = nbttagcompound.getCompound("TileEntityData");
}
if (nbttagcompound.hasKey("Bukkit.tileData")) {
this.tileEntityData = ((NBTTagCompound)nbttagcompound.getCompound("Bukkit.tileData").clone());
}
if (this.id == 0)
this.id = Block.SAND.id;
}
public void a(boolean flag)
{
this.hurtEntities = flag;
}
public void a(CrashReportSystemDetails crashreportsystemdetails) {
super.a(crashreportsystemdetails);
crashreportsystemdetails.a("Immitating block ID", Integer.valueOf(this.id));
crashreportsystemdetails.a("Immitating block data", Integer.valueOf(this.data));
}
public boolean damageEntity(DamageSource damagesource, float f) {
CraftEventFactory.handleEntityDamageEvent(this, damagesource, f);
return false;
}
}

View File

@ -1,263 +0,0 @@
package net.minecraft.server.v1_6_R3;
//CraftBukkit start
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_6_R3.inventory.CraftItemStack;
import org.bukkit.event.entity.EntityTargetEvent;
//CraftBukkit end
public class EntityGhast extends EntityFlying implements IMonster {
public int h;
public double i;
public double j;
public double bn;
private Entity target;
private int br;
public int bo;
public int bp;
private int explosionPower = 1;
public EntityGhast(World world) {
super(world);
this.a(4.0F, 4.0F);
this.fireProof = true;
this.b = 5;
}
public boolean damageEntity(DamageSource damagesource, float f) {
if (this.isInvulnerable()) {
return false;
} else if ("fireball".equals(damagesource.n()) && damagesource.getEntity() instanceof EntityHuman) {
super.damageEntity(damagesource, 1000.0F);
((EntityHuman) damagesource.getEntity()).a((Statistic) AchievementList.y);
return true;
} else {
return super.damageEntity(damagesource, f);
}
}
protected void a() {
super.a();
this.datawatcher.a(16, Byte.valueOf((byte) 0));
}
protected void az() {
super.az();
this.getAttributeInstance(GenericAttributes.a).setValue(10.0D);
}
protected void bl() {
if (!this.world.isStatic && this.world.difficulty == 0) {
this.die();
}
if (Vegetated)
{
double d0 = this.i - this.locX;
double d1 = this.j - this.locY;
double d2 = this.bn - this.locZ;
double d3 = d0 * d0 + d1 * d1 + d2 * d2;
this.motX += d0 / d3 * 0.1D;
this.motY += d1 / d3 * 0.1D;
this.motZ += d2 / d3 * 0.1D;
double d5 = this.i - this.locX;
double d6 = this.bn - this.locZ;
this.aN = this.yaw = -((float) Math.atan2(d5, d6)) * 180.0F / 3.1415927F;
return;
}
this.u();
this.bo = this.bp;
double d0 = this.i - this.locX;
double d1 = this.j - this.locY;
double d2 = this.bn - this.locZ;
double d3 = d0 * d0 + d1 * d1 + d2 * d2;
if (d3 < 1.0D || d3 > 3600.0D) {
this.i = this.locX + (double) ((this.random.nextFloat() * 2.0F - 1.0F) * 16.0F);
this.j = this.locY + (double) ((this.random.nextFloat() * 2.0F - 1.0F) * 16.0F);
this.bn = this.locZ + (double) ((this.random.nextFloat() * 2.0F - 1.0F) * 16.0F);
}
if (this.h-- <= 0) {
this.h += this.random.nextInt(5) + 2;
d3 = (double) MathHelper.sqrt(d3);
if (this.a(this.i, this.j, this.bn, d3)) {
this.motX += d0 / d3 * 0.1D;
this.motY += d1 / d3 * 0.1D;
this.motZ += d2 / d3 * 0.1D;
} else {
this.i = this.locX;
this.j = this.locY;
this.bn = this.locZ;
}
}
if (this.target != null && this.target.dead) {
// CraftBukkit start
EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), null, EntityTargetEvent.TargetReason.TARGET_DIED);
this.world.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
if (event.getTarget() == null) {
this.target = null;
} else {
this.target = ((CraftEntity) event.getTarget()).getHandle();
}
}
// CraftBukkit end
}
if (this.target == null || this.br-- <= 0) {
// CraftBukkit start
Entity target = this.world.findNearbyVulnerablePlayer(this, 100.0D);
if (target != null) {
EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), target.getBukkitEntity(), EntityTargetEvent.TargetReason.CLOSEST_PLAYER);
this.world.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
if (event.getTarget() == null) {
this.target = null;
} else {
this.target = ((CraftEntity) event.getTarget()).getHandle();
}
}
}
// CraftBukkit end
if (this.target != null) {
this.br = 20;
}
}
double d4 = 64.0D;
if (this.target != null && this.target.e((Entity) this) < d4 * d4) {
double d5 = this.target.locX - this.locX;
double d6 = this.target.boundingBox.b + (double) (this.target.length / 2.0F) - (this.locY + (double) (this.length / 2.0F));
double d7 = this.target.locZ - this.locZ;
this.aN = this.yaw = -((float) Math.atan2(d5, d7)) * 180.0F / 3.1415927F;
if (this.o(this.target)) {
if (this.bp == 10) {
this.world.a((EntityHuman) null, 1007, (int) this.locX, (int) this.locY, (int) this.locZ, 0);
}
++this.bp;
if (this.bp == 20) {
this.world.a((EntityHuman) null, 1008, (int) this.locX, (int) this.locY, (int) this.locZ, 0);
EntityLargeFireball entitylargefireball = new EntityLargeFireball(this.world, this, d5, d6, d7);
// CraftBukkit - set bukkitYield when setting explosionpower
entitylargefireball.bukkitYield = entitylargefireball.yield = this.explosionPower;
double d8 = 4.0D;
Vec3D vec3d = this.j(1.0F);
entitylargefireball.locX = this.locX + vec3d.c * d8;
entitylargefireball.locY = this.locY + (double) (this.length / 2.0F) + 0.5D;
entitylargefireball.locZ = this.locZ + vec3d.e * d8;
this.world.addEntity(entitylargefireball);
this.bp = -40;
}
} else if (this.bp > 0) {
--this.bp;
}
} else {
this.aN = this.yaw = -((float) Math.atan2(this.motX, this.motZ)) * 180.0F / 3.1415927F;
if (this.bp > 0) {
--this.bp;
}
}
if (!this.world.isStatic) {
byte b0 = this.datawatcher.getByte(16);
byte b1 = (byte) (this.bp > 10 ? 1 : 0);
if (b0 != b1) {
this.datawatcher.watch(16, Byte.valueOf(b1));
}
}
}
private boolean a(double d0, double d1, double d2, double d3) {
double d4 = (this.i - this.locX) / d3;
double d5 = (this.j - this.locY) / d3;
double d6 = (this.bn - this.locZ) / d3;
AxisAlignedBB axisalignedbb = this.boundingBox.clone();
for (int i = 1; (double) i < d3; ++i) {
axisalignedbb.d(d4, d5, d6);
if (!this.world.getCubes(this, axisalignedbb).isEmpty()) {
return false;
}
}
return true;
}
protected String r() {
return "mob.ghast.moan";
}
protected String aO() {
return "mob.ghast.scream";
}
protected String aP() {
return "mob.ghast.death";
}
protected int getLootId() {
return Item.SULPHUR.id;
}
protected void dropDeathLoot(boolean flag, int i) {
// CraftBukkit start
java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>();
int j = this.random.nextInt(2) + this.random.nextInt(1 + i);
int k;
if (j > 0) {
loot.add(CraftItemStack.asNewCraftStack(Item.GHAST_TEAR, j));
}
j = this.random.nextInt(3) + this.random.nextInt(1 + i);
if (j > 0) {
loot.add(CraftItemStack.asNewCraftStack(Item.SULPHUR, j));
}
org.bukkit.craftbukkit.v1_6_R3.event.CraftEventFactory.callEntityDeathEvent(this, loot);
// CraftBukkit end
}
protected float ba() {
return 10.0F;
}
public boolean canSpawn() {
return this.random.nextInt(20) == 0 && super.canSpawn() && this.world.difficulty > 0;
}
public int bv() {
return 1;
}
public void b(NBTTagCompound nbttagcompound) {
super.b(nbttagcompound);
nbttagcompound.setInt("ExplosionPower", this.explosionPower);
}
public void a(NBTTagCompound nbttagcompound) {
super.a(nbttagcompound);
if (nbttagcompound.hasKey("ExplosionPower")) {
this.explosionPower = nbttagcompound.getInt("ExplosionPower");
}
}
}

View File

@ -1,102 +0,0 @@
package net.minecraft.server.v1_6_R3;
import org.bukkit.craftbukkit.v1_6_R3.CraftServer;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftEntity;
import org.bukkit.entity.Explosive;
import org.bukkit.event.entity.ExplosionPrimeEvent;
import org.bukkit.plugin.PluginManager;
public class EntityTNTPrimed extends Entity
{
public int fuseTicks;
private EntityLiving source;
public float yield = 4.0F;
public boolean isIncendiary = false;
public boolean spectating = false;
public EntityTNTPrimed(World world) {
super(world);
this.m = true;
a(0.98F, 0.98F);
this.height = (this.length / 2.0F);
}
public EntityTNTPrimed(World world, double d0, double d1, double d2, EntityLiving entityliving) {
this(world);
setPosition(d0, d1, d2);
float f = (float)(Math.random() * 3.141592741012573D * 2.0D);
this.motX = (-(float)Math.sin(f) * 0.02F);
this.motY = 0.2000000029802322D;
this.motZ = (-(float)Math.cos(f) * 0.02F);
this.fuseTicks = 80;
this.lastX = d0;
this.lastY = d1;
this.lastZ = d2;
this.source = entityliving;
}
protected void a() {
}
protected boolean e_() {
return false;
}
public boolean L() {
return !this.dead && !spectating;
}
public void l_() {
this.lastX = this.locX;
this.lastY = this.locY;
this.lastZ = this.locZ;
this.motY -= 0.03999999910593033D;
move(this.motX, this.motY, this.motZ);
this.motX *= 0.9800000190734863D;
this.motY *= 0.9800000190734863D;
this.motZ *= 0.9800000190734863D;
if (this.onGround) {
this.motX *= 0.699999988079071D;
this.motZ *= 0.699999988079071D;
this.motY *= -0.5D;
}
if (this.fuseTicks-- <= 0)
{
if (!this.world.isStatic) {
explode();
}
die();
}
else {
this.world.addParticle("smoke", this.locX, this.locY + 0.5D, this.locZ, 0.0D, 0.0D, 0.0D);
}
}
private void explode()
{
CraftServer server = this.world.getServer();
ExplosionPrimeEvent event = new ExplosionPrimeEvent((Explosive)CraftEntity.getEntity(server, this));
server.getPluginManager().callEvent(event);
if (!event.isCancelled())
{
this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire(), true);
}
}
protected void b(NBTTagCompound nbttagcompound)
{
nbttagcompound.setByte("Fuse", (byte)this.fuseTicks);
}
protected void a(NBTTagCompound nbttagcompound) {
this.fuseTicks = nbttagcompound.getByte("Fuse");
}
public EntityLiving getSource() {
return this.source;
}
}

View File

@ -1,435 +0,0 @@
package net.minecraft.server.v1_6_R3;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.EOFException;
import java.io.IOException;
import java.net.Socket;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import net.minecraft.server.v1_6_R3.Connection;
import net.minecraft.server.v1_6_R3.IConsoleLogManager;
import net.minecraft.server.v1_6_R3.IntHashMap;
import net.minecraft.server.v1_6_R3.ItemStack;
import net.minecraft.server.v1_6_R3.MinecraftServer;
import net.minecraft.server.v1_6_R3.NBTCompressedStreamTools;
import net.minecraft.server.v1_6_R3.NBTTagCompound;
import net.minecraft.server.v1_6_R3.Packet;
import net.minecraft.server.v1_6_R3.Packet0KeepAlive;
import net.minecraft.server.v1_6_R3.Packet100OpenWindow;
import net.minecraft.server.v1_6_R3.Packet101CloseWindow;
import net.minecraft.server.v1_6_R3.Packet102WindowClick;
import net.minecraft.server.v1_6_R3.Packet103SetSlot;
import net.minecraft.server.v1_6_R3.Packet104WindowItems;
import net.minecraft.server.v1_6_R3.Packet105CraftProgressBar;
import net.minecraft.server.v1_6_R3.Packet106Transaction;
import net.minecraft.server.v1_6_R3.Packet107SetCreativeSlot;
import net.minecraft.server.v1_6_R3.Packet108ButtonClick;
import net.minecraft.server.v1_6_R3.Packet10Flying;
import net.minecraft.server.v1_6_R3.Packet11PlayerPosition;
import net.minecraft.server.v1_6_R3.Packet12PlayerLook;
import net.minecraft.server.v1_6_R3.Packet130UpdateSign;
import net.minecraft.server.v1_6_R3.Packet131ItemData;
import net.minecraft.server.v1_6_R3.Packet132TileEntityData;
import net.minecraft.server.v1_6_R3.Packet133OpenTileEntity;
import net.minecraft.server.v1_6_R3.Packet13PlayerLookMove;
import net.minecraft.server.v1_6_R3.Packet14BlockDig;
import net.minecraft.server.v1_6_R3.Packet15Place;
import net.minecraft.server.v1_6_R3.Packet16BlockItemSwitch;
import net.minecraft.server.v1_6_R3.Packet17EntityLocationAction;
import net.minecraft.server.v1_6_R3.Packet18ArmAnimation;
import net.minecraft.server.v1_6_R3.Packet19EntityAction;
import net.minecraft.server.v1_6_R3.Packet1Login;
import net.minecraft.server.v1_6_R3.Packet200Statistic;
import net.minecraft.server.v1_6_R3.Packet201PlayerInfo;
import net.minecraft.server.v1_6_R3.Packet202Abilities;
import net.minecraft.server.v1_6_R3.Packet203TabComplete;
import net.minecraft.server.v1_6_R3.Packet204LocaleAndViewDistance;
import net.minecraft.server.v1_6_R3.Packet205ClientCommand;
import net.minecraft.server.v1_6_R3.Packet206SetScoreboardObjective;
import net.minecraft.server.v1_6_R3.Packet207SetScoreboardScore;
import net.minecraft.server.v1_6_R3.Packet208SetScoreboardDisplayObjective;
import net.minecraft.server.v1_6_R3.Packet209SetScoreboardTeam;
import net.minecraft.server.v1_6_R3.Packet20NamedEntitySpawn;
import net.minecraft.server.v1_6_R3.Packet22Collect;
import net.minecraft.server.v1_6_R3.Packet23VehicleSpawn;
import net.minecraft.server.v1_6_R3.Packet24MobSpawn;
import net.minecraft.server.v1_6_R3.Packet250CustomPayload;
import net.minecraft.server.v1_6_R3.Packet252KeyResponse;
import net.minecraft.server.v1_6_R3.Packet253KeyRequest;
import net.minecraft.server.v1_6_R3.Packet254GetInfo;
import net.minecraft.server.v1_6_R3.Packet255KickDisconnect;
import net.minecraft.server.v1_6_R3.Packet25EntityPainting;
import net.minecraft.server.v1_6_R3.Packet26AddExpOrb;
import net.minecraft.server.v1_6_R3.Packet27PlayerInput;
import net.minecraft.server.v1_6_R3.Packet28EntityVelocity;
import net.minecraft.server.v1_6_R3.Packet29DestroyEntity;
import net.minecraft.server.v1_6_R3.Packet2Handshake;
import net.minecraft.server.v1_6_R3.Packet30Entity;
import net.minecraft.server.v1_6_R3.Packet31RelEntityMove;
import net.minecraft.server.v1_6_R3.Packet32EntityLook;
import net.minecraft.server.v1_6_R3.Packet33RelEntityMoveLook;
import net.minecraft.server.v1_6_R3.Packet34EntityTeleport;
import net.minecraft.server.v1_6_R3.Packet35EntityHeadRotation;
import net.minecraft.server.v1_6_R3.Packet38EntityStatus;
import net.minecraft.server.v1_6_R3.Packet39AttachEntity;
import net.minecraft.server.v1_6_R3.Packet3Chat;
import net.minecraft.server.v1_6_R3.Packet40EntityMetadata;
import net.minecraft.server.v1_6_R3.Packet41MobEffect;
import net.minecraft.server.v1_6_R3.Packet42RemoveMobEffect;
import net.minecraft.server.v1_6_R3.Packet43SetExperience;
import net.minecraft.server.v1_6_R3.Packet44UpdateAttributes;
import net.minecraft.server.v1_6_R3.Packet4UpdateTime;
import net.minecraft.server.v1_6_R3.Packet51MapChunk;
import net.minecraft.server.v1_6_R3.Packet52MultiBlockChange;
import net.minecraft.server.v1_6_R3.Packet53BlockChange;
import net.minecraft.server.v1_6_R3.Packet54PlayNoteBlock;
import net.minecraft.server.v1_6_R3.Packet55BlockBreakAnimation;
import net.minecraft.server.v1_6_R3.Packet56MapChunkBulk;
import net.minecraft.server.v1_6_R3.Packet5EntityEquipment;
import net.minecraft.server.v1_6_R3.Packet60Explosion;
import net.minecraft.server.v1_6_R3.Packet61WorldEvent;
import net.minecraft.server.v1_6_R3.Packet62NamedSoundEffect;
import net.minecraft.server.v1_6_R3.Packet63WorldParticles;
import net.minecraft.server.v1_6_R3.Packet6SpawnPosition;
import net.minecraft.server.v1_6_R3.Packet70Bed;
import net.minecraft.server.v1_6_R3.Packet71Weather;
import net.minecraft.server.v1_6_R3.Packet7UseEntity;
import net.minecraft.server.v1_6_R3.Packet8UpdateHealth;
import net.minecraft.server.v1_6_R3.Packet9Respawn;
import net.minecraft.server.v1_6_R3.PacketCounter;
import org.bukkit.craftbukkit.v1_6_R3.inventory.CraftItemStack; // CraftBukkit
public abstract class Packet {
public static IntHashMap l = new IntHashMap();
private static Map a = new HashMap();
private static Set b = new HashSet();
private static Set c = new HashSet();
protected IConsoleLogManager m;
public final long timestamp = MinecraftServer.aq();
public static long o;
public static long p;
public static long q;
public static long r;
public boolean lowPriority;
// CraftBukkit start - Calculate packet ID once - used a bunch of times
private int packetID;
public Packet() {
packetID = ((Integer) a.get(this.getClass())).intValue();
}
// CraftBukkit end
static void a(int i, boolean flag, boolean flag1, Class oclass) {
if (l.b(i)) {
throw new IllegalArgumentException("Duplicate packet id:" + i);
} else if (a.containsKey(oclass)) {
throw new IllegalArgumentException("Duplicate packet class:" + oclass);
} else {
l.a(i, oclass);
a.put(oclass, Integer.valueOf(i));
if (flag) {
b.add(Integer.valueOf(i));
}
if (flag1) {
c.add(Integer.valueOf(i));
}
}
}
public static Packet a(IConsoleLogManager iconsolelogmanager, int i) {
try {
Class oclass = (Class) l.get(i);
return oclass == null ? null : (Packet) oclass.newInstance();
} catch (Exception exception) {
exception.printStackTrace();
iconsolelogmanager.severe("Skipping packet with id " + i);
return null;
}
}
public static void a(DataOutput dataoutput, byte[] abyte) throws IOException { // CraftBukkit - throws IOException
dataoutput.writeShort(abyte.length);
dataoutput.write(abyte);
}
public static byte[] b(DataInput datainput) throws IOException { // CraftBukkit - throws IOException
short short1 = datainput.readShort();
if (short1 < 0) {
throw new IOException("Key was smaller than nothing! Weird key!");
} else {
byte[] abyte = new byte[short1];
datainput.readFully(abyte);
return abyte;
}
}
public final int n() {
return packetID; // ((Integer) a.get(this.getClass())).intValue(); // CraftBukkit
}
public static Packet a(IConsoleLogManager iconsolelogmanager, DataInput datainput, boolean flag, Socket socket) throws IOException { // CraftBukkit - throws IOException
boolean flag1 = false;
Packet packet = null;
int i = socket.getSoTimeout();
int j;
try {
j = datainput.readUnsignedByte();
if (flag && !c.contains(Integer.valueOf(j)) || !flag && !b.contains(Integer.valueOf(j))) {
throw new IOException("Bad packet id " + j);
}
packet = a(iconsolelogmanager, j);
if (packet == null) {
throw new IOException("Bad packet id " + j);
}
packet.m = iconsolelogmanager;
if (packet instanceof Packet254GetInfo) {
socket.setSoTimeout(1500);
}
packet.a(datainput);
++o;
p += (long) packet.a();
} catch (EOFException eofexception) {
if (eofexception.getMessage() != null)
iconsolelogmanager.severe("Reached end of stream for " + socket.getInetAddress());
return null;
}
// CraftBukkit start
catch (java.net.SocketTimeoutException exception) {
iconsolelogmanager.info("Read timed out");
return null;
} catch (java.net.SocketException exception) {
iconsolelogmanager.info("Connection reset");
return null;
}
// CraftBukkit end
PacketCounter.a(j, (long) packet.a());
++o;
p += (long) packet.a();
socket.setSoTimeout(i);
return packet;
}
public static void a(Packet packet, DataOutput dataoutput) throws IOException { // CraftBukkit - throws IOException
dataoutput.write(packet.n());
packet.a(dataoutput);
++q;
r += (long) packet.a();
}
public static void a(String s, DataOutput dataoutput) throws IOException { // CraftBukkit - throws IOException
if (s.length() > 32767) {
throw new IOException("String too big");
} else {
dataoutput.writeShort(s.length());
dataoutput.writeChars(s);
}
}
public static String a(DataInput datainput, int i) throws IOException { // CraftBukkit - throws IOException
short short1 = datainput.readShort();
if (short1 > i) {
throw new IOException("Received string length longer than maximum allowed (" + short1 + " > " + i + ")");
} else if (short1 < 0) {
throw new IOException("Received string length is less than zero! Weird string!");
} else {
StringBuilder stringbuilder = new StringBuilder();
for (int j = 0; j < short1; ++j) {
stringbuilder.append(datainput.readChar());
}
return stringbuilder.toString();
}
}
public abstract void a(DataInput datainput) throws IOException; // CraftBukkit - throws IOException
public abstract void a(DataOutput dataoutput) throws IOException; // CraftBukkit - throws IOException
public abstract void handle(Connection connection);
public abstract int a();
public boolean e() {
return false;
}
public boolean a(Packet packet) {
return false;
}
public boolean a_() {
return this instanceof Packet3Chat && !((Packet3Chat) this).message.startsWith("/"); // CraftBukkit - async chat
}
public String toString() {
String s = this.getClass().getSimpleName();
return s;
}
public static ItemStack c(DataInput datainput) throws IOException { // CraftBukkit - throws IOException
ItemStack itemstack = null;
short short1 = datainput.readShort();
if (short1 >= 0) {
byte b0 = datainput.readByte();
short short2 = datainput.readShort();
itemstack = new ItemStack(short1, b0, short2);
itemstack.tag = d(datainput);
// CraftBukkit start
if (itemstack.tag != null) {
CraftItemStack.setItemMeta(itemstack, CraftItemStack.getItemMeta(itemstack));
}
// CraftBukkit end
}
return itemstack;
}
public static void a(ItemStack itemstack, DataOutput dataoutput) throws IOException { // CraftBukkit - throws IOException
if (itemstack == null || itemstack.getItem() == null) { // CraftBukkit - NPE fix itemstack.getItem()
dataoutput.writeShort(-1);
} else {
dataoutput.writeShort(itemstack.id);
dataoutput.writeByte(itemstack.count);
dataoutput.writeShort(itemstack.getData());
NBTTagCompound nbttagcompound = null;
if (itemstack.getItem().usesDurability() || itemstack.getItem().s()) {
nbttagcompound = itemstack.tag;
}
a(nbttagcompound, dataoutput);
}
}
public static NBTTagCompound d(DataInput datainput) throws IOException { // CraftBukkit - throws IOException
short short1 = datainput.readShort();
if (short1 < 0) {
return null;
} else {
byte[] abyte = new byte[short1];
datainput.readFully(abyte);
return NBTCompressedStreamTools.a(abyte);
}
}
protected static void a(NBTTagCompound nbttagcompound, DataOutput dataoutput) throws IOException { // CraftBukkit - throws IOException
if (nbttagcompound == null) {
dataoutput.writeShort(-1);
} else {
byte[] abyte = NBTCompressedStreamTools.a(nbttagcompound);
dataoutput.writeShort((short) abyte.length);
dataoutput.write(abyte);
}
}
static {
a(0, true, true, Packet0KeepAlive.class);
a(1, true, true, Packet1Login.class);
a(2, false, true, Packet2Handshake.class);
a(3, true, true, Packet3Chat.class);
a(4, true, false, Packet4UpdateTime.class);
a(5, true, false, Packet5EntityEquipment.class);
a(6, true, false, Packet6SpawnPosition.class);
a(7, false, true, Packet7UseEntity.class);
a(8, true, false, Packet8UpdateHealth.class);
a(9, true, true, Packet9Respawn.class);
a(10, true, true, Packet10Flying.class);
a(11, true, true, Packet11PlayerPosition.class);
a(12, true, true, Packet12PlayerLook.class);
a(13, true, true, Packet13PlayerLookMove.class);
a(14, false, true, Packet14BlockDig.class);
a(15, false, true, Packet15Place.class);
a(16, true, true, Packet16BlockItemSwitch.class);
a(17, true, false, Packet17EntityLocationAction.class);
a(18, true, true, Packet18ArmAnimation.class);
a(19, false, true, Packet19EntityAction.class);
a(20, true, false, Packet20NamedEntitySpawn.class);
a(22, true, false, Packet22Collect.class);
a(23, true, false, Packet23VehicleSpawn.class);
a(24, true, false, Packet24MobSpawn.class);
a(25, true, false, Packet25EntityPainting.class);
a(26, true, false, Packet26AddExpOrb.class);
a(27, false, true, Packet27PlayerInput.class);
a(28, true, false, Packet28EntityVelocity.class);
a(29, true, false, Packet29DestroyEntity.class);
a(30, true, false, Packet30Entity.class);
a(31, true, false, Packet31RelEntityMove.class);
a(32, true, false, Packet32EntityLook.class);
a(33, true, false, Packet33RelEntityMoveLook.class);
a(34, true, false, Packet34EntityTeleport.class);
a(35, true, false, Packet35EntityHeadRotation.class);
a(38, true, false, Packet38EntityStatus.class);
a(39, true, false, Packet39AttachEntity.class);
a(40, true, false, Packet40EntityMetadata.class);
a(41, true, false, Packet41MobEffect.class);
a(42, true, false, Packet42RemoveMobEffect.class);
a(43, true, false, Packet43SetExperience.class);
a(44, true, false, Packet44UpdateAttributes.class);
a(51, true, false, Packet51MapChunk.class);
a(52, true, false, Packet52MultiBlockChange.class);
a(53, true, false, Packet53BlockChange.class);
a(54, true, false, Packet54PlayNoteBlock.class);
a(55, true, false, Packet55BlockBreakAnimation.class);
a(56, true, false, Packet56MapChunkBulk.class);
a(60, true, false, Packet60Explosion.class);
a(61, true, false, Packet61WorldEvent.class);
a(62, true, false, Packet62NamedSoundEffect.class);
a(63, true, false, Packet63WorldParticles.class);
a(70, true, false, Packet70Bed.class);
a(71, true, false, Packet71Weather.class);
a(100, true, false, Packet100OpenWindow.class);
a(101, true, true, Packet101CloseWindow.class);
a(102, false, true, Packet102WindowClick.class);
a(103, true, false, Packet103SetSlot.class);
a(104, true, false, Packet104WindowItems.class);
a(105, true, false, Packet105CraftProgressBar.class);
a(106, true, true, Packet106Transaction.class);
a(107, true, true, Packet107SetCreativeSlot.class);
a(108, false, true, Packet108ButtonClick.class);
a(130, true, true, Packet130UpdateSign.class);
a(131, true, false, Packet131ItemData.class);
a(132, true, false, Packet132TileEntityData.class);
a(133, true, false, Packet133OpenTileEntity.class);
a(200, true, false, Packet200Statistic.class);
a(201, true, false, Packet201PlayerInfo.class);
a(202, true, true, Packet202Abilities.class);
a(203, true, true, Packet203TabComplete.class);
a(204, false, true, Packet204LocaleAndViewDistance.class);
a(205, false, true, Packet205ClientCommand.class);
a(206, true, false, Packet206SetScoreboardObjective.class);
a(207, true, false, Packet207SetScoreboardScore.class);
a(208, true, false, Packet208SetScoreboardDisplayObjective.class);
a(209, true, false, Packet209SetScoreboardTeam.class);
a(250, true, true, Packet250CustomPayload.class);
a(252, true, true, Packet252KeyResponse.class);
a(253, true, false, Packet253KeyRequest.class);
a(254, false, true, Packet254GetInfo.class);
a(255, true, true, Packet255KickDisconnect.class);
}
}

View File

@ -1,234 +0,0 @@
package net.minecraft.server.v1_6_R3;
import java.io.Serializable;
import java.net.InetAddress;
import java.net.Socket;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import javax.crypto.SecretKey;
import net.minecraft.server.v1_6_R3.Connection;
import net.minecraft.server.v1_6_R3.DedicatedServerConnection;
import net.minecraft.server.v1_6_R3.EntityPlayer;
import net.minecraft.server.v1_6_R3.INetworkManager;
import net.minecraft.server.v1_6_R3.MinecraftServer;
import net.minecraft.server.v1_6_R3.NetworkManager;
import net.minecraft.server.v1_6_R3.Packet;
import net.minecraft.server.v1_6_R3.Packet1Login;
import net.minecraft.server.v1_6_R3.Packet205ClientCommand;
import net.minecraft.server.v1_6_R3.Packet252KeyResponse;
import net.minecraft.server.v1_6_R3.Packet253KeyRequest;
import net.minecraft.server.v1_6_R3.Packet254GetInfo;
import net.minecraft.server.v1_6_R3.Packet255KickDisconnect;
import net.minecraft.server.v1_6_R3.Packet2Handshake;
import net.minecraft.server.v1_6_R3.PendingConnection;
import net.minecraft.server.v1_6_R3.PlayerList;
import net.minecraft.server.v1_6_R3.StripColor;
public class PendingConnection extends Connection {
private static Random random = new Random();
private byte[] d;
private final MinecraftServer server;
public final NetworkManager networkManager;
public boolean b;
private int f;
private String g;
private volatile boolean h;
private String loginKey = Long.toString(random.nextLong(), 16); // CraftBukkit - Security fix
private boolean j;
private SecretKey k;
public String hostname = ""; // CraftBukkit - add field
public PendingConnection(MinecraftServer minecraftserver, Socket socket, String s) throws java.io.IOException { // CraftBukkit - throws IOException
this.server = minecraftserver;
this.networkManager = new NetworkManager(minecraftserver.getLogger(), socket, s, this, minecraftserver.H().getPrivate());
this.networkManager.e = 0;
}
// CraftBukkit start
public Socket getSocket() {
return this.networkManager.getSocket();
}
// CraftBukkit end
public void d() {
if (this.h) {
this.e();
}
if (this.f++ == 600) {
this.disconnect("Took too long to log in");
} else {
this.networkManager.b();
}
}
public void disconnect(String s) {
try {
this.server.getLogger().info("Disconnecting " + this.getName() + ": " + s);
this.networkManager.queue(new Packet255KickDisconnect(s));
this.networkManager.d();
this.b = true;
} catch (Exception exception) {
exception.printStackTrace();
}
}
public void a(Packet2Handshake packet2handshake) {
if (this.g != null) {
this.disconnect("Quit repeating yourself!");
} else {
this.g = packet2handshake.f();
if (!this.g.equals(StripColor.a(this.g))) {
this.disconnect("Invalid username!");
} else {
PublicKey publickey = this.server.H().getPublic();
if (packet2handshake.d() != 78) {
if (packet2handshake.d() > 78) {
this.disconnect("Outdated server!");
} else {
this.disconnect("Outdated client!");
}
} else {
this.loginKey = this.server.getOnlineMode() ? Long.toString(random.nextLong(), 16) : "-";
this.d = new byte[4];
random.nextBytes(this.d);
this.networkManager.queue(new Packet253KeyRequest(this.loginKey, publickey, this.d));
}
}
}
}
public void a(Packet252KeyResponse packet252keyresponse) {
PrivateKey privatekey = this.server.H().getPrivate();
this.k = packet252keyresponse.a(privatekey);
if (!Arrays.equals(this.d, packet252keyresponse.b(privatekey))) {
this.disconnect("Invalid client reply");
}
this.networkManager.queue(new Packet252KeyResponse());
}
public void a(Packet205ClientCommand packet205clientcommand) {
if (packet205clientcommand.a == 0) {
if (this.j) {
this.disconnect("Duplicate login");
return;
}
this.j = true;
(new AsyncLoginThread(this, server.server)).start(); // CraftBukkit - add CraftServer
}
}
public void a(Packet1Login packet1login) {}
public void e() {
// CraftBukkit start
EntityPlayer s = this.server.getPlayerList().attemptLogin(this, this.g, this.hostname);
if (s == null) {
// this.disconnect(s);
return;
// CraftBukkit end
} else {
EntityPlayer entityplayer = this.server.getPlayerList().processLogin(s); // CraftBukkit - this.g -> s
if (entityplayer != null) {
this.server.getPlayerList().a((INetworkManager) this.networkManager, entityplayer);
}
}
this.b = true;
}
public void a(String s, Object[] aobject) {
this.server.getLogger().info(this.getName() + " lost connection");
this.b = true;
}
public void a(Packet254GetInfo packet254getinfo) {
if (this.networkManager.getSocket() == null) return; // CraftBukkit - fix NPE when a client queries a server that is unable to handle it.
try {
PlayerList playerlist = this.server.getPlayerList();
String s = null;
// CraftBukkit
org.bukkit.event.server.ServerListPingEvent pingEvent = org.bukkit.craftbukkit.v1_6_R3.event.CraftEventFactory.callServerListPingEvent(this.server.server, getSocket().getInetAddress(), this.server.getMotd(), playerlist.getPlayerCount(), playerlist.getMaxPlayers());
if (packet254getinfo.d()) {
// CraftBukkit
s = pingEvent.getMotd() + "\u00A7" + playerlist.getPlayerCount() + "\u00A7" + pingEvent.getMaxPlayers();
} else {
List list = Arrays.asList(new Serializable[] { Integer.valueOf(1), Integer.valueOf(78), this.server.getVersion(), pingEvent.getMotd(), Integer.valueOf(playerlist.getPlayerCount()), pingEvent.getMaxPlayers()});
Object object;
for (Iterator iterator = list.iterator(); iterator.hasNext(); s = s + object.toString().replaceAll("\0", "")) {
object = iterator.next();
if (s == null) {
s = "\u00A7";
} else {
s = s + '\0';
}
}
}
InetAddress inetaddress = null;
if (this.networkManager.getSocket() != null) {
inetaddress = this.networkManager.getSocket().getInetAddress();
}
this.networkManager.queue(new Packet255KickDisconnect(s));
this.networkManager.d();
if (inetaddress != null && this.server.ag() instanceof DedicatedServerConnection) {
((DedicatedServerConnection) this.server.ag()).a(inetaddress);
}
this.b = true;
} catch (Exception exception) {
exception.printStackTrace();
}
}
public void onUnhandledPacket(Packet packet) {
this.disconnect("Protocol error");
}
public String getName() {
return this.g != null ? this.g + " [" + this.networkManager.getSocketAddress().toString() + "]" : this.networkManager.getSocketAddress().toString();
}
public boolean a() {
return true;
}
public boolean c() {
return this.b;
}
static String a(PendingConnection pendingconnection) {
return pendingconnection.loginKey;
}
static MinecraftServer b(PendingConnection pendingconnection) {
return pendingconnection.server;
}
static SecretKey c(PendingConnection pendingconnection) {
return pendingconnection.k;
}
static String d(PendingConnection pendingconnection) {
return pendingconnection.g;
}
static boolean a(PendingConnection pendingconnection, boolean flag) {
return pendingconnection.h = flag;
}
}

View File

@ -1,4 +1,4 @@
package net.minecraft.server.v1_6_R3;
package net.minecraft.server.v1_7_R1;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;

View File

@ -1,4 +1,4 @@
package net.minecraft.server.v1_6_R3;
package net.minecraft.server.v1_7_R1;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;

View File

@ -1,42 +1,36 @@
package net.minecraft.server.v1_6_R3;
package net.minecraft.server.v1_7_R1;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import net.minecraft.server.v1_7_R1.ChunkPreLoadEvent;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
// CraftBukkit start
import java.util.Random;
import net.minecraft.server.v1_6_R3.BlockSand;
import net.minecraft.server.v1_6_R3.Chunk;
import net.minecraft.server.v1_6_R3.ChunkCoordinates;
import net.minecraft.server.v1_6_R3.ChunkPosition;
import net.minecraft.server.v1_6_R3.ChunkRegionLoader;
import net.minecraft.server.v1_6_R3.CrashReport;
import net.minecraft.server.v1_6_R3.CrashReportSystemDetails;
import net.minecraft.server.v1_6_R3.EmptyChunk;
import net.minecraft.server.v1_6_R3.EnumCreatureType;
import net.minecraft.server.v1_6_R3.IChunkLoader;
import net.minecraft.server.v1_6_R3.IChunkProvider;
import net.minecraft.server.v1_6_R3.IProgressUpdate;
import net.minecraft.server.v1_6_R3.ReportedException;
import net.minecraft.server.v1_6_R3.World;
import net.minecraft.server.v1_6_R3.WorldServer;
import org.bukkit.Server;
import org.bukkit.craftbukkit.v1_6_R3.chunkio.ChunkIOExecutor;
import org.bukkit.craftbukkit.v1_6_R3.util.LongHash;
import org.bukkit.craftbukkit.v1_6_R3.util.LongHashSet;
import org.bukkit.craftbukkit.v1_6_R3.util.LongObjectHashMap;
import org.bukkit.craftbukkit.v1_7_R1.util.LongHash;
import org.bukkit.craftbukkit.v1_7_R1.util.LongHashSet;
import org.bukkit.craftbukkit.v1_7_R1.util.LongObjectHashMap;
import org.bukkit.event.world.ChunkUnloadEvent;
// CraftBukkit end
public class ChunkProviderServer implements IChunkProvider {
// CraftBukkit start
public LongHashSet unloadQueue = new LongHashSet();
private static final Logger b = LogManager.getLogger();
// CraftBukkit start - private -> public
public LongHashSet unloadQueue = new LongHashSet(); // LongHashSet
public Chunk emptyChunk;
public IChunkProvider chunkProvider; // CraftBukkit
private IChunkLoader e;
public IChunkProvider chunkProvider;
private IChunkLoader f;
public boolean forceChunkLoad = false; // true -> false
public LongObjectHashMap<Chunk> chunks = new LongObjectHashMap<Chunk>();
public WorldServer world;
@ -45,7 +39,7 @@ public class ChunkProviderServer implements IChunkProvider {
public ChunkProviderServer(WorldServer worldserver, IChunkLoader ichunkloader, IChunkProvider ichunkprovider) {
this.emptyChunk = new EmptyChunk(worldserver, 0, 0);
this.world = worldserver;
this.e = ichunkloader;
this.f = ichunkloader;
this.chunkProvider = ichunkprovider;
}
@ -88,11 +82,11 @@ public class ChunkProviderServer implements IChunkProvider {
while (iterator.hasNext()) {
Chunk chunk = (Chunk) iterator.next();
this.queueUnload(chunk.x, chunk.z);
this.queueUnload(chunk.locX, chunk.locZ);
}
}
// CraftBukkit start - add async variant, provide compatibility
// CraftBukkit start - Add async variant, provide compatibility
public Chunk getChunkAt(int i, int j) {
return getChunkAt(i, j, null);
}
@ -103,13 +97,13 @@ public class ChunkProviderServer implements IChunkProvider {
boolean newChunk = false;
ChunkRegionLoader loader = null;
if (this.e instanceof ChunkRegionLoader) {
loader = (ChunkRegionLoader) this.e;
if (this.f instanceof ChunkRegionLoader) {
loader = (ChunkRegionLoader) this.f;
}
// If the chunk exists but isn't loaded do it async
if (chunk == null && runnable != null && loader != null && loader.chunkExists(this.world, i, j)) {
ChunkIOExecutor.queueChunkLoad(this.world, loader, this, i, j, runnable);
org.bukkit.craftbukkit.v1_7_R1.chunkio.ChunkIOExecutor.queueChunkLoad(this.world, loader, this, i, j, runnable);
return null;
}
// CraftBukkit end
@ -124,7 +118,7 @@ public class ChunkProviderServer implements IChunkProvider {
if (event.isCancelled())
return null;
}
if (chunk == null) {
chunk = this.loadChunk(i, j);
if (chunk == null) {
@ -138,7 +132,7 @@ public class ChunkProviderServer implements IChunkProvider {
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Chunk to be generated");
crashreportsystemdetails.a("Location", String.format("%d,%d", new Object[] { Integer.valueOf(i), Integer.valueOf(j)}));
crashreportsystemdetails.a("Position hash", Long.valueOf(LongHash.toLong(i, j)));
crashreportsystemdetails.a("Position hash", Long.valueOf(LongHash.toLong(i, j))); // CraftBukkit - Use LongHash
crashreportsystemdetails.a("Generator", this.chunkProvider.getName());
throw new ReportedException(crashreport);
}
@ -147,9 +141,7 @@ public class ChunkProviderServer implements IChunkProvider {
}
this.chunks.put(LongHash.toLong(i, j), chunk); // CraftBukkit
if (chunk != null) {
chunk.addEntities();
}
chunk.addEntities();
// CraftBukkit start
if (server != null) {
@ -161,7 +153,6 @@ public class ChunkProviderServer implements IChunkProvider {
server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkLoadEvent(chunk.bukkitChunk, newChunk));
}
// CraftBukkit end
chunk.a(this, this, i, j);
}
@ -180,9 +171,9 @@ public class ChunkProviderServer implements IChunkProvider {
chunk = chunk == null ? (!this.world.isLoading && !this.forceChunkLoad ? this.emptyChunk : this.getChunkAt(i, j)) : chunk;
if (chunk == this.emptyChunk) return chunk;
if (i != chunk.x || j != chunk.z) {
this.world.getLogger().severe("Chunk (" + chunk.x + ", " + chunk.z + ") stored at (" + i + ", " + j + ") in world '" + world.getWorld().getName() + "'");
this.world.getLogger().severe(chunk.getClass().getName());
if (i != chunk.locX || j != chunk.locZ) {
b.error("Chunk (" + chunk.locX + ", " + chunk.locZ + ") stored at (" + i + ", " + j + ") in world '" + world.getWorld().getName() + "'");
b.error(chunk.getClass().getName());
Throwable ex = new Throwable();
ex.fillInStackTrace();
ex.printStackTrace();
@ -192,14 +183,14 @@ public class ChunkProviderServer implements IChunkProvider {
}
public Chunk loadChunk(int i, int j) { // CraftBukkit - private -> public
if (this.e == null) {
if (this.f == null) {
return null;
} else {
try {
Chunk chunk = this.e.a(this.world, i, j);
Chunk chunk = this.f.a(this.world, i, j);
if (chunk != null) {
chunk.n = this.world.getTime();
chunk.p = this.world.getTime();
if (this.chunkProvider != null) {
this.chunkProvider.recreateStructures(i, j);
}
@ -207,35 +198,35 @@ public class ChunkProviderServer implements IChunkProvider {
return chunk;
} catch (Exception exception) {
exception.printStackTrace();
b.error("Couldn\'t load chunk", exception);
return null;
}
}
}
public void saveChunkNOP(Chunk chunk) { // CraftBukkit - private -> public
if (this.e != null) {
if (this.f != null) {
try {
this.e.b(this.world, chunk);
this.f.b(this.world, chunk);
} catch (Exception exception) {
exception.printStackTrace();
b.error("Couldn\'t save entities", exception);
}
}
}
public void saveChunk(Chunk chunk) { // CraftBukkit - private -> public
if (this.e != null) {
if (this.f != null) {
try {
chunk.n = this.world.getTime();
this.e.a(this.world, chunk);
} catch (Exception ioexception) { // CraftBukkit - IOException -> Exception
ioexception.printStackTrace();
// CraftBukkit start - remove extra exception
chunk.p = this.world.getTime();
this.f.a(this.world, chunk);
// CraftBukkit start - IOException to Exception
} catch (Exception ioexception) {
b.error("Couldn\'t save chunk", ioexception);
/* Remove extra exception
} catch (ExceptionWorldConflict exceptionworldconflict) {
b.error("Couldn\'t save chunk; already in use by another instance of Minecraft?", exceptionworldconflict);
// CraftBukkit end */
}
// } catch (ExceptionWorldConflict exceptionworldconflict) {
// exceptionworldconflict.printStackTrace();
// }
// CraftBukkit end
}
}
@ -243,7 +234,7 @@ public class ChunkProviderServer implements IChunkProvider {
Chunk chunk = this.getOrCreateChunk(i, j);
if (!chunk.done) {
chunk.done = true;
chunk.p();
if (this.chunkProvider != null) {
this.chunkProvider.getChunkAt(ichunkprovider, i, j);
@ -257,8 +248,13 @@ public class ChunkProviderServer implements IChunkProvider {
org.bukkit.World world = this.world.getWorld();
if (world != null) {
for (org.bukkit.generator.BlockPopulator populator : world.getPopulators()) {
populator.populate(world, random, chunk.bukkitChunk);
this.world.populating = true;
try {
for (org.bukkit.generator.BlockPopulator populator : world.getPopulators()) {
populator.populate(world, random, chunk.bukkitChunk);
}
} finally {
this.world.populating = false;
}
}
BlockSand.instaFall = false;
@ -285,7 +281,7 @@ public class ChunkProviderServer implements IChunkProvider {
if (chunk.a(flag)) {
this.saveChunk(chunk);
chunk.l = false;
chunk.n = false;
++i;
if (i == 24 && !flag) {
return false;
@ -297,11 +293,11 @@ public class ChunkProviderServer implements IChunkProvider {
}
public void b() {
if (this.e != null) {
this.e.b();
if (this.f != null) {
this.f.b();
}
}
public boolean unloadChunks() {
if (!this.world.savingDisabled) {
// CraftBukkit start
@ -317,14 +313,15 @@ public class ChunkProviderServer implements IChunkProvider {
chunk.removeEntities();
this.saveChunk(chunk);
this.saveChunkNOP(chunk);
// this.unloadQueue.remove(integer);
// this.unloadQueue.remove(olong);
// this.chunks.remove(olong.longValue());
this.chunks.remove(chunkcoordinates); // CraftBukkit
}
}
// CraftBukkit end
if (this.e != null) {
this.e.a();
if (this.f != null) {
this.f.a();
}
}
@ -336,7 +333,8 @@ public class ChunkProviderServer implements IChunkProvider {
}
public String getName() {
return "ServerChunkCache: " + this.chunks.values().size() + " Drop: " + this.unloadQueue.size(); // CraftBukkit
// CraftBukkit - this.chunks.count() -> .values().size()
return "ServerChunkCache: " + this.chunks.values().size() + " Drop: " + this.unloadQueue.size();
}
public List getMobsFor(EnumCreatureType enumcreaturetype, int i, int j, int k) {
@ -348,7 +346,8 @@ public class ChunkProviderServer implements IChunkProvider {
}
public int getLoadedChunks() {
return this.chunks.values().size(); // CraftBukkit
// CraftBukkit - this.chunks.count() -> .values().size()
return this.chunks.values().size();
}
public void recreateStructures(int i, int j) {}

View File

@ -1,14 +1,8 @@
package net.minecraft.server.v1_6_R3;
package net.minecraft.server.v1_7_R1;
// CraftBukkit start
import java.util.List;
import net.minecraft.server.v1_6_R3.ContainerAnvil;
import net.minecraft.server.v1_6_R3.IInventory;
import net.minecraft.server.v1_6_R3.InventorySubcontainer;
import net.minecraft.server.v1_6_R3.ItemStack;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftHumanEntity;
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftHumanEntity;
import org.bukkit.entity.HumanEntity;
// CraftBukkit end

View File

@ -1,127 +1,133 @@
package net.minecraft.server.v1_6_R3;
package net.minecraft.server.v1_7_R1;
import java.util.Calendar;
import java.util.Random;
public class EntityBat extends EntityAmbient
public class EntityBat
extends EntityAmbient
{
private ChunkCoordinates h;
public boolean Vegetated = false;
public EntityBat(World paramWorld)
{
super(paramWorld);
a(0.5F, 0.9F);
a(true);
}
protected void a()
protected void c()
{
super.a();
super.c();
this.datawatcher.a(16, new Byte((byte)0));
}
protected float ba()
protected float bf()
{
return 0.1F;
}
protected float bb()
protected float bg()
{
return super.bb() * 0.95F;
return super.bg() * 0.95F;
}
protected String r()
protected String t()
{
if ((bJ()) && (this.random.nextInt(4) != 0)) {
if ((bN()) && (this.random.nextInt(4) != 0)) {
return null;
}
return "mob.bat.idle";
}
protected String aO()
protected String aT()
{
return "mob.bat.hurt";
}
protected String aP()
protected String aU()
{
return "mob.bat.death";
}
public boolean M()
public boolean S()
{
return false;
}
protected void n(Entity paramEntity)
protected void n(Entity paramEntity) {}
protected void bo() {}
protected void aD()
{
}
protected void bj()
{
}
protected void az()
{
super.az();
super.aD();
getAttributeInstance(GenericAttributes.a).setValue(6.0D);
}
public boolean bJ() {
public boolean bN()
{
return (this.datawatcher.getByte(16) & 0x1) != 0;
}
public void a(boolean paramBoolean) {
public void a(boolean paramBoolean)
{
int i = this.datawatcher.getByte(16);
if (paramBoolean)
if (paramBoolean) {
this.datawatcher.watch(16, Byte.valueOf((byte)(i | 0x1)));
else
} else {
this.datawatcher.watch(16, Byte.valueOf((byte)(i & 0xFFFFFFFE)));
}
}
protected boolean bf()
protected boolean bk()
{
return true;
}
public void l_()
public void h()
{
super.l_();
super.h();
if (Vegetated)
return;
if (bJ()) {
if (bN())
{
this.motX = (this.motY = this.motZ = 0.0D);
this.locY = (MathHelper.floor(this.locY) + 1.0D - this.length);
} else {
}
else
{
this.motY *= 0.6000000238418579D;
}
}
protected void bi()
protected void bn()
{
super.bi();
super.bn();
if (Vegetated)
return;
if (bJ()) {
if (!this.world.u(MathHelper.floor(this.locX), (int)this.locY + 1, MathHelper.floor(this.locZ))) {
if (bN())
{
if (!this.world.getType(MathHelper.floor(this.locX), (int)this.locY + 1, MathHelper.floor(this.locZ)).r())
{
a(false);
this.world.a(null, 1015, (int)this.locX, (int)this.locY, (int)this.locZ, 0);
}
else {
else
{
if (this.random.nextInt(200) == 0) {
this.aP = this.random.nextInt(360);
}
if (this.world.findNearbyPlayer(this, 4.0D) != null) {
if (this.world.findNearbyPlayer(this, 4.0D) != null)
{
a(false);
this.world.a(null, 1015, (int)this.locX, (int)this.locY, (int)this.locZ, 0);
}
@ -135,87 +141,85 @@ public class EntityBat extends EntityAmbient
if ((this.h == null) || (this.random.nextInt(30) == 0) || (this.h.e((int)this.locX, (int)this.locY, (int)this.locZ) < 4.0F)) {
this.h = new ChunkCoordinates((int)this.locX + this.random.nextInt(7) - this.random.nextInt(7), (int)this.locY + this.random.nextInt(6) - 2, (int)this.locZ + this.random.nextInt(7) - this.random.nextInt(7));
}
double d1 = this.h.x + 0.5D - this.locX;
double d2 = this.h.y + 0.1D - this.locY;
double d3 = this.h.z + 0.5D - this.locZ;
this.motX += (Math.signum(d1) * 0.5D - this.motX) * 0.1000000014901161D;
this.motY += (Math.signum(d2) * 0.699999988079071D - this.motY) * 0.1000000014901161D;
this.motZ += (Math.signum(d3) * 0.5D - this.motZ) * 0.1000000014901161D;
float f1 = (float)(Math.atan2(this.motZ, this.motX) * 180.0D / 3.141592741012573D) - 90.0F;
float f2 = MathHelper.g(f1 - this.yaw);
this.bf = 0.5F;
this.yaw += f2;
if ((this.random.nextInt(100) == 0) && (this.world.u(MathHelper.floor(this.locX), (int)this.locY + 1, MathHelper.floor(this.locZ))))
if ((this.random.nextInt(100) == 0) && (this.world.getType(MathHelper.floor(this.locX), (int)this.locY + 1, MathHelper.floor(this.locZ)).r())) {
a(true);
}
}
}
protected boolean e_()
protected boolean g_()
{
return false;
}
protected void b(float paramFloat)
{
}
protected void a(double paramDouble, boolean paramBoolean)
{
}
public boolean au()
protected void b(float paramFloat) {}
protected void a(double paramDouble, boolean paramBoolean) {}
public boolean az()
{
return true;
}
public boolean damageEntity(DamageSource paramDamageSource, float paramFloat)
{
if (isInvulnerable()) return false;
if ((!this.world.isStatic) && bJ() && !Vegetated) {
if (isInvulnerable()) {
return false;
}
if ((!this.world.isStatic) &&
(bN()) &&
!Vegetated) {
a(false);
}
return super.damageEntity(paramDamageSource, paramFloat);
}
public void a(NBTTagCompound paramNBTTagCompound)
{
super.a(paramNBTTagCompound);
this.datawatcher.watch(16, Byte.valueOf(paramNBTTagCompound.getByte("BatFlags")));
}
public void b(NBTTagCompound paramNBTTagCompound)
{
super.b(paramNBTTagCompound);
paramNBTTagCompound.setByte("BatFlags", this.datawatcher.getByte(16));
}
public boolean canSpawn()
{
int i = MathHelper.floor(this.boundingBox.b);
if (i >= 63) return false;
int j = MathHelper.floor(this.locX);
int k = MathHelper.floor(this.locZ);
int m = this.world.getLightLevel(j, i, k);
int n = 4;
Calendar localCalendar = this.world.W();
if (((localCalendar.get(2) + 1 == 10) && (localCalendar.get(5) >= 20)) || ((localCalendar.get(2) + 1 == 11) && (localCalendar.get(5) <= 3)))
n = 7;
else if (this.random.nextBoolean()) {
if (i >= 63) {
return false;
}
int j = MathHelper.floor(this.locX);
int k = MathHelper.floor(this.locZ);
int m = this.world.getLightLevel(j, i, k);
int n = 4;
Calendar localCalendar = this.world.V();
if (((localCalendar.get(2) + 1 == 10) && (localCalendar.get(5) >= 20)) || ((localCalendar.get(2) + 1 == 11) && (localCalendar.get(5) <= 3))) {
n = 7;
} else if (this.random.nextBoolean()) {
return false;
}
if (m > this.random.nextInt(n)) {
return false;
}
if (m > this.random.nextInt(n)) return false;
return super.canSpawn();
}
}
}

View File

@ -1,14 +1,4 @@
package net.minecraft.server.v1_6_R3;
import net.minecraft.server.v1_6_R3.DamageSource;
import net.minecraft.server.v1_6_R3.Entity;
import net.minecraft.server.v1_6_R3.EntityHuman;
import net.minecraft.server.v1_6_R3.EntityMonster;
import net.minecraft.server.v1_6_R3.EntitySmallFireball;
import net.minecraft.server.v1_6_R3.GenericAttributes;
import net.minecraft.server.v1_6_R3.Item;
import net.minecraft.server.v1_6_R3.MathHelper;
import net.minecraft.server.v1_6_R3.World;
package net.minecraft.server.v1_7_R1;
public class EntityBlaze extends EntityMonster {
@ -22,25 +12,25 @@ public class EntityBlaze extends EntityMonster {
this.b = 10;
}
protected void az() {
super.az();
protected void aD() {
super.aD();
this.getAttributeInstance(GenericAttributes.e).setValue(6.0D);
}
protected void a() {
super.a();
protected void c() {
super.c();
this.datawatcher.a(16, new Byte((byte) 0));
}
protected String r() {
protected String t() {
return "mob.blaze.breathe";
}
protected String aO() {
protected String aT() {
return "mob.blaze.hit";
}
protected String aP() {
protected String aU() {
return "mob.blaze.death";
}
@ -48,9 +38,9 @@ public class EntityBlaze extends EntityMonster {
return 1.0F;
}
public void c() {
public void e() {
if (!this.world.isStatic) {
if (this.G()) {
if (this.L()) {
this.damageEntity(DamageSource.DROWN, 1.0F);
}
@ -60,7 +50,7 @@ public class EntityBlaze extends EntityMonster {
this.bp = 0.5F + (float) this.random.nextGaussian() * 3.0F;
}
if (this.bN() != null && this.bN().locY + (double) this.bN().getHeadHeight() > this.locY + (double) this.getHeadHeight() + (double) this.bp) {
if (this.bR() != null && this.bR().locY + (double) this.bR().getHeadHeight() > this.locY + (double) this.getHeadHeight() + (double) this.bp) {
this.motY += (0.30000001192092896D - this.motY) * 0.30000001192092896D;
}
}
@ -77,7 +67,7 @@ public class EntityBlaze extends EntityMonster {
this.world.addParticle("largesmoke", this.locX + (this.random.nextDouble() - 0.5D) * (double) this.width, this.locY + this.random.nextDouble() * (double) this.length, this.locZ + (this.random.nextDouble() - 0.5D) * (double) this.width, 0.0D, 0.0D, 0.0D);
}
super.c();
super.e();
}
protected void a(Entity entity, float f) {
@ -126,30 +116,31 @@ public class EntityBlaze extends EntityMonster {
protected void b(float f) {}
protected int getLootId() {
return Item.BLAZE_ROD.id;
protected Item getLoot() {
return Items.BLAZE_ROD;
}
public boolean isBurning() {
return this.bT();
return this.bX();
}
protected void dropDeathLoot(boolean flag, int i) {
// CraftBukkit start
java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>();
if (flag) {
// CraftBukkit start
java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>();
int j = this.random.nextInt(2 + i);
if (j > 0) {
loot.add(new org.bukkit.inventory.ItemStack(Item.BLAZE_ROD.id, j));
loot.add(new org.bukkit.inventory.ItemStack(org.bukkit.craftbukkit.v1_7_R1.util.CraftMagicNumbers.getMaterial(Items.BLAZE_ROD), j));
}
org.bukkit.craftbukkit.v1_6_R3.event.CraftEventFactory.callEntityDeathEvent(this, loot);
// CraftBukkit end
}
org.bukkit.craftbukkit.v1_7_R1.event.CraftEventFactory.callEntityDeathEvent(this, loot);
// CraftBukkit end
}
public boolean bT() {
public boolean bX() {
return (this.datawatcher.getByte(16) & 1) != 0;
}
@ -165,7 +156,7 @@ public class EntityBlaze extends EntityMonster {
this.datawatcher.watch(16, Byte.valueOf(b0));
}
protected boolean i_() {
protected boolean j_() {
return true;
}
}

View File

@ -0,0 +1,313 @@
package net.minecraft.server.v1_7_R1;
import java.util.UUID;
// CraftBukkit start
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftEntity;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.entity.EntityUnleashEvent;
// CraftBukkit end
public abstract class EntityCreature extends EntityInsentient {
public static final UUID h = UUID.fromString("E199AD21-BA8A-4C53-8D13-6182D5C69D3A");
public static final AttributeModifier i = (new AttributeModifier(h, "Fleeing speed bonus", 2.0D, 2)).a(false);
public PathEntity pathEntity; // CraftBukkit - private -> public
public Entity target; // CraftBukkit - protected -> public
protected boolean bn;
protected int bo;
private ChunkCoordinates bq = new ChunkCoordinates(0, 0, 0);
private float br = -1.0F;
private PathfinderGoal bs = new PathfinderGoalMoveTowardsRestriction(this, 1.0D);
private boolean bt;
public EntityCreature(World world) {
super(world);
}
protected boolean bN() {
return false;
}
protected void bq() {
this.world.methodProfiler.a("ai");
if (this.bo > 0 && --this.bo == 0) {
AttributeInstance attributeinstance = this.getAttributeInstance(GenericAttributes.d);
attributeinstance.b(i);
}
this.bn = this.bN();
float f11 = 16.0F;
if (this.target == null) {
// CraftBukkit start
Entity target = this.findTarget();
if (target != null) {
EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), target.getBukkitEntity(), EntityTargetEvent.TargetReason.CLOSEST_PLAYER);
this.world.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
if (event.getTarget() == null) {
this.target = null;
} else {
this.target = ((CraftEntity) event.getTarget()).getHandle();
}
}
}
// CraftBukkit end
if (this.target != null) {
this.pathEntity = this.world.findPath(this, this.target, f11, true, false, false, true);
}
} else if (this.target.isAlive()) {
float f1 = this.target.d((Entity) this);
if (this.o(this.target)) {
this.a(this.target, f1);
}
} else {
// CraftBukkit start
EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), null, EntityTargetEvent.TargetReason.TARGET_DIED);
this.world.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
if (event.getTarget() == null) {
this.target = null;
} else {
this.target = ((CraftEntity) event.getTarget()).getHandle();
}
}
// CraftBukkit end
}
if (this.target instanceof EntityPlayer && ((EntityPlayer) this.target).playerInteractManager.isCreative()) {
this.target = null;
}
this.world.methodProfiler.b();
if (!this.bn && this.target != null && (this.pathEntity == null || this.random.nextInt(20) == 0)) {
this.pathEntity = this.world.findPath(this, this.target, f11, true, false, false, true);
} else if (!this.bn && (this.pathEntity == null && this.random.nextInt(180) == 0 || this.random.nextInt(120) == 0 || this.bo > 0) && this.aV < 100) {
this.bO();
}
int i = MathHelper.floor(this.boundingBox.b + 0.5D);
boolean flag = this.M();
boolean flag1 = this.P();
this.pitch = 0.0F;
if (this.pathEntity != null && this.random.nextInt(100) != 0) {
this.world.methodProfiler.a("followpath");
Vec3D vec3d = this.pathEntity.a((Entity) this);
double d0 = (double) (this.width * 2.0F);
while (vec3d != null && vec3d.d(this.locX, vec3d.d, this.locZ) < d0 * d0) {
this.pathEntity.a();
if (this.pathEntity.b()) {
vec3d = null;
this.pathEntity = null;
} else {
vec3d = this.pathEntity.a((Entity) this);
}
}
this.bd = false;
if (vec3d != null) {
double d1 = vec3d.c - this.locX;
double d2 = vec3d.e - this.locZ;
double d3 = vec3d.d - (double) i;
// CraftBukkit - Math -> TrigMath
float f2 = (float) (org.bukkit.craftbukkit.v1_7_R1.TrigMath.atan2(d2, d1) * 180.0D / 3.1415927410125732D) - 90.0F;
float f3 = MathHelper.g(f2 - this.yaw);
this.bf = (float) this.getAttributeInstance(GenericAttributes.d).getValue();
if (f3 > 30.0F) {
f3 = 30.0F;
}
if (f3 < -30.0F) {
f3 = -30.0F;
}
this.yaw += f3;
if (this.bn && this.target != null) {
double d4 = this.target.locX - this.locX;
double d5 = this.target.locZ - this.locZ;
float f4 = this.yaw;
this.yaw = (float) (Math.atan2(d5, d4) * 180.0D / 3.1415927410125732D) - 90.0F;
f3 = (f4 - this.yaw + 90.0F) * 3.1415927F / 180.0F;
this.be = -MathHelper.sin(f3) * this.bf * 1.0F;
this.bf = MathHelper.cos(f3) * this.bf * 1.0F;
}
if (d3 > 0.0D) {
this.bd = true;
}
}
if (this.target != null) {
this.a(this.target, 30.0F, 30.0F);
}
if (this.positionChanged && !this.bQ()) {
this.bd = true;
}
if (this.random.nextFloat() < 0.8F && (flag || flag1)) {
this.bd = true;
}
this.world.methodProfiler.b();
} else {
super.bq();
this.pathEntity = null;
}
}
protected void bO() {
this.world.methodProfiler.a("stroll");
boolean flag = false;
int i = -1;
int j = -1;
int k = -1;
float f = -99999.0F;
for (int l = 0; l < 10; ++l) {
int i1 = MathHelper.floor(this.locX + (double) this.random.nextInt(13) - 6.0D);
int j1 = MathHelper.floor(this.locY + (double) this.random.nextInt(7) - 3.0D);
int k1 = MathHelper.floor(this.locZ + (double) this.random.nextInt(13) - 6.0D);
float f1 = this.a(i1, j1, k1);
if (f1 > f) {
f = f1;
i = i1;
j = j1;
k = k1;
flag = true;
}
}
if (flag) {
this.pathEntity = this.world.a(this, i, j, k, 10.0F, true, false, false, true);
}
this.world.methodProfiler.b();
}
protected void a(Entity entity, float f) {}
public float a(int i, int j, int k) {
return 0.0F;
}
protected Entity findTarget() {
return null;
}
public boolean canSpawn() {
int i = MathHelper.floor(this.locX);
int j = MathHelper.floor(this.boundingBox.b);
int k = MathHelper.floor(this.locZ);
return super.canSpawn() && this.a(i, j, k) >= 0.0F;
}
public boolean bQ() {
return this.pathEntity != null;
}
public void setPathEntity(PathEntity pathentity) {
this.pathEntity = pathentity;
}
public Entity bR() {
return this.target;
}
public void setTarget(Entity entity) {
this.target = entity;
}
public boolean bS() {
return this.b(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ));
}
public boolean b(int i, int j, int k) {
return this.br == -1.0F ? true : this.bq.e(i, j, k) < this.br * this.br;
}
public void a(int i, int j, int k, int l) {
this.bq.b(i, j, k);
this.br = (float) l;
}
public ChunkCoordinates bT() {
return this.bq;
}
public float bU() {
return this.br;
}
public void bV() {
this.br = -1.0F;
}
public boolean bW() {
return this.br != -1.0F;
}
protected void bJ() {
super.bJ();
if (this.bL() && this.getLeashHolder() != null && this.getLeashHolder().world == this.world && this.PullWhileLeashed) {
Entity entity = this.getLeashHolder();
this.a((int) entity.locX, (int) entity.locY, (int) entity.locZ, 5);
float f = this.d(entity);
if (this instanceof EntityTameableAnimal && ((EntityTameableAnimal) this).isSitting()) {
if (f > 10.0F) {
this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE)); // CraftBukkit
this.unleash(true, true);
}
return;
}
if (!this.bt) {
this.goalSelector.a(2, this.bs);
this.getNavigation().a(false);
this.bt = true;
}
this.o(f);
if (f > 4.0F) {
this.getNavigation().a(entity, 1.0D);
}
if (f > 6.0F) {
double d0 = (entity.locX - this.locX) / (double) f;
double d1 = (entity.locY - this.locY) / (double) f;
double d2 = (entity.locZ - this.locZ) / (double) f;
this.motX += d0 * Math.abs(d0) * 0.4D;
this.motY += d1 * Math.abs(d1) * 0.4D;
this.motZ += d2 * Math.abs(d2) * 0.4D;
}
if (f > 10.0F) {
this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE)); // CraftBukkit
this.unleash(true, true);
}
} else if (!this.bL() && this.bt) {
this.bt = false;
this.goalSelector.a(this.bs);
this.getNavigation().a(true);
this.bV();
}
}
protected void o(float f) {}
}

View File

@ -1,14 +1,16 @@
package net.minecraft.server.v1_6_R3;
package net.minecraft.server.v1_7_R1;
import java.util.Iterator;
import java.util.List;
// CraftBukkit start
import org.bukkit.block.BlockState;
import org.bukkit.craftbukkit.v1_6_R3.util.BlockStateListPopulator;
import org.bukkit.craftbukkit.v1_7_R1.util.BlockStateListPopulator;
import org.bukkit.event.entity.EntityCreatePortalEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.Bukkit;
// CraftBukkit end
@ -43,19 +45,19 @@ public class EntityEnderDragon extends EntityInsentient implements IComplex, IMo
this.children = new EntityComplexPart[] { this.bq = new EntityComplexPart(this, "head", 6.0F, 6.0F), this.br = new EntityComplexPart(this, "body", 8.0F, 8.0F), this.bs = new EntityComplexPart(this, "tail", 4.0F, 4.0F), this.bt = new EntityComplexPart(this, "tail", 4.0F, 4.0F), this.bu = new EntityComplexPart(this, "tail", 4.0F, 4.0F), this.bv = new EntityComplexPart(this, "wing", 4.0F, 4.0F), this.bw = new EntityComplexPart(this, "wing", 4.0F, 4.0F)};
this.setHealth(this.getMaxHealth());
this.a(16.0F, 8.0F);
this.Z = true;
this.Y = true;
this.fireProof = true;
this.i = 100.0D;
this.am = true;
this.al = true;
}
protected void az() {
super.az();
protected void aD() {
super.aD();
this.getAttributeInstance(GenericAttributes.a).setValue(200.0D);
}
protected void a() {
super.a();
protected void c() {
super.c();
}
public double[] b(int i, float f) {
@ -78,7 +80,7 @@ public class EntityEnderDragon extends EntityInsentient implements IComplex, IMo
return adouble;
}
public void c() {
public void e() {
float f;
float f1;
@ -99,7 +101,7 @@ public class EntityEnderDragon extends EntityInsentient implements IComplex, IMo
f2 = (this.random.nextFloat() - 0.5F) * 8.0F;
this.world.addParticle("largeexplode", this.locX + (double) f, this.locY + 2.0D + (double) f1, this.locZ + (double) f2, 0.0D, 0.0D, 0.0D);
} else {
this.bJ();
this.bN();
f = 0.2F / (MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ) * 10.0F + 1.0F);
f *= (float) Math.pow(2.0D, this.motY);
if (this.bA) {
@ -163,8 +165,8 @@ public class EntityEnderDragon extends EntityInsentient implements IComplex, IMo
this.j += this.random.nextGaussian() * 2.0D;
}
if (!Vegetated && (this.bz || d3 < 100.0D || d3 > 22500.0D || this.positionChanged || this.H)) {
this.bK();
if (!Vegetated && (this.bz || d3 < 100.0D || d3 > 22500.0D || this.positionChanged || this.G)) {
this.bO();
}
d1 /= (double) MathHelper.sqrt(d0 * d0 + d2 * d2);
@ -245,11 +247,11 @@ public class EntityEnderDragon extends EntityInsentient implements IComplex, IMo
float f11 = MathHelper.sin(f10);
float f12 = MathHelper.cos(f10);
this.br.l_();
this.br.h();
this.br.setPositionRotation(this.locX + (double) (f11 * 0.5F), this.locY, this.locZ - (double) (f12 * 0.5F), 0.0F, 0.0F);
this.bv.l_();
this.bv.h();
this.bv.setPositionRotation(this.locX + (double) (f12 * 4.5F), this.locY + 2.0D, this.locZ + (double) (f11 * 4.5F), 0.0F, 0.0F);
this.bw.l_();
this.bw.h();
this.bw.setPositionRotation(this.locX - (double) (f12 * 4.5F), this.locY + 2.0D, this.locZ - (double) (f11 * 4.5F), 0.0F, 0.0F);
if (!this.world.isStatic && this.hurtTicks == 0 && !ghost) {
this.a(this.world.getEntities(this, this.bv.boundingBox.grow(4.0D, 2.0D, 4.0D).d(0.0D, -2.0D, 0.0D)));
@ -263,7 +265,7 @@ public class EntityEnderDragon extends EntityInsentient implements IComplex, IMo
f3 = MathHelper.sin(this.yaw * 3.1415927F / 180.0F - this.bg * 0.01F);
float f13 = MathHelper.cos(this.yaw * 3.1415927F / 180.0F - this.bg * 0.01F);
this.bq.l_();
this.bq.h();
this.bq.setPositionRotation(this.locX + (double) (f3 * 5.5F * f2), this.locY + (adouble1[1] - adouble[1]) * 1.0D + (double) (f9 * 5.5F), this.locZ - (double) (f13 * 5.5F * f2), 0.0F, 0.0F);
for (int j = 0; j < 3; ++j) {
@ -288,7 +290,7 @@ public class EntityEnderDragon extends EntityInsentient implements IComplex, IMo
float f17 = 1.5F;
float f18 = (float) (j + 1) * 2.0F;
entitycomplexpart.l_();
entitycomplexpart.h();
entitycomplexpart.setPositionRotation(this.locX - (double) ((f11 * f17 + f15 * f18) * f2), this.locY + (adouble2[1] - adouble[1]) * 1.0D - (double) ((f18 + f17) * f9) + 1.5D, this.locZ + (double) ((f12 * f17 + f16 * f18) * f2), 0.0F, 0.0F);
}
@ -298,15 +300,23 @@ public class EntityEnderDragon extends EntityInsentient implements IComplex, IMo
}
}
private void bJ() {
private void bN() {
if (this.bC != null) {
if (this.bC.dead) {
if (!this.world.isStatic) {
this.a(this.bq, DamageSource.explosion((Explosion) null), 10.0F);
// CraftBukkit start
EntityDamageEvent event = new EntityDamageEvent(this.getBukkitEntity(), org.bukkit.event.entity.EntityDamageEvent.DamageCause.ENTITY_EXPLOSION, 10.0F);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
getBukkitEntity().setLastDamageCause(event);
this.a(this.bq, DamageSource.explosion((Explosion) null), (float) event.getDamage());
}
// CraftBukkit end
}
this.bC = null;
} else if (this.ticksLived % 10 == 0 && this.getHealth() < this.getMaxHealth()) { // CraftBukkit - this.getMaxHealth() -> this.maxHealth
} else if (this.ticksLived % 10 == 0 && this.getHealth() < this.getMaxHealth()) {
// CraftBukkit start
EntityRegainHealthEvent event = new EntityRegainHealthEvent(this.getBukkitEntity(), 1.0D, EntityRegainHealthEvent.RegainReason.ENDER_CRYSTAL);
this.world.getServer().getPluginManager().callEvent(event);
@ -380,10 +390,22 @@ public class EntityEnderDragon extends EntityInsentient implements IComplex, IMo
this.bD = entity;
}
private void bK() {
private void bO() {
this.bz = false;
if (this.random.nextInt(2) == 0 && !this.world.players.isEmpty()) {
this.bD = (Entity) this.world.players.get(this.random.nextInt(this.world.players.size()));
// CraftBukkit start
Entity target = (Entity) this.world.players.get(this.random.nextInt(this.world.players.size()));
EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), target.getBukkitEntity(), EntityTargetEvent.TargetReason.RANDOM_TARGET);
this.world.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
if (event.getTarget() == null) {
this.bD = null;
} else {
this.bD = ((org.bukkit.craftbukkit.v1_7_R1.entity.CraftEntity) event.getTarget()).getHandle();
}
}
// CraftBukkit end
} else {
boolean flag = false;
@ -420,16 +442,16 @@ public class EntityEnderDragon extends EntityInsentient implements IComplex, IMo
// CraftBukkit start - Create a list to hold all the destroyed blocks
List<org.bukkit.block.Block> destroyedBlocks = new java.util.ArrayList<org.bukkit.block.Block>();
org.bukkit.craftbukkit.v1_6_R3.CraftWorld craftWorld = this.world.getWorld();
org.bukkit.craftbukkit.v1_7_R1.CraftWorld craftWorld = this.world.getWorld();
// CraftBukkit end
for (int k1 = i; k1 <= l; ++k1) {
for (int l1 = j; l1 <= i1; ++l1) {
for (int i2 = k; i2 <= j1; ++i2) {
int j2 = this.world.getTypeId(k1, l1, i2);
Block block = this.world.getType(k1, l1, i2);
if (j2 != 0) {
if (j2 != Block.OBSIDIAN.id && j2 != Block.WHITESTONE.id && j2 != Block.BEDROCK.id && this.world.getGameRules().getBoolean("mobGriefing")) {
if (block.getMaterial() != Material.AIR) {
if (block != Blocks.OBSIDIAN && block != Blocks.WHITESTONE && block != Blocks.BEDROCK && this.world.getGameRules().getBoolean("mobGriefing")) {
// CraftBukkit start - Add blocks to list rather than destroying them
// flag1 = this.world.setAir(k1, l1, i2) || flag1;
flag1 = true;
@ -459,9 +481,8 @@ public class EntityEnderDragon extends EntityInsentient implements IComplex, IMo
}
} else {
for (org.bukkit.block.Block block : event.blockList()) {
int blockId = block.getTypeId();
if (blockId == 0) {
org.bukkit.Material blockId = block.getType();
if (blockId == org.bukkit.Material.AIR) {
continue;
}
@ -469,10 +490,11 @@ public class EntityEnderDragon extends EntityInsentient implements IComplex, IMo
int blockY = block.getY();
int blockZ = block.getZ();
if (Block.byId[blockId].a(explosionSource)) {
Block.byId[blockId].dropNaturally(this.world, blockX, blockY, blockZ, block.getData(), event.getYield(), 0);
Block nmsBlock = org.bukkit.craftbukkit.v1_7_R1.util.CraftMagicNumbers.getBlock(blockId);
if (nmsBlock.a(explosionSource)) {
nmsBlock.dropNaturally(this.world, blockX, blockY, blockZ, block.getData(), event.getYield(), 0);
}
Block.byId[blockId].wasExploded(world, blockX, blockY, blockZ, explosionSource);
nmsBlock.wasExploded(world, blockX, blockY, blockZ, explosionSource);
this.world.setAir(blockX, blockY, blockZ);
}
@ -517,7 +539,8 @@ public class EntityEnderDragon extends EntityInsentient implements IComplex, IMo
return super.damageEntity(damagesource, f);
}
protected void aB() {
protected void aF() {
if (this.dead) return; // CraftBukkit - can't kill what's already dead
++this.bB;
if (this.bB >= 180 && this.bB <= 200) {
float f = (this.random.nextFloat() - 0.5F) * 8.0F;
@ -532,7 +555,7 @@ public class EntityEnderDragon extends EntityInsentient implements IComplex, IMo
if (!this.world.isStatic) {
if (this.bB > 150 && this.bB % 5 == 0) {
i = expToDrop / 12; // CraftBukkit - drop experience as dragon falls from sky. use experience drop from death event. This is now set in getExpReward()
i = this.expToDrop / 12; // CraftBukkit - drop experience as dragon falls from sky. use experience drop from death event. This is now set in getExpReward()
while (i > 0) {
j = EntityExperienceOrb.getOrbValue(i);
@ -542,14 +565,14 @@ public class EntityEnderDragon extends EntityInsentient implements IComplex, IMo
}
if (this.bB == 1) {
this.world.d(1018, (int) this.locX, (int) this.locY, (int) this.locZ, 0);
this.world.b(1018, (int) this.locX, (int) this.locY, (int) this.locZ, 0);
}
}
this.move(0.0D, 0.10000000149011612D, 0.0D);
this.aN = this.yaw += 20.0F;
if (this.bB == 200 && !this.world.isStatic) {
i = expToDrop - 10 * (expToDrop / 12); // CraftBukkit - drop the remaining experience
i = this.expToDrop - (10 * this.expToDrop / 12); // CraftBukkit - drop the remaining experience
while (i > 0) {
j = EntityExperienceOrb.getOrbValue(i);
@ -557,12 +580,12 @@ public class EntityEnderDragon extends EntityInsentient implements IComplex, IMo
this.world.addEntity(new EntityExperienceOrb(this.world, this.locX, this.locY, this.locZ, j));
}
this.c(MathHelper.floor(this.locX), MathHelper.floor(this.locZ));
this.b(MathHelper.floor(this.locX), MathHelper.floor(this.locZ));
this.die();
}
}
private void c(int i, int j) {
private void b(int i, int j) {
byte b0 = 64;
BlockEnderPortal.a = true;
@ -581,29 +604,29 @@ public class EntityEnderDragon extends EntityInsentient implements IComplex, IMo
if (d2 <= ((double) b1 - 0.5D) * ((double) b1 - 0.5D)) {
if (k < b0) {
if (d2 <= ((double) (b1 - 1) - 0.5D) * ((double) (b1 - 1) - 0.5D)) {
world.setTypeId(l, k, i1, Block.BEDROCK.id);
world.setTypeUpdate(l, k, i1, Blocks.BEDROCK);
}
} else if (k > b0) {
world.setTypeId(l, k, i1, 0);
world.setTypeUpdate(l, k, i1, Blocks.AIR);
} else if (d2 > ((double) (b1 - 1) - 0.5D) * ((double) (b1 - 1) - 0.5D)) {
world.setTypeId(l, k, i1, Block.BEDROCK.id);
world.setTypeUpdate(l, k, i1, Blocks.BEDROCK);
} else {
world.setTypeId(l, k, i1, Block.ENDER_PORTAL.id);
world.setTypeUpdate(l, k, i1, Blocks.ENDER_PORTAL);
}
}
}
}
}
world.setTypeId(i, b0 + 0, j, Block.BEDROCK.id);
world.setTypeId(i, b0 + 1, j, Block.BEDROCK.id);
world.setTypeId(i, b0 + 2, j, Block.BEDROCK.id);
world.setTypeId(i - 1, b0 + 2, j, Block.TORCH.id);
world.setTypeId(i + 1, b0 + 2, j, Block.TORCH.id);
world.setTypeId(i, b0 + 2, j - 1, Block.TORCH.id);
world.setTypeId(i, b0 + 2, j + 1, Block.TORCH.id);
world.setTypeId(i, b0 + 3, j, Block.BEDROCK.id);
world.setTypeId(i, b0 + 4, j, Block.DRAGON_EGG.id);
world.setType(i, b0 + 0, j, Blocks.BEDROCK);
world.setType(i, b0 + 1, j, Blocks.BEDROCK);
world.setType(i, b0 + 2, j, Blocks.BEDROCK);
world.setTypeAndData(i - 1, b0 + 2, j, Blocks.TORCH, 2, 0);
world.setTypeAndData(i + 1, b0 + 2, j, Blocks.TORCH, 1, 0);
world.setTypeAndData(i, b0 + 2, j - 1, Blocks.TORCH, 4, 0);
world.setTypeAndData(i, b0 + 2, j + 1, Blocks.TORCH, 3, 0);
world.setType(i, b0 + 3, j, Blocks.BEDROCK);
world.setType(i, b0 + 4, j, Blocks.DRAGON_EGG);
EntityCreatePortalEvent event = new EntityCreatePortalEvent((org.bukkit.entity.LivingEntity) this.getBukkitEntity(), java.util.Collections.unmodifiableList(world.getList()), org.bukkit.PortalType.ENDER);
this.world.getServer().getPluginManager().callEvent(event);
@ -614,7 +637,7 @@ public class EntityEnderDragon extends EntityInsentient implements IComplex, IMo
}
} else {
for (BlockState state : event.getBlocks()) {
Packet53BlockChange packet = new Packet53BlockChange(state.getX(), state.getY(), state.getZ(), this.world);
PacketPlayOutBlockChange packet = new PacketPlayOutBlockChange(state.getX(), state.getY(), state.getZ(), this.world);
for (Iterator it = this.world.players.iterator(); it.hasNext();) {
EntityHuman entity = (EntityHuman) it.next();
if (entity instanceof EntityPlayer) {
@ -628,29 +651,29 @@ public class EntityEnderDragon extends EntityInsentient implements IComplex, IMo
BlockEnderPortal.a = false;
}
protected void u() {}
protected void w() {}
public Entity[] ao() {
public Entity[] at() {
return this.children;
}
public boolean L() {
public boolean R() {
return false;
}
public World b() {
public World a() {
return this.world;
}
protected String r() {
protected String t() {
return "mob.enderdragon.growl";
}
protected String aO() {
protected String aT() {
return "mob.enderdragon.hit";
}
protected float ba() {
protected float bf() {
return 5.0F;
}
@ -661,4 +684,4 @@ public class EntityEnderDragon extends EntityInsentient implements IComplex, IMo
return 12000;
}
// CraftBukkit end
}
}

View File

@ -1,27 +1,10 @@
package net.minecraft.server.v1_6_R3;
package net.minecraft.server.v1_7_R1;
import java.util.UUID;
import net.minecraft.server.v1_6_R3.AttributeInstance;
import net.minecraft.server.v1_6_R3.AttributeModifier;
import net.minecraft.server.v1_6_R3.Block;
import net.minecraft.server.v1_6_R3.DamageSource;
import net.minecraft.server.v1_6_R3.Entity;
import net.minecraft.server.v1_6_R3.EntityDamageSource;
import net.minecraft.server.v1_6_R3.EntityDamageSourceIndirect;
import net.minecraft.server.v1_6_R3.EntityHuman;
import net.minecraft.server.v1_6_R3.EntityMonster;
import net.minecraft.server.v1_6_R3.GenericAttributes;
import net.minecraft.server.v1_6_R3.Item;
import net.minecraft.server.v1_6_R3.ItemStack;
import net.minecraft.server.v1_6_R3.MathHelper;
import net.minecraft.server.v1_6_R3.NBTTagCompound;
import net.minecraft.server.v1_6_R3.Vec3D;
import net.minecraft.server.v1_6_R3.World;
// CraftBukkit start
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_6_R3.event.CraftEventFactory;
import org.bukkit.craftbukkit.v1_7_R1.event.CraftEventFactory;
import org.bukkit.event.entity.EntityTeleportEvent;
// CraftBukkit end
@ -38,18 +21,18 @@ public class EntityEnderman extends EntityMonster {
public EntityEnderman(World world) {
super(world);
this.a(0.6F, 2.9F);
this.Y = 1.0F;
this.X = 1.0F;
}
protected void az() {
super.az();
protected void aD() {
super.aD();
this.getAttributeInstance(GenericAttributes.a).setValue(40.0D);
this.getAttributeInstance(GenericAttributes.d).setValue(0.30000001192092896D);
this.getAttributeInstance(GenericAttributes.e).setValue(7.0D);
}
protected void a() {
super.a();
protected void c() {
super.c();
this.datawatcher.a(16, new Byte((byte) 0));
this.datawatcher.a(17, new Byte((byte) 0));
this.datawatcher.a(18, new Byte((byte) 0));
@ -57,13 +40,13 @@ public class EntityEnderman extends EntityMonster {
public void b(NBTTagCompound nbttagcompound) {
super.b(nbttagcompound);
nbttagcompound.setShort("carried", (short) this.getCarriedId());
nbttagcompound.setShort("carried", (short) Block.b(this.getCarried()));
nbttagcompound.setShort("carriedData", (short) this.getCarriedData());
}
public void a(NBTTagCompound nbttagcompound) {
super.a(nbttagcompound);
this.setCarriedId(nbttagcompound.getShort("carried"));
this.setCarried(Block.e(nbttagcompound.getShort("carried")));
this.setCarriedData(nbttagcompound.getShort("carriedData"));
}
@ -77,7 +60,7 @@ public class EntityEnderman extends EntityMonster {
if (this.f(entityhuman)) {
this.bv = true;
if (this.bt == 0) {
this.world.makeSound(entityhuman, "mob.endermen.stare", 1.0F, 1.0F);
this.world.makeSound(entityhuman.locX, entityhuman.locY, entityhuman.locZ, "mob.endermen.stare", 1.0F, 1.0F);
}
if (this.bt++ == 5) {
@ -96,7 +79,7 @@ public class EntityEnderman extends EntityMonster {
private boolean f(EntityHuman entityhuman) {
ItemStack itemstack = entityhuman.inventory.armor[3];
if (itemstack != null && itemstack.id == Block.PUMPKIN.id) {
if (itemstack != null && itemstack.getItem() == Item.getItemOf(Blocks.PUMPKIN)) {
return false;
} else {
Vec3D vec3d = entityhuman.j(1.0F).a();
@ -110,8 +93,8 @@ public class EntityEnderman extends EntityMonster {
}
}
public void c() {
if (this.G()) {
public void e() {
if (this.L()) {
this.damageEntity(DamageSource.DROWN, 1.0F);
}
@ -130,20 +113,20 @@ public class EntityEnderman extends EntityMonster {
if (!this.world.isStatic && this.world.getGameRules().getBoolean("mobGriefing")) {
int j;
int k;
int l;
Block block;
if (this.getCarriedId() == 0) {
if (this.getCarried().getMaterial() == Material.AIR) {
if (this.random.nextInt(20) == 0) {
i = MathHelper.floor(this.locX - 2.0D + this.random.nextDouble() * 4.0D);
j = MathHelper.floor(this.locY + this.random.nextDouble() * 3.0D);
k = MathHelper.floor(this.locZ - 2.0D + this.random.nextDouble() * 4.0D);
l = this.world.getTypeId(i, j, k);
if (br[l]) {
block = this.world.getType(i, j, k);
if (br[Block.b(block)]) {
// CraftBukkit start - Pickup event
if (!CraftEventFactory.callEntityChangeBlockEvent(this, this.world.getWorld().getBlockAt(i, j, k), org.bukkit.Material.AIR).isCancelled()) {
this.setCarriedId(this.world.getTypeId(i, j, k));
this.setCarried(block);
this.setCarriedData(this.world.getData(i, j, k));
this.world.setTypeIdUpdate(i, j, k, 0);
this.world.setTypeUpdate(i, j, k, Blocks.AIR);
}
// CraftBukkit end
}
@ -152,14 +135,14 @@ public class EntityEnderman extends EntityMonster {
i = MathHelper.floor(this.locX - 1.0D + this.random.nextDouble() * 2.0D);
j = MathHelper.floor(this.locY + this.random.nextDouble() * 2.0D);
k = MathHelper.floor(this.locZ - 1.0D + this.random.nextDouble() * 2.0D);
l = this.world.getTypeId(i, j, k);
int i1 = this.world.getTypeId(i, j - 1, k);
block = this.world.getType(i, j, k);
Block block1 = this.world.getType(i, j - 1, k);
if (l == 0 && i1 > 0 && Block.byId[i1].b()) {
if (block.getMaterial() == Material.AIR && block1.getMaterial() != Material.AIR && block1.d()) {
// CraftBukkit start - Place event
if (!CraftEventFactory.callEntityChangeBlockEvent(this, i, j, k, this.getCarriedId(), this.getCarriedData()).isCancelled()) {
this.world.setTypeIdAndData(i, j, k, this.getCarriedId(), this.getCarriedData(), 3);
this.setCarriedId(0);
if (!CraftEventFactory.callEntityChangeBlockEvent(this, i, j, k, this.getCarried(), this.getCarriedData()).isCancelled()) {
this.world.setTypeAndData(i, j, k, this.getCarried(), this.getCarriedData(), 3);
this.setCarried(Blocks.AIR);
}
// CraftBukkit end
}
@ -173,22 +156,22 @@ public class EntityEnderman extends EntityMonster {
if (this.world.v() && !this.world.isStatic) {
float f = this.d(1.0F);
if (f > 0.5F && this.world.l(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)) && this.random.nextFloat() * 30.0F < (f - 0.4F) * 2.0F) {
if (f > 0.5F && this.world.i(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)) && this.random.nextFloat() * 30.0F < (f - 0.4F) * 2.0F) {
this.target = null;
this.a(false);
this.bv = false;
this.bT();
this.bX();
}
}
if (this.G() || this.isBurning()) {
if (this.L() || this.isBurning()) {
this.target = null;
this.a(false);
this.bv = false;
this.bT();
this.bX();
}
if (this.bX() && !this.bv && this.random.nextInt(100) == 0) {
if (this.cb() && !this.bv && this.random.nextInt(100) == 0) {
this.a(false);
}
@ -201,7 +184,7 @@ public class EntityEnderman extends EntityMonster {
if (this.target != null) {
if (this.target instanceof EntityHuman && this.f((EntityHuman) this.target)) {
if (this.target.e((Entity) this) < 16.0D) {
this.bT();
this.bX();
}
this.bs = 0;
@ -214,15 +197,15 @@ public class EntityEnderman extends EntityMonster {
}
}
super.c();
super.e();
}
protected boolean bT() {
protected boolean bX() {
double d0 = this.locX + (this.random.nextDouble() - 0.5D) * 64.0D;
double d1 = this.locY + (double) (this.random.nextInt(64) - 32);
double d2 = this.locZ + (this.random.nextDouble() - 0.5D) * 64.0D;
return this.j(d0, d1, d2);
return this.k(d0, d1, d2);
}
protected boolean c(Entity entity) {
@ -234,10 +217,10 @@ public class EntityEnderman extends EntityMonster {
double d2 = this.locY + (double) (this.random.nextInt(16) - 8) - vec3d.d * d0;
double d3 = this.locZ + (this.random.nextDouble() - 0.5D) * 8.0D - vec3d.e * d0;
return this.j(d1, d2, d3);
return this.k(d1, d2, d3);
}
protected boolean j(double d0, double d1, double d2) {
protected boolean k(double d0, double d1, double d2) {
double d3 = this.locX;
double d4 = this.locY;
double d5 = this.locZ;
@ -249,14 +232,14 @@ public class EntityEnderman extends EntityMonster {
int i = MathHelper.floor(this.locX);
int j = MathHelper.floor(this.locY);
int k = MathHelper.floor(this.locZ);
int l;
if (this.world.isLoaded(i, j, k)) {
boolean flag1 = false;
while (!flag1 && j > 0) {
l = this.world.getTypeId(i, j - 1, k);
if (l != 0 && Block.byId[l].material.isSolid()) {
Block block = this.world.getType(i, j - 1, k);
if (block.getMaterial().isSolid()) {
flag1 = true;
} else {
--this.locY;
@ -288,7 +271,7 @@ public class EntityEnderman extends EntityMonster {
} else {
short short1 = 128;
for (l = 0; l < short1; ++l) {
for (int l = 0; l < short1; ++l) {
double d6 = (double) l / ((double) short1 - 1.0D);
float f = (this.random.nextFloat() - 0.5F) * 0.2F;
float f1 = (this.random.nextFloat() - 0.5F) * 0.2F;
@ -306,32 +289,32 @@ public class EntityEnderman extends EntityMonster {
}
}
protected String r() {
return this.bX() ? "mob.endermen.scream" : "mob.endermen.idle";
protected String t() {
return this.cb() ? "mob.endermen.scream" : "mob.endermen.idle";
}
protected String aO() {
protected String aT() {
return "mob.endermen.hit";
}
protected String aP() {
protected String aU() {
return "mob.endermen.death";
}
protected int getLootId() {
return Item.ENDER_PEARL.id;
protected Item getLoot() {
return Items.ENDER_PEARL;
}
protected void dropDeathLoot(boolean flag, int i) {
int j = this.getLootId();
Item item = this.getLoot();
if (j > 0) {
if (item != null) {
// CraftBukkit start - Whole method
java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>();
int count = this.random.nextInt(2 + i);
if ((j > 0) && (count > 0)) {
loot.add(new org.bukkit.inventory.ItemStack(j, count));
if (count > 0) {
loot.add(new org.bukkit.inventory.ItemStack(org.bukkit.craftbukkit.v1_7_R1.util.CraftMagicNumbers.getMaterial(item), count));
}
CraftEventFactory.callEntityDeathEvent(this, loot);
@ -339,12 +322,12 @@ public class EntityEnderman extends EntityMonster {
}
}
public void setCarriedId(int i) {
this.datawatcher.watch(16, Byte.valueOf((byte) (i & 255)));
public void setCarried(Block block) {
this.datawatcher.watch(16, Byte.valueOf((byte) (Block.b(block) & 255)));
}
public int getCarriedId() {
return this.datawatcher.getByte(16);
public Block getCarried() {
return Block.e(this.datawatcher.getByte(16));
}
public void setCarriedData(int i) {
@ -368,7 +351,7 @@ public class EntityEnderman extends EntityMonster {
this.bv = false;
for (int i = 0; i < 64; ++i) {
if (this.bT()) {
if (this.bX()) {
return true;
}
}
@ -380,7 +363,7 @@ public class EntityEnderman extends EntityMonster {
}
}
public boolean bX() {
public boolean cb() {
return this.datawatcher.getByte(18) > 0;
}
@ -389,19 +372,19 @@ public class EntityEnderman extends EntityMonster {
}
static {
br[Block.GRASS.id] = true;
br[Block.DIRT.id] = true;
br[Block.SAND.id] = true;
br[Block.GRAVEL.id] = true;
br[Block.YELLOW_FLOWER.id] = true;
br[Block.RED_ROSE.id] = true;
br[Block.BROWN_MUSHROOM.id] = true;
br[Block.RED_MUSHROOM.id] = true;
br[Block.TNT.id] = true;
br[Block.CACTUS.id] = true;
br[Block.CLAY.id] = true;
br[Block.PUMPKIN.id] = true;
br[Block.MELON.id] = true;
br[Block.MYCEL.id] = true;
br[Block.b((Block) Blocks.GRASS)] = true;
br[Block.b(Blocks.DIRT)] = true;
br[Block.b(Blocks.SAND)] = true;
br[Block.b(Blocks.GRAVEL)] = true;
br[Block.b((Block) Blocks.YELLOW_FLOWER)] = true;
br[Block.b((Block) Blocks.RED_ROSE)] = true;
br[Block.b((Block) Blocks.BROWN_MUSHROOM)] = true;
br[Block.b((Block) Blocks.RED_MUSHROOM)] = true;
br[Block.b(Blocks.TNT)] = true;
br[Block.b(Blocks.CACTUS)] = true;
br[Block.b(Blocks.CLAY)] = true;
br[Block.b(Blocks.PUMPKIN)] = true;
br[Block.b(Blocks.MELON)] = true;
br[Block.b((Block) Blocks.MYCEL)] = true;
}
}

View File

@ -0,0 +1,245 @@
package net.minecraft.server.v1_7_R1;
import java.util.ArrayList;
import java.util.Iterator;
// CraftBukkit start
import org.bukkit.craftbukkit.v1_7_R1.event.CraftEventFactory;
import org.bukkit.event.entity.EntityDamageEvent;
// CraftBukkit end
public class EntityFallingBlock extends Entity {
public Block id; // CraftBukkit - private -> public
public int data;
public int b;
public boolean dropItem;
private boolean f;
private boolean hurtEntities;
private int fallHurtMax;
private float fallHurtAmount;
public NBTTagCompound tileEntityData;
public boolean spectating;
public EntityFallingBlock(World world) {
super(world);
this.dropItem = true;
this.fallHurtMax = 40;
this.fallHurtAmount = 2.0F;
}
public EntityFallingBlock(World world, double d0, double d1, double d2, Block block) {
this(world, d0, d1, d2, block, 0);
}
public EntityFallingBlock(World world, double d0, double d1, double d2, Block block, int i) {
super(world);
this.dropItem = true;
this.fallHurtMax = 40;
this.fallHurtAmount = 2.0F;
this.id = block;
this.data = i;
this.l = true;
this.a(0.98F, 0.98F);
this.height = this.length / 2.0F;
this.setPosition(d0, d1, d2);
this.motX = 0.0D;
this.motY = 0.0D;
this.motZ = 0.0D;
this.lastX = d0;
this.lastY = d1;
this.lastZ = d2;
}
protected boolean g_() {
return false;
}
protected void c() {}
public boolean R() {
return !this.dead && !spectating;
}
public void h() {
if (this.id.getMaterial() == Material.AIR) {
this.die();
} else {
this.lastX = this.locX;
this.lastY = this.locY;
this.lastZ = this.locZ;
++this.b;
this.motY -= 0.03999999910593033D;
this.move(this.motX, this.motY, this.motZ);
this.motX *= 0.9800000190734863D;
this.motY *= 0.9800000190734863D;
this.motZ *= 0.9800000190734863D;
if (!this.world.isStatic) {
int i = MathHelper.floor(this.locX);
int j = MathHelper.floor(this.locY);
int k = MathHelper.floor(this.locZ);
if (this.b == 1) {
// CraftBukkit - compare data and call event
if (this.b != 1 || this.world.getType(i, j, k) != this.id || this.world.getData(i, j, k) != this.data || CraftEventFactory.callEntityChangeBlockEvent(this, i, j, k, Blocks.AIR, 0).isCancelled()) {
this.die();
return;
}
this.world.setAir(i, j, k);
}
if (this.onGround) {
this.motX *= 0.699999988079071D;
this.motZ *= 0.699999988079071D;
this.motY *= -0.5D;
if (this.world.getType(i, j, k) != Blocks.PISTON_MOVING) {
this.die();
// CraftBukkit start
if (!this.f && this.world.mayPlace(this.id, i, j, k, true, 1, (Entity) null, (ItemStack) null) && !BlockFalling.canFall(this.world, i, j - 1, k) /* mimic the false conditions of setTypeIdAndData */ && i >= -30000000 && k >= -30000000 && i < 30000000 && k < 30000000 && j > 0 && j < 256 && !(this.world.getType(i, j, k) == this.id && this.world.getData(i, j, k) == this.data)) {
if (CraftEventFactory.callEntityChangeBlockEvent(this, i, j, k, this.id, this.data).isCancelled()) {
return;
}
this.world.setTypeAndData(i, j, k, this.id, this.data, 3);
// CraftBukkit end
if (this.id instanceof BlockFalling) {
((BlockFalling) this.id).a(this.world, i, j, k, this.data);
}
if (this.tileEntityData != null && this.id instanceof IContainer) {
TileEntity tileentity = this.world.getTileEntity(i, j, k);
if (tileentity != null) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
tileentity.b(nbttagcompound);
Iterator iterator = this.tileEntityData.c().iterator();
while (iterator.hasNext()) {
String s = (String) iterator.next();
NBTBase nbtbase = this.tileEntityData.get(s);
if (!s.equals("x") && !s.equals("y") && !s.equals("z")) {
nbttagcompound.set(s, nbtbase.clone());
}
}
tileentity.a(nbttagcompound);
tileentity.update();
}
}
} else if (this.dropItem && !this.f) {
this.a(new ItemStack(this.id, 1, this.id.getDropData(this.data)), 0.0F);
}
}
} else if (this.b > 100 && !this.world.isStatic && (j < 1 || j > 256) || this.b > 600) {
if (this.dropItem) {
this.a(new ItemStack(this.id, 1, this.id.getDropData(this.data)), 0.0F);
}
this.die();
}
}
}
}
protected void b(float f) {
if (this.hurtEntities) {
int i = MathHelper.f(f - 1.0F);
if (i > 0) {
ArrayList arraylist = new ArrayList(this.world.getEntities(this, this.boundingBox));
boolean flag = this.id == Blocks.ANVIL;
DamageSource damagesource = flag ? DamageSource.ANVIL : DamageSource.FALLING_BLOCK;
Iterator iterator = arraylist.iterator();
while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next();
// CraftBukkit start
float damage = (float) Math.min(MathHelper.d((float) i * this.fallHurtAmount), this.fallHurtMax);
EntityDamageEvent event = CraftEventFactory.callEntityDamageEvent(this, entity, EntityDamageEvent.DamageCause.FALLING_BLOCK, damage);
if (event.isCancelled()) {
continue;
}
entity.damageEntity(damagesource, (float) event.getDamage());
// CraftBukkit end
}
if (flag && (double) this.random.nextFloat() < 0.05000000074505806D + (double) i * 0.05D) {
int j = this.data >> 2;
int k = this.data & 3;
++j;
if (j > 2) {
this.f = true;
} else {
this.data = k | j << 2;
}
}
}
}
}
protected void b(NBTTagCompound nbttagcompound) {
nbttagcompound.setByte("Tile", (byte) Block.b(this.id));
nbttagcompound.setInt("TileID", Block.b(this.id));
nbttagcompound.setByte("Data", (byte) this.data);
nbttagcompound.setByte("Time", (byte) this.b);
nbttagcompound.setBoolean("DropItem", this.dropItem);
nbttagcompound.setBoolean("HurtEntities", this.hurtEntities);
nbttagcompound.setFloat("FallHurtAmount", this.fallHurtAmount);
nbttagcompound.setInt("FallHurtMax", this.fallHurtMax);
if (this.tileEntityData != null) {
nbttagcompound.set("TileEntityData", this.tileEntityData);
}
}
protected void a(NBTTagCompound nbttagcompound) {
if (nbttagcompound.hasKeyOfType("TileID", 99)) {
this.id = Block.e(nbttagcompound.getInt("TileID"));
} else {
this.id = Block.e(nbttagcompound.getByte("Tile") & 255);
}
this.data = nbttagcompound.getByte("Data") & 255;
this.b = nbttagcompound.getByte("Time") & 255;
if (nbttagcompound.hasKeyOfType("HurtEntities", 99)) {
this.hurtEntities = nbttagcompound.getBoolean("HurtEntities");
this.fallHurtAmount = nbttagcompound.getFloat("FallHurtAmount");
this.fallHurtMax = nbttagcompound.getInt("FallHurtMax");
} else if (this.id == Blocks.ANVIL) {
this.hurtEntities = true;
}
if (nbttagcompound.hasKeyOfType("DropItem", 99)) {
this.dropItem = nbttagcompound.getBoolean("DropItem");
}
if (nbttagcompound.hasKeyOfType("TileEntityData", 10)) {
this.tileEntityData = nbttagcompound.getCompound("TileEntityData");
}
if (this.id.getMaterial() == Material.AIR) {
this.id = Blocks.SAND;
}
}
public void a(boolean flag) {
this.hurtEntities = flag;
}
public void a(CrashReportSystemDetails crashreportsystemdetails) {
super.a(crashreportsystemdetails);
crashreportsystemdetails.a("Immitating block ID", Integer.valueOf(Block.b(this.id)));
crashreportsystemdetails.a("Immitating block data", Integer.valueOf(this.data));
}
public Block f() {
return this.id;
}
}

View File

@ -0,0 +1,263 @@
package net.minecraft.server.v1_7_R1;
// CraftBukkit start
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_7_R1.inventory.CraftItemStack;
import org.bukkit.event.entity.EntityTargetEvent;
// CraftBukkit end
public class EntityGhast extends EntityFlying implements IMonster {
public int h;
public double i;
public double j;
public double bn;
private Entity target;
private int br;
public int bo;
public int bp;
private int explosionPower = 1;
public EntityGhast(World world) {
super(world);
this.a(4.0F, 4.0F);
this.fireProof = true;
this.b = 5;
}
public boolean damageEntity(DamageSource damagesource, float f) {
if (this.isInvulnerable()) {
return false;
} else if ("fireball".equals(damagesource.p()) && damagesource.getEntity() instanceof EntityHuman) {
super.damageEntity(damagesource, 1000.0F);
((EntityHuman) damagesource.getEntity()).a((Statistic) AchievementList.z);
return true;
} else {
return super.damageEntity(damagesource, f);
}
}
protected void c() {
super.c();
this.datawatcher.a(16, Byte.valueOf((byte) 0));
}
protected void aD() {
super.aD();
this.getAttributeInstance(GenericAttributes.a).setValue(10.0D);
}
protected void bq() {
if (!this.world.isStatic && this.world.difficulty == EnumDifficulty.PEACEFUL) {
this.die();
}
if (Vegetated)
{
double d0 = this.i - this.locX;
double d1 = this.j - this.locY;
double d2 = this.bn - this.locZ;
double d3 = d0 * d0 + d1 * d1 + d2 * d2;
this.motX += d0 / d3 * 0.1D;
this.motY += d1 / d3 * 0.1D;
this.motZ += d2 / d3 * 0.1D;
double d5 = this.i - this.locX;
double d6 = this.bn - this.locZ;
this.aN = this.yaw = -((float) Math.atan2(d5, d6)) * 180.0F / 3.1415927F;
return;
}
this.w();
this.bo = this.bp;
double d0 = this.i - this.locX;
double d1 = this.j - this.locY;
double d2 = this.bn - this.locZ;
double d3 = d0 * d0 + d1 * d1 + d2 * d2;
if (d3 < 1.0D || d3 > 3600.0D) {
this.i = this.locX + (double) ((this.random.nextFloat() * 2.0F - 1.0F) * 16.0F);
this.j = this.locY + (double) ((this.random.nextFloat() * 2.0F - 1.0F) * 16.0F);
this.bn = this.locZ + (double) ((this.random.nextFloat() * 2.0F - 1.0F) * 16.0F);
}
if (this.h-- <= 0) {
this.h += this.random.nextInt(5) + 2;
d3 = (double) MathHelper.sqrt(d3);
if (this.a(this.i, this.j, this.bn, d3)) {
this.motX += d0 / d3 * 0.1D;
this.motY += d1 / d3 * 0.1D;
this.motZ += d2 / d3 * 0.1D;
} else {
this.i = this.locX;
this.j = this.locY;
this.bn = this.locZ;
}
}
if (this.target != null && this.target.dead) {
// CraftBukkit start
EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), null, EntityTargetEvent.TargetReason.TARGET_DIED);
this.world.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
if (event.getTarget() == null) {
this.target = null;
} else {
this.target = ((CraftEntity) event.getTarget()).getHandle();
}
}
// CraftBukkit end
}
if (this.target == null || this.br-- <= 0) {
// CraftBukkit start
Entity target = this.world.findNearbyVulnerablePlayer(this, 100.0D);
if (target != null) {
EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), target.getBukkitEntity(), EntityTargetEvent.TargetReason.CLOSEST_PLAYER);
this.world.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
if (event.getTarget() == null) {
this.target = null;
} else {
this.target = ((CraftEntity) event.getTarget()).getHandle();
}
}
}
// CraftBukkit end
if (this.target != null) {
this.br = 20;
}
}
double d4 = 64.0D;
if (this.target != null && this.target.e((Entity) this) < d4 * d4) {
double d5 = this.target.locX - this.locX;
double d6 = this.target.boundingBox.b + (double) (this.target.length / 2.0F) - (this.locY + (double) (this.length / 2.0F));
double d7 = this.target.locZ - this.locZ;
this.aN = this.yaw = -((float) Math.atan2(d5, d7)) * 180.0F / 3.1415927F;
if (this.o(this.target)) {
if (this.bp == 10) {
this.world.a((EntityHuman) null, 1007, (int) this.locX, (int) this.locY, (int) this.locZ, 0);
}
++this.bp;
if (this.bp == 20) {
this.world.a((EntityHuman) null, 1008, (int) this.locX, (int) this.locY, (int) this.locZ, 0);
EntityLargeFireball entitylargefireball = new EntityLargeFireball(this.world, this, d5, d6, d7);
// CraftBukkit - set bukkitYield when setting explosionpower
entitylargefireball.bukkitYield = entitylargefireball.yield = this.explosionPower;
double d8 = 4.0D;
Vec3D vec3d = this.j(1.0F);
entitylargefireball.locX = this.locX + vec3d.c * d8;
entitylargefireball.locY = this.locY + (double) (this.length / 2.0F) + 0.5D;
entitylargefireball.locZ = this.locZ + vec3d.e * d8;
this.world.addEntity(entitylargefireball);
this.bp = -40;
}
} else if (this.bp > 0) {
--this.bp;
}
} else {
this.aN = this.yaw = -((float) Math.atan2(this.motX, this.motZ)) * 180.0F / 3.1415927F;
if (this.bp > 0) {
--this.bp;
}
}
if (!this.world.isStatic) {
byte b0 = this.datawatcher.getByte(16);
byte b1 = (byte) (this.bp > 10 ? 1 : 0);
if (b0 != b1) {
this.datawatcher.watch(16, Byte.valueOf(b1));
}
}
}
private boolean a(double d0, double d1, double d2, double d3) {
double d4 = (this.i - this.locX) / d3;
double d5 = (this.j - this.locY) / d3;
double d6 = (this.bn - this.locZ) / d3;
AxisAlignedBB axisalignedbb = this.boundingBox.clone();
for (int i = 1; (double) i < d3; ++i) {
axisalignedbb.d(d4, d5, d6);
if (!this.world.getCubes(this, axisalignedbb).isEmpty()) {
return false;
}
}
return true;
}
protected String t() {
return "mob.ghast.moan";
}
protected String aT() {
return "mob.ghast.scream";
}
protected String aU() {
return "mob.ghast.death";
}
protected Item getLoot() {
return Items.SULPHUR;
}
protected void dropDeathLoot(boolean flag, int i) {
// CraftBukkit start
java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>();
int j = this.random.nextInt(2) + this.random.nextInt(1 + i);
int k;
if (j > 0) {
loot.add(CraftItemStack.asNewCraftStack(Items.GHAST_TEAR, j));
}
j = this.random.nextInt(3) + this.random.nextInt(1 + i);
if (j > 0) {
loot.add(CraftItemStack.asNewCraftStack(Items.SULPHUR, j));
}
org.bukkit.craftbukkit.v1_7_R1.event.CraftEventFactory.callEntityDeathEvent(this, loot);
// CraftBukkit end
}
protected float bf() {
return 10.0F;
}
public boolean canSpawn() {
return this.random.nextInt(20) == 0 && super.canSpawn() && this.world.difficulty != EnumDifficulty.PEACEFUL;
}
public int bz() {
return 1;
}
public void b(NBTTagCompound nbttagcompound) {
super.b(nbttagcompound);
nbttagcompound.setInt("ExplosionPower", this.explosionPower);
}
public void a(NBTTagCompound nbttagcompound) {
super.a(nbttagcompound);
if (nbttagcompound.hasKeyOfType("ExplosionPower", 99)) {
this.explosionPower = nbttagcompound.getInt("ExplosionPower");
}
}
}

View File

@ -1,47 +1,13 @@
package net.minecraft.server.v1_6_R3;
package net.minecraft.server.v1_7_R1;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
import net.minecraft.server.v1_6_R3.AttributeModifier;
import net.minecraft.server.v1_6_R3.Block;
import net.minecraft.server.v1_6_R3.ControllerJump;
import net.minecraft.server.v1_6_R3.ControllerLook;
import net.minecraft.server.v1_6_R3.ControllerMove;
import net.minecraft.server.v1_6_R3.EnchantmentManager;
import net.minecraft.server.v1_6_R3.Entity;
import net.minecraft.server.v1_6_R3.EntityAIBodyControl;
import net.minecraft.server.v1_6_R3.EntityCreeper;
import net.minecraft.server.v1_6_R3.EntityGhast;
import net.minecraft.server.v1_6_R3.EntityHanging;
import net.minecraft.server.v1_6_R3.EntityHuman;
import net.minecraft.server.v1_6_R3.EntityItem;
import net.minecraft.server.v1_6_R3.EntityLeash;
import net.minecraft.server.v1_6_R3.EntityLiving;
import net.minecraft.server.v1_6_R3.EntityPlayer;
import net.minecraft.server.v1_6_R3.EntitySenses;
import net.minecraft.server.v1_6_R3.EntityTameableAnimal;
import net.minecraft.server.v1_6_R3.GenericAttributes;
import net.minecraft.server.v1_6_R3.GroupDataEntity;
import net.minecraft.server.v1_6_R3.IMonster;
import net.minecraft.server.v1_6_R3.Item;
import net.minecraft.server.v1_6_R3.ItemArmor;
import net.minecraft.server.v1_6_R3.ItemStack;
import net.minecraft.server.v1_6_R3.ItemSword;
import net.minecraft.server.v1_6_R3.MathHelper;
import net.minecraft.server.v1_6_R3.NBTTagCompound;
import net.minecraft.server.v1_6_R3.NBTTagFloat;
import net.minecraft.server.v1_6_R3.NBTTagList;
import net.minecraft.server.v1_6_R3.Navigation;
import net.minecraft.server.v1_6_R3.Packet;
import net.minecraft.server.v1_6_R3.Packet39AttachEntity;
import net.minecraft.server.v1_6_R3.PathfinderGoalSelector;
import net.minecraft.server.v1_6_R3.World;
import net.minecraft.server.v1_6_R3.WorldServer;
// CraftBukkit start
import org.bukkit.craftbukkit.v1_6_R3.event.CraftEventFactory;
import org.bukkit.craftbukkit.v1_7_R1.event.CraftEventFactory;
import org.bukkit.event.entity.EntityUnleashEvent;
import org.bukkit.event.entity.EntityUnleashEvent.UnleashReason;
// CraftBukkit end
public abstract class EntityInsentient extends EntityLiving {
@ -67,11 +33,11 @@ public abstract class EntityInsentient extends EntityLiving {
private boolean bv;
private Entity bw;
private NBTTagCompound bx;
public boolean Vegetated;
public boolean BreakLeash = true;
public boolean PullWhileLeashed = true;
public EntityInsentient(World world) {
super(world);
this.goalSelector = new PathfinderGoalSelector(world != null && world.methodProfiler != null ? world.methodProfiler : null);
@ -88,9 +54,9 @@ public abstract class EntityInsentient extends EntityLiving {
}
}
protected void az() {
super.az();
this.aX().b(GenericAttributes.b).setValue(16.0D);
protected void aD() {
super.aD();
this.bc().b(GenericAttributes.b).setValue(16.0D);
}
public ControllerLook getControllerLook() {
@ -125,32 +91,32 @@ public abstract class EntityInsentient extends EntityLiving {
return EntityCreeper.class != oclass && EntityGhast.class != oclass;
}
public void n() {}
public void p() {}
protected void a() {
super.a();
protected void c() {
super.c();
this.datawatcher.a(11, Byte.valueOf((byte) 0));
this.datawatcher.a(10, "");
}
public int o() {
public int q() {
return 80;
}
public void p() {
String s = this.r();
public void r() {
String s = this.t();
if (s != null) {
this.makeSound(s, this.ba(), this.bb());
this.makeSound(s, this.bf(), this.bg());
}
}
public void y() {
super.y();
public void C() {
super.C();
this.world.methodProfiler.a("mobBaseTick");
if (this.isAlive() && !Silent && this.random.nextInt(1000) < this.a_++) {
this.a_ = -this.o();
this.p();
this.a_ = -this.q();
this.r();
}
this.world.methodProfiler.b();
@ -173,7 +139,7 @@ public abstract class EntityInsentient extends EntityLiving {
}
}
public void q() {
public void s() {
for (int i = 0; i < 20; ++i) {
double d0 = this.random.nextGaussian() * 0.02D;
double d1 = this.random.nextGaussian() * 0.02D;
@ -184,15 +150,15 @@ public abstract class EntityInsentient extends EntityLiving {
}
}
public void l_() {
super.l_();
public void h() {
super.h();
if (!this.world.isStatic) {
this.bF();
this.bJ();
}
}
protected float f(float f, float f1) {
if (this.bf()) {
if (this.bk()) {
this.bn.a();
return f1;
} else {
@ -200,28 +166,28 @@ public abstract class EntityInsentient extends EntityLiving {
}
}
protected String r() {
protected String t() {
return null;
}
protected int getLootId() {
return 0;
protected Item getLoot() {
return Item.d(0);
}
protected void dropDeathLoot(boolean flag, int i) {
// CraftBukkit start - Whole method
List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>();
int j = this.getLootId();
Item item = this.getLoot();
if (j > 0) {
int k = this.random.nextInt(3);
if (item != null) {
int j = this.random.nextInt(3);
if (i > 0) {
k += this.random.nextInt(i + 1);
j += this.random.nextInt(i + 1);
}
if (k > 0) {
loot.add(new org.bukkit.inventory.ItemStack(j, k));
if (j > 0) {
loot.add(new org.bukkit.inventory.ItemStack(org.bukkit.craftbukkit.v1_7_R1.util.CraftMagicNumbers.getMaterial(item), j));
}
}
@ -230,9 +196,9 @@ public abstract class EntityInsentient extends EntityLiving {
int k = this.random.nextInt(200) - i;
if (k < 5) {
ItemStack itemstack = this.l(k <= 0 ? 1 : 0);
ItemStack itemstack = this.getRareDrop(k <= 0 ? 1 : 0);
if (itemstack != null) {
loot.add(org.bukkit.craftbukkit.v1_6_R3.inventory.CraftItemStack.asCraftMirror(itemstack));
loot.add(org.bukkit.craftbukkit.v1_7_R1.inventory.CraftItemStack.asCraftMirror(itemstack));
}
}
}
@ -243,7 +209,7 @@ public abstract class EntityInsentient extends EntityLiving {
public void b(NBTTagCompound nbttagcompound) {
super.b(nbttagcompound);
nbttagcompound.setBoolean("CanPickUpLoot", this.bD());
nbttagcompound.setBoolean("CanPickUpLoot", this.bH());
nbttagcompound.setBoolean("PersistenceRequired", this.persistent);
NBTTagList nbttaglist = new NBTTagList();
@ -262,7 +228,7 @@ public abstract class EntityInsentient extends EntityLiving {
NBTTagList nbttaglist1 = new NBTTagList();
for (int j = 0; j < this.dropChances.length; ++j) {
nbttaglist1.add(new NBTTagFloat(j + "", this.dropChances[j]));
nbttaglist1.add(new NBTTagFloat(this.dropChances[j]));
}
nbttagcompound.set("DropChances", nbttaglist1);
@ -270,7 +236,7 @@ public abstract class EntityInsentient extends EntityLiving {
nbttagcompound.setBoolean("CustomNameVisible", this.getCustomNameVisible());
nbttagcompound.setBoolean("Leashed", this.bv);
if (this.bw != null) {
nbttagcompound1 = new NBTTagCompound("Leash");
nbttagcompound1 = new NBTTagCompound();
if (this.bw instanceof EntityLiving) {
nbttagcompound1.setLong("UUIDMost", this.bw.getUniqueID().getMostSignificantBits());
nbttagcompound1.setLong("UUIDLeast", this.bw.getUniqueID().getLeastSignificantBits());
@ -301,7 +267,7 @@ public abstract class EntityInsentient extends EntityLiving {
}
// CraftBukkit end
if (nbttagcompound.hasKey("CustomName") && nbttagcompound.getString("CustomName").length() > 0) {
if (nbttagcompound.hasKeyOfType("CustomName", 8) && nbttagcompound.getString("CustomName").length() > 0) {
this.setCustomName(nbttagcompound.getString("CustomName"));
}
@ -309,24 +275,24 @@ public abstract class EntityInsentient extends EntityLiving {
NBTTagList nbttaglist;
int i;
if (nbttagcompound.hasKey("Equipment")) {
nbttaglist = nbttagcompound.getList("Equipment");
if (nbttagcompound.hasKeyOfType("Equipment", 9)) {
nbttaglist = nbttagcompound.getList("Equipment", 10);
for (i = 0; i < this.equipment.length; ++i) {
this.equipment[i] = ItemStack.createStack((NBTTagCompound) nbttaglist.get(i));
this.equipment[i] = ItemStack.createStack(nbttaglist.get(i));
}
}
if (nbttagcompound.hasKey("DropChances")) {
nbttaglist = nbttagcompound.getList("DropChances");
if (nbttagcompound.hasKeyOfType("DropChances", 9)) {
nbttaglist = nbttagcompound.getList("DropChances", 5);
for (i = 0; i < nbttaglist.size(); ++i) {
this.dropChances[i] = ((NBTTagFloat) nbttaglist.get(i)).data;
this.dropChances[i] = nbttaglist.e(i);
}
}
this.bv = nbttagcompound.getBoolean("Leashed");
if (this.bv && nbttagcompound.hasKey("Leash")) {
if (this.bv && nbttagcompound.hasKeyOfType("Leash", 10)) {
this.bx = nbttagcompound.getCompound("Leash");
}
}
@ -340,10 +306,10 @@ public abstract class EntityInsentient extends EntityLiving {
this.n(f);
}
public void c() {
super.c();
public void e() {
super.e();
this.world.methodProfiler.a("looting");
if (!this.world.isStatic && this.bD() && !this.aU && this.world.getGameRules().getBoolean("mobGriefing")) {
if (!this.world.isStatic && this.bH() && !this.aU && this.world.getGameRules().getBoolean("mobGriefing")) {
List list = this.world.a(EntityItem.class, this.boundingBox.grow(1.0D, 0.0D, 1.0D));
Iterator iterator = list.iterator();
@ -366,10 +332,10 @@ public abstract class EntityInsentient extends EntityLiving {
ItemSword itemsword = (ItemSword) itemstack.getItem();
ItemSword itemsword1 = (ItemSword) itemstack1.getItem();
if (itemsword.g() == itemsword1.g()) {
if (itemsword.i() == itemsword1.i()) {
flag = itemstack.getData() > itemstack1.getData() || itemstack.hasTag() && !itemstack1.hasTag();
} else {
flag = itemsword.g() > itemsword1.g();
flag = itemsword.i() > itemsword1.i();
}
} else {
flag = false;
@ -395,6 +361,14 @@ public abstract class EntityInsentient extends EntityLiving {
this.a(itemstack1, 0.0F);
}
if (itemstack.getItem() == Items.DIAMOND && entityitem.j() != null) {
EntityHuman entityhuman = this.world.a(entityitem.j());
if (entityhuman != null) {
entityhuman.a((Statistic) AchievementList.x);
}
}
this.setEquipment(i, itemstack);
this.dropChances[i] = 2.0F;
this.persistent = true;
@ -409,7 +383,7 @@ public abstract class EntityInsentient extends EntityLiving {
this.world.methodProfiler.b();
}
protected boolean bf() {
protected boolean bk() {
return false;
}
@ -417,7 +391,7 @@ public abstract class EntityInsentient extends EntityLiving {
return true;
}
protected void u() {
protected void w() {
if (this.persistent) {
this.aV = 0;
} else {
@ -442,10 +416,10 @@ public abstract class EntityInsentient extends EntityLiving {
}
}
protected void bi() {
protected void bn() {
++this.aV;
this.world.methodProfiler.a("checkDespawn");
this.u();
this.w();
this.world.methodProfiler.b();
this.world.methodProfiler.a("sensing");
this.bq.a();
@ -460,7 +434,7 @@ public abstract class EntityInsentient extends EntityLiving {
this.navigation.f();
this.world.methodProfiler.b();
this.world.methodProfiler.a("mob tick");
this.bk();
this.bp();
this.world.methodProfiler.b();
this.world.methodProfiler.a("controls");
this.world.methodProfiler.a("move");
@ -473,11 +447,11 @@ public abstract class EntityInsentient extends EntityLiving {
this.world.methodProfiler.b();
}
protected void bl() {
super.bl();
protected void bq() {
super.bq();
this.be = 0.0F;
this.bf = 0.0F;
this.u();
this.w();
float f = 8.0F;
if (this.random.nextFloat() < 0.02F) {
@ -492,7 +466,7 @@ public abstract class EntityInsentient extends EntityLiving {
}
if (this.bu != null) {
this.a(this.bu, 10.0F, (float) this.bp());
this.a(this.bu, 10.0F, (float) this.x());
if (this.g-- <= 0 || this.bu.dead || this.bu.e((Entity) this) > (double) (f * f)) {
this.bu = null;
}
@ -505,15 +479,15 @@ public abstract class EntityInsentient extends EntityLiving {
this.pitch = this.f;
}
boolean flag = this.H();
boolean flag1 = this.J();
boolean flag = this.M();
boolean flag1 = this.P();
if (flag || flag1) {
this.bd = this.random.nextFloat() < 0.8F;
}
}
public int bp() {
public int x() {
return 40;
}
@ -556,17 +530,17 @@ public abstract class EntityInsentient extends EntityLiving {
return this.world.b(this.boundingBox) && this.world.getCubes(this, this.boundingBox).isEmpty() && !this.world.containsLiquid(this.boundingBox);
}
public int bv() {
public int bz() {
return 4;
}
public int as() {
public int ax() {
if (this.getGoalTarget() == null) {
return 3;
} else {
int i = (int) (this.getHealth() - this.getMaxHealth() * 0.33F);
i -= (3 - this.world.difficulty) * 4;
i -= (3 - this.world.difficulty.a()) * 4;
if (i < 0) {
i = 0;
}
@ -575,7 +549,7 @@ public abstract class EntityInsentient extends EntityLiving {
}
}
public ItemStack aZ() {
public ItemStack be() {
return this.equipment[0];
}
@ -583,7 +557,7 @@ public abstract class EntityInsentient extends EntityLiving {
return this.equipment[i];
}
public ItemStack o(int i) {
public ItemStack r(int i) {
return this.equipment[i + 1];
}
@ -621,10 +595,10 @@ public abstract class EntityInsentient extends EntityLiving {
}
}
protected void bw() {
protected void bA() {
if (this.random.nextFloat() < 0.15F * this.world.b(this.locX, this.locY, this.locZ)) {
int i = this.random.nextInt(2);
float f = this.world.difficulty == 3 ? 0.1F : 0.25F;
float f = this.world.difficulty == EnumDifficulty.HARD ? 0.1F : 0.25F;
if (this.random.nextFloat() < 0.095F) {
++i;
@ -639,7 +613,7 @@ public abstract class EntityInsentient extends EntityLiving {
}
for (int j = 3; j >= 0; --j) {
ItemStack itemstack = this.o(j);
ItemStack itemstack = this.r(j);
if (j < 3 && this.random.nextFloat() < f) {
break;
@ -657,7 +631,7 @@ public abstract class EntityInsentient extends EntityLiving {
}
public static int b(ItemStack itemstack) {
if (itemstack.id != Block.PUMPKIN.id && itemstack.id != Item.SKULL.id) {
if (itemstack.getItem() != Item.getItemOf(Blocks.PUMPKIN) && itemstack.getItem() != Items.SKULL) {
if (itemstack.getItem() instanceof ItemArmor) {
switch (((ItemArmor) itemstack.getItem()).b) {
case 0:
@ -684,54 +658,54 @@ public abstract class EntityInsentient extends EntityLiving {
switch (i) {
case 4:
if (j == 0) {
return Item.LEATHER_HELMET;
return Items.LEATHER_HELMET;
} else if (j == 1) {
return Item.GOLD_HELMET;
return Items.GOLD_HELMET;
} else if (j == 2) {
return Item.CHAINMAIL_HELMET;
return Items.CHAINMAIL_HELMET;
} else if (j == 3) {
return Item.IRON_HELMET;
return Items.IRON_HELMET;
} else if (j == 4) {
return Item.DIAMOND_HELMET;
return Items.DIAMOND_HELMET;
}
case 3:
if (j == 0) {
return Item.LEATHER_CHESTPLATE;
return Items.LEATHER_CHESTPLATE;
} else if (j == 1) {
return Item.GOLD_CHESTPLATE;
return Items.GOLD_CHESTPLATE;
} else if (j == 2) {
return Item.CHAINMAIL_CHESTPLATE;
return Items.CHAINMAIL_CHESTPLATE;
} else if (j == 3) {
return Item.IRON_CHESTPLATE;
return Items.IRON_CHESTPLATE;
} else if (j == 4) {
return Item.DIAMOND_CHESTPLATE;
return Items.DIAMOND_CHESTPLATE;
}
case 2:
if (j == 0) {
return Item.LEATHER_LEGGINGS;
return Items.LEATHER_LEGGINGS;
} else if (j == 1) {
return Item.GOLD_LEGGINGS;
return Items.GOLD_LEGGINGS;
} else if (j == 2) {
return Item.CHAINMAIL_LEGGINGS;
return Items.CHAINMAIL_LEGGINGS;
} else if (j == 3) {
return Item.IRON_LEGGINGS;
return Items.IRON_LEGGINGS;
} else if (j == 4) {
return Item.DIAMOND_LEGGINGS;
return Items.DIAMOND_LEGGINGS;
}
case 1:
if (j == 0) {
return Item.LEATHER_BOOTS;
return Items.LEATHER_BOOTS;
} else if (j == 1) {
return Item.GOLD_BOOTS;
return Items.GOLD_BOOTS;
} else if (j == 2) {
return Item.CHAINMAIL_BOOTS;
return Items.CHAINMAIL_BOOTS;
} else if (j == 3) {
return Item.IRON_BOOTS;
return Items.IRON_BOOTS;
} else if (j == 4) {
return Item.DIAMOND_BOOTS;
return Items.DIAMOND_BOOTS;
}
default:
@ -739,15 +713,15 @@ public abstract class EntityInsentient extends EntityLiving {
}
}
protected void bx() {
protected void bB() {
float f = this.world.b(this.locX, this.locY, this.locZ);
if (this.aZ() != null && this.random.nextFloat() < 0.25F * f) {
EnchantmentManager.a(this.random, this.aZ(), (int) (5.0F + f * (float) this.random.nextInt(18)));
if (this.be() != null && this.random.nextFloat() < 0.25F * f) {
EnchantmentManager.a(this.random, this.be(), (int) (5.0F + f * (float) this.random.nextInt(18)));
}
for (int i = 0; i < 4; ++i) {
ItemStack itemstack = this.o(i);
ItemStack itemstack = this.r(i);
if (itemstack != null && this.random.nextFloat() < 0.5F * f) {
EnchantmentManager.a(this.random, itemstack, (int) (5.0F + f * (float) this.random.nextInt(18)));
@ -760,15 +734,15 @@ public abstract class EntityInsentient extends EntityLiving {
return groupdataentity;
}
public boolean by() {
public boolean bC() {
return false;
}
public String getLocalizedName() {
return this.hasCustomName() ? this.getCustomName() : super.getLocalizedName();
public String getName() {
return this.hasCustomName() ? this.getCustomName() : super.getName();
}
public void bz() {
public void bD() {
this.persistent = true;
}
@ -796,7 +770,7 @@ public abstract class EntityInsentient extends EntityLiving {
this.dropChances[i] = f;
}
public boolean bD() {
public boolean bH() {
return this.canPickUpLoot;
}
@ -809,38 +783,38 @@ public abstract class EntityInsentient extends EntityLiving {
}
public final boolean c(EntityHuman entityhuman) {
if (this.bH() && this.getLeashHolder() == entityhuman && BreakLeash) {
// CraftBukkit start
if (CraftEventFactory.callPlayerUnleashEntityEvent(this, entityhuman).isCancelled()) {
((EntityPlayer)entityhuman).playerConnection.sendPacket(new Packet39AttachEntity(1, this, this.getLeashHolder()));
return false;
}
// CraftBukkit end
if (this.bL() && this.getLeashHolder() == entityhuman && BreakLeash) {
// CraftBukkit start
if (CraftEventFactory.callPlayerUnleashEntityEvent(this, entityhuman).isCancelled()) {
((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutAttachEntity(1, this, this.getLeashHolder()));
return false;
}
// CraftBukkit end
this.unleash(true, !entityhuman.abilities.canInstantlyBuild);
return true;
} else {
ItemStack itemstack = entityhuman.inventory.getItemInHand();
if (itemstack != null && itemstack.id == Item.LEASH.id && this.bG()) {
if (itemstack != null && itemstack.getItem() == Items.LEASH && this.bK()) {
if (!(this instanceof EntityTameableAnimal) || !((EntityTameableAnimal) this).isTamed()) {
// CraftBukkit start
if (CraftEventFactory.callPlayerLeashEntityEvent(this, entityhuman, entityhuman).isCancelled()) {
((EntityPlayer)entityhuman).playerConnection.sendPacket(new Packet39AttachEntity(1, this, this.getLeashHolder()));
return false;
}
// CraftBukkit end
// CraftBukkit start
if (CraftEventFactory.callPlayerLeashEntityEvent(this, entityhuman, entityhuman).isCancelled()) {
((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutAttachEntity(1, this, this.getLeashHolder()));
return false;
}
// CraftBukkit end
this.setLeashHolder(entityhuman, true);
--itemstack.count;
return true;
}
if (entityhuman.getName().equalsIgnoreCase(((EntityTameableAnimal) this).getOwnerName())) {
// CraftBukkit start
if (CraftEventFactory.callPlayerLeashEntityEvent(this, entityhuman, entityhuman).isCancelled()) {
((EntityPlayer)entityhuman).playerConnection.sendPacket(new Packet39AttachEntity(1, this, this.getLeashHolder()));
return false;
}
// CraftBukkit end
// CraftBukkit start
if (CraftEventFactory.callPlayerLeashEntityEvent(this, entityhuman, entityhuman).isCancelled()) {
((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutAttachEntity(1, this, this.getLeashHolder()));
return false;
}
// CraftBukkit end
this.setLeashHolder(entityhuman, true);
--itemstack.count;
return true;
@ -855,13 +829,14 @@ public abstract class EntityInsentient extends EntityLiving {
return false;
}
protected void bF() {
protected void bJ() {
if (this.bx != null) {
this.bJ();
this.bN();
}
if (this.bv) {
if (this.bw == null || this.bw.dead) {
this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.HOLDER_GONE)); // CraftBukkit
this.unleash(true, true);
}
}
@ -872,20 +847,20 @@ public abstract class EntityInsentient extends EntityLiving {
this.bv = false;
this.bw = null;
if (!this.world.isStatic && flag1) {
this.b(Item.LEASH.id, 1);
this.a(Items.LEASH, 1);
}
if (!this.world.isStatic && flag && this.world instanceof WorldServer) {
((WorldServer) this.world).getTracker().a((Entity) this, (Packet) (new Packet39AttachEntity(1, this, (Entity) null)));
((WorldServer) this.world).getTracker().a((Entity) this, (Packet) (new PacketPlayOutAttachEntity(1, this, (Entity) null)));
}
}
}
public boolean bG() {
return !this.bH() && !(this instanceof IMonster);
public boolean bK() {
return !this.bL() && !(this instanceof IMonster);
}
public boolean bH() {
public boolean bL() {
return this.bv;
}
@ -897,13 +872,13 @@ public abstract class EntityInsentient extends EntityLiving {
this.bv = true;
this.bw = entity;
if (!this.world.isStatic && flag && this.world instanceof WorldServer) {
((WorldServer) this.world).getTracker().a((Entity) this, (Packet) (new Packet39AttachEntity(1, this, this.bw)));
((WorldServer) this.world).getTracker().a((Entity) this, (Packet) (new PacketPlayOutAttachEntity(1, this, this.bw)));
}
}
private void bJ() {
private void bN() {
if (this.bv && this.bx != null) {
if (this.bx.hasKey("UUIDMost") && this.bx.hasKey("UUIDLeast")) {
if (this.bx.hasKeyOfType("UUIDMost", 4) && this.bx.hasKeyOfType("UUIDLeast", 4)) {
UUID uuid = new UUID(this.bx.getLong("UUIDMost"), this.bx.getLong("UUIDLeast"));
List list = this.world.a(EntityLiving.class, this.boundingBox.grow(10.0D, 10.0D, 10.0D));
Iterator iterator = list.iterator();
@ -916,7 +891,7 @@ public abstract class EntityInsentient extends EntityLiving {
break;
}
}
} else if (this.bx.hasKey("X") && this.bx.hasKey("Y") && this.bx.hasKey("Z")) {
} else if (this.bx.hasKeyOfType("X", 99) && this.bx.hasKeyOfType("Y", 99) && this.bx.hasKeyOfType("Z", 99)) {
int i = this.bx.getInt("X");
int j = this.bx.getInt("Y");
int k = this.bx.getInt("Z");
@ -928,6 +903,7 @@ public abstract class EntityInsentient extends EntityLiving {
this.bw = entityleash;
} else {
this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit
this.unleash(false, true);
}
}

View File

@ -1,133 +1,54 @@
package net.minecraft.server.v1_6_R3;
package net.minecraft.server.v1_7_R1;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import net.minecraft.server.v1_6_R3.AchievementList;
import net.minecraft.server.v1_6_R3.ChatMessage;
import net.minecraft.server.v1_6_R3.Chunk;
import net.minecraft.server.v1_6_R3.ChunkCoordIntPair;
import net.minecraft.server.v1_6_R3.ChunkCoordinates;
import net.minecraft.server.v1_6_R3.CombatTracker;
import net.minecraft.server.v1_6_R3.Container;
import net.minecraft.server.v1_6_R3.ContainerAnvil;
import net.minecraft.server.v1_6_R3.ContainerBeacon;
import net.minecraft.server.v1_6_R3.ContainerBrewingStand;
import net.minecraft.server.v1_6_R3.ContainerChest;
import net.minecraft.server.v1_6_R3.ContainerDispenser;
import net.minecraft.server.v1_6_R3.ContainerEnchantTable;
import net.minecraft.server.v1_6_R3.ContainerFurnace;
import net.minecraft.server.v1_6_R3.ContainerHopper;
import net.minecraft.server.v1_6_R3.ContainerHorse;
import net.minecraft.server.v1_6_R3.ContainerMerchant;
import net.minecraft.server.v1_6_R3.ContainerWorkbench;
import net.minecraft.server.v1_6_R3.CrashReport;
import net.minecraft.server.v1_6_R3.CrashReportSystemDetails;
import net.minecraft.server.v1_6_R3.DamageSource;
import net.minecraft.server.v1_6_R3.Entity;
import net.minecraft.server.v1_6_R3.EntityArrow;
import net.minecraft.server.v1_6_R3.EntityDamageSource;
import net.minecraft.server.v1_6_R3.EntityHorse;
import net.minecraft.server.v1_6_R3.EntityHuman;
import net.minecraft.server.v1_6_R3.EntityLiving;
import net.minecraft.server.v1_6_R3.EntityMinecartHopper;
import net.minecraft.server.v1_6_R3.EntityPlayer;
import net.minecraft.server.v1_6_R3.EnumAnimation;
import net.minecraft.server.v1_6_R3.EnumBedResult;
import net.minecraft.server.v1_6_R3.EnumGamemode;
import net.minecraft.server.v1_6_R3.FoodMetaData;
import net.minecraft.server.v1_6_R3.ICrafting;
import net.minecraft.server.v1_6_R3.IInventory;
import net.minecraft.server.v1_6_R3.IMerchant;
import net.minecraft.server.v1_6_R3.IScoreboardCriteria;
import net.minecraft.server.v1_6_R3.InventoryMerchant;
import net.minecraft.server.v1_6_R3.Item;
import net.minecraft.server.v1_6_R3.ItemStack;
import net.minecraft.server.v1_6_R3.ItemWorldMapBase;
import net.minecraft.server.v1_6_R3.MathHelper;
import net.minecraft.server.v1_6_R3.MerchantRecipeList;
import net.minecraft.server.v1_6_R3.MinecraftServer;
import net.minecraft.server.v1_6_R3.MobEffect;
import net.minecraft.server.v1_6_R3.NBTTagCompound;
import net.minecraft.server.v1_6_R3.Packet;
import net.minecraft.server.v1_6_R3.Packet100OpenWindow;
import net.minecraft.server.v1_6_R3.Packet101CloseWindow;
import net.minecraft.server.v1_6_R3.Packet103SetSlot;
import net.minecraft.server.v1_6_R3.Packet104WindowItems;
import net.minecraft.server.v1_6_R3.Packet105CraftProgressBar;
import net.minecraft.server.v1_6_R3.Packet133OpenTileEntity;
import net.minecraft.server.v1_6_R3.Packet17EntityLocationAction;
import net.minecraft.server.v1_6_R3.Packet18ArmAnimation;
import net.minecraft.server.v1_6_R3.Packet200Statistic;
import net.minecraft.server.v1_6_R3.Packet202Abilities;
import net.minecraft.server.v1_6_R3.Packet204LocaleAndViewDistance;
import net.minecraft.server.v1_6_R3.Packet250CustomPayload;
import net.minecraft.server.v1_6_R3.Packet29DestroyEntity;
import net.minecraft.server.v1_6_R3.Packet38EntityStatus;
import net.minecraft.server.v1_6_R3.Packet39AttachEntity;
import net.minecraft.server.v1_6_R3.Packet3Chat;
import net.minecraft.server.v1_6_R3.Packet41MobEffect;
import net.minecraft.server.v1_6_R3.Packet42RemoveMobEffect;
import net.minecraft.server.v1_6_R3.Packet43SetExperience;
import net.minecraft.server.v1_6_R3.Packet56MapChunkBulk;
import net.minecraft.server.v1_6_R3.Packet70Bed;
import net.minecraft.server.v1_6_R3.Packet8UpdateHealth;
import net.minecraft.server.v1_6_R3.PlayerConnection;
import net.minecraft.server.v1_6_R3.PlayerInteractManager;
import net.minecraft.server.v1_6_R3.ReportedException;
import net.minecraft.server.v1_6_R3.ScoreboardScore;
import net.minecraft.server.v1_6_R3.SlotResult;
import net.minecraft.server.v1_6_R3.Statistic;
import net.minecraft.server.v1_6_R3.StatisticList;
import net.minecraft.server.v1_6_R3.TileEntity;
import net.minecraft.server.v1_6_R3.TileEntityBeacon;
import net.minecraft.server.v1_6_R3.TileEntityBrewingStand;
import net.minecraft.server.v1_6_R3.TileEntityDispenser;
import net.minecraft.server.v1_6_R3.TileEntityDropper;
import net.minecraft.server.v1_6_R3.TileEntityFurnace;
import net.minecraft.server.v1_6_R3.TileEntityHopper;
import net.minecraft.server.v1_6_R3.TileEntitySign;
import net.minecraft.server.v1_6_R3.World;
import net.minecraft.server.v1_6_R3.WorldServer;
import net.minecraft.util.com.google.common.collect.Sets;
import net.minecraft.util.com.mojang.authlib.GameProfile;
import net.minecraft.util.io.netty.buffer.Unpooled;
import net.minecraft.util.org.apache.commons.io.Charsets;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
// CraftBukkit start
import org.bukkit.Bukkit;
import org.bukkit.WeatherType;
import org.bukkit.craftbukkit.v1_6_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_6_R3.event.CraftEventFactory;
import org.bukkit.craftbukkit.v1_6_R3.inventory.CraftItemStack;
import org.bukkit.craftbukkit.v1_7_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_7_R1.event.CraftEventFactory;
import org.bukkit.craftbukkit.v1_7_R1.inventory.CraftItemStack;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
// CraftBukkit end
public class EntityPlayer extends EntityHuman implements ICrafting {
private static final Logger bM = LogManager.getLogger();
private String locale = "en_US";
public PlayerConnection playerConnection;
public MinecraftServer server;
public PlayerInteractManager playerInteractManager;
public final MinecraftServer server;
public final PlayerInteractManager playerInteractManager;
public double d;
public double e;
public final List chunkCoordIntPairQueue = new LinkedList();
public final List removeQueue = new LinkedList();
private float bO = Float.MIN_VALUE;
private float bP = -1.0E8F;
private int bQ = -99999999;
private boolean bR = true;
private final ServerStatisticManager bO;
private float bP = Float.MIN_VALUE;
private float bQ = -1.0E8F;
private int bR = -99999999;
private boolean bS = true;
public int lastSentExp = -99999999; // CraftBukkit - private -> public
public int invulnerableTicks = 60; // CraftBukkit - private -> public
private int bU;
private int bV;
private boolean bW = true;
private long bX = 0L;
private EnumChatVisibility bW;
private boolean bX = true;
private long bY = 0L;
private int containerCounter;
public boolean h;
public int ping;
@ -142,39 +63,40 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
public boolean keepLevel = false;
public double maxHealthCache;
// CraftBukkit end
public boolean spectating;
public EntityPlayer(MinecraftServer minecraftserver, World world, String s, PlayerInteractManager playerinteractmanager) {
super(world, s);
public boolean spectating; // Mineplex
public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, PlayerInteractManager playerinteractmanager) {
super(worldserver, gameprofile);
playerinteractmanager.player = this;
this.playerInteractManager = playerinteractmanager;
this.bU = minecraftserver.getPlayerList().o();
ChunkCoordinates chunkcoordinates = world.getSpawn();
this.bV = minecraftserver.getPlayerList().o();
ChunkCoordinates chunkcoordinates = worldserver.getSpawn();
int i = chunkcoordinates.x;
int j = chunkcoordinates.z;
int k = chunkcoordinates.y;
if (!world.worldProvider.g && world.getWorldData().getGameType() != EnumGamemode.ADVENTURE) {
if (!worldserver.worldProvider.g && worldserver.getWorldData().getGameType() != EnumGamemode.ADVENTURE) {
int l = Math.max(5, minecraftserver.getSpawnProtection() - 6);
i += this.random.nextInt(l * 2) - l;
j += this.random.nextInt(l * 2) - l;
k = world.i(i, j);
k = worldserver.i(i, j);
}
this.server = minecraftserver;
this.Y = 0.0F;
this.bO = minecraftserver.getPlayerList().i(this.getName());
this.X = 0.0F;
this.height = 0.0F;
this.setPositionRotation((double) i + 0.5D, (double) k, (double) j + 0.5D, 0.0F, 0.0F);
while (!world.getCubes(this, this.boundingBox).isEmpty()) {
while (!worldserver.getCubes(this, this.boundingBox).isEmpty()) {
this.setPosition(this.locX, this.locY + 1.0D, this.locZ);
}
// CraftBukkit start
this.displayName = this.name;
this.listName = this.name;
this.displayName = this.getName();
this.listName = this.getName();
// this.canPickUpLoot = true; TODO
this.maxHealthCache = this.getMaxHealth();
// CraftBukkit end
@ -182,7 +104,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
public void a(NBTTagCompound nbttagcompound) {
super.a(nbttagcompound);
if (nbttagcompound.hasKey("playerGameType")) {
if (nbttagcompound.hasKeyOfType("playerGameType", 99)) {
if (MinecraftServer.getServer().getForceGamemode()) {
this.playerInteractManager.setGameMode(MinecraftServer.getServer().getGamemode());
} else {
@ -232,7 +154,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
this.activeContainer.addSlotListener(this);
}
protected void d_() {
protected void e_() {
this.height = 0.0F;
}
@ -240,21 +162,19 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
return 1.62F;
}
public void l_() {
public void h() {
this.playerInteractManager.a();
--this.invulnerableTicks;
if (this.noDamageTicks > 0) {
--this.noDamageTicks;
}
this.activeContainer.b();
if (!this.world.isStatic && !this.activeContainer.a((EntityHuman) this)) {
this.closeInventory();
this.activeContainer = this.defaultContainer;
}
// CraftBukkit start
if (this.noDamageTicks > 0) {
--this.noDamageTicks;
}
// CraftBukkit end
while (!this.removeQueue.isEmpty()) {
int i = Math.min(this.removeQueue.size(), 127);
int[] aint = new int[i];
@ -266,7 +186,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
iterator.remove();
}
this.playerConnection.sendPacket(new Packet29DestroyEntity(aint));
this.playerConnection.sendPacket(new PacketPlayOutEntityDestroy(aint));
}
if (!this.chunkCoordIntPairQueue.isEmpty()) {
@ -274,21 +194,27 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
Iterator iterator1 = this.chunkCoordIntPairQueue.iterator();
ArrayList arraylist1 = new ArrayList();
while (iterator1.hasNext() && arraylist.size() < 5) {
Chunk chunk;
while (iterator1.hasNext() && arraylist.size() < PacketPlayOutMapChunkBulk.c()) {
ChunkCoordIntPair chunkcoordintpair = (ChunkCoordIntPair) iterator1.next();
iterator1.remove();
if (chunkcoordintpair != null && this.world.isLoaded(chunkcoordintpair.x << 4, 0, chunkcoordintpair.z << 4)) {
// CraftBukkit start - Get tile entities directly from the chunk instead of the world
Chunk chunk = this.world.getChunkAt(chunkcoordintpair.x, chunkcoordintpair.z);
arraylist.add(chunk);
arraylist1.addAll(chunk.tileEntities.values());
// CraftBukkit end
if (chunkcoordintpair != null) {
if (this.world.isLoaded(chunkcoordintpair.x << 4, 0, chunkcoordintpair.z << 4)) {
chunk = this.world.getChunkAt(chunkcoordintpair.x, chunkcoordintpair.z);
if (chunk.k()) {
arraylist.add(chunk);
arraylist1.addAll(chunk.tileEntities.values()); // CraftBukkit - Get tile entities directly from the chunk instead of the world
iterator1.remove();
}
}
} else {
iterator1.remove();
}
}
if (!arraylist.isEmpty()) {
this.playerConnection.sendPacket(new Packet56MapChunkBulk(arraylist));
this.playerConnection.sendPacket(new PacketPlayOutMapChunkBulk(arraylist));
Iterator iterator2 = arraylist1.iterator();
while (iterator2.hasNext()) {
@ -300,27 +226,26 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
iterator2 = arraylist.iterator();
while (iterator2.hasNext()) {
Chunk chunk = (Chunk) iterator2.next();
this.p().getTracker().a(this, chunk);
chunk = (Chunk) iterator2.next();
this.r().getTracker().a(this, chunk);
}
}
if (this.bX > 0L && this.server.ar() > 0 && MinecraftServer.aq() - this.bX > (long) (this.server.ar() * 1000 * 60)) {
this.playerConnection.disconnect("You have been idle for too long!");
}
}
if (this.bY > 0L && this.server.aq() > 0 && MinecraftServer.ap() - this.bY > (long) (this.server.aq() * 1000 * 60)) {
this.playerConnection.disconnect("You have been idle for too long!");
}
}
public void h() {
public void i() {
try {
super.l_();
super.h();
for (int i = 0; i < this.inventory.getSize(); ++i) {
ItemStack itemstack = this.inventory.getItem(i);
if (itemstack != null && Item.byId[itemstack.id].f() && this.playerConnection.lowPriorityCount() <= 5) {
Packet packet = ((ItemWorldMapBase) Item.byId[itemstack.id]).c(itemstack, this.world, this);
if (itemstack != null && itemstack.getItem().h()) {
Packet packet = ((ItemWorldMapBase) itemstack.getItem()).c(itemstack, this.world, this);
if (packet != null) {
this.playerConnection.sendPacket(packet);
@ -328,28 +253,33 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
}
}
if (this.getHealth() != this.bP || this.bQ != this.foodData.a() || this.foodData.e() == 0.0F != this.bR) {
// CraftBukkit - this.getHealth() -> this.getScaledHealth()
this.playerConnection.sendPacket(new Packet8UpdateHealth(getBukkitEntity().getScaledHealth(), this.foodData.a(), this.foodData.e()));
this.bP = this.getHealth();
this.bQ = this.foodData.a();
this.bR = this.foodData.e() == 0.0F;
// CraftBukkit - Optionally scale health
if (this.getHealth() != this.bQ || this.bR != this.foodData.a() || this.foodData.e() == 0.0F != this.bS) {
this.playerConnection.sendPacket(new PacketPlayOutUpdateHealth(this.getBukkitEntity().getScaledHealth(), this.foodData.a(), this.foodData.e()));
this.bQ = this.getHealth();
this.bR = this.foodData.a();
this.bS = this.foodData.e() == 0.0F;
}
if (this.getHealth() + this.bn() != this.bO) {
this.bO = this.getHealth() + this.bn();
if (this.getHealth() + this.bs() != this.bP) {
this.bP = this.getHealth() + this.bs();
// CraftBukkit - Update ALL the scores!
this.world.getServer().getScoreboardManager().updateAllScoresForList(IScoreboardCriteria.f, this.getLocalizedName(), com.google.common.collect.ImmutableList.of(this));
this.world.getServer().getScoreboardManager().updateAllScoresForList(IScoreboardCriteria.f, this.getName(), com.google.common.collect.ImmutableList.of(this));
}
// CraftBukkit start - Force max health updates
if (this.maxHealthCache != this.getMaxHealth()) {
this.getBukkitEntity().updateScaledHealth();
this.getBukkitEntity().updateScaledHealth();
}
// CraftBukkit end
if (this.expTotal != this.lastSentExp) {
this.lastSentExp = this.expTotal;
this.playerConnection.sendPacket(new Packet43SetExperience(this.exp, this.expTotal, this.expLevel));
this.playerConnection.sendPacket(new PacketPlayOutExperience(this.exp, this.expTotal, this.expLevel));
}
if (this.ticksLived % 20 * 5 == 0 && !this.x().a(AchievementList.L)) {
this.j();
}
// CraftBukkit start
@ -371,6 +301,46 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
}
}
protected void j() {
BiomeBase biomebase = this.world.getBiome(MathHelper.floor(this.locX), MathHelper.floor(this.locZ));
if (biomebase != null) {
String s = biomebase.af;
AchievementSet achievementset = (AchievementSet) this.x().b((Statistic) AchievementList.L); // CraftBukkit - fix decompile error
if (achievementset == null) {
achievementset = (AchievementSet) this.x().a(AchievementList.L, new AchievementSet());
}
achievementset.add(s);
if (this.x().b(AchievementList.L) && achievementset.size() == BiomeBase.n.size()) {
HashSet hashset = Sets.newHashSet(BiomeBase.n);
Iterator iterator = achievementset.iterator();
while (iterator.hasNext()) {
String s1 = (String) iterator.next();
Iterator iterator1 = hashset.iterator();
while (iterator1.hasNext()) {
BiomeBase biomebase1 = (BiomeBase) iterator1.next();
if (biomebase1.af.equals(s1)) {
iterator1.remove();
}
}
if (hashset.isEmpty()) {
break;
}
}
if (hashset.isEmpty()) {
this.a((Statistic) AchievementList.L);
}
}
}
}
public void die(DamageSource damagesource) {
// CraftBukkit start
if (this.dead) {
@ -394,22 +364,22 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
}
}
ChatMessage chatmessage = this.aR().b();
IChatBaseComponent chatmessage = this.aW().b();
String deathmessage = chatmessage.toString();
String deathmessage = chatmessage.c();
org.bukkit.event.entity.PlayerDeathEvent event = CraftEventFactory.callPlayerDeathEvent(this, loot, deathmessage);
String deathMessage = event.getDeathMessage();
if (deathMessage != null && deathMessage.length() > 0) {
if (deathMessage.equals(chatmessage.toString())) {
if (deathMessage.equals(deathmessage)) {
this.server.getPlayerList().sendMessage(chatmessage);
} else {
this.server.getPlayerList().sendMessage(ChatMessage.d(event.getDeathMessage()));
this.server.getPlayerList().sendMessage(org.bukkit.craftbukkit.v1_7_R1.util.CraftChatMessage.fromString(deathMessage));
}
}
// CraftBukkit - we clean the player's inventory after the EntityDeathEvent is called so plugins can get the exact state of the inventory.
// we clean the player's inventory after the EntityDeathEvent is called so plugins can get the exact state of the inventory.
if (!keepInventory) {
for (int i = 0; i < this.inventory.items.length; ++i) {
this.inventory.items[i] = null;
@ -424,7 +394,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
// CraftBukkit end
// CraftBukkit - Get our scores instead
Collection<ScoreboardScore> collection = this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.c, this.getLocalizedName(), new java.util.ArrayList<ScoreboardScore>());
Collection<ScoreboardScore> collection = this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.c, this.getName(), new java.util.ArrayList<ScoreboardScore>());
Iterator iterator = collection.iterator();
while (iterator.hasNext()) {
@ -433,13 +403,20 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
scoreboardscore.incrementScore();
}
EntityLiving entityliving = this.aS();
EntityLiving entityliving = this.aX();
if (entityliving != null) {
int i = EntityTypes.a(entityliving);
MonsterEggInfo monsteregginfo = (MonsterEggInfo) EntityTypes.a.get(Integer.valueOf(i));
if (monsteregginfo != null) {
this.a(monsteregginfo.e, 1);
}
entityliving.b(this, this.bb);
}
this.a(StatisticList.y, 1);
this.a(StatisticList.v, 1);
}
public boolean damageEntity(DamageSource damagesource, float f) {
@ -480,13 +457,13 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
public void b(int i) {
if (this.dimension == 1 && i == 1) {
this.a((Statistic) AchievementList.C);
this.a((Statistic) AchievementList.D);
this.world.kill(this);
this.viewingCredits = true;
this.playerConnection.sendPacket(new Packet70Bed(4, 0));
this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(4, 0.0F));
} else {
if (this.dimension == 0 && i == 1) {
this.a((Statistic) AchievementList.B);
this.a((Statistic) AchievementList.C);
// CraftBukkit start - Rely on custom portal management
/*
ChunkCoordinates chunkcoordinates = this.server.getWorldServer(i).getDimensionSpawn();
@ -499,21 +476,20 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
*/
// CraftBukkit end
} else {
this.a((Statistic) AchievementList.x);
this.a((Statistic) AchievementList.y);
}
// CraftBukkit start
TeleportCause cause = (this.dimension == 1 || i == 1) ? TeleportCause.END_PORTAL : TeleportCause.NETHER_PORTAL;
if (dimension == -1 && i == 0)
i = 4;
this.server.getPlayerList().changeDimension(this, i, cause);
// CraftBukkit end
this.lastSentExp = -1;
this.bP = -1.0F;
this.bQ = -1;
this.bQ = -1.0F;
this.bR = -1;
}
}
@ -536,11 +512,11 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
EnumBedResult enumbedresult = super.a(i, j, k);
if (enumbedresult == EnumBedResult.OK) {
Packet17EntityLocationAction packet17entitylocationaction = new Packet17EntityLocationAction(this, 0, i, j, k);
PacketPlayOutBed packetplayoutbed = new PacketPlayOutBed(this, i, j, k);
this.p().getTracker().a((Entity) this, (Packet) packet17entitylocationaction);
this.r().getTracker().a((Entity) this, (Packet) packetplayoutbed);
this.playerConnection.a(this.locX, this.locY, this.locZ, this.yaw, this.pitch);
this.playerConnection.sendPacket(packet17entitylocationaction);
this.playerConnection.sendPacket(packetplayoutbed);
}
return enumbedresult;
@ -550,7 +526,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
if (this.fauxSleeping && !this.sleeping) return; // CraftBukkit - Can't leave bed if not in one!
if (this.isSleeping()) {
this.p().getTracker().sendPacketToEntity(this, new Packet18ArmAnimation(this, 3));
this.r().getTracker().sendPacketToEntity(this, new PacketPlayOutAnimation(this, 2));
}
super.a(flag, flag1, flag2);
@ -567,16 +543,16 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
public void setPassengerOf(Entity entity) {
// mount(null) doesn't really fly for overloaded methods,
// so this method is needed
Entity currentVehicle = this.vehicle;
Entity currentVehicle = this.vehicle;
super.setPassengerOf(entity);
// CraftBukkit end
// Check if the vehicle actually changed.
// Check if the vehicle actually changed.
if (currentVehicle != this.vehicle) {
this.playerConnection.sendPacket(new Packet39AttachEntity(0, this, this.vehicle));
this.playerConnection.sendPacket(new PacketPlayOutAttachEntity(0, this, this.vehicle));
this.playerConnection.a(this.locX, this.locY, this.locZ, this.yaw, this.pitch);
}
// CraftBukkit end
}
protected void a(double d0, boolean flag) {}
@ -584,12 +560,12 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
public void b(double d0, boolean flag) {
super.a(d0, flag);
}
public void a(TileEntity tileentity) {
if (tileentity instanceof TileEntitySign) {
((TileEntitySign) tileentity).a((EntityHuman)this);
this.playerConnection.sendPacket(new Packet133OpenTileEntity(0, tileentity.x, tileentity.y, tileentity.z));
}
if (tileentity instanceof TileEntitySign) {
((TileEntitySign) tileentity).a((EntityHuman) this);
this.playerConnection.sendPacket(new PacketPlayOutOpenSignEditor(tileentity.x, tileentity.y, tileentity.z));
}
}
public int nextContainerCounter() { // CraftBukkit - private void -> public int
@ -604,7 +580,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
// CraftBukkit end
this.nextContainerCounter();
this.playerConnection.sendPacket(new Packet100OpenWindow(this.containerCounter, 1, "Crafting", 9, true));
this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, 1, "Crafting", 9, true));
this.activeContainer = container; // CraftBukkit - Use container we passed to event
this.activeContainer.windowId = this.containerCounter;
this.activeContainer.addSlotListener(this);
@ -617,7 +593,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
// CraftBukkit end
this.nextContainerCounter();
this.playerConnection.sendPacket(new Packet100OpenWindow(this.containerCounter, 4, s == null ? "" : s, 9, s != null));
this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, 4, s == null ? "" : s, 9, s != null));
this.activeContainer = container; // CraftBukkit - Use container we passed to event
this.activeContainer.windowId = this.containerCounter;
this.activeContainer.addSlotListener(this);
@ -630,7 +606,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
// CraftBukkit end
this.nextContainerCounter();
this.playerConnection.sendPacket(new Packet100OpenWindow(this.containerCounter, 8, "Repairing", 9, true));
this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, 8, "Repairing", 9, true));
this.activeContainer = container; // CraftBukkit - Use container we passed to event
this.activeContainer.windowId = this.containerCounter;
this.activeContainer.addSlotListener(this);
@ -647,7 +623,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
// CraftBukkit end
this.nextContainerCounter();
this.playerConnection.sendPacket(new Packet100OpenWindow(this.containerCounter, 0, iinventory.getName(), iinventory.getSize(), iinventory.c()));
this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, 0, iinventory.getInventoryName(), iinventory.getSize(), iinventory.k_()));
this.activeContainer = container; // CraftBukkit - Use container we passed to event
this.activeContainer.windowId = this.containerCounter;
this.activeContainer.addSlotListener(this);
@ -660,7 +636,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
// CraftBukkit end
this.nextContainerCounter();
this.playerConnection.sendPacket(new Packet100OpenWindow(this.containerCounter, 9, tileentityhopper.getName(), tileentityhopper.getSize(), tileentityhopper.c()));
this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, 9, tileentityhopper.getInventoryName(), tileentityhopper.getSize(), tileentityhopper.k_()));
this.activeContainer = container; // CraftBukkit - Use container we passed to event
this.activeContainer.windowId = this.containerCounter;
this.activeContainer.addSlotListener(this);
@ -673,7 +649,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
// CraftBukkit end
this.nextContainerCounter();
this.playerConnection.sendPacket(new Packet100OpenWindow(this.containerCounter, 9, entityminecarthopper.getName(), entityminecarthopper.getSize(), entityminecarthopper.c()));
this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, 9, entityminecarthopper.getInventoryName(), entityminecarthopper.getSize(), entityminecarthopper.k_()));
this.activeContainer = container; // CraftBukkit - Use container we passed to event
this.activeContainer.windowId = this.containerCounter;
this.activeContainer.addSlotListener(this);
@ -686,7 +662,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
// CraftBukkit end
this.nextContainerCounter();
this.playerConnection.sendPacket(new Packet100OpenWindow(this.containerCounter, 2, tileentityfurnace.getName(), tileentityfurnace.getSize(), tileentityfurnace.c()));
this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, 2, tileentityfurnace.getInventoryName(), tileentityfurnace.getSize(), tileentityfurnace.k_()));
this.activeContainer = container; // CraftBukkit - Use container we passed to event
this.activeContainer.windowId = this.containerCounter;
this.activeContainer.addSlotListener(this);
@ -699,7 +675,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
// CraftBukkit end
this.nextContainerCounter();
this.playerConnection.sendPacket(new Packet100OpenWindow(this.containerCounter, tileentitydispenser instanceof TileEntityDropper ? 10 : 3, tileentitydispenser.getName(), tileentitydispenser.getSize(), tileentitydispenser.c()));
this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, tileentitydispenser instanceof TileEntityDropper ? 10 : 3, tileentitydispenser.getInventoryName(), tileentitydispenser.getSize(), tileentitydispenser.k_()));
this.activeContainer = container; // CraftBukkit - Use container we passed to event
this.activeContainer.windowId = this.containerCounter;
this.activeContainer.addSlotListener(this);
@ -712,7 +688,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
// CraftBukkit end
this.nextContainerCounter();
this.playerConnection.sendPacket(new Packet100OpenWindow(this.containerCounter, 5, tileentitybrewingstand.getName(), tileentitybrewingstand.getSize(), tileentitybrewingstand.c()));
this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, 5, tileentitybrewingstand.getInventoryName(), tileentitybrewingstand.getSize(), tileentitybrewingstand.k_()));
this.activeContainer = container; // CraftBukkit - Use container we passed to event
this.activeContainer.windowId = this.containerCounter;
this.activeContainer.addSlotListener(this);
@ -725,7 +701,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
// CraftBukkit end
this.nextContainerCounter();
this.playerConnection.sendPacket(new Packet100OpenWindow(this.containerCounter, 7, tileentitybeacon.getName(), tileentitybeacon.getSize(), tileentitybeacon.c()));
this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, 7, tileentitybeacon.getInventoryName(), tileentitybeacon.getSize(), tileentitybeacon.k_()));
this.activeContainer = container; // CraftBukkit - Use container we passed to event
this.activeContainer.windowId = this.containerCounter;
this.activeContainer.addSlotListener(this);
@ -743,19 +719,18 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
this.activeContainer.addSlotListener(this);
InventoryMerchant inventorymerchant = ((ContainerMerchant) this.activeContainer).getMerchantInventory();
this.playerConnection.sendPacket(new Packet100OpenWindow(this.containerCounter, 6, s == null ? "" : s, inventorymerchant.getSize(), s != null));
this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, 6, s == null ? "" : s, inventorymerchant.getSize(), s != null));
MerchantRecipeList merchantrecipelist = imerchant.getOffers(this);
if (merchantrecipelist != null) {
try {
ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream();
DataOutputStream dataoutputstream = new DataOutputStream(bytearrayoutputstream);
PacketDataSerializer packetdataserializer = new PacketDataSerializer(Unpooled.buffer());
dataoutputstream.writeInt(this.containerCounter);
merchantrecipelist.a(dataoutputstream);
this.playerConnection.sendPacket(new Packet250CustomPayload("MC|TrList", bytearrayoutputstream.toByteArray()));
} catch (IOException ioexception) {
ioexception.printStackTrace();
packetdataserializer.writeInt(this.containerCounter);
merchantrecipelist.a(packetdataserializer);
this.playerConnection.sendPacket(new PacketPlayOutCustomPayload("MC|TrList", packetdataserializer));
} catch (Exception ioexception) { // CraftBukkit - IOException -> Exception
bM.error("Couldn\'t send trade list", ioexception);
}
}
}
@ -771,7 +746,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
}
this.nextContainerCounter();
this.playerConnection.sendPacket(new Packet100OpenWindow(this.containerCounter, 11, iinventory.getName(), iinventory.getSize(), iinventory.c(), entityhorse.id));
this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, 11, iinventory.getInventoryName(), iinventory.getSize(), iinventory.k_(), entityhorse.getId()));
this.activeContainer = container; // CraftBukkit - Use container we passed to event
this.activeContainer.windowId = this.containerCounter;
this.activeContainer.addSlotListener(this);
@ -780,7 +755,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
public void a(Container container, int i, ItemStack itemstack) {
if (!(container.getSlot(i) instanceof SlotResult)) {
if (!this.h) {
this.playerConnection.sendPacket(new Packet103SetSlot(container.windowId, i, itemstack));
this.playerConnection.sendPacket(new PacketPlayOutSetSlot(container.windowId, i, itemstack));
}
}
}
@ -790,32 +765,32 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
}
public void a(Container container, List list) {
this.playerConnection.sendPacket(new Packet104WindowItems(container.windowId, list));
this.playerConnection.sendPacket(new Packet103SetSlot(-1, -1, this.inventory.getCarried()));
this.playerConnection.sendPacket(new PacketPlayOutWindowItems(container.windowId, list));
this.playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, this.inventory.getCarried()));
// CraftBukkit start - Send a Set Slot to update the crafting result slot
if (java.util.EnumSet.of(InventoryType.CRAFTING,InventoryType.WORKBENCH).contains(container.getBukkitView().getType())) {
this.playerConnection.sendPacket(new Packet103SetSlot(container.windowId, 0, container.getSlot(0).getItem()));
this.playerConnection.sendPacket(new PacketPlayOutSetSlot(container.windowId, 0, container.getSlot(0).getItem()));
}
// CraftBukkit end
}
public void setContainerData(Container container, int i, int j) {
this.playerConnection.sendPacket(new Packet105CraftProgressBar(container.windowId, i, j));
this.playerConnection.sendPacket(new PacketPlayOutCraftProgressBar(container.windowId, i, j));
}
public void closeInventory() {
CraftEventFactory.handleInventoryCloseEvent(this); // CraftBukkit
this.playerConnection.sendPacket(new Packet101CloseWindow(this.activeContainer.windowId));
this.k();
this.playerConnection.sendPacket(new PacketPlayOutCloseWindow(this.activeContainer.windowId));
this.m();
}
public void broadcastCarriedItem() {
if (!this.h) {
this.playerConnection.sendPacket(new Packet103SetSlot(-1, -1, this.inventory.getCarried()));
this.playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, this.inventory.getCarried()));
}
}
public void k() {
public void m() {
this.activeContainer.b((EntityHuman) this);
this.activeContainer = this.defaultContainer;
}
@ -837,13 +812,22 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
public void a(Statistic statistic, int i) {
if (statistic != null) {
if (!statistic.f) {
this.playerConnection.sendPacket(new Packet200Statistic(statistic.e, i));
this.bO.b(this, statistic, i);
Iterator iterator = this.getScoreboard().getObjectivesForCriteria(statistic.k()).iterator();
while (iterator.hasNext()) {
ScoreboardObjective scoreboardobjective = (ScoreboardObjective) iterator.next();
this.getScoreboard().getPlayerScoreForObjective(this.getName(), scoreboardobjective).incrementScore();
}
if (this.bO.e()) {
this.bO.a(this);
}
}
}
public void l() {
public void n() {
if (this.passenger != null) {
this.passenger.mount(this);
}
@ -854,53 +838,53 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
}
@Override
public boolean L()
public boolean R()
{
return !spectating;
}
public void triggerHealthUpdate() {
this.bP = -1.0E8F;
this.bQ = -1.0E8F;
this.lastSentExp = -1; // CraftBukkit - Added to reset
}
public void a(String s) {
this.playerConnection.sendPacket(new Packet3Chat(ChatMessage.e(s)));
public void b(IChatBaseComponent ichatbasecomponent) {
this.playerConnection.sendPacket(new PacketPlayOutChat(ichatbasecomponent));
}
protected void n() {
this.playerConnection.sendPacket(new Packet38EntityStatus(this.id, (byte) 9));
super.n();
protected void p() {
this.playerConnection.sendPacket(new PacketPlayOutEntityStatus(this, (byte) 9));
super.p();
}
public void a(ItemStack itemstack, int i) {
super.a(itemstack, i);
if (itemstack != null && itemstack.getItem() != null && itemstack.getItem().c_(itemstack) == EnumAnimation.EAT) {
this.p().getTracker().sendPacketToEntity(this, new Packet18ArmAnimation(this, 5));
if (itemstack != null && itemstack.getItem() != null && itemstack.getItem().d(itemstack) == EnumAnimation.EAT) {
this.r().getTracker().sendPacketToEntity(this, new PacketPlayOutAnimation(this, 3));
}
}
public void copyTo(EntityHuman entityhuman, boolean flag) {
super.copyTo(entityhuman, flag);
this.lastSentExp = -1;
this.bP = -1.0F;
this.bQ = -1;
this.bQ = -1.0F;
this.bR = -1;
this.removeQueue.addAll(((EntityPlayer) entityhuman).removeQueue);
}
protected void a(MobEffect mobeffect) {
super.a(mobeffect);
this.playerConnection.sendPacket(new Packet41MobEffect(this.id, mobeffect));
this.playerConnection.sendPacket(new PacketPlayOutEntityEffect(this.getId(), mobeffect));
}
protected void a(MobEffect mobeffect, boolean flag) {
super.a(mobeffect, flag);
this.playerConnection.sendPacket(new Packet41MobEffect(this.id, mobeffect));
this.playerConnection.sendPacket(new PacketPlayOutEntityEffect(this.getId(), mobeffect));
}
protected void b(MobEffect mobeffect) {
super.b(mobeffect);
this.playerConnection.sendPacket(new Packet42RemoveMobEffect(this.id, mobeffect));
this.playerConnection.sendPacket(new PacketPlayOutRemoveEntityEffect(this.getId(), mobeffect));
}
public void enderTeleportTo(double d0, double d1, double d2) {
@ -908,37 +892,45 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
}
public void b(Entity entity) {
this.p().getTracker().sendPacketToEntity(this, new Packet18ArmAnimation(entity, 6));
this.r().getTracker().sendPacketToEntity(this, new PacketPlayOutAnimation(entity, 4));
}
public void c(Entity entity) {
this.p().getTracker().sendPacketToEntity(this, new Packet18ArmAnimation(entity, 7));
this.r().getTracker().sendPacketToEntity(this, new PacketPlayOutAnimation(entity, 5));
}
public void updateAbilities() {
if (this.playerConnection != null) {
this.playerConnection.sendPacket(new Packet202Abilities(this.abilities));
this.playerConnection.sendPacket(new PacketPlayOutAbilities(this.abilities));
}
}
public WorldServer p() {
public WorldServer r() {
return (WorldServer) this.world;
}
public void a(EnumGamemode enumgamemode) {
this.playerInteractManager.setGameMode(enumgamemode);
this.playerConnection.sendPacket(new Packet70Bed(3, enumgamemode.a()));
this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(3, (float) enumgamemode.a()));
}
public void sendMessage(ChatMessage chatmessage) {
this.playerConnection.sendPacket(new Packet3Chat(chatmessage));
// CraftBukkit start - Support multi-line messages
public void sendMessage(IChatBaseComponent[] ichatbasecomponent) {
for (IChatBaseComponent component : ichatbasecomponent) {
this.sendMessage(component);
}
}
// CraftBukkit end
public void sendMessage(IChatBaseComponent ichatbasecomponent) {
this.playerConnection.sendPacket(new PacketPlayOutChat(ichatbasecomponent));
}
public boolean a(int i, String s) {
return "seed".equals(s) && !this.server.V() ? true : (!"tell".equals(s) && !"help".equals(s) && !"me".equals(s) ? (this.server.getPlayerList().isOp(this.name) ? this.server.k() >= i : false) : true);
return "seed".equals(s) && !this.server.V() ? true : (!"tell".equals(s) && !"help".equals(s) && !"me".equals(s) ? (this.server.getPlayerList().isOp(this.getName()) ? this.server.l() >= i : false) : true);
}
public String q() {
public String s() {
String s = this.playerConnection.networkManager.getSocketAddress().toString();
s = s.substring(s.indexOf("/") + 1);
@ -946,41 +938,43 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
return s;
}
public void a(Packet204LocaleAndViewDistance packet204localeandviewdistance) {
this.locale = packet204localeandviewdistance.d();
int i = 256 >> packet204localeandviewdistance.f();
public void a(PacketPlayInSettings packetplayinsettings) {
this.locale = packetplayinsettings.c();
int i = 256 >> packetplayinsettings.d();
if (i > 3 && i < 15) {
this.bU = i;
this.bV = i;
}
this.bV = packet204localeandviewdistance.g();
this.bW = packet204localeandviewdistance.h();
if (this.server.K() && this.server.J().equals(this.name)) {
this.server.c(packet204localeandviewdistance.i());
this.bW = packetplayinsettings.e();
this.bX = packetplayinsettings.f();
if (this.server.L() && this.server.K().equals(this.getName())) {
this.server.a(packetplayinsettings.g());
}
this.b(1, !packet204localeandviewdistance.j());
this.b(1, !packetplayinsettings.h());
}
public int getChatFlags() {
return this.bV;
public EnumChatVisibility getChatFlags() {
return this.bW;
}
public void a(String s, int i) {
String s1 = s + "\0" + i; // CraftBukkit - fix decompile error
this.playerConnection.sendPacket(new Packet250CustomPayload("MC|TPack", s1.getBytes()));
public void a(String s) {
this.playerConnection.sendPacket(new PacketPlayOutCustomPayload("MC|RPack", s.getBytes(Charsets.UTF_8)));
}
public ChunkCoordinates b() {
public ChunkCoordinates getChunkCoordinates() {
return new ChunkCoordinates(MathHelper.floor(this.locX), MathHelper.floor(this.locY + 0.5D), MathHelper.floor(this.locZ));
}
public void u() {
this.bX = MinecraftServer.aq();
public void w() {
this.bY = MinecraftServer.ap();
}
public ServerStatisticManager x() {
return this.bO;
}
// CraftBukkit start
public long timeOffset = 0;
public boolean relativeTime = true;
@ -1010,7 +1004,13 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
this.weather = type;
}
this.playerConnection.sendPacket(new Packet70Bed(type == WeatherType.DOWNFALL ? 1 : 2, 0));
if (type == WeatherType.DOWNFALL) {
this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(2, 0));
// this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(7, this.world.j(1.0F)));
// this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(8, this.world.h(1.0F)));
} else {
this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(1, 0));
}
}
public void resetPlayerWeather() {
@ -1020,7 +1020,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
@Override
public String toString() {
return super.toString() + "(" + this.name + " at " + this.locX + "," + this.locY + "," + this.locZ + ")";
return super.toString() + "(" + this.getName() + " at " + this.locX + "," + this.locY + "," + this.locZ + ")";
}
public void reset() {
@ -1036,12 +1036,12 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
this.setHealth(this.getMaxHealth());
this.fireTicks = 0;
this.fallDistance = 0;
this.foodData = new FoodMetaData();
this.foodData = new FoodMetaData(this);
this.expLevel = this.newLevel;
this.expTotal = this.newTotalExp;
this.exp = 0;
this.deathTicks = 0;
this.aJ();
this.aP(); // Should be remapped: removeAllEffects should be remapped to this.
this.updateEffects = true;
this.activeContainer = this.defaultContainer;
this.killer = null;

View File

@ -1,23 +1,8 @@
package net.minecraft.server.v1_6_R3;
package net.minecraft.server.v1_7_R1;
// CraftBukkit start
import net.minecraft.server.v1_6_R3.BiomeBase;
import net.minecraft.server.v1_6_R3.Chunk;
import net.minecraft.server.v1_6_R3.DamageSource;
import net.minecraft.server.v1_6_R3.Entity;
import net.minecraft.server.v1_6_R3.EntityHuman;
import net.minecraft.server.v1_6_R3.EntityInsentient;
import net.minecraft.server.v1_6_R3.EntitySlime;
import net.minecraft.server.v1_6_R3.GenericAttributes;
import net.minecraft.server.v1_6_R3.IMonster;
import net.minecraft.server.v1_6_R3.Item;
import net.minecraft.server.v1_6_R3.MathHelper;
import net.minecraft.server.v1_6_R3.NBTTagCompound;
import net.minecraft.server.v1_6_R3.World;
import net.minecraft.server.v1_6_R3.WorldType;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_6_R3.event.CraftEventFactory;
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_7_R1.event.CraftEventFactory;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.entity.SlimeSplitEvent;
// CraftBukkit end
@ -39,8 +24,8 @@ public class EntitySlime extends EntityInsentient implements IMonster {
this.setSize(i);
}
protected void a() {
super.a();
protected void c() {
super.c();
this.datawatcher.a(16, new Byte((byte) 1));
}
@ -68,16 +53,16 @@ public class EntitySlime extends EntityInsentient implements IMonster {
this.setSize(nbttagcompound.getInt("Size") + 1);
}
protected String bJ() {
protected String bN() {
return "slime";
}
protected String bP() {
protected String bT() {
return "mob.slime." + (this.getSize() > 1 ? "big" : "small");
}
public void l_() {
if (!this.world.isStatic && this.world.difficulty == 0 && this.getSize() > 0) {
public void h() {
if (!this.world.isStatic && this.world.difficulty == EnumDifficulty.PEACEFUL && this.getSize() > 0) {
this.dead = true;
}
@ -85,7 +70,7 @@ public class EntitySlime extends EntityInsentient implements IMonster {
this.j = this.i;
boolean flag = this.onGround;
super.l_();
super.h();
int i;
if (this.onGround && !flag) {
@ -97,11 +82,11 @@ public class EntitySlime extends EntityInsentient implements IMonster {
float f2 = MathHelper.sin(f) * (float) i * 0.5F * f1;
float f3 = MathHelper.cos(f) * (float) i * 0.5F * f1;
this.world.addParticle(this.bJ(), this.locX + (double) f2, this.boundingBox.b, this.locZ + (double) f3, 0.0D, 0.0D, 0.0D);
this.world.addParticle(this.bN(), this.locX + (double) f2, this.boundingBox.b, this.locZ + (double) f3, 0.0D, 0.0D, 0.0D);
}
if (this.bQ()) {
this.makeSound(this.bP(), this.ba(), ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) / 0.8F);
if (this.bU()) {
this.makeSound(this.bT(), this.bf(), ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) / 0.8F);
}
this.h = -0.5F;
@ -109,15 +94,15 @@ public class EntitySlime extends EntityInsentient implements IMonster {
this.h = 1.0F;
}
this.bM();
this.bQ();
if (this.world.isStatic) {
i = this.getSize();
this.a(0.6F * (float) i, 0.6F * (float) i);
}
}
protected void bl() {
this.u();
protected void bq() {
this.w();
if (Vegetated)
return;
@ -144,14 +129,14 @@ public class EntitySlime extends EntityInsentient implements IMonster {
}
if (this.onGround && this.jumpDelay-- <= 0) {
this.jumpDelay = this.bL();
this.jumpDelay = this.bP();
if (entityhuman != null) {
this.jumpDelay /= 3;
}
this.bd = true;
if (this.bS()) {
this.makeSound(this.bP(), this.ba(), ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) * 0.8F);
if (this.bW()) {
this.makeSound(this.bT(), this.bf(), ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) * 0.8F);
}
this.be = 1.0F - this.random.nextFloat() * 2.0F;
@ -164,15 +149,15 @@ public class EntitySlime extends EntityInsentient implements IMonster {
}
}
protected void bM() {
protected void bQ() {
this.h *= 0.6F;
}
protected int bL() {
protected int bP() {
return this.random.nextInt(20) + 10;
}
protected EntitySlime bK() {
protected EntitySlime bO() {
return new EntitySlime(this.world);
}
@ -197,7 +182,7 @@ public class EntitySlime extends EntityInsentient implements IMonster {
for (int k = 0; k < j; ++k) {
float f = ((float) (k % 2) - 0.5F) * (float) i / 4.0F;
float f1 = ((float) (k / 2) - 0.5F) * (float) i / 4.0F;
EntitySlime entityslime = this.bK();
EntitySlime entityslime = this.bO();
entityslime.setSize(i / 2);
entityslime.setPositionRotation(this.locX + (double) f, this.locY + 0.5D, this.locZ + (double) f1, this.random.nextFloat() * 360.0F, 0.0F);
@ -209,33 +194,33 @@ public class EntitySlime extends EntityInsentient implements IMonster {
}
public void b_(EntityHuman entityhuman) {
if (this.bN()) {
if (this.bR()) {
int i = this.getSize();
if (this.o(entityhuman) && this.e(entityhuman) < 0.6D * (double) i * 0.6D * (double) i && entityhuman.damageEntity(DamageSource.mobAttack(this), (float) this.bO())) {
if (this.o(entityhuman) && this.e(entityhuman) < 0.6D * (double) i * 0.6D * (double) i && entityhuman.damageEntity(DamageSource.mobAttack(this), (float) this.bS())) {
this.makeSound("mob.attack", 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
}
}
}
protected boolean bN() {
protected boolean bR() {
return this.getSize() > 1;
}
protected int bO() {
protected int bS() {
return this.getSize();
}
protected String aO() {
protected String aT() {
return "mob.slime." + (this.getSize() > 1 ? "big" : "small");
}
protected String aP() {
protected String aU() {
return "mob.slime." + (this.getSize() > 1 ? "big" : "small");
}
protected int getLootId() {
return this.getSize() == 1 ? Item.SLIME_BALL.id : 0;
protected Item getLoot() {
return this.getSize() == 1 ? Items.SLIME_BALL : Item.d(0);
}
public boolean canSpawn() {
@ -244,7 +229,7 @@ public class EntitySlime extends EntityInsentient implements IMonster {
if (this.world.getWorldData().getType() == WorldType.FLAT && this.random.nextInt(4) != 1) {
return false;
} else {
if (this.getSize() == 1 || this.world.difficulty > 0) {
if (this.getSize() == 1 || this.world.difficulty != EnumDifficulty.PEACEFUL) {
BiomeBase biomebase = this.world.getBiome(MathHelper.floor(this.locX), MathHelper.floor(this.locZ));
if (biomebase == BiomeBase.SWAMPLAND && this.locY > 50.0D && this.locY < 70.0D && this.random.nextFloat() < 0.5F && this.random.nextFloat() < this.world.x() && this.world.getLightLevel(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)) <= this.random.nextInt(8)) {
@ -260,19 +245,19 @@ public class EntitySlime extends EntityInsentient implements IMonster {
}
}
protected float ba() {
protected float bf() {
return 0.4F * (float) this.getSize();
}
public int bp() {
public int x() {
return 0;
}
protected boolean bS() {
protected boolean bW() {
return this.getSize() > 0;
}
protected boolean bQ() {
protected boolean bU() {
return this.getSize() > 2;
}
}

View File

@ -0,0 +1,100 @@
package net.minecraft.server.v1_7_R1;
import org.bukkit.event.entity.ExplosionPrimeEvent; // CraftBukkit
public class EntityTNTPrimed extends Entity {
public int fuseTicks;
private EntityLiving source;
public float yield = 4; // CraftBukkit
public boolean isIncendiary = false; // CraftBukkit
public boolean spectating = false;
public EntityTNTPrimed(World world) {
super(world);
this.l = true;
this.a(0.98F, 0.98F);
this.height = this.length / 2.0F;
}
public EntityTNTPrimed(World world, double d0, double d1, double d2, EntityLiving entityliving) {
this(world);
this.setPosition(d0, d1, d2);
float f = (float) (Math.random() * 3.1415927410125732D * 2.0D);
this.motX = (double) (-((float) Math.sin((double) f)) * 0.02F);
this.motY = 0.20000000298023224D;
this.motZ = (double) (-((float) Math.cos((double) f)) * 0.02F);
this.fuseTicks = 80;
this.lastX = d0;
this.lastY = d1;
this.lastZ = d2;
this.source = entityliving;
}
protected void c() {}
protected boolean g_() {
return false;
}
public boolean R() {
return !this.dead && !spectating;
}
public void h() {
this.lastX = this.locX;
this.lastY = this.locY;
this.lastZ = this.locZ;
this.motY -= 0.03999999910593033D;
this.move(this.motX, this.motY, this.motZ);
this.motX *= 0.9800000190734863D;
this.motY *= 0.9800000190734863D;
this.motZ *= 0.9800000190734863D;
if (this.onGround) {
this.motX *= 0.699999988079071D;
this.motZ *= 0.699999988079071D;
this.motY *= -0.5D;
}
if (this.fuseTicks-- <= 0) {
// CraftBukkit start - Need to reverse the order of the explosion and the entity death so we have a location for the event
if (!this.world.isStatic) {
this.explode();
}
this.die();
// CraftBukkit end
} else {
this.world.addParticle("smoke", this.locX, this.locY + 0.5D, this.locZ, 0.0D, 0.0D, 0.0D);
}
}
private void explode() {
// CraftBukkit start
// float f = 4.0F;
org.bukkit.craftbukkit.v1_7_R1.CraftServer server = this.world.getServer();
ExplosionPrimeEvent event = new ExplosionPrimeEvent((org.bukkit.entity.Explosive) org.bukkit.craftbukkit.v1_7_R1.entity.CraftEntity.getEntity(server, this));
server.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
// give 'this' instead of (Entity) null so we know what causes the damage
this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire(), true);
}
// CraftBukkit end
}
protected void b(NBTTagCompound nbttagcompound) {
nbttagcompound.setByte("Fuse", (byte) this.fuseTicks);
}
protected void a(NBTTagCompound nbttagcompound) {
this.fuseTicks = nbttagcompound.getByte("Fuse");
}
public EntityLiving getSource() {
return this.source;
}
}

View File

@ -0,0 +1,34 @@
package net.minecraft.server.v1_7_R1;
public class PacketPlayInCloseWindow
extends Packet
{
public int a;
public PacketPlayInCloseWindow() {}
public PacketPlayInCloseWindow(int id)
{
this.a = id;
}
public void a(PacketPlayInListener packetplayinlistener)
{
packetplayinlistener.a(this);
}
public void a(PacketDataSerializer packetdataserializer)
{
this.a = packetdataserializer.readByte();
}
public void b(PacketDataSerializer packetdataserializer)
{
packetdataserializer.writeByte(this.a);
}
public void handle(PacketListener packetlistener)
{
a((PacketPlayInListener)packetlistener);
}
}

View File

@ -0,0 +1,42 @@
package net.minecraft.server.v1_7_R1;
public class PacketPlayOutAnimation extends Packet
{
public int a;
public int b;
public PacketPlayOutAnimation() {}
public PacketPlayOutAnimation(Entity paramEntity, int paramInt)
{
this.a = paramEntity.getId();
this.b = paramInt;
}
public void a(PacketDataSerializer paramPacketDataSerializer)
{
this.a = paramPacketDataSerializer.a();
this.b = paramPacketDataSerializer.readUnsignedByte();
}
public void b(PacketDataSerializer paramPacketDataSerializer)
{
paramPacketDataSerializer.b(this.a);
paramPacketDataSerializer.writeByte(this.b);
}
public void a(PacketPlayOutListener paramPacketPlayOutListener)
{
paramPacketPlayOutListener.a(this);
}
public String b()
{
return String.format("id=%d, type=%d", new Object[] { Integer.valueOf(this.a), Integer.valueOf(this.b) });
}
@Override
public void handle(PacketListener arg0)
{
}
}

View File

@ -0,0 +1,41 @@
package net.minecraft.server.v1_7_R1;
public class PacketPlayOutAttachEntity extends Packet
{
public int a;
public int b;
public int c;
public PacketPlayOutAttachEntity() {}
public PacketPlayOutAttachEntity(int paramInt, Entity paramEntity1, Entity paramEntity2)
{
this.a = paramInt;
this.b = paramEntity1.getId();
this.c = (paramEntity2 != null ? paramEntity2.getId() : -1);
}
public void a(PacketDataSerializer paramPacketDataSerializer)
{
this.b = paramPacketDataSerializer.readInt();
this.c = paramPacketDataSerializer.readInt();
this.a = paramPacketDataSerializer.readUnsignedByte();
}
public void b(PacketDataSerializer paramPacketDataSerializer)
{
paramPacketDataSerializer.writeInt(this.b);
paramPacketDataSerializer.writeInt(this.c);
paramPacketDataSerializer.writeByte(this.a);
}
public void a(PacketPlayOutListener paramPacketPlayOutListener)
{
paramPacketPlayOutListener.a(this);
}
@Override
public void handle(PacketListener arg0)
{
}
}

View File

@ -0,0 +1,50 @@
package net.minecraft.server.v1_7_R1;
public class PacketPlayOutEntity
extends Packet
{
public int a;
public byte b;
public byte c;
public byte d;
public byte e;
public byte f;
public boolean g;
public PacketPlayOutEntity() {}
public PacketPlayOutEntity(int paramInt)
{
this.a = paramInt;
}
public void a(PacketDataSerializer paramPacketDataSerializer)
{
this.a = paramPacketDataSerializer.readInt();
}
public void b(PacketDataSerializer paramPacketDataSerializer)
{
paramPacketDataSerializer.writeInt(this.a);
}
public void a(PacketPlayOutListener paramPacketPlayOutListener)
{
paramPacketPlayOutListener.a(this);
}
public String b()
{
return String.format("id=%d", new Object[] { Integer.valueOf(this.a) });
}
public String toString()
{
return "Entity_" + super.toString();
}
@Override
public void handle(PacketListener arg0)
{
}
}

View File

@ -0,0 +1,46 @@
package net.minecraft.server.v1_7_R1;
public class PacketPlayOutEntityEquipment extends Packet
{
public int a;
public int b;
private ItemStack c;
public PacketPlayOutEntityEquipment() {}
public PacketPlayOutEntityEquipment(int paramInt1, int paramInt2, ItemStack paramItemStack)
{
this.a = paramInt1;
this.b = paramInt2;
this.c = (paramItemStack == null ? null : paramItemStack.cloneItemStack());
}
public void a(PacketDataSerializer paramPacketDataSerializer)
{
this.a = paramPacketDataSerializer.readInt();
this.b = paramPacketDataSerializer.readShort();
this.c = paramPacketDataSerializer.c();
}
public void b(PacketDataSerializer paramPacketDataSerializer)
{
paramPacketDataSerializer.writeInt(this.a);
paramPacketDataSerializer.writeShort(this.b);
paramPacketDataSerializer.a(this.c);
}
public void a(PacketPlayOutListener paramPacketPlayOutListener)
{
paramPacketPlayOutListener.a(this);
}
public String b()
{
return String.format("entity=%d, slot=%d, item=%s", new Object[] { Integer.valueOf(this.a), Integer.valueOf(this.b), this.c });
}
@Override
public void handle(PacketListener paramPacketListener)
{
}
}

View File

@ -0,0 +1,43 @@
package net.minecraft.server.v1_7_R1;
import java.util.List;
public class PacketPlayOutEntityMetadata extends Packet
{
public int a;
public List b;
public PacketPlayOutEntityMetadata() {}
public PacketPlayOutEntityMetadata(int paramInt, DataWatcher paramDataWatcher, boolean paramBoolean)
{
this.a = paramInt;
if (paramBoolean) {
this.b = paramDataWatcher.c();
} else {
this.b = paramDataWatcher.b();
}
}
public void a(PacketDataSerializer paramPacketDataSerializer)
{
this.a = paramPacketDataSerializer.readInt();
this.b = DataWatcher.b(paramPacketDataSerializer);
}
public void b(PacketDataSerializer paramPacketDataSerializer)
{
paramPacketDataSerializer.writeInt(this.a);
DataWatcher.a(this.b, paramPacketDataSerializer);
}
public void a(PacketPlayOutListener paramPacketPlayOutListener)
{
paramPacketPlayOutListener.a(this);
}
@Override
public void handle(PacketListener arg0)
{
}
}

View File

@ -0,0 +1,66 @@
package net.minecraft.server.v1_7_R1;
public class PacketPlayOutEntityTeleport extends Packet
{
public int a;
public int b;
public int c;
public int d;
public byte e;
public byte f;
public PacketPlayOutEntityTeleport()
{
}
public PacketPlayOutEntityTeleport(Entity paramEntity)
{
this.a = paramEntity.getId();
this.b = MathHelper.floor(paramEntity.locX * 32.0D);
this.c = MathHelper.floor(paramEntity.locY * 32.0D);
this.d = MathHelper.floor(paramEntity.locZ * 32.0D);
this.e = ((byte) (int) (paramEntity.yaw * 256.0F / 360.0F));
this.f = ((byte) (int) (paramEntity.pitch * 256.0F / 360.0F));
}
public PacketPlayOutEntityTeleport(int paramInt1, int paramInt2, int paramInt3, int paramInt4, byte paramByte1,
byte paramByte2)
{
this.a = paramInt1;
this.b = paramInt2;
this.c = paramInt3;
this.d = paramInt4;
this.e = paramByte1;
this.f = paramByte2;
}
public void a(PacketDataSerializer paramPacketDataSerializer)
{
this.a = paramPacketDataSerializer.readInt();
this.b = paramPacketDataSerializer.readInt();
this.c = paramPacketDataSerializer.readInt();
this.d = paramPacketDataSerializer.readInt();
this.e = paramPacketDataSerializer.readByte();
this.f = paramPacketDataSerializer.readByte();
}
public void b(PacketDataSerializer paramPacketDataSerializer)
{
paramPacketDataSerializer.writeInt(this.a);
paramPacketDataSerializer.writeInt(this.b);
paramPacketDataSerializer.writeInt(this.c);
paramPacketDataSerializer.writeInt(this.d);
paramPacketDataSerializer.writeByte(this.e);
paramPacketDataSerializer.writeByte(this.f);
}
public void a(PacketPlayOutListener paramPacketPlayOutListener)
{
paramPacketPlayOutListener.a(this);
}
@Override
public void handle(PacketListener arg0)
{
}
}

View File

@ -0,0 +1,75 @@
package net.minecraft.server.v1_7_R1;
public class PacketPlayOutEntityVelocity
extends Packet
{
public int a;
public int b;
public int c;
public int d;
public PacketPlayOutEntityVelocity() {}
public PacketPlayOutEntityVelocity(Entity paramEntity)
{
this(paramEntity.getId(), paramEntity.motX, paramEntity.motY, paramEntity.motZ);
}
public PacketPlayOutEntityVelocity(int paramInt, double paramDouble1, double paramDouble2, double paramDouble3)
{
this.a = paramInt;
double d1 = 3.9D;
if (paramDouble1 < -d1) {
paramDouble1 = -d1;
}
if (paramDouble2 < -d1) {
paramDouble2 = -d1;
}
if (paramDouble3 < -d1) {
paramDouble3 = -d1;
}
if (paramDouble1 > d1) {
paramDouble1 = d1;
}
if (paramDouble2 > d1) {
paramDouble2 = d1;
}
if (paramDouble3 > d1) {
paramDouble3 = d1;
}
this.b = ((int)(paramDouble1 * 8000.0D));
this.c = ((int)(paramDouble2 * 8000.0D));
this.d = ((int)(paramDouble3 * 8000.0D));
}
public void a(PacketDataSerializer paramPacketDataSerializer)
{
this.a = paramPacketDataSerializer.readInt();
this.b = paramPacketDataSerializer.readShort();
this.c = paramPacketDataSerializer.readShort();
this.d = paramPacketDataSerializer.readShort();
}
public void b(PacketDataSerializer paramPacketDataSerializer)
{
paramPacketDataSerializer.writeInt(this.a);
paramPacketDataSerializer.writeShort(this.b);
paramPacketDataSerializer.writeShort(this.c);
paramPacketDataSerializer.writeShort(this.d);
}
public void a(PacketPlayOutListener paramPacketPlayOutListener)
{
paramPacketPlayOutListener.a(this);
}
public String b()
{
return String.format("id=%d, x=%.2f, y=%.2f, z=%.2f", new Object[] { Integer.valueOf(this.a), Float.valueOf(this.b / 8000.0F), Float.valueOf(this.c / 8000.0F), Float.valueOf(this.d / 8000.0F) });
}
@Override
public void handle(PacketListener arg0)
{
}
}

View File

@ -0,0 +1,80 @@
package net.minecraft.server.v1_7_R1;
import java.io.IOException;
import java.util.List;
import net.minecraft.util.com.mojang.authlib.GameProfile;
public class PacketPlayOutNamedEntitySpawn extends Packet
{
public int a;
public GameProfile b;
public int c;
public int d;
public int e;
public byte f;
public byte g;
public int h;
public DataWatcher i;
public List j;
public PacketPlayOutNamedEntitySpawn() {}
public PacketPlayOutNamedEntitySpawn(EntityHuman entityhuman)
{
this.a = entityhuman.getId();
this.b = entityhuman.getProfile();
this.c = MathHelper.floor(entityhuman.locX * 32.0D);
this.d = MathHelper.floor(entityhuman.locY * 32.0D);
this.e = MathHelper.floor(entityhuman.locZ * 32.0D);
this.f = ((byte)(int)(entityhuman.yaw * 256.0F / 360.0F));
this.g = ((byte)(int)(entityhuman.pitch * 256.0F / 360.0F));
ItemStack itemstack = entityhuman.inventory.getItemInHand();
this.h = (itemstack == null ? 0 : Item.b(itemstack.getItem()));
this.i = entityhuman.getDataWatcher();
}
public void a(PacketDataSerializer packetdataserializer)
throws IOException
{
this.a = packetdataserializer.a();
this.b = new GameProfile(packetdataserializer.c(36), packetdataserializer.c(16));
this.c = packetdataserializer.readInt();
this.d = packetdataserializer.readInt();
this.e = packetdataserializer.readInt();
this.f = packetdataserializer.readByte();
this.g = packetdataserializer.readByte();
this.h = packetdataserializer.readShort();
this.j = DataWatcher.b(packetdataserializer);
}
public void b(PacketDataSerializer packetdataserializer)
throws IOException
{
packetdataserializer.b(this.a);
packetdataserializer.a(this.b.getId());
packetdataserializer.a(this.b.getName().length() > 16 ? this.b.getName().substring(0, 16) : this.b.getName());
packetdataserializer.writeInt(this.c);
packetdataserializer.writeInt(this.d);
packetdataserializer.writeInt(this.e);
packetdataserializer.writeByte(this.f);
packetdataserializer.writeByte(this.g);
packetdataserializer.writeShort(this.h);
this.i.a(packetdataserializer);
}
public void a(PacketPlayOutListener packetplayoutlistener)
{
packetplayoutlistener.a(this);
}
public String b()
{
return String.format("id=%d, gameProfile='%s', x=%.2f, y=%.2f, z=%.2f, carried=%d", new Object[] { Integer.valueOf(this.a), this.b, Float.valueOf(this.c / 32.0F), Float.valueOf(this.d / 32.0F), Float.valueOf(this.e / 32.0F), Integer.valueOf(this.h) });
}
public void handle(PacketListener packetlistener)
{
a((PacketPlayOutListener)packetlistener);
}
}

View File

@ -0,0 +1,36 @@
package net.minecraft.server.v1_7_R1;
public class PacketPlayOutRelEntityMove
extends PacketPlayOutEntity
{
public PacketPlayOutRelEntityMove() {}
public PacketPlayOutRelEntityMove(int paramInt, byte paramByte1, byte paramByte2, byte paramByte3)
{
super(paramInt);
this.b = paramByte1;
this.c = paramByte2;
this.d = paramByte3;
}
public void a(PacketDataSerializer paramPacketDataSerializer)
{
super.a(paramPacketDataSerializer);
this.b = paramPacketDataSerializer.readByte();
this.c = paramPacketDataSerializer.readByte();
this.d = paramPacketDataSerializer.readByte();
}
public void b(PacketDataSerializer paramPacketDataSerializer)
{
super.b(paramPacketDataSerializer);
paramPacketDataSerializer.writeByte(this.b);
paramPacketDataSerializer.writeByte(this.c);
paramPacketDataSerializer.writeByte(this.d);
}
public String b()
{
return super.b() + String.format(", xa=%d, ya=%d, za=%d", new Object[] { Byte.valueOf(this.b), Byte.valueOf(this.c), Byte.valueOf(this.d) });
}
}

View File

@ -0,0 +1,46 @@
package net.minecraft.server.v1_7_R1;
public class PacketPlayOutRelEntityMoveLook
extends PacketPlayOutEntity
{
public PacketPlayOutRelEntityMoveLook()
{
this.g = true;
}
public PacketPlayOutRelEntityMoveLook(int paramInt, byte paramByte1, byte paramByte2, byte paramByte3, byte paramByte4, byte paramByte5)
{
super(paramInt);
this.b = paramByte1;
this.c = paramByte2;
this.d = paramByte3;
this.e = paramByte4;
this.f = paramByte5;
this.g = true;
}
public void a(PacketDataSerializer paramPacketDataSerializer)
{
super.a(paramPacketDataSerializer);
this.b = paramPacketDataSerializer.readByte();
this.c = paramPacketDataSerializer.readByte();
this.d = paramPacketDataSerializer.readByte();
this.e = paramPacketDataSerializer.readByte();
this.f = paramPacketDataSerializer.readByte();
}
public void b(PacketDataSerializer paramPacketDataSerializer)
{
super.b(paramPacketDataSerializer);
paramPacketDataSerializer.writeByte(this.b);
paramPacketDataSerializer.writeByte(this.c);
paramPacketDataSerializer.writeByte(this.d);
paramPacketDataSerializer.writeByte(this.e);
paramPacketDataSerializer.writeByte(this.f);
}
public String b()
{
return super.b() + String.format(", xa=%d, ya=%d, za=%d, yRot=%d, xRot=%d", new Object[] { Byte.valueOf(this.b), Byte.valueOf(this.c), Byte.valueOf(this.d), Byte.valueOf(this.e), Byte.valueOf(this.f) });
}
}

View File

@ -0,0 +1,144 @@
package net.minecraft.server.v1_7_R1;
public class PacketPlayOutSpawnEntity extends Packet
{
public int a;
public int b;
public int c;
public int d;
public int e;
public int f;
public int g;
public int h;
public int i;
public int j;
public int k;
public PacketPlayOutSpawnEntity() {}
public PacketPlayOutSpawnEntity(Entity paramEntity, int paramInt)
{
this(paramEntity, paramInt, 0);
}
public PacketPlayOutSpawnEntity(Entity paramEntity, int paramInt1, int paramInt2)
{
this.a = paramEntity.getId();
this.b = MathHelper.floor(paramEntity.locX * 32.0D);
this.c = MathHelper.floor(paramEntity.locY * 32.0D);
this.d = MathHelper.floor(paramEntity.locZ * 32.0D);
this.h = MathHelper.d(paramEntity.pitch * 256.0F / 360.0F);
this.i = MathHelper.d(paramEntity.yaw * 256.0F / 360.0F);
this.j = paramInt1;
this.k = paramInt2;
if (paramInt2 > 0)
{
double d1 = paramEntity.motX;
double d2 = paramEntity.motY;
double d3 = paramEntity.motZ;
double d4 = 3.9D;
if (d1 < -d4) {
d1 = -d4;
}
if (d2 < -d4) {
d2 = -d4;
}
if (d3 < -d4) {
d3 = -d4;
}
if (d1 > d4) {
d1 = d4;
}
if (d2 > d4) {
d2 = d4;
}
if (d3 > d4) {
d3 = d4;
}
this.e = ((int)(d1 * 8000.0D));
this.f = ((int)(d2 * 8000.0D));
this.g = ((int)(d3 * 8000.0D));
}
}
public void a(PacketDataSerializer paramPacketDataSerializer)
{
this.a = paramPacketDataSerializer.a();
this.j = paramPacketDataSerializer.readByte();
this.b = paramPacketDataSerializer.readInt();
this.c = paramPacketDataSerializer.readInt();
this.d = paramPacketDataSerializer.readInt();
this.h = paramPacketDataSerializer.readByte();
this.i = paramPacketDataSerializer.readByte();
this.k = paramPacketDataSerializer.readInt();
if (this.k > 0)
{
this.e = paramPacketDataSerializer.readShort();
this.f = paramPacketDataSerializer.readShort();
this.g = paramPacketDataSerializer.readShort();
}
}
public void b(PacketDataSerializer paramPacketDataSerializer)
{
paramPacketDataSerializer.b(this.a);
paramPacketDataSerializer.writeByte(this.j);
paramPacketDataSerializer.writeInt(this.b);
paramPacketDataSerializer.writeInt(this.c);
paramPacketDataSerializer.writeInt(this.d);
paramPacketDataSerializer.writeByte(this.h);
paramPacketDataSerializer.writeByte(this.i);
paramPacketDataSerializer.writeInt(this.k);
if (this.k > 0)
{
paramPacketDataSerializer.writeShort(this.e);
paramPacketDataSerializer.writeShort(this.f);
paramPacketDataSerializer.writeShort(this.g);
}
}
public void a(PacketPlayOutListener paramPacketPlayOutListener)
{
paramPacketPlayOutListener.a(this);
}
public String b()
{
return String.format("id=%d, type=%d, x=%.2f, y=%.2f, z=%.2f", new Object[] { Integer.valueOf(this.a), Integer.valueOf(this.j), Float.valueOf(this.b / 32.0F), Float.valueOf(this.c / 32.0F), Float.valueOf(this.d / 32.0F) });
}
public void a(int paramInt)
{
this.b = paramInt;
}
public void b(int paramInt)
{
this.c = paramInt;
}
public void c(int paramInt)
{
this.d = paramInt;
}
public void d(int paramInt)
{
this.e = paramInt;
}
public void e(int paramInt)
{
this.f = paramInt;
}
public void f(int paramInt)
{
this.g = paramInt;
}
@Override
public void handle(PacketListener arg0)
{
}
}

View File

@ -0,0 +1,111 @@
package net.minecraft.server.v1_7_R1;
import java.util.List;
public class PacketPlayOutSpawnEntityLiving extends Packet
{
public int a;
public int b;
public int c;
public int d;
public int e;
public int f;
public int g;
public int h;
public byte i;
public byte j;
public byte k;
public DataWatcher l;
public List m;
public PacketPlayOutSpawnEntityLiving() {}
public PacketPlayOutSpawnEntityLiving(EntityLiving paramEntityLiving)
{
this.a = paramEntityLiving.getId();
this.b = ((byte)EntityTypes.a(paramEntityLiving));
this.c = paramEntityLiving.at.a(paramEntityLiving.locX);
this.d = MathHelper.floor(paramEntityLiving.locY * 32.0D);
this.e = paramEntityLiving.at.a(paramEntityLiving.locZ);
this.i = ((byte)(int)(paramEntityLiving.yaw * 256.0F / 360.0F));
this.j = ((byte)(int)(paramEntityLiving.pitch * 256.0F / 360.0F));
this.k = ((byte)(int)(paramEntityLiving.aP * 256.0F / 360.0F));
double d1 = 3.9D;
double d2 = paramEntityLiving.motX;
double d3 = paramEntityLiving.motY;
double d4 = paramEntityLiving.motZ;
if (d2 < -d1) {
d2 = -d1;
}
if (d3 < -d1) {
d3 = -d1;
}
if (d4 < -d1) {
d4 = -d1;
}
if (d2 > d1) {
d2 = d1;
}
if (d3 > d1) {
d3 = d1;
}
if (d4 > d1) {
d4 = d1;
}
this.f = ((int)(d2 * 8000.0D));
this.g = ((int)(d3 * 8000.0D));
this.h = ((int)(d4 * 8000.0D));
this.l = paramEntityLiving.getDataWatcher();
}
public void a(PacketDataSerializer paramPacketDataSerializer)
{
this.a = paramPacketDataSerializer.a();
this.b = (paramPacketDataSerializer.readByte() & 0xFF);
this.c = paramPacketDataSerializer.readInt();
this.d = paramPacketDataSerializer.readInt();
this.e = paramPacketDataSerializer.readInt();
this.i = paramPacketDataSerializer.readByte();
this.j = paramPacketDataSerializer.readByte();
this.k = paramPacketDataSerializer.readByte();
this.f = paramPacketDataSerializer.readShort();
this.g = paramPacketDataSerializer.readShort();
this.h = paramPacketDataSerializer.readShort();
this.m = DataWatcher.b(paramPacketDataSerializer);
}
public void b(PacketDataSerializer paramPacketDataSerializer)
{
paramPacketDataSerializer.b(this.a);
paramPacketDataSerializer.writeByte(this.b & 0xFF);
paramPacketDataSerializer.writeInt(this.c);
paramPacketDataSerializer.writeInt(this.d);
paramPacketDataSerializer.writeInt(this.e);
paramPacketDataSerializer.writeByte(this.i);
paramPacketDataSerializer.writeByte(this.j);
paramPacketDataSerializer.writeByte(this.k);
paramPacketDataSerializer.writeShort(this.f);
paramPacketDataSerializer.writeShort(this.g);
paramPacketDataSerializer.writeShort(this.h);
this.l.a(paramPacketDataSerializer);
}
public void a(PacketPlayOutListener paramPacketPlayOutListener)
{
paramPacketPlayOutListener.a(this);
}
public String b()
{
return String.format("id=%d, type=%d, x=%.2f, y=%.2f, z=%.2f, xd=%.2f, yd=%.2f, zd=%.2f", new Object[] { Integer.valueOf(this.a), Integer.valueOf(this.b), Float.valueOf(this.c / 32.0F), Float.valueOf(this.d / 32.0F), Float.valueOf(this.e / 32.0F), Float.valueOf(this.f / 8000.0F), Float.valueOf(this.g / 8000.0F), Float.valueOf(this.h / 8000.0F) });
}
@Override
public void handle(PacketListener arg0)
{
}
}

View File

@ -1,19 +1,8 @@
package net.minecraft.server.v1_6_R3;
package net.minecraft.server.v1_7_R1;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.server.v1_6_R3.Chunk;
import net.minecraft.server.v1_6_R3.ChunkCoordIntPair;
import net.minecraft.server.v1_6_R3.EntityPlayer;
import net.minecraft.server.v1_6_R3.Packet;
import net.minecraft.server.v1_6_R3.Packet51MapChunk;
import net.minecraft.server.v1_6_R3.Packet52MultiBlockChange;
import net.minecraft.server.v1_6_R3.Packet53BlockChange;
import net.minecraft.server.v1_6_R3.PlayerChunk;
import net.minecraft.server.v1_6_R3.PlayerChunkMap;
import net.minecraft.server.v1_6_R3.TileEntity;
class PlayerChunk {
private final List b;
@ -22,9 +11,8 @@ class PlayerChunk {
private int dirtyCount;
private int f;
private long g;
private boolean loaded = false; // CraftBukkit
final PlayerChunkMap playerChunkMap;
private boolean loaded = false; // CraftBukkit
public PlayerChunk(PlayerChunkMap playerchunkmap, int i, int j) {
this.playerChunkMap = playerchunkmap;
@ -49,12 +37,10 @@ class PlayerChunk {
}
this.b.add(entityplayer);
// CraftBukkit start
if (this.loaded) {
entityplayer.chunkCoordIntPairQueue.add(this.location);
} else {
// Abuse getChunkAt to add another callback
this.playerChunkMap.a().chunkProviderServer.getChunkAt(this.location.x, this.location.z, new Runnable() {
public void run() {
entityplayer.chunkCoordIntPairQueue.add(PlayerChunk.this.location);
@ -67,13 +53,13 @@ class PlayerChunk {
public void b(EntityPlayer entityplayer) {
if (this.b.contains(entityplayer)) {
Chunk chunk = PlayerChunkMap.a(this.playerChunkMap).getChunkAt(this.location.x, this.location.z);
if (chunk.x == location.x && chunk.z == location.z)
{
entityplayer.playerConnection.sendPacket(new Packet51MapChunk(chunk, true, 0));
}
Chunk chunk = PlayerChunkMap.a(this.playerChunkMap).getChunkAt(this.location.x, this.location.z);
if (chunk.k() && chunk.locX == location.x && chunk.locZ == location.z)
{
entityplayer.playerConnection.sendPacket(new PacketPlayOutMapChunk(chunk, true, 0));
}
this.b.remove(entityplayer);
entityplayer.chunkCoordIntPairQueue.remove(this.location);
if (this.b.isEmpty()) {
@ -96,7 +82,7 @@ class PlayerChunk {
}
private void a(Chunk chunk) {
chunk.q += PlayerChunkMap.a(this.playerChunkMap).getTime() - this.g;
chunk.s += PlayerChunkMap.a(this.playerChunkMap).getTime() - this.g;
this.g = PlayerChunkMap.a(this.playerChunkMap).getTime();
}
@ -139,8 +125,8 @@ class PlayerChunk {
i = this.location.x * 16 + (this.dirtyBlocks[0] >> 12 & 15);
j = this.dirtyBlocks[0] & 255;
k = this.location.z * 16 + (this.dirtyBlocks[0] >> 8 & 15);
this.sendAll(new Packet53BlockChange(i, j, k, PlayerChunkMap.a(this.playerChunkMap)));
if (PlayerChunkMap.a(this.playerChunkMap).isTileEntity(i, j, k)) {
this.sendAll(new PacketPlayOutBlockChange(i, j, k, PlayerChunkMap.a(this.playerChunkMap)));
if (PlayerChunkMap.a(this.playerChunkMap).getType(i, j, k).isTileEntity()) {
this.sendTileEntity(PlayerChunkMap.a(this.playerChunkMap).getTileEntity(i, j, k));
}
} else {
@ -149,7 +135,7 @@ class PlayerChunk {
if (this.dirtyCount == 64) {
i = this.location.x * 16;
j = this.location.z * 16;
this.sendAll(new Packet51MapChunk(PlayerChunkMap.a(this.playerChunkMap).getChunkAt(this.location.x, this.location.z), (this.f == 0xFFFF), this.f));
this.sendAll(new PacketPlayOutMapChunk(PlayerChunkMap.a(this.playerChunkMap).getChunkAt(this.location.x, this.location.z), (this.f == 0xFFFF), this.f)); // CraftBukkit - send everything (including biome) if all sections flagged
for (k = 0; k < 16; ++k) {
if ((this.f & 1 << k) != 0) {
@ -162,13 +148,13 @@ class PlayerChunk {
}
}
} else {
this.sendAll(new Packet52MultiBlockChange(this.location.x, this.location.z, this.dirtyBlocks, this.dirtyCount, PlayerChunkMap.a(this.playerChunkMap)));
this.sendAll(new PacketPlayOutMultiBlockChange(this.dirtyCount, this.dirtyBlocks, PlayerChunkMap.a(this.playerChunkMap).getChunkAt(this.location.x, this.location.z)));
for (i = 0; i < this.dirtyCount; ++i) {
j = this.location.x * 16 + (this.dirtyBlocks[i] >> 12 & 15);
k = this.dirtyBlocks[i] & 255;
l = this.location.z * 16 + (this.dirtyBlocks[i] >> 8 & 15);
if (PlayerChunkMap.a(this.playerChunkMap).isTileEntity(j, k, l)) {
if (PlayerChunkMap.a(this.playerChunkMap).getType(j, k, l).isTileEntity()) {
this.sendTileEntity(PlayerChunkMap.a(this.playerChunkMap).getTileEntity(j, k, l));
}
}

View File

@ -1,6 +1,5 @@
package net.minecraft.server.v1_6_R3;
package net.minecraft.server.v1_7_R1;
import com.google.common.base.Charsets;
import java.io.File;
import java.net.SocketAddress;
import java.text.SimpleDateFormat;
@ -13,54 +12,16 @@ import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
import net.minecraft.server.v1_6_R3.BanEntry;
import net.minecraft.server.v1_6_R3.BanList;
import net.minecraft.server.v1_6_R3.ChatMessage;
import net.minecraft.server.v1_6_R3.ChunkCoordinates;
import net.minecraft.server.v1_6_R3.DemoPlayerInteractManager;
import net.minecraft.server.v1_6_R3.Entity;
import net.minecraft.server.v1_6_R3.EntityHuman;
import net.minecraft.server.v1_6_R3.EntityPlayer;
import net.minecraft.server.v1_6_R3.EntityTypes;
import net.minecraft.server.v1_6_R3.EnumGamemode;
import net.minecraft.server.v1_6_R3.INetworkManager;
import net.minecraft.server.v1_6_R3.IPlayerFileData;
import net.minecraft.server.v1_6_R3.MathHelper;
import net.minecraft.server.v1_6_R3.MinecraftServer;
import net.minecraft.server.v1_6_R3.MobEffect;
import net.minecraft.server.v1_6_R3.NBTTagCompound;
import net.minecraft.server.v1_6_R3.Packet;
import net.minecraft.server.v1_6_R3.Packet16BlockItemSwitch;
import net.minecraft.server.v1_6_R3.Packet1Login;
import net.minecraft.server.v1_6_R3.Packet201PlayerInfo;
import net.minecraft.server.v1_6_R3.Packet202Abilities;
import net.minecraft.server.v1_6_R3.Packet209SetScoreboardTeam;
import net.minecraft.server.v1_6_R3.Packet250CustomPayload;
import net.minecraft.server.v1_6_R3.Packet3Chat;
import net.minecraft.server.v1_6_R3.Packet41MobEffect;
import net.minecraft.server.v1_6_R3.Packet43SetExperience;
import net.minecraft.server.v1_6_R3.Packet4UpdateTime;
import net.minecraft.server.v1_6_R3.Packet6SpawnPosition;
import net.minecraft.server.v1_6_R3.Packet70Bed;
import net.minecraft.server.v1_6_R3.Packet9Respawn;
import net.minecraft.server.v1_6_R3.PendingConnection;
import net.minecraft.server.v1_6_R3.PlayerChunkMap;
import net.minecraft.server.v1_6_R3.PlayerConnection;
import net.minecraft.server.v1_6_R3.PlayerDistanceComparator;
import net.minecraft.server.v1_6_R3.PlayerInteractManager;
import net.minecraft.server.v1_6_R3.Scoreboard;
import net.minecraft.server.v1_6_R3.ScoreboardObjective;
import net.minecraft.server.v1_6_R3.ScoreboardScore;
import net.minecraft.server.v1_6_R3.ScoreboardServer;
import net.minecraft.server.v1_6_R3.ScoreboardTeam;
import net.minecraft.server.v1_6_R3.ScoreboardTeamBase;
import net.minecraft.server.v1_6_R3.World;
import net.minecraft.server.v1_6_R3.WorldServer;
import net.minecraft.util.com.google.common.base.Charsets;
import net.minecraft.util.com.google.common.collect.Maps;
import net.minecraft.util.com.mojang.authlib.GameProfile;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
// CraftBukkit start
import org.bukkit.craftbukkit.v1_6_R3.CraftServer;
import org.bukkit.craftbukkit.v1_6_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_6_R3.chunkio.ChunkIOExecutor;
import org.bukkit.craftbukkit.v1_7_R1.CraftServer;
import org.bukkit.craftbukkit.v1_7_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_7_R1.chunkio.ChunkIOExecutor;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@ -78,27 +39,30 @@ import org.bukkit.util.Vector;
public abstract class PlayerList {
private static final SimpleDateFormat d = new SimpleDateFormat("yyyy-MM-dd \'at\' HH:mm:ss z");
private static final Logger d = LogManager.getLogger();
private static final SimpleDateFormat e = new SimpleDateFormat("yyyy-MM-dd \'at\' HH:mm:ss z");
private final MinecraftServer server;
public final List players = new java.util.concurrent.CopyOnWriteArrayList(); // CraftBukkit - ArrayList -> CopyOnWriteArrayList: Iterator safety
private final BanList banByName = new BanList(new File("banned-players.txt"));
private final BanList banByIP = new BanList(new File("banned-ips.txt"));
private Set operators = new HashSet();
private Set whitelist = new java.util.LinkedHashSet(); // CraftBukkit - HashSet -> LinkedHashSet
private final Set operators = new HashSet();
private final Set whitelist = new java.util.LinkedHashSet(); // CraftBukkit - HashSet -> LinkedHashSet
private final Map k = Maps.newHashMap();
public IPlayerFileData playerFileData; // CraftBukkit - private -> public
public boolean hasWhitelist; // CraftBukkit - private -> public
protected int maxPlayers;
protected int c;
private EnumGamemode l;
private boolean m;
private int n;
private EnumGamemode n;
private boolean o;
private int p;
// CraftBukkit start
private CraftServer cserver;
public PlayerList(MinecraftServer minecraftserver) {
minecraftserver.server = new CraftServer(minecraftserver, this);
minecraftserver.console = org.bukkit.craftbukkit.v1_6_R3.command.ColouredConsoleSender.getInstance();
minecraftserver.console = org.bukkit.craftbukkit.v1_7_R1.command.ColouredConsoleSender.getInstance();
minecraftserver.reader.addCompleter(new org.bukkit.craftbukkit.v1_7_R1.command.ConsoleCommandCompleter(minecraftserver.server));
this.cserver = minecraftserver.server;
// CraftBukkit end
@ -108,47 +72,52 @@ public abstract class PlayerList {
this.maxPlayers = 8;
}
public void a(INetworkManager inetworkmanager, EntityPlayer entityplayer) {
public void a(NetworkManager networkmanager, EntityPlayer entityplayer) {
NBTTagCompound nbttagcompound = this.a(entityplayer);
entityplayer.spawnIn(this.server.getWorldServer(entityplayer.dimension));
entityplayer.playerInteractManager.a((WorldServer) entityplayer.world);
String s = "local";
if (inetworkmanager.getSocketAddress() != null) {
s = inetworkmanager.getSocketAddress().toString();
if (networkmanager.getSocketAddress() != null) {
s = networkmanager.getSocketAddress().toString();
}
// CraftBukkit - add world and location to 'logged in' message.
this.server.getLogger().info(entityplayer.getName() + "[" + s + "] logged in with entity id " + entityplayer.id + " at ([" + entityplayer.world.worldData.getName() + "] " + entityplayer.locX + ", " + entityplayer.locY + ", " + entityplayer.locZ + ")");
// CraftBukkit - add world to 'logged in' message.
d.info(entityplayer.getName() + "[" + s + "] logged in with entity id " + entityplayer.getId() + " at ([" + entityplayer.world.worldData.getName() + "] " + entityplayer.locX + ", " + entityplayer.locY + ", " + entityplayer.locZ + ")");
WorldServer worldserver = this.server.getWorldServer(entityplayer.dimension);
ChunkCoordinates chunkcoordinates = worldserver.getSpawn();
this.a(entityplayer, (EntityPlayer) null, worldserver);
PlayerConnection playerconnection = new PlayerConnection(this.server, inetworkmanager, entityplayer);
PlayerConnection playerconnection = new PlayerConnection(this.server, networkmanager, entityplayer);
// CraftBukkit start -- Don't send a higher than 60 MaxPlayer size, otherwise the PlayerInfo window won't render correctly.
int maxPlayers = this.getMaxPlayers();
if (maxPlayers > 60) {
maxPlayers = 60;
}
playerconnection.sendPacket(new Packet1Login(entityplayer.id, worldserver.getWorldData().getType(), entityplayer.playerInteractManager.getGameMode(), worldserver.getWorldData().isHardcore(), worldserver.worldProvider.dimension, worldserver.difficulty, worldserver.getHeight(), maxPlayers));
playerconnection.sendPacket(new PacketPlayOutLogin(entityplayer.getId(), entityplayer.playerInteractManager.getGameMode(), worldserver.getWorldData().isHardcore(), worldserver.worldProvider.dimension, worldserver.difficulty, maxPlayers, worldserver.getWorldData().getType()));
entityplayer.getBukkitEntity().sendSupportedChannels();
// CraftBukkit end
playerconnection.sendPacket(new Packet250CustomPayload("MC|Brand", this.getServer().getServerModName().getBytes(Charsets.UTF_8)));
playerconnection.sendPacket(new Packet6SpawnPosition(chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z));
playerconnection.sendPacket(new Packet202Abilities(entityplayer.abilities));
playerconnection.sendPacket(new Packet16BlockItemSwitch(entityplayer.inventory.itemInHandIndex));
playerconnection.sendPacket(new PacketPlayOutCustomPayload("MC|Brand", this.getServer().getServerModName().getBytes(Charsets.UTF_8)));
playerconnection.sendPacket(new PacketPlayOutSpawnPosition(chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z));
playerconnection.sendPacket(new PacketPlayOutAbilities(entityplayer.abilities));
playerconnection.sendPacket(new PacketPlayOutHeldItemSlot(entityplayer.inventory.itemInHandIndex));
entityplayer.x().d();
entityplayer.x().b(entityplayer);
this.a((ScoreboardServer) worldserver.getScoreboard(), entityplayer);
this.b(entityplayer, worldserver);
// this.sendMessage(ChatMessage.b("multiplayer.player.joined", new Object[] { entityplayer.getScoreboardDisplayName()}).a(EnumChatFormat.YELLOW)); // CraftBukkit - handled in event
this.server.au();
/* CraftBukkit start - login message is handled in the event
ChatMessage chatmessage = new ChatMessage("multiplayer.player.joined", new Object[] { entityplayer.getScoreboardDisplayName()});
chatmessage.b().setColor(EnumChatFormat.YELLOW);
this.sendMessage(chatmessage);
// CraftBukkit end*/
this.c(entityplayer);
playerconnection.a(entityplayer.locX, entityplayer.locY, entityplayer.locZ, entityplayer.yaw, entityplayer.pitch);
this.server.ag().a(playerconnection);
playerconnection.sendPacket(new Packet4UpdateTime(worldserver.getTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean("doDaylightCycle")));
if (this.server.getTexturePack().length() > 0) {
entityplayer.a(this.server.getTexturePack(), this.server.U());
this.b(entityplayer, worldserver);
if (this.server.getResourcePack().length() > 0) {
entityplayer.a(this.server.getResourcePack());
}
Iterator iterator = entityplayer.getEffects().iterator();
@ -156,18 +125,18 @@ public abstract class PlayerList {
while (iterator.hasNext()) {
MobEffect mobeffect = (MobEffect) iterator.next();
playerconnection.sendPacket(new Packet41MobEffect(entityplayer.id, mobeffect));
playerconnection.sendPacket(new PacketPlayOutEntityEffect(entityplayer.getId(), mobeffect));
}
entityplayer.syncInventory();
if (nbttagcompound != null && nbttagcompound.hasKey("Riding")) {
if (nbttagcompound != null && nbttagcompound.hasKeyOfType("Riding", 10)) {
Entity entity = EntityTypes.a(nbttagcompound.getCompound("Riding"), worldserver);
if (entity != null) {
entity.p = true;
entity.o = true;
worldserver.addEntity(entity);
entityplayer.mount(entity);
entity.p = false;
entity.o = false;
}
}
}
@ -179,7 +148,7 @@ public abstract class PlayerList {
while (iterator.hasNext()) {
ScoreboardTeam scoreboardteam = (ScoreboardTeam) iterator.next();
entityplayer.playerConnection.sendPacket(new Packet209SetScoreboardTeam(scoreboardteam, 0));
entityplayer.playerConnection.sendPacket(new PacketPlayOutScoreboardTeam(scoreboardteam, 0));
}
for (int i = 0; i < 3; ++i) {
@ -206,7 +175,7 @@ public abstract class PlayerList {
}
public void a(EntityPlayer entityplayer, WorldServer worldserver) {
WorldServer worldserver1 = entityplayer.p();
WorldServer worldserver1 = entityplayer.r();
if (worldserver != null) {
worldserver.getPlayerChunkMap().removePlayer(entityplayer);
@ -221,13 +190,14 @@ public abstract class PlayerList {
}
public NBTTagCompound a(EntityPlayer entityplayer) {
NBTTagCompound nbttagcompound = this.server.worlds.get(0).getWorldData().i(); // CraftBukkit
// CraftBukkit - fix reference to worldserver array
NBTTagCompound nbttagcompound = this.server.worlds.get(0).getWorldData().i();
NBTTagCompound nbttagcompound1;
if (entityplayer.getName().equals(this.server.J()) && nbttagcompound != null) {
if (entityplayer.getName().equals(this.server.K()) && nbttagcompound != null) {
entityplayer.f(nbttagcompound);
nbttagcompound1 = nbttagcompound;
System.out.println("loading single player");
d.debug("loading single player");
} else {
nbttagcompound1 = this.playerFileData.load(entityplayer);
}
@ -237,22 +207,29 @@ public abstract class PlayerList {
protected void b(EntityPlayer entityplayer) {
this.playerFileData.save(entityplayer);
ServerStatisticManager serverstatisticmanager = (ServerStatisticManager) this.k.get(entityplayer.getName());
if (serverstatisticmanager != null) {
serverstatisticmanager.b();
}
}
public void c(EntityPlayer entityplayer) {
cserver.detectListNameConflict(entityplayer); // CraftBukkit
// this.sendAll(new Packet201PlayerInfo(entityplayer.getName(), true, 1000)); // CraftBukkit - replaced with loop below
// this.sendAll(new PacketPlayOutPlayerInfo(entityplayer.getName(), true, 1000)); // CraftBukkit - replaced with loop below
this.players.add(entityplayer);
WorldServer worldserver = this.server.getWorldServer(entityplayer.dimension);
// CraftBukkit start
PlayerJoinEvent playerJoinEvent = new PlayerJoinEvent(this.cserver.getPlayer(entityplayer), "\u00A7e" + entityplayer.name + " joined the game.");
PlayerJoinEvent playerJoinEvent = new PlayerJoinEvent(this.cserver.getPlayer(entityplayer), "\u00A7e" + entityplayer.getName() + " joined the game.");
this.cserver.getPluginManager().callEvent(playerJoinEvent);
String joinMessage = playerJoinEvent.getJoinMessage();
if ((joinMessage != null) && (joinMessage.length() > 0)) {
this.server.getPlayerList().sendAll(new Packet3Chat(ChatMessage.d(joinMessage)));
for (IChatBaseComponent line : org.bukkit.craftbukkit.v1_7_R1.util.CraftChatMessage.fromString(joinMessage)) {
this.server.getPlayerList().sendAll(new PacketPlayOutChat(line));
}
}
this.cserver.onPlayerJoin(playerJoinEvent.getPlayer());
@ -267,7 +244,7 @@ public abstract class PlayerList {
// CraftBukkit end
// CraftBukkit start - sendAll above replaced with this loop
Packet201PlayerInfo packet = new Packet201PlayerInfo(entityplayer.listName, true, 1000);
PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(entityplayer.listName, true, 1000);
for (int i = 0; i < this.players.size(); ++i) {
EntityPlayer entityplayer1 = (EntityPlayer) this.players.get(i);
@ -280,44 +257,47 @@ public abstract class PlayerList {
for (int i = 0; i < this.players.size(); ++i) {
EntityPlayer entityplayer1 = (EntityPlayer) this.players.get(i);
// CraftBukkit start - .name -> .listName
if (entityplayer.getBukkitEntity().canSee(entityplayer1.getBukkitEntity())) {
entityplayer.playerConnection.sendPacket(new Packet201PlayerInfo(entityplayer1.listName, true, entityplayer1.ping));
// CraftBukkit start
if (!entityplayer.getBukkitEntity().canSee(entityplayer1.getBukkitEntity())) {
continue;
}
// .name -> .listName
entityplayer.playerConnection.sendPacket(new PacketPlayOutPlayerInfo(entityplayer1.listName, true, entityplayer1.ping));
// CraftBukkit end
}
}
public void d(EntityPlayer entityplayer) {
entityplayer.p().getPlayerChunkMap().movePlayer(entityplayer);
entityplayer.r().getPlayerChunkMap().movePlayer(entityplayer);
}
public String disconnect(EntityPlayer entityplayer) { // CraftBukkit - return string
if (entityplayer.playerConnection.disconnected) return null; // CraftBukkit - exploitsies fix
entityplayer.a(StatisticList.f);
// CraftBukkit start - Quitting must be before we do final save of data, in case plugins need to modify it
org.bukkit.craftbukkit.v1_6_R3.event.CraftEventFactory.handleInventoryCloseEvent(entityplayer);
org.bukkit.craftbukkit.v1_7_R1.event.CraftEventFactory.handleInventoryCloseEvent(entityplayer);
PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(this.cserver.getPlayer(entityplayer), "\u00A7e" + entityplayer.name + " left the game.");
PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(this.cserver.getPlayer(entityplayer), "\u00A7e" + entityplayer.getName() + " left the game.");
this.cserver.getPluginManager().callEvent(playerQuitEvent);
entityplayer.getBukkitEntity().disconnect(playerQuitEvent.getQuitMessage());
// CraftBukkit end
this.b(entityplayer);
WorldServer worldserver = entityplayer.p();
WorldServer worldserver = entityplayer.r();
if (entityplayer.vehicle != null && !(entityplayer.vehicle instanceof EntityPlayer)) { // CraftBukkit - Don't remove players
worldserver.removeEntity(entityplayer.vehicle);
// System.out.println("removing player mount"); // CraftBukkit - Removed debug message
d.debug("removing player mount");
}
worldserver.kill(entityplayer);
worldserver.getPlayerChunkMap().removePlayer(entityplayer);
this.players.remove(entityplayer);
this.k.remove(entityplayer.getName());
ChunkIOExecutor.adjustPoolSize(this.getPlayerCount()); // CraftBukkit
// CraftBukkit start - .name -> .listName, replace sendAll with loop
Packet201PlayerInfo packet = new Packet201PlayerInfo(entityplayer.listName, false, 9999);
// this.sendAll(new PacketPlayOutPlayerInfo(entityplayer.getName(), false, 9999));
PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(entityplayer.listName, false, 9999);
for (int i = 0; i < this.players.size(); ++i) {
EntityPlayer entityplayer1 = (EntityPlayer) this.players.get(i);
@ -332,52 +312,56 @@ public abstract class PlayerList {
// CraftBukkit end
}
// CraftBukkit start - Whole method and signature
public EntityPlayer attemptLogin(PendingConnection pendingconnection, String s, String hostname) {
// CraftBukkit start - Whole method, SocketAddress to LoginListener, added hostname to signature, return EntityPlayer
public EntityPlayer attemptLogin(LoginListener loginlistener, GameProfile gameprofile, String hostname) {
// Instead of kicking then returning, we need to store the kick reason
// in the event, check with plugins to see if it's ok, and THEN kick
// depending on the outcome.
EntityPlayer entity = new EntityPlayer(this.server, this.server.getWorldServer(0), s, this.server.O() ? new DemoPlayerInteractManager(this.server.getWorldServer(0)) : new PlayerInteractManager(this.server.getWorldServer(0)));
SocketAddress socketaddress = loginlistener.networkManager.getSocketAddress();
EntityPlayer entity = new EntityPlayer(this.server, this.server.getWorldServer(0), gameprofile, new PlayerInteractManager(this.server.getWorldServer(0)));
Player player = entity.getBukkitEntity();
PlayerLoginEvent event = new PlayerLoginEvent(player, hostname, pendingconnection.getSocket().getInetAddress());
PlayerLoginEvent event = new PlayerLoginEvent(player, hostname, ((java.net.InetSocketAddress) socketaddress).getAddress());
SocketAddress socketaddress = pendingconnection.networkManager.getSocketAddress();
if (this.banByName.isBanned(s)) {
BanEntry banentry = (BanEntry) this.banByName.getEntries().get(s);
String s1 = "You are banned from this server!\nReason: " + banentry.getReason();
if (this.banByName.isBanned(gameprofile.getName())) {
BanEntry banentry = (BanEntry) this.banByName.getEntries().get(gameprofile.getName());
String s = "You are banned from this server!\nReason: " + banentry.getReason();
if (banentry.getExpires() != null) {
s1 = s1 + "\nYour ban will be removed on " + d.format(banentry.getExpires());
s = s + "\nYour ban will be removed on " + e.format(banentry.getExpires());
}
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, s1);
} else if (!this.isWhitelisted(s)) {
// return s;
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, s);
} else if (!this.isWhitelisted(gameprofile.getName())) {
// return "You are not white-listed on this server!";
event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, "You are not white-listed on this server!");
} else {
String s2 = socketaddress.toString();
String s1 = socketaddress.toString();
s2 = s2.substring(s2.indexOf("/") + 1);
s2 = s2.substring(0, s2.indexOf(":"));
if (this.banByIP.isBanned(s2)) {
BanEntry banentry1 = (BanEntry) this.banByIP.getEntries().get(s2);
String s3 = "Your IP address is banned from this server!\nReason: " + banentry1.getReason();
s1 = s1.substring(s1.indexOf("/") + 1);
s1 = s1.substring(0, s1.indexOf(":"));
if (this.banByIP.isBanned(s1)) {
BanEntry banentry1 = (BanEntry) this.banByIP.getEntries().get(s1);
String s2 = "Your IP address is banned from this server!\nReason: " + banentry1.getReason();
if (banentry1.getExpires() != null) {
s3 = s3 + "\nYour ban will be removed on " + d.format(banentry1.getExpires());
s2 = s2 + "\nYour ban will be removed on " + e.format(banentry1.getExpires());
}
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, s3);
} else if (this.players.size() >= this.maxPlayers) {
event.disallow(PlayerLoginEvent.Result.KICK_FULL, "The server is full!");
// return s2;
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, s2);
} else {
event.disallow(PlayerLoginEvent.Result.ALLOWED, s2);
// return this.players.size() >= this.maxPlayers ? "The server is full!" : null;
if (this.players.size() >= this.maxPlayers) {
event.disallow(PlayerLoginEvent.Result.KICK_FULL, "The server is full!");
}
}
}
this.cserver.getPluginManager().callEvent(event);
if (event.getResult() != PlayerLoginEvent.Result.ALLOWED) {
pendingconnection.disconnect(event.getKickMessage());
loginlistener.disconnect(event.getKickMessage());
return null;
}
@ -385,15 +369,14 @@ public abstract class PlayerList {
// CraftBukkit end
}
public EntityPlayer processLogin(EntityPlayer player) { // CraftBukkit - String -> EntityPlayer
String s = player.name; // CraftBukkit
public EntityPlayer processLogin(GameProfile gameprofile, EntityPlayer player) { // CraftBukkit - added EntityPlayer
ArrayList arraylist = new ArrayList();
EntityPlayer entityplayer;
for (int i = 0; i < this.players.size(); ++i) {
entityplayer = (EntityPlayer) this.players.get(i);
if (entityplayer.getName().equalsIgnoreCase(s)) {
if (entityplayer.getName().equalsIgnoreCase(gameprofile.getName())) {
arraylist.add(entityplayer);
}
}
@ -408,14 +391,14 @@ public abstract class PlayerList {
/* CraftBukkit start
Object object;
if (this.server.O()) {
if (this.server.P()) {
object = new DemoPlayerInteractManager(this.server.getWorldServer(0));
} else {
object = new PlayerInteractManager(this.server.getWorldServer(0));
}
return new EntityPlayer(this.server, this.server.getWorldServer(0), s, (PlayerInteractManager) object);
*/
return new EntityPlayer(this.server, this.server.getWorldServer(0), gameprofile, (PlayerInteractManager) object);
// */
return player;
// CraftBukkit end
}
@ -427,22 +410,40 @@ public abstract class PlayerList {
public EntityPlayer moveToWorld(EntityPlayer entityplayer, int i, boolean flag, Location location, boolean avoidSuffocation) {
// CraftBukkit end
entityplayer.p().getTracker().untrackPlayer(entityplayer);
// entityplayer.p().getTracker().untrackEntity(entityplayer); // CraftBukkit
entityplayer.p().getPlayerChunkMap().removePlayer(entityplayer);
entityplayer.r().getTracker().untrackPlayer(entityplayer);
// entityplayer.r().getTracker().untrackEntity(entityplayer); // CraftBukkit
entityplayer.r().getPlayerChunkMap().removePlayer(entityplayer);
this.players.remove(entityplayer);
this.server.getWorldServer(entityplayer.dimension).removeEntity(entityplayer);
ChunkCoordinates chunkcoordinates = entityplayer.getBed();
boolean flag1 = entityplayer.isRespawnForced();
// CraftBukkit start
/* CraftBukkit start
entityplayer.dimension = i;
Object object;
if (this.server.P()) {
object = new DemoPlayerInteractManager(this.server.getWorldServer(entityplayer.dimension));
} else {
object = new PlayerInteractManager(this.server.getWorldServer(entityplayer.dimension));
}
EntityPlayer entityplayer1 = new EntityPlayer(this.server, this.server.getWorldServer(entityplayer.dimension), entityplayer.getProfile(), (PlayerInteractManager) object);
// */
EntityPlayer entityplayer1 = entityplayer;
org.bukkit.World fromWorld = entityplayer1.getBukkitEntity().getWorld();
entityplayer1.viewingCredits = false;
// CraftBukkit end
entityplayer1.playerConnection = entityplayer.playerConnection;
entityplayer1.copyTo(entityplayer, flag);
entityplayer1.d(entityplayer.getId());
// WorldServer worldserver = this.server.getWorldServer(entityplayer.dimension); // CraftBukkit - handled later
// this.a(entityplayer1, entityplayer, worldserver); // CraftBukkit - removed
ChunkCoordinates chunkcoordinates1;
// CraftBukkit start
if (location == null) {
boolean isBedSpawn = false;
CraftWorld cworld = (CraftWorld) this.server.server.getWorld(entityplayer.spawnWorld);
@ -453,7 +454,7 @@ public abstract class PlayerList {
location = new Location(cworld, chunkcoordinates1.x + 0.5, chunkcoordinates1.y, chunkcoordinates1.z + 0.5);
} else {
entityplayer1.setRespawnPosition(null, true);
entityplayer1.playerConnection.sendPacket(new Packet70Bed(0, 0));
entityplayer1.playerConnection.sendPacket(new PacketPlayOutGameStateChange(0, 0));
}
}
@ -485,29 +486,30 @@ public abstract class PlayerList {
// CraftBukkit start
byte actualDimension = (byte) (worldserver.getWorld().getEnvironment().getId());
// Force the client to refresh their chunk cache.
entityplayer1.playerConnection.sendPacket(new Packet9Respawn((byte) (actualDimension >= 0 ? -1 : 0), (byte) worldserver.difficulty, worldserver.getWorldData().getType(), worldserver.getHeight(), entityplayer.playerInteractManager.getGameMode()));
entityplayer1.playerConnection.sendPacket(new Packet9Respawn(actualDimension, (byte) worldserver.difficulty, worldserver.getWorldData().getType(), worldserver.getHeight(), entityplayer.playerInteractManager.getGameMode()));
entityplayer1.playerConnection.sendPacket(new PacketPlayOutRespawn((byte) (actualDimension >= 0 ? -1 : 0), worldserver.difficulty, worldserver.getWorldData().getType(), entityplayer.playerInteractManager.getGameMode()));
entityplayer1.playerConnection.sendPacket(new PacketPlayOutRespawn(actualDimension, worldserver.difficulty, worldserver.getWorldData().getType(), entityplayer1.playerInteractManager.getGameMode()));
entityplayer1.spawnIn(worldserver);
entityplayer1.dead = false;
entityplayer1.playerConnection.teleport(new Location(worldserver.getWorld(), entityplayer1.locX, entityplayer1.locY, entityplayer1.locZ, entityplayer1.yaw, entityplayer1.pitch));
entityplayer1.setSneaking(false);
chunkcoordinates1 = worldserver.getSpawn();
// entityplayer1.playerConnection.a(entityplayer1.locX, entityplayer1.locY, entityplayer1.locZ, entityplayer1.yaw, entityplayer1.pitch);
// CraftBukkit end
entityplayer1.playerConnection.sendPacket(new Packet6SpawnPosition(chunkcoordinates1.x, chunkcoordinates1.y, chunkcoordinates1.z));
entityplayer1.playerConnection.sendPacket(new Packet43SetExperience(entityplayer1.exp, entityplayer1.expTotal, entityplayer1.expLevel));
entityplayer1.playerConnection.sendPacket(new PacketPlayOutSpawnPosition(chunkcoordinates1.x, chunkcoordinates1.y, chunkcoordinates1.z));
entityplayer1.playerConnection.sendPacket(new PacketPlayOutExperience(entityplayer1.exp, entityplayer1.expTotal, entityplayer1.expLevel));
this.b(entityplayer1, worldserver);
worldserver.getPlayerChunkMap().addPlayer(entityplayer1);
worldserver.addEntity(entityplayer1);
this.players.add(entityplayer1);
// CraftBukkit start - Added from changeDimension
this.updateClient(entityplayer1); // CraftBukkit
this.updateClient(entityplayer1); // Update health, etc...
entityplayer1.updateAbilities();
Iterator iterator = entityplayer1.getEffects().iterator();
while (iterator.hasNext()) {
MobEffect mobeffect = (MobEffect) iterator.next();
entityplayer1.playerConnection.sendPacket(new Packet41MobEffect(entityplayer1.id, mobeffect));
entityplayer1.playerConnection.sendPacket(new PacketPlayOutEntityEffect(entityplayer1.getId(), mobeffect));
}
// entityplayer1.syncInventory();
// CraftBukkit end
@ -526,8 +528,10 @@ public abstract class PlayerList {
// CraftBukkit start - Replaced the standard handling of portals with a more customised method.
public void changeDimension(EntityPlayer entityplayer, int i, TeleportCause cause) {
WorldServer exitWorld = null;
System.out.println("dimension : " + i);
if (entityplayer.dimension < CraftWorld.CUSTOM_DIMENSION_OFFSET) { // plugins must specify exit from custom Bukkit worlds
// only target existing worlds (compensate for allow-nether/allow-end as false)
System.out.println("less than custom");
for (WorldServer world : this.server.worlds) {
if (world.dimension == i) {
exitWorld = world;
@ -535,13 +539,15 @@ public abstract class PlayerList {
}
}
System.out.println(exitWorld);
Location enter = entityplayer.getBukkitEntity().getLocation();
Location exit = null;
boolean useTravelAgent = false; // don't use agent for custom worlds or return from THE_END
if (exitWorld != null) {
if ((cause == TeleportCause.END_PORTAL) && (i == 0)) {
// THE_END -> NORMAL; use bed if available, otherwise default spawn
exit = ((org.bukkit.craftbukkit.v1_6_R3.entity.CraftPlayer) entityplayer.getBukkitEntity()).getBedSpawnLocation();
exit = ((org.bukkit.craftbukkit.v1_7_R1.entity.CraftPlayer) entityplayer.getBukkitEntity()).getBedSpawnLocation();
if (exit == null || ((CraftWorld) exit.getWorld()).getHandle().dimension != 0) {
exit = exitWorld.getWorld().getSpawnLocation();
}
@ -552,7 +558,7 @@ public abstract class PlayerList {
}
}
TravelAgent agent = exit != null ? (TravelAgent) ((CraftWorld) exit.getWorld()).getHandle().t() : org.bukkit.craftbukkit.v1_6_R3.CraftTravelAgent.DEFAULT; // return arbitrary TA to compensate for implementation dependent plugins
TravelAgent agent = exit != null ? (TravelAgent) ((CraftWorld) exit.getWorld()).getHandle().t() : org.bukkit.craftbukkit.v1_7_R1.CraftTravelAgent.DEFAULT; // return arbitrary TA to compensate for implementation dependent plugins
PlayerPortalEvent event = new PlayerPortalEvent(entityplayer.getBukkitEntity(), enter, exit, agent, cause);
event.useTravelAgent(useTravelAgent);
Bukkit.getServer().getPluginManager().callEvent(event);
@ -590,7 +596,7 @@ public abstract class PlayerList {
WorldServer worldserver = ((CraftWorld) enter.getWorld()).getHandle();
WorldServer worldserver1 = ((CraftWorld) target.getWorld()).getHandle();
int i = worldserver.dimension;
double y = enter.getY();
float yaw = enter.getYaw();
float pitch = enter.getPitch();
@ -631,7 +637,7 @@ public abstract class PlayerList {
worldserver1 = this.server.worlds.get(0);
chunkcoordinates = worldserver1.getSpawn();
} else {
chunkcoordinates = worldserver1.getSpawn();
chunkcoordinates = worldserver1.getDimensionSpawn();
}
d0 = (double) chunkcoordinates.x;
@ -663,8 +669,9 @@ public abstract class PlayerList {
worldserver.methodProfiler.b();
*/
}
// entity.spawnIn(worldserver1);
System.out.println(worldserver1.getWorld() + ": " + d0 + ", " + y + ", " + d1 + " ," + yaw + "," + pitch);
return new Location(worldserver1.getWorld(), d0, y, d1, yaw, pitch);
}
@ -730,9 +737,7 @@ public abstract class PlayerList {
d1 = (double) MathHelper.a((int) d1, -29999872, 29999872);
*/
if (entity.isAlive()) {
worldserver1.addEntity(entity);
// entity.setPositionRotation(d0, entity.locY, d1, entity.yaw, entity.pitch)
worldserver1.entityJoinedWorld(entity, false);
// worldserver1.s().a(entity, d3, d4, d5, f);
if (portal) {
Vector velocity = entity.getBukkitEntity().getVelocity();
@ -742,6 +747,8 @@ public abstract class PlayerList {
entity.getBukkitEntity().setVelocity(velocity);
}
}
worldserver1.addEntity(entity);
worldserver1.entityJoinedWorld(entity, false);
}
worldserver.methodProfiler.b();
@ -752,15 +759,15 @@ public abstract class PlayerList {
}
public void tick() {
if (++this.n > 600) {
this.n = 0;
if (++this.p > 600) {
this.p = 0;
}
/* CraftBukkit start - Remove updating of lag to players -- it spams way to much on big servers.
if (this.n < this.players.size()) {
EntityPlayer entityplayer = (EntityPlayer) this.players.get(this.n);
if (this.p < this.players.size()) {
EntityPlayer entityplayer = (EntityPlayer) this.players.get(this.p);
this.sendAll(new Packet201PlayerInfo(entityplayer.getName(), true, entityplayer.ping));
this.sendAll(new PacketPlayOutPlayerInfo(entityplayer.getName(), true, entityplayer.ping));
}
// CraftBukkit end */
}
@ -817,7 +824,7 @@ public abstract class PlayerList {
this.operators.add(s.toLowerCase());
// CraftBukkit start
Player player = server.server.getPlayer(s);
Player player = server.server.getPlayerExact(s);
if (player != null) {
player.recalculatePermissions();
}
@ -828,7 +835,7 @@ public abstract class PlayerList {
this.operators.remove(s.toLowerCase());
// CraftBukkit start
Player player = server.server.getPlayer(s);
Player player = server.server.getPlayerExact(s);
if (player != null) {
player.recalculatePermissions();
}
@ -841,8 +848,8 @@ public abstract class PlayerList {
}
public boolean isOp(String s) {
// CraftBukkit
return this.operators.contains(s.trim().toLowerCase()) || this.server.K() && this.server.worlds.get(0).getWorldData().allowCommands() && this.server.J().equalsIgnoreCase(s) || this.m;
// CraftBukkit - fix reference to worldserver array
return this.operators.contains(s.trim().toLowerCase()) || this.server.L() && this.server.worlds.get(0).getWorldData().allowCommands() && this.server.K().equalsIgnoreCase(s) || this.o;
}
public EntityPlayer getPlayer(String s) {
@ -884,7 +891,7 @@ public abstract class PlayerList {
for (int i2 = 0; i2 < this.players.size(); ++i2) {
EntityPlayer entityplayer = (EntityPlayer) this.players.get(i2);
if ((world == null || entityplayer.world == world) && (s == null || flag1 != s.equalsIgnoreCase(entityplayer.getLocalizedName()))) {
if ((world == null || entityplayer.world == world) && (s == null || flag1 != s.equalsIgnoreCase(entityplayer.getName()))) {
if (s1 != null) {
ScoreboardTeamBase scoreboardteambase = entityplayer.getScoreboardTeam();
String s2 = scoreboardteambase == null ? "" : scoreboardteambase.getName();
@ -895,7 +902,7 @@ public abstract class PlayerList {
}
if (chunkcoordinates != null && (i > 0 || j > 0)) {
float f = chunkcoordinates.e(entityplayer.b());
float f = chunkcoordinates.e(entityplayer.getChunkCoordinates());
if (i > 0 && f < (float) k1 || j > 0 && f > (float) l1) {
continue;
@ -953,7 +960,7 @@ public abstract class PlayerList {
return false;
}
ScoreboardScore scoreboardscore = entityhuman.getScoreboard().getPlayerScoreForObjective(entityhuman.getLocalizedName(), scoreboardobjective);
ScoreboardScore scoreboardscore = entityhuman.getScoreboard().getPlayerScoreForObjective(entityhuman.getName(), scoreboardobjective);
i = scoreboardscore.getScore();
if (i < ((Integer) entry.getValue()).intValue() && flag) {
@ -980,6 +987,7 @@ public abstract class PlayerList {
continue;
}
// CraftBukkit end
if (entityplayer != entityhuman && entityplayer.dimension == i) {
double d4 = d0 - entityplayer.locX;
double d5 = d1 - entityplayer.locY;
@ -1017,16 +1025,21 @@ public abstract class PlayerList {
public void reloadWhitelist() {}
public void b(EntityPlayer entityplayer, WorldServer worldserver) {
entityplayer.playerConnection.sendPacket(new Packet4UpdateTime(worldserver.getTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean("doDaylightCycle")));
if (worldserver.Q()) {
entityplayer.setPlayerWeather(org.bukkit.WeatherType.DOWNFALL, false); // CraftBukkit - handle player specific weather
entityplayer.playerConnection.sendPacket(new PacketPlayOutUpdateTime(worldserver.getTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean("doDaylightCycle")));
if (worldserver.P()) {
// CraftBukkit start - handle player weather
// entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(1, 0.0F));
// entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(7, worldserver.j(1.0F)));
// entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(8, worldserver.h(1.0F)));
entityplayer.setPlayerWeather(org.bukkit.WeatherType.DOWNFALL, false);
// CraftBukkit end
}
}
public void updateClient(EntityPlayer entityplayer) {
entityplayer.updateInventory(entityplayer.defaultContainer);
entityplayer.getBukkitEntity().updateScaledHealth(); // CraftBukkit - Update scaled health on respawn and worldchange
entityplayer.playerConnection.sendPacket(new Packet16BlockItemSwitch(entityplayer.inventory.itemInHandIndex));
entityplayer.playerConnection.sendPacket(new PacketPlayOutHeldItemSlot(entityplayer.inventory.itemInHandIndex));
}
public int getPlayerCount() {
@ -1038,7 +1051,8 @@ public abstract class PlayerList {
}
public String[] getSeenPlayers() {
return this.server.worlds.get(0).getDataManager().getPlayerFileData().getSeenPlayers(); // CraftBukkit
// CraftBukkit - fix reference to worldserver array
return this.server.worlds.get(0).getDataManager().getPlayerFileData().getSeenPlayers();
}
public boolean getHasWhitelist() {
@ -1049,14 +1063,14 @@ public abstract class PlayerList {
this.hasWhitelist = flag;
}
public List i(String s) {
public List h(String s) {
ArrayList arraylist = new ArrayList();
Iterator iterator = this.players.iterator();
while (iterator.hasNext()) {
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
if (entityplayer.q().equals(s)) {
if (entityplayer.s().equals(s)) {
arraylist.add(entityplayer);
}
}
@ -1079,25 +1093,45 @@ public abstract class PlayerList {
private void a(EntityPlayer entityplayer, EntityPlayer entityplayer1, World world) {
if (entityplayer1 != null) {
entityplayer.playerInteractManager.setGameMode(entityplayer1.playerInteractManager.getGameMode());
} else if (this.l != null) {
entityplayer.playerInteractManager.setGameMode(this.l);
} else if (this.n != null) {
entityplayer.playerInteractManager.setGameMode(this.n);
}
entityplayer.playerInteractManager.b(world.getWorldData().getGameType());
}
public void r() {
while (!this.players.isEmpty()) {
((EntityPlayer) this.players.get(0)).playerConnection.disconnect(this.server.server.getShutdownMessage()); // CraftBukkit - add custom shutdown message
for (int i = 0; i < this.players.size(); ++i) {
((EntityPlayer) this.players.get(i)).playerConnection.disconnect(this.server.server.getShutdownMessage()); // CraftBukkit - add custom shutdown message
}
}
public void sendMessage(ChatMessage chatmessage, boolean flag) {
this.server.sendMessage(chatmessage);
this.sendAll(new Packet3Chat(chatmessage, flag));
// CraftBukkit start - Support multi-line messages
public void sendMessage(IChatBaseComponent[] ichatbasecomponent) {
for (IChatBaseComponent component : ichatbasecomponent) {
sendMessage(component, true);
}
}
// CraftBukkit end
public void sendMessage(IChatBaseComponent ichatbasecomponent, boolean flag) {
this.server.sendMessage(ichatbasecomponent);
this.sendAll(new PacketPlayOutChat(ichatbasecomponent, flag));
}
public void sendMessage(ChatMessage chatmessage) {
this.sendMessage(chatmessage, true);
public void sendMessage(IChatBaseComponent ichatbasecomponent) {
this.sendMessage(ichatbasecomponent, true);
}
}
public ServerStatisticManager i(String s) {
ServerStatisticManager serverstatisticmanager = (ServerStatisticManager) this.k.get(s);
if (serverstatisticmanager == null) {
serverstatisticmanager = new ServerStatisticManager(this.server, new File(this.server.getWorldServer(0).getDataManager().getDirectory(), "stats/" + s + ".json"));
serverstatisticmanager.a();
this.k.put(s, serverstatisticmanager);
}
return serverstatisticmanager;
}
}

View File

@ -1,4 +1,4 @@
package org.bukkit.craftbukkit.v1_6_R3.entity;
package org.bukkit.craftbukkit.v1_7_R1.entity;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.MapMaker;
@ -16,32 +16,32 @@ import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.minecraft.server.v1_6_R3.*;
import net.minecraft.server.v1_7_R1.*;
import org.apache.commons.lang.Validate;
import org.apache.commons.lang.NotImplementedException;
import org.bukkit.*;
import org.bukkit.Achievement;
import org.bukkit.Material;
import org.bukkit.Statistic;
import org.bukkit.Statistic.Type;
import org.bukkit.World;
import org.bukkit.configuration.serialization.DelegateDeserialization;
import org.bukkit.conversations.Conversation;
import org.bukkit.conversations.ConversationAbandonedEvent;
import org.bukkit.conversations.ManuallyAbandonedConversationCanceller;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftHumanEntity;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_6_R3.conversations.ConversationTracker;
import org.bukkit.craftbukkit.v1_6_R3.CraftEffect;
import org.bukkit.craftbukkit.v1_6_R3.CraftOfflinePlayer;
import org.bukkit.craftbukkit.v1_6_R3.CraftServer;
import org.bukkit.craftbukkit.v1_6_R3.CraftSound;
import org.bukkit.craftbukkit.v1_6_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_6_R3.map.CraftMapView;
import org.bukkit.craftbukkit.v1_6_R3.map.RenderData;
import org.bukkit.craftbukkit.v1_6_R3.scoreboard.CraftScoreboard;
import org.bukkit.entity.Entity;
import org.bukkit.craftbukkit.v1_7_R1.conversations.ConversationTracker;
import org.bukkit.craftbukkit.v1_7_R1.CraftEffect;
import org.bukkit.craftbukkit.v1_7_R1.CraftOfflinePlayer;
import org.bukkit.craftbukkit.v1_7_R1.CraftServer;
import org.bukkit.craftbukkit.v1_7_R1.CraftSound;
import org.bukkit.craftbukkit.v1_7_R1.CraftStatistic;
import org.bukkit.craftbukkit.v1_7_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_7_R1.map.CraftMapView;
import org.bukkit.craftbukkit.v1_7_R1.map.RenderData;
import org.bukkit.craftbukkit.v1_7_R1.scoreboard.CraftScoreboard;
import org.bukkit.craftbukkit.v1_7_R1.util.CraftChatMessage;
import org.bukkit.craftbukkit.v1_7_R1.util.CraftMagicNumbers;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerGameModeChangeEvent;
@ -52,7 +52,6 @@ import org.bukkit.inventory.InventoryView.Property;
import org.bukkit.map.MapView;
import org.bukkit.metadata.MetadataValue;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.messaging.Messenger;
import org.bukkit.plugin.messaging.StandardMessenger;
import org.bukkit.scoreboard.Scoreboard;
@ -132,36 +131,45 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
}
@Override
public void sendRawMessage(String message) {
if (getHandle().playerConnection == null) return;
getHandle().playerConnection.sendPacket(new Packet3Chat(ChatMessage.d(message)));
for (IChatBaseComponent component : CraftChatMessage.fromString(message)) {
getHandle().playerConnection.sendPacket(new PacketPlayOutChat(component));
}
}
@Override
public void sendMessage(String message) {
if (!conversationTracker.isConversingModaly()) {
this.sendRawMessage(message);
}
}
@Override
public void sendMessage(String[] messages) {
for (String message : messages) {
sendMessage(message);
}
}
@Override
public String getDisplayName() {
return getHandle().displayName;
}
@Override
public void setDisplayName(final String name) {
getHandle().displayName = name;
}
@Override
public String getPlayerListName() {
return getHandle().listName;
}
@Override
public void setPlayerListName(String name) {
String oldName = getHandle().listName;
@ -187,8 +195,8 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
getHandle().listName = name;
// Change the name on the client side
Packet201PlayerInfo oldpacket = new Packet201PlayerInfo(oldName, false, 9999);
Packet201PlayerInfo packet = new Packet201PlayerInfo(name, true, getHandle().ping);
PacketPlayOutPlayerInfo oldpacket = new PacketPlayOutPlayerInfo(oldName, false, 9999);
PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(name, true, getHandle().ping);
for (int i = 0; i < server.getHandle().players.size(); ++i) {
EntityPlayer entityplayer = (EntityPlayer) server.getHandle().players.get(i);
if (entityplayer.playerConnection == null) continue;
@ -220,54 +228,97 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
return nameEquals && idEquals;
}
@Override
public void kickPlayer(String message) {
if (getHandle().playerConnection == null) return;
getHandle().playerConnection.disconnect(message == null ? "" : message);
}
@Override
public void setCompassTarget(Location loc) {
if (getHandle().playerConnection == null) return;
// Do not directly assign here, from the packethandler we'll assign it.
getHandle().playerConnection.sendPacket(new Packet6SpawnPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
getHandle().playerConnection.sendPacket(new PacketPlayOutSpawnPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
}
@Override
public Location getCompassTarget() {
return getHandle().compassTarget;
}
@Override
public void chat(String msg) {
if (getHandle().playerConnection == null) return;
getHandle().playerConnection.chat(msg, false);
}
@Override
public boolean performCommand(String command) {
return server.dispatchCommand(this, command);
}
@Override
public void playNote(Location loc, byte instrument, byte note) {
if (getHandle().playerConnection == null) return;
int id = getHandle().world.getTypeId(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
getHandle().playerConnection.sendPacket(new Packet54PlayNoteBlock(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), id, instrument, note));
String instrumentName = null;
switch (instrument) {
case 0:
instrumentName = "harp";
break;
case 1:
instrumentName = "bd";
break;
case 2:
instrumentName = "snare";
break;
case 3:
instrumentName = "hat";
break;
case 4:
instrumentName = "bassattack";
break;
}
getHandle().playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect("note."+instrumentName, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, note));
}
@Override
public void playNote(Location loc, Instrument instrument, Note note) {
if (getHandle().playerConnection == null) return;
int id = getHandle().world.getTypeId(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
getHandle().playerConnection.sendPacket(new Packet54PlayNoteBlock(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), id, instrument.getType(), note.getId()));
String instrumentName = null;
switch (instrument.ordinal()) {
case 0:
instrumentName = "harp";
break;
case 1:
instrumentName = "bd";
break;
case 2:
instrumentName = "snare";
break;
case 3:
instrumentName = "hat";
break;
case 4:
instrumentName = "bassattack";
break;
}
getHandle().playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect("note."+instrumentName, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, note.getId()));
}
@Override
public void playSound(Location loc, Sound sound, float volume, float pitch) {
if (sound == null) {
return;
}
playSound(loc, CraftSound.getSound(sound), volume, pitch);
if (sound == null) {
return;
}
playSound(loc, CraftSound.getSound(sound), volume, pitch);
}
@Override
public void playSound(Location loc, String sound, float volume, float pitch) {
if (loc == null || sound == null || getHandle().playerConnection == null) return;
@ -275,18 +326,20 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
double y = loc.getBlockY() + 0.5;
double z = loc.getBlockZ() + 0.5;
Packet62NamedSoundEffect packet = new Packet62NamedSoundEffect(sound, x, y, z, volume, pitch);
PacketPlayOutNamedSoundEffect packet = new PacketPlayOutNamedSoundEffect(sound, x, y, z, volume, pitch);
getHandle().playerConnection.sendPacket(packet);
}
@Override
public void playEffect(Location loc, Effect effect, int data) {
if (getHandle().playerConnection == null) return;
int packetData = effect.getId();
Packet61WorldEvent packet = new Packet61WorldEvent(packetData, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), data, false);
PacketPlayOutWorldEvent packet = new PacketPlayOutWorldEvent(packetData, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), data, false);
getHandle().playerConnection.sendPacket(packet);
}
@Override
public <T> void playEffect(Location loc, Effect effect, T data) {
if (data != null) {
Validate.isTrue(data.getClass().equals(effect.getData()), "Wrong kind of data for this effect!");
@ -298,20 +351,23 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
playEffect(loc, effect, datavalue);
}
@Override
public void sendBlockChange(Location loc, Material material, byte data) {
sendBlockChange(loc, material.getId(), data);
}
@Override
public void sendBlockChange(Location loc, int material, byte data) {
if (getHandle().playerConnection == null) return;
Packet53BlockChange packet = new Packet53BlockChange(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), ((CraftWorld) loc.getWorld()).getHandle());
PacketPlayOutBlockChange packet = new PacketPlayOutBlockChange(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), ((CraftWorld) loc.getWorld()).getHandle());
packet.material = material;
packet.block = CraftMagicNumbers.getBlock(material);
packet.data = data;
getHandle().playerConnection.sendPacket(packet);
}
@Override
public boolean sendChunkChange(Location loc, int sx, int sy, int sz, byte[] data) {
if (getHandle().playerConnection == null) return false;
@ -345,6 +401,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
throw new NotImplementedException("Chunk changes do not yet work"); // TODO: Chunk changes.
}
@Override
public void sendMap(MapView map) {
if (getHandle().playerConnection == null) return;
@ -355,7 +412,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
for (int y = 0; y < 128; ++y) {
bytes[y + 3] = data.buffer[y * 128 + x];
}
Packet131ItemData packet = new Packet131ItemData((short) Material.MAP.getId(), map.getId(), bytes);
PacketPlayOutMap packet = new PacketPlayOutMap(map.getId(), bytes);
getHandle().playerConnection.sendPacket(packet);
}
}
@ -368,7 +425,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
return false;
}
if (entity.playerConnection == null || entity.playerConnection.disconnected) {
if (entity.playerConnection == null || entity.playerConnection.isDisconnected()) {
return false;
}
@ -411,125 +468,251 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
return true;
}
@Override
public void setSneaking(boolean sneak) {
getHandle().setSneaking(sneak);
}
@Override
public boolean isSneaking() {
return getHandle().isSneaking();
}
@Override
public boolean isSprinting() {
return getHandle().isSprinting();
}
@Override
public void setSprinting(boolean sprinting) {
getHandle().setSprinting(sprinting);
}
@Override
public void loadData() {
server.getHandle().playerFileData.load(getHandle());
}
@Override
public void saveData() {
server.getHandle().playerFileData.save(getHandle());
}
@Deprecated
@Override
public void updateInventory() {
getHandle().updateInventory(getHandle().activeContainer);
}
@Override
public void setSleepingIgnored(boolean isSleeping) {
getHandle().fauxSleeping = isSleeping;
((CraftWorld) getWorld()).getHandle().checkSleepStatus();
}
@Override
public boolean isSleepingIgnored() {
return getHandle().fauxSleeping;
}
@Override
public void awardAchievement(Achievement achievement) {
sendStatistic(achievement.getId(), 1);
Validate.notNull(achievement, "Achievement cannot be null");
if (achievement.hasParent() && !hasAchievement(achievement.getParent())) {
awardAchievement(achievement.getParent());
}
getHandle().x().a(getHandle(), CraftStatistic.getNMSAchievement(achievement), 1);
getHandle().x().b(getHandle());
}
@Override
public void removeAchievement(Achievement achievement) {
Validate.notNull(achievement, "Achievement cannot be null");
for (Achievement achieve : Achievement.values()) {
if (achieve.getParent() == achievement && hasAchievement(achieve)) {
removeAchievement(achieve);
}
}
getHandle().x().a(getHandle(), CraftStatistic.getNMSAchievement(achievement), 0);
}
@Override
public boolean hasAchievement(Achievement achievement) {
Validate.notNull(achievement, "Achievement cannot be null");
return getHandle().x().a(CraftStatistic.getNMSAchievement(achievement));
}
@Override
public void incrementStatistic(Statistic statistic) {
incrementStatistic(statistic, 1);
}
public void incrementStatistic(Statistic statistic, int amount) {
sendStatistic(statistic.getId(), amount);
@Override
public void decrementStatistic(Statistic statistic) {
decrementStatistic(statistic, 1);
}
@Override
public int getStatistic(Statistic statistic) {
Validate.notNull(statistic, "Statistic cannot be null");
Validate.isTrue(statistic.getType() == Type.UNTYPED, "Must supply additional paramater for this statistic");
return getHandle().x().a(CraftStatistic.getNMSStatistic(statistic));
}
@Override
public void incrementStatistic(Statistic statistic, int amount) {
Validate.isTrue(amount > 0, "Amount must be greater than 0");
setStatistic(statistic, getStatistic(statistic) + amount);
}
@Override
public void decrementStatistic(Statistic statistic, int amount) {
Validate.isTrue(amount > 0, "Amount must be greater than 0");
setStatistic(statistic, getStatistic(statistic) - amount);
}
@Override
public void setStatistic(Statistic statistic, int newValue) {
Validate.notNull(statistic, "Statistic cannot be null");
Validate.isTrue(statistic.getType() == Type.UNTYPED, "Must supply additional paramater for this statistic");
Validate.isTrue(newValue >= 0, "Value must be greater than or equal to 0");
net.minecraft.server.v1_7_R1.Statistic nmsStatistic = CraftStatistic.getNMSStatistic(statistic);
getHandle().x().a(getHandle(), nmsStatistic, newValue);
}
@Override
public void incrementStatistic(Statistic statistic, Material material) {
incrementStatistic(statistic, material, 1);
}
@Override
public void decrementStatistic(Statistic statistic, Material material) {
decrementStatistic(statistic, material, 1);
}
@Override
public int getStatistic(Statistic statistic, Material material) {
Validate.notNull(statistic, "Statistic cannot be null");
Validate.notNull(material, "Material cannot be null");
Validate.isTrue(statistic.getType() == Type.BLOCK || statistic.getType() == Type.ITEM, "This statistic does not take a Material parameter");
net.minecraft.server.v1_7_R1.Statistic nmsStatistic = CraftStatistic.getMaterialStatistic(statistic, material);
Validate.notNull(nmsStatistic, "The supplied Material does not have a corresponding statistic");
return getHandle().x().a(nmsStatistic);
}
@Override
public void incrementStatistic(Statistic statistic, Material material, int amount) {
if (!statistic.isSubstatistic()) {
throw new IllegalArgumentException("Given statistic is not a substatistic");
}
if (statistic.isBlock() != material.isBlock()) {
throw new IllegalArgumentException("Given material is not valid for this substatistic");
}
int mat = material.getId();
if (!material.isBlock()) {
mat -= 255;
}
sendStatistic(statistic.getId() + mat, amount);
Validate.isTrue(amount > 0, "Amount must be greater than 0");
setStatistic(statistic, material, getStatistic(statistic, material) + amount);
}
private void sendStatistic(int id, int amount) {
if (getHandle().playerConnection == null) return;
while (amount > Byte.MAX_VALUE) {
sendStatistic(id, Byte.MAX_VALUE);
amount -= Byte.MAX_VALUE;
}
getHandle().playerConnection.sendPacket(new Packet200Statistic(id, amount));
@Override
public void decrementStatistic(Statistic statistic, Material material, int amount) {
Validate.isTrue(amount > 0, "Amount must be greater than 0");
setStatistic(statistic, material, getStatistic(statistic, material) - amount);
}
@Override
public void setStatistic(Statistic statistic, Material material, int newValue) {
Validate.notNull(statistic, "Statistic cannot be null");
Validate.notNull(material, "Material cannot be null");
Validate.isTrue(newValue >= 0, "Value must be greater than or equal to 0");
Validate.isTrue(statistic.getType() == Type.BLOCK || statistic.getType() == Type.ITEM, "This statistic does not take a Material parameter");
net.minecraft.server.v1_7_R1.Statistic nmsStatistic = CraftStatistic.getMaterialStatistic(statistic, material);
Validate.notNull(nmsStatistic, "The supplied Material does not have a corresponding statistic");
getHandle().x().a(getHandle(), nmsStatistic, newValue);
}
@Override
public void incrementStatistic(Statistic statistic, EntityType entityType) {
incrementStatistic(statistic, entityType, 1);
}
@Override
public void decrementStatistic(Statistic statistic, EntityType entityType) {
decrementStatistic(statistic, entityType, 1);
}
@Override
public int getStatistic(Statistic statistic, EntityType entityType) {
Validate.notNull(statistic, "Statistic cannot be null");
Validate.notNull(entityType, "EntityType cannot be null");
Validate.isTrue(statistic.getType() == Type.ENTITY, "This statistic does not take an EntityType parameter");
net.minecraft.server.v1_7_R1.Statistic nmsStatistic = CraftStatistic.getEntityStatistic(statistic, entityType);
Validate.notNull(nmsStatistic, "The supplied EntityType does not have a corresponding statistic");
return getHandle().x().a(nmsStatistic);
}
@Override
public void incrementStatistic(Statistic statistic, EntityType entityType, int amount) {
Validate.isTrue(amount > 0, "Amount must be greater than 0");
setStatistic(statistic, entityType, getStatistic(statistic, entityType) + amount);
}
@Override
public void decrementStatistic(Statistic statistic, EntityType entityType, int amount) {
Validate.isTrue(amount > 0, "Amount must be greater than 0");
setStatistic(statistic, entityType, getStatistic(statistic, entityType) - amount);
}
@Override
public void setStatistic(Statistic statistic, EntityType entityType, int newValue) {
Validate.notNull(statistic, "Statistic cannot be null");
Validate.notNull(entityType, "EntityType cannot be null");
Validate.isTrue(newValue >= 0, "Value must be greater than or equal to 0");
Validate.isTrue(statistic.getType() == Type.ENTITY, "This statistic does not take an EntityType parameter");
net.minecraft.server.v1_7_R1.Statistic nmsStatistic = CraftStatistic.getEntityStatistic(statistic, entityType);
Validate.notNull(nmsStatistic, "The supplied EntityType does not have a corresponding statistic");
getHandle().x().a(getHandle(), nmsStatistic, newValue);
}
@Override
public void setPlayerTime(long time, boolean relative) {
getHandle().timeOffset = time;
getHandle().relativeTime = relative;
}
@Override
public long getPlayerTimeOffset() {
return getHandle().timeOffset;
}
@Override
public long getPlayerTime() {
return getHandle().getPlayerTime();
}
@Override
public boolean isPlayerTimeRelative() {
return getHandle().relativeTime;
}
@Override
public void resetPlayerTime() {
setPlayerTime(0, true);
}
@Override
public void setPlayerWeather(WeatherType type) {
getHandle().setPlayerWeather(type, true);
}
@Override
public WeatherType getPlayerWeather() {
return getHandle().getPlayerWeather();
}
@Override
public void resetPlayerWeather() {
getHandle().resetPlayerWeather();
}
@Override
public boolean isBanned() {
return server.getHandle().getNameBans().isBanned(getName().toLowerCase());
}
@Override
public void setBanned(boolean value) {
if (value) {
BanEntry entry = new BanEntry(getName().toLowerCase());
@ -541,10 +724,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
server.getHandle().getNameBans().save();
}
@Override
public boolean isWhitelisted() {
return server.getHandle().getWhitelisted().contains(getName().toLowerCase());
}
@Override
public void setWhitelisted(boolean value) {
if (value) {
server.getHandle().addWhitelist(getName().toLowerCase());
@ -569,7 +754,8 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
getHandle().playerInteractManager.setGameMode(EnumGamemode.a(mode.getValue()));
getHandle().playerConnection.sendPacket(new Packet70Bed(3, mode.getValue()));
getHandle().fallDistance = 0;
getHandle().playerConnection.sendPacket(new PacketPlayOutGameStateChange(3, mode.getValue()));
}
}
@ -676,14 +862,14 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
//remove this player from the hidden player's EntityTrackerEntry
EntityTracker tracker = ((WorldServer) entity.world).tracker;
EntityPlayer other = ((CraftPlayer) player).getHandle();
EntityTrackerEntry entry = (EntityTrackerEntry) tracker.trackedEntities.get(other.id);
EntityTrackerEntry entry = (EntityTrackerEntry) tracker.trackedEntities.get(other.getId());
if (entry != null) {
entry.clear(getHandle());
}
//remove the hidden player from this player user list
if (hideList)
getHandle().playerConnection.sendPacket(new Packet201PlayerInfo(player.getPlayerListName(), false, 9999));
getHandle().playerConnection.sendPacket(new PacketPlayOutPlayerInfo(player.getPlayerListName(), false, 9999));
}
public void showPlayer(Player player) {
@ -695,12 +881,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
EntityTracker tracker = ((WorldServer) entity.world).tracker;
EntityPlayer other = ((CraftPlayer) player).getHandle();
EntityTrackerEntry entry = (EntityTrackerEntry) tracker.trackedEntities.get(other.id);
EntityTrackerEntry entry = (EntityTrackerEntry) tracker.trackedEntities.get(other.getId());
if (entry != null && !entry.trackedPlayers.contains(getHandle())) {
entry.updatePlayer(getHandle());
}
getHandle().playerConnection.sendPacket(new Packet201PlayerInfo(player.getPlayerListName(), true, getHandle().ping));
getHandle().playerConnection.sendPacket(new PacketPlayOutPlayerInfo(player.getPlayerListName(), true, getHandle().ping));
}
public boolean canSee(Player player) {
@ -780,7 +966,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
public void setExtraData(NBTTagCompound nbttagcompound) {
if (!nbttagcompound.hasKey("bukkit")) {
nbttagcompound.setCompound("bukkit", new NBTTagCompound());
nbttagcompound.set("bukkit", new NBTTagCompound());
}
NBTTagCompound data = nbttagcompound.getCompound("bukkit");
@ -819,21 +1005,20 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
if (getHandle().playerConnection == null) return;
if (channels.contains(channel)) {
Packet250CustomPayload packet = new Packet250CustomPayload();
packet.tag = channel;
packet.length = message.length;
packet.data = message;
PacketPlayOutCustomPayload packet = new PacketPlayOutCustomPayload(channel, message);
getHandle().playerConnection.sendPacket(packet);
}
}
public void setTexturePack(String url) {
Validate.notNull(url, "Texture pack URL cannot be null");
setResourcePack(url);
}
byte[] message = (url + "\0" + "16").getBytes();
Validate.isTrue(message.length <= Messenger.MAX_MESSAGE_SIZE, "Texture pack URL is too long");
@Override
public void setResourcePack(String url) {
Validate.notNull(url, "Resource pack URL cannot be null");
getHandle().playerConnection.sendPacket(new Packet250CustomPayload("MC|TPack", message));
getHandle().a(url); // should be setResourcePack
}
public void addChannel(String channel) {
@ -857,9 +1042,6 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
Set<String> listening = server.getMessenger().getIncomingChannels();
if (!listening.isEmpty()) {
Packet250CustomPayload packet = new Packet250CustomPayload();
packet.tag = "REGISTER";
ByteArrayOutputStream stream = new ByteArrayOutputStream();
for (String channel : listening) {
@ -871,10 +1053,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
}
packet.data = stream.toByteArray();
packet.length = packet.data.length;
getHandle().playerConnection.sendPacket(packet);
getHandle().playerConnection.sendPacket(new PacketPlayOutCustomPayload("REGISTER", stream.toByteArray()));
}
}
@ -1011,7 +1190,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
if (playerConnection == null) {
throw new IllegalStateException("Cannot set scoreboard yet");
}
if (playerConnection.disconnected) {
if (playerConnection.isDisconnected()) {
throw new IllegalStateException("Cannot set scoreboard for invalid CraftPlayer");
}
@ -1053,14 +1232,14 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
public void updateScaledHealth() {
AttributeMapServer attributemapserver = (AttributeMapServer) getHandle().aX();
AttributeMapServer attributemapserver = (AttributeMapServer) getHandle().bc();
Set set = attributemapserver.b();
injectScaledMaxHealth(set, true);
getHandle().getDataWatcher().watch(6, (float) getScaledHealth());
getHandle().playerConnection.sendPacket(new Packet8UpdateHealth(getScaledHealth(), getHandle().getFoodData().a(), getHandle().getFoodData().e()));
getHandle().playerConnection.sendPacket(new Packet44UpdateAttributes(getHandle().id, set));
getHandle().playerConnection.sendPacket(new PacketPlayOutUpdateHealth(getScaledHealth(), getHandle().getFoodData().a(), getHandle().getFoodData().e()));
getHandle().playerConnection.sendPacket(new PacketPlayOutUpdateAttributes(getHandle().getId(), set));
set.clear();
getHandle().maxHealthCache = getMaxHealth();
@ -1078,6 +1257,6 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
continue;
}
collection.add(new AttributeModifiable(getHandle().aX(), (new AttributeRanged("generic.maxHealth", scaledHealth ? healthScale : getMaxHealth(), 0.0D, Float.MAX_VALUE)).a("Max Health").a(true)));
collection.add(new AttributeModifiable(getHandle().bc(), (new AttributeRanged("generic.maxHealth", scaledHealth ? healthScale : getMaxHealth(), 0.0D, Float.MAX_VALUE)).a("Max Health").a(true)));
}
}

View File

@ -1,6 +1,7 @@
package org.bukkit.craftbukkit.v1_6_R3.inventory;
package org.bukkit.craftbukkit.v1_7_R1.inventory;
import org.bukkit.craftbukkit.v1_6_R3.inventory.CraftInventory;
import org.bukkit.craftbukkit.v1_7_R1.inventory.MinecraftInventory;
import org.bukkit.craftbukkit.v1_7_R1.inventory.CraftInventory;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.InventoryHolder;

View File

@ -1,29 +1,20 @@
package org.bukkit.craftbukkit.v1_6_R3.inventory;
package org.bukkit.craftbukkit.v1_7_R1.inventory;
import static org.bukkit.craftbukkit.v1_6_R3.inventory.CraftMetaItem.ENCHANTMENTS;
import static org.bukkit.craftbukkit.v1_6_R3.inventory.CraftMetaItem.ENCHANTMENTS_ID;
import static org.bukkit.craftbukkit.v1_6_R3.inventory.CraftMetaItem.ENCHANTMENTS_LVL;
import static org.bukkit.craftbukkit.v1_7_R1.inventory.CraftMetaItem.ENCHANTMENTS;
import static org.bukkit.craftbukkit.v1_7_R1.inventory.CraftMetaItem.ENCHANTMENTS_ID;
import static org.bukkit.craftbukkit.v1_7_R1.inventory.CraftMetaItem.ENCHANTMENTS_LVL;
import java.util.Map;
import net.minecraft.server.v1_6_R3.EnchantmentManager;
import net.minecraft.server.v1_6_R3.NBTTagCompound;
import net.minecraft.server.v1_6_R3.NBTTagList;
import net.minecraft.server.v1_7_R1.EnchantmentManager;
import net.minecraft.server.v1_7_R1.Item;
import net.minecraft.server.v1_7_R1.NBTTagCompound;
import net.minecraft.server.v1_7_R1.NBTTagList;
import org.apache.commons.lang.Validate;
import org.bukkit.Material;
import org.bukkit.configuration.serialization.DelegateDeserialization;
import org.bukkit.craftbukkit.v1_6_R3.inventory.CraftItemFactory;
import org.bukkit.craftbukkit.v1_6_R3.inventory.CraftItemStack;
import org.bukkit.craftbukkit.v1_6_R3.inventory.CraftMetaBook;
import org.bukkit.craftbukkit.v1_6_R3.inventory.CraftMetaCharge;
import org.bukkit.craftbukkit.v1_6_R3.inventory.CraftMetaEnchantedBook;
import org.bukkit.craftbukkit.v1_6_R3.inventory.CraftMetaFirework;
import org.bukkit.craftbukkit.v1_6_R3.inventory.CraftMetaItem;
import org.bukkit.craftbukkit.v1_6_R3.inventory.CraftMetaLeatherArmor;
import org.bukkit.craftbukkit.v1_6_R3.inventory.CraftMetaMap;
import org.bukkit.craftbukkit.v1_6_R3.inventory.CraftMetaPotion;
import org.bukkit.craftbukkit.v1_6_R3.inventory.CraftMetaSkull;
import org.bukkit.craftbukkit.v1_7_R1.util.CraftMagicNumbers;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
@ -33,7 +24,7 @@ import com.google.common.collect.ImmutableMap;
@DelegateDeserialization(ItemStack.class)
public class CraftItemStack extends ItemStack {
public static net.minecraft.server.v1_6_R3.ItemStack asNMSCopy(ItemStack original) {
public static net.minecraft.server.v1_7_R1.ItemStack asNMSCopy(ItemStack original) {
if (original instanceof CraftItemStack) {
CraftItemStack stack = (CraftItemStack) original;
return stack.handle == null ? null : stack.handle.cloneItemStack();
@ -41,15 +32,22 @@ public class CraftItemStack extends ItemStack {
if (original == null || original.getTypeId() <= 0) {
return null;
}
net.minecraft.server.v1_6_R3.ItemStack stack = new net.minecraft.server.v1_6_R3.ItemStack(original.getTypeId(), original.getAmount(), original.getDurability());
Item item = CraftMagicNumbers.getItem(original.getType());
if (item == null) {
return null;
}
net.minecraft.server.v1_7_R1.ItemStack stack = new net.minecraft.server.v1_7_R1.ItemStack(item, original.getAmount(), original.getDurability());
if (original.hasItemMeta()) {
setItemMeta(stack, original.getItemMeta());
}
return stack;
}
public static net.minecraft.server.v1_6_R3.ItemStack copyNMSStack(net.minecraft.server.v1_6_R3.ItemStack original, int amount) {
net.minecraft.server.v1_6_R3.ItemStack stack = original.cloneItemStack();
public static net.minecraft.server.v1_7_R1.ItemStack copyNMSStack(net.minecraft.server.v1_7_R1.ItemStack original, int amount) {
net.minecraft.server.v1_7_R1.ItemStack stack = original.cloneItemStack();
stack.count = amount;
return stack;
}
@ -57,18 +55,18 @@ public class CraftItemStack extends ItemStack {
/**
* Copies the NMS stack to return as a strictly-Bukkit stack
*/
public static ItemStack asBukkitCopy(net.minecraft.server.v1_6_R3.ItemStack original) {
public static ItemStack asBukkitCopy(net.minecraft.server.v1_7_R1.ItemStack original) {
if (original == null) {
return new ItemStack(Material.AIR);
}
ItemStack stack = new ItemStack(original.id, original.count, (short) original.getData());
ItemStack stack = new ItemStack(CraftMagicNumbers.getMaterial(original.getItem()), original.count, (short) original.getData());
if (hasItemMeta(original)) {
stack.setItemMeta(getItemMeta(original));
}
return stack;
}
public static CraftItemStack asCraftMirror(net.minecraft.server.v1_6_R3.ItemStack original) {
public static CraftItemStack asCraftMirror(net.minecraft.server.v1_7_R1.ItemStack original) {
return new CraftItemStack(original);
}
@ -80,37 +78,42 @@ public class CraftItemStack extends ItemStack {
return new CraftItemStack(original);
}
public static CraftItemStack asNewCraftStack(net.minecraft.server.v1_6_R3.Item item) {
public static CraftItemStack asNewCraftStack(Item item) {
return asNewCraftStack(item, 1);
}
public static CraftItemStack asNewCraftStack(net.minecraft.server.v1_6_R3.Item item, int amount) {
return new CraftItemStack(item.id, amount, (short) 0, null);
public static CraftItemStack asNewCraftStack(Item item, int amount) {
return new CraftItemStack(CraftMagicNumbers.getMaterial(item), amount, (short) 0, null);
}
net.minecraft.server.v1_6_R3.ItemStack handle;
net.minecraft.server.v1_7_R1.ItemStack handle;
/**
* Mirror
*/
private CraftItemStack(net.minecraft.server.v1_6_R3.ItemStack item) {
protected CraftItemStack(net.minecraft.server.v1_7_R1.ItemStack item) {
this.handle = item;
}
protected CraftItemStack(ItemStack item) {
this(item.getTypeId(), item.getAmount(), item.getDurability(), item.hasItemMeta() ? item.getItemMeta() : null);
}
protected CraftItemStack(int typeId, int amount, short durability, ItemMeta itemMeta) {
setTypeId(typeId);
protected CraftItemStack(Material type, int amount, short durability, ItemMeta itemMeta) {
setType(type);
setAmount(amount);
setDurability(durability);
setItemMeta(itemMeta);
}
protected CraftItemStack(int typeId, int amount, short durability, ItemMeta itemMeta) {
this(Material.getMaterial(typeId), amount, durability, itemMeta);
}
@Override
public int getTypeId() {
return handle != null ? handle.id : 0;
return handle != null ? CraftMagicNumbers.getId(handle.getItem()) : 0;
}
@Override
@ -119,10 +122,12 @@ public class CraftItemStack extends ItemStack {
return;
} else if (type == 0) {
handle = null;
} else if (CraftMagicNumbers.getItem(type) == null) { // :(
handle = null;
} else if (handle == null) {
handle = new net.minecraft.server.v1_6_R3.ItemStack(type, 1, 0);
handle = new net.minecraft.server.v1_7_R1.ItemStack(CraftMagicNumbers.getItem(type), 1, 0);
} else {
handle.id = type;
handle.setItem(CraftMagicNumbers.getItem(type));
if (hasItemMeta()) {
// This will create the appropriate item meta, which will contain all the data we intend to keep
setItemMeta(handle, getItemMeta(handle));
@ -156,11 +161,6 @@ public class CraftItemStack extends ItemStack {
}
}
public net.minecraft.server.v1_6_R3.ItemStack getHandle()
{
return handle;
}
@Override
public short getDurability() {
if (handle != null) {
@ -184,7 +184,7 @@ public class CraftItemStack extends ItemStack {
}
NBTTagList list = getEnchantmentList(handle);
if (list == null) {
list = new NBTTagList(ENCHANTMENTS.NBT);
list = new NBTTagList();
handle.tag.set(ENCHANTMENTS.NBT, list);
}
int size = list.size();
@ -203,14 +203,15 @@ public class CraftItemStack extends ItemStack {
list.add(tag);
}
static boolean makeTag(net.minecraft.server.v1_6_R3.ItemStack item) {
static boolean makeTag(net.minecraft.server.v1_7_R1.ItemStack item) {
if (item == null) {
return false;
}
if (item.tag != null) {
return true;
if (item.tag == null) {
item.setTag(new NBTTagCompound());
}
item.tag = new NBTTagCompound();
return true;
}
@ -262,7 +263,7 @@ public class CraftItemStack extends ItemStack {
}
// This is workaround for not having an index removal
listCopy = new NBTTagList(ENCHANTMENTS.NBT);
listCopy = new NBTTagList();
for (int i = 0; i < size; i++) {
if (i != index) {
listCopy.add(list.get(i));
@ -278,14 +279,15 @@ public class CraftItemStack extends ItemStack {
return getEnchantments(handle);
}
static Map<Enchantment, Integer> getEnchantments(net.minecraft.server.v1_6_R3.ItemStack item) {
ImmutableMap.Builder<Enchantment, Integer> result = ImmutableMap.builder();
NBTTagList list = (item == null) ? null : item.getEnchantments();
static Map<Enchantment, Integer> getEnchantments(net.minecraft.server.v1_7_R1.ItemStack item) {
NBTTagList list = (item != null && item.hasEnchantments()) ? item.getEnchantments() : null;
if (list == null) {
return result.build();
if (list == null || list.size() == 0) {
return ImmutableMap.of();
}
ImmutableMap.Builder<Enchantment, Integer> result = ImmutableMap.builder();
for (int i = 0; i < list.size(); i++) {
int id = 0xffff & ((NBTTagCompound) list.get(i)).getShort(ENCHANTMENTS_ID.NBT);
int level = 0xffff & ((NBTTagCompound) list.get(i)).getShort(ENCHANTMENTS_LVL.NBT);
@ -296,8 +298,8 @@ public class CraftItemStack extends ItemStack {
return result.build();
}
static NBTTagList getEnchantmentList(net.minecraft.server.v1_6_R3.ItemStack item) {
return item == null ? null : item.getEnchantments();
static NBTTagList getEnchantmentList(net.minecraft.server.v1_7_R1.ItemStack item) {
return (item != null && item.hasEnchantments()) ? item.getEnchantments() : null;
}
@Override
@ -313,8 +315,12 @@ public class CraftItemStack extends ItemStack {
public ItemMeta getItemMeta() {
return getItemMeta(handle);
}
public net.minecraft.server.v1_7_R1.ItemStack getHandle() {
return handle;
}
public static ItemMeta getItemMeta(net.minecraft.server.v1_6_R3.ItemStack item) {
public static ItemMeta getItemMeta(net.minecraft.server.v1_7_R1.ItemStack item) {
if (!hasItemMeta(item)) {
return CraftItemFactory.instance().getItemMeta(getType(item));
}
@ -344,8 +350,8 @@ public class CraftItemStack extends ItemStack {
}
}
static Material getType(net.minecraft.server.v1_6_R3.ItemStack item) {
Material material = Material.getMaterial(item == null ? 0 : item.id);
static Material getType(net.minecraft.server.v1_7_R1.ItemStack item) {
Material material = Material.getMaterial(item == null ? 0 : CraftMagicNumbers.getId(item.getItem()));
return material == null ? Material.AIR : material;
}
@ -354,7 +360,7 @@ public class CraftItemStack extends ItemStack {
return setItemMeta(handle, itemMeta);
}
public static boolean setItemMeta(net.minecraft.server.v1_6_R3.ItemStack item, ItemMeta itemMeta) {
public static boolean setItemMeta(net.minecraft.server.v1_7_R1.ItemStack item, ItemMeta itemMeta) {
if (item == null) {
return false;
}
@ -403,7 +409,7 @@ public class CraftItemStack extends ItemStack {
return hasItemMeta(handle);
}
static boolean hasItemMeta(net.minecraft.server.v1_6_R3.ItemStack item) {
static boolean hasItemMeta(net.minecraft.server.v1_7_R1.ItemStack item) {
return !(item == null || item.tag == null || item.tag.isEmpty());
}
}
}

View File

@ -1,17 +1,17 @@
package org.bukkit.craftbukkit.v1_6_R3.inventory;
package org.bukkit.craftbukkit.v1_7_R1.inventory;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.craftbukkit.v1_6_R3.inventory.CraftItemStack;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftHumanEntity;
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftHumanEntity;
import org.bukkit.craftbukkit.v1_7_R1.inventory.CraftItemStack;
import org.bukkit.entity.HumanEntity;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.InventoryHolder;
import net.minecraft.server.v1_6_R3.EntityHuman;
import net.minecraft.server.v1_6_R3.IInventory;
import net.minecraft.server.v1_6_R3.ItemStack;
import net.minecraft.server.v1_7_R1.EntityHuman;
import net.minecraft.server.v1_7_R1.IInventory;
import net.minecraft.server.v1_7_R1.ItemStack;
public class MinecraftInventory implements IInventory {
private final ItemStack[] items;
@ -139,4 +139,21 @@ public class MinecraftInventory implements IInventory {
public boolean b(int i, ItemStack itemstack) {
return true;
}
@Override
public String getInventoryName()
{
return null;
}
@Override
public boolean k_()
{
return false;
}
@Override
public void l_()
{
}
}