Mineplex2018-withcommit/Patches/0181-Mineplex-Patches.patch

2415 lines
79 KiB
Diff
Raw Normal View History

2014-09-05 23:40:39 +02:00
From 52ffc1e292f4a6ead573bdfcd884c800b8c4b1a5 Mon Sep 17 00:00:00 2001
2014-09-03 12:50:26 +02:00
From: Jonathan Williams <jonathan@mineplex.com>
Date: Tue, 2 Sep 2014 21:54:15 -0700
Subject: [PATCH] Mineplex Patches
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
index 0423ee9..559693f 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -633,6 +633,10 @@ public class Chunk {
// CraftBukkit end
}
+ 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/ChunkAddEntityEvent.java b/src/main/java/net/minecraft/server/ChunkAddEntityEvent.java
new file mode 100644
index 0000000..f3fd0e1
--- /dev/null
+++ b/src/main/java/net/minecraft/server/ChunkAddEntityEvent.java
@@ -0,0 +1,31 @@
+package net.minecraft.server;
+
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList;
+
+public class ChunkAddEntityEvent extends Event
+{
+ private static final HandlerList handlers = new HandlerList();
+ private org.bukkit.entity.Entity _entity;
+
+ public ChunkAddEntityEvent(org.bukkit.entity.Entity entity)
+ {
+ _entity = entity;
+ }
+
+ public HandlerList getHandlers()
+ {
+ return handlers;
+ }
+
+ public static HandlerList getHandlerList()
+ {
+ return handlers;
+ }
+
+ public org.bukkit.entity.Entity GetEntity()
+ {
+ return _entity;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/net/minecraft/server/ChunkPreLoadEvent.java b/src/main/java/net/minecraft/server/ChunkPreLoadEvent.java
new file mode 100644
index 0000000..9d698f3
--- /dev/null
+++ b/src/main/java/net/minecraft/server/ChunkPreLoadEvent.java
@@ -0,0 +1,58 @@
+package net.minecraft.server;
+
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList;
+
+public class ChunkPreLoadEvent extends Event implements Cancellable
+{
+ private static final HandlerList handlers = new HandlerList();
+ private boolean _cancelled;
+ private org.bukkit.World _world;
+ private int _x;
+ private int _z;
+
+ public ChunkPreLoadEvent(org.bukkit.World world, int x, int z)
+ {
+ _world = world;
+ _x = x;
+ _z = z;
+ }
+
+ public HandlerList getHandlers()
+ {
+ return handlers;
+ }
+
+ public static HandlerList getHandlerList()
+ {
+ return handlers;
+ }
+
+ public org.bukkit.World GetWorld()
+ {
+ return _world;
+ }
+
+ public int GetX()
+ {
+ return _x;
+ }
+
+ public int GetZ()
+ {
+ return _z;
+ }
+
+ @Override
+ public boolean isCancelled()
+ {
+ return _cancelled;
+ }
+
+ @Override
+ public void setCancelled(boolean arg0)
+ {
+ _cancelled = arg0;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index 22330c3..6438052 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
@@ -114,10 +114,42 @@ public class ChunkProviderServer implements IChunkProvider {
// We can only use the queue for already generated chunks
if (chunk == null && loader != null && loader.chunkExists(this.world, i, j)) {
if (runnable != null) {
- ChunkIOExecutor.queueChunkLoad(this.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(this.world, loader, this, i, j, runnable);
+ }
+
return null;
} else {
- chunk = ChunkIOExecutor.syncChunkLoad(this.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(this.world, loader, this, i, j);
+ }
}
} else if (chunk == null) {
chunk = this.originalGetChunkAt(i, j);
@@ -136,6 +168,23 @@ public class ChunkProviderServer implements IChunkProvider {
Chunk chunk = (Chunk) this.chunks.get(LongHash.toLong(i, j));
boolean newChunk = false;
+ 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);
@@ -162,7 +211,6 @@ public class ChunkProviderServer implements IChunkProvider {
chunk.addEntities();
// CraftBukkit start
- Server server = this.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 9cc0526..337e962 100644
--- a/src/main/java/net/minecraft/server/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/DedicatedServer.java
@@ -78,63 +78,50 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
this.propertyManager = new PropertyManager(this.options); // CraftBukkit - CLI argument support
this.n = new EULA(new File("eula.txt"));
// Spigot Start
- boolean eulaAgreed = Boolean.getBoolean( "com.mojang.eula.agree" );
- if ( eulaAgreed )
- {
- System.err.println( "You have used the Spigot command line EULA agreement flag." );
- System.err.println( "By using this setting you are indicating your agreement to Mojang's EULA (https://account.mojang.com/documents/minecraft_eula)." );
- 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.n.a() && !eulaAgreed) {
- i.info("You need to agree to the EULA in order to run the server. Go to eula.txt for more info.");
- this.n.b();
- return false;
- } else {
- if (this.N()) {
- this.c("127.0.0.1");
- } else {
- this.setOnlineMode(this.propertyManager.getBoolean("online-mode", true));
- this.c(this.propertyManager.getString("server-ip", ""));
- }
-
- this.setSpawnAnimals(this.propertyManager.getBoolean("spawn-animals", true));
- this.setSpawnNPCs(this.propertyManager.getBoolean("spawn-npcs", true));
- this.setPvP(this.propertyManager.getBoolean("pvp", true));
- this.setAllowFlight(this.propertyManager.getBoolean("allow-flight", false));
- this.setTexturePack(this.propertyManager.getString("resource-pack", ""));
- this.setMotd(this.propertyManager.getString("motd", "A Minecraft Server"));
- this.setForceGamemode(this.propertyManager.getBoolean("force-gamemode", false));
- this.setIdleTimeout(this.propertyManager.getInt("player-idle-timeout", 0));
- if (this.propertyManager.getInt("difficulty", 1) < 0) {
- this.propertyManager.setProperty("difficulty", Integer.valueOf(0));
- } else if (this.propertyManager.getInt("difficulty", 1) > 3) {
- this.propertyManager.setProperty("difficulty", Integer.valueOf(3));
- }
-
- this.generateStructures = this.propertyManager.getBoolean("generate-structures", true);
- int gamemode = this.propertyManager.getInt("gamemode", EnumGamemode.SURVIVAL.getId()); // CraftBukkit - Unique name to avoid stomping on logger
-
- this.p = WorldSettings.a(gamemode); // CraftBukkit - Use new name
- i.info("Default game type: " + this.p);
- InetAddress inetaddress = null;
-
- if (this.getServerIp().length() > 0) {
- inetaddress = InetAddress.getByName(this.getServerIp());
- }
-
- if (this.L() < 0) {
- this.setPort(this.propertyManager.getInt("server-port", 25565));
- }
- // Spigot start
- this.a((PlayerList) (new DedicatedPlayerList(this)));
- org.spigotmc.SpigotConfig.init();
- org.spigotmc.SpigotConfig.registerCommands();
- // Spigot end
-
- i.info("Generating keypair");
- this.a(MinecraftEncryption.b());
- i.info("Starting Minecraft server on " + (this.getServerIp().length() == 0 ? "*" : this.getServerIp()) + ":" + this.L());
+ if (this.N()) {
+ this.c("127.0.0.1");
+ } else {
+ this.setOnlineMode(this.propertyManager.getBoolean("online-mode", true));
+ this.c(this.propertyManager.getString("server-ip", ""));
+ }
+
+ this.setSpawnAnimals(this.propertyManager.getBoolean("spawn-animals", true));
+ this.setSpawnNPCs(this.propertyManager.getBoolean("spawn-npcs", true));
+ this.setPvP(this.propertyManager.getBoolean("pvp", true));
+ this.setAllowFlight(this.propertyManager.getBoolean("allow-flight", false));
+ this.setTexturePack(this.propertyManager.getString("resource-pack", ""));
+ this.setMotd(this.propertyManager.getString("motd", "A Minecraft Server"));
+ this.setForceGamemode(this.propertyManager.getBoolean("force-gamemode", false));
+ this.setIdleTimeout(this.propertyManager.getInt("player-idle-timeout", 0));
+ if (this.propertyManager.getInt("difficulty", 1) < 0) {
+ this.propertyManager.setProperty("difficulty", Integer.valueOf(0));
+ } else if (this.propertyManager.getInt("difficulty", 1) > 3) {
+ this.propertyManager.setProperty("difficulty", Integer.valueOf(3));
+ }
+
+ this.generateStructures = this.propertyManager.getBoolean("generate-structures", true);
+ int gamemode = this.propertyManager.getInt("gamemode", EnumGamemode.SURVIVAL.getId()); // CraftBukkit - Unique name to avoid stomping on logger
+
+ this.p = WorldSettings.a(gamemode); // CraftBukkit - Use new name
+ i.info("Default game type: " + this.p);
+ InetAddress inetaddress = null;
+
+ if (this.getServerIp().length() > 0) {
+ inetaddress = InetAddress.getByName(this.getServerIp());
+ }
+
+ if (this.L() < 0) {
+ this.setPort(this.propertyManager.getInt("server-port", 25565));
+ }
+ // Spigot start
+ this.a((PlayerList) (new DedicatedPlayerList(this)));
+ org.spigotmc.SpigotConfig.init();
+ org.spigotmc.SpigotConfig.registerCommands();
+ // Spigot end
+
+ i.info("Generating keypair");
+ this.a(MinecraftEncryption.b());
+ i.info("Starting Minecraft server on " + (this.getServerIp().length() == 0 ? "*" : this.getServerIp()) + ":" + this.L());
if (!org.spigotmc.SpigotConfig.lateBind) {
try {
@@ -147,93 +134,93 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
}
}
- // Spigot Start - Move DedicatedPlayerList up and bring plugin loading from CraftServer to here
- // this.a((PlayerList) (new DedicatedPlayerList(this))); // CraftBukkit
- server.loadPlugins();
- server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.STARTUP);
- // Spigot End
-
- if (!this.getOnlineMode()) {
- i.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!");
- i.warn("The server will make no attempt to authenticate usernames. Beware.");
- i.warn("While this makes the game possible to play without internet access, it also opens up the ability for hackers to connect with any username they choose.");
- i.warn("To change this, set \"online-mode\" to \"true\" in the server.properties file.");
- }
-
- if (this.aE()) {
- this.getUserCache().c();
- }
-
- if (!NameReferencingFileConverter.a(this.propertyManager)) {
- return false;
- } else {
- // this.a((PlayerList) (new DedicatedPlayerList(this))); // CraftBukkit - moved up
- this.convertable = new WorldLoaderServer(server.getWorldContainer()); // CraftBukkit - moved from MinecraftServer constructor
- long j = System.nanoTime();
-
- if (this.O() == null) {
- this.k(this.propertyManager.getString("level-name", "world"));
- }
-
- String s = this.propertyManager.getString("level-seed", "");
- String s1 = this.propertyManager.getString("level-type", "DEFAULT");
- String s2 = this.propertyManager.getString("generator-settings", "");
- long k = (new Random()).nextLong();
-
- if (s.length() > 0) {
- try {
- long l = Long.parseLong(s);
-
- if (l != 0L) {
- k = l;
- }
- } catch (NumberFormatException numberformatexception) {
- k = (long) s.hashCode();
- }
- }
-
- WorldType worldtype = WorldType.getType(s1);
-
- if (worldtype == null) {
- worldtype = WorldType.NORMAL;
- }
-
- this.at();
- this.getEnableCommandBlock();
- this.l();
- this.getSnooperEnabled();
- this.c(this.propertyManager.getInt("max-build-height", 256));
- this.c((this.getMaxBuildHeight() + 8) / 16 * 16);
- this.c(MathHelper.a(this.getMaxBuildHeight(), 64, 256));
- this.propertyManager.setProperty("max-build-height", Integer.valueOf(this.getMaxBuildHeight()));
- i.info("Preparing level \"" + this.O() + "\"");
- this.a(this.O(), this.O(), k, worldtype, s2);
- long i1 = System.nanoTime() - j;
- String s3 = String.format("%.3fs", new Object[] { Double.valueOf((double) i1 / 1.0E9D)});
-
- i.info("Done (" + s3 + ")! For help, type \"help\" or \"?\"");
- if (this.propertyManager.getBoolean("enable-query", false)) {
- i.info("Starting GS4 status listener");
- this.k = new RemoteStatusListener(this);
- this.k.a();
- }
-
- if (this.propertyManager.getBoolean("enable-rcon", false)) {
- i.info("Starting remote control listener");
- this.l = new RemoteControlListener(this);
- this.l.a();
- this.remoteConsole = new org.bukkit.craftbukkit.command.CraftRemoteConsoleCommandSender(); // CraftBukkit
- }
-
- // CraftBukkit start
- if (this.server.getBukkitSpawnRadius() > -1) {
- i.info("'settings.spawn-radius' in bukkit.yml has been moved to 'spawn-protection' in server.properties. I will move your config for you.");
- this.propertyManager.properties.remove("spawn-protection");
- this.propertyManager.getInt("spawn-protection", this.server.getBukkitSpawnRadius());
- this.server.removeBukkitSpawnRadius();
- this.propertyManager.savePropertiesFile();
- }
- // CraftBukkit end
+ // Spigot Start - Move DedicatedPlayerList up and bring plugin loading from CraftServer to here
+ // this.a((PlayerList) (new DedicatedPlayerList(this))); // CraftBukkit
+ server.loadPlugins();
+ server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.STARTUP);
+ // Spigot End
+
+ if (!this.getOnlineMode()) {
+ i.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!");
+ i.warn("The server will make no attempt to authenticate usernames. Beware.");
+ i.warn("While this makes the game possible to play without internet access, it also opens up the ability for hackers to connect with any username they choose.");
+ i.warn("To change this, set \"online-mode\" to \"true\" in the server.properties file.");
+ }
+
+ if (this.aE()) {
+ this.getUserCache().c();
+ }
+
+ if (!NameReferencingFileConverter.a(this.propertyManager)) {
+ return false;
+ } else {
+ // this.a((PlayerList) (new DedicatedPlayerList(this))); // CraftBukkit - moved up
+ this.convertable = new WorldLoaderServer(server.getWorldContainer()); // CraftBukkit - moved from MinecraftServer constructor
+ long j = System.nanoTime();
+
+ if (this.O() == null) {
+ this.k(this.propertyManager.getString("level-name", "world"));
+ }
+
+ String s = this.propertyManager.getString("level-seed", "");
+ String s1 = this.propertyManager.getString("level-type", "DEFAULT");
+ String s2 = this.propertyManager.getString("generator-settings", "");
+ long k = (new Random()).nextLong();
+
+ if (s.length() > 0) {
+ try {
+ long l = Long.parseLong(s);
+
+ if (l != 0L) {
+ k = l;
+ }
+ } catch (NumberFormatException numberformatexception) {
+ k = (long) s.hashCode();
+ }
+ }
+
+ WorldType worldtype = WorldType.getType(s1);
+
+ if (worldtype == null) {
+ worldtype = WorldType.NORMAL;
+ }
+
+ this.at();
+ this.getEnableCommandBlock();
+ this.l();
+ this.getSnooperEnabled();
+ this.c(this.propertyManager.getInt("max-build-height", 256));
+ this.c((this.getMaxBuildHeight() + 8) / 16 * 16);
+ this.c(MathHelper.a(this.getMaxBuildHeight(), 64, 256));
+ this.propertyManager.setProperty("max-build-height", Integer.valueOf(this.getMaxBuildHeight()));
+ i.info("Preparing level \"" + this.O() + "\"");
+ this.a(this.O(), this.O(), k, worldtype, s2);
+ long i1 = System.nanoTime() - j;
+ String s3 = String.format("%.3fs", new Object[] { Double.valueOf((double) i1 / 1.0E9D)});
+
+ i.info("Done (" + s3 + ")! For help, type \"help\" or \"?\"");
+ if (this.propertyManager.getBoolean("enable-query", false)) {
+ i.info("Starting GS4 status listener");
+ this.k = new RemoteStatusListener(this);
+ this.k.a();
+ }
+
+ if (this.propertyManager.getBoolean("enable-rcon", false)) {
+ i.info("Starting remote control listener");
+ this.l = new RemoteControlListener(this);
+ this.l.a();
+ this.remoteConsole = new org.bukkit.craftbukkit.command.CraftRemoteConsoleCommandSender(); // CraftBukkit
+ }
+
+ // CraftBukkit start
+ if (this.server.getBukkitSpawnRadius() > -1) {
+ i.info("'settings.spawn-radius' in bukkit.yml has been moved to 'spawn-protection' in server.properties. I will move your config for you.");
+ this.propertyManager.properties.remove("spawn-protection");
+ this.propertyManager.getInt("spawn-protection", this.server.getBukkitSpawnRadius());
+ this.server.removeBukkitSpawnRadius();
+ this.propertyManager.savePropertiesFile();
+ }
+ // CraftBukkit end
if (org.spigotmc.SpigotConfig.lateBind) {
try {
@@ -246,7 +233,6 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
}
}
return true;
- }
}
}
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index dea5e19..9253cd4 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -123,6 +123,9 @@ public abstract class Entity {
public void inactiveTick() { }
// Spigot end
+ public boolean Silent;
+ public boolean Invisible;
+
public int getId() {
return this.id;
}
@@ -692,7 +695,9 @@ public abstract class Entity {
this.makeSound(this.H(), f, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F);
}
- this.a(l, k, i1, block);
+ if (!Silent)
+ this.a(l, k, i1, block);
+
block.b(this.world, l, k, i1, this);
}
}
@@ -788,7 +793,8 @@ public abstract class Entity {
}
public void makeSound(String s, float f, float f1) {
- this.world.makeSound(this, s, f, f1);
+ if (!Silent)
+ this.world.makeSound(this, s, f, f1);
}
protected boolean g_() {
@@ -1446,8 +1452,8 @@ public abstract class Entity {
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() || this.vehicle != originalVehicle) {
@@ -1464,11 +1470,11 @@ public abstract class Entity {
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)) {
+ if ((this.bukkitEntity instanceof LivingEntity) && (entity instanceof Vehicle) && entity.world.isChunkLoaded((int) entity.locX >> 4, (int) entity.locZ >> 4)) {
// 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);
+ 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)) {
@@ -1584,6 +1590,9 @@ public abstract class Entity {
}
public void setInvisible(boolean flag) {
+ if (Invisible && !flag)
+ return;
+
this.a(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..dcf0a2e
--- /dev/null
+++ b/src/main/java/net/minecraft/server/EntityBat.java
@@ -0,0 +1,260 @@
+package net.minecraft.server;
+
+import java.util.Calendar;
+import java.util.Random;
+
+import net.minecraft.server.ChunkCoordinates;
+import net.minecraft.server.DamageSource;
+import net.minecraft.server.Entity;
+import net.minecraft.server.EntityAmbient;
+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 ChunkCoordinates h;
+
+ public boolean Vegetated = false;
+
+ public EntityBat(World paramWorld)
+ {
+ super(paramWorld);
+
+ a(0.5F, 0.9F);
+ setAsleep(true);
+ }
+
+ protected void c()
+ {
+ super.c();
+
+ this.datawatcher.a(16, new Byte((byte) 0));
+ }
+
+ protected float bf()
+ {
+ return 0.1F;
+ }
+
+ protected float bg()
+ {
+ return super.bg() * 0.95F;
+ }
+
+ protected String t()
+ {
+ if ((isAsleep()) && (this.random.nextInt(4) != 0))
+ {
+ return null;
+ }
+ return "mob.bat.idle";
+ }
+
+ protected String aT()
+ {
+ return "mob.bat.hurt";
+ }
+
+ protected String aU()
+ {
+ return "mob.bat.death";
+ }
+
+ public boolean S()
+ {
+ return false;
+ }
+
+ protected void o(Entity paramEntity)
+ {
+ }
+
+ protected void bo()
+ {
+ }
+
+ protected void aD()
+ {
+ super.aD();
+
+ getAttributeInstance(GenericAttributes.maxHealth).setValue(6.0D);
+ }
+
+ public boolean isAsleep()
+ {
+ return (this.datawatcher.getByte(16) & 0x1) != 0;
+ }
+
+ public void setAsleep(boolean paramBoolean)
+ {
+ int i = this.datawatcher.getByte(16);
+ if (paramBoolean)
+ {
+ this.datawatcher.watch(16, Byte.valueOf((byte) (i | 0x1)));
+ }
+ else
+ {
+ this.datawatcher.watch(16, Byte.valueOf((byte) (i & 0xFFFFFFFE)));
+ }
+ }
+
+ protected boolean bk()
+ {
+ return true;
+ }
+
+ public void h()
+ {
+ super.h();
+
+ if (Vegetated)
+ return;
+
+ if (isAsleep())
+ {
+ this.motX = (this.motY = this.motZ = 0.0D);
+ this.locY = (MathHelper.floor(this.locY) + 1.0D - this.length);
+ }
+ else
+ {
+ this.motY *= 0.6000000238418579D;
+ }
+ }
+
+ protected void bn()
+ {
+ super.bn();
+
+ if (Vegetated)
+ return;
+
+ if (isAsleep())
+ {
+ if (!this.world.getType(MathHelper.floor(this.locX), (int) this.locY + 1, MathHelper.floor(this.locZ)).r())
+ {
+ setAsleep(false);
+ this.world.a(null, 1015, (int) this.locX, (int) this.locY, (int) this.locZ, 0);
+ }
+ else
+ {
+ if (this.random.nextInt(200) == 0)
+ {
+ this.aO = this.random.nextInt(360);
+ }
+ if (this.world.findNearbyPlayer(this, 4.0D) != null)
+ {
+ setAsleep(false);
+ this.world.a(null, 1015, (int) this.locX, (int) this.locY, (int) this.locZ, 0);
+ }
+ }
+ }
+ else
+ {
+ if ((this.h != null) && ((!this.world.isEmpty(this.h.x, this.h.y, this.h.z)) || (this.h.y < 1)))
+ {
+ this.h = null;
+ }
+ 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.be = 0.5F;
+ this.yaw += f2;
+ if ((this.random.nextInt(100) == 0)
+ && (this.world.getType(MathHelper.floor(this.locX), (int) this.locY + 1,
+ MathHelper.floor(this.locZ)).r()))
+ {
+ setAsleep(true);
+ }
+ }
+ }
+
+ protected boolean g_()
+ {
+ return false;
+ }
+
+ 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) && (isAsleep()) && !Vegetated)
+ {
+ setAsleep(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.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;
+ }
+ return super.canSpawn();
+ }
+}
diff --git a/src/main/java/net/minecraft/server/EntityBlaze.java b/src/main/java/net/minecraft/server/EntityBlaze.java
new file mode 100644
index 0000000..2868ffa
--- /dev/null
+++ b/src/main/java/net/minecraft/server/EntityBlaze.java
@@ -0,0 +1,202 @@
+package net.minecraft.server;
+
+import java.util.Random;
+
+import net.minecraft.server.DamageSource;
+import net.minecraft.server.Entity;
+import net.minecraft.server.EntityMonster;
+import net.minecraft.server.EntitySmallFireball;
+import net.minecraft.server.GenericAttributes;
+import net.minecraft.server.Item;
+import net.minecraft.server.Items;
+import net.minecraft.server.MathHelper;
+import net.minecraft.server.World;
+
+public class EntityBlaze extends EntityMonster
+{
+ private float bp = 0.5F;
+ private int bq;
+ private int br;
+
+ public EntityBlaze(World paramWorld)
+ {
+ super(paramWorld);
+
+ this.fireProof = true;
+ this.b = 10;
+ }
+
+ protected void aD()
+ {
+ super.aD();
+ getAttributeInstance(GenericAttributes.e).setValue(6.0D);
+ }
+
+ protected void c()
+ {
+ super.c();
+
+ this.datawatcher.a(16, new Byte((byte) 0));
+ }
+
+ protected String t()
+ {
+ return "mob.blaze.breathe";
+ }
+
+ protected String aT()
+ {
+ return "mob.blaze.hit";
+ }
+
+ protected String aU()
+ {
+ return "mob.blaze.death";
+ }
+
+ public float d(float paramFloat)
+ {
+ return 1.0F;
+ }
+
+ public void e()
+ {
+ if (!this.world.isStatic)
+ {
+ if (L())
+ {
+ damageEntity(DamageSource.DROWN, 1.0F);
+ }
+ this.bq -= 1;
+ if (this.bq <= 0)
+ {
+ this.bq = 100;
+ this.bp = (0.5F + (float) this.random.nextGaussian() * 3.0F);
+ }
+ if ((bT() != null) && (bT().locY + bT().getHeadHeight() > this.locY + getHeadHeight() + this.bp))
+ {
+ this.motY += (0.300000011920929D - this.motY) * 0.300000011920929D;
+ }
+ }
+ if (this.random.nextInt(24) == 0)
+ {
+ this.world.makeSound(this.locX + 0.5D, this.locY + 0.5D, this.locZ + 0.5D, "fire.fire",
+ 1.0F + this.random.nextFloat(), this.random.nextFloat() * 0.7F + 0.3F);
+ }
+ if (!Vegetated && (!this.onGround) && (this.motY < 0.0D))
+ {
+ this.motY *= 0.6D;
+ }
+ for (int i = 0; i < 2; i++)
+ {
+ this.world.addParticle("largesmoke", this.locX + (this.random.nextDouble() - 0.5D) * this.width, this.locY
+ + this.random.nextDouble() * this.length, this.locZ + (this.random.nextDouble() - 0.5D)
+ * this.width, 0.0D, 0.0D, 0.0D);
+ }
+ super.e();
+ }
+
+ protected void a(Entity paramEntity, float paramFloat)
+ {
+ if (Vegetated)
+ return;
+
+ if ((this.attackTicks <= 0) && (paramFloat < 2.0F) && (paramEntity.boundingBox.e > this.boundingBox.b)
+ && (paramEntity.boundingBox.b < this.boundingBox.e))
+ {
+ this.attackTicks = 20;
+ n(paramEntity);
+ }
+ else if (paramFloat < 30.0F)
+ {
+ double d1 = paramEntity.locX - this.locX;
+ double d2 = paramEntity.boundingBox.b + paramEntity.length / 2.0F - (this.locY + this.length / 2.0F);
+ double d3 = paramEntity.locZ - this.locZ;
+ if (this.attackTicks == 0)
+ {
+ this.br += 1;
+ if (this.br == 1)
+ {
+ this.attackTicks = 60;
+ a(true);
+ }
+ else if (this.br <= 4)
+ {
+ this.attackTicks = 6;
+ }
+ else
+ {
+ this.attackTicks = 100;
+ this.br = 0;
+ a(false);
+ }
+ if (this.br > 1)
+ {
+ float f = MathHelper.c(paramFloat) * 0.5F;
+
+ this.world.a(null, 1009, (int) this.locX, (int) this.locY, (int) this.locZ, 0);
+ for (int i = 0; i < 1; i++)
+ {
+ EntitySmallFireball localEntitySmallFireball = new EntitySmallFireball(this.world, this, d1
+ + this.random.nextGaussian() * f, d2, d3 + this.random.nextGaussian() * f);
+ localEntitySmallFireball.locY = (this.locY + this.length / 2.0F + 0.5D);
+ this.world.addEntity(localEntitySmallFireball);
+ }
+ }
+ }
+ this.yaw = ((float) (Math.atan2(d3, d1) * 180.0D / 3.141592741012573D) - 90.0F);
+
+ this.bn = true;
+ }
+ }
+
+ protected void b(float paramFloat)
+ {
+ }
+
+ protected Item getLoot()
+ {
+ return Items.BLAZE_ROD;
+ }
+
+ public boolean isBurning()
+ {
+ return bZ();
+ }
+
+ protected void dropDeathLoot(boolean paramBoolean, int paramInt)
+ {
+ if (paramBoolean)
+ {
+ int i = this.random.nextInt(2 + paramInt);
+ for (int j = 0; j < i; j++)
+ {
+ a(Items.BLAZE_ROD, 1);
+ }
+ }
+ }
+
+ public boolean bZ()
+ {
+ return (this.datawatcher.getByte(16) & 0x1) != 0;
+ }
+
+ public void a(boolean paramBoolean)
+ {
+ byte b = this.datawatcher.getByte(16);
+ if (paramBoolean)
+ {
+ b = (byte) (b | 0x1);
+ }
+ else
+ {
+ b = (byte) (b & 0xFFFFFFFE);
+ }
+ this.datawatcher.watch(16, Byte.valueOf(b));
+ }
+
+ protected boolean j_()
+ {
+ return true;
+ }
+}
diff --git a/src/main/java/net/minecraft/server/EntityEnderDragon.java b/src/main/java/net/minecraft/server/EntityEnderDragon.java
index 5d761aa..f64a7e5 100644
--- a/src/main/java/net/minecraft/server/EntityEnderDragon.java
+++ b/src/main/java/net/minecraft/server/EntityEnderDragon.java
@@ -38,6 +38,8 @@ public class EntityEnderDragon extends EntityInsentient implements IComplex, IMo
public EntityEnderCrystal bC;
private Explosion explosionSource = new Explosion(null, this, Double.NaN, Double.NaN, Double.NaN, Float.NaN); // CraftBukkit - reusable source for CraftTNTPrimed.getSource()
+ public boolean Vegetated = false;
+
public EntityEnderDragon(World world) {
super(world);
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)};
@@ -163,7 +165,7 @@ public class EntityEnderDragon extends EntityInsentient implements IComplex, IMo
this.bm += this.random.nextGaussian() * 2.0D;
}
- if (this.bz || d3 < 100.0D || d3 > 22500.0D || this.positionChanged || this.F) {
+ if (!Vegetated && this.bz || d3 < 100.0D || d3 > 22500.0D || this.positionChanged || this.F) {
this.bQ();
}
@@ -251,7 +253,7 @@ public class EntityEnderDragon extends EntityInsentient implements IComplex, IMo
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.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) {
+ 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)));
this.a(this.world.getEntities(this, this.bw.boundingBox.grow(4.0D, 2.0D, 4.0D).d(0.0D, -2.0D, 0.0D)));
this.b(this.world.getEntities(this, this.bq.boundingBox.grow(1.0D, 1.0D, 1.0D)));
@@ -369,6 +371,19 @@ public class EntityEnderDragon extends EntityInsentient implements IComplex, IMo
}
}
+ public void setTargetBlock(int x, int y, int z)
+ {
+ this.h = x;
+ this.i = y;
+ this.bm = z;
+ this.bD = null;
+ }
+
+ public void setTargetEntity(Entity entity)
+ {
+ this.bD = entity;
+ }
+
private void bQ() {
this.bz = false;
if (this.random.nextInt(2) == 0 && !this.world.players.isEmpty()) {
diff --git a/src/main/java/net/minecraft/server/EntityEnderman.java b/src/main/java/net/minecraft/server/EntityEnderman.java
index 87afc9c..b9a2b3a 100644
--- a/src/main/java/net/minecraft/server/EntityEnderman.java
+++ b/src/main/java/net/minecraft/server/EntityEnderman.java
@@ -52,6 +52,9 @@ public class EntityEnderman extends EntityMonster {
}
protected Entity findTarget() {
+ if (Vegetated)
+ return null;
+
EntityHuman entityhuman = this.world.findNearbyVulnerablePlayer(this, 64.0D);
if (entityhuman != null) {
diff --git a/src/main/java/net/minecraft/server/EntityFallingBlock.java b/src/main/java/net/minecraft/server/EntityFallingBlock.java
index df602bd..a8ad2c4 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;
public NBTTagCompound tileEntityData;
+ public boolean spectating;
+
public EntityFallingBlock(World world) {
super(world);
this.dropItem = true;
@@ -54,7 +56,15 @@ public class EntityFallingBlock extends Entity {
protected void c() {}
public boolean R() {
- return !this.dead;
+ return !this.dead && !spectating;
+ }
+
+ @Override
+ public boolean damageEntity(DamageSource damagesource, float f)
+ {
+ CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f);
+
+ return true;
}
public void h() {
diff --git a/src/main/java/net/minecraft/server/EntityHorse.java b/src/main/java/net/minecraft/server/EntityHorse.java
index e9f6236..8253ec9 100644
--- a/src/main/java/net/minecraft/server/EntityHorse.java
+++ b/src/main/java/net/minecraft/server/EntityHorse.java
@@ -115,6 +115,9 @@ public class EntityHorse extends EntityAnimal implements IInventoryListener {
private void b(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 5bb7295..595f15f 100644
--- a/src/main/java/net/minecraft/server/EntityHuman.java
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
@@ -124,7 +124,7 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen
if (this.f != null) {
ItemStack itemstack = this.inventory.getItemInHand();
- if (itemstack == this.f) {
+ if (ItemStack.equals(itemstack, this.f)) {
if (this.g <= 25 && this.g % 4 == 0) {
this.c(itemstack, 5);
}
diff --git a/src/main/java/net/minecraft/server/EntityInsentient.java b/src/main/java/net/minecraft/server/EntityInsentient.java
index 617f7d4..8781438 100644
--- a/src/main/java/net/minecraft/server/EntityInsentient.java
+++ b/src/main/java/net/minecraft/server/EntityInsentient.java
@@ -34,6 +34,10 @@ public abstract class EntityInsentient extends EntityLiving {
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);
@@ -114,7 +118,7 @@ public abstract class EntityInsentient extends EntityLiving {
public void C() {
super.C();
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.q();
this.r();
}
@@ -774,7 +778,7 @@ public abstract class EntityInsentient extends EntityLiving {
}
public final boolean c(EntityHuman entityhuman) {
- if (this.bN() && this.getLeashHolder() == entityhuman) {
+ if (this.bN() && this.getLeashHolder() == entityhuman && BreakLeash) {
// CraftBukkit start - fire PlayerUnleashEntityEvent
if (CraftEventFactory.callPlayerUnleashEntityEvent(this, entityhuman).isCancelled()) {
((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutAttachEntity(1, this, this.getLeashHolder()));
@@ -834,7 +838,7 @@ public abstract class EntityInsentient extends EntityLiving {
}
public void unleash(boolean flag, boolean flag1) {
- if (this.bv) {
+ if (this.bv && BreakLeash) {
this.bv = false;
this.bw = 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 546b952..881b87f 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -91,6 +91,7 @@ public abstract class EntityLiving extends Entity {
++this.aU; // Above all the floats
}
// Spigot end
+ public boolean ghost;
public EntityLiving(World world) {
super(world);
@@ -1699,7 +1700,7 @@ public abstract class EntityLiving extends Entity {
}
public boolean S() {
- return !this.dead;
+ return !ghost && !this.dead;
}
public float getHeadHeight() {
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
index 6e80242..7eb8f94 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -71,7 +71,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
@Override
public boolean R()
{
- return this.collidesWithEntities && super.R(); // (first !this.isDead near bottom of EntityLiving)
+ return !spectating && this.collidesWithEntities && super.R(); // (first !this.isDead near bottom of EntityLiving)
}
@Override
@@ -81,6 +81,8 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
}
// Spigot end
+ public boolean spectating; // Mineplex
+
public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, PlayerInteractManager playerinteractmanager) {
super(worldserver, gameprofile);
playerinteractmanager.player = this;
diff --git a/src/main/java/net/minecraft/server/EntitySlime.java b/src/main/java/net/minecraft/server/EntitySlime.java
index 65cd24d..60423f2 100644
--- a/src/main/java/net/minecraft/server/EntitySlime.java
+++ b/src/main/java/net/minecraft/server/EntitySlime.java
@@ -109,6 +109,10 @@ public class EntitySlime extends EntityInsentient implements IMonster {
protected void bq() {
this.w();
+
+ if (Vegetated)
+ return;
+
// CraftBukkit start
Entity entityhuman = this.world.findNearbyVulnerablePlayer(this, 16.0D); // EntityHuman -> Entity
EntityTargetEvent event = null;
diff --git a/src/main/java/net/minecraft/server/EntityTNTPrimed.java b/src/main/java/net/minecraft/server/EntityTNTPrimed.java
index 2214660..0905078 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;
@@ -38,7 +40,7 @@ public class EntityTNTPrimed extends Entity {
}
public boolean R() {
- return !this.dead;
+ return !this.dead && !spectating;
}
public void h() {
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 43df03a..5e34263 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 extends Packet {
- private int a;
+ public int a;
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..72eba15
--- /dev/null
+++ b/src/main/java/net/minecraft/server/PacketPlayOutAnimation.java
@@ -0,0 +1,42 @@
+package net.minecraft.server;
+
+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)
+{
+}
+}
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..c182fae
--- /dev/null
+++ b/src/main/java/net/minecraft/server/PacketPlayOutAttachEntity.java
@@ -0,0 +1,41 @@
+package net.minecraft.server;
+
+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)
+{
+}
+}
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutEntity.java b/src/main/java/net/minecraft/server/PacketPlayOutEntity.java
index 749b32d..be48529 100644
--- a/src/main/java/net/minecraft/server/PacketPlayOutEntity.java
+++ b/src/main/java/net/minecraft/server/PacketPlayOutEntity.java
@@ -2,13 +2,13 @@ package net.minecraft.server;
public class PacketPlayOutEntity extends Packet {
- protected int a;
- protected byte b;
- protected byte c;
- protected byte d;
- protected byte e;
- protected byte f;
- protected boolean g;
+ public int a;
+ public byte b;
+ public byte c;
+ public byte d;
+ public byte e;
+ public byte f;
+ public boolean g;
public PacketPlayOutEntity() {}
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutEntityEquipment.java b/src/main/java/net/minecraft/server/PacketPlayOutEntityEquipment.java
index 1ca4f08..d5376f4 100644
--- a/src/main/java/net/minecraft/server/PacketPlayOutEntityEquipment.java
+++ b/src/main/java/net/minecraft/server/PacketPlayOutEntityEquipment.java
@@ -2,9 +2,9 @@ package net.minecraft.server;
public class PacketPlayOutEntityEquipment extends Packet {
- private int a;
- private int b;
- private ItemStack c;
+ public int a;
+ public int b;
+ public ItemStack c;
public PacketPlayOutEntityEquipment() {}
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutEntityMetadata.java b/src/main/java/net/minecraft/server/PacketPlayOutEntityMetadata.java
index c937f59..06e933f 100644
--- a/src/main/java/net/minecraft/server/PacketPlayOutEntityMetadata.java
+++ b/src/main/java/net/minecraft/server/PacketPlayOutEntityMetadata.java
@@ -4,8 +4,8 @@ import java.util.List;
public class PacketPlayOutEntityMetadata extends Packet {
- private int a;
- private List b;
+ public int a;
+ public List b;
public PacketPlayOutEntityMetadata() {}
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutEntityTeleport.java b/src/main/java/net/minecraft/server/PacketPlayOutEntityTeleport.java
index 87260d5..a499083 100644
--- a/src/main/java/net/minecraft/server/PacketPlayOutEntityTeleport.java
+++ b/src/main/java/net/minecraft/server/PacketPlayOutEntityTeleport.java
@@ -2,12 +2,12 @@ package net.minecraft.server;
public class PacketPlayOutEntityTeleport extends Packet {
- private int a;
- private int b;
- private int c;
- private int d;
- private byte e;
- private byte f;
+ public int a;
+ public int b;
+ public int c;
+ public int d;
+ public byte e;
+ public byte f;
private boolean onGround; // Spigot - protocol patch
public PacketPlayOutEntityTeleport() {}
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutEntityVelocity.java b/src/main/java/net/minecraft/server/PacketPlayOutEntityVelocity.java
index 170f27f..d43f5d8 100644
--- a/src/main/java/net/minecraft/server/PacketPlayOutEntityVelocity.java
+++ b/src/main/java/net/minecraft/server/PacketPlayOutEntityVelocity.java
@@ -2,10 +2,10 @@ package net.minecraft.server;
public class PacketPlayOutEntityVelocity extends Packet {
- private int a;
- private int b;
- private int c;
- private int d;
+ public int a;
+ public int b;
+ public int c;
+ public int d;
public PacketPlayOutEntityVelocity() {}
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutNamedEntitySpawn.java b/src/main/java/net/minecraft/server/PacketPlayOutNamedEntitySpawn.java
index 80857c9..7e06d42 100644
--- a/src/main/java/net/minecraft/server/PacketPlayOutNamedEntitySpawn.java
+++ b/src/main/java/net/minecraft/server/PacketPlayOutNamedEntitySpawn.java
@@ -11,16 +11,16 @@ import java.io.IOException; // CraftBukkit
public class PacketPlayOutNamedEntitySpawn extends Packet {
- private int a;
- private GameProfile b;
- private int c;
- private int d;
- private int e;
- private byte f;
- private byte g;
- private int h;
- private DataWatcher i;
- private List j;
+ 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() {}
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutPlayerInfo.java b/src/main/java/net/minecraft/server/PacketPlayOutPlayerInfo.java
index adb8e8f..d324bd7 100644
--- a/src/main/java/net/minecraft/server/PacketPlayOutPlayerInfo.java
+++ b/src/main/java/net/minecraft/server/PacketPlayOutPlayerInfo.java
@@ -9,19 +9,19 @@ import org.bukkit.craftbukkit.util.CraftChatMessage;
public class PacketPlayOutPlayerInfo extends Packet {
- private static final int ADD_PLAYER = 0;
- private static final int UPDATE_GAMEMODE = 1;
- private static final int UPDATE_LATENCY = 2;
- private static final int UPDATE_DISPLAY_NAME = 3;
- private static final int REMOVE_PLAYER = 4;
+ public static final int ADD_PLAYER = 0;
+ public static final int UPDATE_GAMEMODE = 1;
+ public static final int UPDATE_LATENCY = 2;
+ public static final int UPDATE_DISPLAY_NAME = 3;
+ public static final int REMOVE_PLAYER = 4;
- private int action;
+ public int action;
// private int length; We don't batch (yet)
- private GameProfile player;
+ public GameProfile player;
- private int gamemode;
- private int ping;
- private String username;
+ public int gamemode;
+ public int ping;
+ public String username;
public PacketPlayOutPlayerInfo() {}
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutSpawnEntity.java b/src/main/java/net/minecraft/server/PacketPlayOutSpawnEntity.java
index dcf1204..37b685c 100644
--- a/src/main/java/net/minecraft/server/PacketPlayOutSpawnEntity.java
+++ b/src/main/java/net/minecraft/server/PacketPlayOutSpawnEntity.java
@@ -2,17 +2,17 @@ package net.minecraft.server;
public class PacketPlayOutSpawnEntity extends Packet {
- private int a;
- private int b;
- private int c;
- private int d;
- private int e;
- private int f;
- private int g;
- private int h;
- private int i;
- private int j;
- private int k;
+ 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() {}
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutSpawnEntityLiving.java b/src/main/java/net/minecraft/server/PacketPlayOutSpawnEntityLiving.java
index 98b4d97..0edd03a 100644
--- a/src/main/java/net/minecraft/server/PacketPlayOutSpawnEntityLiving.java
+++ b/src/main/java/net/minecraft/server/PacketPlayOutSpawnEntityLiving.java
@@ -4,19 +4,19 @@ import java.util.List;
public class PacketPlayOutSpawnEntityLiving extends Packet {
- private int a;
- private int b;
- private int c;
- private int d;
- private int e;
- private int f;
- private int g;
- private int h;
- private byte i;
- private byte j;
- private byte k;
- private DataWatcher l;
- private List m;
+ 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() {}
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..533ebfc
--- /dev/null
+++ b/src/main/java/net/minecraft/server/PacketProcessor.java
@@ -0,0 +1,44 @@
+package net.minecraft.server;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.minecraft.util.io.netty.util.concurrent.GenericFutureListener;
+
+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, new GenericFutureListener[0]);
+ }
+ }
+
+ 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 10faa8c..6aa0018 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -81,6 +81,8 @@ public class PlayerConnection implements PacketPlayInListener {
public boolean checkMovement = true; // CraftBukkit - private -> public
private boolean processedDisconnect; // CraftBukkit - added
+ public PacketProcessor PacketVerifier;
+
public PlayerConnection(MinecraftServer minecraftserver, NetworkManager networkmanager, EntityPlayer entityplayer) {
this.minecraftServer = minecraftserver;
this.networkManager = networkmanager;
@@ -88,6 +90,8 @@ public class PlayerConnection implements PacketPlayInListener {
this.player = entityplayer;
entityplayer.playerConnection = this;
+ PacketVerifier = new PacketProcessor();
+
// CraftBukkit start - add fields and methods
this.server = minecraftserver.server;
}
@@ -800,7 +804,7 @@ public class PlayerConnection implements PacketPlayInListener {
// CraftBukkit end
try {
- this.networkManager.handle(packet, new GenericFutureListener[0]);
+ PacketVerifier.processPacket(packet, this.networkManager);
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.a(throwable, "Sending packet");
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Packet being sent");
@@ -1252,9 +1256,12 @@ public class PlayerConnection implements PacketPlayInListener {
public void a(PacketPlayInCloseWindow packetplayinclosewindow) {
if (this.player.dead) return; // CraftBukkit
- CraftEventFactory.handleInventoryCloseEvent(this.player); // CraftBukkit
+ if (packetplayinclosewindow.a == player.activeContainer.windowId)
+ {
+ CraftEventFactory.handleInventoryCloseEvent(this.player); // CraftBukkit
- this.player.m();
+ this.player.m();
+ }
}
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
index fdebf9d..f1c3730 100644
--- a/src/main/java/net/minecraft/server/QueuedPacket.java
+++ b/src/main/java/net/minecraft/server/QueuedPacket.java
@@ -3,7 +3,7 @@ package net.minecraft.server;
import net.minecraft.util.io.netty.util.concurrent.GenericFutureListener;
// CraftBukkit - imported class because the methods are package private
-class QueuedPacket {
+public class QueuedPacket {
private final Packet a;
private final GenericFutureListener[] b;
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 7a547da..5a42240 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -145,7 +145,7 @@ public abstract class World implements IBlockAccess {
}
triggerHoppersList.clear();
}
-
+
// Helper method for altHopperTicking. Updates chests at the specified location,
// accounting for double chests. Updating the chest will update adjacent hoppers.
public void updateChestAndHoppers(int a, int b, int c) {
@@ -200,6 +200,8 @@ public abstract class World implements IBlockAccess {
public final SpigotTimings.WorldTimingsHandler timings; // Spigot
+ private Entity _startEntity;
+
public CraftWorld getWorld() {
return this.world;
}
@@ -1661,13 +1663,32 @@ public abstract class World implements IBlockAccess {
this.methodProfiler.b();
if (flag && entity.ag && entity.passenger != null) {
- if (!entity.passenger.dead && entity.passenger.vehicle == entity) {
- this.playerJoinedWorld(entity.passenger);
- } else {
- entity.passenger.vehicle = null;
- entity.passenger = null;
- }
- }
+ if (!entity.passenger.dead && entity.passenger.vehicle == entity) {
+ if (_startEntity == null)
+ _startEntity = entity;
+
+ this.playerJoinedWorld(entity.passenger);
+ }
+ 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 ea786ae..20ab405 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -1062,9 +1062,9 @@ public class CraftWorld implements World {
( (EntityOcelot) entity ).spawnBonus = false;
}
// Spigot end
- if (entity instanceof EntityInsentient) {
- ((EntityInsentient) entity).prepare((GroupDataEntity) null);
- }
+ //if (entity instanceof EntityInsentient) {
+ // ((EntityInsentient) entity).prepare((GroupDataEntity) null);
+ //}
world.addEntity(entity, reason);
return (T) entity.getBukkitEntity();
2014-09-05 23:40:39 +02:00
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
index 0c4976d..28ab76a 100644
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
@@ -49,25 +49,6 @@ public class Main {
+ "*** Any bug reports not running the very latest versions of these softwares will be ignored ***\n\n" );
Enumeration<URL> resources = Main.class.getClassLoader().getResources( "META-INF/MANIFEST.MF" );
- while ( resources.hasMoreElements() )
- {
- Manifest manifest = new Manifest( resources.nextElement().openStream() );
- String ts = manifest.getMainAttributes().getValue( "Timestamp" );
- if ( ts != null )
- {
- Date buildDate = new SimpleDateFormat( "yyyyMMdd-hhmm" ).parse( ts );
-
- Calendar cal = Calendar.getInstance();
- cal.add( Calendar.DAY_OF_YEAR, -2 );
- if ( buildDate.before(cal.getTime() ) )
- {
- System.err.println( "WARNING: This build is more than 2 days old and there are likely updates available!" );
- System.err.println( "You will get no support with this build unless you update from http://ci.md-5.net/job/Spigot/" );
- System.err.println( "The server will start in 10 seconds!" );
- Thread.sleep( TimeUnit.SECONDS.toMillis( 10 ) );
- }
- }
- }
// Spigot End
// Todo: Installation script
OptionParser parser = new OptionParser() {
2014-09-03 12:50:26 +02:00
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 35f2bfa..8a6ca55 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -890,11 +890,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
}
- 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
@@ -906,6 +910,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
//remove the hidden player from this player user list
+ if (hideList)
getHandle().playerConnection.sendPacket(PacketPlayOutPlayerInfo.removePlayer( ( (CraftPlayer) player ).getHandle ())); // Spigot - protocol patch
}
@@ -1321,17 +1326,17 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
@Override
- public boolean getCollidesWithEntities()
- {
- return getHandle().collidesWithEntities;
- }
-
- @Override
- public void setCollidesWithEntities(boolean collides)
- {
- getHandle().collidesWithEntities = collides;
- getHandle().k = collides; // First boolean of Entity
- }
+ public boolean getCollidesWithEntities()
+ {
+ return !getHandle().spectating;
+ }
+
+ @Override
+ public void setCollidesWithEntities(boolean collides)
+ {
+ getHandle().spectating = !collides;
+ getHandle().k = collides; // First boolean of Entity
+ }
@Override
public void respawn()
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java
index 6748465..24f5970 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java
@@ -18,6 +18,7 @@ import net.minecraft.server.TileEntityDispenser;
import net.minecraft.server.TileEntityDropper;
import net.minecraft.server.TileEntityFurnace;
+import org.bukkit.craftbukkit.inventory.MinecraftInventory;
import org.apache.commons.lang.Validate;
import org.bukkit.entity.HumanEntity;
import org.bukkit.event.inventory.InventoryType;
@@ -440,8 +441,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 8b8a317..6565b0f 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java
@@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang.Validate;
+import org.bukkit.craftbukkit.inventory.MinecraftInventory;
import org.bukkit.craftbukkit.entity.CraftHumanEntity;
import org.bukkit.entity.HumanEntity;
import org.bukkit.event.inventory.InventoryType;
@@ -29,135 +30,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 String getInventoryName() {
- return title;
- }
-
- 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 void closeContainer() {}
-
- public InventoryHolder getOwner() {
- return owner;
- }
-
- public void startOpen() {}
-
- public boolean k_() {
- return false;
- }
-
- public boolean b(int i, ItemStack itemstack) {
- return true;
- }
- }
}
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
index 704be69..848f748 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) {
@@ -95,18 +95,18 @@ public final class CraftItemStack extends ItemStack {
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);
}
@@ -136,6 +136,11 @@ public final class CraftItemStack extends ItemStack {
setData(null);
}
+ public net.minecraft.server.ItemStack getHandle()
+ {
+ return handle;
+ }
+
@Override
public int getAmount() {
return handle != null ? handle.count : 0;
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..9102b06
--- /dev/null
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/MinecraftInventory.java
@@ -0,0 +1,199 @@
+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.EntityHuman;
+import net.minecraft.server.IInventory;
+import net.minecraft.server.ItemStack;
+import net.minecraft.util.org.apache.commons.lang3.Validate;
+
+public class MinecraftInventory implements IInventory
+{
+ private final ItemStack[] items;
+ private int maxStack = MAX_STACK;
+ private final List<HumanEntity> viewers;
+ private 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();
+ 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 void setInventoryName(String name)
+ {
+ title = name;
+ }
+
+ 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 void g()
+ {
+ }
+
+ public InventoryHolder getOwner()
+ {
+ return owner;
+ }
+
+ public void startOpen()
+ {
+ }
+
+ public boolean c()
+ {
+ return false;
+ }
+
+ public boolean b(int i, ItemStack itemstack)
+ {
+ return true;
+ }
+
+ @Override
+ public String getInventoryName()
+ {
+ return title;
+ }
+
+ @Override
+ public boolean k_()
+ {
+ return false;
+ }
+
+ @Override
+ public void closeContainer()
+ {
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/bukkit/event/vehicle/VehicleExitEvent.java b/src/main/java/org/bukkit/event/vehicle/VehicleExitEvent.java
new file mode 100644
index 0000000..31fa335
--- /dev/null
+++ b/src/main/java/org/bukkit/event/vehicle/VehicleExitEvent.java
@@ -0,0 +1,56 @@
+package org.bukkit.event.vehicle;
+
+import org.bukkit.entity.LivingEntity;
+import org.bukkit.entity.Entity;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList;
+
+/**
+ * Raised when a living entity exits a vehicle.
+ */
+public class VehicleExitEvent extends Event implements Cancellable {
+ private static final HandlerList handlers = new HandlerList();
+ private boolean cancelled;
+ private Entity vehicle;
+ private final LivingEntity exited;
+
+ public VehicleExitEvent(final Entity vehicle, final LivingEntity exited) {
+ this.vehicle = vehicle;
+ this.exited = exited;
+ }
+
+ /**
+ * Get the vehicle.
+ *
+ * @return the vehicle
+ */
+ public final Entity getVehicle() {
+ return vehicle;
+ }
+
+ /**
+ * Get the living entity that exited the vehicle.
+ *
+ * @return The entity.
+ */
+ public LivingEntity getExited() {
+ return exited;
+ }
+
+ public boolean isCancelled() {
+ return cancelled;
+ }
+
+ public void setCancelled(boolean cancel) {
+ this.cancelled = cancel;
+ }
+
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+}
--
1.8.4.msysgit.0