Mineplex2018-withcommit/Patches/CraftBukkit-Patches/0161-Mineplex-Changes.patch
Shaun Bennett 50fffa670c Jonnnyyy
2014-11-30 00:13:14 -06:00

2129 lines
65 KiB
Diff

From d9dfe49376fe2b1f709f9f20e62db39fd9381956 Mon Sep 17 00:00:00 2001
From: Shaun Bennett <shaun@mineplex.com>
Date: Sun, 30 Nov 2014 00:10:38 -0600
Subject: [PATCH] Mineplex Changes
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
index 858e12c..5c84ad2 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -16,6 +16,7 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.bukkit.Bukkit; // CraftBukkit
+import org.bukkit.event.world.ChunkAddEntityEvent;
public class Chunk {
@@ -648,6 +649,9 @@ public class Chunk {
entity.die();
}
+ ChunkAddEntityEvent event = new ChunkAddEntityEvent(entity.bukkitEntity);
+ Bukkit.getServer().getPluginManager().callEvent(event);
+
int k = MathHelper.floor(entity.locY / 16.0D);
if (k < 0) {
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index 9ee7e75..5b0d9ab 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
@@ -19,6 +19,7 @@ import org.bukkit.craftbukkit.chunkio.ChunkIOExecutor;
import org.bukkit.craftbukkit.util.LongHash;
import org.bukkit.craftbukkit.util.LongHashSet;
import org.bukkit.craftbukkit.util.LongObjectHashMap;
+import org.bukkit.event.world.ChunkPreLoadEvent;
import org.bukkit.event.world.ChunkUnloadEvent;
// CraftBukkit end
@@ -107,10 +108,44 @@ public class ChunkProviderServer implements IChunkProvider {
// We can only use the queue for already generated chunks
if (chunk == null && loader != null && loader.chunkExists(world, i, j)) {
if (runnable != null) {
- ChunkIOExecutor.queueChunkLoad(world, loader, this, i, j, runnable);
+ Server server = this.world.getServer();
+
+ ChunkPreLoadEvent event = new ChunkPreLoadEvent(world.getWorld(), i, j);
+ server.getPluginManager().callEvent(event);
+
+ if (event.isCancelled())
+ {
+ runnable.run();
+
+ chunk = new EmptyChunk(world, i, j);
+ chunk.done = true;
+ chunks.put(LongHash.toLong(i, j), chunk);
+ }
+ else
+ {
+ ChunkIOExecutor.queueChunkLoad(world, loader, this, i, j, runnable);
+ }
+
return null;
} else {
- chunk = ChunkIOExecutor.syncChunkLoad(world, loader, this, i, j);
+ Server server = this.world.getServer();
+
+ if (server != null)
+ {
+ ChunkPreLoadEvent event = new ChunkPreLoadEvent(world.getWorld(), i, j);
+ server.getPluginManager().callEvent(event);
+
+ if (event.isCancelled())
+ {
+ chunk = new EmptyChunk(world, i, j);
+ chunk.done = true;
+ chunks.put(LongHash.toLong(i, j), chunk);
+ }
+ else
+ {
+ chunk = ChunkIOExecutor.syncChunkLoad(world, loader, this, i, j);
+ }
+ }
}
} else if (chunk == null) {
chunk = originalGetChunkAt(i, j);
@@ -129,6 +164,23 @@ public class ChunkProviderServer implements IChunkProvider {
boolean newChunk = false;
// CraftBukkit end
+ Server server = this.world.getServer();
+
+ if (chunk == null && server != null)
+ {
+ ChunkPreLoadEvent event = new ChunkPreLoadEvent(world.getWorld(), i, j);
+ server.getPluginManager().callEvent(event);
+
+ if (event.isCancelled())
+ {
+ chunk = new EmptyChunk(world, i, j);
+ chunk.done = true;
+ chunks.put(LongHash.toLong(i, j), chunk);
+
+ return chunk;
+ }
+ }
+
if (chunk == null) {
world.timings.syncChunkLoadTimer.startTiming(); // Spigot
chunk = this.loadChunk(i, j);
@@ -155,7 +207,6 @@ public class ChunkProviderServer implements IChunkProvider {
chunk.addEntities();
// CraftBukkit start
- Server server = world.getServer();
if (server != null) {
/*
* If it's a new world, the first few chunks are generated inside
diff --git a/src/main/java/net/minecraft/server/DedicatedServer.java b/src/main/java/net/minecraft/server/DedicatedServer.java
index 2806f1e..f37e8b4 100644
--- a/src/main/java/net/minecraft/server/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/DedicatedServer.java
@@ -86,7 +86,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
System.err.println( "If you do not agree to the above EULA please stop your server and remove this flag immediately." );
}
// Spigot End
- if (!this.o.a() && !eulaAgreed) { // Spigot
+ if (false && !this.o.a() && !eulaAgreed) { // Spigot
DedicatedServer.LOGGER.info("You need to agree to the EULA in order to run the server. Go to eula.txt for more info.");
this.o.b();
return false;
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index b0a90d7..841b714 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -122,6 +122,9 @@ public abstract class Entity implements ICommandListener {
public void inactiveTick() { }
// Spigot end
+ public boolean Silent;
+ public boolean Invisible;
+
public int getId() {
return this.id;
}
@@ -684,7 +687,9 @@ public abstract class Entity implements ICommandListener {
this.makeSound(this.P(), f, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F);
}
- this.a(blockposition, block);
+ if (!Silent)
+ this.a(blockposition, block);
+
block.a(this.world, blockposition, this); // CraftBukkit - moved from above
}
}
@@ -786,7 +791,7 @@ public abstract class Entity implements ICommandListener {
}
public void makeSound(String s, float f, float f1) {
- if (!this.R()) {
+ if (!Silent && !this.R()) {
this.world.makeSound(this, s, f, f1);
}
@@ -1541,8 +1546,8 @@ public abstract class Entity implements ICommandListener {
if (entity == null) {
if (this.vehicle != null) {
// CraftBukkit start
- if ((this.bukkitEntity instanceof LivingEntity) && (this.vehicle.getBukkitEntity() instanceof Vehicle)) {
- VehicleExitEvent event = new VehicleExitEvent((Vehicle) this.vehicle.getBukkitEntity(), (LivingEntity) this.bukkitEntity);
+ if ((this.bukkitEntity instanceof LivingEntity)) {
+ VehicleExitEvent event = new VehicleExitEvent(this.vehicle.getBukkitEntity(), (LivingEntity) this.bukkitEntity);
pluginManager.callEvent(event);
if (event.isCancelled() || vehicle != originalVehicle) {
@@ -1558,11 +1563,11 @@ public abstract class Entity implements ICommandListener {
this.vehicle = null;
} else {
// CraftBukkit start
- if ((this.bukkitEntity instanceof LivingEntity) && (entity.getBukkitEntity() instanceof Vehicle) && entity.world.isChunkLoaded((int) entity.locX >> 4, (int) entity.locZ >> 4, true)) {
+ if ((this.bukkitEntity instanceof LivingEntity)&& entity.world.isChunkLoaded((int) entity.locX >> 4, (int) entity.locZ >> 4, true)) {
// It's possible to move from one vehicle to another. We need to check if they're already in a vehicle, and fire an exit event if they are.
VehicleExitEvent exitEvent = null;
- if (this.vehicle != null && this.vehicle.getBukkitEntity() instanceof Vehicle) {
- exitEvent = new VehicleExitEvent((Vehicle) this.vehicle.getBukkitEntity(), (LivingEntity) this.bukkitEntity);
+ if (this.vehicle != null) {
+ exitEvent = new VehicleExitEvent(this.vehicle.getBukkitEntity(), (LivingEntity) this.bukkitEntity);
pluginManager.callEvent(exitEvent);
if (exitEvent.isCancelled() || this.vehicle != originalVehicle || (this.vehicle != null && this.vehicle.passenger != originalPassenger)) {
@@ -1686,6 +1691,9 @@ public abstract class Entity implements ICommandListener {
}
public void setInvisible(boolean flag) {
+ if (Invisible && !flag)
+ return;
+
this.b(5, flag);
}
diff --git a/src/main/java/net/minecraft/server/EntityBat.java b/src/main/java/net/minecraft/server/EntityBat.java
new file mode 100644
index 0000000..aac4e0a
--- /dev/null
+++ b/src/main/java/net/minecraft/server/EntityBat.java
@@ -0,0 +1,208 @@
+//
+// Source code recreated from a .class file by IntelliJ IDEA
+// (powered by Fernflower decompiler)
+//
+
+package net.minecraft.server;
+
+import java.util.Calendar;
+import net.minecraft.server.Block;
+import net.minecraft.server.BlockPosition;
+import net.minecraft.server.DamageSource;
+import net.minecraft.server.Entity;
+import net.minecraft.server.EntityAmbient;
+import net.minecraft.server.EntityHuman;
+import net.minecraft.server.GenericAttributes;
+import net.minecraft.server.MathHelper;
+import net.minecraft.server.NBTTagCompound;
+import net.minecraft.server.World;
+
+public class EntityBat extends EntityAmbient {
+ private BlockPosition a;
+
+ public boolean Vegetated = false;
+
+ public EntityBat(World var1) {
+ super(var1);
+ this.a(0.5F, 0.9F);
+ this.setAsleep(true);
+ }
+
+ protected void h() {
+ super.h();
+ this.datawatcher.a(16, new Byte((byte)0));
+ }
+
+ protected float bA() {
+ return 0.1F;
+ }
+
+ protected float bB() {
+ return super.bB() * 0.95F;
+ }
+
+ protected String z() {
+ return this.isAsleep() && this.random.nextInt(4) != 0?null:"mob.bat.idle";
+ }
+
+ protected String bn() {
+ return "mob.bat.hurt";
+ }
+
+ protected String bo() {
+ return "mob.bat.death";
+ }
+
+ public boolean ae() {
+ return false;
+ }
+
+ protected void s(Entity var1) {
+ }
+
+ protected void bK() {
+ }
+
+ protected void aW() {
+ super.aW();
+ this.getAttributeInstance(GenericAttributes.maxHealth).setValue(6.0D);
+ }
+
+ public boolean isAsleep() {
+ return (this.datawatcher.getByte(16) & 1) != 0;
+ }
+
+ public void setAsleep(boolean var1) {
+ byte var2 = this.datawatcher.getByte(16);
+ if(var1) {
+ this.datawatcher.watch(16, Byte.valueOf((byte)(var2 | 1)));
+ } else {
+ this.datawatcher.watch(16, Byte.valueOf((byte)(var2 & -2)));
+ }
+
+ }
+
+ public void s_() {
+ super.s_();
+
+ if (Vegetated)
+ return;
+
+ if(this.isAsleep()) {
+ this.motX = this.motY = this.motZ = 0.0D;
+ this.locY = (double)MathHelper.floor(this.locY) + 1.0D - (double)this.length;
+ } else {
+ this.motY *= 0.6000000238418579D;
+ }
+
+ }
+
+ protected void E() {
+ super.E();
+
+ if (Vegetated)
+ return;
+
+ BlockPosition var1 = new BlockPosition(this);
+ BlockPosition var2 = var1.up();
+ if(this.isAsleep()) {
+ if(!this.world.getType(var2).getBlock().isOccluding()) {
+ this.setAsleep(false);
+ this.world.a((EntityHuman)null, 1015, var1, 0);
+ } else {
+ if(this.random.nextInt(200) == 0) {
+ this.aI = (float)this.random.nextInt(360);
+ }
+
+ if(this.world.findNearbyPlayer(this, 4.0D) != null) {
+ this.setAsleep(false);
+ this.world.a((EntityHuman)null, 1015, var1, 0);
+ }
+ }
+ } else {
+ if(this.a != null && (!this.world.isEmpty(this.a) || this.a.getY() < 1)) {
+ this.a = null;
+ }
+
+ if(this.a == null || this.random.nextInt(30) == 0 || this.a.c((double)((int)this.locX), (double)((int)this.locY), (double)((int)this.locZ)) < 4.0D) {
+ this.a = new BlockPosition((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 var3 = (double)this.a.getX() + 0.5D - this.locX;
+ double var5 = (double)this.a.getY() + 0.1D - this.locY;
+ double var7 = (double)this.a.getZ() + 0.5D - this.locZ;
+ this.motX += (Math.signum(var3) * 0.5D - this.motX) * 0.10000000149011612D;
+ this.motY += (Math.signum(var5) * 0.699999988079071D - this.motY) * 0.10000000149011612D;
+ this.motZ += (Math.signum(var7) * 0.5D - this.motZ) * 0.10000000149011612D;
+ float var9 = (float)(Math.atan2(this.motZ, this.motX) * 180.0D / 3.1415927410125732D) - 90.0F;
+ float var10 = MathHelper.g(var9 - this.yaw);
+ this.aY = 0.5F;
+ this.yaw += var10;
+ if(this.random.nextInt(100) == 0 && this.world.getType(var2).getBlock().isOccluding()) {
+ this.setAsleep(true);
+ }
+ }
+
+ }
+
+ protected boolean r_() {
+ return false;
+ }
+
+ public void e(float var1, float var2) {
+ }
+
+ protected void a(double var1, boolean var3, Block var4, BlockPosition var5) {
+ }
+
+ public boolean aH() {
+ return true;
+ }
+
+ public boolean damageEntity(DamageSource var1, float var2) {
+ if(this.isInvulnerable(var1)) {
+ return false;
+ } else {
+ if(!this.world.isStatic && this.isAsleep()) {
+ this.setAsleep(false);
+ }
+
+ return super.damageEntity(var1, var2);
+ }
+ }
+
+ public void a(NBTTagCompound var1) {
+ super.a(var1);
+ this.datawatcher.watch(16, Byte.valueOf(var1.getByte("BatFlags")));
+ }
+
+ public void b(NBTTagCompound var1) {
+ super.b(var1);
+ var1.setByte("BatFlags", this.datawatcher.getByte(16));
+ }
+
+ public boolean bQ() {
+ BlockPosition var1 = new BlockPosition(this.locX, this.getBoundingBox().b, this.locZ);
+ if(var1.getY() >= 63) {
+ return false;
+ } else {
+ int var2 = this.world.getLightLevel(var1);
+ byte var3 = 4;
+ if(this.a((Calendar)this.world.Y())) {
+ var3 = 7;
+ } else if(this.random.nextBoolean()) {
+ return false;
+ }
+
+ return var2 > this.random.nextInt(var3)?false:super.bQ();
+ }
+ }
+
+ private boolean a(Calendar var1) {
+ return var1.get(2) + 1 == 10 && var1.get(5) >= 20 || var1.get(2) + 1 == 11 && var1.get(5) <= 3;
+ }
+
+ public float getHeadHeight() {
+ return this.length / 2.0F;
+ }
+}
diff --git a/src/main/java/net/minecraft/server/EntityEnderDragon.java b/src/main/java/net/minecraft/server/EntityEnderDragon.java
index ec94142..6e927a3 100644
--- a/src/main/java/net/minecraft/server/EntityEnderDragon.java
+++ b/src/main/java/net/minecraft/server/EntityEnderDragon.java
@@ -40,6 +40,8 @@ public class EntityEnderDragon extends EntityInsentient implements IComplex, IMo
public EntityEnderCrystal bx;
private Explosion explosionSource = new Explosion(null, this, Double.NaN, Double.NaN, Double.NaN, Float.NaN, true, true); // CraftBukkit - reusable source for CraftTNTPrimed.getSource()
+ public boolean Vegetated = false;
+
public EntityEnderDragon(World world) {
super(world);
this.children = new EntityComplexPart[] { this.bl = new EntityComplexPart(this, "head", 6.0F, 6.0F), this.bm = new EntityComplexPart(this, "body", 8.0F, 8.0F), this.bn = new EntityComplexPart(this, "tail", 4.0F, 4.0F), this.bo = new EntityComplexPart(this, "tail", 4.0F, 4.0F), this.bp = new EntityComplexPart(this, "tail", 4.0F, 4.0F), this.bq = new EntityComplexPart(this, "wing", 4.0F, 4.0F), this.br = new EntityComplexPart(this, "wing", 4.0F, 4.0F)};
@@ -167,7 +169,7 @@ public class EntityEnderDragon extends EntityInsentient implements IComplex, IMo
this.c += this.random.nextGaussian() * 2.0D;
}
- if (this.bu || d3 < 100.0D || d3 > 22500.0D || this.positionChanged || this.E) {
+ if (!Vegetated && this.bu || d3 < 100.0D || d3 > 22500.0D || this.positionChanged || this.E) {
this.cd();
}
@@ -250,7 +252,7 @@ public class EntityEnderDragon extends EntityInsentient implements IComplex, IMo
this.bq.setPositionRotation(this.locX + (double) (f12 * 4.5F), this.locY + 2.0D, this.locZ + (double) (f11 * 4.5F), 0.0F, 0.0F);
this.br.s_();
this.br.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) {
+ if (!this.world.isStatic && this.hurtTicks == 0 && !ghost) {
this.a(this.world.getEntities(this, this.bq.getBoundingBox().grow(4.0D, 2.0D, 4.0D).c(0.0D, -2.0D, 0.0D)));
this.a(this.world.getEntities(this, this.br.getBoundingBox().grow(4.0D, 2.0D, 4.0D).c(0.0D, -2.0D, 0.0D)));
this.b(this.world.getEntities(this, this.bl.getBoundingBox().grow(1.0D, 1.0D, 1.0D)));
@@ -298,6 +300,19 @@ public class EntityEnderDragon extends EntityInsentient implements IComplex, IMo
}
}
+ public void setTargetBlock(int x, int y, int z)
+ {
+ this.a = x;
+ this.b = y;
+ this.c = z;
+ this.by = null;
+ }
+
+ public void setTargetEntity(Entity entity)
+ {
+ this.by = entity;
+ }
+
private void n() {
if (this.bx != null) {
if (this.bx.dead) {
diff --git a/src/main/java/net/minecraft/server/EntityFallingBlock.java b/src/main/java/net/minecraft/server/EntityFallingBlock.java
index fd78677..9f76410 100644
--- a/src/main/java/net/minecraft/server/EntityFallingBlock.java
+++ b/src/main/java/net/minecraft/server/EntityFallingBlock.java
@@ -17,6 +17,8 @@ public class EntityFallingBlock extends Entity {
private float fallHurtAmount = 2.0F;
public NBTTagCompound tileEntityData;
+ public boolean spectating;
+
public EntityFallingBlock(World world) {
super(world);
}
@@ -42,7 +44,15 @@ public class EntityFallingBlock extends Entity {
protected void h() {}
public boolean ad() {
- return !this.dead;
+ return !this.dead && !spectating;
+ }
+
+ @Override
+ public boolean damageEntity(DamageSource damagesource, float f)
+ {
+ CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f);
+
+ return true;
}
public void s_() {
diff --git a/src/main/java/net/minecraft/server/EntityHorse.java b/src/main/java/net/minecraft/server/EntityHorse.java
index 1d4354e..618aac9 100644
--- a/src/main/java/net/minecraft/server/EntityHorse.java
+++ b/src/main/java/net/minecraft/server/EntityHorse.java
@@ -117,6 +117,9 @@ public class EntityHorse extends EntityAnimal implements IInventoryListener {
private void c(int i, boolean flag) {
int j = this.datawatcher.getInt(16);
+ if (Vegetated)
+ return;
+
if (flag) {
this.datawatcher.watch(16, Integer.valueOf(j | i));
} else {
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
index 4ef5e01..0aaf491 100644
--- a/src/main/java/net/minecraft/server/EntityHuman.java
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
@@ -131,7 +131,7 @@ public abstract class EntityHuman extends EntityLiving {
if (this.g != null) {
ItemStack itemstack = this.inventory.getItemInHand();
- if (itemstack == this.g) {
+ if (ItemStack.equals(itemstack, this.g)) {
if (this.h <= 25 && this.h % 4 == 0) {
this.b(itemstack, 5);
}
diff --git a/src/main/java/net/minecraft/server/EntityInsentient.java b/src/main/java/net/minecraft/server/EntityInsentient.java
index bc7f81e..cc6f7b9 100644
--- a/src/main/java/net/minecraft/server/EntityInsentient.java
+++ b/src/main/java/net/minecraft/server/EntityInsentient.java
@@ -35,6 +35,10 @@ public abstract class EntityInsentient extends EntityLiving {
private Entity bn;
private NBTTagCompound bo;
+ public boolean Vegetated;
+ public boolean BreakLeash;
+ public boolean PullWhileLeashed;
+
public EntityInsentient(World world) {
super(world);
this.goalSelector = new PathfinderGoalSelector(world != null && world.methodProfiler != null ? world.methodProfiler : null);
@@ -148,7 +152,7 @@ public abstract class EntityInsentient extends EntityLiving {
public void K() {
super.K();
this.world.methodProfiler.a("mobBaseTick");
- if (this.isAlive() && this.random.nextInt(1000) < this.a_++) {
+ if (this.isAlive() && !Silent && this.random.nextInt(1000) < this.a_++) {
this.a_ = -this.w();
this.x();
}
@@ -764,7 +768,7 @@ public abstract class EntityInsentient extends EntityLiving {
}
public final boolean e(EntityHuman entityhuman) {
- if (this.cb() && this.getLeashHolder() == entityhuman) {
+ if (this.cb() && this.getLeashHolder() == entityhuman && BreakLeash) {
// CraftBukkit start - fire PlayerUnleashEntityEvent
if (CraftEventFactory.callPlayerUnleashEntityEvent(this, entityhuman).isCancelled()) {
((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutAttachEntity(1, this, this.getLeashHolder()));
@@ -829,7 +833,7 @@ public abstract class EntityInsentient extends EntityLiving {
}
public void unleash(boolean flag, boolean flag1) {
- if (this.bm) {
+ if (this.bm && BreakLeash) {
this.bm = false;
this.bn = null;
if (!this.world.isStatic && flag1) {
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
index 9604034..aeeb9a5 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -91,6 +91,8 @@ public abstract class EntityLiving extends Entity {
}
// Spigot end
+ public boolean ghost;
+
public void G() {
this.damageEntity(DamageSource.OUT_OF_WORLD, Float.MAX_VALUE);
}
@@ -1718,7 +1720,7 @@ public abstract class EntityLiving extends Entity {
}
public boolean ae() {
- return !this.dead;
+ return !this.dead && !ghost;
}
protected void ac() {
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
index 67230f6..f59e611 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -62,13 +62,16 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
public double maxHealthCache;
public boolean joining = true;
// CraftBukkit end
+
+ public boolean spectating;
+
// Spigot start
public boolean collidesWithEntities = true;
@Override
public boolean ad()
{
- return this.collidesWithEntities && super.ad(); // (first !this.isDead near bottom of EntityLiving)
+ return !spectating && this.collidesWithEntities && super.ad(); // (first !this.isDead near bottom of EntityLiving)
}
@Override
diff --git a/src/main/java/net/minecraft/server/EntityTNTPrimed.java b/src/main/java/net/minecraft/server/EntityTNTPrimed.java
index 3621faf..cc12f1b 100644
--- a/src/main/java/net/minecraft/server/EntityTNTPrimed.java
+++ b/src/main/java/net/minecraft/server/EntityTNTPrimed.java
@@ -9,6 +9,8 @@ public class EntityTNTPrimed extends Entity {
public float yield = 4; // CraftBukkit - add field
public boolean isIncendiary = false; // CraftBukkit - add field
+ public boolean spectating = false;
+
public EntityTNTPrimed(World world) {
super(world);
this.k = true;
@@ -37,7 +39,7 @@ public class EntityTNTPrimed extends Entity {
}
public boolean ad() {
- return !this.dead;
+ return !this.dead && !spectating;
}
public void s_() {
diff --git a/src/main/java/net/minecraft/server/IPacketVerifier.java b/src/main/java/net/minecraft/server/IPacketVerifier.java
new file mode 100644
index 0000000..4a61c32
--- /dev/null
+++ b/src/main/java/net/minecraft/server/IPacketVerifier.java
@@ -0,0 +1,6 @@
+package net.minecraft.server;
+
+public interface IPacketVerifier
+{
+ boolean verify(Packet packet);
+}
diff --git a/src/main/java/net/minecraft/server/PacketPlayInCloseWindow.java b/src/main/java/net/minecraft/server/PacketPlayInCloseWindow.java
index e24f224..d8a2da9 100644
--- a/src/main/java/net/minecraft/server/PacketPlayInCloseWindow.java
+++ b/src/main/java/net/minecraft/server/PacketPlayInCloseWindow.java
@@ -2,7 +2,7 @@ package net.minecraft.server;
public class PacketPlayInCloseWindow implements Packet {
- private int id;
+ public int id;
public PacketPlayInCloseWindow() {}
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutAnimation.java b/src/main/java/net/minecraft/server/PacketPlayOutAnimation.java
new file mode 100644
index 0000000..082e523
--- /dev/null
+++ b/src/main/java/net/minecraft/server/PacketPlayOutAnimation.java
@@ -0,0 +1,43 @@
+//
+// Source code recreated from a .class file by IntelliJ IDEA
+// (powered by Fernflower decompiler)
+//
+
+package net.minecraft.server;
+
+import net.minecraft.server.Entity;
+import net.minecraft.server.Packet;
+import net.minecraft.server.PacketDataSerializer;
+import net.minecraft.server.PacketListenerPlayOut;
+
+public class PacketPlayOutAnimation implements Packet {
+ public int a;
+ public int b;
+
+ public PacketPlayOutAnimation() {
+ }
+
+ public PacketPlayOutAnimation(Entity var1, int var2) {
+ this.a = var1.getId();
+ this.b = var2;
+ }
+
+ public void a(PacketDataSerializer var1) {
+ this.a = var1.e();
+ this.b = var1.readUnsignedByte();
+ }
+
+ public void b(PacketDataSerializer var1) {
+ var1.b(this.a);
+ var1.writeByte(this.b);
+ }
+
+ public void a(PacketListenerPlayOut var1) {
+ var1.a(this);
+ }
+
+ public void a(PacketListener listener)
+ {
+ a((PacketListenerPlayOut) listener);
+ }
+}
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutAttachEntity.java b/src/main/java/net/minecraft/server/PacketPlayOutAttachEntity.java
new file mode 100644
index 0000000..275e765
--- /dev/null
+++ b/src/main/java/net/minecraft/server/PacketPlayOutAttachEntity.java
@@ -0,0 +1,46 @@
+//
+// Source code recreated from a .class file by IntelliJ IDEA
+// (powered by Fernflower decompiler)
+//
+
+package net.minecraft.server;
+
+import net.minecraft.server.Entity;
+import net.minecraft.server.Packet;
+import net.minecraft.server.PacketDataSerializer;
+import net.minecraft.server.PacketListenerPlayOut;
+
+public class PacketPlayOutAttachEntity implements Packet {
+ public int a;
+ public int b;
+ public int c;
+
+ public PacketPlayOutAttachEntity() {
+ }
+
+ public PacketPlayOutAttachEntity(int var1, Entity var2, Entity var3) {
+ this.a = var1;
+ this.b = var2.getId();
+ this.c = var3 != null?var3.getId():-1;
+ }
+
+ public void a(PacketDataSerializer var1) {
+ this.b = var1.readInt();
+ this.c = var1.readInt();
+ this.a = var1.readUnsignedByte();
+ }
+
+ public void b(PacketDataSerializer var1) {
+ var1.writeInt(this.b);
+ var1.writeInt(this.c);
+ var1.writeByte(this.a);
+ }
+
+ public void a(PacketListenerPlayOut var1) {
+ var1.a(this);
+ }
+
+ public void a(PacketListener packetlistener) {
+ this.a((PacketListenerPlayOut) packetlistener);
+ }
+}
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutEntity.java b/src/main/java/net/minecraft/server/PacketPlayOutEntity.java
new file mode 100644
index 0000000..d4e9528
--- /dev/null
+++ b/src/main/java/net/minecraft/server/PacketPlayOutEntity.java
@@ -0,0 +1,48 @@
+//
+// Source code recreated from a .class file by IntelliJ IDEA
+// (powered by Fernflower decompiler)
+//
+
+package net.minecraft.server;
+
+import net.minecraft.server.Packet;
+import net.minecraft.server.PacketDataSerializer;
+import net.minecraft.server.PacketListenerPlayOut;
+
+public class PacketPlayOutEntity implements Packet {
+ public int a;
+ public byte b;
+ public byte c;
+ public byte d;
+ public byte e;
+ public byte f;
+ public boolean g;
+ public boolean h;
+
+ public PacketPlayOutEntity() {
+ }
+
+ public PacketPlayOutEntity(int var1) {
+ this.a = var1;
+ }
+
+ public void a(PacketDataSerializer var1) {
+ this.a = var1.e();
+ }
+
+ public void b(PacketDataSerializer var1) {
+ var1.b(this.a);
+ }
+
+ public void a(PacketListenerPlayOut var1) {
+ var1.a(this);
+ }
+
+ public String toString() {
+ return "Entity_" + super.toString();
+ }
+
+ public void a(PacketListener packetlistener) {
+ this.a((PacketListenerPlayOut) packetlistener);
+ }
+}
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutEntityEquipment.java b/src/main/java/net/minecraft/server/PacketPlayOutEntityEquipment.java
new file mode 100644
index 0000000..7631d9f
--- /dev/null
+++ b/src/main/java/net/minecraft/server/PacketPlayOutEntityEquipment.java
@@ -0,0 +1,46 @@
+//
+// Source code recreated from a .class file by IntelliJ IDEA
+// (powered by Fernflower decompiler)
+//
+
+package net.minecraft.server;
+
+import net.minecraft.server.ItemStack;
+import net.minecraft.server.Packet;
+import net.minecraft.server.PacketDataSerializer;
+import net.minecraft.server.PacketListenerPlayOut;
+
+public class PacketPlayOutEntityEquipment implements Packet {
+ public int a;
+ public int b;
+ public ItemStack c;
+
+ public PacketPlayOutEntityEquipment() {
+ }
+
+ public PacketPlayOutEntityEquipment(int var1, int var2, ItemStack var3) {
+ this.a = var1;
+ this.b = var2;
+ this.c = var3 == null?null:var3.cloneItemStack();
+ }
+
+ public void a(PacketDataSerializer var1) {
+ this.a = var1.e();
+ this.b = var1.readShort();
+ this.c = var1.i();
+ }
+
+ public void b(PacketDataSerializer var1) {
+ var1.b(this.a);
+ var1.writeShort(this.b);
+ var1.a(this.c);
+ }
+
+ public void a(PacketListenerPlayOut var1) {
+ var1.a(this);
+ }
+
+ public void a(PacketListener packetlistener) {
+ this.a((PacketListenerPlayOut) packetlistener);
+ }
+}
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutEntityMetadata.java b/src/main/java/net/minecraft/server/PacketPlayOutEntityMetadata.java
new file mode 100644
index 0000000..6d54b76
--- /dev/null
+++ b/src/main/java/net/minecraft/server/PacketPlayOutEntityMetadata.java
@@ -0,0 +1,48 @@
+//
+// Source code recreated from a .class file by IntelliJ IDEA
+// (powered by Fernflower decompiler)
+//
+
+package net.minecraft.server;
+
+import java.util.List;
+import net.minecraft.server.DataWatcher;
+import net.minecraft.server.Packet;
+import net.minecraft.server.PacketDataSerializer;
+import net.minecraft.server.PacketListenerPlayOut;
+
+public class PacketPlayOutEntityMetadata implements Packet {
+ public int a;
+ public List b;
+
+ public PacketPlayOutEntityMetadata() {
+ }
+
+ public PacketPlayOutEntityMetadata(int var1, DataWatcher var2, boolean var3) {
+ this.a = var1;
+ if(var3) {
+ this.b = var2.c();
+ } else {
+ this.b = var2.b();
+ }
+
+ }
+
+ public void a(PacketDataSerializer var1) {
+ this.a = var1.e();
+ this.b = DataWatcher.b(var1);
+ }
+
+ public void b(PacketDataSerializer var1) {
+ var1.b(this.a);
+ DataWatcher.a(this.b, var1);
+ }
+
+ public void a(PacketListenerPlayOut var1) {
+ var1.a(this);
+ }
+
+ public void a(PacketListener packetlistener) {
+ this.a((PacketListenerPlayOut) packetlistener);
+ }
+}
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutEntityTeleport.java b/src/main/java/net/minecraft/server/PacketPlayOutEntityTeleport.java
new file mode 100644
index 0000000..6c5f222
--- /dev/null
+++ b/src/main/java/net/minecraft/server/PacketPlayOutEntityTeleport.java
@@ -0,0 +1,73 @@
+//
+// Source code recreated from a .class file by IntelliJ IDEA
+// (powered by Fernflower decompiler)
+//
+
+package net.minecraft.server;
+
+import net.minecraft.server.Entity;
+import net.minecraft.server.MathHelper;
+import net.minecraft.server.Packet;
+import net.minecraft.server.PacketDataSerializer;
+import net.minecraft.server.PacketListenerPlayOut;
+
+public class PacketPlayOutEntityTeleport implements Packet {
+ public int a;
+ public int b;
+ public int c;
+ public int d;
+ public byte e;
+ public byte f;
+ public boolean g;
+
+ public PacketPlayOutEntityTeleport() {
+ }
+
+ public PacketPlayOutEntityTeleport(Entity var1) {
+ this.a = var1.getId();
+ this.b = MathHelper.floor(var1.locX * 32.0D);
+ this.c = MathHelper.floor(var1.locY * 32.0D);
+ this.d = MathHelper.floor(var1.locZ * 32.0D);
+ this.e = (byte)((int)(var1.yaw * 256.0F / 360.0F));
+ this.f = (byte)((int)(var1.pitch * 256.0F / 360.0F));
+ this.g = var1.onGround;
+ }
+
+ public PacketPlayOutEntityTeleport(int var1, int var2, int var3, int var4, byte var5, byte var6, boolean var7) {
+ this.a = var1;
+ this.b = var2;
+ this.c = var3;
+ this.d = var4;
+ this.e = var5;
+ this.f = var6;
+ this.g = var7;
+ }
+
+ public void a(PacketDataSerializer var1) {
+ this.a = var1.e();
+ this.b = var1.readInt();
+ this.c = var1.readInt();
+ this.d = var1.readInt();
+ this.e = var1.readByte();
+ this.f = var1.readByte();
+ this.g = var1.readBoolean();
+ }
+
+ public void b(PacketDataSerializer var1) {
+ var1.b(this.a);
+ var1.writeInt(this.b);
+ var1.writeInt(this.c);
+ var1.writeInt(this.d);
+ var1.writeByte(this.e);
+ var1.writeByte(this.f);
+ var1.writeBoolean(this.g);
+ }
+
+ public void a(PacketListenerPlayOut var1) {
+ var1.a(this);
+ }
+
+ public void a(PacketListener packetlistener) {
+ this.a((PacketListenerPlayOut) packetlistener);
+ }
+}
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutEntityVelocity.java b/src/main/java/net/minecraft/server/PacketPlayOutEntityVelocity.java
new file mode 100644
index 0000000..2cddb08
--- /dev/null
+++ b/src/main/java/net/minecraft/server/PacketPlayOutEntityVelocity.java
@@ -0,0 +1,79 @@
+//
+// Source code recreated from a .class file by IntelliJ IDEA
+// (powered by Fernflower decompiler)
+//
+
+package net.minecraft.server;
+
+import net.minecraft.server.Entity;
+import net.minecraft.server.Packet;
+import net.minecraft.server.PacketDataSerializer;
+import net.minecraft.server.PacketListenerPlayOut;
+
+public class PacketPlayOutEntityVelocity implements Packet {
+ public int a;
+ public int b;
+ public int c;
+ public int d;
+
+ public PacketPlayOutEntityVelocity() {
+ }
+
+ public PacketPlayOutEntityVelocity(Entity var1) {
+ this(var1.getId(), var1.motX, var1.motY, var1.motZ);
+ }
+
+ public PacketPlayOutEntityVelocity(int var1, double var2, double var4, double var6) {
+ this.a = var1;
+ double var8 = 3.9D;
+ if(var2 < -var8) {
+ var2 = -var8;
+ }
+
+ if(var4 < -var8) {
+ var4 = -var8;
+ }
+
+ if(var6 < -var8) {
+ var6 = -var8;
+ }
+
+ if(var2 > var8) {
+ var2 = var8;
+ }
+
+ if(var4 > var8) {
+ var4 = var8;
+ }
+
+ if(var6 > var8) {
+ var6 = var8;
+ }
+
+ this.b = (int)(var2 * 8000.0D);
+ this.c = (int)(var4 * 8000.0D);
+ this.d = (int)(var6 * 8000.0D);
+ }
+
+ public void a(PacketDataSerializer var1) {
+ this.a = var1.e();
+ this.b = var1.readShort();
+ this.c = var1.readShort();
+ this.d = var1.readShort();
+ }
+
+ public void b(PacketDataSerializer var1) {
+ var1.b(this.a);
+ var1.writeShort(this.b);
+ var1.writeShort(this.c);
+ var1.writeShort(this.d);
+ }
+
+ public void a(PacketListenerPlayOut var1) {
+ var1.a(this);
+ }
+
+ public void a(PacketListener packetlistener) {
+ this.a((PacketListenerPlayOut) packetlistener);
+ }
+}
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutNamedEntitySpawn.java b/src/main/java/net/minecraft/server/PacketPlayOutNamedEntitySpawn.java
new file mode 100644
index 0000000..c7da28c
--- /dev/null
+++ b/src/main/java/net/minecraft/server/PacketPlayOutNamedEntitySpawn.java
@@ -0,0 +1,78 @@
+//
+// Source code recreated from a .class file by IntelliJ IDEA
+// (powered by Fernflower decompiler)
+//
+
+package net.minecraft.server;
+
+import java.util.List;
+import java.util.UUID;
+import net.minecraft.server.DataWatcher;
+import net.minecraft.server.EntityHuman;
+import net.minecraft.server.Item;
+import net.minecraft.server.ItemStack;
+import net.minecraft.server.MathHelper;
+import net.minecraft.server.Packet;
+import net.minecraft.server.PacketDataSerializer;
+import net.minecraft.server.PacketListenerPlayOut;
+
+public class PacketPlayOutNamedEntitySpawn implements Packet {
+ public int a;
+ public UUID 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 var1) {
+ this.a = var1.getId();
+ this.b = var1.getProfile().getId();
+ this.c = MathHelper.floor(var1.locX * 32.0D);
+ this.d = MathHelper.floor(var1.locY * 32.0D);
+ this.e = MathHelper.floor(var1.locZ * 32.0D);
+ this.f = (byte)((int)(var1.yaw * 256.0F / 360.0F));
+ this.g = (byte)((int)(var1.pitch * 256.0F / 360.0F));
+ ItemStack var2 = var1.inventory.getItemInHand();
+ this.h = var2 == null?0:Item.getId(var2.getItem());
+ this.i = var1.getDataWatcher();
+ }
+
+ public void a(PacketDataSerializer var1) {
+ this.a = var1.e();
+ this.b = var1.g();
+ this.c = var1.readInt();
+ this.d = var1.readInt();
+ this.e = var1.readInt();
+ this.f = var1.readByte();
+ this.g = var1.readByte();
+ this.h = var1.readShort();
+ this.j = DataWatcher.b(var1);
+ }
+
+ public void b(PacketDataSerializer var1) {
+ var1.b(this.a);
+ var1.a(this.b);
+ var1.writeInt(this.c);
+ var1.writeInt(this.d);
+ var1.writeInt(this.e);
+ var1.writeByte(this.f);
+ var1.writeByte(this.g);
+ var1.writeShort(this.h);
+ this.i.a(var1);
+ }
+
+ public void a(PacketListenerPlayOut var1) {
+ var1.a(this);
+ }
+
+ public void a(PacketListener packetlistener) {
+ this.a((PacketListenerPlayOut) packetlistener);
+ }
+}
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutSpawnEntity.java b/src/main/java/net/minecraft/server/PacketPlayOutSpawnEntity.java
new file mode 100644
index 0000000..d77bccf
--- /dev/null
+++ b/src/main/java/net/minecraft/server/PacketPlayOutSpawnEntity.java
@@ -0,0 +1,144 @@
+//
+// Source code recreated from a .class file by IntelliJ IDEA
+// (powered by Fernflower decompiler)
+//
+
+package net.minecraft.server;
+
+import net.minecraft.server.Entity;
+import net.minecraft.server.MathHelper;
+import net.minecraft.server.Packet;
+import net.minecraft.server.PacketDataSerializer;
+import net.minecraft.server.PacketListenerPlayOut;
+
+public class PacketPlayOutSpawnEntity implements 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 var1, int var2) {
+ this(var1, var2, 0);
+ }
+
+ public PacketPlayOutSpawnEntity(Entity var1, int var2, int var3) {
+ this.a = var1.getId();
+ this.b = MathHelper.floor(var1.locX * 32.0D);
+ this.c = MathHelper.floor(var1.locY * 32.0D);
+ this.d = MathHelper.floor(var1.locZ * 32.0D);
+ this.h = MathHelper.d(var1.pitch * 256.0F / 360.0F);
+ this.i = MathHelper.d(var1.yaw * 256.0F / 360.0F);
+ this.j = var2;
+ this.k = var3;
+ if(var3 > 0) {
+ double var4 = var1.motX;
+ double var6 = var1.motY;
+ double var8 = var1.motZ;
+ double var10 = 3.9D;
+ if(var4 < -var10) {
+ var4 = -var10;
+ }
+
+ if(var6 < -var10) {
+ var6 = -var10;
+ }
+
+ if(var8 < -var10) {
+ var8 = -var10;
+ }
+
+ if(var4 > var10) {
+ var4 = var10;
+ }
+
+ if(var6 > var10) {
+ var6 = var10;
+ }
+
+ if(var8 > var10) {
+ var8 = var10;
+ }
+
+ this.e = (int)(var4 * 8000.0D);
+ this.f = (int)(var6 * 8000.0D);
+ this.g = (int)(var8 * 8000.0D);
+ }
+
+ }
+
+ public void a(PacketDataSerializer var1) {
+ this.a = var1.e();
+ this.j = var1.readByte();
+ this.b = var1.readInt();
+ this.c = var1.readInt();
+ this.d = var1.readInt();
+ this.h = var1.readByte();
+ this.i = var1.readByte();
+ this.k = var1.readInt();
+ if(this.k > 0) {
+ this.e = var1.readShort();
+ this.f = var1.readShort();
+ this.g = var1.readShort();
+ }
+
+ }
+
+ public void b(PacketDataSerializer var1) {
+ var1.b(this.a);
+ var1.writeByte(this.j);
+ var1.writeInt(this.b);
+ var1.writeInt(this.c);
+ var1.writeInt(this.d);
+ var1.writeByte(this.h);
+ var1.writeByte(this.i);
+ var1.writeInt(this.k);
+ if(this.k > 0) {
+ var1.writeShort(this.e);
+ var1.writeShort(this.f);
+ var1.writeShort(this.g);
+ }
+
+ }
+
+ public void a(PacketListenerPlayOut var1) {
+ var1.a(this);
+ }
+
+ public void a(int var1) {
+ this.b = var1;
+ }
+
+ public void b(int var1) {
+ this.c = var1;
+ }
+
+ public void c(int var1) {
+ this.d = var1;
+ }
+
+ public void d(int var1) {
+ this.e = var1;
+ }
+
+ public void e(int var1) {
+ this.f = var1;
+ }
+
+ public void f(int var1) {
+ this.g = var1;
+ }
+
+ public void a(PacketListener packetlistener) {
+ this.a((PacketListenerPlayOut) packetlistener);
+ }
+}
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutSpawnEntityLiving.java b/src/main/java/net/minecraft/server/PacketPlayOutSpawnEntityLiving.java
new file mode 100644
index 0000000..c86fe82
--- /dev/null
+++ b/src/main/java/net/minecraft/server/PacketPlayOutSpawnEntityLiving.java
@@ -0,0 +1,115 @@
+//
+// Source code recreated from a .class file by IntelliJ IDEA
+// (powered by Fernflower decompiler)
+//
+
+package net.minecraft.server;
+
+import java.util.List;
+import net.minecraft.server.DataWatcher;
+import net.minecraft.server.EntityLiving;
+import net.minecraft.server.EntityTypes;
+import net.minecraft.server.MathHelper;
+import net.minecraft.server.Packet;
+import net.minecraft.server.PacketDataSerializer;
+import net.minecraft.server.PacketListenerPlayOut;
+
+public class PacketPlayOutSpawnEntityLiving implements 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 var1) {
+ this.a = var1.getId();
+ this.b = (byte)EntityTypes.a(var1);
+ this.c = MathHelper.floor(var1.locX * 32.0D);
+ this.d = MathHelper.floor(var1.locY * 32.0D);
+ this.e = MathHelper.floor(var1.locZ * 32.0D);
+ this.i = (byte)((int)(var1.yaw * 256.0F / 360.0F));
+ this.j = (byte)((int)(var1.pitch * 256.0F / 360.0F));
+ this.k = (byte)((int)(var1.aI * 256.0F / 360.0F));
+ double var2 = 3.9D;
+ double var4 = var1.motX;
+ double var6 = var1.motY;
+ double var8 = var1.motZ;
+ if(var4 < -var2) {
+ var4 = -var2;
+ }
+
+ if(var6 < -var2) {
+ var6 = -var2;
+ }
+
+ if(var8 < -var2) {
+ var8 = -var2;
+ }
+
+ if(var4 > var2) {
+ var4 = var2;
+ }
+
+ if(var6 > var2) {
+ var6 = var2;
+ }
+
+ if(var8 > var2) {
+ var8 = var2;
+ }
+
+ this.f = (int)(var4 * 8000.0D);
+ this.g = (int)(var6 * 8000.0D);
+ this.h = (int)(var8 * 8000.0D);
+ this.l = var1.getDataWatcher();
+ }
+
+ public void a(PacketDataSerializer var1) {
+ this.a = var1.e();
+ this.b = var1.readByte() & 255;
+ this.c = var1.readInt();
+ this.d = var1.readInt();
+ this.e = var1.readInt();
+ this.i = var1.readByte();
+ this.j = var1.readByte();
+ this.k = var1.readByte();
+ this.f = var1.readShort();
+ this.g = var1.readShort();
+ this.h = var1.readShort();
+ this.m = DataWatcher.b(var1);
+ }
+
+ public void b(PacketDataSerializer var1) {
+ var1.b(this.a);
+ var1.writeByte(this.b & 255);
+ var1.writeInt(this.c);
+ var1.writeInt(this.d);
+ var1.writeInt(this.e);
+ var1.writeByte(this.i);
+ var1.writeByte(this.j);
+ var1.writeByte(this.k);
+ var1.writeShort(this.f);
+ var1.writeShort(this.g);
+ var1.writeShort(this.h);
+ this.l.a(var1);
+ }
+
+ public void a(PacketListenerPlayOut var1) {
+ var1.a(this);
+ }
+
+ public void a(PacketListener packetlistener) {
+ this.a((PacketListenerPlayOut) packetlistener);
+ }
+}
diff --git a/src/main/java/net/minecraft/server/PacketProcessor.java b/src/main/java/net/minecraft/server/PacketProcessor.java
new file mode 100644
index 0000000..e43149a
--- /dev/null
+++ b/src/main/java/net/minecraft/server/PacketProcessor.java
@@ -0,0 +1,43 @@
+package net.minecraft.server;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class PacketProcessor
+{
+ private List<IPacketVerifier> _packetVerifiers;
+
+ public PacketProcessor()
+ {
+ _packetVerifiers = new ArrayList<IPacketVerifier>();
+ }
+
+ public void addPacketVerifier(IPacketVerifier verifier)
+ {
+ _packetVerifiers.add(verifier);
+ }
+
+ public void processPacket(Packet packet, NetworkManager networkManager)
+ {
+ boolean addDefaultPacket = true;
+
+ for (IPacketVerifier verifier : _packetVerifiers)
+ {
+ if (!verifier.verify(packet))
+ {
+ addDefaultPacket = false;
+ }
+ }
+
+ if (addDefaultPacket)
+ {
+ networkManager.handle(packet);
+ }
+ }
+
+ public void clearVerifiers()
+ {
+ _packetVerifiers.clear();
+ }
+
+}
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index 18b9e9b..105d821 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -83,6 +83,8 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
public boolean checkMovement = true;
private boolean processedDisconnect; // CraftBukkit - added
+ public PacketProcessor _packetVerifier;
+
public PlayerConnection(MinecraftServer minecraftserver, NetworkManager networkmanager, EntityPlayer entityplayer) {
this.minecraftServer = minecraftserver;
this.networkManager = networkmanager;
@@ -90,6 +92,8 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
this.player = entityplayer;
entityplayer.playerConnection = this;
+ _packetVerifier = new PacketProcessor();
+
// CraftBukkit start - add fields and methods
this.server = minecraftserver.server;
}
@@ -833,7 +837,7 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
// CraftBukkit end
try {
- this.networkManager.handle(packet);
+ _packetVerifier.processPacket(packet, this.networkManager);
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.a(throwable, "Sending packet");
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Packet being sent");
@@ -1333,10 +1337,13 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
public void a(PacketPlayInCloseWindow packetplayinclosewindow) {
if (this.player.dead) return; // CraftBukkit
PlayerConnectionUtils.ensureMainThread(packetplayinclosewindow, this, this.player.u());
-
- CraftEventFactory.handleInventoryCloseEvent(this.player); // CraftBukkit
-
- this.player.p();
+
+ if (packetplayinclosewindow.id == player.activeContainer.windowId)
+ {
+ CraftEventFactory.handleInventoryCloseEvent(this.player); // CraftBukkit
+
+ this.player.p();
+ }
}
public void a(PacketPlayInWindowClick packetplayinwindowclick) {
diff --git a/src/main/java/net/minecraft/server/QueuedPacket.java b/src/main/java/net/minecraft/server/QueuedPacket.java
new file mode 100644
index 0000000..5aceeb4
--- /dev/null
+++ b/src/main/java/net/minecraft/server/QueuedPacket.java
@@ -0,0 +1,27 @@
+//
+// Source code recreated from a .class file by IntelliJ IDEA
+// (powered by Fernflower decompiler)
+//
+
+package net.minecraft.server;
+
+import io.netty.util.concurrent.GenericFutureListener;
+import net.minecraft.server.Packet;
+
+public class QueuedPacket {
+ private final Packet a;
+ private final GenericFutureListener[] b;
+
+ public QueuedPacket(Packet var1, GenericFutureListener... var2) {
+ this.a = var1;
+ this.b = var2;
+ }
+
+ public static Packet a(QueuedPacket var0) {
+ return var0.a;
+ }
+
+ public static GenericFutureListener[] b(QueuedPacket var0) {
+ return var0.b;
+ }
+}
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 762e469..533e1e2 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -194,6 +194,8 @@ public abstract class World implements IBlockAccess {
public final SpigotTimings.WorldTimingsHandler timings; // Spigot
+ private Entity _startEntity;
+
public CraftWorld getWorld() {
return this.world;
}
@@ -1628,14 +1630,43 @@ public abstract class World implements IBlockAccess {
}
this.methodProfiler.b();
- if (flag && entity.ad && entity.passenger != null) {
- if (!entity.passenger.dead && entity.passenger.vehicle == entity) {
+ if (flag && entity.ad && entity.passenger != null)
+ {
+// if (!entity.passenger.dead && entity.passenger.vehicle == entity) {
+// this.g(entity.passenger);
+// } else {
+// entity.passenger.vehicle = null;
+// entity.passenger = null;
+// }
+// }
+ if (!entity.passenger.dead && entity.passenger.vehicle == entity)
+ {
+ if (_startEntity == null)
+ _startEntity = entity;
+
this.g(entity.passenger);
- } else {
+ } else if (entity == _startEntity)
+ {
+ for (StackTraceElement element : Thread.currentThread().getStackTrace())
+ {
+ System.out.println(element);
+ }
+
+ entity.passenger.vehicle = null;
+ entity.passenger = null;
+ _startEntity = null;
+ } else
+ {
entity.passenger.vehicle = null;
entity.passenger = null;
+ _startEntity = null;
}
}
+ else
+ {
+ _startEntity = null;
+ }
+
entity.tickTimer.stopTiming(); // Spigot
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index d5ea292..ecee9f2 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -1072,9 +1072,9 @@ public class CraftWorld implements World {
( (EntityOcelot) entity ).spawnBonus = false;
}
// Spigot end
- if (entity instanceof EntityInsentient) {
- ((EntityInsentient) entity).prepare(getHandle().E(new BlockPosition(entity)), (GroupDataEntity) null);
- }
+// if (entity instanceof EntityInsentient) {
+// ((EntityInsentient) entity).prepare(getHandle().E(new BlockPosition(entity)), (GroupDataEntity) null);
+// }
world.addEntity(entity, reason);
return (T) entity.getBukkitEntity();
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 5864a51..e6efa95 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -870,12 +870,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
}
- @Override
- public void hidePlayer(Player player) {
+ public void hidePlayer(Player player)
+ {
+ hidePlayer(player, false, true);
+ }
+
+ public void hidePlayer(Player player, boolean override, boolean hideList) {
Validate.notNull(player, "hidden player cannot be null");
if (getHandle().playerConnection == null) return;
if (equals(player)) return;
- if (hiddenPlayers.contains(player.getUniqueId())) return;
+ if (!override && hiddenPlayers.contains(player.getUniqueId())) return;
hiddenPlayers.add(player.getUniqueId());
//remove this player from the hidden player's EntityTrackerEntry
@@ -887,7 +891,8 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
//remove the hidden player from this player user list
- getHandle().playerConnection.sendPacket(new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.REMOVE_PLAYER, other));
+ if (hideList)
+ getHandle().playerConnection.sendPacket(new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.REMOVE_PLAYER, other));
}
@Override
@@ -1333,13 +1338,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@Override
public boolean getCollidesWithEntities()
{
- return getHandle().collidesWithEntities;
+ return !getHandle().spectating;
}
@Override
public void setCollidesWithEntities(boolean collides)
{
- getHandle().collidesWithEntities = collides;
+ getHandle().spectating = !collides;
getHandle().k = collides; // First boolean of Entity
}
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java
index 7ae6f12..00c98cf 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java
@@ -439,8 +439,8 @@ public class CraftInventory implements Inventory {
return InventoryType.ENCHANTING;
} else if (inventory instanceof TileEntityBrewingStand) {
return InventoryType.BREWING;
- } else if (inventory instanceof CraftInventoryCustom.MinecraftInventory) {
- return ((CraftInventoryCustom.MinecraftInventory) inventory).getType();
+ } else if (inventory instanceof MinecraftInventory) {
+ return ((MinecraftInventory) inventory).getType();
} else if (inventory instanceof InventoryEnderChest) {
return InventoryType.ENDER_CHEST;
} else if (inventory instanceof InventoryMerchant) {
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java
index 947c493..eed9afa 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java
@@ -31,168 +31,4 @@ public class CraftInventoryCustom extends CraftInventory {
public CraftInventoryCustom(InventoryHolder owner, int size, String title) {
super(new MinecraftInventory(owner, size, title));
}
-
- static class MinecraftInventory implements IInventory {
- private final ItemStack[] items;
- private int maxStack = MAX_STACK;
- private final List<HumanEntity> viewers;
- private final String title;
- private InventoryType type;
- private final InventoryHolder owner;
-
- public MinecraftInventory(InventoryHolder owner, InventoryType type) {
- this(owner, type.getDefaultSize(), type.getDefaultTitle());
- this.type = type;
- }
-
- public MinecraftInventory(InventoryHolder owner, InventoryType type, String title) {
- this(owner, type.getDefaultSize(), title);
- this.type = type;
- }
-
- public MinecraftInventory(InventoryHolder owner, int size) {
- this(owner, size, "Chest");
- }
-
- public MinecraftInventory(InventoryHolder owner, int size, String title) {
- Validate.notNull(title, "Title cannot be null");
- Validate.isTrue(title.length() <= 32, "Title cannot be longer than 32 characters");
- this.items = new ItemStack[size];
- this.title = title;
- this.viewers = new ArrayList<HumanEntity>();
- this.owner = owner;
- this.type = InventoryType.CHEST;
- }
-
- public int getSize() {
- return items.length;
- }
-
- public ItemStack getItem(int i) {
- return items[i];
- }
-
- public ItemStack splitStack(int i, int j) {
- ItemStack stack = this.getItem(i);
- ItemStack result;
- if (stack == null) return null;
- if (stack.count <= j) {
- this.setItem(i, null);
- result = stack;
- } else {
- result = CraftItemStack.copyNMSStack(stack, j);
- stack.count -= j;
- }
- this.update();
- return result;
- }
-
- public ItemStack splitWithoutUpdate(int i) {
- ItemStack stack = this.getItem(i);
- ItemStack result;
- if (stack == null) return null;
- if (stack.count <= 1) {
- this.setItem(i, null);
- result = stack;
- } else {
- result = CraftItemStack.copyNMSStack(stack, 1);
- stack.count -= 1;
- }
- return result;
- }
-
- public void setItem(int i, ItemStack itemstack) {
- items[i] = itemstack;
- if (itemstack != null && this.getMaxStackSize() > 0 && itemstack.count > this.getMaxStackSize()) {
- itemstack.count = this.getMaxStackSize();
- }
- }
-
- public int getMaxStackSize() {
- return maxStack;
- }
-
- public void setMaxStackSize(int size) {
- maxStack = size;
- }
-
- public void update() {}
-
- public boolean a(EntityHuman entityhuman) {
- return true;
- }
-
- public ItemStack[] getContents() {
- return items;
- }
-
- public void onOpen(CraftHumanEntity who) {
- viewers.add(who);
- }
-
- public void onClose(CraftHumanEntity who) {
- viewers.remove(who);
- }
-
- public List<HumanEntity> getViewers() {
- return viewers;
- }
-
- public InventoryType getType() {
- return type;
- }
-
- public InventoryHolder getOwner() {
- return owner;
- }
-
- public boolean b(int i, ItemStack itemstack) {
- return true;
- }
-
- @Override
- public void startOpen(EntityHuman entityHuman) {
-
- }
-
- @Override
- public void closeContainer(EntityHuman entityHuman) {
-
- }
-
- @Override
- public int getProperty(int i) {
- return 0;
- }
-
- @Override
- public void b(int i, int i1) {
-
- }
-
- @Override
- public int g() {
- return 0;
- }
-
- @Override
- public void l() {
-
- }
-
- @Override
- public String getName() {
- return title;
- }
-
- @Override
- public boolean hasCustomName() {
- return title != null;
- }
-
- @Override
- public IChatBaseComponent getScoreboardDisplayName() {
- return new ChatComponentText(title);
- }
- }
}
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
index b49c2dc..fe23d4d 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
@@ -22,7 +22,7 @@ import org.bukkit.inventory.meta.ItemMeta;
import com.google.common.collect.ImmutableMap;
@DelegateDeserialization(ItemStack.class)
-public final class CraftItemStack extends ItemStack {
+public class CraftItemStack extends ItemStack {
public static net.minecraft.server.ItemStack asNMSCopy(ItemStack original) {
if (original instanceof CraftItemStack) {
@@ -91,22 +91,22 @@ public final class CraftItemStack extends ItemStack {
/**
* Mirror
*/
- private CraftItemStack(net.minecraft.server.ItemStack item) {
+ protected CraftItemStack(net.minecraft.server.ItemStack item) {
this.handle = item;
}
- private CraftItemStack(ItemStack item) {
+ protected CraftItemStack(ItemStack item) {
this(item.getTypeId(), item.getAmount(), item.getDurability(), item.hasItemMeta() ? item.getItemMeta() : null);
}
- private CraftItemStack(Material type, int amount, short durability, ItemMeta itemMeta) {
+ protected CraftItemStack(Material type, int amount, short durability, ItemMeta itemMeta) {
setType(type);
setAmount(amount);
setDurability(durability);
setItemMeta(itemMeta);
}
- private CraftItemStack(int typeId, int amount, short durability, ItemMeta itemMeta) {
+ protected CraftItemStack(int typeId, int amount, short durability, ItemMeta itemMeta) {
this(Material.getMaterial(typeId), amount, durability, itemMeta);
}
@@ -402,6 +402,11 @@ public final class CraftItemStack extends ItemStack {
return hasItemMeta() ? that.hasItemMeta() && handle.getTag().equals(that.handle.getTag()) : !that.hasItemMeta();
}
+ public net.minecraft.server.ItemStack getHandler()
+ {
+ return handle;
+ }
+
@Override
public boolean hasItemMeta() {
return hasItemMeta(handle);
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/MinecraftInventory.java b/src/main/java/org/bukkit/craftbukkit/inventory/MinecraftInventory.java
new file mode 100644
index 0000000..b990b6b
--- /dev/null
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/MinecraftInventory.java
@@ -0,0 +1,183 @@
+package org.bukkit.craftbukkit.inventory;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.entity.HumanEntity;
+import org.bukkit.event.inventory.InventoryType;
+import org.bukkit.inventory.InventoryHolder;
+
+import net.minecraft.server.ChatComponentText;
+import net.minecraft.server.EntityHuman;
+import net.minecraft.server.IChatBaseComponent;
+import net.minecraft.server.IInventory;
+import net.minecraft.server.ItemStack;
+
+import org.apache.commons.lang.Validate;
+
+public class MinecraftInventory implements IInventory
+{
+ private final ItemStack[] items;
+ private int maxStack = MAX_STACK;
+ private final List<HumanEntity> viewers;
+ private final String title;
+ private InventoryType type;
+ private final InventoryHolder owner;
+
+ public MinecraftInventory(InventoryHolder owner, InventoryType type) {
+ this(owner, type.getDefaultSize(), type.getDefaultTitle());
+ this.type = type;
+ }
+
+ public MinecraftInventory(InventoryHolder owner, InventoryType type, String title) {
+ this(owner, type.getDefaultSize(), title);
+ this.type = type;
+ }
+
+ public MinecraftInventory(InventoryHolder owner, int size) {
+ this(owner, size, "Chest");
+ }
+
+ public MinecraftInventory(InventoryHolder owner, int size, String title) {
+ Validate.notNull(title, "Title cannot be null");
+ Validate.isTrue(title.length() <= 32, "Title cannot be longer than 32 characters");
+ this.items = new ItemStack[size];
+ this.title = title;
+ this.viewers = new ArrayList<HumanEntity>();
+ this.owner = owner;
+ this.type = InventoryType.CHEST;
+ }
+
+ public int getSize() {
+ return items.length;
+ }
+
+ public ItemStack getItem(int i) {
+ return items[i];
+ }
+
+ public ItemStack splitStack(int i, int j) {
+ ItemStack stack = this.getItem(i);
+ ItemStack result;
+ if (stack == null) return null;
+ if (stack.count <= j) {
+ this.setItem(i, null);
+ result = stack;
+ } else {
+ result = CraftItemStack.copyNMSStack(stack, j);
+ stack.count -= j;
+ }
+ this.update();
+ return result;
+ }
+
+ public ItemStack splitWithoutUpdate(int i) {
+ ItemStack stack = this.getItem(i);
+ ItemStack result;
+ if (stack == null) return null;
+ if (stack.count <= 1) {
+ this.setItem(i, null);
+ result = stack;
+ } else {
+ result = CraftItemStack.copyNMSStack(stack, 1);
+ stack.count -= 1;
+ }
+ return result;
+ }
+
+ public void setItem(int i, ItemStack itemstack) {
+ items[i] = itemstack;
+ if (itemstack != null && this.getMaxStackSize() > 0 && itemstack.count > this.getMaxStackSize()) {
+ itemstack.count = this.getMaxStackSize();
+ }
+ }
+
+ public int getMaxStackSize() {
+ return maxStack;
+ }
+
+ public void setMaxStackSize(int size) {
+ maxStack = size;
+ }
+
+ public void update() {}
+
+ public boolean a(EntityHuman entityhuman) {
+ return true;
+ }
+
+ public ItemStack[] getContents() {
+ return items;
+ }
+
+ public void onOpen(CraftHumanEntity who) {
+ viewers.add(who);
+ }
+
+ public void onClose(CraftHumanEntity who) {
+ viewers.remove(who);
+ }
+
+ public List<HumanEntity> getViewers() {
+ return viewers;
+ }
+
+ public InventoryType getType() {
+ return type;
+ }
+
+ public InventoryHolder getOwner() {
+ return owner;
+ }
+
+ public boolean b(int i, ItemStack itemstack) {
+ return true;
+ }
+
+ @Override
+ public void startOpen(EntityHuman entityHuman) {
+
+ }
+
+ @Override
+ public void closeContainer(EntityHuman entityHuman) {
+
+ }
+
+ @Override
+ public int getProperty(int i) {
+ return 0;
+ }
+
+ @Override
+ public void b(int i, int i1) {
+
+ }
+
+ @Override
+ public int g() {
+ return 0;
+ }
+
+ @Override
+ public void l() {
+
+ }
+
+ @Override
+ public String getName() {
+ return title;
+ }
+
+ @Override
+ public boolean hasCustomName() {
+ return title != null;
+ }
+
+ @Override
+ public IChatBaseComponent getScoreboardDisplayName() {
+ return new ChatComponentText(title);
+ }
+}
\ No newline at end of file
--
1.9.4.msysgit.0