diff --git a/Patches/0181-Mineplex-Patches.patch b/Patches/0181-Mineplex-Patches.patch new file mode 100644 index 000000000..e6b6c5342 --- /dev/null +++ b/Patches/0181-Mineplex-Patches.patch @@ -0,0 +1,2384 @@ +From dab2987baf7b1908affbdda61b2019d4338d2d72 Mon Sep 17 00:00:00 2001 +From: Jonathan Williams +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 _packetVerifiers; ++ ++ public PacketProcessor() ++ { ++ _packetVerifiers = new ArrayList(); ++ } ++ ++ 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(); +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 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(); +- 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 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 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 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 + diff --git a/Plugins/.idea/libraries/craftbukkit.xml b/Plugins/.idea/libraries/craftbukkit.xml index 4b176a94e..d3750ebca 100644 --- a/Plugins/.idea/libraries/craftbukkit.xml +++ b/Plugins/.idea/libraries/craftbukkit.xml @@ -1,13 +1,13 @@ - + - + \ No newline at end of file diff --git a/Plugins/Libraries/craftbukkit_official.jar b/Plugins/Libraries/craftbukkit.jar similarity index 82% rename from Plugins/Libraries/craftbukkit_official.jar rename to Plugins/Libraries/craftbukkit.jar index a39ede124..e20d9f3ce 100644 Binary files a/Plugins/Libraries/craftbukkit_official.jar and b/Plugins/Libraries/craftbukkit.jar differ diff --git a/Plugins/Mineplex.Core.Common/.classpath b/Plugins/Mineplex.Core.Common/.classpath index f81250dfa..137cfcb84 100644 --- a/Plugins/Mineplex.Core.Common/.classpath +++ b/Plugins/Mineplex.Core.Common/.classpath @@ -2,6 +2,6 @@ - + diff --git a/Plugins/Mineplex.Core.Common/Mineplex.Core.Common.iml b/Plugins/Mineplex.Core.Common/Mineplex.Core.Common.iml index be0d60967..b59695f8a 100644 --- a/Plugins/Mineplex.Core.Common/Mineplex.Core.Common.iml +++ b/Plugins/Mineplex.Core.Common/Mineplex.Core.Common.iml @@ -7,7 +7,6 @@ - diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java index 638ad7db6..0d1bd6724 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java @@ -134,4 +134,38 @@ public class UtilAlg return true; } + + public static Vector cross(Vector a, Vector b) + { + double x = a.getY()*b.getZ() - a.getZ()*b.getY(); + double y = a.getZ()*b.getX() - a.getX()*b.getZ(); + double z = a.getX()*b.getY() - a.getY()*b.getX(); + + return new Vector(x,y,z).normalize(); + } + + public static Vector getRight(Vector vec) + { + return cross(vec.clone().normalize(), new Vector(0,1,0)); + } + + public static Vector getLeft(Vector vec) + { + return getRight(vec).multiply(-1); + } + + public static Vector getBehind(Vector vec) + { + return vec.clone().multiply(-1); + } + + public static Vector getUp(Vector vec) + { + return getDown(vec).multiply(-1); + } + + public static Vector getDown(Vector vec) + { + return cross(vec, getRight(vec)); + } } diff --git a/Plugins/Mineplex.Core/.classpath b/Plugins/Mineplex.Core/.classpath index b3bed9696..c89e4f798 100644 --- a/Plugins/Mineplex.Core/.classpath +++ b/Plugins/Mineplex.Core/.classpath @@ -5,8 +5,7 @@ - - + diff --git a/Plugins/Mineplex.Core/Mineplex.Core.iml b/Plugins/Mineplex.Core/Mineplex.Core.iml index cbebd0c40..14fefcaee 100644 --- a/Plugins/Mineplex.Core/Mineplex.Core.iml +++ b/Plugins/Mineplex.Core/Mineplex.Core.iml @@ -13,7 +13,6 @@ - diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java index d725eb237..65732efa3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java @@ -6,10 +6,10 @@ import java.util.Arrays; import java.util.HashSet; import java.util.List; +import net.minecraft.server.v1_7_R4.PacketPlayOutAnimation; import net.minecraft.server.v1_7_R4.ChunkAddEntityEvent; import net.minecraft.server.v1_7_R4.EntityPlayer; import net.minecraft.server.v1_7_R4.Packet; -import net.minecraft.server.v1_7_R4.PacketPlayOutAnimation; import net.minecraft.server.v1_7_R4.PacketPlayOutNamedEntitySpawn; import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntity; import net.minecraft.server.v1_7_R4.PacketPlayOutEntityVelocity; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseAgeable.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseAgeable.java index 0fe8c7811..83ffd1d83 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseAgeable.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseAgeable.java @@ -1,6 +1,7 @@ package mineplex.core.disguise.disguises; import org.bukkit.entity.*; +import org.spigotmc.ProtocolData; public abstract class DisguiseAgeable extends DisguiseCreature { @@ -8,16 +9,23 @@ public abstract class DisguiseAgeable extends DisguiseCreature { super(disguiseType, entity); - DataWatcher.a(12, new Integer(0)); + DataWatcher.a(12, new ProtocolData.IntByte(0, (byte)0)); + } + + public void UpdateDataWatcher() + { + super.UpdateDataWatcher(); + + DataWatcher.watch(12, DataWatcher.getIntByte(12)); } public boolean isBaby() { - return DataWatcher.getInt(12) < 0; + return DataWatcher.getIntByte(12).value < 0; } public void setBaby() { - DataWatcher.watch(12, Integer.valueOf(-24000)); + DataWatcher.watch(12, new ProtocolData.IntByte(-24000, (byte) ( -1 ))); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseEnderman.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseEnderman.java index ad371f92b..1420fc58e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseEnderman.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseEnderman.java @@ -5,7 +5,9 @@ import java.util.Arrays; import net.minecraft.server.v1_7_R4.MobEffect; import net.minecraft.server.v1_7_R4.MobEffectList; import net.minecraft.server.v1_7_R4.PotionBrewer; + import org.bukkit.entity.*; +import org.spigotmc.ProtocolData; public class DisguiseEnderman extends DisguiseMonster { @@ -13,7 +15,7 @@ public class DisguiseEnderman extends DisguiseMonster { super(EntityType.ENDERMAN, entity); - DataWatcher.a(16, new Byte((byte)0)); + DataWatcher.a(16, new ProtocolData.ByteShort( (short) 0 ) ); DataWatcher.a(17, new Byte((byte)0)); DataWatcher.a(18, new Byte((byte)0)); @@ -27,11 +29,12 @@ public class DisguiseEnderman extends DisguiseMonster super.UpdateDataWatcher(); DataWatcher.watch(0, Byte.valueOf((byte)(DataWatcher.getByte(0) & ~(1 << 0)))); + DataWatcher.watch(16, new ProtocolData.ByteShort( DataWatcher.getShort(16) )); } public void SetCarriedId(int i) { - DataWatcher.watch(16, Byte.valueOf((byte)(i & 0xFF))); + DataWatcher.watch(16, new ProtocolData.ByteShort( (short)(i & 0xFF)) ); } public int GetCarriedId() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseHorse.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseHorse.java index a5526300d..46345018d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseHorse.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseHorse.java @@ -1,6 +1,7 @@ package mineplex.core.disguise.disguises; import org.bukkit.entity.*; +import org.spigotmc.ProtocolData; public class DisguiseHorse extends DisguiseAnimal { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/LineTracker.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/LineTracker.java index ea3345c95..f7f7341f5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/LineTracker.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/ui/LineTracker.java @@ -1,7 +1,10 @@ package mineplex.core.friend.ui; +import java.util.UUID; + import net.minecraft.server.v1_7_R4.EntityPlayer; import net.minecraft.server.v1_7_R4.PacketPlayOutPlayerInfo; +import net.minecraft.util.com.mojang.authlib.GameProfile; public class LineTracker { @@ -29,13 +32,26 @@ public class LineTracker if (_oldLine != null) { - _clearOldPacket = new PacketPlayOutPlayerInfo(_oldLine, false, 0); + _clearOldPacket = new PacketPlayOutPlayerInfo(); + _clearOldPacket.username = _oldLine; + _clearOldPacket.action = PacketPlayOutPlayerInfo.REMOVE_PLAYER; + _clearOldPacket.ping = 0; + _clearOldPacket.player = new GameProfile(UUID.randomUUID(), _oldLine); } if (_line != null) { - _addNewPacket = new PacketPlayOutPlayerInfo(_line, true, 0); - _clearNewPacket = new PacketPlayOutPlayerInfo(_line, false, 0); + _addNewPacket = new PacketPlayOutPlayerInfo(); + _addNewPacket.username = _line; + _addNewPacket.action = PacketPlayOutPlayerInfo.ADD_PLAYER; + _addNewPacket.ping = 0; + _addNewPacket.player = new GameProfile(UUID.randomUUID(), _line); + + _clearNewPacket = new PacketPlayOutPlayerInfo(); + _clearNewPacket.username = _line; + _clearNewPacket.action = PacketPlayOutPlayerInfo.REMOVE_PLAYER; + _clearNewPacket.ping = 0; + _clearNewPacket.player = new GameProfile(UUID.randomUUID(), _line); } return true; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/hologram/SimpleHologram.java b/Plugins/Mineplex.Core/src/mineplex/core/hologram/SimpleHologram.java new file mode 100644 index 000000000..c43edc9e3 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/hologram/SimpleHologram.java @@ -0,0 +1,123 @@ +package mineplex.core.hologram; + +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; +import org.bukkit.entity.Player; +import net.minecraft.server.v1_7_R4.EntityFireball; +import net.minecraft.server.v1_7_R4.EntityHorse; +import net.minecraft.server.v1_7_R4.EntitySmallFireball; +import net.minecraft.server.v1_7_R4.Packet; +import net.minecraft.server.v1_7_R4.PacketPlayOutAttachEntity; +import net.minecraft.server.v1_7_R4.PacketPlayOutEntityDestroy; +import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntity; +import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving; +import net.minecraft.server.v1_7_R4.World; + +import mineplex.core.common.util.UtilServer; + +/** + * Created by Shaun on 8/29/2014. + */ +public class SimpleHologram +{ + /** + * SimpleHologram creates the required entities to spawn in a hologram. It is possible to send the packets for the entities to a player, + * but it is also possible to add the entities to the nmsWorld to keep them loaded into the server. + */ + + private Location _location; + private String _text; + + private World _nmsWorld; + private EntityFireball _fireball; + private EntityHorse _horse; + + public SimpleHologram(Location location, String text) + { + _location = location; + _text = text; + + _nmsWorld = ((CraftWorld) location.getWorld()).getHandle(); + + // Create Entities + _fireball = new EntitySmallFireball(_nmsWorld); + _horse = new EntityHorse(_nmsWorld); + + // Location Data + _fireball.setLocation(_location.getX(), _location.getY() + 55.25, _location.getZ(), 0, 0); + _horse.setLocation(_location.getX(), _location.getY() + 55.25, _location.getZ(), 0, 0); + _horse.setAge(-1700000); + _horse.setCustomName(_text); + _horse.setCustomNameVisible(true); + } + + public void spawnWithPackets() + { + Packet fireballSpawn = getFireballSpawnPacket(); + Packet horseSpawn = getHorseSpawnPacket(); + Packet attachPacket = getAttachEntityPacket(); + + for (Player player : UtilServer.getPlayers()) + { + sendPacket(player, fireballSpawn); + sendPacket(player, horseSpawn); + sendPacket(player, attachPacket); + } + + } + + public void removeWithPackets() + { + Packet horseDestroy = getHorseDestroyPacket(); + Packet fireballDestroy = getFireballDestroyPacket(); + + for (Player player : UtilServer.getPlayers()) + { + sendPacket(player, horseDestroy); + sendPacket(player, fireballDestroy); + } + } + + public void setText(String text) + { + _text = text; + _horse.setCustomName(_text); + } + + public String getText() + { + return _text; + } + + private Packet getHorseSpawnPacket() + { + return new PacketPlayOutSpawnEntityLiving(_horse); + } + + private Packet getFireballSpawnPacket() + { + return new PacketPlayOutSpawnEntity(_fireball, 64); + } + + private Packet getAttachEntityPacket() + { + return new PacketPlayOutAttachEntity(0, _horse, _fireball); + } + + private Packet getHorseDestroyPacket() + { + return new PacketPlayOutEntityDestroy(_horse.getId()); + } + + private Packet getFireballDestroyPacket() + { + return new PacketPlayOutEntityDestroy(_fireball.getId()); + } + + private void sendPacket(Player player, Packet packet) + { + ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet); + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/HorseMount.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/HorseMount.java index d23c8f393..ae5fb44f8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/HorseMount.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/HorseMount.java @@ -100,16 +100,22 @@ public class HorseMount extends Mount horse.setMaxDomestication(1); horse.setJumpStrength(_jump); horse.getInventory().setSaddle(new ItemStack(Material.SADDLE)); - + if (horse.getVariant() == Variant.MULE) horse.setCarryingChest(true); if (_armor != null) horse.getInventory().setArmor(new ItemStack(_armor)); - - horse.setCustomName(player.getName() + "'s " + GetName()); - horse.setCustomNameVisible(true); + if (player.getName().equals("Phinary")) + { + horse.setCustomName("Dinnerbone"); + } + else + { + horse.setCustomName(player.getName() + "'s " + GetName()); + horse.setCustomNameVisible(true); + } //Inform UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(GetName()) + ".")); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountCart.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountCart.java index d72168ac4..0c3c5d113 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountCart.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountCart.java @@ -10,6 +10,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.event.vehicle.VehicleDamageEvent; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; @@ -173,9 +174,9 @@ public class MountCart extends Mount } @EventHandler - public void cancelBreak(EntityDamageEvent event) + public void cancelBreak(VehicleDamageEvent event) { - if (GetActive().values().contains(event.getEntity())) + if (GetActive().values().contains(event.getVehicle())) event.setCancelled(true); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/packethandler/PacketVerifier.java b/Plugins/Mineplex.Core/src/mineplex/core/packethandler/PacketVerifier.java index 4ccd99590..2d8b39660 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/packethandler/PacketVerifier.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/packethandler/PacketVerifier.java @@ -25,63 +25,6 @@ public class PacketVerifier implements IPacketVerifier @Override public boolean verify(Packet o) { - if (o instanceof PacketPlayOutEntityTeleport) - { - PacketPlayOutEntityTeleport packet = (PacketPlayOutEntityTeleport)o; - - //System.out.println("Packet34EntityTeleport (" + packet.b + ", " + packet.c + ", " + packet.d + ")"); - - if (_handler.IsForwarding(_owner) && _handler.IsForwarded(_owner, packet.a)) - { - forceProcess(new PacketPlayOutEntityTeleport(_handler.GetForwardId(_owner, packet.a), packet.b, packet.c, packet.d, packet.e, packet.f)); - return true; - } - else if (_handler.IsBlocked(_owner, packet.a)) - return false; - } - else if (o instanceof PacketPlayOutEntityVelocity) - { - PacketPlayOutEntityVelocity packet = (PacketPlayOutEntityVelocity)o; - - //System.out.println("Packet28EntityVelocity (" + packet.b / 8000.0D + ", " + packet.c / 8000.0D + ", " + packet.d / 8000.0D + ") for " + packet.a + " to " + _owner.getName()); - - if (_handler.IsForwarding(_owner) && _handler.IsForwarded(_owner, packet.a)) - { - // Occasional velocity sent for player in MK jacks up karts so don't process this. - return false; - } - else if (_handler.IsBlocked(_owner, packet.a)) - return false; - } - else if (o instanceof PacketPlayOutRelEntityMove) - { - PacketPlayOutRelEntityMove packet = (PacketPlayOutRelEntityMove)o; - - //System.out.println("Packet31RelEntityMove (" + packet.b + ", " + packet.c + ", " + packet.d + ")"); - - if (_handler.IsForwarding(_owner) && _handler.IsForwarded(_owner, packet.a)) - { - forceProcess(new PacketPlayOutRelEntityMove(_handler.GetForwardId(_owner, packet.a), packet.b, packet.c, packet.d)); - return true; - } - else if (_handler.IsBlocked(_owner, packet.a)) - return false; - } - else if (o instanceof PacketPlayOutRelEntityMoveLook) - { - PacketPlayOutRelEntityMoveLook packet = (PacketPlayOutRelEntityMoveLook)o; - - //System.out.println("Packet33RelEntityMoveLook (" + packet.b + ", " + packet.c + ", " + packet.d + ")"); - - if (_handler.IsForwarding(_owner) && _handler.IsForwarded(_owner, packet.a)) - { - forceProcess(new PacketPlayOutRelEntityMoveLook(_handler.GetForwardId(_owner, packet.a), packet.b, packet.c, packet.d, packet.e, packet.f)); - return true; - } - else if (_handler.IsBlocked(_owner, packet.a)) - return false; - } - return _handler.FireRunnables(o, _owner, this); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/BlockInfo.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/BlockInfo.java new file mode 100644 index 000000000..13e40df3b --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/BlockInfo.java @@ -0,0 +1,26 @@ +package mineplex.core.treasure; + +/** + * Created by Shaun on 8/28/2014. + */ +public class BlockInfo +{ + private int _id; + private byte _data; + + public BlockInfo(int id, byte data) + { + _id = id; + _data = data; + } + + public int getId() + { + return _id; + } + + public byte getData() + { + return _data; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/ChestData.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/ChestData.java new file mode 100644 index 000000000..4136487ac --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/ChestData.java @@ -0,0 +1,61 @@ +package mineplex.core.treasure; + +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_7_R4.util.CraftMagicNumbers; +import org.bukkit.entity.Player; +import net.minecraft.server.v1_7_R4.PacketPlayOutBlockAction; + +import mineplex.core.common.util.UtilServer; +import mineplex.core.treasure.reward.ITreasureReward; + +/** + * Created by Shaun on 8/29/2014. + */ +public class ChestData +{ + private Block _block; + private ITreasureReward _reward; + private boolean _opened; + private boolean _finishedOpen; + + public ChestData(Block block, ITreasureReward reward) + { + _block = block; + _opened = false; + _finishedOpen = false; + _reward = reward; + } + + public boolean isOpened() + { + return _opened; + } + + public boolean isFinishedOpen() + { + return _finishedOpen; + } + + public void setOpened(boolean opened) + { + _opened = opened; + } + + public void setFinishedOpen(boolean finishedOpen) + { + _finishedOpen = finishedOpen; + } + + public Block getBlock() + { + return _block; + } + + public ITreasureReward getReward() + { + return _reward; + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/Treasure.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/Treasure.java new file mode 100644 index 000000000..f055faafa --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/Treasure.java @@ -0,0 +1,280 @@ +package mineplex.core.treasure; + +import java.util.Iterator; +import java.util.LinkedList; +import java.util.Map; +import java.util.Random; + +import org.bukkit.ChatColor; +import org.bukkit.Effect; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; + +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.treasure.animation.ChestSpawnAnimation; +import mineplex.core.treasure.animation.ChestOpenAnimation; +import mineplex.core.treasure.animation.ParticleAnimation; +import mineplex.core.treasure.animation.Animation; +import mineplex.core.treasure.reward.ExampleReward; +import mineplex.core.treasure.reward.ITreasureReward; + +/** + * Created by Shaun on 8/27/2014. + */ +public class Treasure +{ + private NautHashMap _blockRestoreMap = new NautHashMap(); + private Player _player; + private Random _random; + private Block _centerBlock; + private int _tickCount; + private ChestData[] _chestData; + private ITreasureReward[] _rewards; + + private LinkedList _animations; + + private TreasureStyle _style; + + public Treasure(Player player) + { + this(player, new Random()); + } + + public Treasure(Player player, Random seed) + { + _player = player; + _random = seed; + + _style = TreasureStyle.values()[_random.nextInt(TreasureStyle.values().length)]; + + _centerBlock = player.getLocation().getBlock().getRelative(BlockFace.DOWN); + _animations = new LinkedList(); + +// _animations.add(new ParticleAnimation(this)); + + _chestData = new ChestData[4]; + _chestData[0] = new ChestData(_centerBlock.getRelative(2, 1, 0), new ExampleReward()); + _chestData[1] = new ChestData(_centerBlock.getRelative(-2, 1, 0), new ExampleReward()); + _chestData[2] = new ChestData(_centerBlock.getRelative(0, 1, 2), new ExampleReward()); + _chestData[3] = new ChestData(_centerBlock.getRelative(0, 1, -2), new ExampleReward()); + } + + private void createCenterClay() + { + for (int x = -1; x <= 1; x++) + { + for (int z = -1; z <= 1; z++) + { + if (Math.abs(x) == 1 || Math.abs(z) == 1) + { + Block block = _centerBlock.getRelative(x, 0, z); + setBlock(block, _style.getPrimaryMaterial(), _style.getPrimaryData()); + } + } + } + } + + private void createOuterClay() + { + for (int x = -2; x <= 2; x++) + { + { + Block block = _centerBlock.getRelative(x, 0, -2); + setBlock(block, _style.getSecondaryMaterial(), _style.getSecondaryData()); + } + + { + Block block = _centerBlock.getRelative(x, 0, 2); + setBlock(block, _style.getSecondaryMaterial(), _style.getSecondaryData()); + } + } + + for (int z = -1; z <= 1; z++) + { + { + Block block = _centerBlock.getRelative(-2, 0, z); + setBlock(block, _style.getSecondaryMaterial(), _style.getSecondaryData()); + } + + { + Block block = _centerBlock.getRelative(2, 0, z); + setBlock(block, _style.getSecondaryMaterial(), _style.getSecondaryData()); + } + } + } + + private void createGlass() + { + for (int z = -2; z <= 2; z++) + { + for (int x = -2; x <= 2; x++) + { + if ((Math.abs(x) == 2 || Math.abs(z) == 2) && (x != 0 && z != 0)) + { + Block playerBlock = getPlayerBlock(); + Block block = playerBlock.getRelative(x, 0, z); + setBlock(block, _style.getWallMaterial(), _style.getWallData()); + } + } + } + } + + public void update() + { + + if (_tickCount == 5) + { + Block block = _centerBlock; + setBlock(block, _style.getPrimaryMaterial(), _style.getPrimaryData()); + } + else if (_tickCount == 10) + { + createCenterClay(); + } + else if (_tickCount == 20) + { + createOuterClay(); + } + else if (_tickCount == 30) + { + createGlass(); + } + else if (_tickCount == 50) + { + Block block = getPlayerBlock().getRelative(2, 0, 0); + ChestSpawnAnimation task = new ChestSpawnAnimation(this, block, (byte)4); + _animations.add(task); + } + else if (_tickCount == 80) + { + Block block = getPlayerBlock().getRelative(-2, 0, 0); + ChestSpawnAnimation task = new ChestSpawnAnimation(this, block, (byte)5); + _animations.add(task); + } + else if (_tickCount == 110) + { + Block block = getPlayerBlock().getRelative(0, 0, 2); + ChestSpawnAnimation task = new ChestSpawnAnimation(this, block, (byte)2); + _animations.add(task); + } + else if (_tickCount == 140) + { + Block block = getPlayerBlock().getRelative(0, 0, -2); + ChestSpawnAnimation task = new ChestSpawnAnimation(this, block, (byte)3); + _animations.add(task); + } + + Block block = _player.getTargetBlock(null, 3); + if (block.getType() == Material.CHEST) + { + ChestData data = getChestData(block); + if (data != null && !data.isOpened()) + { + UtilParticle.PlayParticle(UtilParticle.ParticleType.ENCHANTMENT_TABLE, block.getLocation().add(0.5, 0.5, 0.5), 0F, 0F, 0F, 1, 4); + } + } + + Iterator taskIterator = _animations.iterator(); + while (taskIterator.hasNext()) + { + Animation animation = taskIterator.next(); + + if (animation.isRunning()) + { + animation.run(); + } + else + { + taskIterator.remove(); + } + } + + _tickCount++; + } + + public Block getCenterBlock() + { + return _centerBlock; + } + + public Block getPlayerBlock() + { + return _centerBlock.getRelative(BlockFace.UP); + } + + public void setBlock(Block block, Material material, byte data) + { + _blockRestoreMap.put(block, new BlockInfo(block.getTypeId(), block.getData())); + block.setType(material); + block.setData(data); + block.getLocation().getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getTypeId()); + } + + public void openChest(Block block) + { + ChestData data = getChestData(block); + if (data != null && !data.isOpened()) + { + data.setOpened(true); + + ChestOpenAnimation chestOpenTask = new ChestOpenAnimation(this, data); + _animations.add(chestOpenTask); + + if (isFinished()) + { + System.out.println("finished"); + } + } + } + + public ChestData getChestData(Block block) + { + for (ChestData data : _chestData) + { + if (data.getBlock().equals(block)) + { + return data; + } + } + return null; + } + + public boolean isFinished() + { + boolean allOpened = true; + for (int i = 0; i < _chestData.length; i++) + { + if (!_chestData[i].isOpened()) + allOpened = false; + } + + return allOpened; + } + + public void finish() + { + for (Map.Entry entry : _blockRestoreMap.entrySet()) + { + Block block = entry.getKey(); + BlockInfo data = entry.getValue(); + + block.setTypeId(data.getId()); + block.setData(data.getData()); + } + + for (Animation animation : _animations) + { + animation.finish(); + } + _animations.clear(); + } + + public TreasureStyle getStyle() + { + return _style; + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java new file mode 100644 index 000000000..12c5bda3d --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java @@ -0,0 +1,190 @@ +package mineplex.core.treasure; + +import java.util.Iterator; +import java.util.Map; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.craftbukkit.v1_7_R4.block.CraftBlock; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_7_R4.util.CraftMagicNumbers; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.Action; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.plugin.java.JavaPlugin; + +import net.minecraft.server.v1_7_R4.PacketPlayOutBlockAction; + +import mineplex.core.MiniPlugin; +import mineplex.core.common.util.F; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + +/** + * Created by Shaun on 8/27/2014. + */ +public class TreasureManager extends MiniPlugin +{ + private NautHashMap _playerTreasureMap; + + public TreasureManager(JavaPlugin plugin) + { + super("Treasure", plugin); + + _playerTreasureMap = new NautHashMap(); + } + + @Override + public void Disable() + { + for (Treasure treasure : _playerTreasureMap.values()) + { + treasure.finish(); + } + } + + public void attemptOpenTreasure(Player player) + { + if (!checkNearbyBlocks(player)) + return; + + Treasure treasure = new Treasure(player); + _playerTreasureMap.put(player, treasure); + + Location teleportLocation = treasure.getPlayerBlock().getLocation().add(0.5, 0, 0.5); + teleportLocation.setPitch(player.getLocation().getPitch()); + teleportLocation.setYaw(player.getLocation().getYaw()); + + player.teleport(teleportLocation); + + } + + private boolean checkNearbyBlocks(Player player) + { + Block centerBlock = player.getLocation().getBlock(); + + for (int y = 0; y <= 3; y++) + { + for (int x = -3; x <= 3; x++) + { + for (int z = -3; z <= 3; z++) + { + Block block = centerBlock.getRelative(x, y, z); + if (UtilBlock.solid(block)) + { + UtilPlayer.message(player, F.main("Treasure", "You can not open a treasure at this spot. Please find a more open location")); + return false; + } + } + } + } + return true; + } + + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + for (Treasure treasure : _playerTreasureMap.values()) + { + treasure.update(); + } + } + + @EventHandler + public void quit(PlayerQuitEvent event) + { + if (_playerTreasureMap.containsKey(event.getPlayer())) + { + Treasure treasure = _playerTreasureMap.remove(event.getPlayer()); + treasure.finish(); + } + } + + @EventHandler + public void cancelMove(PlayerMoveEvent event) + { + Player player = event.getPlayer(); + if (_playerTreasureMap.containsKey(player)) + { + Location to = event.getTo(); + Location from = event.getFrom(); + if (to.getX() != from.getX() || to.getY() != from.getY() || to.getZ() != from.getZ()) + { + Location newTo = event.getFrom().clone(); + newTo.setPitch(event.getTo().getPitch()); + newTo.setYaw(event.getTo().getYaw()); + event.setTo(newTo); + } + } + else + { + for (Treasure treasure : _playerTreasureMap.values()) + { + Location centerLocation = treasure.getCenterBlock().getLocation().add(0.5, 1.5, 0.5); + if (centerLocation.distanceSquared(event.getTo()) <= 6) + { + UtilAction.velocity(player, UtilAlg.getTrajectory(player.getLocation(), centerLocation).multiply(-1), 1.5, true, 0.8, 0, 1.0, true); + event.setTo(event.getFrom()); + } + } + } + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + Player player = event.getPlayer(); + if (_playerTreasureMap.containsKey(player)) + { + if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock().getType() == Material.CHEST) + { + Block block = event.getClickedBlock(); + event.setCancelled(true); + + Treasure treasure = _playerTreasureMap.get(player); + treasure.openChest(event.getClickedBlock()); + } + } + else if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock().getType() == Material.CHEST) + { + for (Treasure treasure : _playerTreasureMap.values()) + { + ChestData data = treasure.getChestData(event.getClickedBlock()); + if (data != null) + { + event.setCancelled(true); + } + } + } + } + +// @EventHandler +// public void command(PlayerCommandPreprocessEvent event) +// { +// //TODO Remove +// if (event.getMessage().startsWith("/treasure")) +// { +// event.getPlayer().sendMessage("Attempting to open treasure..."); +// attemptOpenTreasure(event.getPlayer()); +// event.setCancelled(true); +// } +// } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureStyle.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureStyle.java new file mode 100644 index 000000000..6186120e7 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureStyle.java @@ -0,0 +1,103 @@ +package mineplex.core.treasure; + +import org.bukkit.Material; + +import mineplex.core.common.util.UtilParticle.ParticleType; + +/** + * Created by Shaun on 8/28/2014. + */ +public enum TreasureStyle +{ + /** + * These are examples, not final! + */ + RED(Material.STAINED_CLAY, (byte) 14, + Material.STAINED_CLAY, (byte) 6, + Material.STAINED_GLASS_PANE, (byte) 14, + ParticleType.HEART, + ParticleType.HAPPY_VILLAGER, + ParticleType.FLAME), + + + GREEN(Material.STAINED_CLAY,(byte) 5, + Material.STAINED_CLAY, (byte) 13, + Material.STAINED_GLASS_PANE, (byte) 5, + ParticleType.FLAME, + ParticleType.RED_DUST, + ParticleType.LAVA); + + private Material _primaryMaterial; + private byte _primaryData; + + private Material _secondaryMaterial; + private byte _secondaryData; + + private Material _wallMaterial; + private byte _wallData; + + private ParticleType _primaryParticle; + private ParticleType _secondaryParticle; + private ParticleType _chestSpawnParticle; + + TreasureStyle(Material primaryMaterial, byte primaryData, Material secondaryMaterial, byte secondaryData, Material wallMaterial, byte wallData, ParticleType primaryParticle, ParticleType secondaryParticle, ParticleType chestSpawnParticle) + { + _primaryMaterial = primaryMaterial; + _primaryData = primaryData; + + _secondaryMaterial = secondaryMaterial; + _secondaryData = secondaryData; + + _wallMaterial = wallMaterial; + _wallData = wallData; + + _primaryParticle = primaryParticle; + _secondaryParticle = secondaryParticle; + _chestSpawnParticle = chestSpawnParticle; + } + + public Material getPrimaryMaterial() + { + return _primaryMaterial; + } + + public byte getPrimaryData() + { + return _primaryData; + } + + public Material getSecondaryMaterial() + { + return _secondaryMaterial; + } + + public byte getSecondaryData() + { + return _secondaryData; + } + + public Material getWallMaterial() + { + return _wallMaterial; + } + + public byte getWallData() + { + return _wallData; + } + + public ParticleType getPrimaryParticle() + { + return _primaryParticle; + } + + public ParticleType getSecondaryParticle() + { + return _secondaryParticle; + } + + public ParticleType getChestSpawnParticle() + { + return _chestSpawnParticle; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/Animation.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/Animation.java new file mode 100644 index 000000000..c3fbe6e62 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/Animation.java @@ -0,0 +1,54 @@ +package mineplex.core.treasure.animation; + +import mineplex.core.treasure.Treasure; + +/** + * Created by Shaun on 8/29/2014. + */ +public abstract class Animation +{ + private Treasure _treasure; + private boolean _running; + private int _ticks; + + public Animation(Treasure treasure) + { + _treasure = treasure; + _running = true; + } + + public void run() + { + tick(); + _ticks++; + } + + protected abstract void tick(); + + protected abstract void onFinish(); + + public void finish() + { + if (_running) + { + _running = false; + onFinish(); + } + } + + public boolean isRunning() + { + return _running; + } + + public int getTicks() + { + return _ticks; + } + + public Treasure getTreasure() + { + return _treasure; + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ChestOpenAnimation.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ChestOpenAnimation.java new file mode 100644 index 000000000..634e15197 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ChestOpenAnimation.java @@ -0,0 +1,71 @@ +package mineplex.core.treasure.animation; + +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_7_R4.util.CraftMagicNumbers; +import org.bukkit.entity.Item; +import org.bukkit.entity.Player; +import org.bukkit.util.Vector; + +import net.minecraft.server.v1_7_R4.PacketPlayOutBlockAction; + +import mineplex.core.common.util.UtilServer; +import mineplex.core.hologram.SimpleHologram; +import mineplex.core.treasure.ChestData; +import mineplex.core.treasure.Treasure; + +/** + * Created by Shaun on 8/29/2014. + */ +public class ChestOpenAnimation extends Animation +{ + private ChestData _chestData; + + private Item _itemEntity; + private SimpleHologram _hologram; + + public ChestOpenAnimation(Treasure treasure, ChestData chestData) + { + super(treasure); + _chestData = chestData; + + // Send chest open packet + Block block = chestData.getBlock(); + PacketPlayOutBlockAction packet = new PacketPlayOutBlockAction(block.getX(), block.getY(), block.getZ(), CraftMagicNumbers.getBlock(block), 1, 1); + for (Player other : UtilServer.getPlayers()) + { + ((CraftPlayer) other).getHandle().playerConnection.sendPacket(packet); + other.playSound(block.getLocation(), Sound.CHEST_OPEN, 1, 1); + } + } + + @Override + protected void tick() + { + if (getTicks() == 5) + { + Location location = _chestData.getBlock().getLocation().add(0.5, 0.8, 0.5); + _itemEntity = location.getWorld().dropItem(location, _chestData.getReward().getItem()); + _itemEntity.setVelocity(new Vector(0, 0, 0)); + _itemEntity.setPickupDelay(Integer.MAX_VALUE); + } + else if (getTicks() == 15) + { + _hologram = new SimpleHologram(_chestData.getBlock().getLocation().add(0.5, 1.1, 0.5), _chestData.getReward().getText()); + _hologram.spawnWithPackets(); + + _chestData.setFinishedOpen(true); + } + } + + public void onFinish() + { + if (_hologram != null) + { + _hologram.removeWithPackets(); + _itemEntity.remove(); + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ChestSpawnAnimation.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ChestSpawnAnimation.java new file mode 100644 index 000000000..a91ed282b --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ChestSpawnAnimation.java @@ -0,0 +1,62 @@ +package mineplex.core.treasure.animation; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; + +import mineplex.core.common.util.UtilParticle; +import mineplex.core.treasure.Treasure; + +/** + * Created by Shaun on 8/29/2014. + */ +public class ChestSpawnAnimation extends Animation +{ + private static final int ANIMATION_DURATION = 30; + + private Block _block; + private byte _direction; + private Location _centerLocation; + + public ChestSpawnAnimation(Treasure tresure, Block block, byte direction) + { + super(tresure); + _block = block; + _direction = direction; + _centerLocation = block.getLocation().clone().add(0.5, 0.5, 0.5); + _centerLocation.getWorld().playSound(_centerLocation, Sound.LAVA, 1, 1); + } + + @Override + public void tick() + { + float scale = (float)((double)(ANIMATION_DURATION - getTicks()) / (double)ANIMATION_DURATION); + + float y = 5 * scale; + double width = 1.4 * ((double) getTicks() / (double) ANIMATION_DURATION); + + for (int i=0 ; i < 2 ; i++) + { + double lead = i * ((2d * Math.PI)/2); + float x = (float) (Math.sin(getTicks()/4D + lead)); + float z = (float) (Math.cos(getTicks()/4D + lead)); + UtilParticle.PlayParticle(getTreasure().getStyle().getSecondaryParticle(), _centerLocation.clone().add(x * width, y, z * width), 0f, 0f, 0f, 0, 1); + } + + if (getTicks() >= ANIMATION_DURATION) + { + getTreasure().setBlock(_block, Material.CHEST, _direction); + _block.getLocation().getWorld().playSound(_centerLocation, Sound.ANVIL_LAND, 0.5f, 1f); + + UtilParticle.PlayParticle(getTreasure().getStyle().getChestSpawnParticle(), _centerLocation, 0.2f, 0.2f, 0.2f, 0, 50); + finish(); + } + } + + @Override + protected void onFinish() + { + + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ParticleAnimation.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ParticleAnimation.java new file mode 100644 index 000000000..40745a47f --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ParticleAnimation.java @@ -0,0 +1,68 @@ +package mineplex.core.treasure.animation; + +import java.util.ArrayList; + +import org.bukkit.util.Vector; + +import mineplex.core.common.util.UtilParticle; +import mineplex.core.treasure.Treasure; + +/** + * Created by Shaun on 8/29/2014. + */ +public class ParticleAnimation extends Animation +{ + private static double MODIFIER = 0.5; + private static ArrayList PATH = new ArrayList(); + + static + { + double y = 5; + double x = 3; + double z = -3; + + for (z = -3; z <= 3; z += MODIFIER) + { + PATH.add(new Vector(x, y, z)); + } + + for (x = 3; x >= -3; x -= MODIFIER) + { + PATH.add(new Vector(x, y, z)); + } + + for (z = 3; z >= -3; z -= MODIFIER) + { + PATH.add(new Vector(x, y, z)); + } + + for (x = -3; x <= 3; x += MODIFIER) + { + PATH.add(new Vector(x, y, z)); + } + } + + private int pathPosition = 0; + + public ParticleAnimation(Treasure treasure) + { + super(treasure); + } + + @Override + protected void tick() + { + Vector position = PATH.get(pathPosition); + + UtilParticle.PlayParticle(getTreasure().getStyle().getPrimaryParticle(), getTreasure().getCenterBlock().getLocation().add(0.5, 0, 0.5).add(position), 0, 0, 0, 0, 1); + + pathPosition = (pathPosition + 1) % PATH.size(); + } + + @Override + protected void onFinish() + { + + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/reward/ExampleReward.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/reward/ExampleReward.java new file mode 100644 index 000000000..5bbc7146b --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/reward/ExampleReward.java @@ -0,0 +1,30 @@ +package mineplex.core.treasure.reward; + +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; + +/** + * Created by Shaun on 9/2/2014. + */ +public class ExampleReward implements ITreasureReward +{ + @Override + public String getText() + { + return C.cGreen + "100 Gems"; + } + + @Override + public ItemStack getItem() + { + return new ItemStack(Material.EMERALD); + } + + @Override + public RewardRarity getRarity() + { + return RewardRarity.COMMON; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/reward/ITreasureReward.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/reward/ITreasureReward.java new file mode 100644 index 000000000..aeabc5420 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/reward/ITreasureReward.java @@ -0,0 +1,16 @@ +package mineplex.core.treasure.reward; + +import org.bukkit.inventory.ItemStack; + +/** + * Created by Shaun on 9/2/2014. + */ +public interface ITreasureReward +{ + public String getText(); + + public ItemStack getItem(); + + public RewardRarity getRarity(); + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/reward/RewardRarity.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/reward/RewardRarity.java new file mode 100644 index 000000000..b7d809415 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/reward/RewardRarity.java @@ -0,0 +1,17 @@ +package mineplex.core.treasure.reward; + +/** + * Created by Shaun on 9/2/2014. + */ +public enum RewardRarity +{ + + /** + * This will probably be used to figure out what effects are shown when the chest is opened + * + * (Fireworks, sounds, etc) + */ + + COMMON, UNCOMMON, RARE, VERY_RARE; + +} diff --git a/Plugins/Mineplex.DDoSProtectionSwitcher/src/mineplex/ddos/DDoSProtectionSwitcher.java b/Plugins/Mineplex.DDoSProtectionSwitcher/src/mineplex/ddos/DDoSProtectionSwitcher.java index 67a04c331..dd9898f6f 100644 --- a/Plugins/Mineplex.DDoSProtectionSwitcher/src/mineplex/ddos/DDoSProtectionSwitcher.java +++ b/Plugins/Mineplex.DDoSProtectionSwitcher/src/mineplex/ddos/DDoSProtectionSwitcher.java @@ -49,7 +49,7 @@ public class DDoSProtectionSwitcher //{ //if (_repository.switchToDDOSProt()) //{ - /* + System.out.println("Starting DDoS Protection Switch at " + dateFormat.format(new Date())); DomainRecords records = new ApiGetCall("https://api.dnsmadeeasy.com/V2.0/dns/managed/", 962728, @@ -111,7 +111,7 @@ public class DDoSProtectionSwitcher + idBuilder.toString()).Execute(); System.out.println("Deleted " + recordsToDelete.size() + " records."); } -*/ +/* // Switching US Bungees switchServer("10.35.74.130", "108.178.20.166", "108.163.222.202", "108.178.20.165", "108.163.222.201"); switchServer("10.35.74.132", "108.163.217.110", "108.178.44.50", "108.163.217.109", "108.178.44.49"); @@ -133,7 +133,7 @@ public class DDoSProtectionSwitcher switchServer("10.32.214.250", "69.175.4.38", "107.6.129.250", "69.175.4.37", "107.6.129.249"); switchServer("10.32.214.249", "107.6.158.78", "184.154.13.38", "107.6.158.77", "184.154.13.37"); switchServer("10.32.214.247", "184.154.13.118", "108.163.242.98", "184.154.13.117", "108.163.242.97"); - +*/ /* // Switching EU Bungees switchServer("10.82.2.202", "107.6.176.194", "107.6.176.34", "107.6.176.193", "107.6.176.33"); diff --git a/Plugins/Mineplex.Hub/.classpath b/Plugins/Mineplex.Hub/.classpath index 30c63b3bc..4397068af 100644 --- a/Plugins/Mineplex.Hub/.classpath +++ b/Plugins/Mineplex.Hub/.classpath @@ -3,7 +3,6 @@ - diff --git a/Plugins/Mineplex.Hub/Mineplex.Hub.iml b/Plugins/Mineplex.Hub/Mineplex.Hub.iml index 6b8306237..dfc217d28 100644 --- a/Plugins/Mineplex.Hub/Mineplex.Hub.iml +++ b/Plugins/Mineplex.Hub/Mineplex.Hub.iml @@ -13,7 +13,6 @@ - diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index 7ce466096..1480ff17a 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -54,6 +54,7 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilWorld; +import mineplex.core.treasure.TreasureManager; import mineplex.minecraft.game.core.condition.ConditionManager; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.disguise.DisguiseManager; @@ -159,6 +160,7 @@ public class HubManager extends MiniClientPlugin _inventoryManager = new InventoryManager(plugin); _gadgetManager = new GadgetManager(_plugin, clientManager, donationManager, _inventoryManager, _mountManager, petManager, preferences, disguiseManager, blockRestore, new ProjectileManager(plugin)); new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, false); +// new TreasureManager(_plugin); _partyManager = partyManager; _preferences = preferences; diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java index 25068829a..41f61537d 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java @@ -132,10 +132,9 @@ public class ServerGameMenu extends ShopPageBase ChatColor.RESET + "Dragon Escape", ChatColor.RESET + "Milk the Cow", ChatColor.RESET + "Super Paintball", - ChatColor.RESET + "Turf Forts", + ChatColor.RESET + "Turf Wars", ChatColor.RESET + "Death Tag", ChatColor.RESET + "Bacon Brawl", - ChatColor.RESET + "Squid Sauce" })); _minigameCycle.add(ItemStackFactory.Instance.CreateStack(Material.GOLD_BOOTS.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String [] @@ -167,10 +166,9 @@ public class ServerGameMenu extends ShopPageBase ChatColor.RESET + "Dragon Escape", ChatColor.RESET + "Milk the Cow", ChatColor.RESET + "Super Paintball", - ChatColor.RESET + "Turf Forts", + ChatColor.RESET + "Turf Wars", ChatColor.RESET + "Death Tag", ChatColor.RESET + "Bacon Brawl", - ChatColor.RESET + "Squid Sauce" })); _minigameCycle.add(ItemStackFactory.Instance.CreateStack(Material.BOW, (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String [] @@ -185,10 +183,9 @@ public class ServerGameMenu extends ShopPageBase ChatColor.RESET + "Dragon Escape", ChatColor.RESET + "Milk the Cow", ChatColor.RESET + "Super Paintball", - ChatColor.RESET + "Turf Forts", + ChatColor.RESET + "Turf Wars", ChatColor.RESET + "Death Tag", ChatColor.RESET + "Bacon Brawl", - ChatColor.RESET + "Squid Sauce" })); _minigameCycle.add(ItemStackFactory.Instance.CreateStack(Material.LEATHER_BOOTS.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String [] @@ -203,10 +200,9 @@ public class ServerGameMenu extends ShopPageBase ChatColor.RESET + C.Bold + ChatColor.GREEN + "Dragon Escape", ChatColor.RESET + "Milk the Cow", ChatColor.RESET + "Super Paintball", - ChatColor.RESET + "Turf Forts", + ChatColor.RESET + "Turf Wars", ChatColor.RESET + "Death Tag", ChatColor.RESET + "Bacon Brawl", - ChatColor.RESET + "Squid Sauce" })); _minigameCycle.add(ItemStackFactory.Instance.CreateStack(Material.MILK_BUCKET.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String [] @@ -221,10 +217,9 @@ public class ServerGameMenu extends ShopPageBase ChatColor.RESET + "Dragon Escape", ChatColor.RESET + C.Bold + ChatColor.GREEN + "Milk the Cow", ChatColor.RESET + "Super Paintball", - ChatColor.RESET + "Turf Forts", + ChatColor.RESET + "Turf Wars", ChatColor.RESET + "Death Tag", ChatColor.RESET + "Bacon Brawl", - ChatColor.RESET + "Squid Sauce" })); _minigameCycle.add(ItemStackFactory.Instance.CreateStack(Material.DIAMOND_BARDING.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String [] @@ -239,10 +234,9 @@ public class ServerGameMenu extends ShopPageBase ChatColor.RESET + "Dragon Escape", ChatColor.RESET + "Milk the Cow", ChatColor.RESET + C.Bold + ChatColor.GREEN + "Super Paintball", - ChatColor.RESET + "Turf Forts", + ChatColor.RESET + "Turf Wars", ChatColor.RESET + "Death Tag", ChatColor.RESET + "Bacon Brawl", - ChatColor.RESET + "Squid Sauce" })); _minigameCycle.add(ItemStackFactory.Instance.CreateStack(159, (byte)14, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String [] @@ -257,10 +251,9 @@ public class ServerGameMenu extends ShopPageBase ChatColor.RESET + "Dragon Escape", ChatColor.RESET + "Milk the Cow", ChatColor.RESET + "Super Paintball", - ChatColor.RESET + C.Bold + ChatColor.GREEN + "Turf Forts", + ChatColor.RESET + C.Bold + ChatColor.GREEN + "Turf Wars", ChatColor.RESET + "Death Tag", ChatColor.RESET + "Bacon Brawl", - ChatColor.RESET + "Squid Sauce" })); _minigameCycle.add(ItemStackFactory.Instance.CreateStack(309, (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String [] @@ -275,10 +268,9 @@ public class ServerGameMenu extends ShopPageBase ChatColor.RESET + "Dragon Escape", ChatColor.RESET + "Milk the Cow", ChatColor.RESET + "Super Paintball", - ChatColor.RESET + "Turf Forts", + ChatColor.RESET + "Turf Wars", ChatColor.RESET + C.Bold + ChatColor.GREEN + "Death Tag", ChatColor.RESET + "Bacon Brawl", - ChatColor.RESET + "Squid Sauce" })); _minigameCycle.add(ItemStackFactory.Instance.CreateStack(319, (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String [] @@ -293,28 +285,9 @@ public class ServerGameMenu extends ShopPageBase ChatColor.RESET + "Dragon Escape", ChatColor.RESET + "Milk the Cow", ChatColor.RESET + "Super Paintball", - ChatColor.RESET + "Turf Forts", + ChatColor.RESET + "Turf Wars", ChatColor.RESET + "Death Tag", ChatColor.RESET + C.Bold + ChatColor.GREEN + "Bacon Brawl", - ChatColor.RESET + "Squid Sauce" - })); - - _minigameCycle.add(ItemStackFactory.Instance.CreateStack(351, (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String [] - { - ChatColor.RESET + "", - ChatColor.RESET + "Play all of these fun minigames:", - ChatColor.RESET + "", - ChatColor.RESET + "Super Spleef", - ChatColor.RESET + "Runner", - ChatColor.RESET + "Dragons", - ChatColor.RESET + "One in the Quiver", - ChatColor.RESET + "Dragon Escape", - ChatColor.RESET + "Milk the Cow", - ChatColor.RESET + "Super Paintball", - ChatColor.RESET + "Turf Forts", - ChatColor.RESET + "Death Tag", - ChatColor.RESET + "Bacon Brawl", - ChatColor.RESET + C.Bold + ChatColor.GREEN + "Squid Sauce" })); } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/.classpath b/Plugins/Mineplex.Minecraft.Game.ClassCombat/.classpath index 2bff5460c..5ce44dc10 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/.classpath +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/.classpath @@ -2,10 +2,9 @@ - - + diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/Mineplex.Minecraft.Game.ClassCombat.iml b/Plugins/Mineplex.Minecraft.Game.ClassCombat/Mineplex.Minecraft.Game.ClassCombat.iml index 0bffff66a..b3324f1c3 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/Mineplex.Minecraft.Game.ClassCombat.iml +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/Mineplex.Minecraft.Game.ClassCombat.iml @@ -10,7 +10,6 @@ - diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/ClassCombatShop.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/ClassCombatShop.java index 57c009d47..e9a7d9481 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/ClassCombatShop.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/ClassCombatShop.java @@ -57,8 +57,6 @@ public class ClassCombatShop extends ShopBase if (!CanOpenShop(player)) return false; - System.out.println(this.getClass().getName() + " - I CAN OPEN SHOP"); - OpenedShop.add(player.getName()); OpenShopForPlayer(player); diff --git a/Plugins/Mineplex.Minecraft.Game.Core/.classpath b/Plugins/Mineplex.Minecraft.Game.Core/.classpath index ee64814c6..c515af76c 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/.classpath +++ b/Plugins/Mineplex.Minecraft.Game.Core/.classpath @@ -3,7 +3,6 @@ - diff --git a/Plugins/Mineplex.Minecraft.Game.Core/Mineplex.Minecraft.Game.Core.iml b/Plugins/Mineplex.Minecraft.Game.Core/Mineplex.Minecraft.Game.Core.iml index 569e314c3..6882d9ec9 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/Mineplex.Minecraft.Game.Core.iml +++ b/Plugins/Mineplex.Minecraft.Game.Core/Mineplex.Minecraft.Game.Core.iml @@ -9,7 +9,6 @@ - diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkCommand.java index 383443db3..d895e9eac 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/checkCommand.java @@ -10,7 +10,7 @@ public class checkCommand extends CommandBase { public checkCommand(CustomerSupport plugin) { - super(plugin, Rank.MODERATOR, "check"); + super(plugin, Rank.MODERATOR, "check", "c"); } @Override diff --git a/Plugins/Nautilus.Core.CraftBukkit/.classpath b/Plugins/Nautilus.Core.CraftBukkit/.classpath deleted file mode 100644 index d5f3f80ed..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/.classpath +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/Plugins/Nautilus.Core.CraftBukkit/.externalToolBuilders/CB2.launch b/Plugins/Nautilus.Core.CraftBukkit/.externalToolBuilders/CB2.launch deleted file mode 100644 index 4067ec440..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/.externalToolBuilders/CB2.launch +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/Plugins/Nautilus.Core.CraftBukkit/.project b/Plugins/Nautilus.Core.CraftBukkit/.project deleted file mode 100644 index e093b6bfc..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/.project +++ /dev/null @@ -1,47 +0,0 @@ - - - Nautilus.Core.CraftBukkit - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.ui.externaltools.ExternalToolBuilder - auto,full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/CB2.launch - - - - - - org.eclipse.jdt.core.javanature - - - - 1350069218645 - - 26 - - org.eclipse.ui.ide.multiFilter - 1.0-name-matches-false-false-main - - - - 1350069218648 - - 26 - - org.eclipse.ui.ide.multiFilter - 1.0-name-matches-false-false-test - - - - diff --git a/Plugins/Nautilus.Core.CraftBukkit/.settings/org.eclipse.core.resources.prefs b/Plugins/Nautilus.Core.CraftBukkit/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 99f26c020..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 diff --git a/Plugins/Nautilus.Core.CraftBukkit/.settings/org.eclipse.jdt.core.prefs b/Plugins/Nautilus.Core.CraftBukkit/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 8000cd6ca..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,11 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.6 diff --git a/Plugins/Nautilus.Core.CraftBukkit/Nautilus.Core.CraftBukkit.iml b/Plugins/Nautilus.Core.CraftBukkit/Nautilus.Core.CraftBukkit.iml deleted file mode 100644 index b59695f8a..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/Nautilus.Core.CraftBukkit.iml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/Plugins/Nautilus.Core.CraftBukkit/Nautilus.Core.CraftBukkit.xml b/Plugins/Nautilus.Core.CraftBukkit/Nautilus.Core.CraftBukkit.xml deleted file mode 100644 index 6c0a40a56..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/Nautilus.Core.CraftBukkit.xml +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/Chunk.java b/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/Chunk.java deleted file mode 100644 index f501ed858..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/Chunk.java +++ /dev/null @@ -1,1180 +0,0 @@ -package net.minecraft.server.v1_7_R4; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Random; -import java.util.concurrent.Callable; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import org.bukkit.Bukkit; // CraftBukkit - -public class Chunk { - - private static final Logger t = LogManager.getLogger(); - public static boolean a; - private ChunkSection[] sections; - private byte[] v; - public int[] b; - public boolean[] c; - public boolean d; - public World world; - public int[] heightMap; - public final int locX; - public final int locZ; - private boolean w; - public Map tileEntities; - public List[] entitySlices; - public boolean done; - public boolean lit; - public boolean m; - public boolean n; - public boolean o; - public long lastSaved; - public boolean q; - public int r; - public long s; - private int x; - protected net.minecraft.util.gnu.trove.map.hash.TObjectIntHashMap entityCount = new net.minecraft.util.gnu.trove.map.hash.TObjectIntHashMap(); // Spigot - - // CraftBukkit start - Neighbor loaded cache for chunk lighting and entity ticking - private int neighbors = 0x1 << 12; - - public boolean areNeighborsLoaded(final int radius) { - switch(radius) { - case 2: - return this.neighbors == Integer.MAX_VALUE >> 6; - case 1: - final int mask = - // x z offset x z offset x z offset - ( 0x1 << (1 * 5 + 1 + 12) ) | ( 0x1 << (0 * 5 + 1 + 12) ) | ( 0x1 << (-1 * 5 + 1 + 12) ) | - ( 0x1 << (1 * 5 + 0 + 12) ) | ( 0x1 << (0 * 5 + 0 + 12) ) | ( 0x1 << (-1 * 5 + 0 + 12) ) | - ( 0x1 << (1 * 5 + -1 + 12) ) | ( 0x1 << (0 * 5 + -1 + 12) ) | ( 0x1 << (-1 * 5 + -1 + 12) ); - return (this.neighbors & mask) == mask; - default: - throw new UnsupportedOperationException(String.valueOf(radius)); - } - } - - public void setNeighborLoaded(final int x, final int z) { - this.neighbors |= 0x1 << (x * 5 + 12 + z); - } - - public void setNeighborUnloaded(final int x, final int z) { - this.neighbors &= ~(0x1 << (x * 5 + 12 + z)); - } - // CraftBukkit end - - public Chunk(World world, int i, int j) { - this.sections = new ChunkSection[16]; - this.v = new byte[256]; - this.b = new int[256]; - this.c = new boolean[256]; - this.tileEntities = new HashMap(); - this.x = 4096; - this.entitySlices = new List[16]; - this.world = world; - this.locX = i; - this.locZ = j; - this.heightMap = new int[256]; - - for (int k = 0; k < this.entitySlices.length; ++k) { - this.entitySlices[k] = new org.bukkit.craftbukkit.v1_7_R4.util.UnsafeList(); // CraftBukkit - ArrayList -> UnsafeList - } - - Arrays.fill(this.b, -999); - Arrays.fill(this.v, (byte) -1); - - // CraftBukkit start - if (!(this instanceof EmptyChunk)) { - this.bukkitChunk = new org.bukkit.craftbukkit.v1_7_R4.CraftChunk(this); - } - } - - public org.bukkit.Chunk bukkitChunk; - public boolean mustSave; - // CraftBukkit end - - public Chunk(World world, Block[] ablock, int i, int j) { - this(world, i, j); - int k = ablock.length / 256; - boolean flag = !world.worldProvider.g; - - for (int l = 0; l < 16; ++l) { - for (int i1 = 0; i1 < 16; ++i1) { - for (int j1 = 0; j1 < k; ++j1) { - Block block = ablock[l << 11 | i1 << 7 | j1]; - - if (block != null && block.getMaterial() != Material.AIR) { - int k1 = j1 >> 4; - - if (this.sections[k1] == null) { - this.sections[k1] = new ChunkSection(k1 << 4, flag); - } - - this.sections[k1].setTypeId(l, j1 & 15, i1, block); - } - } - } - } - } - - public Chunk(World world, Block[] ablock, byte[] abyte, int i, int j) { - this(world, i, j); - int k = ablock.length / 256; - boolean flag = !world.worldProvider.g; - - for (int l = 0; l < 16; ++l) { - for (int i1 = 0; i1 < 16; ++i1) { - for (int j1 = 0; j1 < k; ++j1) { - int k1 = l * k * 16 | i1 * k | j1; - Block block = ablock[k1]; - - if (block != null && block != Blocks.AIR) { - int l1 = j1 >> 4; - - if (this.sections[l1] == null) { - this.sections[l1] = new ChunkSection(l1 << 4, flag); - } - - this.sections[l1].setTypeId(l, j1 & 15, i1, block); - this.sections[l1].setData(l, j1 & 15, i1, checkData( block, abyte[k1] ) ); - } - } - } - } - } - - public boolean a(int i, int j) { - return i == this.locX && j == this.locZ; - } - - public int b(int i, int j) { - return this.heightMap[j << 4 | i]; - } - - public int h() { - for (int i = this.sections.length - 1; i >= 0; --i) { - if (this.sections[i] != null) { - return this.sections[i].getYPosition(); - } - } - - return 0; - } - - public ChunkSection[] getSections() { - return this.sections; - } - - public void initLighting() { - int i = this.h(); - - this.r = Integer.MAX_VALUE; - - for (int j = 0; j < 16; ++j) { - int k = 0; - - while (k < 16) { - this.b[j + (k << 4)] = -999; - int l = i + 16 - 1; - - while (true) { - if (l > 0) { - if (this.b(j, l - 1, k) == 0) { - --l; - continue; - } - - this.heightMap[k << 4 | j] = l; - if (l < this.r) { - this.r = l; - } - } - - if (!this.world.worldProvider.g) { - l = 15; - int i1 = i + 16 - 1; - - do { - int j1 = this.b(j, i1, k); - - if (j1 == 0 && l != 15) { - j1 = 1; - } - - l -= j1; - if (l > 0) { - ChunkSection chunksection = this.sections[i1 >> 4]; - - if (chunksection != null) { - chunksection.setSkyLight(j, i1 & 15, k, l); - this.world.m((this.locX << 4) + j, i1, (this.locZ << 4) + k); - } - } - - --i1; - } while (i1 > 0 && l > 0); - } - - ++k; - break; - } - } - } - - this.n = true; - } - - private void e(int i, int j) { - this.c[i + j * 16] = true; - this.w = true; - } - - private void c(boolean flag) { - this.world.methodProfiler.a("recheckGaps"); - if (this.world.areChunksLoaded(this.locX * 16 + 8, 0, this.locZ * 16 + 8, 16)) { - for (int i = 0; i < 16; ++i) { - for (int j = 0; j < 16; ++j) { - if (this.c[i + j * 16]) { - this.c[i + j * 16] = false; - int k = this.b(i, j); - int l = this.locX * 16 + i; - int i1 = this.locZ * 16 + j; - int j1 = this.world.g(l - 1, i1); - int k1 = this.world.g(l + 1, i1); - int l1 = this.world.g(l, i1 - 1); - int i2 = this.world.g(l, i1 + 1); - - if (k1 < j1) { - j1 = k1; - } - - if (l1 < j1) { - j1 = l1; - } - - if (i2 < j1) { - j1 = i2; - } - - this.g(l, i1, j1); - this.g(l - 1, i1, k); - this.g(l + 1, i1, k); - this.g(l, i1 - 1, k); - this.g(l, i1 + 1, k); - if (flag) { - this.world.methodProfiler.b(); - return; - } - } - } - } - - this.w = false; - } - - this.world.methodProfiler.b(); - } - - private void g(int i, int j, int k) { - int l = this.world.getHighestBlockYAt(i, j); - - if (l > k) { - this.c(i, j, k, l + 1); - } else if (l < k) { - this.c(i, j, l, k + 1); - } - } - - private void c(int i, int j, int k, int l) { - if (l > k && this.world.areChunksLoaded(i, 0, j, 16)) { - for (int i1 = k; i1 < l; ++i1) { - this.world.c(EnumSkyBlock.SKY, i, i1, j); - } - - this.n = true; - } - } - - private void h(int i, int j, int k) { - int l = this.heightMap[k << 4 | i] & 255; - int i1 = l; - - if (j > l) { - i1 = j; - } - - while (i1 > 0 && this.b(i, i1 - 1, k) == 0) { - --i1; - } - - if (i1 != l) { - this.world.b(i + this.locX * 16, k + this.locZ * 16, i1, l); - this.heightMap[k << 4 | i] = i1; - int j1 = this.locX * 16 + i; - int k1 = this.locZ * 16 + k; - int l1; - int i2; - - if (!this.world.worldProvider.g) { - ChunkSection chunksection; - - if (i1 < l) { - for (l1 = i1; l1 < l; ++l1) { - chunksection = this.sections[l1 >> 4]; - if (chunksection != null) { - chunksection.setSkyLight(i, l1 & 15, k, 15); - this.world.m((this.locX << 4) + i, l1, (this.locZ << 4) + k); - } - } - } else { - for (l1 = l; l1 < i1; ++l1) { - chunksection = this.sections[l1 >> 4]; - if (chunksection != null) { - chunksection.setSkyLight(i, l1 & 15, k, 0); - this.world.m((this.locX << 4) + i, l1, (this.locZ << 4) + k); - } - } - } - - l1 = 15; - - while (i1 > 0 && l1 > 0) { - --i1; - i2 = this.b(i, i1, k); - if (i2 == 0) { - i2 = 1; - } - - l1 -= i2; - if (l1 < 0) { - l1 = 0; - } - - ChunkSection chunksection1 = this.sections[i1 >> 4]; - - if (chunksection1 != null) { - chunksection1.setSkyLight(i, i1 & 15, k, l1); - } - } - } - - l1 = this.heightMap[k << 4 | i]; - i2 = l; - int j2 = l1; - - if (l1 < l) { - i2 = l1; - j2 = l; - } - - if (l1 < this.r) { - this.r = l1; - } - - if (!this.world.worldProvider.g) { - this.c(j1 - 1, k1, i2, j2); - this.c(j1 + 1, k1, i2, j2); - this.c(j1, k1 - 1, i2, j2); - this.c(j1, k1 + 1, i2, j2); - this.c(j1, k1, i2, j2); - } - - this.n = true; - } - } - - public int b(int i, int j, int k) { - return this.getType(i, j, k).k(); - } - - public Block getType(int i, int j, int k) { - Block block = Blocks.AIR; - - if (j >> 4 < this.sections.length) { - ChunkSection chunksection = this.sections[j >> 4]; - - if (chunksection != null) { - try { - block = chunksection.getTypeId(i, j & 15, k); - } catch (Throwable throwable) { - CrashReport crashreport = CrashReport.a(throwable, "Getting block"); - CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Block being got"); - - crashreportsystemdetails.a("Location", (Callable) (new CrashReportLocation(this, i, j, k))); - throw new ReportedException(crashreport); - } - } - } - - return block; - } - - public int getData(int i, int j, int k) { - if (j >> 4 >= this.sections.length) { - return 0; - } else { - ChunkSection chunksection = this.sections[j >> 4]; - - return chunksection != null ? chunksection.getData(i, j & 15, k) : 0; - } - } - - // Spigot start - prevent invalid data values - public static int checkData( Block block, int data ) - { - if (block == Blocks.DOUBLE_PLANT ) - { - return data < 6 || data >= 8 ? data : 0; - } - return data; - } - // Spigot end - - public boolean a(int i, int j, int k, Block block, int l) { - int i1 = k << 4 | i; - - if (j >= this.b[i1] - 1) { - this.b[i1] = -999; - } - - int j1 = this.heightMap[i1]; - Block block1 = this.getType(i, j, k); - int k1 = this.getData(i, j, k); - - if (block1 == block && k1 == l) { - return false; - } else { - ChunkSection chunksection = this.sections[j >> 4]; - boolean flag = false; - - if (chunksection == null) { - if (block == Blocks.AIR) { - return false; - } - - chunksection = this.sections[j >> 4] = new ChunkSection(j >> 4 << 4, !this.world.worldProvider.g); - flag = j >= j1; - } - - int l1 = this.locX * 16 + i; - int i2 = this.locZ * 16 + k; - - if (!this.world.isStatic) { - block1.f(this.world, l1, j, i2, k1); - } - - // CraftBukkit start - Delay removing containers until after they're cleaned up - if (!(block1 instanceof IContainer)) { - chunksection.setTypeId(i, j & 15, k, block); - } - // CraftBukkit end - - if (!this.world.isStatic) { - block1.remove(this.world, l1, j, i2, block1, k1); - } else if (block1 instanceof IContainer && block1 != block) { - this.world.p(l1, j, i2); - } - - // CraftBukkit start - Remove containers now after cleanup - if (block1 instanceof IContainer) { - chunksection.setTypeId(i, j & 15, k, block); - } - // CraftBukkit end - - if (chunksection.getTypeId(i, j & 15, k) != block) { - return false; - } else { - chunksection.setData(i, j & 15, k, checkData( block, l ) ); - if (flag) { - this.initLighting(); - } else { - int j2 = block.k(); - int k2 = block1.k(); - - if (j2 > 0) { - if (j >= j1) { - this.h(i, j + 1, k); - } - } else if (j == j1 - 1) { - this.h(i, j, k); - } - - if (j2 != k2 && (j2 < k2 || this.getBrightness(EnumSkyBlock.SKY, i, j, k) > 0 || this.getBrightness(EnumSkyBlock.BLOCK, i, j, k) > 0)) { - this.e(i, k); - } - } - - TileEntity tileentity; - - if (block1 instanceof IContainer) { - tileentity = this.e(i, j, k); - if (tileentity != null) { - tileentity.u(); - } - } - - // CraftBukkit - Don't place while processing the BlockPlaceEvent, unless it's a BlockContainer. Prevents blocks such as TNT from activating when cancelled. - if (!this.world.isStatic && (!this.world.captureBlockStates || block instanceof BlockContainer)) { - block.onPlace(this.world, l1, j, i2); - } - - if (block instanceof IContainer) { - - tileentity = this.e(i, j, k); - if (tileentity == null) { - tileentity = ((IContainer) block).a(this.world, l); - this.world.setTileEntity(l1, j, i2, tileentity); - } - - if (tileentity != null) { - tileentity.u(); - } - } - - this.n = true; - return true; - } - } - } - - public boolean a(int i, int j, int k, int l) { - ChunkSection chunksection = this.sections[j >> 4]; - - if (chunksection == null) { - return false; - } else { - int i1 = chunksection.getData(i, j & 15, k); - - if (i1 == l) { - return false; - } else { - this.n = true; - Block block = chunksection.getTypeId( i, j & 15, k ); - chunksection.setData(i, j & 15, k, checkData( block, l ) ); - if (block instanceof IContainer) { - TileEntity tileentity = this.e(i, j, k); - - if (tileentity != null) { - tileentity.u(); - tileentity.g = l; - } - } - - return true; - } - } - } - - public int getBrightness(EnumSkyBlock enumskyblock, int i, int j, int k) { - ChunkSection chunksection = this.sections[j >> 4]; - - return chunksection == null ? (this.d(i, j, k) ? enumskyblock.c : 0) : (enumskyblock == EnumSkyBlock.SKY ? (this.world.worldProvider.g ? 0 : chunksection.getSkyLight(i, j & 15, k)) : (enumskyblock == EnumSkyBlock.BLOCK ? chunksection.getEmittedLight(i, j & 15, k) : enumskyblock.c)); - } - - public void a(EnumSkyBlock enumskyblock, int i, int j, int k, int l) { - ChunkSection chunksection = this.sections[j >> 4]; - - if (chunksection == null) { - chunksection = this.sections[j >> 4] = new ChunkSection(j >> 4 << 4, !this.world.worldProvider.g); - this.initLighting(); - } - - this.n = true; - if (enumskyblock == EnumSkyBlock.SKY) { - if (!this.world.worldProvider.g) { - chunksection.setSkyLight(i, j & 15, k, l); - } - } else if (enumskyblock == EnumSkyBlock.BLOCK) { - chunksection.setEmittedLight(i, j & 15, k, l); - } - } - - public int b(int i, int j, int k, int l) { - ChunkSection chunksection = this.sections[j >> 4]; - - if (chunksection == null) { - return !this.world.worldProvider.g && l < EnumSkyBlock.SKY.c ? EnumSkyBlock.SKY.c - l : 0; - } else { - int i1 = this.world.worldProvider.g ? 0 : chunksection.getSkyLight(i, j & 15, k); - - if (i1 > 0) { - a = true; - } - - i1 -= l; - int j1 = chunksection.getEmittedLight(i, j & 15, k); - - if (j1 > i1) { - i1 = j1; - } - - return i1; - } - } - - public void a(Entity entity) { - this.o = true; - int i = MathHelper.floor(entity.locX / 16.0D); - int j = MathHelper.floor(entity.locZ / 16.0D); - - if (i != this.locX || j != this.locZ) { - // CraftBukkit start - Bukkit.getLogger().warning("Wrong location for " + entity + " in world '" + world.getWorld().getName() + "'!"); - // t.warn("Wrong location! " + entity + " (at " + i + ", " + j + " instead of " + this.locX + ", " + this.locZ + ")"); - // Thread.dumpStack(); - Bukkit.getLogger().warning("Entity is at " + entity.locX + "," + entity.locZ + " (chunk " + i + "," + j + ") but was stored in chunk " + this.locX + "," + this.locZ); - // CraftBukkit end - } - - ChunkAddEntityEvent event = new ChunkAddEntityEvent(entity.bukkitEntity); - Bukkit.getServer().getPluginManager().callEvent(event); - - int k = MathHelper.floor(entity.locY / 16.0D); - - if (k < 0) { - k = 0; - } - - if (k >= this.entitySlices.length) { - k = this.entitySlices.length - 1; - } - - entity.ag = true; - entity.ah = this.locX; - entity.ai = k; - entity.aj = this.locZ; - this.entitySlices[k].add(entity); - // Spigot start - increment creature type count - // Keep this synced up with World.a(Class) - if (entity instanceof EntityInsentient) { - EntityInsentient entityinsentient = (EntityInsentient) entity; - if (entityinsentient.isTypeNotPersistent() && entityinsentient.isPersistent()) { - return; - } - } - for ( EnumCreatureType creatureType : EnumCreatureType.values() ) - { - if ( creatureType.a().isAssignableFrom( entity.getClass() ) ) - { - this.entityCount.adjustOrPutValue( creatureType.a(), 1, 1 ); - } - } - // Spigot end - } - - public void b(Entity entity) { - this.a(entity, entity.ai); - } - - public void a(Entity entity, int i) { - if (i < 0) { - i = 0; - } - - if (i >= this.entitySlices.length) { - i = this.entitySlices.length - 1; - } - - this.entitySlices[i].remove(entity); - // Spigot start - decrement creature type count - // Keep this synced up with World.a(Class) - if (entity instanceof EntityInsentient) { - EntityInsentient entityinsentient = (EntityInsentient) entity; - if (entityinsentient.isTypeNotPersistent() && entityinsentient.isPersistent()) { - return; - } - } - for ( EnumCreatureType creatureType : EnumCreatureType.values() ) - { - if ( creatureType.a().isAssignableFrom( entity.getClass() ) ) - { - this.entityCount.adjustValue( creatureType.a(), -1 ); - } - } - // Spigot end - } - - public boolean d(int i, int j, int k) { - return j >= this.heightMap[k << 4 | i]; - } - - public TileEntity e(int i, int j, int k) { - ChunkPosition chunkposition = new ChunkPosition(i, j, k); - TileEntity tileentity = (TileEntity) this.tileEntities.get(chunkposition); - - if (tileentity == null) { - Block block = this.getType(i, j, k); - - if (!block.isTileEntity()) { - return null; - } - - tileentity = ((IContainer) block).a(this.world, this.getData(i, j, k)); - this.world.setTileEntity(this.locX * 16 + i, j, this.locZ * 16 + k, tileentity); - } - - if (tileentity != null && tileentity.r()) { - this.tileEntities.remove(chunkposition); - return null; - } else { - return tileentity; - } - } - - public void a(TileEntity tileentity) { - int i = tileentity.x - this.locX * 16; - int j = tileentity.y; - int k = tileentity.z - this.locZ * 16; - - this.a(i, j, k, tileentity); - if (this.d) { - this.world.tileEntityList.add(tileentity); - } - } - - public void a(int i, int j, int k, TileEntity tileentity) { - ChunkPosition chunkposition = new ChunkPosition(i, j, k); - - tileentity.a(this.world); - tileentity.x = this.locX * 16 + i; - tileentity.y = j; - tileentity.z = this.locZ * 16 + k; - if (this.getType(i, j, k) instanceof IContainer) { - if (this.tileEntities.containsKey(chunkposition)) { - ((TileEntity) this.tileEntities.get(chunkposition)).s(); - } - - tileentity.t(); - this.tileEntities.put(chunkposition, tileentity); - // Spigot start - The tile entity has a world, now hoppers can be born ticking. - if (this.world.spigotConfig.altHopperTicking) { - this.world.triggerHoppersList.add(tileentity); - } - // Spigot end - // CraftBukkit start - } else { - System.out.println("Attempted to place a tile entity (" + tileentity + ") at " + tileentity.x + "," + tileentity.y + "," + tileentity.z - + " (" + org.bukkit.craftbukkit.v1_7_R4.util.CraftMagicNumbers.getMaterial(getType(i, j, k)) + ") where there was no entity tile!"); - System.out.println("Chunk coordinates: " + (this.locX * 16) + "," + (this.locZ * 16)); - new Exception().printStackTrace(); - // CraftBukkit end - } - } - - public void f(int i, int j, int k) { - ChunkPosition chunkposition = new ChunkPosition(i, j, k); - - if (this.d) { - TileEntity tileentity = (TileEntity) this.tileEntities.remove(chunkposition); - - if (tileentity != null) { - tileentity.s(); - } - } - } - - public void addEntities() { - this.d = true; - this.world.a(this.tileEntities.values()); - - for (int i = 0; i < this.entitySlices.length; ++i) { - Iterator iterator = this.entitySlices[i].iterator(); - - while (iterator.hasNext()) { - Entity entity = (Entity) iterator.next(); - - entity.X(); - } - - this.world.a(this.entitySlices[i]); - } - } - - public void removeEntities() { - this.d = false; - Iterator iterator = this.tileEntities.values().iterator(); - - while (iterator.hasNext()) { - TileEntity tileentity = (TileEntity) iterator.next(); - // Spigot Start - if ( tileentity instanceof IInventory ) - { - for ( org.bukkit.entity.HumanEntity h : new ArrayList( (List) ( (IInventory) tileentity ).getViewers() ) ) - { - if ( h instanceof org.bukkit.craftbukkit.v1_7_R4.entity.CraftHumanEntity ) - { - ( (org.bukkit.craftbukkit.v1_7_R4.entity.CraftHumanEntity) h).getHandle().closeInventory(); - } - } - } - // Spigot End - - this.world.a(tileentity); - } - - for (int i = 0; i < this.entitySlices.length; ++i) { - // CraftBukkit start - java.util.Iterator iter = this.entitySlices[i].iterator(); - while (iter.hasNext()) { - Entity entity = (Entity) iter.next(); - // Spigot Start - if ( entity instanceof IInventory ) - { - for ( org.bukkit.entity.HumanEntity h : new ArrayList( (List) ( (IInventory) entity ).getViewers() ) ) - { - if ( h instanceof org.bukkit.craftbukkit.v1_7_R4.entity.CraftHumanEntity ) - { - ( (org.bukkit.craftbukkit.v1_7_R4.entity.CraftHumanEntity) h).getHandle().closeInventory(); - } - } - } - // Spigot End - - // Do not pass along players, as doing so can get them stuck outside of time. - // (which for example disables inventory icon updates and prevents block breaking) - if (entity instanceof EntityPlayer) { - iter.remove(); - } - } - // CraftBukkit end - - this.world.b(this.entitySlices[i]); - } - } - - public void e() { - this.n = true; - } - - public void a(Entity entity, AxisAlignedBB axisalignedbb, List list, IEntitySelector ientityselector) { - int i = MathHelper.floor((axisalignedbb.b - 2.0D) / 16.0D); - int j = MathHelper.floor((axisalignedbb.e + 2.0D) / 16.0D); - - i = MathHelper.a(i, 0, this.entitySlices.length - 1); - j = MathHelper.a(j, 0, this.entitySlices.length - 1); - - for (int k = i; k <= j; ++k) { - List list1 = this.entitySlices[k]; - - for (int l = 0; l < list1.size(); ++l) { - Entity entity1 = (Entity) list1.get(l); - - if (entity1 != entity && entity1.boundingBox.b(axisalignedbb) && (ientityselector == null || ientityselector.a(entity1))) { - list.add(entity1); - Entity[] aentity = entity1.at(); - - if (aentity != null) { - for (int i1 = 0; i1 < aentity.length; ++i1) { - entity1 = aentity[i1]; - if (entity1 != entity && entity1.boundingBox.b(axisalignedbb) && (ientityselector == null || ientityselector.a(entity1))) { - list.add(entity1); - } - } - } - } - } - } - } - - public void a(Class oclass, AxisAlignedBB axisalignedbb, List list, IEntitySelector ientityselector) { - int i = MathHelper.floor((axisalignedbb.b - 2.0D) / 16.0D); - int j = MathHelper.floor((axisalignedbb.e + 2.0D) / 16.0D); - - i = MathHelper.a(i, 0, this.entitySlices.length - 1); - j = MathHelper.a(j, 0, this.entitySlices.length - 1); - - for (int k = i; k <= j; ++k) { - List list1 = this.entitySlices[k]; - - for (int l = 0; l < list1.size(); ++l) { - Entity entity = (Entity) list1.get(l); - - if (oclass.isAssignableFrom(entity.getClass()) && entity.boundingBox.b(axisalignedbb) && (ientityselector == null || ientityselector.a(entity))) { - list.add(entity); - } - } - } - } - - public boolean a(boolean flag) { - if (flag) { - if (this.o && this.world.getTime() != this.lastSaved || this.n) { - return true; - } - } else if (this.o && this.world.getTime() >= this.lastSaved + 600L) { - return true; - } - - return this.n; - } - - public Random a(long i) { - return new Random(this.world.getSeed() + (long) (this.locX * this.locX * 4987142) + (long) (this.locX * 5947611) + (long) (this.locZ * this.locZ) * 4392871L + (long) (this.locZ * 389711) ^ i); - } - - public boolean isEmpty() { - return false; - } - - public void loadNearby(IChunkProvider ichunkprovider, IChunkProvider ichunkprovider1, int i, int j) { - world.timings.syncChunkLoadPostTimer.startTiming(); // Spigot - if (!this.done && ichunkprovider.isChunkLoaded(i + 1, j + 1) && ichunkprovider.isChunkLoaded(i, j + 1) && ichunkprovider.isChunkLoaded(i + 1, j)) { - ichunkprovider.getChunkAt(ichunkprovider1, i, j); - } - - if (ichunkprovider.isChunkLoaded(i - 1, j) && !ichunkprovider.getOrCreateChunk(i - 1, j).done && ichunkprovider.isChunkLoaded(i - 1, j + 1) && ichunkprovider.isChunkLoaded(i, j + 1) && ichunkprovider.isChunkLoaded(i - 1, j + 1)) { - ichunkprovider.getChunkAt(ichunkprovider1, i - 1, j); - } - - if (ichunkprovider.isChunkLoaded(i, j - 1) && !ichunkprovider.getOrCreateChunk(i, j - 1).done && ichunkprovider.isChunkLoaded(i + 1, j - 1) && ichunkprovider.isChunkLoaded(i + 1, j - 1) && ichunkprovider.isChunkLoaded(i + 1, j)) { - ichunkprovider.getChunkAt(ichunkprovider1, i, j - 1); - } - - if (ichunkprovider.isChunkLoaded(i - 1, j - 1) && !ichunkprovider.getOrCreateChunk(i - 1, j - 1).done && ichunkprovider.isChunkLoaded(i, j - 1) && ichunkprovider.isChunkLoaded(i - 1, j)) { - ichunkprovider.getChunkAt(ichunkprovider1, i - 1, j - 1); - } - world.timings.syncChunkLoadPostTimer.stopTiming(); // Spigot - } - - public int d(int i, int j) { - int k = i | j << 4; - int l = this.b[k]; - - if (l == -999) { - int i1 = this.h() + 15; - - l = -1; - - while (i1 > 0 && l == -1) { - Block block = this.getType(i, i1, j); - Material material = block.getMaterial(); - - if (!material.isSolid() && !material.isLiquid()) { - --i1; - } else { - l = i1 + 1; - } - } - - this.b[k] = l; - } - - return l; - } - - public void b(boolean flag) { - if (this.w && !this.world.worldProvider.g && !flag) { - this.c(this.world.isStatic); - } - - this.m = true; - if (!this.lit && this.done && this.world.spigotConfig.randomLightUpdates) { // Spigot - also use random light updates setting to determine if we should relight - this.p(); - } - } - - public boolean isReady() { - // Spigot Start - /* - * As of 1.7, Mojang added a check to make sure that only chunks which have been lit are sent to the client. - * Unfortunately this interferes with our modified chunk ticking algorithm, which will only tick chunks distant from the player on a very infrequent basis. - * We cannot unfortunately do this lighting stage during chunk gen as it appears to put a lot more noticeable load on the server, than when it is done at play time. - * For now at least we will simply send all chunks, in accordance with pre 1.7 behaviour. - */ - return true; - // Spigot End - } - - public ChunkCoordIntPair l() { - return new ChunkCoordIntPair(this.locX, this.locZ); - } - - public boolean c(int i, int j) { - if (i < 0) { - i = 0; - } - - if (j >= 256) { - j = 255; - } - - for (int k = i; k <= j; k += 16) { - ChunkSection chunksection = this.sections[k >> 4]; - - if (chunksection != null && !chunksection.isEmpty()) { - return false; - } - } - - return true; - } - - public void a(ChunkSection[] achunksection) { - this.sections = achunksection; - } - - public BiomeBase getBiome(int i, int j, WorldChunkManager worldchunkmanager) { - int k = this.v[j << 4 | i] & 255; - - if (k == 255) { - BiomeBase biomebase = worldchunkmanager.getBiome((this.locX << 4) + i, (this.locZ << 4) + j); - - k = biomebase.id; - this.v[j << 4 | i] = (byte) (k & 255); - } - - return BiomeBase.getBiome(k) == null ? BiomeBase.PLAINS : BiomeBase.getBiome(k); - } - - public byte[] m() { - return this.v; - } - - public void a(byte[] abyte) { - this.v = abyte; - } - - public void n() { - this.x = 0; - } - - public void o() { - for (int i = 0; i < 8; ++i) { - if (this.x >= 4096) { - return; - } - - int j = this.x % 16; - int k = this.x / 16 % 16; - int l = this.x / 256; - - ++this.x; - int i1 = (this.locX << 4) + k; - int j1 = (this.locZ << 4) + l; - - for (int k1 = 0; k1 < 16; ++k1) { - int l1 = (j << 4) + k1; - - if (this.sections[j] == null && (k1 == 0 || k1 == 15 || k == 0 || k == 15 || l == 0 || l == 15) || this.sections[j] != null && this.sections[j].getTypeId(k, k1, l).getMaterial() == Material.AIR) { - if (this.world.getType(i1, l1 - 1, j1).m() > 0) { - this.world.t(i1, l1 - 1, j1); - } - - if (this.world.getType(i1, l1 + 1, j1).m() > 0) { - this.world.t(i1, l1 + 1, j1); - } - - if (this.world.getType(i1 - 1, l1, j1).m() > 0) { - this.world.t(i1 - 1, l1, j1); - } - - if (this.world.getType(i1 + 1, l1, j1).m() > 0) { - this.world.t(i1 + 1, l1, j1); - } - - if (this.world.getType(i1, l1, j1 - 1).m() > 0) { - this.world.t(i1, l1, j1 - 1); - } - - if (this.world.getType(i1, l1, j1 + 1).m() > 0) { - this.world.t(i1, l1, j1 + 1); - } - - this.world.t(i1, l1, j1); - } - } - } - } - - public void p() { - this.done = true; - this.lit = true; - if (!this.world.worldProvider.g) { - if (this.world.b(this.locX * 16 - 1, 0, this.locZ * 16 - 1, this.locX * 16 + 1, 63, this.locZ * 16 + 1)) { - for (int i = 0; i < 16; ++i) { - for (int j = 0; j < 16; ++j) { - if (!this.f(i, j)) { - this.lit = false; - break; - } - } - } - - if (this.lit) { - Chunk chunk = this.world.getChunkAtWorldCoords(this.locX * 16 - 1, this.locZ * 16); - - chunk.a(3); - chunk = this.world.getChunkAtWorldCoords(this.locX * 16 + 16, this.locZ * 16); - chunk.a(1); - chunk = this.world.getChunkAtWorldCoords(this.locX * 16, this.locZ * 16 - 1); - chunk.a(0); - chunk = this.world.getChunkAtWorldCoords(this.locX * 16, this.locZ * 16 + 16); - chunk.a(2); - } - } else { - this.lit = false; - } - } - } - - private void a(int i) { - if (this.done) { - int j; - - if (i == 3) { - for (j = 0; j < 16; ++j) { - this.f(15, j); - } - } else if (i == 1) { - for (j = 0; j < 16; ++j) { - this.f(0, j); - } - } else if (i == 0) { - for (j = 0; j < 16; ++j) { - this.f(j, 15); - } - } else if (i == 2) { - for (j = 0; j < 16; ++j) { - this.f(j, 0); - } - } - } - } - - private boolean f(int i, int j) { - int k = this.h(); - boolean flag = false; - boolean flag1 = false; - - int l; - - for (l = k + 16 - 1; l > 63 || l > 0 && !flag1; --l) { - int i1 = this.b(i, l, j); - - if (i1 == 255 && l < 63) { - flag1 = true; - } - - if (!flag && i1 > 0) { - flag = true; - } else if (flag && i1 == 0 && !this.world.t(this.locX * 16 + i, l, this.locZ * 16 + j)) { - return false; - } - } - - for (; l > 0; --l) { - if (this.getType(i, l, j).m() > 0) { - this.world.t(this.locX * 16 + i, l, this.locZ * 16 + j); - } - } - - return true; - } -} diff --git a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/ChunkAddEntityEvent.java b/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/ChunkAddEntityEvent.java deleted file mode 100644 index 5fe940a56..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/ChunkAddEntityEvent.java +++ /dev/null @@ -1,31 +0,0 @@ -package net.minecraft.server.v1_7_R4; - -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/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/ChunkPreLoadEvent.java b/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/ChunkPreLoadEvent.java deleted file mode 100644 index 791d0774c..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/ChunkPreLoadEvent.java +++ /dev/null @@ -1,58 +0,0 @@ -package net.minecraft.server.v1_7_R4; - -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/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/ChunkProviderServer.java b/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/ChunkProviderServer.java deleted file mode 100644 index 07af13347..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/ChunkProviderServer.java +++ /dev/null @@ -1,452 +0,0 @@ -package net.minecraft.server.v1_7_R4; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; - -import net.minecraft.util.com.google.common.collect.Lists; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -// CraftBukkit start -import java.util.Random; - -import org.bukkit.Server; -import org.bukkit.craftbukkit.v1_7_R4.chunkio.ChunkIOExecutor; -import org.bukkit.craftbukkit.v1_7_R4.util.LongHash; -import org.bukkit.craftbukkit.v1_7_R4.util.LongHashSet; -import org.bukkit.craftbukkit.v1_7_R4.util.LongObjectHashMap; -import org.bukkit.event.world.ChunkUnloadEvent; -// CraftBukkit end - -public class ChunkProviderServer implements IChunkProvider { - - private static final Logger b = LogManager.getLogger(); - // CraftBukkit start - private -> public - public LongHashSet unloadQueue = new LongHashSet(); // LongHashSet - public Chunk emptyChunk; - public IChunkProvider chunkProvider; - private IChunkLoader f; - public boolean forceChunkLoad = false; // true -> false - public LongObjectHashMap chunks = new LongObjectHashMap(); - public WorldServer world; - // CraftBukkit end - - public ChunkProviderServer(WorldServer worldserver, IChunkLoader ichunkloader, IChunkProvider ichunkprovider) { - this.emptyChunk = new EmptyChunk(worldserver, 0, 0); - this.world = worldserver; - this.f = ichunkloader; - this.chunkProvider = ichunkprovider; - } - - public boolean isChunkLoaded(int i, int j) { - return this.chunks.containsKey(LongHash.toLong(i, j)); // CraftBukkit - } - - // CraftBukkit start - Change return type to Collection and return the values of our chunk map - public java.util.Collection a() { - // return this.chunkList; - return this.chunks.values(); - // CraftBukkit end - } - - public void queueUnload(int i, int j) { - if (this.world.worldProvider.e()) { - ChunkCoordinates chunkcoordinates = this.world.getSpawn(); - int k = i * 16 + 8 - chunkcoordinates.x; - int l = j * 16 + 8 - chunkcoordinates.z; - short short1 = 128; - - // CraftBukkit start - if (k < -short1 || k > short1 || l < -short1 || l > short1 || !(this.world.keepSpawnInMemory)) { // Added 'this.world.keepSpawnInMemory' - this.unloadQueue.add(i, j); - - Chunk c = this.chunks.get(LongHash.toLong(i, j)); - if (c != null) { - c.mustSave = true; - } - } - // CraftBukkit end - } else { - // CraftBukkit start - this.unloadQueue.add(i, j); - - Chunk c = this.chunks.get(LongHash.toLong(i, j)); - if (c != null) { - c.mustSave = true; - } - // CraftBukkit end - } - } - - public void b() { - Iterator iterator = this.chunks.values().iterator(); // CraftBukkit - - while (iterator.hasNext()) { - Chunk chunk = (Chunk) iterator.next(); - - this.queueUnload(chunk.locX, chunk.locZ); - } - } - - // CraftBukkit start - Add async variant, provide compatibility - public Chunk getChunkIfLoaded(int x, int z) { - return this.chunks.get(LongHash.toLong(x, z)); - } - - public Chunk getChunkAt(int i, int j) { - return getChunkAt(i, j, null); - } - - public Chunk getChunkAt(int i, int j, Runnable runnable) { - this.unloadQueue.remove(i, j); - Chunk chunk = this.chunks.get(LongHash.toLong(i, j)); - ChunkRegionLoader loader = null; - - if (this.f instanceof ChunkRegionLoader) { - loader = (ChunkRegionLoader) this.f; - } - - // We can only use the queue for already generated chunks - if (chunk == null && loader != null && loader.chunkExists(this.world, i, j)) { - if (runnable != null) { - 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 { - - 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); - } - - // If we didn't load the chunk async and have a callback run it now - if (runnable != null) { - runnable.run(); - } - - return chunk; - } - - public Chunk originalGetChunkAt(int i, int j) { - this.unloadQueue.remove(i, j); - 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); - if (chunk == null) { - if (this.chunkProvider == null) { - chunk = this.emptyChunk; - } else { - try { - chunk = this.chunkProvider.getOrCreateChunk(i, j); - } catch (Throwable throwable) { - CrashReport crashreport = CrashReport.a(throwable, "Exception generating new chunk"); - CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Chunk to be generated"); - - crashreportsystemdetails.a("Location", String.format("%d,%d", new Object[] { Integer.valueOf(i), Integer.valueOf(j)})); - crashreportsystemdetails.a("Position hash", Long.valueOf(LongHash.toLong(i, j))); // CraftBukkit - Use LongHash - crashreportsystemdetails.a("Generator", this.chunkProvider.getName()); - throw new ReportedException(crashreport); - } - } - newChunk = true; // CraftBukkit - } - - this.chunks.put(LongHash.toLong(i, j), chunk); // CraftBukkit - chunk.addEntities(); - - // CraftBukkit start - if (server != null) { - /* - * If it's a new world, the first few chunks are generated inside - * the World constructor. We can't reliably alter that, so we have - * no way of creating a CraftWorld/CraftServer at that point. - */ - server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkLoadEvent(chunk.bukkitChunk, newChunk)); - } - - // Update neighbor counts - for (int x = -2; x < 3; x++) { - for (int z = -2; z < 3; z++) { - if (x == 0 && z == 0) { - continue; - } - - Chunk neighbor = this.getChunkIfLoaded(chunk.locX + x, chunk.locZ + z); - if (neighbor != null) { - neighbor.setNeighborLoaded(-x, -z); - chunk.setNeighborLoaded(x, z); - } - } - } - // CraftBukkit end - chunk.loadNearby(this, this, i, j); - world.timings.syncChunkLoadTimer.stopTiming(); // Spigot - } - - return chunk; - } - - public Chunk getOrCreateChunk(int i, int j) { - // CraftBukkit start - Chunk chunk = (Chunk) this.chunks.get(LongHash.toLong(i, j)); - - chunk = chunk == null ? (!this.world.isLoading && !this.forceChunkLoad ? this.emptyChunk : this.getChunkAt(i, j)) : chunk; - if (chunk == this.emptyChunk) return chunk; - if (i != chunk.locX || j != chunk.locZ) { - b.error("Chunk (" + chunk.locX + ", " + chunk.locZ + ") stored at (" + i + ", " + j + ") in world '" + world.getWorld().getName() + "'"); - b.error(chunk.getClass().getName()); - Throwable ex = new Throwable(); - ex.fillInStackTrace(); - ex.printStackTrace(); - } - return chunk; - // CraftBukkit end - } - - public Chunk loadChunk(int i, int j) { // CraftBukkit - private -> public - if (this.f == null) { - return null; - } else { - try { - Chunk chunk = this.f.a(this.world, i, j); - - if (chunk != null) { - chunk.lastSaved = this.world.getTime(); - if (this.chunkProvider != null) { - world.timings.syncChunkLoadStructuresTimer.startTiming(); // Spigot - this.chunkProvider.recreateStructures(i, j); - world.timings.syncChunkLoadStructuresTimer.stopTiming(); // Spigot - } - } - - return chunk; - } catch (Exception exception) { - b.error("Couldn\'t load chunk", exception); - return null; - } - } - } - - public void saveChunkNOP(Chunk chunk) { // CraftBukkit - private -> public - if (this.f != null) { - try { - this.f.b(this.world, chunk); - } catch (Exception exception) { - b.error("Couldn\'t save entities", exception); - } - } - } - - public void saveChunk(Chunk chunk) { // CraftBukkit - private -> public - if (this.f != null) { - try { - chunk.lastSaved = this.world.getTime(); - this.f.a(this.world, chunk); - // CraftBukkit start - IOException to Exception - } catch (Exception ioexception) { - b.error("Couldn\'t save chunk", ioexception); - /* Remove extra exception - } catch (ExceptionWorldConflict exceptionworldconflict) { - b.error("Couldn\'t save chunk; already in use by another instance of Minecraft?", exceptionworldconflict); - // CraftBukkit end */ - } - } - } - - public void getChunkAt(IChunkProvider ichunkprovider, int i, int j) { - Chunk chunk = this.getOrCreateChunk(i, j); - - if (!chunk.done) { - chunk.p(); - if (this.chunkProvider != null) { - this.chunkProvider.getChunkAt(ichunkprovider, i, j); - - // CraftBukkit start - BlockSand.instaFall = true; - Random random = new Random(); - random.setSeed(world.getSeed()); - long xRand = random.nextLong() / 2L * 2L + 1L; - long zRand = random.nextLong() / 2L * 2L + 1L; - random.setSeed((long) i * xRand + (long) j * zRand ^ world.getSeed()); - - org.bukkit.World world = this.world.getWorld(); - if (world != null) { - this.world.populating = true; - try { - for (org.bukkit.generator.BlockPopulator populator : world.getPopulators()) { - populator.populate(world, random, chunk.bukkitChunk); - } - } finally { - this.world.populating = false; - } - } - BlockSand.instaFall = false; - this.world.getServer().getPluginManager().callEvent(new org.bukkit.event.world.ChunkPopulateEvent(chunk.bukkitChunk)); - // CraftBukkit end - - chunk.e(); - } - } - } - - public boolean saveChunks(boolean flag, IProgressUpdate iprogressupdate) { - int i = 0; - // CraftBukkit start - Iterator iterator = this.chunks.values().iterator(); - - while (iterator.hasNext()) { - Chunk chunk = (Chunk) iterator.next(); - // CraftBukkit end - - if (flag) { - this.saveChunkNOP(chunk); - } - - if (chunk.a(flag)) { - this.saveChunk(chunk); - chunk.n = false; - ++i; - if (i == 24 && !flag) { - return false; - } - } - } - - return true; - } - - public void c() { - if (this.f != null) { - this.f.b(); - } - } - - public boolean unloadChunks() { - if (!this.world.savingDisabled) { - // CraftBukkit start - Server server = this.world.getServer(); - for (int i = 0; i < 100 && !this.unloadQueue.isEmpty(); i++) { - long chunkcoordinates = this.unloadQueue.popFirst(); - Chunk chunk = this.chunks.get(chunkcoordinates); - if (chunk == null) continue; - - ChunkUnloadEvent event = new ChunkUnloadEvent(chunk.bukkitChunk); - server.getPluginManager().callEvent(event); - if (!event.isCancelled()) { - if (chunk != null) { - chunk.removeEntities(); - this.saveChunk(chunk); - this.saveChunkNOP(chunk); - this.chunks.remove(chunkcoordinates); // CraftBukkit - } - - // this.unloadQueue.remove(olong); - // this.chunks.remove(olong.longValue()); - - // Update neighbor counts - for (int x = -2; x < 3; x++) { - for (int z = -2; z < 3; z++) { - if (x == 0 && z == 0) { - continue; - } - - Chunk neighbor = this.getChunkIfLoaded(chunk.locX + x, chunk.locZ + z); - if (neighbor != null) { - neighbor.setNeighborUnloaded(-x, -z); - chunk.setNeighborUnloaded(x, z); - } - } - } - } - } - // CraftBukkit end - - if (this.f != null) { - this.f.a(); - } - } - - return this.chunkProvider.unloadChunks(); - } - - public boolean canSave() { - return !this.world.savingDisabled; - } - - public String getName() { - // CraftBukkit - this.chunks.count() -> .values().size() - return "ServerChunkCache: " + this.chunks.values().size() + " Drop: " + this.unloadQueue.size(); - } - - public List getMobsFor(EnumCreatureType enumcreaturetype, int i, int j, int k) { - return this.chunkProvider.getMobsFor(enumcreaturetype, i, j, k); - } - - public ChunkPosition findNearestMapFeature(World world, String s, int i, int j, int k) { - return this.chunkProvider.findNearestMapFeature(world, s, i, j, k); - } - - public int getLoadedChunks() { - // CraftBukkit - this.chunks.count() -> this.chunks.size() - return this.chunks.size(); - } - - public void recreateStructures(int i, int j) {} -} diff --git a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/ContainerAnvilInventory.java b/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/ContainerAnvilInventory.java deleted file mode 100644 index 75501b79b..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/ContainerAnvilInventory.java +++ /dev/null @@ -1,58 +0,0 @@ -package net.minecraft.server.v1_7_R4; - -// CraftBukkit start -import java.util.List; -import org.bukkit.craftbukkit.v1_7_R4.entity.CraftHumanEntity; -import org.bukkit.entity.HumanEntity; -// CraftBukkit end - -public class ContainerAnvilInventory extends InventorySubcontainer { // CraftBukkit - public - - final ContainerAnvil a; - - // CraftBukkit start - public List transaction = new java.util.ArrayList(); - public org.bukkit.entity.Player player; - private int maxStack = MAX_STACK; - - public ItemStack[] getContents() { - return this.items; - } - - public void onOpen(CraftHumanEntity who) { - transaction.add(who); - } - - public void onClose(CraftHumanEntity who) { - transaction.remove(who); - } - - public List getViewers() { - return transaction; - } - - public org.bukkit.inventory.InventoryHolder getOwner() { - return this.player; - } - - public void setMaxStackSize(int size) { - maxStack = size; - } - // CraftBukkit end - - public ContainerAnvilInventory(ContainerAnvil containeranvil, String s, boolean flag, int i) { - super(s, flag, i); - this.a = containeranvil; - } - - // CraftBukkit start - override inherited maxStack from InventorySubcontainer - public int getMaxStackSize() { - return maxStack; - } - // CraftBukkit end - - public void update() { - super.update(); - this.a.a((IInventory) this); - } -} \ No newline at end of file diff --git a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/DedicatedServer.java b/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/DedicatedServer.java deleted file mode 100644 index 2c1958a39..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/DedicatedServer.java +++ /dev/null @@ -1,512 +0,0 @@ -package net.minecraft.server.v1_7_R4; - -import java.io.File; -import java.io.PrintStream; -import java.net.InetAddress; -import java.net.Proxy; -import java.net.UnknownHostException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.Random; -import java.util.logging.Handler; -import org.apache.logging.log4j.Level; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.core.Appender; -import org.apache.logging.log4j.core.appender.ConsoleAppender; -import org.bukkit.craftbukkit.libs.joptsimple.OptionSet; -import org.bukkit.craftbukkit.v1_7_R4.CraftServer; -import org.bukkit.craftbukkit.v1_7_R4.LoggerOutputStream; -import org.bukkit.craftbukkit.v1_7_R4.SpigotTimings; -import org.bukkit.craftbukkit.v1_7_R4.command.CraftRemoteConsoleCommandSender; -import org.bukkit.craftbukkit.v1_7_R4.util.ForwardLogHandler; -import org.bukkit.craftbukkit.v1_7_R4.util.TerminalConsoleWriterThread; -import org.bukkit.event.server.ServerCommandEvent; -import org.bukkit.plugin.PluginLoadOrder; -import org.bukkit.plugin.PluginManager; -import org.spigotmc.CustomTimingsHandler; -import org.spigotmc.SpigotConfig; - -public class DedicatedServer - extends MinecraftServer - implements IMinecraftServer -{ - private static final org.apache.logging.log4j.Logger logger = LogManager.getLogger(); - private final List j = Collections.synchronizedList(new ArrayList()); - private RemoteStatusListener k; - private RemoteControlListener l; - public PropertyManager propertyManager; - private boolean generateStructures; - private EnumGamemode p; - private boolean q; - - public DedicatedServer(OptionSet options) - { - super(options, Proxy.NO_PROXY); - - - new ThreadSleepForever(this, "Server Infinisleeper"); - } - - protected boolean init() - throws UnknownHostException - { - ThreadCommandReader threadcommandreader = new ThreadCommandReader(this, "Server console handler"); - - threadcommandreader.setDaemon(true); - threadcommandreader.start(); - - - java.util.logging.Logger global = java.util.logging.Logger.getLogger(""); - global.setUseParentHandlers(false); - for (Handler handler : global.getHandlers()) { - global.removeHandler(handler); - } - global.addHandler(new ForwardLogHandler()); - - org.apache.logging.log4j.core.Logger logger = (org.apache.logging.log4j.core.Logger)LogManager.getRootLogger(); - for (Appender appender : logger.getAppenders().values()) { - if ((appender instanceof ConsoleAppender)) { - logger.removeAppender(appender); - } - } - new Thread(new TerminalConsoleWriterThread(System.out, this.reader)).start(); - - System.setOut(new PrintStream(new LoggerOutputStream(logger, Level.INFO), true)); - System.setErr(new PrintStream(new LoggerOutputStream(logger, Level.WARN), true)); - - - logger.info("Starting minecraft server version 1.7.10"); - if (Runtime.getRuntime().maxMemory() / 1024L / 1024L < 512L) { - logger.warn("To start the server with more ram, launch it as \"java -Xmx1024M -Xms1024M -jar minecraft_server.jar\""); - } - logger.info("Loading properties"); - this.propertyManager = new PropertyManager(this.options); - - if (N()) - { - c("127.0.0.1"); - } - else - { - setOnlineMode(this.propertyManager.getBoolean("online-mode", true)); - c(this.propertyManager.getString("server-ip", "")); - } - setSpawnAnimals(this.propertyManager.getBoolean("spawn-animals", true)); - setSpawnNPCs(this.propertyManager.getBoolean("spawn-npcs", true)); - setPvP(this.propertyManager.getBoolean("pvp", true)); - setAllowFlight(this.propertyManager.getBoolean("allow-flight", false)); - setTexturePack(this.propertyManager.getString("resource-pack", "")); - setMotd(this.propertyManager.getString("motd", "A Minecraft Server")); - setForceGamemode(this.propertyManager.getBoolean("force-gamemode", false)); - 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()); - - this.p = WorldSettings.a(gamemode); - logger.info("Default game type: " + this.p); - InetAddress inetaddress = null; - if (getServerIp().length() > 0) { - inetaddress = InetAddress.getByName(getServerIp()); - } - if (L() < 0) { - setPort(this.propertyManager.getInt("server-port", 25565)); - } - a(new DedicatedPlayerList(this)); - SpigotConfig.init(); - SpigotConfig.registerCommands(); - - - logger.info("Generating keypair"); - a(MinecraftEncryption.b()); - logger.info("Starting Minecraft server on " + (getServerIp().length() == 0 ? "*" : getServerIp()) + ":" + L()); - if (!SpigotConfig.lateBind) { - try - { - ai().a(inetaddress, L()); - } - catch (Throwable ioexception) - { - logger.warn("**** FAILED TO BIND TO PORT!"); - logger.warn("The exception was: {}", new Object[] { ioexception.toString() }); - logger.warn("Perhaps a server is already running on that port?"); - return false; - } - } - this.server.loadPlugins(); - this.server.enablePlugins(PluginLoadOrder.STARTUP); - if (!getOnlineMode()) - { - logger.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!"); - logger.warn("The server will make no attempt to authenticate usernames. Beware."); - logger.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."); - logger.warn("To change this, set \"online-mode\" to \"true\" in the server.properties file."); - } - if (aE()) { - getUserCache().c(); - } - if (!NameReferencingFileConverter.a(this.propertyManager)) { - return false; - } - this.convertable = new WorldLoaderServer(this.server.getWorldContainer()); - long j = System.nanoTime(); - if (O() == null) { - 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 = s.hashCode(); - } - } - WorldType worldtype = WorldType.getType(s1); - if (worldtype == null) { - worldtype = WorldType.NORMAL; - } - at(); - getEnableCommandBlock(); - l(); - getSnooperEnabled(); - c(this.propertyManager.getInt("max-build-height", 256)); - c((getMaxBuildHeight() + 8) / 16 * 16); - c(MathHelper.a(getMaxBuildHeight(), 64, 256)); - this.propertyManager.setProperty("max-build-height", Integer.valueOf(getMaxBuildHeight())); - logger.info("Preparing level \"" + O() + "\""); - a(O(), O(), k, worldtype, s2); - long i1 = System.nanoTime() - j; - String s3 = String.format("%.3fs", new Object[] { Double.valueOf(i1 / 1000000000.0D) }); - - logger.info("Done (" + s3 + ")! For help, type \"help\" or \"?\""); - if (this.propertyManager.getBoolean("enable-query", false)) - { - logger.info("Starting GS4 status listener"); - this.k = new RemoteStatusListener(this); - this.k.a(); - } - if (this.propertyManager.getBoolean("enable-rcon", false)) - { - logger.info("Starting remote control listener"); - this.l = new RemoteControlListener(this); - this.l.a(); - this.remoteConsole = new CraftRemoteConsoleCommandSender(); - } - if (this.server.getBukkitSpawnRadius() > -1) - { - logger.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(); - } - if (SpigotConfig.lateBind) { - try - { - ai().a(inetaddress, L()); - } - catch (Throwable ioexception) - { - logger.warn("**** FAILED TO BIND TO PORT!"); - logger.warn("The exception was: {}", new Object[] { ioexception.toString() }); - logger.warn("Perhaps a server is already running on that port?"); - return false; - } - } - return true; - } - - public PropertyManager getPropertyManager() - { - return this.propertyManager; - } - - public boolean getGenerateStructures() - { - return this.generateStructures; - } - - public EnumGamemode getGamemode() - { - return this.p; - } - - public EnumDifficulty getDifficulty() - { - return EnumDifficulty.getById(this.propertyManager.getInt("difficulty", 1)); - } - - public boolean isHardcore() - { - return this.propertyManager.getBoolean("hardcore", false); - } - - protected void a(CrashReport crashreport) {} - - public CrashReport b(CrashReport crashreport) - { - crashreport = super.b(crashreport); - crashreport.g().a("Is Modded", new CrashReportModded(this)); - crashreport.g().a("Type", new CrashReportType(this)); - return crashreport; - } - - protected void t() - { - System.exit(0); - } - - public void v() - { - super.v(); - aB(); - } - - public boolean getAllowNether() - { - return this.propertyManager.getBoolean("allow-nether", true); - } - - public boolean getSpawnMonsters() - { - return this.propertyManager.getBoolean("spawn-monsters", true); - } - - public void a(MojangStatisticsGenerator mojangstatisticsgenerator) - { - mojangstatisticsgenerator.a("whitelist_enabled", Boolean.valueOf(aC().getHasWhitelist())); - mojangstatisticsgenerator.a("whitelist_count", Integer.valueOf(aC().getWhitelisted().length)); - super.a(mojangstatisticsgenerator); - } - - public boolean getSnooperEnabled() - { - return this.propertyManager.getBoolean("snooper-enabled", true); - } - - public void issueCommand(String s, ICommandListener icommandlistener) - { - this.j.add(new ServerCommand(s, icommandlistener)); - } - - public void aB() - { - SpigotTimings.serverCommandTimer.startTiming(); - while (!this.j.isEmpty()) - { - ServerCommand servercommand = (ServerCommand)this.j.remove(0); - - - ServerCommandEvent event = new ServerCommandEvent(this.console, servercommand.command); - this.server.getPluginManager().callEvent(event); - servercommand = new ServerCommand(event.getCommand(), servercommand.source); - - - this.server.dispatchServerCommand(this.console, servercommand); - } - SpigotTimings.serverCommandTimer.stopTiming(); - } - - public boolean X() - { - return true; - } - - public DedicatedPlayerList aC() - { - return (DedicatedPlayerList)super.getPlayerList(); - } - - public int a(String s, int i) - { - return this.propertyManager.getInt(s, i); - } - - public String a(String s, String s1) - { - return this.propertyManager.getString(s, s1); - } - - public boolean a(String s, boolean flag) - { - return this.propertyManager.getBoolean(s, flag); - } - - public void a(String s, Object object) - { - this.propertyManager.setProperty(s, object); - } - - public void a() - { - this.propertyManager.savePropertiesFile(); - } - - public String b() - { - File file1 = this.propertyManager.c(); - - return file1 != null ? file1.getAbsolutePath() : "No settings file"; - } - - public void aD() - { - ServerGUI.a(this); - this.q = true; - } - - public boolean ak() - { - return this.q; - } - - public String a(EnumGamemode enumgamemode, boolean flag) - { - return ""; - } - - public boolean getEnableCommandBlock() - { - return this.propertyManager.getBoolean("enable-command-block", false); - } - - public int getSpawnProtection() - { - return this.propertyManager.getInt("spawn-protection", super.getSpawnProtection()); - } - - public boolean a(World world, int i, int j, int k, EntityHuman entityhuman) - { - if (world.worldProvider.dimension != 0) { - return false; - } - if (aC().getOPs().isEmpty()) { - return false; - } - if (aC().isOp(entityhuman.getProfile())) { - return false; - } - if (getSpawnProtection() <= 0) { - return false; - } - ChunkCoordinates chunkcoordinates = world.getSpawn(); - int l = MathHelper.a(i - chunkcoordinates.x); - int i1 = MathHelper.a(k - chunkcoordinates.z); - int j1 = Math.max(l, i1); - - return j1 <= getSpawnProtection(); - } - - public int l() - { - return this.propertyManager.getInt("op-permission-level", 4); - } - - public void setIdleTimeout(int i) - { - super.setIdleTimeout(i); - this.propertyManager.setProperty("player-idle-timeout", Integer.valueOf(i)); - a(); - } - - public boolean m() - { - return this.propertyManager.getBoolean("broadcast-rcon-to-ops", true); - } - - public boolean at() - { - return this.propertyManager.getBoolean("announce-player-achievements", true); - } - - protected boolean aE() - { - this.server.getLogger().info("**** Beginning UUID conversion, this may take A LONG time ****"); - boolean flag = false; - for (int i = 0; (!flag) && (i <= 2); i++) - { - if (i > 0) - { - logger.warn("Encountered a problem while converting the user banlist, retrying in a few seconds"); - aG(); - } - flag = NameReferencingFileConverter.a(this); - } - boolean flag1 = false; - for (int i = 0; (!flag1) && (i <= 2); i++) - { - if (i > 0) - { - logger.warn("Encountered a problem while converting the ip banlist, retrying in a few seconds"); - aG(); - } - flag1 = NameReferencingFileConverter.b(this); - } - boolean flag2 = false; - for (int i = 0; (!flag2) && (i <= 2); i++) - { - if (i > 0) - { - logger.warn("Encountered a problem while converting the op list, retrying in a few seconds"); - aG(); - } - flag2 = NameReferencingFileConverter.c(this); - } - boolean flag3 = false; - for (int i = 0; (!flag3) && (i <= 2); i++) - { - if (i > 0) - { - logger.warn("Encountered a problem while converting the whitelist, retrying in a few seconds"); - aG(); - } - flag3 = NameReferencingFileConverter.d(this); - } - boolean flag4 = false; - for (int i = 0; (!flag4) && (i <= 2); i++) - { - if (i > 0) - { - logger.warn("Encountered a problem while converting the player save files, retrying in a few seconds"); - aG(); - } - flag4 = NameReferencingFileConverter.a(this, this.propertyManager); - } - return (flag) || (flag1) || (flag2) || (flag3) || (flag4); - } - - private void aG() - { - try - { - Thread.sleep(5000L); - } - catch (InterruptedException interruptedexception) {} - } - - public PlayerList getPlayerList() - { - return aC(); - } - - static org.apache.logging.log4j.Logger aF() - { - return logger; - } -} diff --git a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/Entity.java b/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/Entity.java deleted file mode 100644 index bfcef9b0f..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/Entity.java +++ /dev/null @@ -1,1933 +0,0 @@ -package net.minecraft.server.v1_7_R4; - -import java.util.List; -import java.util.Random; -import java.util.UUID; -import java.util.concurrent.Callable; - -// CraftBukkit start -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Server; -import org.bukkit.TravelAgent; -import org.bukkit.block.BlockFace; -import org.bukkit.entity.Hanging; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Painting; -import org.bukkit.entity.Vehicle; -import org.spigotmc.CustomTimingsHandler; // Spigot -import org.bukkit.event.entity.EntityCombustByEntityEvent; -import org.bukkit.event.hanging.HangingBreakByEntityEvent; -import org.bukkit.event.painting.PaintingBreakByEntityEvent; -import org.bukkit.event.vehicle.VehicleBlockCollisionEvent; -import org.bukkit.event.vehicle.VehicleEnterEvent; -import org.bukkit.event.vehicle.VehicleExitEvent; -import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; -import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; -import org.bukkit.craftbukkit.v1_7_R4.event.CraftEventFactory; -import org.bukkit.event.entity.EntityCombustEvent; -import org.bukkit.event.entity.EntityPortalEvent; -import org.bukkit.plugin.PluginManager; -// CraftBukkit end - -public abstract class Entity { - - // CraftBukkit start - private static final int CURRENT_LEVEL = 2; - static boolean isLevelAtLeast(NBTTagCompound tag, int level) { - return tag.hasKey("Bukkit.updateLevel") && tag.getInt("Bukkit.updateLevel") >= level; - } - // CraftBukkit end - - private static int entityCount; - private int id; - public double j; - public boolean k; - public Entity passenger; - public Entity vehicle; - public boolean attachedToPlayer; - public World world; - public double lastX; - public double lastY; - public double lastZ; - public double locX; - public double locY; - public double locZ; - public double motX; - public double motY; - public double motZ; - public float yaw; - public float pitch; - public float lastYaw; - public float lastPitch; - public final AxisAlignedBB boundingBox; - public boolean onGround; - public boolean positionChanged; - public boolean F; - public boolean G; - public boolean velocityChanged; - protected boolean I; - public boolean J; - public boolean dead; - public float height; - public float width; - public float length; - public float O; - public float P; - public float Q; - public float fallDistance; - private int d; - public double S; - public double T; - public double U; - public float V; - public float W; - public boolean X; - public float Y; - public float Z; - protected Random random; - public int ticksLived; - public int maxFireTicks; - public int fireTicks; // CraftBukkit - private -> public - public boolean inWater; // Spigot - protected -> public - public int noDamageTicks; - private boolean justCreated; - protected boolean fireProof; - protected DataWatcher datawatcher; - private double g; - private double h; - public boolean ag; - public int ah; - public int ai; - public int aj; - public boolean ak; - public boolean al; - public int portalCooldown; - protected boolean an; - protected int ao; - public int dimension; - protected int aq; - private boolean invulnerable; - public UUID uniqueID; // CraftBukkit - protected -> public - public EnumEntitySize as; - public boolean valid; // CraftBukkit - public org.bukkit.projectiles.ProjectileSource projectileSource; // CraftBukkit - For projectiles only - - // Spigot start - public CustomTimingsHandler tickTimer = org.bukkit.craftbukkit.v1_7_R4.SpigotTimings.getEntityTimings(this); // Spigot - public final byte activationType = org.spigotmc.ActivationRange.initializeEntityActivationType(this); - public final boolean defaultActivationState; - public long activatedTick = 0; - public boolean fromMobSpawner; - public void inactiveTick() { } - // Spigot end - - public boolean Silent; - public boolean Invisible; - - public int getId() { - return this.id; - } - - public void d(int i) { - this.id = i; - } - - public Entity(World world) { - this.id = entityCount++; - this.j = 1.0D; - this.boundingBox = AxisAlignedBB.a(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D); - this.J = true; - this.width = 0.6F; - this.length = 1.8F; - this.d = 1; - this.random = new Random(); - this.maxFireTicks = 1; - this.justCreated = true; - this.uniqueID = new UUID(random.nextLong(), random.nextLong()); // Spigot - this.as = EnumEntitySize.SIZE_2; - this.world = world; - this.setPosition(0.0D, 0.0D, 0.0D); - if (world != null) { - this.dimension = world.worldProvider.dimension; - // Spigot start - this.defaultActivationState = org.spigotmc.ActivationRange.initializeEntityActivationState(this, world.spigotConfig); - } else { - this.defaultActivationState = false; - } - // Spigot end - - this.datawatcher = new DataWatcher(this); - this.datawatcher.a(0, Byte.valueOf((byte) 0)); - this.datawatcher.a(1, Short.valueOf((short) 300)); - this.c(); - } - - protected abstract void c(); - - public DataWatcher getDataWatcher() { - return this.datawatcher; - } - - public boolean equals(Object object) { - return object instanceof Entity ? ((Entity) object).id == this.id : false; - } - - public int hashCode() { - return this.id; - } - - public void die() { - this.dead = true; - } - - protected void a(float f, float f1) { - float f2; - - if (f != this.width || f1 != this.length) { - f2 = this.width; - this.width = f; - this.length = f1; - this.boundingBox.d = this.boundingBox.a + (double) this.width; - this.boundingBox.f = this.boundingBox.c + (double) this.width; - this.boundingBox.e = this.boundingBox.b + (double) this.length; - if (this.width > f2 && !this.justCreated && !this.world.isStatic) { - this.move((double) (f2 - this.width), 0.0D, (double) (f2 - this.width)); - } - } - - f2 = f % 2.0F; - if ((double) f2 < 0.375D) { - this.as = EnumEntitySize.SIZE_1; - } else if ((double) f2 < 0.75D) { - this.as = EnumEntitySize.SIZE_2; - } else if ((double) f2 < 1.0D) { - this.as = EnumEntitySize.SIZE_3; - } else if ((double) f2 < 1.375D) { - this.as = EnumEntitySize.SIZE_4; - } else if ((double) f2 < 1.75D) { - this.as = EnumEntitySize.SIZE_5; - } else { - this.as = EnumEntitySize.SIZE_6; - } - } - - protected void b(float f, float f1) { - // CraftBukkit start - yaw was sometimes set to NaN, so we need to set it back to 0 - if (Float.isNaN(f)) { - f = 0; - } - - if ((f == Float.POSITIVE_INFINITY) || (f == Float.NEGATIVE_INFINITY)) { - if (this instanceof EntityPlayer) { - this.world.getServer().getLogger().warning(((CraftPlayer) this.getBukkitEntity()).getName() + " was caught trying to crash the server with an invalid yaw"); - ((CraftPlayer) this.getBukkitEntity()).kickPlayer("Infinite yaw (Hacking?)"); //Spigot "Nope" -> Descriptive reason - } - f = 0; - } - - // pitch was sometimes set to NaN, so we need to set it back to 0. - if (Float.isNaN(f1)) { - f1 = 0; - } - - if ((f1 == Float.POSITIVE_INFINITY) || (f1 == Float.NEGATIVE_INFINITY)) { - if (this instanceof EntityPlayer) { - this.world.getServer().getLogger().warning(((CraftPlayer) this.getBukkitEntity()).getName() + " was caught trying to crash the server with an invalid pitch"); - ((CraftPlayer) this.getBukkitEntity()).kickPlayer("Infinite pitch (Hacking?)"); //Spigot "Nope" -> Descriptive reason - } - f1 = 0; - } - // CraftBukkit end - - this.yaw = f % 360.0F; - this.pitch = f1 % 360.0F; - } - - public void setPosition(double d0, double d1, double d2) { - this.locX = d0; - this.locY = d1; - this.locZ = d2; - float f = this.width / 2.0F; - float f1 = this.length; - - this.boundingBox.b(d0 - (double) f, d1 - (double) this.height + (double) this.V, d2 - (double) f, d0 + (double) f, d1 - (double) this.height + (double) this.V + (double) f1, d2 + (double) f); - } - - public void h() { - this.C(); - } - - public void C() { - this.world.methodProfiler.a("entityBaseTick"); - if (this.vehicle != null && this.vehicle.dead) { - this.vehicle = null; - } - - this.O = this.P; - this.lastX = this.locX; - this.lastY = this.locY; - this.lastZ = this.locZ; - this.lastPitch = this.pitch; - this.lastYaw = this.yaw; - int i; - - if (!this.world.isStatic && this.world instanceof WorldServer) { - this.world.methodProfiler.a("portal"); - MinecraftServer minecraftserver = ((WorldServer) this.world).getMinecraftServer(); - - i = this.D(); - if (this.an) { - if (true || minecraftserver.getAllowNether()) { // CraftBukkit - if (this.vehicle == null && this.ao++ >= i) { - this.ao = i; - this.portalCooldown = this.ai(); - byte b0; - - if (this.world.worldProvider.dimension == -1) { - b0 = 0; - } else { - b0 = -1; - } - - this.b(b0); - } - - this.an = false; - } - } else { - if (this.ao > 0) { - this.ao -= 4; - } - - if (this.ao < 0) { - this.ao = 0; - } - } - - if (this.portalCooldown > 0) { - --this.portalCooldown; - } - - this.world.methodProfiler.b(); - } - - if (this.isSprinting() && !this.M()) { - int j = MathHelper.floor(this.locX); - - i = MathHelper.floor(this.locY - 0.20000000298023224D - (double) this.height); - int k = MathHelper.floor(this.locZ); - Block block = this.world.getType(j, i, k); - - if (block.getMaterial() != Material.AIR) { - this.world.addParticle("blockcrack_" + Block.getId(block) + "_" + this.world.getData(j, i, k), this.locX + ((double) this.random.nextFloat() - 0.5D) * (double) this.width, this.boundingBox.b + 0.1D, this.locZ + ((double) this.random.nextFloat() - 0.5D) * (double) this.width, -this.motX * 4.0D, 1.5D, -this.motZ * 4.0D); - } - } - - this.N(); - if (this.world.isStatic) { - this.fireTicks = 0; - } else if (this.fireTicks > 0) { - if (this.fireProof) { - this.fireTicks -= 4; - if (this.fireTicks < 0) { - this.fireTicks = 0; - } - } else { - if (this.fireTicks % 20 == 0) { - this.damageEntity(DamageSource.BURN, 1.0F); - } - - --this.fireTicks; - } - } - - if (this.P()) { - this.E(); - this.fallDistance *= 0.5F; - } - - if (this.locY < -64.0D) { - this.G(); - } - - if (!this.world.isStatic) { - this.a(0, this.fireTicks > 0); - } - - this.justCreated = false; - this.world.methodProfiler.b(); - } - - public int D() { - return 0; - } - - protected void E() { - if (!this.fireProof) { - this.damageEntity(DamageSource.LAVA, 4); - - // CraftBukkit start - Fallen in lava TODO: this event spams! - if (this instanceof EntityLiving) { - if (this.fireTicks <= 0) { - // not on fire yet - // TODO: shouldn't be sending null for the block. - org.bukkit.block.Block damager = null; // ((WorldServer) this.l).getWorld().getBlockAt(i, j, k); - org.bukkit.entity.Entity damagee = this.getBukkitEntity(); - EntityCombustEvent combustEvent = new org.bukkit.event.entity.EntityCombustByBlockEvent(damager, damagee, 15); - this.world.getServer().getPluginManager().callEvent(combustEvent); - - if (!combustEvent.isCancelled()) { - this.setOnFire(combustEvent.getDuration()); - } - } else { - // This will be called every single tick the entity is in lava, so don't throw an event - this.setOnFire(15); - } - return; - } - // CraftBukkit end - we also don't throw an event unless the object in lava is living, to save on some event calls - - this.setOnFire(15); - } - } - - public void setOnFire(int i) { - int j = i * 20; - - j = EnchantmentProtection.a(this, j); - if (this.fireTicks < j) { - this.fireTicks = j; - } - } - - public void extinguish() { - this.fireTicks = 0; - } - - protected void G() { - this.die(); - } - - public boolean c(double d0, double d1, double d2) { - AxisAlignedBB axisalignedbb = this.boundingBox.c(d0, d1, d2); - List list = this.world.getCubes(this, axisalignedbb); - - return !list.isEmpty() ? false : !this.world.containsLiquid(axisalignedbb); - } - - public void move(double d0, double d1, double d2) { - // CraftBukkit start - Don't do anything if we aren't moving - // We need to do this regardless of whether or not we are moving thanks to portals - try { - this.I(); - } catch (Throwable throwable) { - CrashReport crashreport = CrashReport.a(throwable, "Checking entity block collision"); - CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being checked for collision"); - - this.a(crashreportsystemdetails); - throw new ReportedException(crashreport); - } - // Check if we're moving - if (d0 == 0 && d1 == 0 && d2 == 0 && this.vehicle == null && this.passenger == null) { - return; - } - // CraftBukkit end - org.bukkit.craftbukkit.v1_7_R4.SpigotTimings.entityMoveTimer.startTiming(); // Spigot - if (this.X) { - this.boundingBox.d(d0, d1, d2); - this.locX = (this.boundingBox.a + this.boundingBox.d) / 2.0D; - this.locY = this.boundingBox.b + (double) this.height - (double) this.V; - this.locZ = (this.boundingBox.c + this.boundingBox.f) / 2.0D; - } else { - this.world.methodProfiler.a("move"); - this.V *= 0.4F; - double d3 = this.locX; - double d4 = this.locY; - double d5 = this.locZ; - - if (this.I) { - this.I = false; - d0 *= 0.25D; - d1 *= 0.05000000074505806D; - d2 *= 0.25D; - this.motX = 0.0D; - this.motY = 0.0D; - this.motZ = 0.0D; - } - - double d6 = d0; - double d7 = d1; - double d8 = d2; - AxisAlignedBB axisalignedbb = this.boundingBox.clone(); - boolean flag = this.onGround && this.isSneaking() && this instanceof EntityHuman; - - if (flag) { - double d9; - - for (d9 = 0.05D; d0 != 0.0D && this.world.getCubes(this, this.boundingBox.c(d0, -1.0D, 0.0D)).isEmpty(); d6 = d0) { - if (d0 < d9 && d0 >= -d9) { - d0 = 0.0D; - } else if (d0 > 0.0D) { - d0 -= d9; - } else { - d0 += d9; - } - } - - for (; d2 != 0.0D && this.world.getCubes(this, this.boundingBox.c(0.0D, -1.0D, d2)).isEmpty(); d8 = d2) { - if (d2 < d9 && d2 >= -d9) { - d2 = 0.0D; - } else if (d2 > 0.0D) { - d2 -= d9; - } else { - d2 += d9; - } - } - - while (d0 != 0.0D && d2 != 0.0D && this.world.getCubes(this, this.boundingBox.c(d0, -1.0D, d2)).isEmpty()) { - if (d0 < d9 && d0 >= -d9) { - d0 = 0.0D; - } else if (d0 > 0.0D) { - d0 -= d9; - } else { - d0 += d9; - } - - if (d2 < d9 && d2 >= -d9) { - d2 = 0.0D; - } else if (d2 > 0.0D) { - d2 -= d9; - } else { - d2 += d9; - } - - d6 = d0; - d8 = d2; - } - } - - List list = this.world.getCubes(this, this.boundingBox.a(d0, d1, d2)); - - for (int i = 0; i < list.size(); ++i) { - d1 = ((AxisAlignedBB) list.get(i)).b(this.boundingBox, d1); - } - - this.boundingBox.d(0.0D, d1, 0.0D); - if (!this.J && d7 != d1) { - d2 = 0.0D; - d1 = 0.0D; - d0 = 0.0D; - } - - boolean flag1 = this.onGround || d7 != d1 && d7 < 0.0D; - - int j; - - for (j = 0; j < list.size(); ++j) { - d0 = ((AxisAlignedBB) list.get(j)).a(this.boundingBox, d0); - } - - this.boundingBox.d(d0, 0.0D, 0.0D); - if (!this.J && d6 != d0) { - d2 = 0.0D; - d1 = 0.0D; - d0 = 0.0D; - } - - for (j = 0; j < list.size(); ++j) { - d2 = ((AxisAlignedBB) list.get(j)).c(this.boundingBox, d2); - } - - this.boundingBox.d(0.0D, 0.0D, d2); - if (!this.J && d8 != d2) { - d2 = 0.0D; - d1 = 0.0D; - d0 = 0.0D; - } - - double d10; - double d11; - double d12; - int k; - - if (this.W > 0.0F && flag1 && (flag || this.V < 0.05F) && (d6 != d0 || d8 != d2)) { - d10 = d0; - d11 = d1; - d12 = d2; - d0 = d6; - d1 = (double) this.W; - d2 = d8; - AxisAlignedBB axisalignedbb1 = this.boundingBox.clone(); - - this.boundingBox.d(axisalignedbb); - list = this.world.getCubes(this, this.boundingBox.a(d6, d1, d8)); - - for (k = 0; k < list.size(); ++k) { - d1 = ((AxisAlignedBB) list.get(k)).b(this.boundingBox, d1); - } - - this.boundingBox.d(0.0D, d1, 0.0D); - if (!this.J && d7 != d1) { - d2 = 0.0D; - d1 = 0.0D; - d0 = 0.0D; - } - - for (k = 0; k < list.size(); ++k) { - d0 = ((AxisAlignedBB) list.get(k)).a(this.boundingBox, d0); - } - - this.boundingBox.d(d0, 0.0D, 0.0D); - if (!this.J && d6 != d0) { - d2 = 0.0D; - d1 = 0.0D; - d0 = 0.0D; - } - - for (k = 0; k < list.size(); ++k) { - d2 = ((AxisAlignedBB) list.get(k)).c(this.boundingBox, d2); - } - - this.boundingBox.d(0.0D, 0.0D, d2); - if (!this.J && d8 != d2) { - d2 = 0.0D; - d1 = 0.0D; - d0 = 0.0D; - } - - if (!this.J && d7 != d1) { - d2 = 0.0D; - d1 = 0.0D; - d0 = 0.0D; - } else { - d1 = (double) (-this.W); - - for (k = 0; k < list.size(); ++k) { - d1 = ((AxisAlignedBB) list.get(k)).b(this.boundingBox, d1); - } - - this.boundingBox.d(0.0D, d1, 0.0D); - } - - if (d10 * d10 + d12 * d12 >= d0 * d0 + d2 * d2) { - d0 = d10; - d1 = d11; - d2 = d12; - this.boundingBox.d(axisalignedbb1); - } - } - - this.world.methodProfiler.b(); - this.world.methodProfiler.a("rest"); - this.locX = (this.boundingBox.a + this.boundingBox.d) / 2.0D; - this.locY = this.boundingBox.b + (double) this.height - (double) this.V; - this.locZ = (this.boundingBox.c + this.boundingBox.f) / 2.0D; - this.positionChanged = d6 != d0 || d8 != d2; - this.F = d7 != d1; - this.onGround = d7 != d1 && d7 < 0.0D; - this.G = this.positionChanged || this.F; - this.a(d1, this.onGround); - if (d6 != d0) { - this.motX = 0.0D; - } - - if (d7 != d1) { - this.motY = 0.0D; - } - - if (d8 != d2) { - this.motZ = 0.0D; - } - - d10 = this.locX - d3; - d11 = this.locY - d4; - d12 = this.locZ - d5; - - // CraftBukkit start - if ((this.positionChanged) && (this.getBukkitEntity() instanceof Vehicle)) { - Vehicle vehicle = (Vehicle) this.getBukkitEntity(); - org.bukkit.block.Block block = this.world.getWorld().getBlockAt(MathHelper.floor(this.locX), MathHelper.floor(this.locY - (double) this.height), MathHelper.floor(this.locZ)); - - if (d6 > d0) { - block = block.getRelative(BlockFace.EAST); - } else if (d6 < d0) { - block = block.getRelative(BlockFace.WEST); - } else if (d8 > d2) { - block = block.getRelative(BlockFace.SOUTH); - } else if (d8 < d2) { - block = block.getRelative(BlockFace.NORTH); - } - - VehicleBlockCollisionEvent event = new VehicleBlockCollisionEvent(vehicle, block); - this.world.getServer().getPluginManager().callEvent(event); - } - // CraftBukkit end - - if (this.g_() && !flag && this.vehicle == null) { - int l = MathHelper.floor(this.locX); - - k = MathHelper.floor(this.locY - 0.20000000298023224D - (double) this.height); - int i1 = MathHelper.floor(this.locZ); - Block block = this.world.getType(l, k, i1); - int j1 = this.world.getType(l, k - 1, i1).b(); - - if (j1 == 11 || j1 == 32 || j1 == 21) { - block = this.world.getType(l, k - 1, i1); - } - - if (block != Blocks.LADDER) { - d11 = 0.0D; - } - - this.P = (float) ((double) this.P + (double) MathHelper.sqrt(d10 * d10 + d12 * d12) * 0.6D); - this.Q = (float) ((double) this.Q + (double) MathHelper.sqrt(d10 * d10 + d11 * d11 + d12 * d12) * 0.6D); - if (this.Q > (float) this.d && block.getMaterial() != Material.AIR) { - this.d = (int) this.Q + 1; - if (this.M()) { - float f = MathHelper.sqrt(this.motX * this.motX * 0.20000000298023224D + this.motY * this.motY + this.motZ * this.motZ * 0.20000000298023224D) * 0.35F; - - if (f > 1.0F) { - f = 1.0F; - } - - this.makeSound(this.H(), f, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F); - } - - if (!Silent) - this.a(l, k, i1, block); - block.b(this.world, l, k, i1, this); - } - } - - // CraftBukkit start - Move to the top of the method - /* - try { - this.I(); - } catch (Throwable throwable) { - CrashReport crashreport = CrashReport.a(throwable, "Checking entity block collision"); - CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being checked for collision"); - - this.a(crashreportsystemdetails); - throw new ReportedException(crashreport); - } - */ - // CraftBukkit end - boolean flag2 = this.L(); - - if (this.world.e(this.boundingBox.shrink(0.001D, 0.001D, 0.001D))) { - this.burn(1); - if (!flag2) { - ++this.fireTicks; - // CraftBukkit start - Not on fire yet - if (this.fireTicks <= 0) { // Only throw events on the first combust, otherwise it spams - EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity(), 8); - this.world.getServer().getPluginManager().callEvent(event); - - if (!event.isCancelled()) { - this.setOnFire(event.getDuration()); - } - } else { - // CraftBukkit end - this.setOnFire(8); - } - } - } else if (this.fireTicks <= 0) { - this.fireTicks = -this.maxFireTicks; - } - - if (flag2 && this.fireTicks > 0) { - this.makeSound("random.fizz", 0.7F, 1.6F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F); - this.fireTicks = -this.maxFireTicks; - } - - this.world.methodProfiler.b(); - } - org.bukkit.craftbukkit.v1_7_R4.SpigotTimings.entityMoveTimer.stopTiming(); // Spigot - } - - protected String H() { - return "game.neutral.swim"; - } - - protected void I() { - int i = MathHelper.floor(this.boundingBox.a + 0.001D); - int j = MathHelper.floor(this.boundingBox.b + 0.001D); - int k = MathHelper.floor(this.boundingBox.c + 0.001D); - int l = MathHelper.floor(this.boundingBox.d - 0.001D); - int i1 = MathHelper.floor(this.boundingBox.e - 0.001D); - int j1 = MathHelper.floor(this.boundingBox.f - 0.001D); - - if (this.world.b(i, j, k, l, i1, j1)) { - for (int k1 = i; k1 <= l; ++k1) { - for (int l1 = j; l1 <= i1; ++l1) { - for (int i2 = k; i2 <= j1; ++i2) { - Block block = this.world.getType(k1, l1, i2); - - try { - block.a(this.world, k1, l1, i2, this); - } catch (Throwable throwable) { - CrashReport crashreport = CrashReport.a(throwable, "Colliding entity with block"); - CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Block being collided with"); - - CrashReportSystemDetails.a(crashreportsystemdetails, k1, l1, i2, block, this.world.getData(k1, l1, i2)); - throw new ReportedException(crashreport); - } - } - } - } - } - } - - protected void a(int i, int j, int k, Block block) { - StepSound stepsound = block.stepSound; - - if (this.world.getType(i, j + 1, k) == Blocks.SNOW) { - stepsound = Blocks.SNOW.stepSound; - this.makeSound(stepsound.getStepSound(), stepsound.getVolume1() * 0.15F, stepsound.getVolume2()); - } else if (!block.getMaterial().isLiquid()) { - this.makeSound(stepsound.getStepSound(), stepsound.getVolume1() * 0.15F, stepsound.getVolume2()); - } - } - - public void makeSound(String s, float f, float f1) { - if (!Silent) - this.world.makeSound(this, s, f, f1); - } - - protected boolean g_() { - return true; - } - - protected void a(double d0, boolean flag) { - if (flag) { - if (this.fallDistance > 0.0F) { - this.b(this.fallDistance); - this.fallDistance = 0.0F; - } - } else if (d0 < 0.0D) { - this.fallDistance = (float) ((double) this.fallDistance - d0); - } - } - - public AxisAlignedBB J() { - return null; - } - - protected void burn(float i) { // CraftBukkit - int -> float - if (!this.fireProof) { - this.damageEntity(DamageSource.FIRE, (float) i); - } - } - - public final boolean isFireproof() { - return this.fireProof; - } - - protected void b(float f) { - if (this.passenger != null) { - this.passenger.b(f); - } - } - - public boolean L() { - return this.inWater || this.world.isRainingAt(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)) || this.world.isRainingAt(MathHelper.floor(this.locX), MathHelper.floor(this.locY + (double) this.length), MathHelper.floor(this.locZ)); - } - - public boolean M() { - return this.inWater; - } - - public boolean N() { - if (this.world.a(this.boundingBox.grow(0.0D, -0.4000000059604645D, 0.0D).shrink(0.001D, 0.001D, 0.001D), Material.WATER, this)) { - if (!this.inWater && !this.justCreated) { - float f = MathHelper.sqrt(this.motX * this.motX * 0.20000000298023224D + this.motY * this.motY + this.motZ * this.motZ * 0.20000000298023224D) * 0.2F; - - if (f > 1.0F) { - f = 1.0F; - } - - this.makeSound(this.O(), f, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F); - float f1 = (float) MathHelper.floor(this.boundingBox.b); - - int i; - float f2; - float f3; - - for (i = 0; (float) i < 1.0F + this.width * 20.0F; ++i) { - f2 = (this.random.nextFloat() * 2.0F - 1.0F) * this.width; - f3 = (this.random.nextFloat() * 2.0F - 1.0F) * this.width; - this.world.addParticle("bubble", this.locX + (double) f2, (double) (f1 + 1.0F), this.locZ + (double) f3, this.motX, this.motY - (double) (this.random.nextFloat() * 0.2F), this.motZ); - } - - for (i = 0; (float) i < 1.0F + this.width * 20.0F; ++i) { - f2 = (this.random.nextFloat() * 2.0F - 1.0F) * this.width; - f3 = (this.random.nextFloat() * 2.0F - 1.0F) * this.width; - this.world.addParticle("splash", this.locX + (double) f2, (double) (f1 + 1.0F), this.locZ + (double) f3, this.motX, this.motY, this.motZ); - } - } - - this.fallDistance = 0.0F; - this.inWater = true; - this.fireTicks = 0; - } else { - this.inWater = false; - } - - return this.inWater; - } - - protected String O() { - return "game.neutral.swim.splash"; - } - - public boolean a(Material material) { - double d0 = this.locY + (double) this.getHeadHeight(); - int i = MathHelper.floor(this.locX); - int j = MathHelper.d((float) MathHelper.floor(d0)); - int k = MathHelper.floor(this.locZ); - Block block = this.world.getType(i, j, k); - - if (block.getMaterial() == material) { - float f = BlockFluids.b(this.world.getData(i, j, k)) - 0.11111111F; - float f1 = (float) (j + 1) - f; - - return d0 < (double) f1; - } else { - return false; - } - } - - public float getHeadHeight() { - return 0.0F; - } - - public boolean P() { - return this.world.a(this.boundingBox.grow(-0.10000000149011612D, -0.4000000059604645D, -0.10000000149011612D), Material.LAVA); - } - - public void a(float f, float f1, float f2) { - float f3 = f * f + f1 * f1; - - if (f3 >= 1.0E-4F) { - f3 = MathHelper.c(f3); - if (f3 < 1.0F) { - f3 = 1.0F; - } - - f3 = f2 / f3; - f *= f3; - f1 *= f3; - float f4 = MathHelper.sin(this.yaw * 3.1415927F / 180.0F); - float f5 = MathHelper.cos(this.yaw * 3.1415927F / 180.0F); - - this.motX += (double) (f * f5 - f1 * f4); - this.motZ += (double) (f1 * f5 + f * f4); - } - } - - public float d(float f) { - int i = MathHelper.floor(this.locX); - int j = MathHelper.floor(this.locZ); - - if (this.world.isLoaded(i, 0, j)) { - double d0 = (this.boundingBox.e - this.boundingBox.b) * 0.66D; - int k = MathHelper.floor(this.locY - (double) this.height + d0); - - return this.world.n(i, k, j); - } else { - return 0.0F; - } - } - - public void spawnIn(World world) { - // CraftBukkit start - if (world == null) { - this.die(); - this.world = ((CraftWorld) Bukkit.getServer().getWorlds().get(0)).getHandle(); - return; - } - // CraftBukkit end - - this.world = world; - } - - public void setLocation(double d0, double d1, double d2, float f, float f1) { - this.lastX = this.locX = d0; - this.lastY = this.locY = d1; - this.lastZ = this.locZ = d2; - this.lastYaw = this.yaw = f; - this.lastPitch = this.pitch = f1; - this.V = 0.0F; - double d3 = (double) (this.lastYaw - f); - - if (d3 < -180.0D) { - this.lastYaw += 360.0F; - } - - if (d3 >= 180.0D) { - this.lastYaw -= 360.0F; - } - - this.setPosition(this.locX, this.locY, this.locZ); - this.b(f, f1); - } - - public void setPositionRotation(double d0, double d1, double d2, float f, float f1) { - this.S = this.lastX = this.locX = d0; - this.T = this.lastY = this.locY = d1 + (double) this.height; - this.U = this.lastZ = this.locZ = d2; - this.yaw = f; - this.pitch = f1; - this.setPosition(this.locX, this.locY, this.locZ); - } - - public float e(Entity entity) { - float f = (float) (this.locX - entity.locX); - float f1 = (float) (this.locY - entity.locY); - float f2 = (float) (this.locZ - entity.locZ); - - return MathHelper.c(f * f + f1 * f1 + f2 * f2); - } - - public double e(double d0, double d1, double d2) { - double d3 = this.locX - d0; - double d4 = this.locY - d1; - double d5 = this.locZ - d2; - - return d3 * d3 + d4 * d4 + d5 * d5; - } - - public double f(double d0, double d1, double d2) { - double d3 = this.locX - d0; - double d4 = this.locY - d1; - double d5 = this.locZ - d2; - - return (double) MathHelper.sqrt(d3 * d3 + d4 * d4 + d5 * d5); - } - - public double f(Entity entity) { - double d0 = this.locX - entity.locX; - double d1 = this.locY - entity.locY; - double d2 = this.locZ - entity.locZ; - - return d0 * d0 + d1 * d1 + d2 * d2; - } - - public void b_(EntityHuman entityhuman) {} - - int numCollisions = 0; // Spigot - public void collide(Entity entity) { - if (entity.passenger != this && entity.vehicle != this) { - double d0 = entity.locX - this.locX; - double d1 = entity.locZ - this.locZ; - double d2 = MathHelper.a(d0, d1); - - if (d2 >= 0.009999999776482582D) { - d2 = (double) MathHelper.sqrt(d2); - d0 /= d2; - d1 /= d2; - double d3 = 1.0D / d2; - - if (d3 > 1.0D) { - d3 = 1.0D; - } - - d0 *= d3; - d1 *= d3; - d0 *= 0.05000000074505806D; - d1 *= 0.05000000074505806D; - d0 *= (double) (1.0F - this.Y); - d1 *= (double) (1.0F - this.Y); - this.g(-d0, 0.0D, -d1); - entity.g(d0, 0.0D, d1); - } - } - } - - public void g(double d0, double d1, double d2) { - this.motX += d0; - this.motY += d1; - this.motZ += d2; - this.al = true; - } - - protected void Q() { - this.velocityChanged = true; - } - - public boolean damageEntity(DamageSource damagesource, float f) { - if (this.isInvulnerable()) { - return false; - } else { - this.Q(); - return false; - } - } - - public boolean R() { - return false; - } - - public boolean S() { - return false; - } - - public void b(Entity entity, int i) {} - - public boolean c(NBTTagCompound nbttagcompound) { - String s = this.W(); - - if (!this.dead && s != null) { - nbttagcompound.setString("id", s); - this.e(nbttagcompound); - return true; - } else { - return false; - } - } - - public boolean d(NBTTagCompound nbttagcompound) { - String s = this.W(); - - if (!this.dead && s != null && this.passenger == null) { - nbttagcompound.setString("id", s); - this.e(nbttagcompound); - return true; - } else { - return false; - } - } - - public void e(NBTTagCompound nbttagcompound) { - try { - nbttagcompound.set("Pos", this.a(new double[] { this.locX, this.locY + (double) this.V, this.locZ})); - nbttagcompound.set("Motion", this.a(new double[] { this.motX, this.motY, this.motZ})); - - // CraftBukkit start - Checking for NaN pitch/yaw and resetting to zero - // TODO: make sure this is the best way to address this. - if (Float.isNaN(this.yaw)) { - this.yaw = 0; - } - - if (Float.isNaN(this.pitch)) { - this.pitch = 0; - } - // CraftBukkit end - - nbttagcompound.set("Rotation", this.a(new float[] { this.yaw, this.pitch})); - nbttagcompound.setFloat("FallDistance", this.fallDistance); - nbttagcompound.setShort("Fire", (short) this.fireTicks); - nbttagcompound.setShort("Air", (short) this.getAirTicks()); - nbttagcompound.setBoolean("OnGround", this.onGround); - nbttagcompound.setInt("Dimension", this.dimension); - nbttagcompound.setBoolean("Invulnerable", this.invulnerable); - nbttagcompound.setInt("PortalCooldown", this.portalCooldown); - nbttagcompound.setLong("UUIDMost", this.getUniqueID().getMostSignificantBits()); - nbttagcompound.setLong("UUIDLeast", this.getUniqueID().getLeastSignificantBits()); - // CraftBukkit start - nbttagcompound.setLong("WorldUUIDLeast", this.world.getDataManager().getUUID().getLeastSignificantBits()); - nbttagcompound.setLong("WorldUUIDMost", this.world.getDataManager().getUUID().getMostSignificantBits()); - nbttagcompound.setInt("Bukkit.updateLevel", CURRENT_LEVEL); - nbttagcompound.setInt("Spigot.ticksLived", this.ticksLived); - // CraftBukkit end - this.b(nbttagcompound); - if (this.vehicle != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - - if (this.vehicle.c(nbttagcompound1)) { - nbttagcompound.set("Riding", nbttagcompound1); - } - } - } catch (Throwable throwable) { - CrashReport crashreport = CrashReport.a(throwable, "Saving entity NBT"); - CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being saved"); - - this.a(crashreportsystemdetails); - throw new ReportedException(crashreport); - } - } - - public void f(NBTTagCompound nbttagcompound) { - try { - NBTTagList nbttaglist = nbttagcompound.getList("Pos", 6); - NBTTagList nbttaglist1 = nbttagcompound.getList("Motion", 6); - NBTTagList nbttaglist2 = nbttagcompound.getList("Rotation", 5); - - this.motX = nbttaglist1.d(0); - this.motY = nbttaglist1.d(1); - this.motZ = nbttaglist1.d(2); - /* CraftBukkit start - Moved section down - if (Math.abs(this.motX) > 10.0D) { - this.motX = 0.0D; - } - - if (Math.abs(this.motY) > 10.0D) { - this.motY = 0.0D; - } - - if (Math.abs(this.motZ) > 10.0D) { - this.motZ = 0.0D; - } - // CraftBukkit end */ - - this.lastX = this.S = this.locX = nbttaglist.d(0); - this.lastY = this.T = this.locY = nbttaglist.d(1); - this.lastZ = this.U = this.locZ = nbttaglist.d(2); - this.lastYaw = this.yaw = nbttaglist2.e(0); - this.lastPitch = this.pitch = nbttaglist2.e(1); - this.fallDistance = nbttagcompound.getFloat("FallDistance"); - this.fireTicks = nbttagcompound.getShort("Fire"); - this.setAirTicks(nbttagcompound.getShort("Air")); - this.onGround = nbttagcompound.getBoolean("OnGround"); - this.dimension = nbttagcompound.getInt("Dimension"); - this.invulnerable = nbttagcompound.getBoolean("Invulnerable"); - this.portalCooldown = nbttagcompound.getInt("PortalCooldown"); - if (nbttagcompound.hasKeyOfType("UUIDMost", 4) && nbttagcompound.hasKeyOfType("UUIDLeast", 4)) { - this.uniqueID = new UUID(nbttagcompound.getLong("UUIDMost"), nbttagcompound.getLong("UUIDLeast")); - } - - this.setPosition(this.locX, this.locY, this.locZ); - this.b(this.yaw, this.pitch); - this.a(nbttagcompound); - if (this.V()) { - this.setPosition(this.locX, this.locY, this.locZ); - } - - // CraftBukkit start - if (this instanceof EntityLiving) { - EntityLiving entity = (EntityLiving) this; - - this.ticksLived = nbttagcompound.getInt("Spigot.ticksLived"); - - // Reset the persistence for tamed animals - if (entity instanceof EntityTameableAnimal && !isLevelAtLeast(nbttagcompound, 2) && !nbttagcompound.getBoolean("PersistenceRequired")) { - EntityInsentient entityinsentient = (EntityInsentient) entity; - entityinsentient.persistent = !entityinsentient.isTypeNotPersistent(); - } - } - // CraftBukkit end - - // CraftBukkit start - Exempt Vehicles from notch's sanity check - if (!(this.getBukkitEntity() instanceof Vehicle)) { - if (Math.abs(this.motX) > 10.0D) { - this.motX = 0.0D; - } - - if (Math.abs(this.motY) > 10.0D) { - this.motY = 0.0D; - } - - if (Math.abs(this.motZ) > 10.0D) { - this.motZ = 0.0D; - } - } - // CraftBukkit end - - // CraftBukkit start - Reset world - if (this instanceof EntityPlayer) { - Server server = Bukkit.getServer(); - org.bukkit.World bworld = null; - - // TODO: Remove World related checks, replaced with WorldUID. - String worldName = nbttagcompound.getString("World"); - - if (nbttagcompound.hasKey("WorldUUIDMost") && nbttagcompound.hasKey("WorldUUIDLeast")) { - UUID uid = new UUID(nbttagcompound.getLong("WorldUUIDMost"), nbttagcompound.getLong("WorldUUIDLeast")); - bworld = server.getWorld(uid); - } else { - bworld = server.getWorld(worldName); - } - - if (bworld == null) { - EntityPlayer entityPlayer = (EntityPlayer) this; - bworld = ((org.bukkit.craftbukkit.v1_7_R4.CraftServer) server).getServer().getWorldServer(entityPlayer.dimension).getWorld(); - } - - this.spawnIn(bworld == null ? null : ((CraftWorld) bworld).getHandle()); - } - // CraftBukkit end - } catch (Throwable throwable) { - CrashReport crashreport = CrashReport.a(throwable, "Loading entity NBT"); - CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being loaded"); - - this.a(crashreportsystemdetails); - throw new ReportedException(crashreport); - } - } - - protected boolean V() { - return true; - } - - protected final String W() { - return EntityTypes.b(this); - } - - protected abstract void a(NBTTagCompound nbttagcompound); - - protected abstract void b(NBTTagCompound nbttagcompound); - - public void X() {} - - protected NBTTagList a(double... adouble) { - NBTTagList nbttaglist = new NBTTagList(); - double[] adouble1 = adouble; - int i = adouble.length; - - for (int j = 0; j < i; ++j) { - double d0 = adouble1[j]; - - nbttaglist.add(new NBTTagDouble(d0)); - } - - return nbttaglist; - } - - protected NBTTagList a(float... afloat) { - NBTTagList nbttaglist = new NBTTagList(); - float[] afloat1 = afloat; - int i = afloat.length; - - for (int j = 0; j < i; ++j) { - float f = afloat1[j]; - - nbttaglist.add(new NBTTagFloat(f)); - } - - return nbttaglist; - } - - public EntityItem a(Item item, int i) { - return this.a(item, i, 0.0F); - } - - public EntityItem a(Item item, int i, float f) { - return this.a(new ItemStack(item, i, 0), f); - } - - public EntityItem a(ItemStack itemstack, float f) { - if (itemstack.count != 0 && itemstack.getItem() != null) { - // CraftBukkit start - Capture drops for death event - if (this instanceof EntityLiving && ((EntityLiving) this).drops != null) { - ((EntityLiving) this).drops.add(org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack.asBukkitCopy(itemstack)); - return null; - } - // CraftBukkit end - - EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY + (double) f, this.locZ, itemstack); - - entityitem.pickupDelay = 10; - this.world.addEntity(entityitem); - return entityitem; - } else { - return null; - } - } - - public boolean isAlive() { - return !this.dead; - } - - public boolean inBlock() { - for (int i = 0; i < 8; ++i) { - float f = ((float) ((i >> 0) % 2) - 0.5F) * this.width * 0.8F; - float f1 = ((float) ((i >> 1) % 2) - 0.5F) * 0.1F; - float f2 = ((float) ((i >> 2) % 2) - 0.5F) * this.width * 0.8F; - int j = MathHelper.floor(this.locX + (double) f); - int k = MathHelper.floor(this.locY + (double) this.getHeadHeight() + (double) f1); - int l = MathHelper.floor(this.locZ + (double) f2); - - if (this.world.getType(j, k, l).r()) { - return true; - } - } - - return false; - } - - public boolean c(EntityHuman entityhuman) { - return false; - } - - public AxisAlignedBB h(Entity entity) { - return null; - } - - public void ab() { - if (this.vehicle.dead) { - this.vehicle = null; - } else { - this.motX = 0.0D; - this.motY = 0.0D; - this.motZ = 0.0D; - this.h(); - if (this.vehicle != null) { - this.vehicle.ac(); - this.h += (double) (this.vehicle.yaw - this.vehicle.lastYaw); - - for (this.g += (double) (this.vehicle.pitch - this.vehicle.lastPitch); this.h >= 180.0D; this.h -= 360.0D) { - ; - } - - while (this.h < -180.0D) { - this.h += 360.0D; - } - - while (this.g >= 180.0D) { - this.g -= 360.0D; - } - - while (this.g < -180.0D) { - this.g += 360.0D; - } - - double d0 = this.h * 0.5D; - double d1 = this.g * 0.5D; - float f = 10.0F; - - if (d0 > (double) f) { - d0 = (double) f; - } - - if (d0 < (double) (-f)) { - d0 = (double) (-f); - } - - if (d1 > (double) f) { - d1 = (double) f; - } - - if (d1 < (double) (-f)) { - d1 = (double) (-f); - } - - this.h -= d0; - this.g -= d1; - } - } - } - - public void ac() { - if (this.passenger != null) { - this.passenger.setPosition(this.locX, this.locY + this.ae() + this.passenger.ad(), this.locZ); // Spigot - } - } - - public double ad() { - return (double) this.height; - } - - public double ae() { - return (double) this.length * 0.75D; - } - - public void mount(Entity entity) { - // CraftBukkit start - this.setPassengerOf(entity); - } - - protected CraftEntity bukkitEntity; - - public CraftEntity getBukkitEntity() { - if (this.bukkitEntity == null) { - this.bukkitEntity = CraftEntity.getEntity(this.world.getServer(), this); - } - return this.bukkitEntity; - } - - public void setPassengerOf(Entity entity) { - // b(null) doesn't really fly for overloaded methods, - // so this method is needed - - Entity originalVehicle = this.vehicle; - Entity originalPassenger = this.vehicle == null ? null : this.vehicle.passenger; - PluginManager pluginManager = Bukkit.getPluginManager(); - this.getBukkitEntity(); // make sure bukkitEntity is initialised - // CraftBukkit end - this.g = 0.0D; - this.h = 0.0D; - if (entity == null) { - if (this.vehicle != null) { - // CraftBukkit start - if ((this.bukkitEntity instanceof LivingEntity)) { - VehicleExitEvent event = new VehicleExitEvent(this.vehicle.getBukkitEntity(), (LivingEntity) this.bukkitEntity); - pluginManager.callEvent(event); - - if (event.isCancelled() || this.vehicle != originalVehicle) { - return; - } - } - // CraftBukkit end - pluginManager.callEvent( new org.spigotmc.event.entity.EntityDismountEvent( this.getBukkitEntity(), this.vehicle.getBukkitEntity() ) ); // Spigot - - this.setPositionRotation(this.vehicle.locX, this.vehicle.boundingBox.b + (double) this.vehicle.length, this.vehicle.locZ, this.yaw, this.pitch); - this.vehicle.passenger = null; - } - - this.vehicle = null; - } else { - // CraftBukkit start - 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(this.vehicle.getBukkitEntity(), (LivingEntity) this.bukkitEntity); - pluginManager.callEvent(exitEvent); - - if (exitEvent.isCancelled() || this.vehicle != originalVehicle || (this.vehicle != null && this.vehicle.passenger != originalPassenger)) { - return; - } - } - - VehicleEnterEvent event = new VehicleEnterEvent((Vehicle) entity.getBukkitEntity(), this.bukkitEntity); - pluginManager.callEvent(event); - - // If a plugin messes with the vehicle or the vehicle's passenger - if (event.isCancelled() || this.vehicle != originalVehicle || (this.vehicle != null && this.vehicle.passenger != originalPassenger)) { - // If we only cancelled the enterevent then we need to put the player in a decent position. - if (exitEvent != null && this.vehicle == originalVehicle && this.vehicle != null && this.vehicle.passenger == originalPassenger) { - this.setPositionRotation(this.vehicle.locX, this.vehicle.boundingBox.b + (double) this.vehicle.length, this.vehicle.locZ, this.yaw, this.pitch); - this.vehicle.passenger = null; - this.vehicle = null; - } - return; - } - } - // CraftBukkit end - // Spigot Start - if ( entity.world.isChunkLoaded( (int) entity.locX >> 4, (int) entity.locZ >> 4 ) ) - { - org.spigotmc.event.entity.EntityMountEvent event = new org.spigotmc.event.entity.EntityMountEvent( this.getBukkitEntity(), entity.getBukkitEntity() ); - pluginManager.callEvent( event ); - if ( event.isCancelled() ) - { - return; - } - } - // Spigot End - - if (this.vehicle != null) { - this.vehicle.passenger = null; - } - - if (entity != null) { - for (Entity entity1 = entity.vehicle; entity1 != null; entity1 = entity1.vehicle) { - if (entity1 == this) { - return; - } - } - } - - this.vehicle = entity; - entity.passenger = this; - } - } - - public float af() { - return 0.1F; - } - - public Vec3D ag() { - return null; - } - - public void ah() { - if (this.portalCooldown > 0) { - this.portalCooldown = this.ai(); - } else { - double d0 = this.lastX - this.locX; - double d1 = this.lastZ - this.locZ; - - if (!this.world.isStatic && !this.an) { - this.aq = Direction.a(d0, d1); - } - - this.an = true; - } - } - - public int ai() { - return 300; - } - - public ItemStack[] getEquipment() { - return null; - } - - public void setEquipment(int i, ItemStack itemstack) {} - - public boolean isBurning() { - boolean flag = this.world != null && this.world.isStatic; - - return !this.fireProof && (this.fireTicks > 0 || flag && this.g(0)); - } - - public boolean am() { - return this.vehicle != null; - } - - public boolean isSneaking() { - return this.g(1); - } - - public void setSneaking(boolean flag) { - this.a(1, flag); - } - - public boolean isSprinting() { - return this.g(3); - } - - public void setSprinting(boolean flag) { - this.a(3, flag); - } - - public boolean isInvisible() { - return this.g(5); - } - - public void setInvisible(boolean flag) { - if (Invisible && !flag) - return; - - this.a(5, flag); - } - - public void e(boolean flag) { - this.a(4, flag); - } - - protected boolean g(int i) { - return (this.datawatcher.getByte(0) & 1 << i) != 0; - } - - protected void a(int i, boolean flag) { - byte b0 = this.datawatcher.getByte(0); - - if (flag) { - this.datawatcher.watch(0, Byte.valueOf((byte) (b0 | 1 << i))); - } else { - this.datawatcher.watch(0, Byte.valueOf((byte) (b0 & ~(1 << i)))); - } - } - - public int getAirTicks() { - return this.datawatcher.getShort(1); - } - - public void setAirTicks(int i) { - this.datawatcher.watch(1, Short.valueOf((short) i)); - } - - public void a(EntityLightning entitylightning) { - // CraftBukkit start - final org.bukkit.entity.Entity thisBukkitEntity = this.getBukkitEntity(); - final org.bukkit.entity.Entity stormBukkitEntity = entitylightning.getBukkitEntity(); - final PluginManager pluginManager = Bukkit.getPluginManager(); - - if (thisBukkitEntity instanceof Hanging) { - HangingBreakByEntityEvent hangingEvent = new HangingBreakByEntityEvent((Hanging) thisBukkitEntity, stormBukkitEntity); - PaintingBreakByEntityEvent paintingEvent = null; - - if (thisBukkitEntity instanceof Painting) { - paintingEvent = new PaintingBreakByEntityEvent((Painting) thisBukkitEntity, stormBukkitEntity); - } - - pluginManager.callEvent(hangingEvent); - - if (paintingEvent != null) { - paintingEvent.setCancelled(hangingEvent.isCancelled()); - pluginManager.callEvent(paintingEvent); - } - - if (hangingEvent.isCancelled() || (paintingEvent != null && paintingEvent.isCancelled())) { - return; - } - } - - if (this.fireProof) { - return; - } - CraftEventFactory.entityDamage = entitylightning; - if (!this.damageEntity(DamageSource.FIRE, 5.0F)) { - CraftEventFactory.entityDamage = null; - return; - } - // CraftBukkit end - - ++this.fireTicks; - if (this.fireTicks == 0) { - // CraftBukkit start - Call a combust event when lightning strikes - EntityCombustByEntityEvent entityCombustEvent = new EntityCombustByEntityEvent(stormBukkitEntity, thisBukkitEntity, 8); - pluginManager.callEvent(entityCombustEvent); - if (!entityCombustEvent.isCancelled()) { - this.setOnFire(entityCombustEvent.getDuration()); - } - // CraftBukkit end - } - } - - public void a(EntityLiving entityliving) {} - - protected boolean j(double d0, double d1, double d2) { - int i = MathHelper.floor(d0); - int j = MathHelper.floor(d1); - int k = MathHelper.floor(d2); - double d3 = d0 - (double) i; - double d4 = d1 - (double) j; - double d5 = d2 - (double) k; - List list = this.world.a(this.boundingBox); - - if (list.isEmpty() && !this.world.q(i, j, k)) { - return false; - } else { - boolean flag = !this.world.q(i - 1, j, k); - boolean flag1 = !this.world.q(i + 1, j, k); - boolean flag2 = !this.world.q(i, j - 1, k); - boolean flag3 = !this.world.q(i, j + 1, k); - boolean flag4 = !this.world.q(i, j, k - 1); - boolean flag5 = !this.world.q(i, j, k + 1); - byte b0 = 3; - double d6 = 9999.0D; - - if (flag && d3 < d6) { - d6 = d3; - b0 = 0; - } - - if (flag1 && 1.0D - d3 < d6) { - d6 = 1.0D - d3; - b0 = 1; - } - - if (flag3 && 1.0D - d4 < d6) { - d6 = 1.0D - d4; - b0 = 3; - } - - if (flag4 && d5 < d6) { - d6 = d5; - b0 = 4; - } - - if (flag5 && 1.0D - d5 < d6) { - d6 = 1.0D - d5; - b0 = 5; - } - - float f = this.random.nextFloat() * 0.2F + 0.1F; - - if (b0 == 0) { - this.motX = (double) (-f); - } - - if (b0 == 1) { - this.motX = (double) f; - } - - if (b0 == 2) { - this.motY = (double) (-f); - } - - if (b0 == 3) { - this.motY = (double) f; - } - - if (b0 == 4) { - this.motZ = (double) (-f); - } - - if (b0 == 5) { - this.motZ = (double) f; - } - - return true; - } - } - - public void as() { - this.I = true; - this.fallDistance = 0.0F; - } - - public String getName() { - String s = EntityTypes.b(this); - - if (s == null) { - s = "generic"; - } - - return LocaleI18n.get("entity." + s + ".name"); - } - - public Entity[] at() { - return null; - } - - public boolean i(Entity entity) { - return this == entity; - } - - public float getHeadRotation() { - return 0.0F; - } - - public boolean av() { - return true; - } - - public boolean j(Entity entity) { - return false; - } - - public String toString() { - return String.format("%s[\'%s\'/%d, l=\'%s\', x=%.2f, y=%.2f, z=%.2f]", new Object[] { this.getClass().getSimpleName(), this.getName(), Integer.valueOf(this.id), this.world == null ? "~NULL~" : this.world.getWorldData().getName(), Double.valueOf(this.locX), Double.valueOf(this.locY), Double.valueOf(this.locZ)}); - } - - public boolean isInvulnerable() { - return this.invulnerable; - } - - public void k(Entity entity) { - this.setPositionRotation(entity.locX, entity.locY, entity.locZ, entity.yaw, entity.pitch); - } - - public void a(Entity entity, boolean flag) { - NBTTagCompound nbttagcompound = new NBTTagCompound(); - - entity.e(nbttagcompound); - this.f(nbttagcompound); - this.portalCooldown = entity.portalCooldown; - this.aq = entity.aq; - } - - public void b(int i) { - if (!this.world.isStatic && !this.dead) { - this.world.methodProfiler.a("changeDimension"); - MinecraftServer minecraftserver = MinecraftServer.getServer(); - // CraftBukkit start - Move logic into new function "teleportToLocation" - // int j = this.dimension; - WorldServer exitWorld = null; - if (this.dimension < CraftWorld.CUSTOM_DIMENSION_OFFSET) { // Plugins must specify exit from custom Bukkit worlds - // Only target existing worlds (compensate for allow-nether/allow-end as false) - for (WorldServer world : minecraftserver.worlds) { - if (world.dimension == i) { - exitWorld = world; - } - } - } - - Location enter = this.getBukkitEntity().getLocation(); - Location exit = exitWorld != null ? minecraftserver.getPlayerList().calculateTarget(enter, minecraftserver.getWorldServer(i)) : null; - boolean useTravelAgent = exitWorld != null && !(this.dimension == 1 && exitWorld.dimension == 1); // don't use agent for custom worlds or return from THE_END - - TravelAgent agent = exit != null ? (TravelAgent) ((CraftWorld) exit.getWorld()).getHandle().getTravelAgent() : org.bukkit.craftbukkit.v1_7_R4.CraftTravelAgent.DEFAULT; // return arbitrary TA to compensate for implementation dependent plugins - EntityPortalEvent event = new EntityPortalEvent(this.getBukkitEntity(), enter, exit, agent); - event.useTravelAgent(useTravelAgent); - event.getEntity().getServer().getPluginManager().callEvent(event); - if (event.isCancelled() || event.getTo() == null || event.getTo().getWorld() == null || !this.isAlive()) { - return; - } - exit = event.useTravelAgent() ? event.getPortalTravelAgent().findOrCreate(event.getTo()) : event.getTo(); - this.teleportTo(exit, true); - } - } - - public void teleportTo(Location exit, boolean portal) { - if (true) { - WorldServer worldserver = ((CraftWorld) this.getBukkitEntity().getLocation().getWorld()).getHandle(); - WorldServer worldserver1 = ((CraftWorld) exit.getWorld()).getHandle(); - int i = worldserver1.dimension; - // CraftBukkit end - - this.dimension = i; - /* CraftBukkit start - TODO: Check if we need this - if (j == 1 && i == 1) { - worldserver1 = minecraftserver.getWorldServer(0); - this.dimension = 0; - } - // CraftBukkit end */ - - this.world.kill(this); - this.dead = false; - this.world.methodProfiler.a("reposition"); - // CraftBukkit start - Ensure chunks are loaded in case TravelAgent is not used which would initially cause chunks to load during find/create - // minecraftserver.getPlayerList().a(this, j, worldserver, worldserver1); - boolean before = worldserver1.chunkProviderServer.forceChunkLoad; - worldserver1.chunkProviderServer.forceChunkLoad = true; - worldserver1.getMinecraftServer().getPlayerList().repositionEntity(this, exit, portal); - worldserver1.chunkProviderServer.forceChunkLoad = before; - // CraftBukkit end - this.world.methodProfiler.c("reloading"); - Entity entity = EntityTypes.createEntityByName(EntityTypes.b(this), worldserver1); - - if (entity != null) { - entity.a(this, true); - /* CraftBukkit start - We need to do this... - if (j == 1 && i == 1) { - ChunkCoordinates chunkcoordinates = worldserver1.getSpawn(); - - chunkcoordinates.y = this.world.i(chunkcoordinates.x, chunkcoordinates.z); - entity.setPositionRotation((double) chunkcoordinates.x, (double) chunkcoordinates.y, (double) chunkcoordinates.z, entity.yaw, entity.pitch); - } - // CraftBukkit end */ - worldserver1.addEntity(entity); - // CraftBukkit start - Forward the CraftEntity to the new entity - this.getBukkitEntity().setHandle(entity); - entity.bukkitEntity = this.getBukkitEntity(); - // CraftBukkit end - } - - this.dead = true; - this.world.methodProfiler.b(); - worldserver.i(); - worldserver1.i(); - this.world.methodProfiler.b(); - } - } - - public float a(Explosion explosion, World world, int i, int j, int k, Block block) { - return block.a(this); - } - - public boolean a(Explosion explosion, World world, int i, int j, int k, Block block, float f) { - return true; - } - - public int ax() { - return 3; - } - - public int ay() { - return this.aq; - } - - public boolean az() { - return false; - } - - public void a(CrashReportSystemDetails crashreportsystemdetails) { - crashreportsystemdetails.a("Entity Type", (Callable) (new CrashReportEntityType(this))); - crashreportsystemdetails.a("Entity ID", Integer.valueOf(this.id)); - crashreportsystemdetails.a("Entity Name", (Callable) (new CrashReportEntityName(this))); - crashreportsystemdetails.a("Entity\'s Exact location", String.format("%.2f, %.2f, %.2f", new Object[] { Double.valueOf(this.locX), Double.valueOf(this.locY), Double.valueOf(this.locZ)})); - crashreportsystemdetails.a("Entity\'s Block location", CrashReportSystemDetails.a(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ))); - crashreportsystemdetails.a("Entity\'s Momentum", String.format("%.2f, %.2f, %.2f", new Object[] { Double.valueOf(this.motX), Double.valueOf(this.motY), Double.valueOf(this.motZ)})); - } - - public UUID getUniqueID() { - return this.uniqueID; - } - - public boolean aC() { - return true; - } - - public IChatBaseComponent getScoreboardDisplayName() { - return new ChatComponentText(this.getName()); - } - - public void i(int i) {} -} diff --git a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/EntityBat.java b/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/EntityBat.java deleted file mode 100644 index f5e80d7dd..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/EntityBat.java +++ /dev/null @@ -1,251 +0,0 @@ -package net.minecraft.server.v1_7_R4; - -import java.util.Calendar; -import java.util.Random; - -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/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/EntityBlaze.java b/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/EntityBlaze.java deleted file mode 100644 index e27f4fe1b..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/EntityBlaze.java +++ /dev/null @@ -1,192 +0,0 @@ -package net.minecraft.server.v1_7_R4; - -import java.util.Random; - -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/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/EntityEnderDragon.java b/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/EntityEnderDragon.java deleted file mode 100644 index 8b3a13e69..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/EntityEnderDragon.java +++ /dev/null @@ -1,698 +0,0 @@ -package net.minecraft.server.v1_7_R4; - -import java.util.Iterator; -import java.util.List; - -// CraftBukkit start -import org.bukkit.block.BlockState; -import org.bukkit.craftbukkit.v1_7_R4.event.CraftEventFactory; -import org.bukkit.craftbukkit.v1_7_R4.util.BlockStateListPopulator; -import org.bukkit.event.entity.EntityCreatePortalEvent; -import org.bukkit.event.entity.EntityExplodeEvent; -import org.bukkit.event.entity.EntityRegainHealthEvent; -import org.bukkit.event.entity.EntityTargetEvent; -import org.bukkit.Bukkit; -// CraftBukkit end - -public class EntityEnderDragon extends EntityInsentient implements IComplex, IMonster { - - public double h; - public double i; - public double bm; - public double[][] bn = new double[64][3]; - public int bo = -1; - public EntityComplexPart[] children; - public EntityComplexPart bq; - public EntityComplexPart br; - public EntityComplexPart bs; - public EntityComplexPart bt; - public EntityComplexPart bu; - public EntityComplexPart bv; - public EntityComplexPart bw; - public float bx; - public float by; - public boolean bz; - public boolean bA; - private Entity bD; - public int bB; - 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)}; - this.setHealth(this.getMaxHealth()); - this.a(16.0F, 8.0F); - this.X = true; - this.fireProof = true; - this.i = 100.0D; - this.ak = true; - } - - protected void aD() { - super.aD(); - this.getAttributeInstance(GenericAttributes.maxHealth).setValue(200.0D); - } - - protected void c() { - super.c(); - } - - public double[] b(int i, float f) { - if (this.getHealth() <= 0.0F) { - f = 0.0F; - } - - f = 1.0F - f; - int j = this.bo - i * 1 & 63; - int k = this.bo - i * 1 - 1 & 63; - double[] adouble = new double[3]; - double d0 = this.bn[j][0]; - double d1 = MathHelper.g(this.bn[k][0] - d0); - - adouble[0] = d0 + d1 * (double) f; - d0 = this.bn[j][1]; - d1 = this.bn[k][1] - d0; - adouble[1] = d0 + d1 * (double) f; - adouble[2] = this.bn[j][2] + (this.bn[k][2] - this.bn[j][2]) * (double) f; - return adouble; - } - - public void e() { - float f; - float f1; - - if (this.world.isStatic) { - f = MathHelper.cos(this.by * 3.1415927F * 2.0F); - f1 = MathHelper.cos(this.bx * 3.1415927F * 2.0F); - if (f1 <= -0.3F && f >= -0.3F) { - this.world.a(this.locX, this.locY, this.locZ, "mob.enderdragon.wings", 5.0F, 0.8F + this.random.nextFloat() * 0.3F, false); - } - } - - this.bx = this.by; - float f2; - - if (this.getHealth() <= 0.0F) { - f = (this.random.nextFloat() - 0.5F) * 8.0F; - f1 = (this.random.nextFloat() - 0.5F) * 4.0F; - f2 = (this.random.nextFloat() - 0.5F) * 8.0F; - this.world.addParticle("largeexplode", this.locX + (double) f, this.locY + 2.0D + (double) f1, this.locZ + (double) f2, 0.0D, 0.0D, 0.0D); - } else { - this.bP(); - f = 0.2F / (MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ) * 10.0F + 1.0F); - f *= (float) Math.pow(2.0D, this.motY); - if (this.bA) { - this.by += f * 0.5F; - } else { - this.by += f; - } - - this.yaw = MathHelper.g(this.yaw); - if (this.bo < 0) { - for (int d05 = 0; d05 < this.bn.length; ++d05) { - this.bn[d05][0] = (double) this.yaw; - this.bn[d05][1] = this.locY; - } - } - - if (++this.bo == this.bn.length) { - this.bo = 0; - } - - this.bn[this.bo][0] = (double) this.yaw; - this.bn[this.bo][1] = this.locY; - double d0; - double d1; - double d2; - double d3; - float f3; - - if (this.world.isStatic) { - if (this.bg > 0) { - d0 = this.locX + (this.bh - this.locX) / (double) this.bg; - d1 = this.locY + (this.bi - this.locY) / (double) this.bg; - d2 = this.locZ + (this.bj - this.locZ) / (double) this.bg; - d3 = MathHelper.g(this.bk - (double) this.yaw); - this.yaw = (float) ((double) this.yaw + d3 / (double) this.bg); - this.pitch = (float) ((double) this.pitch + (this.bl - (double) this.pitch) / (double) this.bg); - --this.bg; - this.setPosition(d0, d1, d2); - this.b(this.yaw, this.pitch); - } - } else { - d0 = this.h - this.locX; - d1 = this.i - this.locY; - d2 = this.bm - this.locZ; - d3 = d0 * d0 + d1 * d1 + d2 * d2; - if (this.bD != null) { - this.h = this.bD.locX; - this.bm = this.bD.locZ; - double d4 = this.h - this.locX; - double d5 = this.bm - this.locZ; - double d6 = Math.sqrt(d4 * d4 + d5 * d5); - double d7 = 0.4000000059604645D + d6 / 80.0D - 1.0D; - - if (d7 > 10.0D) { - d7 = 10.0D; - } - - this.i = this.bD.boundingBox.b + d7; - } else { - this.h += this.random.nextGaussian() * 2.0D; - this.bm += this.random.nextGaussian() * 2.0D; - } - - if (!Vegetated && this.bz || d3 < 100.0D || d3 > 22500.0D || this.positionChanged || this.F) { - this.bQ(); - } - - d1 /= (double) MathHelper.sqrt(d0 * d0 + d2 * d2); - f3 = 0.6F; - if (d1 < (double) (-f3)) { - d1 = (double) (-f3); - } - - if (d1 > (double) f3) { - d1 = (double) f3; - } - - this.motY += d1 * 0.10000000149011612D; - this.yaw = MathHelper.g(this.yaw); - double d8 = 180.0D - Math.atan2(d0, d2) * 180.0D / 3.1415927410125732D; - double d9 = MathHelper.g(d8 - (double) this.yaw); - - if (d9 > 50.0D) { - d9 = 50.0D; - } - - if (d9 < -50.0D) { - d9 = -50.0D; - } - - Vec3D vec3d = Vec3D.a(this.h - this.locX, this.i - this.locY, this.bm - this.locZ).a(); - Vec3D vec3d1 = Vec3D.a((double) MathHelper.sin(this.yaw * 3.1415927F / 180.0F), this.motY, (double) (-MathHelper.cos(this.yaw * 3.1415927F / 180.0F))).a(); - float f4 = (float) (vec3d1.b(vec3d) + 0.5D) / 1.5F; - - if (f4 < 0.0F) { - f4 = 0.0F; - } - - this.bf *= 0.8F; - float f5 = MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ) * 1.0F + 1.0F; - double d10 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ) * 1.0D + 1.0D; - - if (d10 > 40.0D) { - d10 = 40.0D; - } - - this.bf = (float) ((double) this.bf + d9 * (0.699999988079071D / d10 / (double) f5)); - this.yaw += this.bf * 0.1F; - float f6 = (float) (2.0D / (d10 + 1.0D)); - float f7 = 0.06F; - - this.a(0.0F, -1.0F, f7 * (f4 * f6 + (1.0F - f6))); - if (this.bA) { - this.move(this.motX * 0.800000011920929D, this.motY * 0.800000011920929D, this.motZ * 0.800000011920929D); - } else { - this.move(this.motX, this.motY, this.motZ); - } - - Vec3D vec3d2 = Vec3D.a(this.motX, this.motY, this.motZ).a(); - float f8 = (float) (vec3d2.b(vec3d1) + 1.0D) / 2.0F; - - f8 = 0.8F + 0.15F * f8; - this.motX *= (double) f8; - this.motZ *= (double) f8; - this.motY *= 0.9100000262260437D; - } - - this.aM = this.yaw; - this.bq.width = this.bq.length = 3.0F; - this.bs.width = this.bs.length = 2.0F; - this.bt.width = this.bt.length = 2.0F; - this.bu.width = this.bu.length = 2.0F; - this.br.length = 3.0F; - this.br.width = 5.0F; - this.bv.length = 2.0F; - this.bv.width = 4.0F; - this.bw.length = 3.0F; - this.bw.width = 4.0F; - f1 = (float) (this.b(5, 1.0F)[1] - this.b(10, 1.0F)[1]) * 10.0F / 180.0F * 3.1415927F; - f2 = MathHelper.cos(f1); - float f9 = -MathHelper.sin(f1); - float f10 = this.yaw * 3.1415927F / 180.0F; - float f11 = MathHelper.sin(f10); - float f12 = MathHelper.cos(f10); - - this.br.h(); - this.br.setPositionRotation(this.locX + (double) (f11 * 0.5F), this.locY, this.locZ - (double) (f12 * 0.5F), 0.0F, 0.0F); - this.bv.h(); - this.bv.setPositionRotation(this.locX + (double) (f12 * 4.5F), this.locY + 2.0D, this.locZ + (double) (f11 * 4.5F), 0.0F, 0.0F); - this.bw.h(); - this.bw.setPositionRotation(this.locX - (double) (f12 * 4.5F), this.locY + 2.0D, this.locZ - (double) (f11 * 4.5F), 0.0F, 0.0F); - if (!this.world.isStatic && this.hurtTicks == 0 && !ghost) { - this.a(this.world.getEntities(this, this.bv.boundingBox.grow(4.0D, 2.0D, 4.0D).d(0.0D, -2.0D, 0.0D))); - 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))); - } - - double[] adouble = this.b(5, 1.0F); - double[] adouble1 = this.b(0, 1.0F); - - f3 = MathHelper.sin(this.yaw * 3.1415927F / 180.0F - this.bf * 0.01F); - float f13 = MathHelper.cos(this.yaw * 3.1415927F / 180.0F - this.bf * 0.01F); - - this.bq.h(); - this.bq.setPositionRotation(this.locX + (double) (f3 * 5.5F * f2), this.locY + (adouble1[1] - adouble[1]) * 1.0D + (double) (f9 * 5.5F), this.locZ - (double) (f13 * 5.5F * f2), 0.0F, 0.0F); - - for (int j = 0; j < 3; ++j) { - EntityComplexPart entitycomplexpart = null; - - if (j == 0) { - entitycomplexpart = this.bs; - } - - if (j == 1) { - entitycomplexpart = this.bt; - } - - if (j == 2) { - entitycomplexpart = this.bu; - } - - double[] adouble2 = this.b(12 + j * 2, 1.0F); - float f14 = this.yaw * 3.1415927F / 180.0F + this.b(adouble2[0] - adouble[0]) * 3.1415927F / 180.0F * 1.0F; - float f15 = MathHelper.sin(f14); - float f16 = MathHelper.cos(f14); - float f17 = 1.5F; - float f18 = (float) (j + 1) * 2.0F; - - entitycomplexpart.h(); - entitycomplexpart.setPositionRotation(this.locX - (double) ((f11 * f17 + f15 * f18) * f2), this.locY + (adouble2[1] - adouble[1]) * 1.0D - (double) ((f18 + f17) * f9) + 1.5D, this.locZ + (double) ((f12 * f17 + f16 * f18) * f2), 0.0F, 0.0F); - } - - if (!this.world.isStatic) { - this.bA = this.a(this.bq.boundingBox) | this.a(this.br.boundingBox); - } - } - } - - private void bP() { - if (this.bC != null) { - if (this.bC.dead) { - if (!this.world.isStatic) { - CraftEventFactory.entityDamage = this.bC; // CraftBukkit - this.a(this.bq, DamageSource.explosion((Explosion) null), 10.0F); - CraftEventFactory.entityDamage = null; // CraftBukkit - } - - this.bC = null; - } else if (this.ticksLived % 10 == 0 && this.getHealth() < this.getMaxHealth()) { - // CraftBukkit start - EntityRegainHealthEvent event = new EntityRegainHealthEvent(this.getBukkitEntity(), 1.0D, EntityRegainHealthEvent.RegainReason.ENDER_CRYSTAL); - this.world.getServer().getPluginManager().callEvent(event); - - if (!event.isCancelled()) { - this.setHealth((float) (this.getHealth() + event.getAmount())); - } - // CraftBukkit end - } - } - - if (this.random.nextInt(10) == 0) { - float f = 32.0F; - List list = this.world.a(EntityEnderCrystal.class, this.boundingBox.grow((double) f, (double) f, (double) f)); - EntityEnderCrystal entityendercrystal = null; - double d0 = Double.MAX_VALUE; - Iterator iterator = list.iterator(); - - while (iterator.hasNext()) { - EntityEnderCrystal entityendercrystal1 = (EntityEnderCrystal) iterator.next(); - double d1 = entityendercrystal1.f(this); - - if (d1 < d0) { - d0 = d1; - entityendercrystal = entityendercrystal1; - } - } - - this.bC = entityendercrystal; - } - } - - private void a(List list) { - double d0 = (this.br.boundingBox.a + this.br.boundingBox.d) / 2.0D; - double d1 = (this.br.boundingBox.c + this.br.boundingBox.f) / 2.0D; - Iterator iterator = list.iterator(); - - while (iterator.hasNext()) { - Entity entity = (Entity) iterator.next(); - - if (entity instanceof EntityLiving) { - double d2 = entity.locX - d0; - double d3 = entity.locZ - d1; - double d4 = d2 * d2 + d3 * d3; - - entity.g(d2 / d4 * 4.0D, 0.20000000298023224D, d3 / d4 * 4.0D); - } - } - } - - private void b(List list) { - for (int i = 0; i < list.size(); ++i) { - Entity entity = (Entity) list.get(i); - - if (entity instanceof EntityLiving) { - entity.damageEntity(DamageSource.mobAttack(this), 10.0F); - } - } - } - - 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()) { - // CraftBukkit start - Entity target = (Entity) this.world.players.get(this.random.nextInt(this.world.players.size())); - EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), target.getBukkitEntity(), EntityTargetEvent.TargetReason.RANDOM_TARGET); - this.world.getServer().getPluginManager().callEvent(event); - - if (!event.isCancelled()) { - if (event.getTarget() == null) { - this.bD = null; - } else { - this.bD = ((org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity) event.getTarget()).getHandle(); - } - } - // CraftBukkit end - } else { - boolean flag = false; - - do { - this.h = 0.0D; - this.i = (double) (70.0F + this.random.nextFloat() * 50.0F); - this.bm = 0.0D; - this.h += (double) (this.random.nextFloat() * 120.0F - 60.0F); - this.bm += (double) (this.random.nextFloat() * 120.0F - 60.0F); - double d0 = this.locX - this.h; - double d1 = this.locY - this.i; - double d2 = this.locZ - this.bm; - - flag = d0 * d0 + d1 * d1 + d2 * d2 > 100.0D; - } while (!flag); - - this.bD = null; - } - } - - private float b(double d0) { - return (float) MathHelper.g(d0); - } - - private boolean a(AxisAlignedBB axisalignedbb) { - int i = MathHelper.floor(axisalignedbb.a); - int j = MathHelper.floor(axisalignedbb.b); - int k = MathHelper.floor(axisalignedbb.c); - int l = MathHelper.floor(axisalignedbb.d); - int i1 = MathHelper.floor(axisalignedbb.e); - int j1 = MathHelper.floor(axisalignedbb.f); - boolean flag = false; - boolean flag1 = false; - - // CraftBukkit start - Create a list to hold all the destroyed blocks - List destroyedBlocks = new java.util.ArrayList(); - org.bukkit.craftbukkit.v1_7_R4.CraftWorld craftWorld = this.world.getWorld(); - // CraftBukkit end - - for (int k1 = i; k1 <= l; ++k1) { - for (int l1 = j; l1 <= i1; ++l1) { - for (int i2 = k; i2 <= j1; ++i2) { - Block block = this.world.getType(k1, l1, i2); - - if (block.getMaterial() != Material.AIR) { - if (block != Blocks.OBSIDIAN && block != Blocks.WHITESTONE && block != Blocks.BEDROCK && this.world.getGameRules().getBoolean("mobGriefing")) { - // CraftBukkit start - Add blocks to list rather than destroying them - // flag1 = this.world.setAir(k1, l1, i2) || flag1; - flag1 = true; - destroyedBlocks.add(craftWorld.getBlockAt(k1, l1, i2)); - // CraftBukkit end - } else { - flag = true; - } - } - } - } - } - - if (flag1) { - // CraftBukkit start - Set off an EntityExplodeEvent for the dragon exploding all these blocks - org.bukkit.entity.Entity bukkitEntity = this.getBukkitEntity(); - EntityExplodeEvent event = new EntityExplodeEvent(bukkitEntity, bukkitEntity.getLocation(), destroyedBlocks, 0F); - Bukkit.getPluginManager().callEvent(event); - if (event.isCancelled()) { - // This flag literally means 'Dragon hit something hard' (Obsidian, White Stone or Bedrock) and will cause the dragon to slow down. - // We should consider adding an event extension for it, or perhaps returning true if the event is cancelled. - return flag; - } else if (event.getYield() == 0F) { - // Yield zero ==> no drops - for (org.bukkit.block.Block block : event.blockList()) { - this.world.setAir(block.getX(), block.getY(), block.getZ()); - } - } else { - for (org.bukkit.block.Block block : event.blockList()) { - org.bukkit.Material blockId = block.getType(); - if (blockId == org.bukkit.Material.AIR) { - continue; - } - - int blockX = block.getX(); - int blockY = block.getY(); - int blockZ = block.getZ(); - - Block nmsBlock = org.bukkit.craftbukkit.v1_7_R4.util.CraftMagicNumbers.getBlock(blockId); - if (nmsBlock.a(explosionSource)) { - nmsBlock.dropNaturally(this.world, blockX, blockY, blockZ, block.getData(), event.getYield(), 0); - } - nmsBlock.wasExploded(world, blockX, blockY, blockZ, explosionSource); - - this.world.setAir(blockX, blockY, blockZ); - } - } - // CraftBukkit end - - double d0 = axisalignedbb.a + (axisalignedbb.d - axisalignedbb.a) * (double) this.random.nextFloat(); - double d1 = axisalignedbb.b + (axisalignedbb.e - axisalignedbb.b) * (double) this.random.nextFloat(); - double d2 = axisalignedbb.c + (axisalignedbb.f - axisalignedbb.c) * (double) this.random.nextFloat(); - - this.world.addParticle("largeexplode", d0, d1, d2, 0.0D, 0.0D, 0.0D); - } - - return flag; - } - - public boolean a(EntityComplexPart entitycomplexpart, DamageSource damagesource, float f) { - if (entitycomplexpart != this.bq) { - f = f / 4.0F + 1.0F; - } - - float f1 = this.yaw * 3.1415927F / 180.0F; - float f2 = MathHelper.sin(f1); - float f3 = MathHelper.cos(f1); - - this.h = this.locX + (double) (f2 * 5.0F) + (double) ((this.random.nextFloat() - 0.5F) * 2.0F); - this.i = this.locY + (double) (this.random.nextFloat() * 3.0F) + 1.0D; - this.bm = this.locZ - (double) (f3 * 5.0F) + (double) ((this.random.nextFloat() - 0.5F) * 2.0F); - this.bD = null; - if (damagesource.getEntity() instanceof EntityHuman || damagesource.isExplosion()) { - this.dealDamage(damagesource, f); - } - - return true; - } - - public boolean damageEntity(DamageSource damagesource, float f) { - return false; - } - - public boolean dealDamage(DamageSource damagesource, float f) { // CraftBukkit - protected -> public - return super.damageEntity(damagesource, f); - } - - protected void aF() { - if (this.dead) return; // CraftBukkit - can't kill what's already dead - ++this.bB; - if (this.bB >= 180 && this.bB <= 200) { - float f = (this.random.nextFloat() - 0.5F) * 8.0F; - float f1 = (this.random.nextFloat() - 0.5F) * 4.0F; - float f2 = (this.random.nextFloat() - 0.5F) * 8.0F; - - this.world.addParticle("hugeexplosion", this.locX + (double) f, this.locY + 2.0D + (double) f1, this.locZ + (double) f2, 0.0D, 0.0D, 0.0D); - } - - int i; - int j; - - if (!this.world.isStatic) { - if (this.bB > 150 && this.bB % 5 == 0) { - i = this.expToDrop / 12; // CraftBukkit - drop experience as dragon falls from sky. use experience drop from death event. This is now set in getExpReward() - - while (i > 0) { - j = EntityExperienceOrb.getOrbValue(i); - i -= j; - this.world.addEntity(new EntityExperienceOrb(this.world, this.locX, this.locY, this.locZ, j)); - } - } - - if (this.bB == 1) { - // CraftBukkit start - Use relative location for far away sounds - //this.world.b(1018, (int) this.locX, (int) this.locY, (int) this.locZ, 0); - int viewDistance = ((WorldServer) this.world).getServer().getViewDistance() * 16; - for (EntityPlayer player : (List) this.world.players) { - double deltaX = this.locX - player.locX; - double deltaZ = this.locZ - player.locZ; - double distanceSquared = deltaX * deltaX + deltaZ * deltaZ; - if ( world.spigotConfig.dragonDeathSoundRadius > 0 && distanceSquared > world.spigotConfig.dragonDeathSoundRadius * world.spigotConfig.dragonDeathSoundRadius ) continue; // Spigot - if (distanceSquared > viewDistance * viewDistance) { - double deltaLength = Math.sqrt(distanceSquared); - double relativeX = player.locX + (deltaX / deltaLength) * viewDistance; - double relativeZ = player.locZ + (deltaZ / deltaLength) * viewDistance; - player.playerConnection.sendPacket(new PacketPlayOutWorldEvent(1018, (int) relativeX, (int) this.locY, (int) relativeZ, 0, true)); - } else { - player.playerConnection.sendPacket(new PacketPlayOutWorldEvent(1018, (int) this.locX, (int) this.locY, (int) this.locZ, 0, true)); - } - } - // CraftBukkit end - } - } - - this.move(0.0D, 0.10000000149011612D, 0.0D); - this.aM = this.yaw += 20.0F; - if (this.bB == 200 && !this.world.isStatic) { - i = this.expToDrop - (10 * this.expToDrop / 12); // CraftBukkit - drop the remaining experience - - while (i > 0) { - j = EntityExperienceOrb.getOrbValue(i); - i -= j; - this.world.addEntity(new EntityExperienceOrb(this.world, this.locX, this.locY, this.locZ, j)); - } - - this.b(MathHelper.floor(this.locX), MathHelper.floor(this.locZ)); - this.die(); - } - } - - private void b(int i, int j) { - byte b0 = 64; - - BlockEnderPortal.a = true; - byte b1 = 4; - - // CraftBukkit start - Replace any "this.world" in the following with just "world"! - BlockStateListPopulator world = new BlockStateListPopulator(this.world.getWorld()); - - for (int k = b0 - 1; k <= b0 + 32; ++k) { - for (int l = i - b1; l <= i + b1; ++l) { - for (int i1 = j - b1; i1 <= j + b1; ++i1) { - double d0 = (double) (l - i); - double d1 = (double) (i1 - j); - double d2 = d0 * d0 + d1 * d1; - - if (d2 <= ((double) b1 - 0.5D) * ((double) b1 - 0.5D)) { - if (k < b0) { - if (d2 <= ((double) (b1 - 1) - 0.5D) * ((double) (b1 - 1) - 0.5D)) { - world.setTypeUpdate(l, k, i1, Blocks.BEDROCK); - } - } else if (k > b0) { - world.setTypeUpdate(l, k, i1, Blocks.AIR); - } else if (d2 > ((double) (b1 - 1) - 0.5D) * ((double) (b1 - 1) - 0.5D)) { - world.setTypeUpdate(l, k, i1, Blocks.BEDROCK); - } else { - world.setTypeUpdate(l, k, i1, Blocks.ENDER_PORTAL); - } - } - } - } - } - - world.setType(i, b0 + 0, j, Blocks.BEDROCK); - world.setType(i, b0 + 1, j, Blocks.BEDROCK); - world.setType(i, b0 + 2, j, Blocks.BEDROCK); - world.setTypeAndData(i - 1, b0 + 2, j, Blocks.TORCH, 2, 0); - world.setTypeAndData(i + 1, b0 + 2, j, Blocks.TORCH, 1, 0); - world.setTypeAndData(i, b0 + 2, j - 1, Blocks.TORCH, 4, 0); - world.setTypeAndData(i, b0 + 2, j + 1, Blocks.TORCH, 3, 0); - world.setType(i, b0 + 3, j, Blocks.BEDROCK); - world.setType(i, b0 + 4, j, Blocks.DRAGON_EGG); - - EntityCreatePortalEvent event = new EntityCreatePortalEvent((org.bukkit.entity.LivingEntity) this.getBukkitEntity(), java.util.Collections.unmodifiableList(world.getList()), org.bukkit.PortalType.ENDER); - this.world.getServer().getPluginManager().callEvent(event); - - if (!event.isCancelled()) { - for (BlockState state : event.getBlocks()) { - state.update(true); - } - } else { - for (BlockState state : event.getBlocks()) { - PacketPlayOutBlockChange packet = new PacketPlayOutBlockChange(state.getX(), state.getY(), state.getZ(), this.world); - for (Iterator it = this.world.players.iterator(); it.hasNext();) { - EntityHuman entity = (EntityHuman) it.next(); - if (entity instanceof EntityPlayer) { - ((EntityPlayer) entity).playerConnection.sendPacket(packet); - } - } - } - } - // CraftBukkit end - - BlockEnderPortal.a = false; - } - - protected void w() {} - - public Entity[] at() { - return this.children; - } - - public boolean R() { - return false; - } - - public World a() { - return this.world; - } - - protected String t() { - return "mob.enderdragon.growl"; - } - - protected String aT() { - return "mob.enderdragon.hit"; - } - - protected float bf() { - return 5.0F; - } - - // CraftBukkit start - public int getExpReward() { - // This value is equal to the amount of experience dropped while falling from the sky (10 * 1000) - // plus what is dropped when the dragon hits the ground (2000) - return 12000; - } - // CraftBukkit end -} diff --git a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/EntityEnderman.java b/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/EntityEnderman.java deleted file mode 100644 index 675752706..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/EntityEnderman.java +++ /dev/null @@ -1,385 +0,0 @@ -package net.minecraft.server.v1_7_R4; - -import java.util.UUID; - -// CraftBukkit start -import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_7_R4.event.CraftEventFactory; -import org.bukkit.event.entity.EntityTeleportEvent; -// CraftBukkit end - -public class EntityEnderman extends EntityMonster { - - private static final UUID bp = UUID.fromString("020E0DFB-87AE-4653-9556-831010E291A0"); - private static final AttributeModifier bq = (new AttributeModifier(bp, "Attacking speed boost", 6.199999809265137D, 0)).a(false); - private static boolean[] br = new boolean[256]; - private int bs; - private int bt; - private Entity bu; - private boolean bv; - - public EntityEnderman(World world) { - super(world); - this.a(0.6F, 2.9F); - this.W = 1.0F; - } - - protected void aD() { - super.aD(); - this.getAttributeInstance(GenericAttributes.maxHealth).setValue(40.0D); - this.getAttributeInstance(GenericAttributes.d).setValue(0.30000001192092896D); - this.getAttributeInstance(GenericAttributes.e).setValue(7.0D); - } - - protected void c() { - super.c(); - this.datawatcher.a(16, new Byte((byte) 0)); - this.datawatcher.a(17, new Byte((byte) 0)); - this.datawatcher.a(18, new Byte((byte) 0)); - } - - public void b(NBTTagCompound nbttagcompound) { - super.b(nbttagcompound); - nbttagcompound.setShort("carried", (short) Block.getId(this.getCarried())); - nbttagcompound.setShort("carriedData", (short) this.getCarriedData()); - } - - public void a(NBTTagCompound nbttagcompound) { - super.a(nbttagcompound); - this.setCarried(Block.getById(nbttagcompound.getShort("carried"))); - this.setCarriedData(nbttagcompound.getShort("carriedData")); - } - - protected Entity findTarget() { - if (Vegetated) - return null; - - EntityHuman entityhuman = this.world.findNearbyVulnerablePlayer(this, 64.0D); - - if (entityhuman != null) { - if (this.f(entityhuman)) { - this.bv = true; - if (this.bt == 0) { - this.world.makeSound(entityhuman.locX, entityhuman.locY, entityhuman.locZ, "mob.endermen.stare", 1.0F, 1.0F); - } - - if (this.bt++ == 5) { - this.bt = 0; - this.a(true); - return entityhuman; - } - } else { - this.bt = 0; - } - } - - return null; - } - - private boolean f(EntityHuman entityhuman) { - ItemStack itemstack = entityhuman.inventory.armor[3]; - - if (itemstack != null && itemstack.getItem() == Item.getItemOf(Blocks.PUMPKIN)) { - return false; - } else { - Vec3D vec3d = entityhuman.j(1.0F).a(); - Vec3D vec3d1 = Vec3D.a(this.locX - entityhuman.locX, this.boundingBox.b + (double) (this.length / 2.0F) - (entityhuman.locY + (double) entityhuman.getHeadHeight()), this.locZ - entityhuman.locZ); - double d0 = vec3d1.b(); - - vec3d1 = vec3d1.a(); - double d1 = vec3d.b(vec3d1); - - return d1 > 1.0D - 0.025D / d0 && entityhuman.hasLineOfSight(this); - } - } - - public void e() { - if (this.L()) { - this.damageEntity(DamageSource.DROWN, 1.0F); - } - - if (this.bu != this.target) { - AttributeInstance attributeinstance = this.getAttributeInstance(GenericAttributes.d); - - attributeinstance.b(bq); - if (this.target != null) { - attributeinstance.a(bq); - } - } - - this.bu = this.target; - int i; - - if (!this.world.isStatic && this.world.getGameRules().getBoolean("mobGriefing")) { - int j; - int k; - Block block; - - if (this.getCarried().getMaterial() == Material.AIR) { - if (this.random.nextInt(20) == 0) { - i = MathHelper.floor(this.locX - 2.0D + this.random.nextDouble() * 4.0D); - j = MathHelper.floor(this.locY + this.random.nextDouble() * 3.0D); - k = MathHelper.floor(this.locZ - 2.0D + this.random.nextDouble() * 4.0D); - block = this.world.getType(i, j, k); - if (br[Block.getId(block)]) { - // CraftBukkit start - Pickup event - if (!CraftEventFactory.callEntityChangeBlockEvent(this, this.world.getWorld().getBlockAt(i, j, k), org.bukkit.Material.AIR).isCancelled()) { - this.setCarried(block); - this.setCarriedData(this.world.getData(i, j, k)); - this.world.setTypeUpdate(i, j, k, Blocks.AIR); - } - // CraftBukkit end - } - } - } else if (this.random.nextInt(2000) == 0) { - i = MathHelper.floor(this.locX - 1.0D + this.random.nextDouble() * 2.0D); - j = MathHelper.floor(this.locY + this.random.nextDouble() * 2.0D); - k = MathHelper.floor(this.locZ - 1.0D + this.random.nextDouble() * 2.0D); - block = this.world.getType(i, j, k); - Block block1 = this.world.getType(i, j - 1, k); - - if (block.getMaterial() == Material.AIR && block1.getMaterial() != Material.AIR && block1.d()) { - // CraftBukkit start - Place event - if (!CraftEventFactory.callEntityChangeBlockEvent(this, i, j, k, this.getCarried(), this.getCarriedData()).isCancelled()) { - this.world.setTypeAndData(i, j, k, this.getCarried(), this.getCarriedData(), 3); - this.setCarried(Blocks.AIR); - } - // CraftBukkit end - } - } - } - - for (i = 0; i < 2; ++i) { - this.world.addParticle("portal", this.locX + (this.random.nextDouble() - 0.5D) * (double) this.width, this.locY + this.random.nextDouble() * (double) this.length - 0.25D, this.locZ + (this.random.nextDouble() - 0.5D) * (double) this.width, (this.random.nextDouble() - 0.5D) * 2.0D, -this.random.nextDouble(), (this.random.nextDouble() - 0.5D) * 2.0D); - } - - if (this.world.w() && !this.world.isStatic) { - float f = this.d(1.0F); - - if (f > 0.5F && this.world.i(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)) && this.random.nextFloat() * 30.0F < (f - 0.4F) * 2.0F) { - this.target = null; - this.a(false); - this.bv = false; - this.bZ(); - } - } - - if (this.L() || this.isBurning()) { - this.target = null; - this.a(false); - this.bv = false; - this.bZ(); - } - - if (this.cd() && !this.bv && this.random.nextInt(100) == 0) { - this.a(false); - } - - this.bc = false; - if (this.target != null) { - this.a(this.target, 100.0F, 100.0F); - } - - if (!this.world.isStatic && this.isAlive()) { - if (this.target != null) { - if (this.target instanceof EntityHuman && this.f((EntityHuman) this.target)) { - if (this.target.f((Entity) this) < 16.0D) { - this.bZ(); - } - - this.bs = 0; - } else if (this.target.f((Entity) this) > 256.0D && this.bs++ >= 30 && this.c(this.target)) { - this.bs = 0; - } - } else { - this.a(false); - this.bs = 0; - } - } - - super.e(); - } - - protected boolean bZ() { - double d0 = this.locX + (this.random.nextDouble() - 0.5D) * 64.0D; - double d1 = this.locY + (double) (this.random.nextInt(64) - 32); - double d2 = this.locZ + (this.random.nextDouble() - 0.5D) * 64.0D; - - return this.k(d0, d1, d2); - } - - protected boolean c(Entity entity) { - Vec3D vec3d = Vec3D.a(this.locX - entity.locX, this.boundingBox.b + (double) (this.length / 2.0F) - entity.locY + (double) entity.getHeadHeight(), this.locZ - entity.locZ); - - vec3d = vec3d.a(); - double d0 = 16.0D; - double d1 = this.locX + (this.random.nextDouble() - 0.5D) * 8.0D - vec3d.a * d0; - double d2 = this.locY + (double) (this.random.nextInt(16) - 8) - vec3d.b * d0; - double d3 = this.locZ + (this.random.nextDouble() - 0.5D) * 8.0D - vec3d.c * d0; - - return this.k(d1, d2, d3); - } - - protected boolean k(double d0, double d1, double d2) { - double d3 = this.locX; - double d4 = this.locY; - double d5 = this.locZ; - - this.locX = d0; - this.locY = d1; - this.locZ = d2; - boolean flag = false; - int i = MathHelper.floor(this.locX); - int j = MathHelper.floor(this.locY); - int k = MathHelper.floor(this.locZ); - - if (this.world.isLoaded(i, j, k)) { - boolean flag1 = false; - - while (!flag1 && j > 0) { - Block block = this.world.getType(i, j - 1, k); - - if (block.getMaterial().isSolid()) { - flag1 = true; - } else { - --this.locY; - --j; - } - } - - if (flag1) { - // CraftBukkit start - Teleport event - EntityTeleportEvent teleport = new EntityTeleportEvent(this.getBukkitEntity(), new Location(this.world.getWorld(), d3, d4, d5), new Location(this.world.getWorld(), this.locX, this.locY, this.locZ)); - this.world.getServer().getPluginManager().callEvent(teleport); - if (teleport.isCancelled()) { - return false; - } - - Location to = teleport.getTo(); - this.setPosition(to.getX(), to.getY(), to.getZ()); - // CraftBukkit end - - if (this.world.getCubes(this, this.boundingBox).isEmpty() && !this.world.containsLiquid(this.boundingBox)) { - flag = true; - } - } - } - - if (!flag) { - this.setPosition(d3, d4, d5); - return false; - } else { - short short1 = 128; - - for (int l = 0; l < short1; ++l) { - double d6 = (double) l / ((double) short1 - 1.0D); - float f = (this.random.nextFloat() - 0.5F) * 0.2F; - float f1 = (this.random.nextFloat() - 0.5F) * 0.2F; - float f2 = (this.random.nextFloat() - 0.5F) * 0.2F; - double d7 = d3 + (this.locX - d3) * d6 + (this.random.nextDouble() - 0.5D) * (double) this.width * 2.0D; - double d8 = d4 + (this.locY - d4) * d6 + this.random.nextDouble() * (double) this.length; - double d9 = d5 + (this.locZ - d5) * d6 + (this.random.nextDouble() - 0.5D) * (double) this.width * 2.0D; - - this.world.addParticle("portal", d7, d8, d9, (double) f, (double) f1, (double) f2); - } - - this.world.makeSound(d3, d4, d5, "mob.endermen.portal", 1.0F, 1.0F); - this.makeSound("mob.endermen.portal", 1.0F, 1.0F); - return true; - } - } - - protected String t() { - return this.cd() ? "mob.endermen.scream" : "mob.endermen.idle"; - } - - protected String aT() { - return "mob.endermen.hit"; - } - - protected String aU() { - return "mob.endermen.death"; - } - - protected Item getLoot() { - return Items.ENDER_PEARL; - } - - protected void dropDeathLoot(boolean flag, int i) { - Item item = this.getLoot(); - - if (item != null) { - int j = this.random.nextInt(2 + i); - - for (int k = 0; k < j; ++k) { - this.a(item, 1); - } - } - } - - public void setCarried(Block block) { - this.datawatcher.watch(16, Byte.valueOf((byte) (Block.getId(block) & 255))); - } - - public Block getCarried() { - return Block.getById(this.datawatcher.getByte(16)); - } - - public void setCarriedData(int i) { - this.datawatcher.watch(17, Byte.valueOf((byte) (i & 255))); - } - - public int getCarriedData() { - return this.datawatcher.getByte(17); - } - - public boolean damageEntity(DamageSource damagesource, float f) { - if (this.isInvulnerable()) { - return false; - } else { - this.a(true); - if (damagesource instanceof EntityDamageSource && damagesource.getEntity() instanceof EntityHuman) { - this.bv = true; - } - - if (damagesource instanceof EntityDamageSourceIndirect) { - this.bv = false; - - for (int i = 0; i < 64; ++i) { - if (this.bZ()) { - return true; - } - } - - return false; - } else { - return super.damageEntity(damagesource, f); - } - } - } - - public boolean cd() { - return this.datawatcher.getByte(18) > 0; - } - - public void a(boolean flag) { - this.datawatcher.watch(18, Byte.valueOf((byte) (flag ? 1 : 0))); - } - - static { - br[Block.getId(Blocks.GRASS)] = true; - br[Block.getId(Blocks.DIRT)] = true; - br[Block.getId(Blocks.SAND)] = true; - br[Block.getId(Blocks.GRAVEL)] = true; - br[Block.getId(Blocks.YELLOW_FLOWER)] = true; - br[Block.getId(Blocks.RED_ROSE)] = true; - br[Block.getId(Blocks.BROWN_MUSHROOM)] = true; - br[Block.getId(Blocks.RED_MUSHROOM)] = true; - br[Block.getId(Blocks.TNT)] = true; - br[Block.getId(Blocks.CACTUS)] = true; - br[Block.getId(Blocks.CLAY)] = true; - br[Block.getId(Blocks.PUMPKIN)] = true; - br[Block.getId(Blocks.MELON)] = true; - br[Block.getId(Blocks.MYCEL)] = true; - } -} diff --git a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/EntityFallingBlock.java b/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/EntityFallingBlock.java deleted file mode 100644 index 93bf96bc9..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/EntityFallingBlock.java +++ /dev/null @@ -1,246 +0,0 @@ -package net.minecraft.server.v1_7_R4; - -import java.util.ArrayList; -import java.util.Iterator; - -import org.bukkit.craftbukkit.v1_7_R4.event.CraftEventFactory; // CraftBukkit -import org.bukkit.event.entity.EntityDamageEvent; - -public class EntityFallingBlock extends Entity { - - public Block id; // CraftBukkit - private -> public - public int data; - public int ticksLived; - public boolean dropItem; - private boolean f; - private boolean hurtEntities; - private int fallHurtMax; - private float fallHurtAmount; - public NBTTagCompound tileEntityData; - - public boolean spectating; - - public EntityFallingBlock(World world) { - super(world); - this.dropItem = true; - this.fallHurtMax = 40; - this.fallHurtAmount = 2.0F; - } - - public EntityFallingBlock(World world, double d0, double d1, double d2, Block block) { - this(world, d0, d1, d2, block, 0); - } - - public EntityFallingBlock(World world, double d0, double d1, double d2, Block block, int i) { - super(world); - this.dropItem = true; - this.fallHurtMax = 40; - this.fallHurtAmount = 2.0F; - this.id = block; - this.data = i; - this.k = true; - this.a(0.98F, 0.98F); - this.height = this.length / 2.0F; - this.setPosition(d0, d1, d2); - this.motX = 0.0D; - this.motY = 0.0D; - this.motZ = 0.0D; - this.lastX = d0; - this.lastY = d1; - this.lastZ = d2; - } - - protected boolean g_() { - return false; - } - - protected void c() {} - - public boolean R() { - return !this.dead && !spectating; - } - - @Override - public boolean damageEntity(DamageSource damagesource, float f) - { - CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f); - - return true; - } - - public void h() { - if (this.id.getMaterial() == Material.AIR) { - this.die(); - } else { - this.lastX = this.locX; - this.lastY = this.locY; - this.lastZ = this.locZ; - ++this.ticksLived; - this.motY -= 0.03999999910593033D; - this.move(this.motX, this.motY, this.motZ); - this.motX *= 0.9800000190734863D; - this.motY *= 0.9800000190734863D; - this.motZ *= 0.9800000190734863D; - if (!this.world.isStatic) { - int i = MathHelper.floor(this.locX); - int j = MathHelper.floor(this.locY); - int k = MathHelper.floor(this.locZ); - - if (this.ticksLived == 1) { - // CraftBukkit - compare data and call event - if (this.ticksLived != 1 || this.world.getType(i, j, k) != this.id || this.world.getData(i, j, k) != this.data || CraftEventFactory.callEntityChangeBlockEvent(this, i, j, k, Blocks.AIR, 0).isCancelled()) { - this.die(); - return; - } - - this.world.setAir(i, j, k); - world.spigotConfig.antiXrayInstance.updateNearbyBlocks(world, i, j, k); // Spigot - } - - if (this.onGround) { - this.motX *= 0.699999988079071D; - this.motZ *= 0.699999988079071D; - this.motY *= -0.5D; - if (this.world.getType(i, j, k) != Blocks.PISTON_MOVING) { - this.die(); - // CraftBukkit start - fire EntityChangeBlockEvent - if (!this.f && this.world.mayPlace(this.id, i, j, k, true, 1, (Entity) null, (ItemStack) null) && !BlockFalling.canFall(this.world, i, j - 1, k) /* mimic the false conditions of setTypeIdAndData */ && i >= -30000000 && k >= -30000000 && i < 30000000 && k < 30000000 && j > 0 && j < 256 && !(this.world.getType(i, j, k) == this.id && this.world.getData(i, j, k) == this.data)) { - if (CraftEventFactory.callEntityChangeBlockEvent(this, i, j, k, this.id, this.data).isCancelled()) { - return; - } - this.world.setTypeAndData(i, j, k, this.id, this.data, 3); - // CraftBukkit end - world.spigotConfig.antiXrayInstance.updateNearbyBlocks(world, i, j, k); // Spigot - - if (this.id instanceof BlockFalling) { - ((BlockFalling) this.id).a(this.world, i, j, k, this.data); - } - - if (this.tileEntityData != null && this.id instanceof IContainer) { - TileEntity tileentity = this.world.getTileEntity(i, j, k); - - if (tileentity != null) { - NBTTagCompound nbttagcompound = new NBTTagCompound(); - - tileentity.b(nbttagcompound); - Iterator iterator = this.tileEntityData.c().iterator(); - - while (iterator.hasNext()) { - String s = (String) iterator.next(); - NBTBase nbtbase = this.tileEntityData.get(s); - - if (!s.equals("x") && !s.equals("y") && !s.equals("z")) { - nbttagcompound.set(s, nbtbase.clone()); - } - } - - tileentity.a(nbttagcompound); - tileentity.update(); - } - } - } else if (this.dropItem && !this.f) { - this.a(new ItemStack(this.id, 1, this.id.getDropData(this.data)), 0.0F); - } - } - } else if (this.ticksLived > 100 && !this.world.isStatic && (j < 1 || j > 256) || this.ticksLived > 600) { - if (this.dropItem) { - this.a(new ItemStack(this.id, 1, this.id.getDropData(this.data)), 0.0F); - } - - this.die(); - } - } - } - } - - protected void b(float f) { - if (this.hurtEntities) { - int i = MathHelper.f(f - 1.0F); - - if (i > 0) { - ArrayList arraylist = new ArrayList(this.world.getEntities(this, this.boundingBox)); - boolean flag = this.id == Blocks.ANVIL; - DamageSource damagesource = flag ? DamageSource.ANVIL : DamageSource.FALLING_BLOCK; - Iterator iterator = arraylist.iterator(); - - while (iterator.hasNext()) { - Entity entity = (Entity) iterator.next(); - - CraftEventFactory.entityDamage = this; // CraftBukkit - entity.damageEntity(damagesource, (float) Math.min(MathHelper.d((float) i * this.fallHurtAmount), this.fallHurtMax)); - CraftEventFactory.entityDamage = null; // CraftBukkit - } - - if (flag && (double) this.random.nextFloat() < 0.05000000074505806D + (double) i * 0.05D) { - int j = this.data >> 2; - int k = this.data & 3; - - ++j; - if (j > 2) { - this.f = true; - } else { - this.data = k | j << 2; - } - } - } - } - } - - protected void b(NBTTagCompound nbttagcompound) { - nbttagcompound.setByte("Tile", (byte) Block.getId(this.id)); - nbttagcompound.setInt("TileID", Block.getId(this.id)); - nbttagcompound.setByte("Data", (byte) this.data); - nbttagcompound.setByte("Time", (byte) this.ticksLived); - nbttagcompound.setBoolean("DropItem", this.dropItem); - nbttagcompound.setBoolean("HurtEntities", this.hurtEntities); - nbttagcompound.setFloat("FallHurtAmount", this.fallHurtAmount); - nbttagcompound.setInt("FallHurtMax", this.fallHurtMax); - if (this.tileEntityData != null) { - nbttagcompound.set("TileEntityData", this.tileEntityData); - } - } - - protected void a(NBTTagCompound nbttagcompound) { - if (nbttagcompound.hasKeyOfType("TileID", 99)) { - this.id = Block.getById(nbttagcompound.getInt("TileID")); - } else { - this.id = Block.getById(nbttagcompound.getByte("Tile") & 255); - } - - this.data = nbttagcompound.getByte("Data") & 255; - this.ticksLived = nbttagcompound.getByte("Time") & 255; - if (nbttagcompound.hasKeyOfType("HurtEntities", 99)) { - this.hurtEntities = nbttagcompound.getBoolean("HurtEntities"); - this.fallHurtAmount = nbttagcompound.getFloat("FallHurtAmount"); - this.fallHurtMax = nbttagcompound.getInt("FallHurtMax"); - } else if (this.id == Blocks.ANVIL) { - this.hurtEntities = true; - } - - if (nbttagcompound.hasKeyOfType("DropItem", 99)) { - this.dropItem = nbttagcompound.getBoolean("DropItem"); - } - - if (nbttagcompound.hasKeyOfType("TileEntityData", 10)) { - this.tileEntityData = nbttagcompound.getCompound("TileEntityData"); - } - - if (this.id.getMaterial() == Material.AIR) { - this.id = Blocks.SAND; - } - } - - public void a(boolean flag) { - this.hurtEntities = flag; - } - - public void a(CrashReportSystemDetails crashreportsystemdetails) { - super.a(crashreportsystemdetails); - crashreportsystemdetails.a("Immitating block ID", Integer.valueOf(Block.getId(this.id))); - crashreportsystemdetails.a("Immitating block data", Integer.valueOf(this.data)); - } - - public Block f() { - return this.id; - } -} diff --git a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/EntityGhast.java b/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/EntityGhast.java deleted file mode 100644 index b1712444b..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/EntityGhast.java +++ /dev/null @@ -1,257 +0,0 @@ -package net.minecraft.server.v1_7_R4; - -// CraftBukkit start -import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity; -import org.bukkit.event.entity.EntityTargetEvent; -// CraftBukkit end - -public class EntityGhast extends EntityFlying implements IMonster { - - public int h; - public double i; - public double bm; - public double bn; - private Entity target; - private int br; - public int bo; - public int bp; - private int explosionPower = 1; - - public EntityGhast(World world) { - super(world); - this.a(4.0F, 4.0F); - this.fireProof = true; - this.b = 5; - } - - public boolean damageEntity(DamageSource damagesource, float f) { - if (this.isInvulnerable()) { - return false; - } else if ("fireball".equals(damagesource.p()) && damagesource.getEntity() instanceof EntityHuman) { - super.damageEntity(damagesource, 1000.0F); - ((EntityHuman) damagesource.getEntity()).a((Statistic) AchievementList.z); - return true; - } else { - return super.damageEntity(damagesource, f); - } - } - - protected void c() { - super.c(); - this.datawatcher.a(16, Byte.valueOf((byte) 0)); - } - - protected void aD() { - super.aD(); - this.getAttributeInstance(GenericAttributes.maxHealth).setValue(10.0D); - } - - protected void bq() { - if (!this.world.isStatic && this.world.difficulty == EnumDifficulty.PEACEFUL) { - this.die(); - } - - if (Vegetated) - { - double d0 = this.i - this.locX; - double d1 = this.bm - this.locY; - double d2 = this.bn - this.locZ; - double d3 = d0 * d0 + d1 * d1 + d2 * d2; - - this.motX += d0 / d3 * 0.1D; - this.motY += d1 / d3 * 0.1D; - this.motZ += d2 / d3 * 0.1D; - - double d5 = this.i - this.locX; - double d6 = this.bn - this.locZ; - - this.aN = this.yaw = -((float) Math.atan2(d5, d6)) * 180.0F / 3.1415927F; - - return; - } - - this.w(); - this.bo = this.bp; - double d0 = this.i - this.locX; - double d1 = this.bm - this.locY; - double d2 = this.bn - this.locZ; - double d3 = d0 * d0 + d1 * d1 + d2 * d2; - - if (d3 < 1.0D || d3 > 3600.0D) { - this.i = this.locX + (double) ((this.random.nextFloat() * 2.0F - 1.0F) * 16.0F); - this.bm = this.locY + (double) ((this.random.nextFloat() * 2.0F - 1.0F) * 16.0F); - this.bn = this.locZ + (double) ((this.random.nextFloat() * 2.0F - 1.0F) * 16.0F); - } - - if (this.h-- <= 0) { - this.h += this.random.nextInt(5) + 2; - d3 = (double) MathHelper.sqrt(d3); - if (this.a(this.i, this.bm, this.bn, d3)) { - this.motX += d0 / d3 * 0.1D; - this.motY += d1 / d3 * 0.1D; - this.motZ += d2 / d3 * 0.1D; - } else { - this.i = this.locX; - this.bm = this.locY; - this.bn = this.locZ; - } - } - - if (this.target != null && this.target.dead) { - // CraftBukkit start - fire EntityTargetEvent - EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), null, EntityTargetEvent.TargetReason.TARGET_DIED); - this.world.getServer().getPluginManager().callEvent(event); - - if (!event.isCancelled()) { - if (event.getTarget() == null) { - this.target = null; - } else { - this.target = ((CraftEntity) event.getTarget()).getHandle(); - } - } - // CraftBukkit end - } - - if (this.target == null || this.br-- <= 0) { - // CraftBukkit start - fire EntityTargetEvent - Entity target = this.world.findNearbyVulnerablePlayer(this, 100.0D); - if (target != null) { - EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), target.getBukkitEntity(), EntityTargetEvent.TargetReason.CLOSEST_PLAYER); - this.world.getServer().getPluginManager().callEvent(event); - - if (!event.isCancelled()) { - if (event.getTarget() == null) { - this.target = null; - } else { - this.target = ((CraftEntity) event.getTarget()).getHandle(); - } - } - } - // CraftBukkit end - - if (this.target != null) { - this.br = 20; - } - } - - double d4 = 64.0D; - - if (this.target != null && this.target.f((Entity) this) < d4 * d4) { - double d5 = this.target.locX - this.locX; - double d6 = this.target.boundingBox.b + (double) (this.target.length / 2.0F) - (this.locY + (double) (this.length / 2.0F)); - double d7 = this.target.locZ - this.locZ; - - this.aM = this.yaw = -((float) Math.atan2(d5, d7)) * 180.0F / 3.1415927F; - if (this.hasLineOfSight(this.target)) { - if (this.bp == 10) { - this.world.a((EntityHuman) null, 1007, (int) this.locX, (int) this.locY, (int) this.locZ, 0); - } - - ++this.bp; - if (this.bp == 20) { - this.world.a((EntityHuman) null, 1008, (int) this.locX, (int) this.locY, (int) this.locZ, 0); - EntityLargeFireball entitylargefireball = new EntityLargeFireball(this.world, this, d5, d6, d7); - - // CraftBukkit - set bukkitYield when setting explosionpower - entitylargefireball.bukkitYield = entitylargefireball.yield = this.explosionPower; - double d8 = 4.0D; - Vec3D vec3d = this.j(1.0F); - - entitylargefireball.locX = this.locX + vec3d.a * d8; - entitylargefireball.locY = this.locY + (double) (this.length / 2.0F) + 0.5D; - entitylargefireball.locZ = this.locZ + vec3d.c * d8; - this.world.addEntity(entitylargefireball); - this.bp = -40; - } - } else if (this.bp > 0) { - --this.bp; - } - } else { - this.aM = this.yaw = -((float) Math.atan2(this.motX, this.motZ)) * 180.0F / 3.1415927F; - if (this.bp > 0) { - --this.bp; - } - } - - if (!this.world.isStatic) { - byte b0 = this.datawatcher.getByte(16); - byte b1 = (byte) (this.bp > 10 ? 1 : 0); - - if (b0 != b1) { - this.datawatcher.watch(16, Byte.valueOf(b1)); - } - } - } - - private boolean a(double d0, double d1, double d2, double d3) { - double d4 = (this.i - this.locX) / d3; - double d5 = (this.bm - this.locY) / d3; - double d6 = (this.bn - this.locZ) / d3; - AxisAlignedBB axisalignedbb = this.boundingBox.clone(); - - for (int i = 1; (double) i < d3; ++i) { - axisalignedbb.d(d4, d5, d6); - if (!this.world.getCubes(this, axisalignedbb).isEmpty()) { - return false; - } - } - - return true; - } - - protected String t() { - return "mob.ghast.moan"; - } - - protected String aT() { - return "mob.ghast.scream"; - } - - protected String aU() { - return "mob.ghast.death"; - } - - protected Item getLoot() { - return Items.SULPHUR; - } - - protected void dropDeathLoot(boolean flag, int i) { - int j = this.random.nextInt(2) + this.random.nextInt(1 + i); - - int k; - - for (k = 0; k < j; ++k) { - this.a(Items.GHAST_TEAR, 1); - } - - j = this.random.nextInt(3) + this.random.nextInt(1 + i); - - for (k = 0; k < j; ++k) { - this.a(Items.SULPHUR, 1); - } - } - - protected float bf() { - return 10.0F; - } - - public boolean canSpawn() { - return this.random.nextInt(20) == 0 && super.canSpawn() && this.world.difficulty != EnumDifficulty.PEACEFUL; - } - - public int bB() { - return 1; - } - - public void b(NBTTagCompound nbttagcompound) { - super.b(nbttagcompound); - nbttagcompound.setInt("ExplosionPower", this.explosionPower); - } - - public void a(NBTTagCompound nbttagcompound) { - super.a(nbttagcompound); - if (nbttagcompound.hasKeyOfType("ExplosionPower", 99)) { - this.explosionPower = nbttagcompound.getInt("ExplosionPower"); - } - } -} diff --git a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/EntityHorse.java b/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/EntityHorse.java deleted file mode 100644 index 7452234fb..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/EntityHorse.java +++ /dev/null @@ -1,1237 +0,0 @@ -package net.minecraft.server.v1_7_R4; - -import java.util.Iterator; -import java.util.List; - -import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; // CraftBukkit - -public class EntityHorse extends EntityAnimal implements IInventoryListener { - - private static final IEntitySelector bu = new EntitySelectorHorse(); - public static final IAttribute attributeJumpStrength = (new AttributeRanged("horse.jumpStrength", 0.7D, 0.0D, 2.0D)).a("Jump Strength").a(true); // CraftBukkit - private -> public - private static final String[] bw = new String[] { null, "textures/entity/horse/armor/horse_armor_iron.png", "textures/entity/horse/armor/horse_armor_gold.png", "textures/entity/horse/armor/horse_armor_diamond.png"}; - private static final String[] bx = new String[] { "", "meo", "goo", "dio"}; - private static final int[] by = new int[] { 0, 5, 7, 11}; - private static final String[] bz = new String[] { "textures/entity/horse/horse_white.png", "textures/entity/horse/horse_creamy.png", "textures/entity/horse/horse_chestnut.png", "textures/entity/horse/horse_brown.png", "textures/entity/horse/horse_black.png", "textures/entity/horse/horse_gray.png", "textures/entity/horse/horse_darkbrown.png"}; - private static final String[] bA = new String[] { "hwh", "hcr", "hch", "hbr", "hbl", "hgr", "hdb"}; - private static final String[] bB = new String[] { null, "textures/entity/horse/horse_markings_white.png", "textures/entity/horse/horse_markings_whitefield.png", "textures/entity/horse/horse_markings_whitedots.png", "textures/entity/horse/horse_markings_blackdots.png"}; - private static final String[] bC = new String[] { "", "wo_", "wmo", "wdo", "bdo"}; - private int bD; - private int bE; - private int bF; - public int bp; - public int bq; - protected boolean br; - public InventoryHorseChest inventoryChest; // CraftBukkit - private -> public - private boolean bH; - protected int bs; - protected float bt; - private boolean bI; - private float bJ; - private float bK; - private float bL; - private float bM; - private float bN; - private float bO; - private int bP; - private String bQ; - private String[] bR = new String[3]; - public int maxDomestication = 100; // CraftBukkit - store max domestication value - - public EntityHorse(World world) { - super(world); - this.a(1.4F, 1.6F); - this.fireProof = false; - this.setHasChest(false); - this.getNavigation().a(true); - this.goalSelector.a(0, new PathfinderGoalFloat(this)); - this.goalSelector.a(1, new PathfinderGoalPanic(this, 1.2D)); - this.goalSelector.a(1, new PathfinderGoalTame(this, 1.2D)); - this.goalSelector.a(2, new PathfinderGoalBreed(this, 1.0D)); - this.goalSelector.a(4, new PathfinderGoalFollowParent(this, 1.0D)); - this.goalSelector.a(6, new PathfinderGoalRandomStroll(this, 0.7D)); - this.goalSelector.a(7, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 6.0F)); - this.goalSelector.a(8, new PathfinderGoalRandomLookaround(this)); - this.loadChest(); - } - - protected void c() { - super.c(); - this.datawatcher.a(16, Integer.valueOf(0)); - this.datawatcher.a(19, Byte.valueOf((byte) 0)); - this.datawatcher.a(20, Integer.valueOf(0)); - this.datawatcher.a(21, String.valueOf("")); - this.datawatcher.a(22, Integer.valueOf(0)); - } - - public void setType(int i) { - this.datawatcher.watch(19, Byte.valueOf((byte) i)); - this.cP(); - } - - public int getType() { - return this.datawatcher.getByte(19); - } - - public void setVariant(int i) { - this.datawatcher.watch(20, Integer.valueOf(i)); - this.cP(); - } - - public int getVariant() { - return this.datawatcher.getInt(20); - } - - public String getName() { - if (this.hasCustomName()) { - return this.getCustomName(); - } else { - int i = this.getType(); - - switch (i) { - case 0: - default: - return LocaleI18n.get("entity.horse.name"); - - case 1: - return LocaleI18n.get("entity.donkey.name"); - - case 2: - return LocaleI18n.get("entity.mule.name"); - - case 3: - return LocaleI18n.get("entity.zombiehorse.name"); - - case 4: - return LocaleI18n.get("entity.skeletonhorse.name"); - } - } - } - - private boolean x(int i) { - return (this.datawatcher.getInt(16) & i) != 0; - } - - 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 { - this.datawatcher.watch(16, Integer.valueOf(j & ~i)); - } - } - - public boolean cb() { - return !this.isBaby(); - } - - public boolean isTame() { - return this.x(2); - } - - public boolean cg() { - return this.cb(); - } - - public String getOwnerUUID() { - return this.datawatcher.getString(21); - } - - public void setOwnerUUID(String s) { - this.datawatcher.watch(21, s); - } - - public float ci() { - int i = this.getAge(); - - return i >= 0 ? 1.0F : 0.5F + (float) (-24000 - i) / -24000.0F * 0.5F; - } - - public void a(boolean flag) { - if (flag) { - this.a(this.ci()); - } else { - this.a(1.0F); - } - } - - public boolean cj() { - return this.br; - } - - public void setTame(boolean flag) { - this.b(2, flag); - } - - public void j(boolean flag) { - this.br = flag; - } - - public boolean bM() { - return !this.cE() && super.bM(); - } - - protected void o(float f) { - if (f > 6.0F && this.cm()) { - this.o(false); - } - } - - public boolean hasChest() { - return this.x(8); - } - - public int cl() { - return this.datawatcher.getInt(22); - } - - private int e(ItemStack itemstack) { - if (itemstack == null) { - return 0; - } else { - Item item = itemstack.getItem(); - - return item == Items.HORSE_ARMOR_IRON ? 1 : (item == Items.HORSE_ARMOR_GOLD ? 2 : (item == Items.HORSE_ARMOR_DIAMOND ? 3 : 0)); - } - } - - public boolean cm() { - return this.x(32); - } - - public boolean cn() { - return this.x(64); - } - - public boolean co() { - return this.x(16); - } - - public boolean cp() { - return this.bH; - } - - public void d(ItemStack itemstack) { - this.datawatcher.watch(22, Integer.valueOf(this.e(itemstack))); - this.cP(); - } - - public void k(boolean flag) { - this.b(16, flag); - } - - public void setHasChest(boolean flag) { - this.b(8, flag); - } - - public void m(boolean flag) { - this.bH = flag; - } - - public void n(boolean flag) { - this.b(4, flag); - } - - public int getTemper() { - return this.bs; - } - - public void setTemper(int i) { - this.bs = i; - } - - public int v(int i) { - int j = MathHelper.a(this.getTemper() + i, 0, this.getMaxDomestication()); - - this.setTemper(j); - return j; - } - - public boolean damageEntity(DamageSource damagesource, float f) { - Entity entity = damagesource.getEntity(); - - return this.passenger != null && this.passenger.equals(entity) ? false : super.damageEntity(damagesource, f); - } - - public int aV() { - return by[this.cl()]; - } - - public boolean S() { - return this.passenger == null; - } - - public boolean cr() { - int i = MathHelper.floor(this.locX); - int j = MathHelper.floor(this.locZ); - - this.world.getBiome(i, j); - return true; - } - - public void cs() { - if (!this.world.isStatic && this.hasChest()) { - this.a(Item.getItemOf(Blocks.CHEST), 1); - this.setHasChest(false); - } - } - - private void cL() { - this.cS(); - this.world.makeSound(this, "eating", 1.0F, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.2F); - } - - protected void b(float f) { - if (f > 1.0F) { - this.makeSound("mob.horse.land", 0.4F, 1.0F); - } - - int i = MathHelper.f(f * 0.5F - 3.0F); - - if (i > 0) { - this.damageEntity(DamageSource.FALL, (float) i); - if (this.passenger != null) { - this.passenger.damageEntity(DamageSource.FALL, (float) i); - } - - Block block = this.world.getType(MathHelper.floor(this.locX), MathHelper.floor(this.locY - 0.2D - (double) this.lastYaw), MathHelper.floor(this.locZ)); - - if (block.getMaterial() != Material.AIR) { - StepSound stepsound = block.stepSound; - - this.world.makeSound(this, stepsound.getStepSound(), stepsound.getVolume1() * 0.5F, stepsound.getVolume2() * 0.75F); - } - } - } - - private int cM() { - int i = this.getType(); - - return this.hasChest() /* && (i == 1 || i == 2) */ ? 17 : 2; // CraftBukkit - Remove type check - } - - public void loadChest() { // CraftBukkit - private -> public - InventoryHorseChest inventoryhorsechest = this.inventoryChest; - - this.inventoryChest = new InventoryHorseChest("HorseChest", this.cM(), this); // CraftBukkit - add this horse - this.inventoryChest.a(this.getName()); - if (inventoryhorsechest != null) { - inventoryhorsechest.b(this); - int i = Math.min(inventoryhorsechest.getSize(), this.inventoryChest.getSize()); - - for (int j = 0; j < i; ++j) { - ItemStack itemstack = inventoryhorsechest.getItem(j); - - if (itemstack != null) { - this.inventoryChest.setItem(j, itemstack.cloneItemStack()); - } - } - - inventoryhorsechest = null; - } - - this.inventoryChest.a(this); - this.cO(); - } - - private void cO() { - if (!this.world.isStatic) { - this.n(this.inventoryChest.getItem(0) != null); - if (this.cB()) { - this.d(this.inventoryChest.getItem(1)); - } - } - } - - public void a(InventorySubcontainer inventorysubcontainer) { - int i = this.cl(); - boolean flag = this.cu(); - - this.cO(); - if (this.ticksLived > 20) { - if (i == 0 && i != this.cl()) { - this.makeSound("mob.horse.armor", 0.5F, 1.0F); - } else if (i != this.cl()) { - this.makeSound("mob.horse.armor", 0.5F, 1.0F); - } - - if (!flag && this.cu()) { - this.makeSound("mob.horse.leather", 0.5F, 1.0F); - } - } - } - - public boolean canSpawn() { - this.cr(); - return super.canSpawn(); - } - - protected EntityHorse a(Entity entity, double d0) { - double d1 = Double.MAX_VALUE; - Entity entity1 = null; - List list = this.world.getEntities(entity, entity.boundingBox.a(d0, d0, d0), bu); - Iterator iterator = list.iterator(); - - while (iterator.hasNext()) { - Entity entity2 = (Entity) iterator.next(); - double d2 = entity2.e(entity.locX, entity.locY, entity.locZ); - - if (d2 < d1) { - entity1 = entity2; - d1 = d2; - } - } - - return (EntityHorse) entity1; - } - - public double getJumpStrength() { - return this.getAttributeInstance(attributeJumpStrength).getValue(); - } - - protected String aU() { - this.cS(); - int i = this.getType(); - - return i == 3 ? "mob.horse.zombie.death" : (i == 4 ? "mob.horse.skeleton.death" : (i != 1 && i != 2 ? "mob.horse.death" : "mob.horse.donkey.death")); - } - - protected Item getLoot() { - boolean flag = this.random.nextInt(4) == 0; - int i = this.getType(); - - return i == 4 ? Items.BONE : (i == 3 ? (flag ? Item.getById(0) : Items.ROTTEN_FLESH) : Items.LEATHER); - } - - protected String aT() { - this.cS(); - if (this.random.nextInt(3) == 0) { - this.cU(); - } - - int i = this.getType(); - - return i == 3 ? "mob.horse.zombie.hit" : (i == 4 ? "mob.horse.skeleton.hit" : (i != 1 && i != 2 ? "mob.horse.hit" : "mob.horse.donkey.hit")); - } - - public boolean cu() { - return this.x(4); - } - - protected String t() { - this.cS(); - if (this.random.nextInt(10) == 0 && !this.bh()) { - this.cU(); - } - - int i = this.getType(); - - return i == 3 ? "mob.horse.zombie.idle" : (i == 4 ? "mob.horse.skeleton.idle" : (i != 1 && i != 2 ? "mob.horse.idle" : "mob.horse.donkey.idle")); - } - - protected String cv() { - this.cS(); - this.cU(); - int i = this.getType(); - - return i != 3 && i != 4 ? (i != 1 && i != 2 ? "mob.horse.angry" : "mob.horse.donkey.angry") : null; - } - - protected void a(int i, int j, int k, Block block) { - StepSound stepsound = block.stepSound; - - if (this.world.getType(i, j + 1, k) == Blocks.SNOW) { - stepsound = Blocks.SNOW.stepSound; - } - - if (!block.getMaterial().isLiquid()) { - int l = this.getType(); - - if (this.passenger != null && l != 1 && l != 2) { - ++this.bP; - if (this.bP > 5 && this.bP % 3 == 0) { - this.makeSound("mob.horse.gallop", stepsound.getVolume1() * 0.15F, stepsound.getVolume2()); - if (l == 0 && this.random.nextInt(10) == 0) { - this.makeSound("mob.horse.breathe", stepsound.getVolume1() * 0.6F, stepsound.getVolume2()); - } - } else if (this.bP <= 5) { - this.makeSound("mob.horse.wood", stepsound.getVolume1() * 0.15F, stepsound.getVolume2()); - } - } else if (stepsound == Block.f) { - this.makeSound("mob.horse.wood", stepsound.getVolume1() * 0.15F, stepsound.getVolume2()); - } else { - this.makeSound("mob.horse.soft", stepsound.getVolume1() * 0.15F, stepsound.getVolume2()); - } - } - } - - protected void aD() { - super.aD(); - this.getAttributeMap().b(attributeJumpStrength); - this.getAttributeInstance(GenericAttributes.maxHealth).setValue(53.0D); - this.getAttributeInstance(GenericAttributes.d).setValue(0.22499999403953552D); - } - - public int bB() { - return 6; - } - - public int getMaxDomestication() { - return this.maxDomestication; // CraftBukkit - return stored max domestication instead of 100 - } - - protected float bf() { - return 0.8F; - } - - public int q() { - return 400; - } - - private void cP() { - this.bQ = null; - } - - public void g(EntityHuman entityhuman) { - if (!this.world.isStatic && (this.passenger == null || this.passenger == entityhuman) && this.isTame()) { - this.inventoryChest.a(this.getName()); - entityhuman.openHorseInventory(this, this.inventoryChest); - } - } - - public boolean a(EntityHuman entityhuman) { - ItemStack itemstack = entityhuman.inventory.getItemInHand(); - - if (itemstack != null && itemstack.getItem() == Items.MONSTER_EGG) { - return super.a(entityhuman); - } else if (!this.isTame() && this.cE()) { - return false; - } else if (this.isTame() && this.cb() && entityhuman.isSneaking()) { - this.g(entityhuman); - return true; - } else if (this.cg() && this.passenger != null) { - return super.a(entityhuman); - } else { - if (itemstack != null) { - boolean flag = false; - - if (this.cB()) { - byte b0 = -1; - - if (itemstack.getItem() == Items.HORSE_ARMOR_IRON) { - b0 = 1; - } else if (itemstack.getItem() == Items.HORSE_ARMOR_GOLD) { - b0 = 2; - } else if (itemstack.getItem() == Items.HORSE_ARMOR_DIAMOND) { - b0 = 3; - } - - if (b0 >= 0) { - if (!this.isTame()) { - this.cJ(); - return true; - } - - this.g(entityhuman); - return true; - } - } - - if (!flag && !this.cE()) { - float f = 0.0F; - short short1 = 0; - byte b1 = 0; - - if (itemstack.getItem() == Items.WHEAT) { - f = 2.0F; - short1 = 60; - b1 = 3; - } else if (itemstack.getItem() == Items.SUGAR) { - f = 1.0F; - short1 = 30; - b1 = 3; - } else if (itemstack.getItem() == Items.BREAD) { - f = 7.0F; - short1 = 180; - b1 = 3; - } else if (Block.a(itemstack.getItem()) == Blocks.HAY_BLOCK) { - f = 20.0F; - short1 = 180; - } else if (itemstack.getItem() == Items.APPLE) { - f = 3.0F; - short1 = 60; - b1 = 3; - } else if (itemstack.getItem() == Items.CARROT_GOLDEN) { - f = 4.0F; - short1 = 60; - b1 = 5; - if (this.isTame() && this.getAge() == 0) { - flag = true; - this.f(entityhuman); - } - } else if (itemstack.getItem() == Items.GOLDEN_APPLE) { - f = 10.0F; - short1 = 240; - b1 = 10; - if (this.isTame() && this.getAge() == 0) { - flag = true; - this.f(entityhuman); - } - } - - if (this.getHealth() < this.getMaxHealth() && f > 0.0F) { - this.heal(f, RegainReason.EATING); // CraftBukkit - flag = true; - } - - if (!this.cb() && short1 > 0) { - this.a(short1); - flag = true; - } - - if (b1 > 0 && (flag || !this.isTame()) && b1 < this.getMaxDomestication()) { - flag = true; - this.v(b1); - } - - if (flag) { - this.cL(); - } - } - - if (!this.isTame() && !flag) { - if (itemstack != null && itemstack.a(entityhuman, (EntityLiving) this)) { - return true; - } - - this.cJ(); - return true; - } - - if (!flag && this.cC() && !this.hasChest() && itemstack.getItem() == Item.getItemOf(Blocks.CHEST)) { - this.setHasChest(true); - this.makeSound("mob.chickenplop", 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); - flag = true; - this.loadChest(); - } - - if (!flag && this.cg() && !this.cu() && itemstack.getItem() == Items.SADDLE) { - this.g(entityhuman); - return true; - } - - if (flag) { - if (!entityhuman.abilities.canInstantlyBuild && --itemstack.count == 0) { - entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, (ItemStack) null); - } - - return true; - } - } - - if (this.cg() && this.passenger == null) { - if (itemstack != null && itemstack.a(entityhuman, (EntityLiving) this)) { - return true; - } else { - this.i(entityhuman); - return true; - } - } else { - return super.a(entityhuman); - } - } - } - - private void i(EntityHuman entityhuman) { - entityhuman.yaw = this.yaw; - entityhuman.pitch = this.pitch; - this.o(false); - this.p(false); - if (!this.world.isStatic) { - entityhuman.mount(this); - } - } - - public boolean cB() { - return this.getType() == 0; - } - - public boolean cC() { - int i = this.getType(); - - return i == 2 || i == 1; - } - - protected boolean bh() { - return this.passenger != null && this.cu() ? true : this.cm() || this.cn(); - } - - public boolean cE() { - int i = this.getType(); - - return i == 3 || i == 4; - } - - public boolean cF() { - return this.cE() || this.getType() == 2; - } - - public boolean c(ItemStack itemstack) { - return false; - } - - private void cR() { - this.bp = 1; - } - - public void die(DamageSource damagesource) { - super.die(damagesource); - /* CraftBukkit start - Handle chest dropping in dropDeathLoot below - if (!this.world.isStatic) { - this.dropChest(); - } - // CraftBukkit end */ - } - - // CraftBukkit start - Add method - protected void dropDeathLoot(boolean flag, int i) { - super.dropDeathLoot(flag, i); - - // Moved from die method above - if (!this.world.isStatic) { - this.dropChest(); - } - } - // CraftBukkit end - - public void e() { - if (this.random.nextInt(200) == 0) { - this.cR(); - } - - super.e(); - if (!this.world.isStatic) { - if (this.random.nextInt(900) == 0 && this.deathTicks == 0) { - this.heal(1.0F, RegainReason.REGEN); // CraftBukkit - } - - if (!this.cm() && this.passenger == null && this.random.nextInt(300) == 0 && this.world.getType(MathHelper.floor(this.locX), MathHelper.floor(this.locY) - 1, MathHelper.floor(this.locZ)) == Blocks.GRASS) { - this.o(true); - } - - if (this.cm() && ++this.bD > 50) { - this.bD = 0; - this.o(false); - } - - if (this.co() && !this.cb() && !this.cm()) { - EntityHorse entityhorse = this.a(this, 16.0D); - - if (entityhorse != null && this.f(entityhorse) > 4.0D) { - PathEntity pathentity = this.world.findPath(this, entityhorse, 16.0F, true, false, false, true); - - this.setPathEntity(pathentity); - } - } - } - } - - public void h() { - super.h(); - if (this.world.isStatic && this.datawatcher.a()) { - this.datawatcher.e(); - this.cP(); - } - - if (this.bE > 0 && ++this.bE > 30) { - this.bE = 0; - this.b(128, false); - } - - if (!this.world.isStatic && this.bF > 0 && ++this.bF > 20) { - this.bF = 0; - this.p(false); - } - - if (this.bp > 0 && ++this.bp > 8) { - this.bp = 0; - } - - if (this.bq > 0) { - ++this.bq; - if (this.bq > 300) { - this.bq = 0; - } - } - - this.bK = this.bJ; - if (this.cm()) { - this.bJ += (1.0F - this.bJ) * 0.4F + 0.05F; - if (this.bJ > 1.0F) { - this.bJ = 1.0F; - } - } else { - this.bJ += (0.0F - this.bJ) * 0.4F - 0.05F; - if (this.bJ < 0.0F) { - this.bJ = 0.0F; - } - } - - this.bM = this.bL; - if (this.cn()) { - this.bK = this.bJ = 0.0F; - this.bL += (1.0F - this.bL) * 0.4F + 0.05F; - if (this.bL > 1.0F) { - this.bL = 1.0F; - } - } else { - this.bI = false; - this.bL += (0.8F * this.bL * this.bL * this.bL - this.bL) * 0.6F - 0.05F; - if (this.bL < 0.0F) { - this.bL = 0.0F; - } - } - - this.bO = this.bN; - if (this.x(128)) { - this.bN += (1.0F - this.bN) * 0.7F + 0.05F; - if (this.bN > 1.0F) { - this.bN = 1.0F; - } - } else { - this.bN += (0.0F - this.bN) * 0.7F - 0.05F; - if (this.bN < 0.0F) { - this.bN = 0.0F; - } - } - } - - private void cS() { - if (!this.world.isStatic) { - this.bE = 1; - this.b(128, true); - } - } - - private boolean cT() { - return this.passenger == null && this.vehicle == null && this.isTame() && this.cb() && !this.cF() && this.getHealth() >= this.getMaxHealth(); - } - - public void e(boolean flag) { - this.b(32, flag); - } - - public void o(boolean flag) { - this.e(flag); - } - - public void p(boolean flag) { - if (flag) { - this.o(false); - } - - this.b(64, flag); - } - - private void cU() { - if (!this.world.isStatic) { - this.bF = 1; - this.p(true); - } - } - - public void cJ() { - this.cU(); - String s = this.cv(); - - if (s != null) { - this.makeSound(s, this.bf(), this.bg()); - } - } - - public void dropChest() { - this.a(this, this.inventoryChest); - this.cs(); - } - - private void a(Entity entity, InventoryHorseChest inventoryhorsechest) { - if (inventoryhorsechest != null && !this.world.isStatic) { - for (int i = 0; i < inventoryhorsechest.getSize(); ++i) { - ItemStack itemstack = inventoryhorsechest.getItem(i); - - if (itemstack != null) { - this.a(itemstack, 0.0F); - } - } - } - } - - public boolean h(EntityHuman entityhuman) { - this.setOwnerUUID(entityhuman.getUniqueID().toString()); - this.setTame(true); - return true; - } - - public void e(float f, float f1) { - if (this.passenger != null && this.passenger instanceof EntityLiving && this.cu()) { - this.lastYaw = this.yaw = this.passenger.yaw; - this.pitch = this.passenger.pitch * 0.5F; - this.b(this.yaw, this.pitch); - this.aO = this.aM = this.yaw; - f = ((EntityLiving) this.passenger).bd * 0.5F; - f1 = ((EntityLiving) this.passenger).be; - if (f1 <= 0.0F) { - f1 *= 0.25F; - this.bP = 0; - } - - if (this.onGround && this.bt == 0.0F && this.cn() && !this.bI) { - f = 0.0F; - f1 = 0.0F; - } - - if (this.bt > 0.0F && !this.cj() && this.onGround) { - this.motY = this.getJumpStrength() * (double) this.bt; - if (this.hasEffect(MobEffectList.JUMP)) { - this.motY += (double) ((float) (this.getEffect(MobEffectList.JUMP).getAmplifier() + 1) * 0.1F); - } - - this.j(true); - this.al = true; - if (f1 > 0.0F) { - float f2 = MathHelper.sin(this.yaw * 3.1415927F / 180.0F); - float f3 = MathHelper.cos(this.yaw * 3.1415927F / 180.0F); - - this.motX += (double) (-0.4F * f2 * this.bt); - this.motZ += (double) (0.4F * f3 * this.bt); - this.makeSound("mob.horse.jump", 0.4F, 1.0F); - } - - this.bt = 0.0F; - } - - this.W = 1.0F; - this.aQ = this.bl() * 0.1F; - if (!this.world.isStatic) { - this.i((float) this.getAttributeInstance(GenericAttributes.d).getValue()); - super.e(f, f1); - } - - if (this.onGround) { - this.bt = 0.0F; - this.j(false); - } - - this.aE = this.aF; - double d0 = this.locX - this.lastX; - double d1 = this.locZ - this.lastZ; - float f4 = MathHelper.sqrt(d0 * d0 + d1 * d1) * 4.0F; - - if (f4 > 1.0F) { - f4 = 1.0F; - } - - this.aF += (f4 - this.aF) * 0.4F; - this.aG += this.aF; - } else { - this.W = 0.5F; - this.aQ = 0.02F; - super.e(f, f1); - } - } - - public void b(NBTTagCompound nbttagcompound) { - super.b(nbttagcompound); - nbttagcompound.setBoolean("EatingHaystack", this.cm()); - nbttagcompound.setBoolean("ChestedHorse", this.hasChest()); - nbttagcompound.setBoolean("HasReproduced", this.cp()); - nbttagcompound.setBoolean("Bred", this.co()); - nbttagcompound.setInt("Type", this.getType()); - nbttagcompound.setInt("Variant", this.getVariant()); - nbttagcompound.setInt("Temper", this.getTemper()); - nbttagcompound.setBoolean("Tame", this.isTame()); - nbttagcompound.setString("OwnerUUID", this.getOwnerUUID()); - nbttagcompound.setInt("Bukkit.MaxDomestication", this.maxDomestication); // CraftBukkit - if (this.hasChest()) { - NBTTagList nbttaglist = new NBTTagList(); - - for (int i = 2; i < this.inventoryChest.getSize(); ++i) { - ItemStack itemstack = this.inventoryChest.getItem(i); - - if (itemstack != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - - nbttagcompound1.setByte("Slot", (byte) i); - itemstack.save(nbttagcompound1); - nbttaglist.add(nbttagcompound1); - } - } - - nbttagcompound.set("Items", nbttaglist); - } - - if (this.inventoryChest.getItem(1) != null) { - nbttagcompound.set("ArmorItem", this.inventoryChest.getItem(1).save(new NBTTagCompound())); - } - - if (this.inventoryChest.getItem(0) != null) { - nbttagcompound.set("SaddleItem", this.inventoryChest.getItem(0).save(new NBTTagCompound())); - } - } - - public void a(NBTTagCompound nbttagcompound) { - super.a(nbttagcompound); - this.o(nbttagcompound.getBoolean("EatingHaystack")); - this.k(nbttagcompound.getBoolean("Bred")); - this.setHasChest(nbttagcompound.getBoolean("ChestedHorse")); - this.m(nbttagcompound.getBoolean("HasReproduced")); - this.setType(nbttagcompound.getInt("Type")); - this.setVariant(nbttagcompound.getInt("Variant")); - this.setTemper(nbttagcompound.getInt("Temper")); - this.setTame(nbttagcompound.getBoolean("Tame")); - if (nbttagcompound.hasKeyOfType("OwnerUUID", 8)) { - this.setOwnerUUID(nbttagcompound.getString("OwnerUUID")); - } - // Spigot start - else if (nbttagcompound.hasKey("OwnerName")) { - String owner = nbttagcompound.getString("OwnerName"); - if (owner != null && !owner.isEmpty()) { - this.setOwnerUUID(NameReferencingFileConverter.a(owner)); - } - } - // Spigot end - // CraftBukkit start - if (nbttagcompound.hasKey("Bukkit.MaxDomestication")) { - this.maxDomestication = nbttagcompound.getInt("Bukkit.MaxDomestication"); - } - // CraftBukkit end - AttributeInstance attributeinstance = this.getAttributeMap().a("Speed"); - - if (attributeinstance != null) { - this.getAttributeInstance(GenericAttributes.d).setValue(attributeinstance.b() * 0.25D); - } - - if (this.hasChest()) { - NBTTagList nbttaglist = nbttagcompound.getList("Items", 10); - - this.loadChest(); - - for (int i = 0; i < nbttaglist.size(); ++i) { - NBTTagCompound nbttagcompound1 = nbttaglist.get(i); - int j = nbttagcompound1.getByte("Slot") & 255; - - if (j >= 2 && j < this.inventoryChest.getSize()) { - this.inventoryChest.setItem(j, ItemStack.createStack(nbttagcompound1)); - } - } - } - - ItemStack itemstack; - - if (nbttagcompound.hasKeyOfType("ArmorItem", 10)) { - itemstack = ItemStack.createStack(nbttagcompound.getCompound("ArmorItem")); - if (itemstack != null && a(itemstack.getItem())) { - this.inventoryChest.setItem(1, itemstack); - } - } - - if (nbttagcompound.hasKeyOfType("SaddleItem", 10)) { - itemstack = ItemStack.createStack(nbttagcompound.getCompound("SaddleItem")); - if (itemstack != null && itemstack.getItem() == Items.SADDLE) { - this.inventoryChest.setItem(0, itemstack); - } - } else if (nbttagcompound.getBoolean("Saddle")) { - this.inventoryChest.setItem(0, new ItemStack(Items.SADDLE)); - } - - this.cO(); - } - - public boolean mate(EntityAnimal entityanimal) { - if (entityanimal == this) { - return false; - } else if (entityanimal.getClass() != this.getClass()) { - return false; - } else { - EntityHorse entityhorse = (EntityHorse) entityanimal; - - if (this.cT() && entityhorse.cT()) { - int i = this.getType(); - int j = entityhorse.getType(); - - return i == j || i == 0 && j == 1 || i == 1 && j == 0; - } else { - return false; - } - } - } - - public EntityAgeable createChild(EntityAgeable entityageable) { - EntityHorse entityhorse = (EntityHorse) entityageable; - EntityHorse entityhorse1 = new EntityHorse(this.world); - int i = this.getType(); - int j = entityhorse.getType(); - int k = 0; - - if (i == j) { - k = i; - } else if (i == 0 && j == 1 || i == 1 && j == 0) { - k = 2; - } - - if (k == 0) { - int l = this.random.nextInt(9); - int i1; - - if (l < 4) { - i1 = this.getVariant() & 255; - } else if (l < 8) { - i1 = entityhorse.getVariant() & 255; - } else { - i1 = this.random.nextInt(7); - } - - int j1 = this.random.nextInt(5); - - if (j1 < 2) { - i1 |= this.getVariant() & '\uff00'; - } else if (j1 < 4) { - i1 |= entityhorse.getVariant() & '\uff00'; - } else { - i1 |= this.random.nextInt(5) << 8 & '\uff00'; - } - - entityhorse1.setVariant(i1); - } - - entityhorse1.setType(k); - double d0 = this.getAttributeInstance(GenericAttributes.maxHealth).b() + entityageable.getAttributeInstance(GenericAttributes.maxHealth).b() + (double) this.cV(); - - entityhorse1.getAttributeInstance(GenericAttributes.maxHealth).setValue(d0 / 3.0D); - double d1 = this.getAttributeInstance(attributeJumpStrength).b() + entityageable.getAttributeInstance(attributeJumpStrength).b() + this.cW(); - - entityhorse1.getAttributeInstance(attributeJumpStrength).setValue(d1 / 3.0D); - double d2 = this.getAttributeInstance(GenericAttributes.d).b() + entityageable.getAttributeInstance(GenericAttributes.d).b() + this.cX(); - - entityhorse1.getAttributeInstance(GenericAttributes.d).setValue(d2 / 3.0D); - return entityhorse1; - } - - public GroupDataEntity prepare(GroupDataEntity groupdataentity) { - Object object = super.prepare(groupdataentity); - boolean flag = false; - int i = 0; - int j; - - if (object instanceof GroupDataHorse) { - j = ((GroupDataHorse) object).a; - i = ((GroupDataHorse) object).b & 255 | this.random.nextInt(5) << 8; - } else { - if (this.random.nextInt(10) == 0) { - j = 1; - } else { - int k = this.random.nextInt(7); - int l = this.random.nextInt(5); - - j = 0; - i = k | l << 8; - } - - object = new GroupDataHorse(j, i); - } - - this.setType(j); - this.setVariant(i); - if (this.random.nextInt(5) == 0) { - this.setAge(-24000); - } - - if (j != 4 && j != 3) { - this.getAttributeInstance(GenericAttributes.maxHealth).setValue((double) this.cV()); - if (j == 0) { - this.getAttributeInstance(GenericAttributes.d).setValue(this.cX()); - } else { - this.getAttributeInstance(GenericAttributes.d).setValue(0.17499999701976776D); - } - } else { - this.getAttributeInstance(GenericAttributes.maxHealth).setValue(15.0D); - this.getAttributeInstance(GenericAttributes.d).setValue(0.20000000298023224D); - } - - if (j != 2 && j != 1) { - this.getAttributeInstance(attributeJumpStrength).setValue(this.cW()); - } else { - this.getAttributeInstance(attributeJumpStrength).setValue(0.5D); - } - - this.setHealth(this.getMaxHealth()); - return (GroupDataEntity) object; - } - - protected boolean bk() { - return true; - } - - public void w(int i) { - if (this.cu()) { - // CraftBukkit start - fire HorseJumpEvent, use event power - if (i < 0) { - i = 0; - } - - float power; - if (i >= 90) { - power = 1.0F; - } else { - power = 0.4F + 0.4F * (float) i / 90.0F; - } - - org.bukkit.event.entity.HorseJumpEvent event = org.bukkit.craftbukkit.v1_7_R4.event.CraftEventFactory.callHorseJumpEvent(this, power); - if (!event.isCancelled()) { - this.bI = true; - this.cU(); - this.bt = event.getPower(); - } - // CraftBukkit end - } - } - - public void ac() { - super.ac(); - if (this.bM > 0.0F) { - float f = MathHelper.sin(this.aM * 3.1415927F / 180.0F); - float f1 = MathHelper.cos(this.aM * 3.1415927F / 180.0F); - float f2 = 0.7F * this.bM; - float f3 = 0.15F * this.bM; - - this.passenger.setPosition(this.locX + (double) (f2 * f), this.locY + this.ad() + this.passenger.ad() + (double) f3, this.locZ - (double) (f2 * f1)); - if (this.passenger instanceof EntityLiving) { - ((EntityLiving) this.passenger).aM = this.aM; - } - } - } - - private float cV() { - return 15.0F + (float) this.random.nextInt(8) + (float) this.random.nextInt(9); - } - - private double cW() { - return 0.4000000059604645D + this.random.nextDouble() * 0.2D + this.random.nextDouble() * 0.2D + this.random.nextDouble() * 0.2D; - } - - private double cX() { - return (0.44999998807907104D + this.random.nextDouble() * 0.3D + this.random.nextDouble() * 0.3D + this.random.nextDouble() * 0.3D) * 0.25D; - } - - public static boolean a(Item item) { - return item == Items.HORSE_ARMOR_IRON || item == Items.HORSE_ARMOR_GOLD || item == Items.HORSE_ARMOR_DIAMOND; - } - - public boolean h_() { - return false; - } -} diff --git a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/EntityHuman.java b/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/EntityHuman.java deleted file mode 100644 index dcf0a0e47..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/EntityHuman.java +++ /dev/null @@ -1,1604 +0,0 @@ -package net.minecraft.server.v1_7_R4; - -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.UUID; - -import net.minecraft.util.com.google.common.base.Charsets; -import net.minecraft.util.com.mojang.authlib.GameProfile; - -// CraftBukkit start -import org.bukkit.craftbukkit.v1_7_R4.entity.CraftHumanEntity; -import org.bukkit.craftbukkit.v1_7_R4.entity.CraftItem; -import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack; -import org.bukkit.entity.Player; -import org.bukkit.event.entity.EntityCombustByEntityEvent; -import org.bukkit.event.player.PlayerBedEnterEvent; -import org.bukkit.event.player.PlayerBedLeaveEvent; -import org.bukkit.event.player.PlayerDropItemEvent; -import org.bukkit.event.player.PlayerItemConsumeEvent; -// CraftBukkit end - -public abstract class EntityHuman extends EntityLiving implements ICommandListener { - - public PlayerInventory inventory = new PlayerInventory(this); - private InventoryEnderChest enderChest = new InventoryEnderChest(); - public Container defaultContainer; - public Container activeContainer; - protected FoodMetaData foodData = new FoodMetaData(this); // CraftBukkit - add "this" to constructor - protected int bq; - public float br; - public float bs; - public int bt; - public double bu; - public double bv; - public double bw; - public double bx; - public double by; - public double bz; - // CraftBukkit start - public boolean sleeping; // protected -> public - public boolean fauxSleeping; - public String spawnWorld = ""; - - @Override - public CraftHumanEntity getBukkitEntity() { - return (CraftHumanEntity) super.getBukkitEntity(); - } - // CraftBukkit end - - public ChunkCoordinates bB; - public int sleepTicks; // CraftBukkit - private -> public - public float bC; - public float bD; - private ChunkCoordinates c; - private boolean d; - private ChunkCoordinates e; - public PlayerAbilities abilities = new PlayerAbilities(); - public int oldLevel = -1; // CraftBukkit - add field - public int expLevel; - public int expTotal; - public float exp; - private ItemStack f; - private int g; - protected float bI = 0.1F; - protected float bJ = 0.02F; - private int h; - private final GameProfile i; - public EntityFishingHook hookedFish; - - public EntityHuman(World world, GameProfile gameprofile) { - super(world); - this.uniqueID = a(gameprofile); - this.i = gameprofile; - this.defaultContainer = new ContainerPlayer(this.inventory, !world.isStatic, this); - this.activeContainer = this.defaultContainer; - this.height = 1.62F; - ChunkCoordinates chunkcoordinates = world.getSpawn(); - - this.setPositionRotation((double) chunkcoordinates.x + 0.5D, (double) (chunkcoordinates.y + 1), (double) chunkcoordinates.z + 0.5D, 0.0F, 0.0F); - this.aZ = 180.0F; - this.maxFireTicks = 20; - } - - protected void aD() { - super.aD(); - this.getAttributeMap().b(GenericAttributes.e).setValue(1.0D); - } - - protected void c() { - super.c(); - this.datawatcher.a(16, Byte.valueOf((byte) 0)); - this.datawatcher.a(17, Float.valueOf(0.0F)); - this.datawatcher.a(18, Integer.valueOf(0)); - } - - public boolean by() { - return this.f != null; - } - - public void bA() { - if (this.f != null) { - this.f.b(this.world, this, this.g); - } - - this.bB(); - } - - public void bB() { - this.f = null; - this.g = 0; - if (!this.world.isStatic) { - this.e(false); - } - } - - public boolean isBlocking() { - return this.by() && this.f.getItem().d(this.f) == EnumAnimation.BLOCK; - } - - public void h() { - if (this.f != null) { - ItemStack itemstack = this.inventory.getItemInHand(); - - if (ItemStack.equals(itemstack, this.f)) { - if (this.g <= 25 && this.g % 4 == 0) { - this.c(itemstack, 5); - } - - if (--this.g == 0 && !this.world.isStatic) { - this.p(); - } - } else { - this.bB(); - } - } - - if (this.bt > 0) { - --this.bt; - } - - if (this.isSleeping()) { - ++this.sleepTicks; - if (this.sleepTicks > 100) { - this.sleepTicks = 100; - } - - if (!this.world.isStatic) { - if (!this.j()) { - this.a(true, true, false); - } else if (this.world.w()) { - this.a(false, true, true); - } - } - } else if (this.sleepTicks > 0) { - ++this.sleepTicks; - if (this.sleepTicks >= 110) { - this.sleepTicks = 0; - } - } - - super.h(); - if (!this.world.isStatic && this.activeContainer != null && !this.activeContainer.a(this)) { - this.closeInventory(); - this.activeContainer = this.defaultContainer; - } - - if (this.isBurning() && this.abilities.isInvulnerable) { - this.extinguish(); - } - - this.bu = this.bx; - this.bv = this.by; - this.bw = this.bz; - double d0 = this.locX - this.bx; - double d1 = this.locY - this.by; - double d2 = this.locZ - this.bz; - double d3 = 10.0D; - - if (d0 > d3) { - this.bu = this.bx = this.locX; - } - - if (d2 > d3) { - this.bw = this.bz = this.locZ; - } - - if (d1 > d3) { - this.bv = this.by = this.locY; - } - - if (d0 < -d3) { - this.bu = this.bx = this.locX; - } - - if (d2 < -d3) { - this.bw = this.bz = this.locZ; - } - - if (d1 < -d3) { - this.bv = this.by = this.locY; - } - - this.bx += d0 * 0.25D; - this.bz += d2 * 0.25D; - this.by += d1 * 0.25D; - if (this.vehicle == null) { - this.e = null; - } - - if (!this.world.isStatic) { - this.foodData.a(this); - this.a(StatisticList.g, 1); - } - } - - public int D() { - return this.abilities.isInvulnerable ? 0 : 80; - } - - protected String H() { - return "game.player.swim"; - } - - protected String O() { - return "game.player.swim.splash"; - } - - public int ai() { - return 10; - } - - public void makeSound(String s, float f, float f1) { - this.world.a(this, s, f, f1); - } - - protected void c(ItemStack itemstack, int i) { - if (itemstack.o() == EnumAnimation.DRINK) { - this.makeSound("random.drink", 0.5F, this.world.random.nextFloat() * 0.1F + 0.9F); - } - - if (itemstack.o() == EnumAnimation.EAT) { - for (int j = 0; j < i; ++j) { - Vec3D vec3d = Vec3D.a(((double) this.random.nextFloat() - 0.5D) * 0.1D, Math.random() * 0.1D + 0.1D, 0.0D); - - vec3d.a(-this.pitch * 3.1415927F / 180.0F); - vec3d.b(-this.yaw * 3.1415927F / 180.0F); - Vec3D vec3d1 = Vec3D.a(((double) this.random.nextFloat() - 0.5D) * 0.3D, (double) (-this.random.nextFloat()) * 0.6D - 0.3D, 0.6D); - - vec3d1.a(-this.pitch * 3.1415927F / 180.0F); - vec3d1.b(-this.yaw * 3.1415927F / 180.0F); - vec3d1 = vec3d1.add(this.locX, this.locY + (double) this.getHeadHeight(), this.locZ); - String s = "iconcrack_" + Item.getId(itemstack.getItem()); - - if (itemstack.usesData()) { - s = s + "_" + itemstack.getData(); - } - - this.world.addParticle(s, vec3d1.a, vec3d1.b, vec3d1.c, vec3d.a, vec3d.b + 0.05D, vec3d.c); - } - - this.makeSound("random.eat", 0.5F + 0.5F * (float) this.random.nextInt(2), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); - } - } - - protected void p() { - if (this.f != null) { - this.c(this.f, 16); - int i = this.f.count; - - // CraftBukkit start - fire PlayerItemConsumeEvent - org.bukkit.inventory.ItemStack craftItem = CraftItemStack.asBukkitCopy(this.f); - PlayerItemConsumeEvent event = new PlayerItemConsumeEvent((Player) this.getBukkitEntity(), craftItem); - world.getServer().getPluginManager().callEvent(event); - - if (event.isCancelled()) { - // Update client - if (this instanceof EntityPlayer) { - ((EntityPlayer) this).playerConnection.sendPacket(new PacketPlayOutSetSlot((byte) 0, activeContainer.getSlot((IInventory) this.inventory, this.inventory.itemInHandIndex).index, this.f)); - // Spigot Start - ((EntityPlayer) this).getBukkitEntity().updateInventory(); - ((EntityPlayer) this).getBukkitEntity().updateScaledHealth(); - // Spigot End - } - return; - } - - // Plugin modified the item, process it but don't remove it - if (!craftItem.equals(event.getItem())) { - CraftItemStack.asNMSCopy(event.getItem()).b(this.world, this); - - // Update client - if (this instanceof EntityPlayer) { - ((EntityPlayer) this).playerConnection.sendPacket(new PacketPlayOutSetSlot((byte) 0, activeContainer.getSlot((IInventory) this.inventory, this.inventory.itemInHandIndex).index, this.f)); - } - return; - } - // CraftBukkit end - - ItemStack itemstack = this.f.b(this.world, this); - - if (itemstack != this.f || itemstack != null && itemstack.count != i) { - this.inventory.items[this.inventory.itemInHandIndex] = itemstack; - if (itemstack.count == 0) { - this.inventory.items[this.inventory.itemInHandIndex] = null; - } - } - - this.bB(); - } - } - - protected boolean bh() { - return this.getHealth() <= 0.0F || this.isSleeping(); - } - - // CraftBukkit - protected -> public - public void closeInventory() { - this.activeContainer = this.defaultContainer; - } - - public void mount(Entity entity) { - // CraftBukkit start - mirror Entity mount changes - this.setPassengerOf(entity); - } - - public void setPassengerOf(Entity entity) { - // CraftBukkit end - if (this.vehicle != null && entity == null) { - world.getServer().getPluginManager().callEvent( new org.spigotmc.event.entity.EntityDismountEvent( this.getBukkitEntity(), this.vehicle.getBukkitEntity() ) ); // Spigot - // CraftBukkit start - use parent method instead to correctly fire VehicleExitEvent - Entity originalVehicle = this.vehicle; - // First statement moved down, second statement handled in parent method. - /* - if (!this.world.isStatic) { - this.m(this.vehicle); - } - - if (this.vehicle != null) { - this.vehicle.passenger = null; - } - - this.vehicle = null; - */ - super.setPassengerOf(entity); - if (!this.world.isStatic && this.vehicle == null) { - this.m(originalVehicle); - } - // CraftBukkit end - } else { - super.setPassengerOf(entity); // CraftBukkit - call new parent - } - } - - public void ab() { - if (!this.world.isStatic && this.isSneaking()) { - this.mount((Entity) null); - this.setSneaking(false); - } else { - double d0 = this.locX; - double d1 = this.locY; - double d2 = this.locZ; - float f = this.yaw; - float f1 = this.pitch; - - super.ab(); - this.br = this.bs; - this.bs = 0.0F; - this.l(this.locX - d0, this.locY - d1, this.locZ - d2); - if (this.vehicle instanceof EntityPig) { - this.pitch = f1; - this.yaw = f; - this.aM = ((EntityPig) this.vehicle).aM; - } - } - } - - protected void bq() { - super.bq(); - this.bb(); - } - - public void e() { - if (this.bq > 0) { - --this.bq; - } - - if (this.world.difficulty == EnumDifficulty.PEACEFUL && this.getHealth() < this.getMaxHealth() && this.world.getGameRules().getBoolean("naturalRegeneration") && this.ticksLived % 20 * 12 == 0) { - // CraftBukkit - added regain reason of "REGEN" for filtering purposes. - this.heal(1.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.REGEN); - } - - this.inventory.k(); - this.br = this.bs; - super.e(); - AttributeInstance attributeinstance = this.getAttributeInstance(GenericAttributes.d); - - if (!this.world.isStatic) { - attributeinstance.setValue((double) this.abilities.b()); - } - - this.aQ = this.bJ; - if (this.isSprinting()) { - this.aQ = (float) ((double) this.aQ + (double) this.bJ * 0.3D); - } - - this.i((float) attributeinstance.getValue()); - float f = MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ); - // CraftBukkit - Math -> TrigMath - float f1 = (float) org.bukkit.craftbukkit.v1_7_R4.TrigMath.atan(-this.motY * 0.20000000298023224D) * 15.0F; - - if (f > 0.1F) { - f = 0.1F; - } - - if (!this.onGround || this.getHealth() <= 0.0F) { - f = 0.0F; - } - - if (this.onGround || this.getHealth() <= 0.0F) { - f1 = 0.0F; - } - - this.bs += (f - this.bs) * 0.4F; - this.aJ += (f1 - this.aJ) * 0.8F; - if (this.getHealth() > 0.0F) { - AxisAlignedBB axisalignedbb = null; - - if (this.vehicle != null && !this.vehicle.dead) { - axisalignedbb = this.boundingBox.a(this.vehicle.boundingBox).grow(1.0D, 0.0D, 1.0D); - } else { - axisalignedbb = this.boundingBox.grow(1.0D, 0.5D, 1.0D); - } - - List list = this.world.getEntities(this, axisalignedbb); - - if (list != null && this.S()) { // Spigot: Add this.S() condition (second !this.isDead near bottom of EntityLiving) - for (int i = 0; i < list.size(); ++i) { - Entity entity = (Entity) list.get(i); - - if (!entity.dead) { - this.d(entity); - } - } - } - } - } - - private void d(Entity entity) { - entity.b_(this); - } - - public int getScore() { - return this.datawatcher.getInt(18); - } - - public void setScore(int i) { - this.datawatcher.watch(18, Integer.valueOf(i)); - } - - public void addScore(int i) { - int j = this.getScore(); - - this.datawatcher.watch(18, Integer.valueOf(j + i)); - } - - public void die(DamageSource damagesource) { - super.die(damagesource); - this.a(0.2F, 0.2F); - this.setPosition(this.locX, this.locY, this.locZ); - this.motY = 0.10000000149011612D; - if (this.getName().equals("Notch")) { - this.a(new ItemStack(Items.APPLE, 1), true, false); - } - - if (!this.world.getGameRules().getBoolean("keepInventory")) { - this.inventory.m(); - } - - if (damagesource != null) { - this.motX = (double) (-MathHelper.cos((this.az + this.yaw) * 3.1415927F / 180.0F) * 0.1F); - this.motZ = (double) (-MathHelper.sin((this.az + this.yaw) * 3.1415927F / 180.0F) * 0.1F); - } else { - this.motX = this.motZ = 0.0D; - } - - this.height = 0.1F; - this.a(StatisticList.v, 1); - } - - protected String aT() { - return "game.player.hurt"; - } - - protected String aU() { - return "game.player.die"; - } - - public void b(Entity entity, int i) { - this.addScore(i); - // CraftBukkit - Get our scores instead - Collection collection = this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.e, this.getName(), new java.util.ArrayList()); - - if (entity instanceof EntityHuman) { - this.a(StatisticList.y, 1); - // CraftBukkit - Get our scores instead - this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.d, this.getName(), collection); - } else { - this.a(StatisticList.w, 1); - } - - Iterator iterator = collection.iterator(); - - while (iterator.hasNext()) { - ScoreboardScore scoreboardscore = (ScoreboardScore) iterator.next(); // CraftBukkit - Use our scores instead - - scoreboardscore.incrementScore(); - } - } - - public EntityItem a(boolean flag) { - // Called only when dropped by Q or CTRL-Q - return this.a(this.inventory.splitStack(this.inventory.itemInHandIndex, flag && this.inventory.getItemInHand() != null ? this.inventory.getItemInHand().count : 1), false, true); - } - - public EntityItem drop(ItemStack itemstack, boolean flag) { - return this.a(itemstack, false, false); - } - - public EntityItem a(ItemStack itemstack, boolean flag, boolean flag1) { - if (itemstack == null) { - return null; - } else if (itemstack.count == 0) { - return null; - } else { - EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY - 0.30000001192092896D + (double) this.getHeadHeight(), this.locZ, itemstack); - - entityitem.pickupDelay = 40; - if (flag1) { - entityitem.b(this.getName()); - } - - float f = 0.1F; - float f1; - - if (flag) { - f1 = this.random.nextFloat() * 0.5F; - float f2 = this.random.nextFloat() * 3.1415927F * 2.0F; - - entityitem.motX = (double) (-MathHelper.sin(f2) * f1); - entityitem.motZ = (double) (MathHelper.cos(f2) * f1); - entityitem.motY = 0.20000000298023224D; - } else { - f = 0.3F; - entityitem.motX = (double) (-MathHelper.sin(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(this.pitch / 180.0F * 3.1415927F) * f); - entityitem.motZ = (double) (MathHelper.cos(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(this.pitch / 180.0F * 3.1415927F) * f); - entityitem.motY = (double) (-MathHelper.sin(this.pitch / 180.0F * 3.1415927F) * f + 0.1F); - f = 0.02F; - f1 = this.random.nextFloat() * 3.1415927F * 2.0F; - f *= this.random.nextFloat(); - entityitem.motX += Math.cos((double) f1) * (double) f; - entityitem.motY += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F); - entityitem.motZ += Math.sin((double) f1) * (double) f; - } - - // CraftBukkit start - fire PlayerDropItemEvent - Player player = (Player) this.getBukkitEntity(); - CraftItem drop = new CraftItem(this.world.getServer(), entityitem); - - PlayerDropItemEvent event = new PlayerDropItemEvent(player, drop); - this.world.getServer().getPluginManager().callEvent(event); - - if (event.isCancelled()) { - org.bukkit.inventory.ItemStack cur = player.getInventory().getItemInHand(); - if (flag1 && (cur == null || cur.getAmount() == 0)) { - // The complete stack was dropped - player.getInventory().setItemInHand(drop.getItemStack()); - } else if (flag1 && cur.isSimilar(drop.getItemStack()) && drop.getItemStack().getAmount() == 1) { - // Only one item is dropped - cur.setAmount(cur.getAmount() + 1); - player.getInventory().setItemInHand(cur); - } else { - // Fallback - player.getInventory().addItem(drop.getItemStack()); - } - return null; - } - // CraftBukkit end - - this.a(entityitem); - this.a(StatisticList.s, 1); - return entityitem; - } - } - - protected void a(EntityItem entityitem) { - this.world.addEntity(entityitem); - } - - public float a(Block block, boolean flag) { - float f = this.inventory.a(block); - - if (f > 1.0F) { - int i = EnchantmentManager.getDigSpeedEnchantmentLevel(this); - ItemStack itemstack = this.inventory.getItemInHand(); - - if (i > 0 && itemstack != null) { - float f1 = (float) (i * i + 1); - - if (!itemstack.b(block) && f <= 1.0F) { - f += f1 * 0.08F; - } else { - f += f1; - } - } - } - - if (this.hasEffect(MobEffectList.FASTER_DIG)) { - f *= 1.0F + (float) (this.getEffect(MobEffectList.FASTER_DIG).getAmplifier() + 1) * 0.2F; - } - - if (this.hasEffect(MobEffectList.SLOWER_DIG)) { - f *= 1.0F - (float) (this.getEffect(MobEffectList.SLOWER_DIG).getAmplifier() + 1) * 0.2F; - } - - if (this.a(Material.WATER) && !EnchantmentManager.hasWaterWorkerEnchantment(this)) { - f /= 5.0F; - } - - if (!this.onGround) { - f /= 5.0F; - } - - return f; - } - - public boolean a(Block block) { - return this.inventory.b(block); - } - - public void a(NBTTagCompound nbttagcompound) { - super.a(nbttagcompound); - this.uniqueID = a(this.i); - NBTTagList nbttaglist = nbttagcompound.getList("Inventory", 10); - - this.inventory.b(nbttaglist); - this.inventory.itemInHandIndex = nbttagcompound.getInt("SelectedItemSlot"); - this.sleeping = nbttagcompound.getBoolean("Sleeping"); - this.sleepTicks = nbttagcompound.getShort("SleepTimer"); - this.exp = nbttagcompound.getFloat("XpP"); - this.expLevel = nbttagcompound.getInt("XpLevel"); - this.expTotal = nbttagcompound.getInt("XpTotal"); - this.setScore(nbttagcompound.getInt("Score")); - if (this.sleeping) { - this.bB = new ChunkCoordinates(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)); - this.a(true, true, false); - } - - // CraftBukkit start - this.spawnWorld = nbttagcompound.getString("SpawnWorld"); - if ("".equals(spawnWorld)) { - this.spawnWorld = this.world.getServer().getWorlds().get(0).getName(); - } - // CraftBukkit end - - if (nbttagcompound.hasKeyOfType("SpawnX", 99) && nbttagcompound.hasKeyOfType("SpawnY", 99) && nbttagcompound.hasKeyOfType("SpawnZ", 99)) { - this.c = new ChunkCoordinates(nbttagcompound.getInt("SpawnX"), nbttagcompound.getInt("SpawnY"), nbttagcompound.getInt("SpawnZ")); - this.d = nbttagcompound.getBoolean("SpawnForced"); - } - - this.foodData.a(nbttagcompound); - this.abilities.b(nbttagcompound); - if (nbttagcompound.hasKeyOfType("EnderItems", 9)) { - NBTTagList nbttaglist1 = nbttagcompound.getList("EnderItems", 10); - - this.enderChest.a(nbttaglist1); - } - } - - public void b(NBTTagCompound nbttagcompound) { - super.b(nbttagcompound); - nbttagcompound.set("Inventory", this.inventory.a(new NBTTagList())); - nbttagcompound.setInt("SelectedItemSlot", this.inventory.itemInHandIndex); - nbttagcompound.setBoolean("Sleeping", this.sleeping); - nbttagcompound.setShort("SleepTimer", (short) this.sleepTicks); - nbttagcompound.setFloat("XpP", this.exp); - nbttagcompound.setInt("XpLevel", this.expLevel); - nbttagcompound.setInt("XpTotal", this.expTotal); - nbttagcompound.setInt("Score", this.getScore()); - if (this.c != null) { - nbttagcompound.setInt("SpawnX", this.c.x); - nbttagcompound.setInt("SpawnY", this.c.y); - nbttagcompound.setInt("SpawnZ", this.c.z); - nbttagcompound.setBoolean("SpawnForced", this.d); - nbttagcompound.setString("SpawnWorld", spawnWorld); // CraftBukkit - fixes bed spawns for multiworld worlds - } - - this.foodData.b(nbttagcompound); - this.abilities.a(nbttagcompound); - nbttagcompound.set("EnderItems", this.enderChest.h()); - } - - public void openContainer(IInventory iinventory) {} - - public void openHopper(TileEntityHopper tileentityhopper) {} - - public void openMinecartHopper(EntityMinecartHopper entityminecarthopper) {} - - public void openHorseInventory(EntityHorse entityhorse, IInventory iinventory) {} - - public void startEnchanting(int i, int j, int k, String s) {} - - public void openAnvil(int i, int j, int k) {} - - public void startCrafting(int i, int j, int k) {} - - public float getHeadHeight() { - return 0.12F; - } - - protected void e_() { - this.height = 1.62F; - } - - public boolean damageEntity(DamageSource damagesource, float f) { - if (this.isInvulnerable()) { - return false; - } else if (this.abilities.isInvulnerable && !damagesource.ignoresInvulnerability()) { - return false; - } else { - this.aU = 0; - if (this.getHealth() <= 0.0F) { - return false; - } else { - if (this.isSleeping() && !this.world.isStatic) { - this.a(true, true, false); - } - - if (damagesource.r()) { - if (this.world.difficulty == EnumDifficulty.PEACEFUL) { - return false; // CraftBukkit - f = 0.0f -> return false - } - - if (this.world.difficulty == EnumDifficulty.EASY) { - f = f / 2.0F + 1.0F; - } - - if (this.world.difficulty == EnumDifficulty.HARD) { - f = f * 3.0F / 2.0F; - } - } - - if (false && f == 0.0F) { // CraftBukkit - Don't filter out 0 damage - return false; - } else { - Entity entity = damagesource.getEntity(); - - if (entity instanceof EntityArrow && ((EntityArrow) entity).shooter != null) { - entity = ((EntityArrow) entity).shooter; - } - - this.a(StatisticList.u, Math.round(f * 10.0F)); - return super.damageEntity(damagesource, f); - } - } - } - } - - public boolean a(EntityHuman entityhuman) { - // CraftBukkit start - Change to check OTHER player's scoreboard team according to API - // To summarize this method's logic, it's "Can parameter hurt this" - org.bukkit.scoreboard.Team team; - if (entityhuman instanceof EntityPlayer) { - EntityPlayer thatPlayer = (EntityPlayer) entityhuman; - team = thatPlayer.getBukkitEntity().getScoreboard().getPlayerTeam(thatPlayer.getBukkitEntity()); - if (team == null || team.allowFriendlyFire()) { - return true; - } - } else { - // This should never be called, but is implemented anyway - org.bukkit.OfflinePlayer thisPlayer = entityhuman.world.getServer().getOfflinePlayer(entityhuman.getName()); - team = entityhuman.world.getServer().getScoreboardManager().getMainScoreboard().getPlayerTeam(thisPlayer); - if (team == null || team.allowFriendlyFire()) { - return true; - } - } - - if (this instanceof EntityPlayer) { - return !team.hasPlayer(((EntityPlayer) this).getBukkitEntity()); - } - return !team.hasPlayer(this.world.getServer().getOfflinePlayer(this.getName())); - // CraftBukkit end - } - - protected void damageArmor(float f) { - this.inventory.a(f); - } - - public int aV() { - return this.inventory.l(); - } - - public float bE() { - int i = 0; - ItemStack[] aitemstack = this.inventory.armor; - int j = aitemstack.length; - - for (int k = 0; k < j; ++k) { - ItemStack itemstack = aitemstack[k]; - - if (itemstack != null) { - ++i; - } - } - - return (float) i / (float) this.inventory.armor.length; - } - - // CraftBukkit start - protected boolean d(DamageSource damagesource, float f) { // void -> boolean - if (true) { - return super.d(damagesource, f); - } - // CraftBukkit end - if (!this.isInvulnerable()) { - if (!damagesource.ignoresArmor() && this.isBlocking() && f > 0.0F) { - f = (1.0F + f) * 0.5F; - } - - f = this.applyArmorModifier(damagesource, f); - f = this.applyMagicModifier(damagesource, f); - float f1 = f; - - f = Math.max(f - this.getAbsorptionHearts(), 0.0F); - this.setAbsorptionHearts(this.getAbsorptionHearts() - (f1 - f)); - if (f != 0.0F) { - this.applyExhaustion(damagesource.getExhaustionCost()); - float f2 = this.getHealth(); - - this.setHealth(this.getHealth() - f); - this.aW().a(damagesource, f2, f); - } - } - return false; // CraftBukkit - } - - public void openFurnace(TileEntityFurnace tileentityfurnace) {} - - public void openDispenser(TileEntityDispenser tileentitydispenser) {} - - public void a(TileEntity tileentity) {} - - public void a(CommandBlockListenerAbstract commandblocklistenerabstract) {} - - public void openBrewingStand(TileEntityBrewingStand tileentitybrewingstand) {} - - public void openBeacon(TileEntityBeacon tileentitybeacon) {} - - public void openTrade(IMerchant imerchant, String s) {} - - public void b(ItemStack itemstack) {} - - public boolean q(Entity entity) { - ItemStack itemstack = this.bF(); - ItemStack itemstack1 = itemstack != null ? itemstack.cloneItemStack() : null; - - if (!entity.c(this)) { - if (itemstack != null && entity instanceof EntityLiving) { - if (this.abilities.canInstantlyBuild) { - itemstack = itemstack1; - } - - if (itemstack.a(this, (EntityLiving) entity)) { - // CraftBukkit - bypass infinite items; <= 0 -> == 0 - if (itemstack.count == 0 && !this.abilities.canInstantlyBuild) { - this.bG(); - } - - return true; - } - } - - return false; - } else { - if (itemstack != null && itemstack == this.bF()) { - if (itemstack.count <= 0 && !this.abilities.canInstantlyBuild) { - this.bG(); - } else if (itemstack.count < itemstack1.count && this.abilities.canInstantlyBuild) { - itemstack.count = itemstack1.count; - } - } - - return true; - } - } - - public ItemStack bF() { - return this.inventory.getItemInHand(); - } - - public void bG() { - this.inventory.setItem(this.inventory.itemInHandIndex, (ItemStack) null); - } - - public double ad() { - return (double) (this.height - 0.5F); - } - - public void attack(Entity entity) { - if (entity.av()) { - if (!entity.j(this)) { - float f = (float) this.getAttributeInstance(GenericAttributes.e).getValue(); - int i = 0; - float f1 = 0.0F; - - if (entity instanceof EntityLiving) { - f1 = EnchantmentManager.a((EntityLiving) this, (EntityLiving) entity); - i += EnchantmentManager.getKnockbackEnchantmentLevel(this, (EntityLiving) entity); - } - - if (this.isSprinting()) { - ++i; - } - - if (f > 0.0F || f1 > 0.0F) { - boolean flag = this.fallDistance > 0.0F && !this.onGround && !this.h_() && !this.M() && !this.hasEffect(MobEffectList.BLINDNESS) && this.vehicle == null && entity instanceof EntityLiving; - - if (flag && f > 0.0F) { - f *= 1.5F; - } - - f += f1; - boolean flag1 = false; - int j = EnchantmentManager.getFireAspectEnchantmentLevel(this); - - if (entity instanceof EntityLiving && j > 0 && !entity.isBurning()) { - // CraftBukkit start - Call a combust event when somebody hits with a fire enchanted item - EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), 1); - org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent); - - if (!combustEvent.isCancelled()) { - flag1 = true; - entity.setOnFire(combustEvent.getDuration()); - } - // CraftBukkit end - } - - boolean flag2 = entity.damageEntity(DamageSource.playerAttack(this), f); - - if (flag2) { - if (i > 0) { - entity.g((double) (-MathHelper.sin(this.yaw * 3.1415927F / 180.0F) * (float) i * 0.5F), 0.1D, (double) (MathHelper.cos(this.yaw * 3.1415927F / 180.0F) * (float) i * 0.5F)); - this.motX *= 0.6D; - this.motZ *= 0.6D; - this.setSprinting(false); - } - - if (flag) { - this.b(entity); - } - - if (f1 > 0.0F) { - this.c(entity); - } - - if (f >= 18.0F) { - this.a((Statistic) AchievementList.F); - } - - this.l(entity); - if (entity instanceof EntityLiving) { - EnchantmentManager.a((EntityLiving) entity, (Entity) this); - } - - EnchantmentManager.b(this, entity); - ItemStack itemstack = this.bF(); - Object object = entity; - - if (entity instanceof EntityComplexPart) { - IComplex icomplex = ((EntityComplexPart) entity).owner; - - if (icomplex != null && icomplex instanceof EntityLiving) { - object = (EntityLiving) icomplex; - } - } - - if (itemstack != null && object instanceof EntityLiving) { - itemstack.a((EntityLiving) object, this); - // CraftBukkit - bypass infinite items; <= 0 -> == 0 - if (itemstack.count == 0) { - this.bG(); - } - } - - if (entity instanceof EntityLiving) { - this.a(StatisticList.t, Math.round(f * 10.0F)); - if (j > 0) { - // CraftBukkit start - Call a combust event when somebody hits with a fire enchanted item - EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), j * 4); - org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent); - - if (!combustEvent.isCancelled()) { - entity.setOnFire(combustEvent.getDuration()); - } - // CraftBukkit end - } - } - - this.applyExhaustion(0.3F); - } else if (flag1) { - entity.extinguish(); - } - } - } - } - } - - public void b(Entity entity) {} - - public void c(Entity entity) {} - - public void die() { - super.die(); - this.defaultContainer.b(this); - if (this.activeContainer != null) { - this.activeContainer.b(this); - } - } - - public boolean inBlock() { - return !this.sleeping && super.inBlock(); - } - - public GameProfile getProfile() { - return this.i; - } - - public EnumBedResult a(int i, int j, int k) { - if (!this.world.isStatic) { - if (this.isSleeping() || !this.isAlive()) { - return EnumBedResult.OTHER_PROBLEM; - } - - if (!this.world.worldProvider.d()) { - return EnumBedResult.NOT_POSSIBLE_HERE; - } - - if (this.world.w()) { - return EnumBedResult.NOT_POSSIBLE_NOW; - } - - if (Math.abs(this.locX - (double) i) > 3.0D || Math.abs(this.locY - (double) j) > 2.0D || Math.abs(this.locZ - (double) k) > 3.0D) { - return EnumBedResult.TOO_FAR_AWAY; - } - - double d0 = 8.0D; - double d1 = 5.0D; - List list = this.world.a(EntityMonster.class, AxisAlignedBB.a((double) i - d0, (double) j - d1, (double) k - d0, (double) i + d0, (double) j + d1, (double) k + d0)); - - if (!list.isEmpty()) { - return EnumBedResult.NOT_SAFE; - } - } - - if (this.am()) { - this.mount((Entity) null); - } - - // CraftBukkit start - fire PlayerBedEnterEvent - if (this.getBukkitEntity() instanceof Player) { - Player player = (Player) this.getBukkitEntity(); - org.bukkit.block.Block bed = this.world.getWorld().getBlockAt(i, j, k); - - PlayerBedEnterEvent event = new PlayerBedEnterEvent(player, bed); - this.world.getServer().getPluginManager().callEvent(event); - - if (event.isCancelled()) { - return EnumBedResult.OTHER_PROBLEM; - } - } - // CraftBukkit end - - this.a(0.2F, 0.2F); - this.height = 0.2F; - if (this.world.isLoaded(i, j, k)) { - int l = this.world.getData(i, j, k); - int i1 = BlockBed.l(l); - float f = 0.5F; - float f1 = 0.5F; - - switch (i1) { - case 0: - f1 = 0.9F; - break; - - case 1: - f = 0.1F; - break; - - case 2: - f1 = 0.1F; - break; - - case 3: - f = 0.9F; - } - - this.w(i1); - this.setPosition((double) ((float) i + f), (double) ((float) j + 0.9375F), (double) ((float) k + f1)); - } else { - this.setPosition((double) ((float) i + 0.5F), (double) ((float) j + 0.9375F), (double) ((float) k + 0.5F)); - } - - this.sleeping = true; - this.sleepTicks = 0; - this.bB = new ChunkCoordinates(i, j, k); - this.motX = this.motZ = this.motY = 0.0D; - if (!this.world.isStatic) { - this.world.everyoneSleeping(); - } - - return EnumBedResult.OK; - } - - private void w(int i) { - this.bC = 0.0F; - this.bD = 0.0F; - switch (i) { - case 0: - this.bD = -1.8F; - break; - - case 1: - this.bC = 1.8F; - break; - - case 2: - this.bD = 1.8F; - break; - - case 3: - this.bC = -1.8F; - } - } - - public void a(boolean flag, boolean flag1, boolean flag2) { - this.a(0.6F, 1.8F); - this.e_(); - ChunkCoordinates chunkcoordinates = this.bB; - ChunkCoordinates chunkcoordinates1 = this.bB; - - if (chunkcoordinates != null && this.world.getType(chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z) == Blocks.BED) { - BlockBed.a(this.world, chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z, false); - chunkcoordinates1 = BlockBed.a(this.world, chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z, 0); - if (chunkcoordinates1 == null) { - chunkcoordinates1 = new ChunkCoordinates(chunkcoordinates.x, chunkcoordinates.y + 1, chunkcoordinates.z); - } - - this.setPosition((double) ((float) chunkcoordinates1.x + 0.5F), (double) ((float) chunkcoordinates1.y + this.height + 0.1F), (double) ((float) chunkcoordinates1.z + 0.5F)); - } - - this.sleeping = false; - if (!this.world.isStatic && flag1) { - this.world.everyoneSleeping(); - } - - // CraftBukkit start - fire PlayerBedLeaveEvent - if (this.getBukkitEntity() instanceof Player) { - Player player = (Player) this.getBukkitEntity(); - - org.bukkit.block.Block bed; - if (chunkcoordinates != null) { - bed = this.world.getWorld().getBlockAt(chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z); - } else { - bed = this.world.getWorld().getBlockAt(player.getLocation()); - } - - PlayerBedLeaveEvent event = new PlayerBedLeaveEvent(player, bed); - this.world.getServer().getPluginManager().callEvent(event); - } - // CraftBukkit end - - if (flag) { - this.sleepTicks = 0; - } else { - this.sleepTicks = 100; - } - - if (flag2) { - this.setRespawnPosition(this.bB, false); - } - } - - private boolean j() { - return this.world.getType(this.bB.x, this.bB.y, this.bB.z) == Blocks.BED; - } - - public static ChunkCoordinates getBed(World world, ChunkCoordinates chunkcoordinates, boolean flag) { - IChunkProvider ichunkprovider = world.L(); - - ichunkprovider.getChunkAt(chunkcoordinates.x - 3 >> 4, chunkcoordinates.z - 3 >> 4); - ichunkprovider.getChunkAt(chunkcoordinates.x + 3 >> 4, chunkcoordinates.z - 3 >> 4); - ichunkprovider.getChunkAt(chunkcoordinates.x - 3 >> 4, chunkcoordinates.z + 3 >> 4); - ichunkprovider.getChunkAt(chunkcoordinates.x + 3 >> 4, chunkcoordinates.z + 3 >> 4); - if (world.getType(chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z) == Blocks.BED) { - ChunkCoordinates chunkcoordinates1 = BlockBed.a(world, chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z, 0); - - return chunkcoordinates1; - } else { - Material material = world.getType(chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z).getMaterial(); - Material material1 = world.getType(chunkcoordinates.x, chunkcoordinates.y + 1, chunkcoordinates.z).getMaterial(); - boolean flag1 = !material.isBuildable() && !material.isLiquid(); - boolean flag2 = !material1.isBuildable() && !material1.isLiquid(); - - return flag && flag1 && flag2 ? chunkcoordinates : null; - } - } - - public boolean isSleeping() { - return this.sleeping; - } - - public boolean isDeeplySleeping() { - return this.sleeping && this.sleepTicks >= 100; - } - - protected void b(int i, boolean flag) { - byte b0 = this.datawatcher.getByte(16); - - if (flag) { - this.datawatcher.watch(16, Byte.valueOf((byte) (b0 | 1 << i))); - } else { - this.datawatcher.watch(16, Byte.valueOf((byte) (b0 & ~(1 << i)))); - } - } - - public void b(IChatBaseComponent ichatbasecomponent) {} - - public ChunkCoordinates getBed() { - return this.c; - } - - public boolean isRespawnForced() { - return this.d; - } - - public void setRespawnPosition(ChunkCoordinates chunkcoordinates, boolean flag) { - if (chunkcoordinates != null) { - this.c = new ChunkCoordinates(chunkcoordinates); - this.d = flag; - this.spawnWorld = this.world.worldData.getName(); // CraftBukkit - } else { - this.c = null; - this.d = false; - this.spawnWorld = ""; // CraftBukkit - } - } - - public void a(Statistic statistic) { - this.a(statistic, 1); - } - - public void a(Statistic statistic, int i) {} - - public void bj() { - super.bj(); - this.a(StatisticList.r, 1); - if (this.isSprinting()) { - this.applyExhaustion(0.8F); - } else { - this.applyExhaustion(0.2F); - } - } - - public void e(float f, float f1) { - double d0 = this.locX; - double d1 = this.locY; - double d2 = this.locZ; - - if (this.abilities.isFlying && this.vehicle == null) { - double d3 = this.motY; - float f2 = this.aQ; - - this.aQ = this.abilities.a(); - super.e(f, f1); - this.motY = d3 * 0.6D; - this.aQ = f2; - } else { - super.e(f, f1); - } - - this.checkMovement(this.locX - d0, this.locY - d1, this.locZ - d2); - } - - public float bl() { - return (float) this.getAttributeInstance(GenericAttributes.d).getValue(); - } - - public void checkMovement(double d0, double d1, double d2) { - if (this.vehicle == null) { - int i; - - if (this.a(Material.WATER)) { - i = Math.round(MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2) * 100.0F); - if (i > 0) { - this.a(StatisticList.m, i); - this.applyExhaustion(0.015F * (float) i * 0.01F); - } - } else if (this.M()) { - i = Math.round(MathHelper.sqrt(d0 * d0 + d2 * d2) * 100.0F); - if (i > 0) { - this.a(StatisticList.i, i); - this.applyExhaustion(0.015F * (float) i * 0.01F); - } - } else if (this.h_()) { - if (d1 > 0.0D) { - this.a(StatisticList.k, (int) Math.round(d1 * 100.0D)); - } - } else if (this.onGround) { - i = Math.round(MathHelper.sqrt(d0 * d0 + d2 * d2) * 100.0F); - if (i > 0) { - this.a(StatisticList.h, i); - if (this.isSprinting()) { - this.applyExhaustion(0.099999994F * (float) i * 0.01F); - } else { - this.applyExhaustion(0.01F * (float) i * 0.01F); - } - } - } else { - i = Math.round(MathHelper.sqrt(d0 * d0 + d2 * d2) * 100.0F); - if (i > 25) { - this.a(StatisticList.l, i); - } - } - } - } - - private void l(double d0, double d1, double d2) { - if (this.vehicle != null) { - int i = Math.round(MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2) * 100.0F); - - if (i > 0) { - if (this.vehicle instanceof EntityMinecartAbstract) { - this.a(StatisticList.n, i); - if (this.e == null) { - this.e = new ChunkCoordinates(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)); - } else if ((double) this.e.e(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)) >= 1000000.0D) { - this.a((Statistic) AchievementList.q, 1); - } - } else if (this.vehicle instanceof EntityBoat) { - this.a(StatisticList.o, i); - } else if (this.vehicle instanceof EntityPig) { - this.a(StatisticList.p, i); - } else if (this.vehicle instanceof EntityHorse) { - this.a(StatisticList.q, i); - } - } - } - } - - protected void b(float f) { - if (!this.abilities.canFly) { - if (f >= 2.0F) { - this.a(StatisticList.j, (int) Math.round((double) f * 100.0D)); - } - - super.b(f); - } - } - - protected String o(int i) { - return i > 4 ? "game.player.hurt.fall.big" : "game.player.hurt.fall.small"; - } - - public void a(EntityLiving entityliving) { - if (entityliving instanceof IMonster) { - this.a((Statistic) AchievementList.s); - } - - int i = EntityTypes.a(entityliving); - MonsterEggInfo monsteregginfo = (MonsterEggInfo) EntityTypes.eggInfo.get(Integer.valueOf(i)); - - if (monsteregginfo != null) { - this.a(monsteregginfo.killEntityStatistic, 1); - } - } - - public void as() { - if (!this.abilities.isFlying) { - super.as(); - } - } - - public ItemStack r(int i) { - return this.inventory.d(i); - } - - public void giveExp(int i) { - this.addScore(i); - int j = Integer.MAX_VALUE - this.expTotal; - - if (i > j) { - i = j; - } - - this.exp += (float) i / (float) this.getExpToLevel(); - - for (this.expTotal += i; this.exp >= 1.0F; this.exp /= (float) this.getExpToLevel()) { - this.exp = (this.exp - 1.0F) * (float) this.getExpToLevel(); - this.levelDown(1); - } - } - - public void levelDown(int i) { - this.expLevel += i; - if (this.expLevel < 0) { - this.expLevel = 0; - this.exp = 0.0F; - this.expTotal = 0; - } - - if (i > 0 && this.expLevel % 5 == 0 && (float) this.h < (float) this.ticksLived - 100.0F) { - float f = this.expLevel > 30 ? 1.0F : (float) this.expLevel / 30.0F; - - this.world.makeSound(this, "random.levelup", f * 0.75F, 1.0F); - this.h = this.ticksLived; - } - } - - public int getExpToLevel() { - return this.expLevel >= 30 ? 62 + (this.expLevel - 30) * 7 : (this.expLevel >= 15 ? 17 + (this.expLevel - 15) * 3 : 17); - } - - public void applyExhaustion(float f) { - if (!this.abilities.isInvulnerable) { - if (!this.world.isStatic) { - this.foodData.a(f); - } - } - } - - public FoodMetaData getFoodData() { - return this.foodData; - } - - public boolean g(boolean flag) { - return (flag || this.foodData.c()) && !this.abilities.isInvulnerable; - } - - public boolean bR() { - return this.getHealth() > 0.0F && this.getHealth() < this.getMaxHealth(); - } - - public void a(ItemStack itemstack, int i) { - if (itemstack != this.f) { - this.f = itemstack; - this.g = i; - if (!this.world.isStatic) { - this.e(true); - } - } - } - - public boolean d(int i, int j, int k) { - if (this.abilities.mayBuild) { - return true; - } else { - Block block = this.world.getType(i, j, k); - - if (block.getMaterial() != Material.AIR) { - if (block.getMaterial().q()) { - return true; - } - - if (this.bF() != null) { - ItemStack itemstack = this.bF(); - - if (itemstack.b(block) || itemstack.a(block) > 1.0F) { - return true; - } - } - } - - return false; - } - } - - public boolean a(int i, int j, int k, int l, ItemStack itemstack) { - return this.abilities.mayBuild ? true : (itemstack != null ? itemstack.z() : false); - } - - protected int getExpValue(EntityHuman entityhuman) { - if (this.world.getGameRules().getBoolean("keepInventory")) { - return 0; - } else { - int i = this.expLevel * 7; - - return i > 100 ? 100 : i; - } - } - - protected boolean alwaysGivesExp() { - return true; - } - - public void copyTo(EntityHuman entityhuman, boolean flag) { - if (flag) { - this.inventory.b(entityhuman.inventory); - this.setHealth(entityhuman.getHealth()); - this.foodData = entityhuman.foodData; - this.expLevel = entityhuman.expLevel; - this.expTotal = entityhuman.expTotal; - this.exp = entityhuman.exp; - this.setScore(entityhuman.getScore()); - this.aq = entityhuman.aq; - } else if (this.world.getGameRules().getBoolean("keepInventory")) { - this.inventory.b(entityhuman.inventory); - this.expLevel = entityhuman.expLevel; - this.expTotal = entityhuman.expTotal; - this.exp = entityhuman.exp; - this.setScore(entityhuman.getScore()); - } - - this.enderChest = entityhuman.enderChest; - } - - protected boolean g_() { - return !this.abilities.isFlying; - } - - public void updateAbilities() {} - - public void a(EnumGamemode enumgamemode) {} - - public String getName() { - return this.i.getName(); - } - - public World getWorld() { - return this.world; - } - - public InventoryEnderChest getEnderChest() { - return this.enderChest; - } - - public ItemStack getEquipment(int i) { - return i == 0 ? this.inventory.getItemInHand() : this.inventory.armor[i - 1]; - } - - public ItemStack be() { - return this.inventory.getItemInHand(); - } - - public void setEquipment(int i, ItemStack itemstack) { - this.inventory.armor[i] = itemstack; - } - - public ItemStack[] getEquipment() { - return this.inventory.armor; - } - - public boolean aC() { - return !this.abilities.isFlying; - } - - public Scoreboard getScoreboard() { - return this.world.getScoreboard(); - } - - public ScoreboardTeamBase getScoreboardTeam() { - return this.getScoreboard().getPlayerTeam(this.getName()); - } - - public IChatBaseComponent getScoreboardDisplayName() { - // CraftBukkit - todo: fun - ChatComponentText chatcomponenttext = new ChatComponentText(ScoreboardTeam.getPlayerDisplayName(this.getScoreboardTeam(), this.getName())); - - chatcomponenttext.getChatModifier().setChatClickable(new ChatClickable(EnumClickAction.SUGGEST_COMMAND, "/msg " + this.getName() + " ")); - return chatcomponenttext; - } - - public void setAbsorptionHearts(float f) { - if (f < 0.0F) { - f = 0.0F; - } - - this.getDataWatcher().watch(17, Float.valueOf(f)); - } - - public float getAbsorptionHearts() { - return this.getDataWatcher().getFloat(17); - } - - public static UUID a(GameProfile gameprofile) { - UUID uuid = gameprofile.getId(); - - if (uuid == null) { - uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + gameprofile.getName()).getBytes(Charsets.UTF_8)); - } - - return uuid; - } -} diff --git a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/EntityInsentient.java b/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/EntityInsentient.java deleted file mode 100644 index 9d4c7d3a4..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/EntityInsentient.java +++ /dev/null @@ -1,902 +0,0 @@ -package net.minecraft.server.v1_7_R4; - -import java.util.Iterator; -import java.util.List; -import java.util.UUID; - -// CraftBukkit start -import org.bukkit.craftbukkit.v1_7_R4.event.CraftEventFactory; -import org.bukkit.event.entity.EntityUnleashEvent; -import org.bukkit.event.entity.EntityUnleashEvent.UnleashReason; -// CraftBukkit end - -public abstract class EntityInsentient extends EntityLiving { - - public int a_; - protected int b; - private ControllerLook lookController; - private ControllerMove moveController; - private ControllerJump bm; - private EntityAIBodyControl bn; - private Navigation navigation; - protected final PathfinderGoalSelector goalSelector; - protected final PathfinderGoalSelector targetSelector; - private EntityLiving goalTarget; - private EntitySenses bq; - private ItemStack[] equipment = new ItemStack[5]; - public float[] dropChances = new float[5]; // CraftBukkit - protected -> public - public boolean canPickUpLoot; // CraftBukkit - private -> public - public boolean persistent = !isTypeNotPersistent(); // CraftBukkit - private -> public - protected float f; - private Entity bu; - protected int g; - private boolean bv; - private Entity bw; - private NBTTagCompound bx; - - public boolean Vegetated; - public boolean BreakLeash = true; - public boolean PullWhileLeashed = true; - - public EntityInsentient(World world) { - super(world); - this.goalSelector = new PathfinderGoalSelector(world != null && world.methodProfiler != null ? world.methodProfiler : null); - this.targetSelector = new PathfinderGoalSelector(world != null && world.methodProfiler != null ? world.methodProfiler : null); - this.lookController = new ControllerLook(this); - this.moveController = new ControllerMove(this); - this.bm = new ControllerJump(this); - this.bn = new EntityAIBodyControl(this); - this.navigation = new Navigation(this, world); - this.bq = new EntitySenses(this); - - for (int i = 0; i < this.dropChances.length; ++i) { - this.dropChances[i] = 0.085F; - } - } - - protected void aD() { - super.aD(); - this.getAttributeMap().b(GenericAttributes.b).setValue(16.0D); - } - - public ControllerLook getControllerLook() { - return this.lookController; - } - - public ControllerMove getControllerMove() { - return this.moveController; - } - - public ControllerJump getControllerJump() { - return this.bm; - } - - public Navigation getNavigation() { - return this.navigation; - } - - public EntitySenses getEntitySenses() { - return this.bq; - } - - public EntityLiving getGoalTarget() { - return this.goalTarget; - } - - public void setGoalTarget(EntityLiving entityliving) { - this.goalTarget = entityliving; - } - - public boolean a(Class oclass) { - return EntityCreeper.class != oclass && EntityGhast.class != oclass; - } - - public void p() {} - - protected void c() { - super.c(); - this.datawatcher.a(11, Byte.valueOf((byte) 0)); - this.datawatcher.a(10, ""); - } - - public int q() { - return 80; - } - - public void r() { - String s = this.t(); - - if (s != null) { - this.makeSound(s, this.bf(), this.bg()); - } - } - - public void C() { - super.C(); - this.world.methodProfiler.a("mobBaseTick"); - if (this.isAlive() && !Silent && this.random.nextInt(1000) < this.a_++) { - this.a_ = -this.q(); - this.r(); - } - - this.world.methodProfiler.b(); - } - - protected int getExpValue(EntityHuman entityhuman) { - if (this.b > 0) { - int i = this.b; - ItemStack[] aitemstack = this.getEquipment(); - - for (int j = 0; j < aitemstack.length; ++j) { - if (aitemstack[j] != null && this.dropChances[j] <= 1.0F) { - i += 1 + this.random.nextInt(3); - } - } - - return i; - } else { - return this.b; - } - } - - public void s() { - for (int i = 0; i < 20; ++i) { - double d0 = this.random.nextGaussian() * 0.02D; - double d1 = this.random.nextGaussian() * 0.02D; - double d2 = this.random.nextGaussian() * 0.02D; - double d3 = 10.0D; - - this.world.addParticle("explode", this.locX + (double) (this.random.nextFloat() * this.width * 2.0F) - (double) this.width - d0 * d3, this.locY + (double) (this.random.nextFloat() * this.length) - d1 * d3, this.locZ + (double) (this.random.nextFloat() * this.width * 2.0F) - (double) this.width - d2 * d3, d0, d1, d2); - } - } - - public void h() { - super.h(); - if (!this.world.isStatic) { - this.bL(); - } - } - - protected float f(float f, float f1) { - if (this.bk()) { - this.bn.a(); - return f1; - } else { - return super.f(f, f1); - } - } - - protected String t() { - return null; - } - - protected Item getLoot() { - return Item.getById(0); - } - - protected void dropDeathLoot(boolean flag, int i) { - Item item = this.getLoot(); - - if (item != null) { - int j = this.random.nextInt(3); - - if (i > 0) { - j += this.random.nextInt(i + 1); - } - - for (int k = 0; k < j; ++k) { - this.a(item, 1); - } - } - } - - public void b(NBTTagCompound nbttagcompound) { - super.b(nbttagcompound); - nbttagcompound.setBoolean("CanPickUpLoot", this.bJ()); - nbttagcompound.setBoolean("PersistenceRequired", this.persistent); - NBTTagList nbttaglist = new NBTTagList(); - - NBTTagCompound nbttagcompound1; - - for (int i = 0; i < this.equipment.length; ++i) { - nbttagcompound1 = new NBTTagCompound(); - if (this.equipment[i] != null) { - this.equipment[i].save(nbttagcompound1); - } - - nbttaglist.add(nbttagcompound1); - } - - nbttagcompound.set("Equipment", nbttaglist); - NBTTagList nbttaglist1 = new NBTTagList(); - - for (int j = 0; j < this.dropChances.length; ++j) { - nbttaglist1.add(new NBTTagFloat(this.dropChances[j])); - } - - nbttagcompound.set("DropChances", nbttaglist1); - nbttagcompound.setString("CustomName", this.getCustomName()); - nbttagcompound.setBoolean("CustomNameVisible", this.getCustomNameVisible()); - nbttagcompound.setBoolean("Leashed", this.bv); - if (this.bw != null) { - nbttagcompound1 = new NBTTagCompound(); - if (this.bw instanceof EntityLiving) { - nbttagcompound1.setLong("UUIDMost", this.bw.getUniqueID().getMostSignificantBits()); - nbttagcompound1.setLong("UUIDLeast", this.bw.getUniqueID().getLeastSignificantBits()); - } else if (this.bw instanceof EntityHanging) { - EntityHanging entityhanging = (EntityHanging) this.bw; - - nbttagcompound1.setInt("X", entityhanging.x); - nbttagcompound1.setInt("Y", entityhanging.y); - nbttagcompound1.setInt("Z", entityhanging.z); - } - - nbttagcompound.set("Leash", nbttagcompound1); - } - } - - public void a(NBTTagCompound nbttagcompound) { - super.a(nbttagcompound); - - // CraftBukkit start - If looting or persistence is false only use it if it was set after we started using it - boolean data = nbttagcompound.getBoolean("CanPickUpLoot"); - if (isLevelAtLeast(nbttagcompound, 1) || data) { - this.canPickUpLoot = data; - } - - data = nbttagcompound.getBoolean("PersistenceRequired"); - if (isLevelAtLeast(nbttagcompound, 1) || data) { - this.persistent = data; - } - // CraftBukkit end - - if (nbttagcompound.hasKeyOfType("CustomName", 8) && nbttagcompound.getString("CustomName").length() > 0) { - this.setCustomName(nbttagcompound.getString("CustomName")); - } - - this.setCustomNameVisible(nbttagcompound.getBoolean("CustomNameVisible")); - NBTTagList nbttaglist; - int i; - - if (nbttagcompound.hasKeyOfType("Equipment", 9)) { - nbttaglist = nbttagcompound.getList("Equipment", 10); - - for (i = 0; i < this.equipment.length; ++i) { - this.equipment[i] = ItemStack.createStack(nbttaglist.get(i)); - } - } - - if (nbttagcompound.hasKeyOfType("DropChances", 9)) { - nbttaglist = nbttagcompound.getList("DropChances", 5); - - for (i = 0; i < nbttaglist.size(); ++i) { - this.dropChances[i] = nbttaglist.e(i); - } - } - - this.bv = nbttagcompound.getBoolean("Leashed"); - if (this.bv && nbttagcompound.hasKeyOfType("Leash", 10)) { - this.bx = nbttagcompound.getCompound("Leash"); - } - } - - public void n(float f) { - this.be = f; - } - - public void i(float f) { - super.i(f); - this.n(f); - } - - public void e() { - super.e(); - this.world.methodProfiler.a("looting"); - if (!this.world.isStatic && this.bJ() && !this.aT && this.world.getGameRules().getBoolean("mobGriefing")) { - List list = this.world.a(EntityItem.class, this.boundingBox.grow(1.0D, 0.0D, 1.0D)); - Iterator iterator = list.iterator(); - - while (iterator.hasNext()) { - EntityItem entityitem = (EntityItem) iterator.next(); - - if (!entityitem.dead && entityitem.getItemStack() != null) { - ItemStack itemstack = entityitem.getItemStack(); - int i = b(itemstack); - - if (i > -1) { - boolean flag = true; - ItemStack itemstack1 = this.getEquipment(i); - - if (itemstack1 != null) { - if (i == 0) { - if (itemstack.getItem() instanceof ItemSword && !(itemstack1.getItem() instanceof ItemSword)) { - flag = true; - } else if (itemstack.getItem() instanceof ItemSword && itemstack1.getItem() instanceof ItemSword) { - ItemSword itemsword = (ItemSword) itemstack.getItem(); - ItemSword itemsword1 = (ItemSword) itemstack1.getItem(); - - if (itemsword.i() == itemsword1.i()) { - flag = itemstack.getData() > itemstack1.getData() || itemstack.hasTag() && !itemstack1.hasTag(); - } else { - flag = itemsword.i() > itemsword1.i(); - } - } else { - flag = false; - } - } else if (itemstack.getItem() instanceof ItemArmor && !(itemstack1.getItem() instanceof ItemArmor)) { - flag = true; - } else if (itemstack.getItem() instanceof ItemArmor && itemstack1.getItem() instanceof ItemArmor) { - ItemArmor itemarmor = (ItemArmor) itemstack.getItem(); - ItemArmor itemarmor1 = (ItemArmor) itemstack1.getItem(); - - if (itemarmor.c == itemarmor1.c) { - flag = itemstack.getData() > itemstack1.getData() || itemstack.hasTag() && !itemstack1.hasTag(); - } else { - flag = itemarmor.c > itemarmor1.c; - } - } else { - flag = false; - } - } - - if (flag) { - if (itemstack1 != null && this.random.nextFloat() - 0.1F < this.dropChances[i]) { - this.a(itemstack1, 0.0F); - } - - if (itemstack.getItem() == Items.DIAMOND && entityitem.j() != null) { - EntityHuman entityhuman = this.world.a(entityitem.j()); - - if (entityhuman != null) { - entityhuman.a((Statistic) AchievementList.x); - } - } - - this.setEquipment(i, itemstack); - this.dropChances[i] = 2.0F; - this.persistent = true; - this.receive(entityitem, 1); - entityitem.die(); - } - } - } - } - } - - this.world.methodProfiler.b(); - } - - protected boolean bk() { - return false; - } - - protected boolean isTypeNotPersistent() { - return true; - } - - protected void w() { - if (this.persistent) { - this.aU = 0; - } else { - EntityHuman entityhuman = this.world.findNearbyPlayer(this, -1.0D); - - if (entityhuman != null) { - double d0 = entityhuman.locX - this.locX; - double d1 = entityhuman.locY - this.locY; - double d2 = entityhuman.locZ - this.locZ; - double d3 = d0 * d0 + d1 * d1 + d2 * d2; - - if (d3 > 16384.0D) { // CraftBukkit - remove isTypeNotPersistent() check - this.die(); - } - - if (this.aU > 600 && this.random.nextInt(800) == 0 && d3 > 1024.0D) { // CraftBukkit - remove isTypeNotPersistent() check - this.die(); - } else if (d3 < 1024.0D) { - this.aU = 0; - } - } - } - } - - protected void bn() { - ++this.aU; - this.world.methodProfiler.a("checkDespawn"); - this.w(); - this.world.methodProfiler.b(); - // Spigot Start - if ( this.fromMobSpawner ) - { - return; - } - // Spigot End - this.world.methodProfiler.a("sensing"); - this.bq.a(); - this.world.methodProfiler.b(); - this.world.methodProfiler.a("targetSelector"); - this.targetSelector.a(); - this.world.methodProfiler.b(); - this.world.methodProfiler.a("goalSelector"); - this.goalSelector.a(); - this.world.methodProfiler.b(); - this.world.methodProfiler.a("navigation"); - this.navigation.f(); - this.world.methodProfiler.b(); - this.world.methodProfiler.a("mob tick"); - this.bp(); - this.world.methodProfiler.b(); - this.world.methodProfiler.a("controls"); - this.world.methodProfiler.a("move"); - this.moveController.c(); - this.world.methodProfiler.c("look"); - this.lookController.a(); - this.world.methodProfiler.c("jump"); - this.bm.b(); - this.world.methodProfiler.b(); - this.world.methodProfiler.b(); - } - - protected void bq() { - super.bq(); - this.bd = 0.0F; - this.be = 0.0F; - this.w(); - float f = 8.0F; - - if (this.random.nextFloat() < 0.02F) { - EntityHuman entityhuman = this.world.findNearbyPlayer(this, (double) f); - - if (entityhuman != null) { - this.bu = entityhuman; - this.g = 10 + this.random.nextInt(20); - } else { - this.bf = (this.random.nextFloat() - 0.5F) * 20.0F; - } - } - - if (this.bu != null) { - this.a(this.bu, 10.0F, (float) this.x()); - if (this.g-- <= 0 || this.bu.dead || this.bu.f((Entity) this) > (double) (f * f)) { - this.bu = null; - } - } else { - if (this.random.nextFloat() < 0.05F) { - this.bf = (this.random.nextFloat() - 0.5F) * 20.0F; - } - - this.yaw += this.bf; - this.pitch = this.f; - } - - boolean flag = this.M(); - boolean flag1 = this.P(); - - if (flag || flag1) { - this.bc = this.random.nextFloat() < 0.8F; - } - } - - public int x() { - return 40; - } - - public void a(Entity entity, float f, float f1) { - double d0 = entity.locX - this.locX; - double d1 = entity.locZ - this.locZ; - double d2; - - if (entity instanceof EntityLiving) { - EntityLiving entityliving = (EntityLiving) entity; - - d2 = entityliving.locY + (double) entityliving.getHeadHeight() - (this.locY + (double) this.getHeadHeight()); - } else { - d2 = (entity.boundingBox.b + entity.boundingBox.e) / 2.0D - (this.locY + (double) this.getHeadHeight()); - } - - double d3 = (double) MathHelper.sqrt(d0 * d0 + d1 * d1); - float f2 = (float) (Math.atan2(d1, d0) * 180.0D / 3.1415927410125732D) - 90.0F; - float f3 = (float) (-(Math.atan2(d2, d3) * 180.0D / 3.1415927410125732D)); - - this.pitch = this.b(this.pitch, f3, f1); - this.yaw = this.b(this.yaw, f2, f); - } - - private float b(float f, float f1, float f2) { - float f3 = MathHelper.g(f1 - f); - - if (f3 > f2) { - f3 = f2; - } - - if (f3 < -f2) { - f3 = -f2; - } - - return f + f3; - } - - public boolean canSpawn() { - return this.world.b(this.boundingBox) && this.world.getCubes(this, this.boundingBox).isEmpty() && !this.world.containsLiquid(this.boundingBox); - } - - public int bB() { - return 4; - } - - public int ax() { - if (this.getGoalTarget() == null) { - return 3; - } else { - int i = (int) (this.getHealth() - this.getMaxHealth() * 0.33F); - - i -= (3 - this.world.difficulty.a()) * 4; - if (i < 0) { - i = 0; - } - - return i + 3; - } - } - - public ItemStack be() { - return this.equipment[0]; - } - - public ItemStack getEquipment(int i) { - return this.equipment[i]; - } - - public ItemStack r(int i) { - return this.equipment[i + 1]; - } - - public void setEquipment(int i, ItemStack itemstack) { - this.equipment[i] = itemstack; - } - - public ItemStack[] getEquipment() { - return this.equipment; - } - - protected void dropEquipment(boolean flag, int i) { - for (int j = 0; j < this.getEquipment().length; ++j) { - ItemStack itemstack = this.getEquipment(j); - boolean flag1 = this.dropChances[j] > 1.0F; - - if (itemstack != null && (flag || flag1) && this.random.nextFloat() - (float) i * 0.01F < this.dropChances[j]) { - if (!flag1 && itemstack.g()) { - int k = Math.max(itemstack.l() - 25, 1); - int l = itemstack.l() - this.random.nextInt(this.random.nextInt(k) + 1); - - if (l > k) { - l = k; - } - - if (l < 1) { - l = 1; - } - - itemstack.setData(l); - } - - this.a(itemstack, 0.0F); - } - } - } - - protected void bC() { - if (this.random.nextFloat() < 0.15F * this.world.b(this.locX, this.locY, this.locZ)) { - int i = this.random.nextInt(2); - float f = this.world.difficulty == EnumDifficulty.HARD ? 0.1F : 0.25F; - - if (this.random.nextFloat() < 0.095F) { - ++i; - } - - if (this.random.nextFloat() < 0.095F) { - ++i; - } - - if (this.random.nextFloat() < 0.095F) { - ++i; - } - - for (int j = 3; j >= 0; --j) { - ItemStack itemstack = this.r(j); - - if (j < 3 && this.random.nextFloat() < f) { - break; - } - - if (itemstack == null) { - Item item = a(j + 1, i); - - if (item != null) { - this.setEquipment(j + 1, new ItemStack(item)); - } - } - } - } - } - - public static int b(ItemStack itemstack) { - if (itemstack.getItem() != Item.getItemOf(Blocks.PUMPKIN) && itemstack.getItem() != Items.SKULL) { - if (itemstack.getItem() instanceof ItemArmor) { - switch (((ItemArmor) itemstack.getItem()).b) { - case 0: - return 4; - - case 1: - return 3; - - case 2: - return 2; - - case 3: - return 1; - } - } - - return 0; - } else { - return 4; - } - } - - public static Item a(int i, int j) { - switch (i) { - case 4: - if (j == 0) { - return Items.LEATHER_HELMET; - } else if (j == 1) { - return Items.GOLD_HELMET; - } else if (j == 2) { - return Items.CHAINMAIL_HELMET; - } else if (j == 3) { - return Items.IRON_HELMET; - } else if (j == 4) { - return Items.DIAMOND_HELMET; - } - - case 3: - if (j == 0) { - return Items.LEATHER_CHESTPLATE; - } else if (j == 1) { - return Items.GOLD_CHESTPLATE; - } else if (j == 2) { - return Items.CHAINMAIL_CHESTPLATE; - } else if (j == 3) { - return Items.IRON_CHESTPLATE; - } else if (j == 4) { - return Items.DIAMOND_CHESTPLATE; - } - - case 2: - if (j == 0) { - return Items.LEATHER_LEGGINGS; - } else if (j == 1) { - return Items.GOLD_LEGGINGS; - } else if (j == 2) { - return Items.CHAINMAIL_LEGGINGS; - } else if (j == 3) { - return Items.IRON_LEGGINGS; - } else if (j == 4) { - return Items.DIAMOND_LEGGINGS; - } - - case 1: - if (j == 0) { - return Items.LEATHER_BOOTS; - } else if (j == 1) { - return Items.GOLD_BOOTS; - } else if (j == 2) { - return Items.CHAINMAIL_BOOTS; - } else if (j == 3) { - return Items.IRON_BOOTS; - } else if (j == 4) { - return Items.DIAMOND_BOOTS; - } - - default: - return null; - } - } - - protected void bD() { - float f = this.world.b(this.locX, this.locY, this.locZ); - - if (this.be() != null && this.random.nextFloat() < 0.25F * f) { - EnchantmentManager.a(this.random, this.be(), (int) (5.0F + f * (float) this.random.nextInt(18))); - } - - for (int i = 0; i < 4; ++i) { - ItemStack itemstack = this.r(i); - - if (itemstack != null && this.random.nextFloat() < 0.5F * f) { - EnchantmentManager.a(this.random, itemstack, (int) (5.0F + f * (float) this.random.nextInt(18))); - } - } - } - - public GroupDataEntity prepare(GroupDataEntity groupdataentity) { - this.getAttributeInstance(GenericAttributes.b).a(new AttributeModifier("Random spawn bonus", this.random.nextGaussian() * 0.05D, 1)); - return groupdataentity; - } - - public boolean bE() { - return false; - } - - public String getName() { - return this.hasCustomName() ? this.getCustomName() : super.getName(); - } - - public void bF() { - this.persistent = true; - } - - public void setCustomName(String s) { - this.datawatcher.watch(10, s); - } - - public String getCustomName() { - return this.datawatcher.getString(10); - } - - public boolean hasCustomName() { - return this.datawatcher.getString(10).length() > 0; - } - - public void setCustomNameVisible(boolean flag) { - this.datawatcher.watch(11, Byte.valueOf((byte) (flag ? 1 : 0))); - } - - public boolean getCustomNameVisible() { - return this.datawatcher.getByte(11) == 1; - } - - public void a(int i, float f) { - this.dropChances[i] = f; - } - - public boolean bJ() { - return this.canPickUpLoot; - } - - public void h(boolean flag) { - this.canPickUpLoot = flag; - } - - public boolean isPersistent() { - return this.persistent; - } - - public final boolean c(EntityHuman 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())); - return false; - } - // CraftBukkit end - this.unleash(true, !entityhuman.abilities.canInstantlyBuild); - return true; - } else { - ItemStack itemstack = entityhuman.inventory.getItemInHand(); - - if (itemstack != null && itemstack.getItem() == Items.LEASH && this.bM()) { - if (!(this instanceof EntityTameableAnimal) || !((EntityTameableAnimal) this).isTamed()) { - // CraftBukkit start - fire PlayerLeashEntityEvent - if (CraftEventFactory.callPlayerLeashEntityEvent(this, entityhuman, entityhuman).isCancelled()) { - ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutAttachEntity(1, this, this.getLeashHolder())); - return false; - } - // CraftBukkit end - this.setLeashHolder(entityhuman, true); - --itemstack.count; - return true; - } - - if (((EntityTameableAnimal) this).e(entityhuman)) { - // CraftBukkit start - fire PlayerLeashEntityEvent - if (CraftEventFactory.callPlayerLeashEntityEvent(this, entityhuman, entityhuman).isCancelled()) { - ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutAttachEntity(1, this, this.getLeashHolder())); - return false; - } - // CraftBukkit end - this.setLeashHolder(entityhuman, true); - --itemstack.count; - return true; - } - } - - return this.a(entityhuman) ? true : super.c(entityhuman); - } - } - - protected boolean a(EntityHuman entityhuman) { - return false; - } - - protected void bL() { - if (this.bx != null) { - this.bP(); - } - - if (this.bv) { - if (this.bw == null || this.bw.dead) { - this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.HOLDER_GONE)); // CraftBukkit - this.unleash(true, true); - } - } - } - - public void unleash(boolean flag, boolean flag1) { - if (this.bv && BreakLeash) { - this.bv = false; - this.bw = null; - if (!this.world.isStatic && flag1) { - this.a(Items.LEASH, 1); - } - - if (!this.world.isStatic && flag && this.world instanceof WorldServer) { - ((WorldServer) this.world).getTracker().a((Entity) this, (Packet) (new PacketPlayOutAttachEntity(1, this, (Entity) null))); - } - } - } - - public boolean bM() { - return !this.bN() && !(this instanceof IMonster); - } - - public boolean bN() { - return this.bv; - } - - public Entity getLeashHolder() { - return this.bw; - } - - public void setLeashHolder(Entity entity, boolean flag) { - this.bv = true; - this.bw = entity; - if (!this.world.isStatic && flag && this.world instanceof WorldServer) { - ((WorldServer) this.world).getTracker().a((Entity) this, (Packet) (new PacketPlayOutAttachEntity(1, this, this.bw))); - } - } - - private void bP() { - if (this.bv && this.bx != null) { - if (this.bx.hasKeyOfType("UUIDMost", 4) && this.bx.hasKeyOfType("UUIDLeast", 4)) { - UUID uuid = new UUID(this.bx.getLong("UUIDMost"), this.bx.getLong("UUIDLeast")); - List list = this.world.a(EntityLiving.class, this.boundingBox.grow(10.0D, 10.0D, 10.0D)); - Iterator iterator = list.iterator(); - - while (iterator.hasNext()) { - EntityLiving entityliving = (EntityLiving) iterator.next(); - - if (entityliving.getUniqueID().equals(uuid)) { - this.bw = entityliving; - break; - } - } - } else if (this.bx.hasKeyOfType("X", 99) && this.bx.hasKeyOfType("Y", 99) && this.bx.hasKeyOfType("Z", 99)) { - int i = this.bx.getInt("X"); - int j = this.bx.getInt("Y"); - int k = this.bx.getInt("Z"); - EntityLeash entityleash = EntityLeash.b(this.world, i, j, k); - - if (entityleash == null) { - entityleash = EntityLeash.a(this.world, i, j, k); - } - - this.bw = entityleash; - } else { - this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit - this.unleash(false, true); - } - } - - this.bx = null; - } -} diff --git a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/EntityLiving.java b/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/EntityLiving.java deleted file mode 100644 index 025f067c6..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/EntityLiving.java +++ /dev/null @@ -1,1745 +0,0 @@ -package net.minecraft.server.v1_7_R4; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Random; -import java.util.UUID; - -// CraftBukkit start -import java.util.ArrayList; -import com.google.common.base.Function; -import org.bukkit.craftbukkit.v1_7_R4.event.CraftEventFactory; -import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.event.entity.EntityDamageEvent.DamageModifier; -import org.bukkit.event.entity.EntityRegainHealthEvent; -// CraftBukkit end - -import org.bukkit.craftbukkit.v1_7_R4.SpigotTimings; // Spigot - -public abstract class EntityLiving extends Entity { - - private static final UUID b = UUID.fromString("662A6B8D-DA3E-4C1C-8813-96EA6097278D"); - private static final AttributeModifier c = (new AttributeModifier(b, "Sprinting speed boost", 0.30000001192092896D, 2)).a(false); - private AttributeMapBase d; - public CombatTracker combatTracker = new CombatTracker(this); // CraftBukkit - private -> public, remove final - public final HashMap effects = new HashMap(); // CraftBukkit - protected -> public - private final ItemStack[] g = new ItemStack[5]; - public boolean at; - public int au; - public int av; - public float aw; - public int hurtTicks; - public int ay; - public float az; - public int deathTicks; - public int attackTicks; - public float aC; - public float aD; - public float aE; - public float aF; - public float aG; - public int maxNoDamageTicks = 20; - public float aI; - public float aJ; - public float aK; - public float aL; - public float aM; - public float aN; - public float aO; - public float aP; - public float aQ = 0.02F; - public EntityHuman killer; // CraftBukkit - protected -> public - protected int lastDamageByPlayerTime; - protected boolean aT; - protected int aU; - protected float aV; - protected float aW; - protected float aX; - protected float aY; - protected float aZ; - protected int ba; - public float lastDamage; // CraftBukkit - protected -> public - protected boolean bc; - public float bd; - public float be; - protected float bf; - protected int bg; - protected double bh; - protected double bi; - protected double bj; - protected double bk; - protected double bl; - public boolean updateEffects = true; // CraftBukkit - private -> public - public EntityLiving lastDamager; // CraftBukkit - private -> public - private int bm; - private EntityLiving bn; - private int bo; - private float bp; - private int bq; - private float br; - // CraftBukkit start - public int expToDrop; - public int maxAirTicks = 300; - ArrayList drops = null; - // CraftBukkit end - // Spigot start - public void inactiveTick() - { - super.inactiveTick(); - ++this.aU; // Above all the floats - } - // Spigot end - public boolean ghost; - - public EntityLiving(World world) { - super(world); - this.aD(); - // CraftBukkit - setHealth(getMaxHealth()) inlined and simplified to skip the instanceof check for EntityPlayer, as getBukkitEntity() is not initialized in constructor - this.datawatcher.watch(6, (float) this.getAttributeInstance(GenericAttributes.maxHealth).getValue()); - this.k = true; - this.aL = (float) (Math.random() + 1.0D) * 0.01F; - this.setPosition(this.locX, this.locY, this.locZ); - this.aK = (float) Math.random() * 12398.0F; - this.yaw = (float) (Math.random() * 3.1415927410125732D * 2.0D); - this.aO = this.yaw; - this.W = 0.5F; - } - - protected void c() { - this.datawatcher.a(7, Integer.valueOf(0)); - this.datawatcher.a(8, Byte.valueOf((byte) 0)); - this.datawatcher.a(9, Byte.valueOf((byte) 0)); - this.datawatcher.a(6, Float.valueOf(1.0F)); - } - - protected void aD() { - this.getAttributeMap().b(GenericAttributes.maxHealth); - this.getAttributeMap().b(GenericAttributes.c); - this.getAttributeMap().b(GenericAttributes.d); - if (!this.bk()) { - this.getAttributeInstance(GenericAttributes.d).setValue(0.10000000149011612D); - } - } - - protected void a(double d0, boolean flag) { - if (!this.M()) { - this.N(); - } - - if (flag && this.fallDistance > 0.0F) { - int i = MathHelper.floor(this.locX); - int j = MathHelper.floor(this.locY - 0.20000000298023224D - (double) this.height); - int k = MathHelper.floor(this.locZ); - Block block = this.world.getType(i, j, k); - - if (block.getMaterial() == Material.AIR) { - int l = this.world.getType(i, j - 1, k).b(); - - if (l == 11 || l == 32 || l == 21) { - block = this.world.getType(i, j - 1, k); - } - } else if (!this.world.isStatic && this.fallDistance > 3.0F) { - // CraftBukkit start - supply player as argument in particles for visibility API to work - if (this instanceof EntityPlayer) { - this.world.a((EntityHuman) this, 2006, i, j, k, MathHelper.f(this.fallDistance - 3.0F)); - ((EntityPlayer) this).playerConnection.sendPacket(new PacketPlayOutWorldEvent(2006, i, j, k, MathHelper.f(this.fallDistance - 3.0F), false)); - } else { - this.world.triggerEffect(2006, i, j, k, MathHelper.f(this.fallDistance - 3.0F)); - } - // CraftBukkit end - } - - block.a(this.world, i, j, k, this, this.fallDistance); - } - - super.a(d0, flag); - } - - public boolean aE() { - return false; - } - - public void C() { - this.aC = this.aD; - super.C(); - this.world.methodProfiler.a("livingEntityBaseTick"); - if (this.isAlive() && this.inBlock()) { - this.damageEntity(DamageSource.STUCK, 1.0F); - } - - if (this.isFireproof() || this.world.isStatic) { - this.extinguish(); - } - - boolean flag = this instanceof EntityHuman && ((EntityHuman) this).abilities.isInvulnerable; - - if (this.isAlive() && this.a(Material.WATER)) { - if (!this.aE() && !this.hasEffect(MobEffectList.WATER_BREATHING.id) && !flag) { - this.setAirTicks(this.j(this.getAirTicks())); - if (this.getAirTicks() == -20) { - this.setAirTicks(0); - - for (int i = 0; i < 8; ++i) { - float f = this.random.nextFloat() - this.random.nextFloat(); - float f1 = this.random.nextFloat() - this.random.nextFloat(); - float f2 = this.random.nextFloat() - this.random.nextFloat(); - - this.world.addParticle("bubble", this.locX + (double) f, this.locY + (double) f1, this.locZ + (double) f2, this.motX, this.motY, this.motZ); - } - - this.damageEntity(DamageSource.DROWN, 2.0F); - } - } - - if (!this.world.isStatic && this.am() && this.vehicle instanceof EntityLiving) { - this.mount((Entity) null); - } - } else { - // CraftBukkit start - Only set if needed to work around a DataWatcher inefficiency - if (this.getAirTicks() != 300) { - this.setAirTicks(maxAirTicks); - } - // CraftBukkit end - } - - if (this.isAlive() && this.L()) { - this.extinguish(); - } - - this.aI = this.aJ; - if (this.attackTicks > 0) { - --this.attackTicks; - } - - if (this.hurtTicks > 0) { - --this.hurtTicks; - } - - if (this.noDamageTicks > 0 && !(this instanceof EntityPlayer)) { - --this.noDamageTicks; - } - - if (this.getHealth() <= 0.0F) { - this.aF(); - } - - if (this.lastDamageByPlayerTime > 0) { - --this.lastDamageByPlayerTime; - } else { - this.killer = null; - } - - if (this.bn != null && !this.bn.isAlive()) { - this.bn = null; - } - - if (this.lastDamager != null) { - if (!this.lastDamager.isAlive()) { - this.b((EntityLiving) null); - } else if (this.ticksLived - this.bm > 100) { - this.b((EntityLiving) null); - } - } - - this.aO(); - this.aY = this.aX; - this.aN = this.aM; - this.aP = this.aO; - this.lastYaw = this.yaw; - this.lastPitch = this.pitch; - this.world.methodProfiler.b(); - } - - // CraftBukkit start - public int getExpReward() { - int exp = this.getExpValue(this.killer); - - if (!this.world.isStatic && (this.lastDamageByPlayerTime > 0 || this.alwaysGivesExp()) && this.aG() && this.world.getGameRules().getBoolean("doMobLoot")) { - return exp; - } else { - return 0; - } - } - // CraftBukkit end - - public boolean isBaby() { - return false; - } - - protected void aF() { - ++this.deathTicks; - if (this.deathTicks >= 20 && !this.dead) { // CraftBukkit - (this.deathTicks == 20) -> (this.deathTicks >= 20 && !this.dead) - int i; - - // CraftBukkit start - Update getExpReward() above if the removed if() changes! - i = this.expToDrop; - while (i > 0) { - int j = EntityExperienceOrb.getOrbValue(i); - - i -= j; - this.world.addEntity(new EntityExperienceOrb(this.world, this.locX, this.locY, this.locZ, j)); - } - this.expToDrop = 0; - // CraftBukkit end - - this.die(); - - for (i = 0; i < 20; ++i) { - double d0 = this.random.nextGaussian() * 0.02D; - double d1 = this.random.nextGaussian() * 0.02D; - double d2 = this.random.nextGaussian() * 0.02D; - - this.world.addParticle("explode", this.locX + (double) (this.random.nextFloat() * this.width * 2.0F) - (double) this.width, this.locY + (double) (this.random.nextFloat() * this.length), this.locZ + (double) (this.random.nextFloat() * this.width * 2.0F) - (double) this.width, d0, d1, d2); - } - } - } - - protected boolean aG() { - return !this.isBaby(); - } - - protected int j(int i) { - int j = EnchantmentManager.getOxygenEnchantmentLevel(this); - - return j > 0 && this.random.nextInt(j + 1) > 0 ? i : i - 1; - } - - protected int getExpValue(EntityHuman entityhuman) { - return 0; - } - - protected boolean alwaysGivesExp() { - return false; - } - - public Random aI() { - return this.random; - } - - public EntityLiving getLastDamager() { - return this.lastDamager; - } - - public int aK() { - return this.bm; - } - - public void b(EntityLiving entityliving) { - this.lastDamager = entityliving; - this.bm = this.ticksLived; - } - - public EntityLiving aL() { - return this.bn; - } - - public int aM() { - return this.bo; - } - - public void l(Entity entity) { - if (entity instanceof EntityLiving) { - this.bn = (EntityLiving) entity; - } else { - this.bn = null; - } - - this.bo = this.ticksLived; - } - - public int aN() { - return this.aU; - } - - public void b(NBTTagCompound nbttagcompound) { - nbttagcompound.setFloat("HealF", this.getHealth()); - nbttagcompound.setShort("Health", (short) ((int) Math.ceil((double) this.getHealth()))); - nbttagcompound.setShort("HurtTime", (short) this.hurtTicks); - nbttagcompound.setShort("DeathTime", (short) this.deathTicks); - nbttagcompound.setShort("AttackTime", (short) this.attackTicks); - nbttagcompound.setFloat("AbsorptionAmount", this.getAbsorptionHearts()); - ItemStack[] aitemstack = this.getEquipment(); - int i = aitemstack.length; - - int j; - ItemStack itemstack; - - for (j = 0; j < i; ++j) { - itemstack = aitemstack[j]; - if (itemstack != null) { - this.d.a(itemstack.D()); - } - } - - nbttagcompound.set("Attributes", GenericAttributes.a(this.getAttributeMap())); - aitemstack = this.getEquipment(); - i = aitemstack.length; - - for (j = 0; j < i; ++j) { - itemstack = aitemstack[j]; - if (itemstack != null) { - this.d.b(itemstack.D()); - } - } - - if (!this.effects.isEmpty()) { - NBTTagList nbttaglist = new NBTTagList(); - Iterator iterator = this.effects.values().iterator(); - - while (iterator.hasNext()) { - MobEffect mobeffect = (MobEffect) iterator.next(); - - nbttaglist.add(mobeffect.a(new NBTTagCompound())); - } - - nbttagcompound.set("ActiveEffects", nbttaglist); - } - } - - public void a(NBTTagCompound nbttagcompound) { - this.setAbsorptionHearts(nbttagcompound.getFloat("AbsorptionAmount")); - if (nbttagcompound.hasKeyOfType("Attributes", 9) && this.world != null && !this.world.isStatic) { - GenericAttributes.a(this.getAttributeMap(), nbttagcompound.getList("Attributes", 10)); - } - - if (nbttagcompound.hasKeyOfType("ActiveEffects", 9)) { - NBTTagList nbttaglist = nbttagcompound.getList("ActiveEffects", 10); - - for (int i = 0; i < nbttaglist.size(); ++i) { - NBTTagCompound nbttagcompound1 = nbttaglist.get(i); - MobEffect mobeffect = MobEffect.b(nbttagcompound1); - - if (mobeffect != null) { - this.effects.put(Integer.valueOf(mobeffect.getEffectId()), mobeffect); - } - } - } - - // CraftBukkit start - if (nbttagcompound.hasKey("Bukkit.MaxHealth")) { - NBTBase nbtbase = nbttagcompound.get("Bukkit.MaxHealth"); - if (nbtbase.getTypeId() == 5) { - this.getAttributeInstance(GenericAttributes.maxHealth).setValue((double) ((NBTTagFloat) nbtbase).c()); - } else if (nbtbase.getTypeId() == 3) { - this.getAttributeInstance(GenericAttributes.maxHealth).setValue((double) ((NBTTagInt) nbtbase).d()); - } - } - // CraftBukkit end - - if (nbttagcompound.hasKeyOfType("HealF", 99)) { - this.setHealth(nbttagcompound.getFloat("HealF")); - } else { - NBTBase nbtbase = nbttagcompound.get("Health"); - - if (nbtbase == null) { - this.setHealth(this.getMaxHealth()); - } else if (nbtbase.getTypeId() == 5) { - this.setHealth(((NBTTagFloat) nbtbase).h()); - } else if (nbtbase.getTypeId() == 2) { - this.setHealth((float) ((NBTTagShort) nbtbase).e()); - } - } - - this.hurtTicks = nbttagcompound.getShort("HurtTime"); - this.deathTicks = nbttagcompound.getShort("DeathTime"); - this.attackTicks = nbttagcompound.getShort("AttackTime"); - } - - protected void aO() { - Iterator iterator = this.effects.keySet().iterator(); - - while (iterator.hasNext()) { - Integer integer = (Integer) iterator.next(); - MobEffect mobeffect = (MobEffect) this.effects.get(integer); - - if (!mobeffect.tick(this)) { - if (!this.world.isStatic) { - iterator.remove(); - this.b(mobeffect); - } - } else if (mobeffect.getDuration() % 600 == 0) { - this.a(mobeffect, false); - } - } - - int i; - - if (this.updateEffects) { - if (!this.world.isStatic) { - if (this.effects.isEmpty()) { - this.datawatcher.watch(8, Byte.valueOf((byte) 0)); - this.datawatcher.watch(7, Integer.valueOf(0)); - this.setInvisible(false); - } else { - i = PotionBrewer.a(this.effects.values()); - this.datawatcher.watch(8, Byte.valueOf((byte) (PotionBrewer.b(this.effects.values()) ? 1 : 0))); - this.datawatcher.watch(7, Integer.valueOf(i)); - this.setInvisible(this.hasEffect(MobEffectList.INVISIBILITY.id)); - } - } - - this.updateEffects = false; - } - - i = this.datawatcher.getInt(7); - boolean flag = this.datawatcher.getByte(8) > 0; - - if (i > 0) { - boolean flag1 = false; - - if (!this.isInvisible()) { - flag1 = this.random.nextBoolean(); - } else { - flag1 = this.random.nextInt(15) == 0; - } - - if (flag) { - flag1 &= this.random.nextInt(5) == 0; - } - - if (flag1 && i > 0) { - double d0 = (double) (i >> 16 & 255) / 255.0D; - double d1 = (double) (i >> 8 & 255) / 255.0D; - double d2 = (double) (i >> 0 & 255) / 255.0D; - - this.world.addParticle(flag ? "mobSpellAmbient" : "mobSpell", this.locX + (this.random.nextDouble() - 0.5D) * (double) this.width, this.locY + this.random.nextDouble() * (double) this.length - (double) this.height, this.locZ + (this.random.nextDouble() - 0.5D) * (double) this.width, d0, d1, d2); - } - } - } - - public void removeAllEffects() { - Iterator iterator = this.effects.keySet().iterator(); - - while (iterator.hasNext()) { - Integer integer = (Integer) iterator.next(); - MobEffect mobeffect = (MobEffect) this.effects.get(integer); - - if (!this.world.isStatic) { - iterator.remove(); - this.b(mobeffect); - } - } - } - - public Collection getEffects() { - return this.effects.values(); - } - - public boolean hasEffect(int i) { - // CraftBukkit - Add size check for efficiency - return this.effects.size() != 0 && this.effects.containsKey(Integer.valueOf(i)); - } - - public boolean hasEffect(MobEffectList mobeffectlist) { - // CraftBukkit - Add size check for efficiency - return this.effects.size() != 0 && this.effects.containsKey(Integer.valueOf(mobeffectlist.id)); - } - - public MobEffect getEffect(MobEffectList mobeffectlist) { - return (MobEffect) this.effects.get(Integer.valueOf(mobeffectlist.id)); - } - - public void addEffect(MobEffect mobeffect) { - if (this.d(mobeffect)) { - if (this.effects.containsKey(Integer.valueOf(mobeffect.getEffectId()))) { - ((MobEffect) this.effects.get(Integer.valueOf(mobeffect.getEffectId()))).a(mobeffect); - this.a((MobEffect) this.effects.get(Integer.valueOf(mobeffect.getEffectId())), true); - } else { - this.effects.put(Integer.valueOf(mobeffect.getEffectId()), mobeffect); - this.a(mobeffect); - } - } - } - - public boolean d(MobEffect mobeffect) { - if (this.getMonsterType() == EnumMonsterType.UNDEAD) { - int i = mobeffect.getEffectId(); - - if (i == MobEffectList.REGENERATION.id || i == MobEffectList.POISON.id) { - return false; - } - } - - return true; - } - - public boolean aR() { - return this.getMonsterType() == EnumMonsterType.UNDEAD; - } - - public void removeEffect(int i) { - MobEffect mobeffect = (MobEffect) this.effects.remove(Integer.valueOf(i)); - - if (mobeffect != null) { - this.b(mobeffect); - } - } - - protected void a(MobEffect mobeffect) { - this.updateEffects = true; - if (!this.world.isStatic) { - MobEffectList.byId[mobeffect.getEffectId()].b(this, this.getAttributeMap(), mobeffect.getAmplifier()); - } - } - - protected void a(MobEffect mobeffect, boolean flag) { - this.updateEffects = true; - if (flag && !this.world.isStatic) { - MobEffectList.byId[mobeffect.getEffectId()].a(this, this.getAttributeMap(), mobeffect.getAmplifier()); - MobEffectList.byId[mobeffect.getEffectId()].b(this, this.getAttributeMap(), mobeffect.getAmplifier()); - } - } - - protected void b(MobEffect mobeffect) { - this.updateEffects = true; - if (!this.world.isStatic) { - MobEffectList.byId[mobeffect.getEffectId()].a(this, this.getAttributeMap(), mobeffect.getAmplifier()); - } - } - - // CraftBukkit start - Delegate so we can handle providing a reason for health being regained - public void heal(float f) { - heal(f, EntityRegainHealthEvent.RegainReason.CUSTOM); - } - - public void heal(float f, EntityRegainHealthEvent.RegainReason regainReason) { - float f1 = this.getHealth(); - - if (f1 > 0.0F) { - EntityRegainHealthEvent event = new EntityRegainHealthEvent(this.getBukkitEntity(), f, regainReason); - this.world.getServer().getPluginManager().callEvent(event); - - if (!event.isCancelled()) { - this.setHealth((float) (this.getHealth() + event.getAmount())); - } - } - } - - public final float getHealth() { - // CraftBukkit start - Use unscaled health - if (this instanceof EntityPlayer) { - return (float) ((EntityPlayer) this).getBukkitEntity().getHealth(); - } - // CraftBukkit end - return this.datawatcher.getFloat(6); - } - - public void setHealth(float f) { - // CraftBukkit start - Handle scaled health - if (this instanceof EntityPlayer) { - org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer player = ((EntityPlayer) this).getBukkitEntity(); - // Squeeze - if (f < 0.0F) { - player.setRealHealth(0.0D); - } else if (f > player.getMaxHealth()) { - player.setRealHealth(player.getMaxHealth()); - } else { - player.setRealHealth(f); - } - - this.datawatcher.watch(6, Float.valueOf(player.getScaledHealth())); - return; - } - // CraftBukkit end - this.datawatcher.watch(6, Float.valueOf(MathHelper.a(f, 0.0F, this.getMaxHealth()))); - } - - public boolean damageEntity(DamageSource damagesource, float f) { - if (this.isInvulnerable()) { - return false; - } else if (this.world.isStatic) { - return false; - } else { - this.aU = 0; - if (this.getHealth() <= 0.0F) { - return false; - } else if (damagesource.o() && this.hasEffect(MobEffectList.FIRE_RESISTANCE)) { - return false; - } else { - // CraftBukkit - Moved into d(DamageSource, float) - if (false && (damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && this.getEquipment(4) != null) { - this.getEquipment(4).damage((int) (f * 4.0F + this.random.nextFloat() * f * 2.0F), this); - f *= 0.75F; - } - - this.aF = 1.5F; - boolean flag = true; - - if ((float) this.noDamageTicks > (float) this.maxNoDamageTicks / 2.0F) { - if (f <= this.lastDamage) { - return false; - } - - // CraftBukkit start - if (!this.d(damagesource, f - this.lastDamage)) { - return false; - } - // CraftBukkit end - this.lastDamage = f; - flag = false; - } else { - // CraftBukkit start - float previousHealth = this.getHealth(); - if (!this.d(damagesource, f)) { - return false; - } - this.lastDamage = f; - this.aw = previousHealth; - this.noDamageTicks = this.maxNoDamageTicks; - // CraftBukkit end - this.hurtTicks = this.ay = 10; - } - - this.az = 0.0F; - Entity entity = damagesource.getEntity(); - - if (entity != null) { - if (entity instanceof EntityLiving) { - this.b((EntityLiving) entity); - } - - if (entity instanceof EntityHuman) { - this.lastDamageByPlayerTime = 100; - this.killer = (EntityHuman) entity; - } else if (entity instanceof EntityWolf) { - EntityWolf entitywolf = (EntityWolf) entity; - - if (entitywolf.isTamed()) { - this.lastDamageByPlayerTime = 100; - this.killer = null; - } - } - } - - if (flag) { - this.world.broadcastEntityEffect(this, (byte) 2); - if (damagesource != DamageSource.DROWN) { - this.Q(); - } - - if (entity != null) { - double d0 = entity.locX - this.locX; - - double d1; - - for (d1 = entity.locZ - this.locZ; d0 * d0 + d1 * d1 < 1.0E-4D; d1 = (Math.random() - Math.random()) * 0.01D) { - d0 = (Math.random() - Math.random()) * 0.01D; - } - - this.az = (float) (Math.atan2(d1, d0) * 180.0D / 3.1415927410125732D) - this.yaw; - this.a(entity, f, d0, d1); - } else { - this.az = (float) ((int) (Math.random() * 2.0D) * 180); - } - } - - String s; - - if (this.getHealth() <= 0.0F) { - s = this.aU(); - if (flag && s != null) { - this.makeSound(s, this.bf(), this.bg()); - } - - this.die(damagesource); - } else { - s = this.aT(); - if (flag && s != null) { - this.makeSound(s, this.bf(), this.bg()); - } - } - - return true; - } - } - } - - public void a(ItemStack itemstack) { - this.makeSound("random.break", 0.8F, 0.8F + this.world.random.nextFloat() * 0.4F); - - for (int i = 0; i < 5; ++i) { - Vec3D vec3d = Vec3D.a(((double) this.random.nextFloat() - 0.5D) * 0.1D, Math.random() * 0.1D + 0.1D, 0.0D); - - vec3d.a(-this.pitch * 3.1415927F / 180.0F); - vec3d.b(-this.yaw * 3.1415927F / 180.0F); - Vec3D vec3d1 = Vec3D.a(((double) this.random.nextFloat() - 0.5D) * 0.3D, (double) (-this.random.nextFloat()) * 0.6D - 0.3D, 0.6D); - - vec3d1.a(-this.pitch * 3.1415927F / 180.0F); - vec3d1.b(-this.yaw * 3.1415927F / 180.0F); - vec3d1 = vec3d1.add(this.locX, this.locY + (double) this.getHeadHeight(), this.locZ); - this.world.addParticle("iconcrack_" + Item.getId(itemstack.getItem()), vec3d1.a, vec3d1.b, vec3d1.c, vec3d.a, vec3d.b + 0.05D, vec3d.c); - } - } - - public void die(DamageSource damagesource) { - Entity entity = damagesource.getEntity(); - EntityLiving entityliving = this.aX(); - - if (this.ba >= 0 && entityliving != null) { - entityliving.b(this, this.ba); - } - - if (entity != null) { - entity.a(this); - } - - this.aT = true; - this.aW().g(); - if (!this.world.isStatic) { - int i = 0; - - if (entity instanceof EntityHuman) { - i = EnchantmentManager.getBonusMonsterLootEnchantmentLevel((EntityLiving) entity); - } - - if (this.aG() && this.world.getGameRules().getBoolean("doMobLoot")) { - this.drops = new ArrayList(); // CraftBukkit - Setup drop capture - - this.dropDeathLoot(this.lastDamageByPlayerTime > 0, i); - this.dropEquipment(this.lastDamageByPlayerTime > 0, i); - if (this.lastDamageByPlayerTime > 0) { - int j = this.random.nextInt(200) - i; - - if (j < 5) { - this.getRareDrop(j <= 0 ? 1 : 0); - } - } - - // CraftBukkit start - Call death event - CraftEventFactory.callEntityDeathEvent(this, this.drops); - this.drops = null; - } else { - CraftEventFactory.callEntityDeathEvent(this); - // CraftBukkit end - } - } - - this.world.broadcastEntityEffect(this, (byte) 3); - } - - protected void dropEquipment(boolean flag, int i) {} - - public void a(Entity entity, float f, double d0, double d1) { - if (this.random.nextDouble() >= this.getAttributeInstance(GenericAttributes.c).getValue()) { - this.al = true; - float f1 = MathHelper.sqrt(d0 * d0 + d1 * d1); - float f2 = 0.4F; - - this.motX /= 2.0D; - this.motY /= 2.0D; - this.motZ /= 2.0D; - this.motX -= d0 / (double) f1 * (double) f2; - this.motY += (double) f2; - this.motZ -= d1 / (double) f1 * (double) f2; - if (this.motY > 0.4000000059604645D) { - this.motY = 0.4000000059604645D; - } - } - } - - protected String aT() { - return "game.neutral.hurt"; - } - - protected String aU() { - return "game.neutral.die"; - } - - protected void getRareDrop(int i) {} - - protected void dropDeathLoot(boolean flag, int i) {} - - public boolean h_() { - int i = MathHelper.floor(this.locX); - int j = MathHelper.floor(this.boundingBox.b); - int k = MathHelper.floor(this.locZ); - Block block = this.world.getType(i, j, k); - - return block == Blocks.LADDER || block == Blocks.VINE; - } - - public boolean isAlive() { - return !this.dead && this.getHealth() > 0.0F; - } - - protected void b(float f) { - super.b(f); - MobEffect mobeffect = this.getEffect(MobEffectList.JUMP); - float f1 = mobeffect != null ? (float) (mobeffect.getAmplifier() + 1) : 0.0F; - int i = MathHelper.f(f - 3.0F - f1); - - if (i > 0) { - // CraftBukkit start - if (!this.damageEntity(DamageSource.FALL, (float) i)) { - return; - } - // CraftBukkit end - this.makeSound(this.o(i), 1.0F, 1.0F); - // this.damageEntity(DamageSource.FALL, (float) i); // CraftBukkit - moved up - int j = MathHelper.floor(this.locX); - int k = MathHelper.floor(this.locY - 0.20000000298023224D - (double) this.height); - int l = MathHelper.floor(this.locZ); - Block block = this.world.getType(j, k, l); - - if (block.getMaterial() != Material.AIR) { - StepSound stepsound = block.stepSound; - - this.makeSound(stepsound.getStepSound(), stepsound.getVolume1() * 0.5F, stepsound.getVolume2() * 0.75F); - } - } - } - - protected String o(int i) { - return i > 4 ? "game.neutral.hurt.fall.big" : "game.neutral.hurt.fall.small"; - } - - public int aV() { - int i = 0; - ItemStack[] aitemstack = this.getEquipment(); - int j = aitemstack.length; - - for (int k = 0; k < j; ++k) { - ItemStack itemstack = aitemstack[k]; - - if (itemstack != null && itemstack.getItem() instanceof ItemArmor) { - int l = ((ItemArmor) itemstack.getItem()).c; - - i += l; - } - } - - return i; - } - - protected void damageArmor(float f) {} - - protected float applyArmorModifier(DamageSource damagesource, float f) { - if (!damagesource.ignoresArmor()) { - int i = 25 - this.aV(); - float f1 = f * (float) i; - - // this.damageArmor(f); // CraftBukkit - Moved into d(DamageSource, float) - f = f1 / 25.0F; - } - - return f; - } - - protected float applyMagicModifier(DamageSource damagesource, float f) { - if (damagesource.isStarvation()) { - return f; - } else { - if (this instanceof EntityZombie) { - f = f; - } - - int i; - int j; - float f1; - - // CraftBukkit - Moved to d(DamageSource, float) - if (false && this.hasEffect(MobEffectList.RESISTANCE) && damagesource != DamageSource.OUT_OF_WORLD) { - i = (this.getEffect(MobEffectList.RESISTANCE).getAmplifier() + 1) * 5; - j = 25 - i; - f1 = f * (float) j; - f = f1 / 25.0F; - } - - if (f <= 0.0F) { - return 0.0F; - } else { - i = EnchantmentManager.a(this.getEquipment(), damagesource); - if (i > 20) { - i = 20; - } - - if (i > 0 && i <= 20) { - j = 25 - i; - f1 = f * (float) j; - f = f1 / 25.0F; - } - - return f; - } - } - } - - // CraftBukkit start - protected boolean d(final DamageSource damagesource, float f) { // void -> boolean, add final - if (!this.isInvulnerable()) { - final boolean human = this instanceof EntityHuman; - float originalDamage = f; - Function hardHat = new Function() { - @Override - public Double apply(Double f) { - if ((damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && EntityLiving.this.getEquipment(4) != null) { - return -(f - (f * 0.75F)); - } - return -0.0; - } - }; - float hardHatModifier = hardHat.apply((double) f).floatValue(); - f += hardHatModifier; - - Function blocking = new Function() { - @Override - public Double apply(Double f) { - if (human) { - if (!damagesource.ignoresArmor() && ((EntityHuman) EntityLiving.this).isBlocking() && f > 0.0F) { - return -(f - ((1.0F + f) * 0.5F)); - } - } - return -0.0; - } - }; - float blockingModifier = blocking.apply((double) f).floatValue(); - f += blockingModifier; - - Function armor = new Function() { - @Override - public Double apply(Double f) { - return -(f - EntityLiving.this.applyArmorModifier(damagesource, f.floatValue())); - } - }; - float armorModifier = armor.apply((double) f).floatValue(); - f += armorModifier; - - Function resistance = new Function() { - @Override - public Double apply(Double f) { - if (!damagesource.isStarvation() && EntityLiving.this.hasEffect(MobEffectList.RESISTANCE) && damagesource != DamageSource.OUT_OF_WORLD) { - int i = (EntityLiving.this.getEffect(MobEffectList.RESISTANCE).getAmplifier() + 1) * 5; - int j = 25 - i; - float f1 = f.floatValue() * (float) j; - return -(f - (f1 / 25.0F)); - } - return -0.0; - } - }; - float resistanceModifier = resistance.apply((double) f).floatValue(); - f += resistanceModifier; - - Function magic = new Function() { - @Override - public Double apply(Double f) { - return -(f - EntityLiving.this.applyMagicModifier(damagesource, f.floatValue())); - } - }; - float magicModifier = magic.apply((double) f).floatValue(); - f += magicModifier; - - Function absorption = new Function() { - @Override - public Double apply(Double f) { - return -(Math.max(f - Math.max(f - EntityLiving.this.getAbsorptionHearts(), 0.0F), 0.0F)); - } - }; - float absorptionModifier = absorption.apply((double) f).floatValue(); - - EntityDamageEvent event = CraftEventFactory.handleLivingEntityDamageEvent(this, damagesource, originalDamage, hardHatModifier, blockingModifier, armorModifier, resistanceModifier, magicModifier, absorptionModifier, hardHat, blocking, armor, resistance, magic, absorption); - if (event.isCancelled()) { - return false; - } - - f = (float) event.getFinalDamage(); - - // Apply damage to helmet - if ((damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && this.getEquipment(4) != null) { - this.getEquipment(4).damage((int) (event.getDamage() * 4.0F + this.random.nextFloat() * event.getDamage() * 2.0F), this); - } - - // Apply damage to armor - if (!damagesource.ignoresArmor()) { - float armorDamage = (float) (event.getDamage() + event.getDamage(DamageModifier.BLOCKING) + event.getDamage(DamageModifier.HARD_HAT)); - this.damageArmor(armorDamage); - } - - absorptionModifier = (float) -event.getDamage(DamageModifier.ABSORPTION); - this.setAbsorptionHearts(Math.max(this.getAbsorptionHearts() - absorptionModifier, 0.0F)); - if (f != 0.0F) { - if (human) { - ((EntityHuman) this).applyExhaustion(damagesource.getExhaustionCost()); - } - // CraftBukkit end - float f2 = this.getHealth(); - - this.setHealth(f2 - f); - this.aW().a(damagesource, f2, f); - // CraftBukkit start - if (human) { - return true; - } - // CraftBukkit end - this.setAbsorptionHearts(this.getAbsorptionHearts() - f); - } - return true; // CraftBukkit - } - return false; // CraftBukkit - } - - public CombatTracker aW() { - return this.combatTracker; - } - - public EntityLiving aX() { - return (EntityLiving) (this.combatTracker.c() != null ? this.combatTracker.c() : (this.killer != null ? this.killer : (this.lastDamager != null ? this.lastDamager : null))); - } - - public final float getMaxHealth() { - return (float) this.getAttributeInstance(GenericAttributes.maxHealth).getValue(); - } - - public final int aZ() { - return this.datawatcher.getByte(9); - } - - public final void p(int i) { - this.datawatcher.watch(9, Byte.valueOf((byte) i)); - } - - private int j() { - return this.hasEffect(MobEffectList.FASTER_DIG) ? 6 - (1 + this.getEffect(MobEffectList.FASTER_DIG).getAmplifier()) * 1 : (this.hasEffect(MobEffectList.SLOWER_DIG) ? 6 + (1 + this.getEffect(MobEffectList.SLOWER_DIG).getAmplifier()) * 2 : 6); - } - - public void ba() { - if (!this.at || this.au >= this.j() / 2 || this.au < 0) { - this.au = -1; - this.at = true; - if (this.world instanceof WorldServer) { - ((WorldServer) this.world).getTracker().a((Entity) this, (Packet) (new PacketPlayOutAnimation(this, 0))); - } - } - } - - protected void G() { - this.damageEntity(DamageSource.OUT_OF_WORLD, 4.0F); - } - - protected void bb() { - int i = this.j(); - - if (this.at) { - ++this.au; - if (this.au >= i) { - this.au = 0; - this.at = false; - } - } else { - this.au = 0; - } - - this.aD = (float) this.au / (float) i; - } - - public AttributeInstance getAttributeInstance(IAttribute iattribute) { - return this.getAttributeMap().a(iattribute); - } - - public AttributeMapBase getAttributeMap() { - if (this.d == null) { - this.d = new AttributeMapServer(); - } - - return this.d; - } - - public EnumMonsterType getMonsterType() { - return EnumMonsterType.UNDEFINED; - } - - public abstract ItemStack be(); - - public abstract ItemStack getEquipment(int i); - - public abstract void setEquipment(int i, ItemStack itemstack); - - public void setSprinting(boolean flag) { - super.setSprinting(flag); - AttributeInstance attributeinstance = this.getAttributeInstance(GenericAttributes.d); - - if (attributeinstance.a(b) != null) { - attributeinstance.b(c); - } - - if (flag) { - attributeinstance.a(c); - } - } - - public abstract ItemStack[] getEquipment(); - - protected float bf() { - return 1.0F; - } - - protected float bg() { - return this.isBaby() ? (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.5F : (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F; - } - - protected boolean bh() { - return this.getHealth() <= 0.0F; - } - - public void enderTeleportTo(double d0, double d1, double d2) { - this.setPositionRotation(d0, d1, d2, this.yaw, this.pitch); - } - - public void m(Entity entity) { - double d0 = entity.locX; - double d1 = entity.boundingBox.b + (double) entity.length; - double d2 = entity.locZ; - byte b0 = 1; - - for (int i = -b0; i <= b0; ++i) { - for (int j = -b0; j < b0; ++j) { - if (i != 0 || j != 0) { - int k = (int) (this.locX + (double) i); - int l = (int) (this.locZ + (double) j); - AxisAlignedBB axisalignedbb = this.boundingBox.c((double) i, 1.0D, (double) j); - - if (this.world.a(axisalignedbb).isEmpty()) { - if (World.a((IBlockAccess) this.world, k, (int) this.locY, l)) { - this.enderTeleportTo(this.locX + (double) i, this.locY + 1.0D, this.locZ + (double) j); - return; - } - - if (World.a((IBlockAccess) this.world, k, (int) this.locY - 1, l) || this.world.getType(k, (int) this.locY - 1, l).getMaterial() == Material.WATER) { - d0 = this.locX + (double) i; - d1 = this.locY + 1.0D; - d2 = this.locZ + (double) j; - } - } - } - } - } - - this.enderTeleportTo(d0, d1, d2); - } - - protected void bj() { - this.motY = 0.41999998688697815D; - if (this.hasEffect(MobEffectList.JUMP)) { - this.motY += (double) ((float) (this.getEffect(MobEffectList.JUMP).getAmplifier() + 1) * 0.1F); - } - - if (this.isSprinting()) { - float f = this.yaw * 0.017453292F; - - this.motX -= (double) (MathHelper.sin(f) * 0.2F); - this.motZ += (double) (MathHelper.cos(f) * 0.2F); - } - - this.al = true; - } - - public void e(float f, float f1) { - double d0; - - if (this.M() && (!(this instanceof EntityHuman) || !((EntityHuman) this).abilities.isFlying)) { - d0 = this.locY; - this.a(f, f1, this.bk() ? 0.04F : 0.02F); - this.move(this.motX, this.motY, this.motZ); - this.motX *= 0.800000011920929D; - this.motY *= 0.800000011920929D; - this.motZ *= 0.800000011920929D; - this.motY -= 0.02D; - if (this.positionChanged && this.c(this.motX, this.motY + 0.6000000238418579D - this.locY + d0, this.motZ)) { - this.motY = 0.30000001192092896D; - } - } else if (this.P() && (!(this instanceof EntityHuman) || !((EntityHuman) this).abilities.isFlying)) { - d0 = this.locY; - this.a(f, f1, 0.02F); - this.move(this.motX, this.motY, this.motZ); - this.motX *= 0.5D; - this.motY *= 0.5D; - this.motZ *= 0.5D; - this.motY -= 0.02D; - if (this.positionChanged && this.c(this.motX, this.motY + 0.6000000238418579D - this.locY + d0, this.motZ)) { - this.motY = 0.30000001192092896D; - } - } else { - float f2 = 0.91F; - - if (this.onGround) { - f2 = this.world.getType(MathHelper.floor(this.locX), MathHelper.floor(this.boundingBox.b) - 1, MathHelper.floor(this.locZ)).frictionFactor * 0.91F; - } - - float f3 = 0.16277136F / (f2 * f2 * f2); - float f4; - - if (this.onGround) { - f4 = this.bl() * f3; - } else { - f4 = this.aQ; - } - - this.a(f, f1, f4); - f2 = 0.91F; - if (this.onGround) { - f2 = this.world.getType(MathHelper.floor(this.locX), MathHelper.floor(this.boundingBox.b) - 1, MathHelper.floor(this.locZ)).frictionFactor * 0.91F; - } - - if (this.h_()) { - float f5 = 0.15F; - - if (this.motX < (double) (-f5)) { - this.motX = (double) (-f5); - } - - if (this.motX > (double) f5) { - this.motX = (double) f5; - } - - if (this.motZ < (double) (-f5)) { - this.motZ = (double) (-f5); - } - - if (this.motZ > (double) f5) { - this.motZ = (double) f5; - } - - this.fallDistance = 0.0F; - if (this.motY < -0.15D) { - this.motY = -0.15D; - } - - boolean flag = this.isSneaking() && this instanceof EntityHuman; - - if (flag && this.motY < 0.0D) { - this.motY = 0.0D; - } - } - - this.move(this.motX, this.motY, this.motZ); - if (this.positionChanged && this.h_()) { - this.motY = 0.2D; - } - - if (this.world.isStatic && (!this.world.isLoaded((int) this.locX, 0, (int) this.locZ) || !this.world.getChunkAtWorldCoords((int) this.locX, (int) this.locZ).d)) { - if (this.locY > 0.0D) { - this.motY = -0.1D; - } else { - this.motY = 0.0D; - } - } else { - this.motY -= 0.08D; - } - - this.motY *= 0.9800000190734863D; - this.motX *= (double) f2; - this.motZ *= (double) f2; - } - - this.aE = this.aF; - d0 = this.locX - this.lastX; - double d1 = this.locZ - this.lastZ; - float f6 = MathHelper.sqrt(d0 * d0 + d1 * d1) * 4.0F; - - if (f6 > 1.0F) { - f6 = 1.0F; - } - - this.aF += (f6 - this.aF) * 0.4F; - this.aG += this.aF; - } - - protected boolean bk() { - return false; - } - - public float bl() { - return this.bk() ? this.bp : 0.1F; - } - - public void i(float f) { - this.bp = f; - } - - public boolean n(Entity entity) { - this.l(entity); - return false; - } - - public boolean isSleeping() { - return false; - } - - public void h() { - SpigotTimings.timerEntityBaseTick.startTiming(); // Spigot - super.h(); - if (!this.world.isStatic) { - int i = this.aZ(); - - if (i > 0) { - if (this.av <= 0) { - this.av = 20 * (30 - i); - } - - --this.av; - if (this.av <= 0) { - this.p(i - 1); - } - } - - for (int j = 0; j < 5; ++j) { - ItemStack itemstack = this.g[j]; - ItemStack itemstack1 = this.getEquipment(j); - - if (!ItemStack.matches(itemstack1, itemstack)) { - ((WorldServer) this.world).getTracker().a((Entity) this, (Packet) (new PacketPlayOutEntityEquipment(this.getId(), j, itemstack1))); - if (itemstack != null) { - this.d.a(itemstack.D()); - } - - if (itemstack1 != null) { - this.d.b(itemstack1.D()); - } - - this.g[j] = itemstack1 == null ? null : itemstack1.cloneItemStack(); - } - } - - if (this.ticksLived % 20 == 0) { - this.aW().g(); - } - } - - SpigotTimings.timerEntityBaseTick.stopTiming(); // Spigot - this.e(); - SpigotTimings.timerEntityTickRest.startTiming(); // Spigot - double d0 = this.locX - this.lastX; - double d1 = this.locZ - this.lastZ; - float f = (float) (d0 * d0 + d1 * d1); - float f1 = this.aM; - float f2 = 0.0F; - - this.aV = this.aW; - float f3 = 0.0F; - - if (f > 0.0025000002F) { - f3 = 1.0F; - f2 = (float) Math.sqrt((double) f) * 3.0F; - // CraftBukkit - Math -> TrigMath - f1 = (float) org.bukkit.craftbukkit.v1_7_R4.TrigMath.atan2(d1, d0) * 180.0F / 3.1415927F - 90.0F; - } - - if (this.aD > 0.0F) { - f1 = this.yaw; - } - - if (!this.onGround) { - f3 = 0.0F; - } - - this.aW += (f3 - this.aW) * 0.3F; - this.world.methodProfiler.a("headTurn"); - f2 = this.f(f1, f2); - this.world.methodProfiler.b(); - this.world.methodProfiler.a("rangeChecks"); - - while (this.yaw - this.lastYaw < -180.0F) { - this.lastYaw -= 360.0F; - } - - while (this.yaw - this.lastYaw >= 180.0F) { - this.lastYaw += 360.0F; - } - - while (this.aM - this.aN < -180.0F) { - this.aN -= 360.0F; - } - - while (this.aM - this.aN >= 180.0F) { - this.aN += 360.0F; - } - - while (this.pitch - this.lastPitch < -180.0F) { - this.lastPitch -= 360.0F; - } - - while (this.pitch - this.lastPitch >= 180.0F) { - this.lastPitch += 360.0F; - } - - while (this.aO - this.aP < -180.0F) { - this.aP -= 360.0F; - } - - while (this.aO - this.aP >= 180.0F) { - this.aP += 360.0F; - } - - this.world.methodProfiler.b(); - this.aX += f2; - SpigotTimings.timerEntityTickRest.stopTiming(); // Spigot - } - - protected float f(float f, float f1) { - float f2 = MathHelper.g(f - this.aM); - - this.aM += f2 * 0.3F; - float f3 = MathHelper.g(this.yaw - this.aM); - boolean flag = f3 < -90.0F || f3 >= 90.0F; - - if (f3 < -75.0F) { - f3 = -75.0F; - } - - if (f3 >= 75.0F) { - f3 = 75.0F; - } - - this.aM = this.yaw - f3; - if (f3 * f3 > 2500.0F) { - this.aM += f3 * 0.2F; - } - - if (flag) { - f1 *= -1.0F; - } - - return f1; - } - - public void e() { - if (this.bq > 0) { - --this.bq; - } - - if (this.bg > 0) { - double d0 = this.locX + (this.bh - this.locX) / (double) this.bg; - double d1 = this.locY + (this.bi - this.locY) / (double) this.bg; - double d2 = this.locZ + (this.bj - this.locZ) / (double) this.bg; - double d3 = MathHelper.g(this.bk - (double) this.yaw); - - this.yaw = (float) ((double) this.yaw + d3 / (double) this.bg); - this.pitch = (float) ((double) this.pitch + (this.bl - (double) this.pitch) / (double) this.bg); - --this.bg; - this.setPosition(d0, d1, d2); - this.b(this.yaw, this.pitch); - } else if (!this.br()) { - this.motX *= 0.98D; - this.motY *= 0.98D; - this.motZ *= 0.98D; - } - - if (Math.abs(this.motX) < 0.005D) { - this.motX = 0.0D; - } - - if (Math.abs(this.motY) < 0.005D) { - this.motY = 0.0D; - } - - if (Math.abs(this.motZ) < 0.005D) { - this.motZ = 0.0D; - } - - this.world.methodProfiler.a("ai"); - SpigotTimings.timerEntityAI.startTiming(); // Spigot - if (this.bh()) { - this.bc = false; - this.bd = 0.0F; - this.be = 0.0F; - this.bf = 0.0F; - } else if (this.br()) { - if (this.bk()) { - this.world.methodProfiler.a("newAi"); - this.bn(); - this.world.methodProfiler.b(); - } else { - this.world.methodProfiler.a("oldAi"); - this.bq(); - this.world.methodProfiler.b(); - this.aO = this.yaw; - } - } - SpigotTimings.timerEntityAI.stopTiming(); // Spigot - - this.world.methodProfiler.b(); - this.world.methodProfiler.a("jump"); - if (this.bc) { - if (!this.M() && !this.P()) { - if (this.onGround && this.bq == 0) { - this.bj(); - this.bq = 10; - } - } else { - this.motY += 0.03999999910593033D; - } - } else { - this.bq = 0; - } - - this.world.methodProfiler.b(); - this.world.methodProfiler.a("travel"); - this.bd *= 0.98F; - this.be *= 0.98F; - this.bf *= 0.9F; - SpigotTimings.timerEntityAIMove.startTiming(); // Spigot - this.e(this.bd, this.be); - SpigotTimings.timerEntityAIMove.stopTiming(); // Spigot - this.world.methodProfiler.b(); - this.world.methodProfiler.a("push"); - if (!this.world.isStatic) { - SpigotTimings.timerEntityAICollision.startTiming(); // Spigot - this.bo(); - SpigotTimings.timerEntityAICollision.stopTiming(); // Spigot - } - - this.world.methodProfiler.b(); - } - - protected void bn() {} - - protected void bo() { - List list = this.world.getEntities(this, this.boundingBox.grow(0.20000000298023224D, 0.0D, 0.20000000298023224D)); - - if (this.R() && list != null && !list.isEmpty()) { // Spigot: Add this.R() condition - numCollisions -= world.spigotConfig.maxCollisionsPerEntity; // Spigot - for (int i = 0; i < list.size(); ++i) { - if (numCollisions > world.spigotConfig.maxCollisionsPerEntity) { break; } // Spigot - Entity entity = (Entity) list.get(i); - - // TODO better check now? - // CraftBukkit start - Only handle mob (non-player) collisions every other tick - if (entity instanceof EntityLiving && !(this instanceof EntityPlayer) && this.ticksLived % 2 == 0) { - continue; - } - // CraftBukkit end - - if (entity.S()) { - entity.numCollisions++; // Spigot - numCollisions++; // Spigot - this.o(entity); - } - } - numCollisions = 0; // Spigot - } - } - - protected void o(Entity entity) { - entity.collide(this); - } - - public void ab() { - super.ab(); - this.aV = this.aW; - this.aW = 0.0F; - this.fallDistance = 0.0F; - } - - protected void bp() {} - - protected void bq() { - ++this.aU; - } - - public void f(boolean flag) { - this.bc = flag; - } - - public void receive(Entity entity, int i) { - if (!entity.dead && !this.world.isStatic) { - EntityTracker entitytracker = ((WorldServer) this.world).getTracker(); - - if (entity instanceof EntityItem) { - entitytracker.a(entity, (Packet) (new PacketPlayOutCollect(entity.getId(), this.getId()))); - } - - if (entity instanceof EntityArrow) { - entitytracker.a(entity, (Packet) (new PacketPlayOutCollect(entity.getId(), this.getId()))); - } - - if (entity instanceof EntityExperienceOrb) { - entitytracker.a(entity, (Packet) (new PacketPlayOutCollect(entity.getId(), this.getId()))); - } - } - } - - public boolean hasLineOfSight(Entity entity) { - return this.world.a(Vec3D.a(this.locX, this.locY + (double) this.getHeadHeight(), this.locZ), Vec3D.a(entity.locX, entity.locY + (double) entity.getHeadHeight(), entity.locZ)) == null; - } - - public Vec3D ag() { - return this.j(1.0F); - } - - public Vec3D j(float f) { - float f1; - float f2; - float f3; - float f4; - - if (f == 1.0F) { - f1 = MathHelper.cos(-this.yaw * 0.017453292F - 3.1415927F); - f2 = MathHelper.sin(-this.yaw * 0.017453292F - 3.1415927F); - f3 = -MathHelper.cos(-this.pitch * 0.017453292F); - f4 = MathHelper.sin(-this.pitch * 0.017453292F); - return Vec3D.a((double) (f2 * f3), (double) f4, (double) (f1 * f3)); - } else { - f1 = this.lastPitch + (this.pitch - this.lastPitch) * f; - f2 = this.lastYaw + (this.yaw - this.lastYaw) * f; - f3 = MathHelper.cos(-f2 * 0.017453292F - 3.1415927F); - f4 = MathHelper.sin(-f2 * 0.017453292F - 3.1415927F); - float f5 = -MathHelper.cos(-f1 * 0.017453292F); - float f6 = MathHelper.sin(-f1 * 0.017453292F); - - return Vec3D.a((double) (f4 * f5), (double) f6, (double) (f3 * f5)); - } - } - - public boolean br() { - return !this.world.isStatic; - } - - public boolean R() { - return !this.dead; - } - - public boolean S() { - return !ghost && !this.dead; - } - - public float getHeadHeight() { - return this.length * 0.85F; - } - - protected void Q() { - this.velocityChanged = this.random.nextDouble() >= this.getAttributeInstance(GenericAttributes.c).getValue(); - } - - public float getHeadRotation() { - return this.aO; - } - - public float getAbsorptionHearts() { - return this.br; - } - - public void setAbsorptionHearts(float f) { - if (f < 0.0F) { - f = 0.0F; - } - - this.br = f; - } - - public ScoreboardTeamBase getScoreboardTeam() { - return null; - } - - public boolean c(EntityLiving entityliving) { - return this.a(entityliving.getScoreboardTeam()); - } - - public boolean a(ScoreboardTeamBase scoreboardteambase) { - return this.getScoreboardTeam() != null ? this.getScoreboardTeam().isAlly(scoreboardteambase) : false; - } - - public void bu() {} - - public void bv() {} -} diff --git a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/EntityPlayer.java b/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/EntityPlayer.java deleted file mode 100644 index 15eaf0373..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/EntityPlayer.java +++ /dev/null @@ -1,1130 +0,0 @@ -package net.minecraft.server.v1_7_R4; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - -import net.minecraft.util.com.google.common.collect.Sets; -import net.minecraft.util.com.mojang.authlib.GameProfile; -import net.minecraft.util.io.netty.buffer.Unpooled; -import net.minecraft.util.org.apache.commons.io.Charsets; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -// CraftBukkit start -import org.bukkit.Bukkit; -import org.bukkit.WeatherType; -import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; -import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; -import org.bukkit.craftbukkit.v1_7_R4.event.CraftEventFactory; -import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack; -import org.bukkit.event.inventory.InventoryType; -import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; -// CraftBukkit end - -public class EntityPlayer extends EntityHuman implements ICrafting { - - private static final Logger bL = LogManager.getLogger(); - public String locale = "en_US"; // Spigot - public PlayerConnection playerConnection; - public final MinecraftServer server; - public final PlayerInteractManager playerInteractManager; - public double d; - public double e; - public final List chunkCoordIntPairQueue = new LinkedList(); - public final List removeQueue = new LinkedList(); // CraftBukkit - private -> public - private final ServerStatisticManager bO; - private float bP = Float.MIN_VALUE; - private float bQ = -1.0E8F; - private int bR = -99999999; - private boolean bS = true; - public int lastSentExp = -99999999; // CraftBukkit - private -> public - public int invulnerableTicks = 60; // CraftBukkit - private -> public - private EnumChatVisibility bV; - private boolean bW = true; - private long bX = System.currentTimeMillis(); - private int containerCounter; - public boolean g; - public int ping; - public boolean viewingCredits; - // CraftBukkit start - public String displayName; - public String listName; - public org.bukkit.Location compassTarget; - public int newExp = 0; - public int newLevel = 0; - public int newTotalExp = 0; - public boolean keepLevel = false; - public double maxHealthCache; - public boolean joining = true; - public int lastPing = -1; // Spigot - // CraftBukkit end - // Spigot start - public boolean collidesWithEntities = true; - - @Override - public boolean R() - { - return !spectating && this.collidesWithEntities && super.R(); // (first !this.isDead near bottom of EntityLiving) - } - - @Override - public boolean S() - { - return this.collidesWithEntities && super.S(); // (second !this.isDead near bottom of EntityLiving) - } - // Spigot end - - public boolean spectating; // Mineplex - - public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, PlayerInteractManager playerinteractmanager) { - super(worldserver, gameprofile); - playerinteractmanager.player = this; - this.playerInteractManager = playerinteractmanager; - ChunkCoordinates chunkcoordinates = worldserver.getSpawn(); - int i = chunkcoordinates.x; - int j = chunkcoordinates.z; - int k = chunkcoordinates.y; - - if (!worldserver.worldProvider.g && worldserver.getWorldData().getGameType() != EnumGamemode.ADVENTURE) { - int l = Math.max(5, minecraftserver.getSpawnProtection() - 6); - - i += this.random.nextInt(l * 2) - l; - j += this.random.nextInt(l * 2) - l; - k = worldserver.i(i, j); - } - - this.server = minecraftserver; - this.bO = minecraftserver.getPlayerList().a((EntityHuman) this); - this.W = 0.0F; - this.height = 0.0F; - this.setPositionRotation((double) i + 0.5D, (double) k, (double) j + 0.5D, 0.0F, 0.0F); - - while (!worldserver.getCubes(this, this.boundingBox).isEmpty()) { - this.setPosition(this.locX, this.locY + 1.0D, this.locZ); - } - - // CraftBukkit start - this.displayName = this.getName(); - this.listName = this.getName(); - // this.canPickUpLoot = true; TODO - this.maxHealthCache = this.getMaxHealth(); - // CraftBukkit end - } - - public void a(NBTTagCompound nbttagcompound) { - super.a(nbttagcompound); - if (nbttagcompound.hasKeyOfType("playerGameType", 99)) { - if (MinecraftServer.getServer().getForceGamemode()) { - this.playerInteractManager.setGameMode(MinecraftServer.getServer().getGamemode()); - } else { - this.playerInteractManager.setGameMode(EnumGamemode.getById(nbttagcompound.getInt("playerGameType"))); - } - } - this.getBukkitEntity().readExtraData(nbttagcompound); // CraftBukkit - } - - public void b(NBTTagCompound nbttagcompound) { - super.b(nbttagcompound); - nbttagcompound.setInt("playerGameType", this.playerInteractManager.getGameMode().getId()); - this.getBukkitEntity().setExtraData(nbttagcompound); // CraftBukkit - } - - // CraftBukkit start - World fallback code, either respawn location or global spawn - public void spawnIn(World world) { - super.spawnIn(world); - if (world == null) { - this.dead = false; - ChunkCoordinates position = null; - if (this.spawnWorld != null && !this.spawnWorld.equals("")) { - CraftWorld cworld = (CraftWorld) Bukkit.getServer().getWorld(this.spawnWorld); - if (cworld != null && this.getBed() != null) { - world = cworld.getHandle(); - position = EntityHuman.getBed(cworld.getHandle(), this.getBed(), false); - } - } - if (world == null || position == null) { - world = ((CraftWorld) Bukkit.getServer().getWorlds().get(0)).getHandle(); - position = world.getSpawn(); - } - this.world = world; - this.setPosition(position.x + 0.5, position.y, position.z + 0.5); - } - this.dimension = ((WorldServer) this.world).dimension; - this.playerInteractManager.a((WorldServer) world); - } - // CraftBukkit end - - public void levelDown(int i) { - super.levelDown(i); - this.lastSentExp = -1; - } - - public void syncInventory() { - this.activeContainer.addSlotListener(this); - } - - protected void e_() { - this.height = 0.0F; - } - - public float getHeadHeight() { - return 1.62F; - } - - public void h() { - // CraftBukkit start - if (this.joining) { - this.joining = false; - } - // CraftBukkit end - - this.playerInteractManager.a(); - --this.invulnerableTicks; - if (this.noDamageTicks > 0) { - --this.noDamageTicks; - } - - this.activeContainer.b(); - if (!this.world.isStatic && !this.activeContainer.a((EntityHuman) this)) { - this.closeInventory(); - this.activeContainer = this.defaultContainer; - } - - while (!this.removeQueue.isEmpty()) { - int i = Math.min(this.removeQueue.size(), 127); - int[] aint = new int[i]; - Iterator iterator = this.removeQueue.iterator(); - int j = 0; - - while (iterator.hasNext() && j < i) { - aint[j++] = ((Integer) iterator.next()).intValue(); - iterator.remove(); - } - - this.playerConnection.sendPacket(new PacketPlayOutEntityDestroy(aint)); - } - - if (!this.chunkCoordIntPairQueue.isEmpty()) { - ArrayList arraylist = new ArrayList(); - Iterator iterator1 = this.chunkCoordIntPairQueue.iterator(); - ArrayList arraylist1 = new ArrayList(); - - Chunk chunk; - - while (iterator1.hasNext() && arraylist.size() < this.world.spigotConfig.maxBulkChunk) { // Spigot - ChunkCoordIntPair chunkcoordintpair = (ChunkCoordIntPair) iterator1.next(); - - if (chunkcoordintpair != null) { - if (this.world.isLoaded(chunkcoordintpair.x << 4, 0, chunkcoordintpair.z << 4)) { - chunk = this.world.getChunkAt(chunkcoordintpair.x, chunkcoordintpair.z); - if (chunk.isReady()) { - arraylist.add(chunk); - arraylist1.addAll(chunk.tileEntities.values()); // CraftBukkit - Get tile entities directly from the chunk instead of the world - iterator1.remove(); - } - } - } else { - iterator1.remove(); - } - } - - if (!arraylist.isEmpty()) { - this.playerConnection.sendPacket(new PacketPlayOutMapChunkBulk(arraylist)); - Iterator iterator2 = arraylist1.iterator(); - - while (iterator2.hasNext()) { - TileEntity tileentity = (TileEntity) iterator2.next(); - - this.b(tileentity); - } - - iterator2 = arraylist.iterator(); - - while (iterator2.hasNext()) { - chunk = (Chunk) iterator2.next(); - this.r().getTracker().a(this, chunk); - } - } - } - } - - public void i() { - try { - super.h(); - - for (int i = 0; i < this.inventory.getSize(); ++i) { - ItemStack itemstack = this.inventory.getItem(i); - - if (itemstack != null && itemstack.getItem().h()) { - Packet packet = ((ItemWorldMapBase) itemstack.getItem()).c(itemstack, this.world, this); - - if (packet != null) { - this.playerConnection.sendPacket(packet); - } - } - } - - // CraftBukkit - Optionally scale health - if (this.getHealth() != this.bQ || this.bR != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.bS) { - this.playerConnection.sendPacket(new PacketPlayOutUpdateHealth(this.getBukkitEntity().getScaledHealth(), this.foodData.getFoodLevel(), this.foodData.getSaturationLevel())); - this.bQ = this.getHealth(); - this.bR = this.foodData.getFoodLevel(); - this.bS = this.foodData.getSaturationLevel() == 0.0F; - } - - if (this.getHealth() + this.getAbsorptionHearts() != this.bP) { - this.bP = this.getHealth() + this.getAbsorptionHearts(); - // CraftBukkit - Update ALL the scores! - this.world.getServer().getScoreboardManager().updateAllScoresForList(IScoreboardCriteria.f, this.getName(), com.google.common.collect.ImmutableList.of(this)); - } - - // CraftBukkit start - Force max health updates - if (this.maxHealthCache != this.getMaxHealth()) { - this.getBukkitEntity().updateScaledHealth(); - } - // CraftBukkit end - - if (this.expTotal != this.lastSentExp) { - this.lastSentExp = this.expTotal; - this.playerConnection.sendPacket(new PacketPlayOutExperience(this.exp, this.expTotal, this.expLevel)); - } - - if (this.ticksLived % 20 * 5 == 0 && !this.getStatisticManager().hasAchievement(AchievementList.L)) { - this.j(); - } - - // CraftBukkit start - initialize oldLevel and fire PlayerLevelChangeEvent - if (this.oldLevel == -1) { - this.oldLevel = this.expLevel; - } - - if (this.oldLevel != this.expLevel) { - CraftEventFactory.callPlayerLevelChangeEvent(this.world.getServer().getPlayer((EntityPlayer) this), this.oldLevel, this.expLevel); - this.oldLevel = this.expLevel; - } - // CraftBukkit end - } catch (Throwable throwable) { - CrashReport crashreport = CrashReport.a(throwable, "Ticking player"); - CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Player being ticked"); - - this.a(crashreportsystemdetails); - throw new ReportedException(crashreport); - } - } - - protected void j() { - BiomeBase biomebase = this.world.getBiome(MathHelper.floor(this.locX), MathHelper.floor(this.locZ)); - - if (biomebase != null) { - String s = biomebase.af; - AchievementSet achievementset = (AchievementSet) this.getStatisticManager().b((Statistic) AchievementList.L); // CraftBukkit - fix decompile error - - if (achievementset == null) { - achievementset = (AchievementSet) this.getStatisticManager().a(AchievementList.L, new AchievementSet()); - } - - achievementset.add(s); - if (this.getStatisticManager().b(AchievementList.L) && achievementset.size() == BiomeBase.n.size()) { - HashSet hashset = Sets.newHashSet(BiomeBase.n); - Iterator iterator = achievementset.iterator(); - - while (iterator.hasNext()) { - String s1 = (String) iterator.next(); - Iterator iterator1 = hashset.iterator(); - - while (iterator1.hasNext()) { - BiomeBase biomebase1 = (BiomeBase) iterator1.next(); - - if (biomebase1.af.equals(s1)) { - iterator1.remove(); - } - } - - if (hashset.isEmpty()) { - break; - } - } - - if (hashset.isEmpty()) { - this.a((Statistic) AchievementList.L); - } - } - } - } - - public void die(DamageSource damagesource) { - // CraftBukkit start - fire PlayerDeathEvent - if (this.dead) { - return; - } - - java.util.List loot = new java.util.ArrayList(); - boolean keepInventory = this.world.getGameRules().getBoolean("keepInventory"); - - if (!keepInventory) { - for (int i = 0; i < this.inventory.items.length; ++i) { - if (this.inventory.items[i] != null) { - loot.add(CraftItemStack.asCraftMirror(this.inventory.items[i])); - } - } - - for (int i = 0; i < this.inventory.armor.length; ++i) { - if (this.inventory.armor[i] != null) { - loot.add(CraftItemStack.asCraftMirror(this.inventory.armor[i])); - } - } - } - - IChatBaseComponent chatmessage = this.aW().b(); - - String deathmessage = chatmessage.c(); - org.bukkit.event.entity.PlayerDeathEvent event = CraftEventFactory.callPlayerDeathEvent(this, loot, deathmessage, keepInventory); - - String deathMessage = event.getDeathMessage(); - - if (deathMessage != null && deathMessage.length() > 0) { - if (deathMessage.equals(deathmessage)) { - this.server.getPlayerList().sendMessage(chatmessage); - } else { - this.server.getPlayerList().sendMessage(org.bukkit.craftbukkit.v1_7_R4.util.CraftChatMessage.fromString(deathMessage)); - } - } - - // we clean the player's inventory after the EntityDeathEvent is called so plugins can get the exact state of the inventory. - if (!event.getKeepInventory()) { - for (int i = 0; i < this.inventory.items.length; ++i) { - this.inventory.items[i] = null; - } - - for (int i = 0; i < this.inventory.armor.length; ++i) { - this.inventory.armor[i] = null; - } - } - - this.closeInventory(); - // CraftBukkit end - - // CraftBukkit - Get our scores instead - Collection collection = this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.c, this.getName(), new java.util.ArrayList()); - Iterator iterator = collection.iterator(); - - while (iterator.hasNext()) { - ScoreboardScore scoreboardscore = (ScoreboardScore) iterator.next(); // CraftBukkit - Use our scores instead - - scoreboardscore.incrementScore(); - } - - EntityLiving entityliving = this.aX(); - - if (entityliving != null) { - int i = EntityTypes.a(entityliving); - MonsterEggInfo monsteregginfo = (MonsterEggInfo) EntityTypes.eggInfo.get(Integer.valueOf(i)); - - if (monsteregginfo != null) { - this.a(monsteregginfo.e, 1); - } - - entityliving.b(this, this.ba); - } - - this.a(StatisticList.v, 1); - this.aW().g(); - } - - public boolean damageEntity(DamageSource damagesource, float f) { - if (this.isInvulnerable()) { - return false; - } else { - // CraftBukkit - this.server.getPvP() -> this.world.pvpMode - boolean flag = this.server.X() && this.world.pvpMode && "fall".equals(damagesource.translationIndex); - - if (!flag && this.invulnerableTicks > 0 && damagesource != DamageSource.OUT_OF_WORLD) { - return false; - } else { - if (damagesource instanceof EntityDamageSource) { - Entity entity = damagesource.getEntity(); - - if (entity instanceof EntityHuman && !this.a((EntityHuman) entity)) { - return false; - } - - if (entity instanceof EntityArrow) { - EntityArrow entityarrow = (EntityArrow) entity; - - if (entityarrow.shooter instanceof EntityHuman && !this.a((EntityHuman) entityarrow.shooter)) { - return false; - } - } - } - - return super.damageEntity(damagesource, f); - } - } - } - - public boolean a(EntityHuman entityhuman) { - // CraftBukkit - this.server.getPvP() -> this.world.pvpMode - return !this.world.pvpMode ? false : super.a(entityhuman); - } - - public void b(int i) { - if (this.dimension == 1 && i == 1) { - this.a((Statistic) AchievementList.D); - this.world.kill(this); - this.viewingCredits = true; - this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(4, 0.0F)); - } else { - if (this.dimension == 0 && i == 1) { - this.a((Statistic) AchievementList.C); - // CraftBukkit start - Rely on custom portal management - /* - ChunkCoordinates chunkcoordinates = this.server.getWorldServer(i).getDimensionSpawn(); - - if (chunkcoordinates != null) { - this.playerConnection.a((double) chunkcoordinates.x, (double) chunkcoordinates.y, (double) chunkcoordinates.z, 0.0F, 0.0F); - } - - i = 1; - */ - // CraftBukkit end - } else { - this.a((Statistic) AchievementList.y); - } - - // CraftBukkit start - TeleportCause cause = (this.dimension == 1 || i == 1) ? TeleportCause.END_PORTAL : TeleportCause.NETHER_PORTAL; - this.server.getPlayerList().changeDimension(this, i, cause); - // CraftBukkit end - this.lastSentExp = -1; - this.bQ = -1.0F; - this.bR = -1; - } - } - - private void b(TileEntity tileentity) { - if (tileentity != null) { - Packet packet = tileentity.getUpdatePacket(); - - if (packet != null) { - this.playerConnection.sendPacket(packet); - } - } - } - - public void receive(Entity entity, int i) { - super.receive(entity, i); - this.activeContainer.b(); - } - - public EnumBedResult a(int i, int j, int k) { - EnumBedResult enumbedresult = super.a(i, j, k); - - if (enumbedresult == EnumBedResult.OK) { - PacketPlayOutBed packetplayoutbed = new PacketPlayOutBed(this, i, j, k); - - this.r().getTracker().a((Entity) this, (Packet) packetplayoutbed); - this.playerConnection.a(this.locX, this.locY, this.locZ, this.yaw, this.pitch); - this.playerConnection.sendPacket(packetplayoutbed); - } - - return enumbedresult; - } - - public void a(boolean flag, boolean flag1, boolean flag2) { - if (!this.sleeping) return; // CraftBukkit - Can't leave bed if not in one! - - if (this.isSleeping()) { - this.r().getTracker().sendPacketToEntity(this, new PacketPlayOutAnimation(this, 2)); - } - - super.a(flag, flag1, flag2); - if (this.playerConnection != null) { - this.playerConnection.a(this.locX, this.locY, this.locZ, this.yaw, this.pitch); - } - } - - public void mount(Entity entity) { - // CraftBukkit start - this.setPassengerOf(entity); - } - - public void setPassengerOf(Entity entity) { - // mount(null) doesn't really fly for overloaded methods, - // so this method is needed - Entity currentVehicle = this.vehicle; - - super.setPassengerOf(entity); - - // Check if the vehicle actually changed. - if (currentVehicle != this.vehicle) { - this.playerConnection.sendPacket(new PacketPlayOutAttachEntity(0, this, this.vehicle)); - this.playerConnection.a(this.locX, this.locY, this.locZ, this.yaw, this.pitch); - } - // CraftBukkit end - } - - protected void a(double d0, boolean flag) {} - - public void b(double d0, boolean flag) { - super.a(d0, flag); - } - - public void a(TileEntity tileentity) { - if (tileentity instanceof TileEntitySign) { - ((TileEntitySign) tileentity).a((EntityHuman) this); - this.playerConnection.sendPacket(new PacketPlayOutOpenSignEditor(tileentity.x, tileentity.y, tileentity.z)); - } - } - - public int nextContainerCounter() { // CraftBukkit - private void -> public int - this.containerCounter = this.containerCounter % 100 + 1; - return this.containerCounter; // CraftBukkit - } - - public void startCrafting(int i, int j, int k) { - // CraftBukkit start - Inventory open hook - Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerWorkbench(this.inventory, this.world, i, j, k)); - if (container == null) { - return; - } - // CraftBukkit end - - this.nextContainerCounter(); - this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, 1, "Crafting", 9, true)); - this.activeContainer = container; // CraftBukkit - Use container we passed to event - this.activeContainer.windowId = this.containerCounter; - this.activeContainer.addSlotListener(this); - } - - public void startEnchanting(int i, int j, int k, String s) { - // CraftBukkit start - Inventory open hook - Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerEnchantTable(this.inventory, this.world, i, j, k)); - if (container == null) { - return; - } - // CraftBukkit end - - this.nextContainerCounter(); - this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, 4, s == null ? "" : s, 9, s != null)); - this.activeContainer = container; // CraftBukkit - Use container we passed to event - this.activeContainer.windowId = this.containerCounter; - this.activeContainer.addSlotListener(this); - } - - public void openAnvil(int i, int j, int k) { - // CraftBukkit start - Inventory open hook - Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerAnvil(this.inventory, this.world, i, j, k, this)); - if (container == null) { - return; - } - // CraftBukkit end - - this.nextContainerCounter(); - this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, 8, "Repairing", 9, true)); - this.activeContainer = container; // CraftBukkit - Use container we passed to event - this.activeContainer.windowId = this.containerCounter; - this.activeContainer.addSlotListener(this); - } - - public void openContainer(IInventory iinventory) { - if (this.activeContainer != this.defaultContainer) { - this.closeInventory(); - } - - // CraftBukkit start - Inventory open hook - Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerChest(this.inventory, iinventory)); - if (container == null) { - iinventory.closeContainer(); - return; - } - // CraftBukkit end - - this.nextContainerCounter(); - this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, 0, iinventory.getInventoryName(), iinventory.getSize(), iinventory.k_())); - this.activeContainer = container; // CraftBukkit - Use container we passed to event - this.activeContainer.windowId = this.containerCounter; - this.activeContainer.addSlotListener(this); - } - - public void openHopper(TileEntityHopper tileentityhopper) { - // CraftBukkit start - Inventory open hook - Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerHopper(this.inventory, tileentityhopper)); - if (container == null) { - tileentityhopper.closeContainer(); - return; - } - // CraftBukkit end - - this.nextContainerCounter(); - this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, 9, tileentityhopper.getInventoryName(), tileentityhopper.getSize(), tileentityhopper.k_())); - this.activeContainer = container; // CraftBukkit - Use container we passed to event - this.activeContainer.windowId = this.containerCounter; - this.activeContainer.addSlotListener(this); - } - - public void openMinecartHopper(EntityMinecartHopper entityminecarthopper) { - // CraftBukkit start - Inventory open hook - Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerHopper(this.inventory, entityminecarthopper)); - if (container == null) { - entityminecarthopper.closeContainer(); - return; - } - // CraftBukkit end - - this.nextContainerCounter(); - this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, 9, entityminecarthopper.getInventoryName(), entityminecarthopper.getSize(), entityminecarthopper.k_())); - this.activeContainer = container; // CraftBukkit - Use container we passed to event - this.activeContainer.windowId = this.containerCounter; - this.activeContainer.addSlotListener(this); - } - - public void openFurnace(TileEntityFurnace tileentityfurnace) { - // CraftBukkit start - Inventory open hook - Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerFurnace(this.inventory, tileentityfurnace)); - if (container == null) { - tileentityfurnace.closeContainer(); - return; - } - // CraftBukkit end - - this.nextContainerCounter(); - this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, 2, tileentityfurnace.getInventoryName(), tileentityfurnace.getSize(), tileentityfurnace.k_())); - this.activeContainer = container; // CraftBukkit - Use container we passed to event - this.activeContainer.windowId = this.containerCounter; - this.activeContainer.addSlotListener(this); - } - - public void openDispenser(TileEntityDispenser tileentitydispenser) { - // CraftBukkit start - Inventory open hook - Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerDispenser(this.inventory, tileentitydispenser)); - if (container == null) { - tileentitydispenser.closeContainer(); - return; - } - // CraftBukkit end - - this.nextContainerCounter(); - this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, tileentitydispenser instanceof TileEntityDropper ? 10 : 3, tileentitydispenser.getInventoryName(), tileentitydispenser.getSize(), tileentitydispenser.k_())); - this.activeContainer = container; // CraftBukkit - Use container we passed to event - this.activeContainer.windowId = this.containerCounter; - this.activeContainer.addSlotListener(this); - } - - public void openBrewingStand(TileEntityBrewingStand tileentitybrewingstand) { - // CraftBukkit start - Inventory open hook - Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerBrewingStand(this.inventory, tileentitybrewingstand)); - if (container == null) { - tileentitybrewingstand.closeContainer(); - return; - } - // CraftBukkit end - - this.nextContainerCounter(); - this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, 5, tileentitybrewingstand.getInventoryName(), tileentitybrewingstand.getSize(), tileentitybrewingstand.k_())); - this.activeContainer = container; // CraftBukkit - Use container we passed to event - this.activeContainer.windowId = this.containerCounter; - this.activeContainer.addSlotListener(this); - } - - public void openBeacon(TileEntityBeacon tileentitybeacon) { - // CraftBukkit start - Inventory open hook - Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerBeacon(this.inventory, tileentitybeacon)); - if (container == null) { - tileentitybeacon.closeContainer(); - return; - } - // CraftBukkit end - - this.nextContainerCounter(); - this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, 7, tileentitybeacon.getInventoryName(), tileentitybeacon.getSize(), tileentitybeacon.k_())); - this.activeContainer = container; // CraftBukkit - Use container we passed to event - this.activeContainer.windowId = this.containerCounter; - this.activeContainer.addSlotListener(this); - } - - public void openTrade(IMerchant imerchant, String s) { - // CraftBukkit start - Inventory open hook - Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerMerchant(this.inventory, imerchant, this.world)); - if (container == null) { - return; - } - // CraftBukkit end - - this.nextContainerCounter(); - this.activeContainer = container; // CraftBukkit - Use container we passed to event - this.activeContainer.windowId = this.containerCounter; - this.activeContainer.addSlotListener(this); - InventoryMerchant inventorymerchant = ((ContainerMerchant) this.activeContainer).getMerchantInventory(); - - this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, 6, s == null ? "" : s, inventorymerchant.getSize(), s != null)); - MerchantRecipeList merchantrecipelist = imerchant.getOffers(this); - - if (merchantrecipelist != null) { - PacketDataSerializer packetdataserializer = new PacketDataSerializer(Unpooled.buffer()); - - try { - packetdataserializer.writeInt(this.containerCounter); - merchantrecipelist.a(packetdataserializer); - this.playerConnection.sendPacket(new PacketPlayOutCustomPayload("MC|TrList", packetdataserializer)); - } catch (Exception ioexception) { // CraftBukkit - IOException -> Exception - bL.error("Couldn\'t send trade list", ioexception); - } finally { - packetdataserializer.release(); - } - } - } - - public void openHorseInventory(EntityHorse entityhorse, IInventory iinventory) { - // CraftBukkit start - Inventory open hook - Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerHorse(this.inventory, iinventory, entityhorse)); - if (container == null) { - iinventory.closeContainer(); - return; - } - // CraftBukkit end - - if (this.activeContainer != this.defaultContainer) { - this.closeInventory(); - } - - this.nextContainerCounter(); - this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, 11, iinventory.getInventoryName(), iinventory.getSize(), iinventory.k_(), entityhorse.getId())); - this.activeContainer = container; // CraftBukkit - Use container we passed to event - this.activeContainer.windowId = this.containerCounter; - this.activeContainer.addSlotListener(this); - } - - public void a(Container container, int i, ItemStack itemstack) { - if (!(container.getSlot(i) instanceof SlotResult)) { - if (!this.g) { - this.playerConnection.sendPacket(new PacketPlayOutSetSlot(container.windowId, i, itemstack)); - } - } - } - - public void updateInventory(Container container) { - this.a(container, container.a()); - } - - public void a(Container container, List list) { - this.playerConnection.sendPacket(new PacketPlayOutWindowItems(container.windowId, list)); - this.playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, this.inventory.getCarried())); - // CraftBukkit start - Send a Set Slot to update the crafting result slot - if (java.util.EnumSet.of(InventoryType.CRAFTING,InventoryType.WORKBENCH).contains(container.getBukkitView().getType())) { - this.playerConnection.sendPacket(new PacketPlayOutSetSlot(container.windowId, 0, container.getSlot(0).getItem())); - } - // CraftBukkit end - } - - public void setContainerData(Container container, int i, int j) { - this.playerConnection.sendPacket(new PacketPlayOutWindowData(container.windowId, i, j)); - } - - public void closeInventory() { - CraftEventFactory.handleInventoryCloseEvent(this); // CraftBukkit - this.playerConnection.sendPacket(new PacketPlayOutCloseWindow(this.activeContainer.windowId)); - this.m(); - } - - public void broadcastCarriedItem() { - if (!this.g) { - this.playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, this.inventory.getCarried())); - } - } - - public void m() { - this.activeContainer.b((EntityHuman) this); - this.activeContainer = this.defaultContainer; - } - - public void a(float f, float f1, boolean flag, boolean flag1) { - if (this.vehicle != null) { - if (f >= -1.0F && f <= 1.0F) { - this.bd = f; - } - - if (f1 >= -1.0F && f1 <= 1.0F) { - this.be = f1; - } - - this.bc = flag; - this.setSneaking(flag1); - } - } - - public void a(Statistic statistic, int i) { - if (statistic != null) { - this.bO.b(this, statistic, i); - Iterator iterator = this.getScoreboard().getObjectivesForCriteria(statistic.k()).iterator(); - - while (iterator.hasNext()) { - ScoreboardObjective scoreboardobjective = (ScoreboardObjective) iterator.next(); - - this.getScoreboard().getPlayerScoreForObjective(this.getName(), scoreboardobjective).incrementScore(); - } - - if (this.bO.e()) { - this.bO.a(this); - } - } - } - - public void n() { - if (this.passenger != null) { - this.passenger.mount(this); - } - - if (this.sleeping) { - this.a(true, false, false); - } - } - - public void triggerHealthUpdate() { - this.bQ = -1.0E8F; - this.lastSentExp = -1; // CraftBukkit - Added to reset - } - - public void b(IChatBaseComponent ichatbasecomponent) { - this.playerConnection.sendPacket(new PacketPlayOutChat(ichatbasecomponent)); - } - - protected void p() { - this.playerConnection.sendPacket(new PacketPlayOutEntityStatus(this, (byte) 9)); - super.p(); - } - - public void a(ItemStack itemstack, int i) { - super.a(itemstack, i); - if (itemstack != null && itemstack.getItem() != null && itemstack.getItem().d(itemstack) == EnumAnimation.EAT) { - this.r().getTracker().sendPacketToEntity(this, new PacketPlayOutAnimation(this, 3)); - } - } - - public void copyTo(EntityHuman entityhuman, boolean flag) { - super.copyTo(entityhuman, flag); - this.lastSentExp = -1; - this.bQ = -1.0F; - this.bR = -1; - this.removeQueue.addAll(((EntityPlayer) entityhuman).removeQueue); - } - - protected void a(MobEffect mobeffect) { - super.a(mobeffect); - this.playerConnection.sendPacket(new PacketPlayOutEntityEffect(this.getId(), mobeffect)); - } - - protected void a(MobEffect mobeffect, boolean flag) { - super.a(mobeffect, flag); - this.playerConnection.sendPacket(new PacketPlayOutEntityEffect(this.getId(), mobeffect)); - } - - protected void b(MobEffect mobeffect) { - super.b(mobeffect); - this.playerConnection.sendPacket(new PacketPlayOutRemoveEntityEffect(this.getId(), mobeffect)); - } - - public void enderTeleportTo(double d0, double d1, double d2) { - this.playerConnection.a(d0, d1, d2, this.yaw, this.pitch); - } - - public void b(Entity entity) { - this.r().getTracker().sendPacketToEntity(this, new PacketPlayOutAnimation(entity, 4)); - } - - public void c(Entity entity) { - this.r().getTracker().sendPacketToEntity(this, new PacketPlayOutAnimation(entity, 5)); - } - - public void updateAbilities() { - if (this.playerConnection != null) { - this.playerConnection.sendPacket(new PacketPlayOutAbilities(this.abilities)); - } - } - - public WorldServer r() { - return (WorldServer) this.world; - } - - public void a(EnumGamemode enumgamemode) { - this.playerInteractManager.setGameMode(enumgamemode); - this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(3, (float) enumgamemode.getId())); - } - - // CraftBukkit start - Support multi-line messages - public void sendMessage(IChatBaseComponent[] ichatbasecomponent) { - for (IChatBaseComponent component : ichatbasecomponent) { - this.sendMessage(component); - } - } - // CraftBukkit end - - public void sendMessage(IChatBaseComponent ichatbasecomponent) { - this.playerConnection.sendPacket(new PacketPlayOutChat(ichatbasecomponent)); - } - - public boolean a(int i, String s) { - if ("seed".equals(s) && !this.server.X()) { - return true; - } else if (!"tell".equals(s) && !"help".equals(s) && !"me".equals(s)) { - if (this.server.getPlayerList().isOp(this.getProfile())) { - OpListEntry oplistentry = (OpListEntry) this.server.getPlayerList().getOPs().get(this.getProfile()); - - return oplistentry != null ? oplistentry.a() >= i : this.server.l() >= i; - } else { - return false; - } - } else { - return true; - } - } - - public String s() { - String s = this.playerConnection.networkManager.getSocketAddress().toString(); - - s = s.substring(s.indexOf("/") + 1); - s = s.substring(0, s.indexOf(":")); - return s; - } - - public void a(PacketPlayInSettings packetplayinsettings) { - this.locale = packetplayinsettings.c(); - int i = 256 >> packetplayinsettings.d(); - - if (i > 3 && i < 20) { - ; - } - - this.bV = packetplayinsettings.e(); - this.bW = packetplayinsettings.f(); - if (this.server.N() && this.server.M().equals(this.getName())) { - this.server.a(packetplayinsettings.g()); - } - - this.b(1, !packetplayinsettings.h()); - } - - public EnumChatVisibility getChatFlags() { - return this.bV; - } - - public void setResourcePack(String s) { - this.playerConnection.sendPacket(new PacketPlayOutCustomPayload("MC|RPack", s.getBytes(Charsets.UTF_8))); - } - - public ChunkCoordinates getChunkCoordinates() { - return new ChunkCoordinates(MathHelper.floor(this.locX), MathHelper.floor(this.locY + 0.5D), MathHelper.floor(this.locZ)); - } - - public void v() { - this.bX = MinecraftServer.ar(); - } - - public ServerStatisticManager getStatisticManager() { - return this.bO; - } - - public void d(Entity entity) { - if (entity instanceof EntityHuman) { - this.playerConnection.sendPacket(new PacketPlayOutEntityDestroy(new int[] { entity.getId()})); - } else { - this.removeQueue.add(Integer.valueOf(entity.getId())); - } - } - - public long x() { - return this.bX; - } - - // CraftBukkit start - Add per-player time and weather. - public long timeOffset = 0; - public boolean relativeTime = true; - - public long getPlayerTime() { - if (this.relativeTime) { - // Adds timeOffset to the current server time. - return this.world.getDayTime() + this.timeOffset; - } else { - // Adds timeOffset to the beginning of this day. - return this.world.getDayTime() - (this.world.getDayTime() % 24000) + this.timeOffset; - } - } - - public WeatherType weather = null; - - public WeatherType getPlayerWeather() { - return this.weather; - } - - public void setPlayerWeather(WeatherType type, boolean plugin) { - if (!plugin && this.weather != null) { - return; - } - - if (plugin) { - this.weather = type; - } - - if (type == WeatherType.DOWNFALL) { - this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(2, 0)); - // this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(7, this.world.j(1.0F))); - // this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(8, this.world.h(1.0F))); - } else { - this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(1, 0)); - } - } - - public void resetPlayerWeather() { - this.weather = null; - this.setPlayerWeather(this.world.getWorldData().hasStorm() ? WeatherType.DOWNFALL : WeatherType.CLEAR, false); - } - - @Override - public String toString() { - return super.toString() + "(" + this.getName() + " at " + this.locX + "," + this.locY + "," + this.locZ + ")"; - } - - public void reset() { - float exp = 0; - boolean keepInventory = this.world.getGameRules().getBoolean("keepInventory"); - - if (this.keepLevel || keepInventory) { - exp = this.exp; - this.newTotalExp = this.expTotal; - this.newLevel = this.expLevel; - } - - this.setHealth(this.getMaxHealth()); - this.fireTicks = 0; - this.fallDistance = 0; - this.foodData = new FoodMetaData(this); - this.expLevel = this.newLevel; - this.expTotal = this.newTotalExp; - this.exp = 0; - this.deathTicks = 0; - this.removeAllEffects(); - this.updateEffects = true; - this.activeContainer = this.defaultContainer; - this.killer = null; - this.lastDamager = null; - this.combatTracker = new CombatTracker(this); - this.lastSentExp = -1; - if (this.keepLevel || keepInventory) { - this.exp = exp; - } else { - this.giveExp(this.newExp); - } - this.keepLevel = false; - } - - @Override - public CraftPlayer getBukkitEntity() { - return (CraftPlayer) super.getBukkitEntity(); - } - // CraftBukkit end -} diff --git a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/EntitySlime.java b/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/EntitySlime.java deleted file mode 100644 index a14749ab9..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/EntitySlime.java +++ /dev/null @@ -1,269 +0,0 @@ -package net.minecraft.server.v1_7_R4; - -// CraftBukkit start -import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_7_R4.event.CraftEventFactory; -import org.bukkit.event.entity.EntityTargetEvent; -import org.bukkit.event.entity.SlimeSplitEvent; -// CraftBukkit end - -public class EntitySlime extends EntityInsentient implements IMonster { - - public float h; - public float i; - public float bm; - private int jumpDelay; - private Entity lastTarget; // CraftBukkit - - public EntitySlime(World world) { - super(world); - int i = 1 << this.random.nextInt(3); - - this.height = 0.0F; - this.jumpDelay = this.random.nextInt(20) + 10; - this.setSize(i); - } - - protected void c() { - super.c(); - this.datawatcher.a(16, new Byte((byte) 1)); - } - - // CraftBukkit - protected -> public - public void setSize(int i) { - this.datawatcher.watch(16, new Byte((byte) i)); - this.a(0.6F * (float) i, 0.6F * (float) i); - this.setPosition(this.locX, this.locY, this.locZ); - this.getAttributeInstance(GenericAttributes.maxHealth).setValue((double) (i * i)); - this.setHealth(this.getMaxHealth()); - this.b = i; - } - - public int getSize() { - return this.datawatcher.getByte(16); - } - - public void b(NBTTagCompound nbttagcompound) { - super.b(nbttagcompound); - nbttagcompound.setInt("Size", this.getSize() - 1); - } - - public void a(NBTTagCompound nbttagcompound) { - super.a(nbttagcompound); - int i = nbttagcompound.getInt("Size"); - - if (i < 0) { - i = 0; - } - - this.setSize(i + 1); - } - - protected String bP() { - return "slime"; - } - - protected String bV() { - return "mob.slime." + (this.getSize() > 1 ? "big" : "small"); - } - - public void h() { - if (!this.world.isStatic && this.world.difficulty == EnumDifficulty.PEACEFUL && this.getSize() > 0) { - this.dead = true; - } - - this.i += (this.h - this.i) * 0.5F; - this.bm = this.i; - boolean flag = this.onGround; - - super.h(); - int i; - - if (this.onGround && !flag) { - i = this.getSize(); - - for (int j = 0; j < i * 8; ++j) { - float f = this.random.nextFloat() * 3.1415927F * 2.0F; - float f1 = this.random.nextFloat() * 0.5F + 0.5F; - float f2 = MathHelper.sin(f) * (float) i * 0.5F * f1; - float f3 = MathHelper.cos(f) * (float) i * 0.5F * f1; - - this.world.addParticle(this.bP(), this.locX + (double) f2, this.boundingBox.b, this.locZ + (double) f3, 0.0D, 0.0D, 0.0D); - } - - if (this.bW()) { - this.makeSound(this.bV(), this.bf(), ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) / 0.8F); - } - - this.h = -0.5F; - } else if (!this.onGround && flag) { - this.h = 1.0F; - } - - this.bS(); - if (this.world.isStatic) { - i = this.getSize(); - this.a(0.6F * (float) i, 0.6F * (float) i); - } - } - - protected void bq() { - this.w(); - - if (Vegetated) - return; - - // CraftBukkit start - Entity entityhuman = this.world.findNearbyVulnerablePlayer(this, 16.0D); // EntityHuman -> Entity - EntityTargetEvent event = null; - - if (entityhuman != null && !entityhuman.equals(lastTarget)) { - event = CraftEventFactory.callEntityTargetEvent(this, entityhuman, EntityTargetEvent.TargetReason.CLOSEST_PLAYER); - } else if (lastTarget != null && entityhuman == null) { - event = CraftEventFactory.callEntityTargetEvent(this, entityhuman, EntityTargetEvent.TargetReason.FORGOT_TARGET); - } - - if (event != null && !event.isCancelled()) { - entityhuman = event.getTarget() == null ? null : ((CraftEntity) event.getTarget()).getHandle(); - } - - this.lastTarget = entityhuman; - // CraftBukkit end - - if (entityhuman != null) { - this.a(entityhuman, 10.0F, 20.0F); - } - - if (this.onGround && this.jumpDelay-- <= 0) { - this.jumpDelay = this.bR(); - if (entityhuman != null) { - this.jumpDelay /= 3; - } - - this.bc = true; - if (this.bY()) { - this.makeSound(this.bV(), this.bf(), ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) * 0.8F); - } - - this.bd = 1.0F - this.random.nextFloat() * 2.0F; - this.be = (float) (1 * this.getSize()); - } else { - this.bc = false; - if (this.onGround) { - this.bd = this.be = 0.0F; - } - } - } - - protected void bS() { - this.h *= 0.6F; - } - - protected int bR() { - return this.random.nextInt(20) + 10; - } - - protected EntitySlime bQ() { - return new EntitySlime(this.world); - } - - public void die() { - int i = this.getSize(); - - if (!this.world.isStatic && i > 1 && this.getHealth() <= 0.0F) { - int j = 2 + this.random.nextInt(3); - - // CraftBukkit start - SlimeSplitEvent event = new SlimeSplitEvent((org.bukkit.entity.Slime) this.getBukkitEntity(), j); - this.world.getServer().getPluginManager().callEvent(event); - - if (!event.isCancelled() && event.getCount() > 0) { - j = event.getCount(); - } else { - super.die(); - return; - } - // CraftBukkit end - - for (int k = 0; k < j; ++k) { - float f = ((float) (k % 2) - 0.5F) * (float) i / 4.0F; - float f1 = ((float) (k / 2) - 0.5F) * (float) i / 4.0F; - EntitySlime entityslime = this.bQ(); - - entityslime.setSize(i / 2); - entityslime.setPositionRotation(this.locX + (double) f, this.locY + 0.5D, this.locZ + (double) f1, this.random.nextFloat() * 360.0F, 0.0F); - this.world.addEntity(entityslime, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SLIME_SPLIT); // CraftBukkit - SpawnReason - } - } - - super.die(); - } - - public void b_(EntityHuman entityhuman) { - if (this.bT()) { - int i = this.getSize(); - - if (this.hasLineOfSight(entityhuman) && this.f(entityhuman) < 0.6D * (double) i * 0.6D * (double) i && entityhuman.damageEntity(DamageSource.mobAttack(this), (float) this.bU())) { - this.makeSound("mob.attack", 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); - } - } - } - - protected boolean bT() { - return this.getSize() > 1; - } - - protected int bU() { - return this.getSize(); - } - - protected String aT() { - return "mob.slime." + (this.getSize() > 1 ? "big" : "small"); - } - - protected String aU() { - return "mob.slime." + (this.getSize() > 1 ? "big" : "small"); - } - - protected Item getLoot() { - return this.getSize() == 1 ? Items.SLIME_BALL : Item.getById(0); - } - - public boolean canSpawn() { - Chunk chunk = this.world.getChunkAtWorldCoords(MathHelper.floor(this.locX), MathHelper.floor(this.locZ)); - - if (this.world.getWorldData().getType() == WorldType.FLAT && this.random.nextInt(4) != 1) { - return false; - } else { - if (this.getSize() == 1 || this.world.difficulty != EnumDifficulty.PEACEFUL) { - BiomeBase biomebase = this.world.getBiome(MathHelper.floor(this.locX), MathHelper.floor(this.locZ)); - - if (biomebase == BiomeBase.SWAMPLAND && this.locY > 50.0D && this.locY < 70.0D && this.random.nextFloat() < 0.5F && this.random.nextFloat() < this.world.y() && this.world.getLightLevel(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)) <= this.random.nextInt(8)) { - return super.canSpawn(); - } - - if (this.random.nextInt(10) == 0 && chunk.a(987234911L).nextInt(10) == 0 && this.locY < 40.0D) { - return super.canSpawn(); - } - } - - return false; - } - } - - protected float bf() { - return 0.4F * (float) this.getSize(); - } - - public int x() { - return 0; - } - - protected boolean bY() { - return this.getSize() > 0; - } - - protected boolean bW() { - return this.getSize() > 2; - } -} diff --git a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/EntityTNTPrimed.java b/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/EntityTNTPrimed.java deleted file mode 100644 index 61c340c1b..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/EntityTNTPrimed.java +++ /dev/null @@ -1,100 +0,0 @@ -package net.minecraft.server.v1_7_R4; - -import org.bukkit.event.entity.ExplosionPrimeEvent; // CraftBukkit - -public class EntityTNTPrimed extends Entity { - - public int fuseTicks; - private EntityLiving source; - 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; - this.a(0.98F, 0.98F); - this.height = this.length / 2.0F; - } - - public EntityTNTPrimed(World world, double d0, double d1, double d2, EntityLiving entityliving) { - this(world); - this.setPosition(d0, d1, d2); - float f = (float) (Math.random() * 3.1415927410125732D * 2.0D); - - this.motX = (double) (-((float) Math.sin((double) f)) * 0.02F); - this.motY = 0.20000000298023224D; - this.motZ = (double) (-((float) Math.cos((double) f)) * 0.02F); - this.fuseTicks = 80; - this.lastX = d0; - this.lastY = d1; - this.lastZ = d2; - this.source = entityliving; - } - - protected void c() {} - - protected boolean g_() { - return false; - } - - public boolean R() { - return !this.dead && !spectating; - } - - public void h() { - this.lastX = this.locX; - this.lastY = this.locY; - this.lastZ = this.locZ; - this.motY -= 0.03999999910593033D; - this.move(this.motX, this.motY, this.motZ); - this.motX *= 0.9800000190734863D; - this.motY *= 0.9800000190734863D; - this.motZ *= 0.9800000190734863D; - if (this.onGround) { - this.motX *= 0.699999988079071D; - this.motZ *= 0.699999988079071D; - this.motY *= -0.5D; - } - - if (this.fuseTicks-- <= 0) { - // CraftBukkit start - Need to reverse the order of the explosion and the entity death so we have a location for the event - if (!this.world.isStatic) { - this.explode(); - } - this.die(); - // CraftBukkit end - } else { - this.world.addParticle("smoke", this.locX, this.locY + 0.5D, this.locZ, 0.0D, 0.0D, 0.0D); - } - } - - private void explode() { - // CraftBukkit start - // float f = 4.0F; - - org.bukkit.craftbukkit.v1_7_R4.CraftServer server = this.world.getServer(); - - ExplosionPrimeEvent event = new ExplosionPrimeEvent((org.bukkit.entity.Explosive) org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity.getEntity(server, this)); - server.getPluginManager().callEvent(event); - - if (!event.isCancelled()) { - // give 'this' instead of (Entity) null so we know what causes the damage - this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire(), true); - } - // CraftBukkit end - } - - protected void b(NBTTagCompound nbttagcompound) { - nbttagcompound.setByte("Fuse", (byte) this.fuseTicks); - } - - protected void a(NBTTagCompound nbttagcompound) { - this.fuseTicks = nbttagcompound.getByte("Fuse"); - } - - public EntityLiving getSource() { - return this.source; - } -} diff --git a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/IPacketVerifier.java b/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/IPacketVerifier.java deleted file mode 100644 index f0fc68d64..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/IPacketVerifier.java +++ /dev/null @@ -1,6 +0,0 @@ -package net.minecraft.server.v1_7_R4; - -public interface IPacketVerifier -{ - boolean verify(Packet packet); -} diff --git a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/NetworkManager.java b/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/NetworkManager.java deleted file mode 100644 index c70894293..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/NetworkManager.java +++ /dev/null @@ -1,308 +0,0 @@ -package net.minecraft.server.v1_7_R4; - -import java.net.SocketAddress; -import java.util.Queue; -import javax.crypto.SecretKey; - -import net.minecraft.util.com.google.common.collect.Queues; -import net.minecraft.util.com.google.common.util.concurrent.ThreadFactoryBuilder; -import net.minecraft.util.com.mojang.authlib.properties.Property; -import net.minecraft.util.io.netty.channel.Channel; -import net.minecraft.util.io.netty.channel.ChannelFutureListener; -import net.minecraft.util.io.netty.channel.ChannelHandlerContext; -import net.minecraft.util.io.netty.channel.SimpleChannelInboundHandler; -import net.minecraft.util.io.netty.channel.local.LocalChannel; -import net.minecraft.util.io.netty.channel.local.LocalServerChannel; -import net.minecraft.util.io.netty.channel.nio.NioEventLoopGroup; -import net.minecraft.util.io.netty.handler.timeout.TimeoutException; -import net.minecraft.util.io.netty.util.AttributeKey; -import net.minecraft.util.io.netty.util.concurrent.GenericFutureListener; -import net.minecraft.util.org.apache.commons.lang3.Validate; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.Marker; -import org.apache.logging.log4j.MarkerManager; -// Spigot start -import com.google.common.collect.ImmutableSet; - -// Spigot end - -public class NetworkManager extends SimpleChannelInboundHandler -{ - - private static final Logger i = LogManager.getLogger(); - public static final Marker a = MarkerManager.getMarker("NETWORK"); - public static final Marker b = MarkerManager.getMarker("NETWORK_PACKETS", a); - public static final Marker c = MarkerManager.getMarker("NETWORK_STAT", a); - public static final AttributeKey d = new AttributeKey("protocol"); - public static final AttributeKey e = new AttributeKey("receivable_packets"); - public static final AttributeKey f = new AttributeKey("sendable_packets"); - public static final NioEventLoopGroup g = new NioEventLoopGroup(0, (new ThreadFactoryBuilder()) - .setNameFormat("Netty Client IO #%d").setDaemon(true).build()); - public static final NetworkStatistics h = new NetworkStatistics(); - private final boolean j; - private final Queue k = Queues.newConcurrentLinkedQueue(); - private final Queue l = Queues.newConcurrentLinkedQueue(); - private Channel m; - // Spigot Start - public SocketAddress n; - public java.util.UUID spoofedUUID; - public Property[] spoofedProfile; - public boolean preparing = true; - // Spigot End - private PacketListener o; - private EnumProtocol p; - private IChatBaseComponent q; - private boolean r; - // Spigot Start - public static final AttributeKey protocolVersion = new AttributeKey("protocol_version"); - public static final ImmutableSet SUPPORTED_VERSIONS = ImmutableSet.of(4, 5); - public static final int CURRENT_VERSION = 5; - - public static int getVersion(Channel attr) - { - Integer ver = attr.attr(protocolVersion).get(); - return (ver != null) ? ver : CURRENT_VERSION; - } - - public int getVersion() - { - return getVersion(this.m); - } - - // Spigot End - - public NetworkManager(boolean flag) - { - this.j = flag; - } - - public void channelActive(ChannelHandlerContext channelhandlercontext) throws Exception - { // CraftBukkit - throws Exception - super.channelActive(channelhandlercontext); - this.m = channelhandlercontext.channel(); - this.n = this.m.remoteAddress(); - // Spigot Start - this.preparing = false; - // Spigot End - this.a(EnumProtocol.HANDSHAKING); - } - - public void a(EnumProtocol enumprotocol) - { - this.p = (EnumProtocol) this.m.attr(d).getAndSet(enumprotocol); - this.m.attr(e).set(enumprotocol.a(this.j)); - this.m.attr(f).set(enumprotocol.b(this.j)); - this.m.config().setAutoRead(true); - i.debug("Enabled auto read"); - } - - public void channelInactive(ChannelHandlerContext channelhandlercontext) - { - this.close(new ChatMessage("disconnect.endOfStream", new Object[0])); - } - - public void exceptionCaught(ChannelHandlerContext channelhandlercontext, Throwable throwable) - { - ChatMessage chatmessage; - - if (throwable instanceof TimeoutException) - { - chatmessage = new ChatMessage("disconnect.timeout", new Object[0]); - } - else - { - chatmessage = new ChatMessage("disconnect.genericReason", - new Object[] { "Internal Exception: " + throwable }); - } - - this.close(chatmessage); - if (MinecraftServer.getServer().isDebugging()) - { - throwable.printStackTrace(); // Spigot - System.out.println("------------"); - for (StackTraceElement trace : Thread.currentThread().getStackTrace()) - { - System.out.println(trace); - } - } - } - - protected void a(ChannelHandlerContext channelhandlercontext, Packet packet) - { - if (this.m.isOpen()) - { - if (packet.a()) - { - packet.handle(this.o); - } - else - { - this.k.add(packet); - } - } - } - - public void a(PacketListener packetlistener) - { - Validate.notNull(packetlistener, "packetListener", new Object[0]); - i.debug("Set listener of {} to {}", new Object[] { this, packetlistener }); - this.o = packetlistener; - } - - public void handle(Packet packet, GenericFutureListener... agenericfuturelistener) - { - if (this.m != null && this.m.isOpen()) - { - this.i(); - this.b(packet, agenericfuturelistener); - } - else - { - this.l.add(new QueuedPacket(packet, agenericfuturelistener)); - } - } - - private void b(Packet packet, GenericFutureListener[] agenericfuturelistener) - { - EnumProtocol enumprotocol = EnumProtocol.a(packet); - EnumProtocol enumprotocol1 = (EnumProtocol) this.m.attr(d).get(); - - if (enumprotocol1 != enumprotocol) - { - i.debug("Disabled auto read"); - this.m.config().setAutoRead(false); - } - - if (this.m.eventLoop().inEventLoop()) - { - if (enumprotocol != enumprotocol1) - { - this.a(enumprotocol); - } - - this.m.writeAndFlush(packet).addListeners(agenericfuturelistener) - .addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); - } - else - { - this.m.eventLoop().execute( - new QueuedProtocolSwitch(this, enumprotocol, enumprotocol1, packet, agenericfuturelistener)); - } - } - - private void i() - { - if (this.m != null && this.m.isOpen()) - { - while (!this.l.isEmpty()) - { - QueuedPacket queuedpacket = (QueuedPacket) this.l.poll(); - - this.b(QueuedPacket.a(queuedpacket), QueuedPacket.b(queuedpacket)); - } - } - } - - public void a() - { - this.i(); - EnumProtocol enumprotocol = (EnumProtocol) this.m.attr(d).get(); - - if (this.p != enumprotocol) - { - if (this.p != null) - { - this.o.a(this.p, enumprotocol); - } - - this.p = enumprotocol; - } - - if (this.o != null) - { - for (int i = 1000; !this.k.isEmpty() && i >= 0; --i) - { - Packet packet = (Packet) this.k.poll(); - - // CraftBukkit start - if (!this.isConnected() || !this.m.config().isAutoRead()) - { - continue; - } - // CraftBukkit end - packet.handle(this.o); - } - - this.o.a(); - } - - this.m.flush(); - } - - public SocketAddress getSocketAddress() - { - return this.n; - } - - public void close(IChatBaseComponent ichatbasecomponent) - { - // Spigot Start - this.preparing = false; - // Spigot End - if (this.m.isOpen()) - { - this.m.close(); - this.q = ichatbasecomponent; - } - } - - public boolean c() - { - return this.m instanceof LocalChannel || this.m instanceof LocalServerChannel; - } - - public void a(SecretKey secretkey) - { - this.m.pipeline().addBefore("splitter", "decrypt", new PacketDecrypter(MinecraftEncryption.a(2, secretkey))); - this.m.pipeline().addBefore("prepender", "encrypt", new PacketEncrypter(MinecraftEncryption.a(1, secretkey))); - this.r = true; - } - - public boolean isConnected() - { - return this.m != null && this.m.isOpen(); - } - - public PacketListener getPacketListener() - { - return this.o; - } - - public IChatBaseComponent f() - { - return this.q; - } - - public void g() - { - this.m.config().setAutoRead(false); - } - - protected void channelRead0(ChannelHandlerContext channelhandlercontext, Object object) - { - this.a(channelhandlercontext, (Packet) object); - } - - static Channel a(NetworkManager networkmanager) - { - return networkmanager.m; - } - - // Spigot Start - public SocketAddress getRawAddress() - { - return this.m.remoteAddress(); - } - // Spigot End -} diff --git a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PacketDataSerializer.java b/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PacketDataSerializer.java deleted file mode 100644 index 4508f313c..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PacketDataSerializer.java +++ /dev/null @@ -1,922 +0,0 @@ -package net.minecraft.server.v1_7_R4; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.nio.channels.GatheringByteChannel; -import java.nio.channels.ScatteringByteChannel; -import java.nio.charset.Charset; - -import net.minecraft.util.com.google.common.base.Charsets; -import net.minecraft.util.io.netty.buffer.ByteBuf; -import net.minecraft.util.io.netty.buffer.ByteBufAllocator; -import net.minecraft.util.io.netty.buffer.ByteBufProcessor; - -import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack; // CraftBukkit - -public class PacketDataSerializer extends ByteBuf -{ - - private final ByteBuf a; - // Spigot Start - public final int version; - - public PacketDataSerializer(ByteBuf bytebuf) - { - this(bytebuf, NetworkManager.CURRENT_VERSION); - } - - public PacketDataSerializer(ByteBuf bytebuf, int version) - { - this.a = bytebuf; - this.version = version; - } - - // Spigot End - - public static int a(int i) - { - return (i & -128) == 0 ? 1 : ((i & -16384) == 0 ? 2 : ((i & -2097152) == 0 ? 3 - : ((i & -268435456) == 0 ? 4 : 5))); - } - - public int a() - { - int i = 0; - int j = 0; - - byte b0; - - do - { - b0 = this.readByte(); - i |= (b0 & 127) << j++ * 7; - if (j > 5) - { - throw new RuntimeException("VarInt too big"); - } - } - while ((b0 & 128) == 128); - - return i; - } - - public void b(int i) - { - while ((i & -128) != 0) - { - this.writeByte(i & 127 | 128); - i >>>= 7; - } - - this.writeByte(i); - } - - public void a(NBTTagCompound nbttagcompound) - { - if (nbttagcompound == null) - { - this.writeShort(-1); - } - else - { - byte[] abyte = NBTCompressedStreamTools.a(nbttagcompound); - - this.writeShort((short) abyte.length); - this.writeBytes(abyte); - } - } - - public NBTTagCompound b() - { - short short1 = this.readShort(); - - if (short1 < 0) - { - return null; - } - else - { - byte[] abyte = new byte[short1]; - - this.readBytes(abyte); - return NBTCompressedStreamTools.a(abyte, new NBTReadLimiter(2097152L)); - } - } - - public void a(ItemStack itemstack) - { - if (itemstack == null || itemstack.getItem() == null) - { // CraftBukkit - NPE fix itemstack.getItem() - this.writeShort(-1); - } - else - { - this.writeShort(Item.getId(itemstack.getItem())); - this.writeByte(itemstack.count); - this.writeShort(itemstack.getData()); - NBTTagCompound nbttagcompound = null; - - if (itemstack.getItem().usesDurability() || itemstack.getItem().s()) - { - nbttagcompound = itemstack.tag; - } - - this.a(nbttagcompound); - } - } - - public ItemStack c() - { - ItemStack itemstack = null; - short short1 = this.readShort(); - - if (short1 >= 0) - { - byte b0 = this.readByte(); - short short2 = this.readShort(); - - itemstack = new ItemStack(Item.getById(short1), b0, short2); - itemstack.tag = this.b(); - // CraftBukkit start - if (itemstack.tag != null) - { - CraftItemStack.setItemMeta(itemstack, CraftItemStack.getItemMeta(itemstack)); - } - // CraftBukkit end - } - - return itemstack; - } - - public String c(int i) throws IOException - { // CraftBukkit - throws IOException - int j = this.a(); - - if (j > i * 4) - { - throw new IOException("The received encoded string buffer length is longer than maximum allowed (" + j - + " > " + i * 4 + ")"); - } - else if (j < 0) - { - throw new IOException("The received encoded string buffer length is less than zero! Weird string!"); - } - else - { - String s = new String(this.readBytes(j).array(), Charsets.UTF_8); - - if (s.length() > i) - { - throw new IOException("The received string length is longer than maximum allowed (" + j + " > " + i - + ")"); - } - else - { - return s; - } - } - } - - public void a(String s) throws IOException - { // CraftBukkit - throws IOException - byte[] abyte = s.getBytes(Charsets.UTF_8); - - if (abyte.length > 32767) - { - throw new IOException("String too big (was " + s.length() + " bytes encoded, max " + 32767 + ")"); - } - else - { - this.b(abyte.length); - this.writeBytes(abyte); - } - } - - public int capacity() - { - return this.a.capacity(); - } - - public ByteBuf capacity(int i) - { - return this.a.capacity(i); - } - - public int maxCapacity() - { - return this.a.maxCapacity(); - } - - public ByteBufAllocator alloc() - { - return this.a.alloc(); - } - - public ByteOrder order() - { - return this.a.order(); - } - - public ByteBuf order(ByteOrder byteorder) - { - return this.a.order(byteorder); - } - - public ByteBuf unwrap() - { - return this.a.unwrap(); - } - - public boolean isDirect() - { - return this.a.isDirect(); - } - - public int readerIndex() - { - return this.a.readerIndex(); - } - - public ByteBuf readerIndex(int i) - { - return this.a.readerIndex(i); - } - - public int writerIndex() - { - return this.a.writerIndex(); - } - - public ByteBuf writerIndex(int i) - { - return this.a.writerIndex(i); - } - - public ByteBuf setIndex(int i, int j) - { - return this.a.setIndex(i, j); - } - - public int readableBytes() - { - return this.a.readableBytes(); - } - - public int writableBytes() - { - return this.a.writableBytes(); - } - - public int maxWritableBytes() - { - return this.a.maxWritableBytes(); - } - - public boolean isReadable() - { - return this.a.isReadable(); - } - - public boolean isReadable(int i) - { - return this.a.isReadable(i); - } - - public boolean isWritable() - { - return this.a.isWritable(); - } - - public boolean isWritable(int i) - { - return this.a.isWritable(i); - } - - public ByteBuf clear() - { - return this.a.clear(); - } - - public ByteBuf markReaderIndex() - { - return this.a.markReaderIndex(); - } - - public ByteBuf resetReaderIndex() - { - return this.a.resetReaderIndex(); - } - - public ByteBuf markWriterIndex() - { - return this.a.markWriterIndex(); - } - - public ByteBuf resetWriterIndex() - { - return this.a.resetWriterIndex(); - } - - public ByteBuf discardReadBytes() - { - return this.a.discardReadBytes(); - } - - public ByteBuf discardSomeReadBytes() - { - return this.a.discardSomeReadBytes(); - } - - public ByteBuf ensureWritable(int i) - { - return this.a.ensureWritable(i); - } - - public int ensureWritable(int i, boolean flag) - { - return this.a.ensureWritable(i, flag); - } - - public boolean getBoolean(int i) - { - return this.a.getBoolean(i); - } - - public byte getByte(int i) - { - return this.a.getByte(i); - } - - public short getUnsignedByte(int i) - { - return this.a.getUnsignedByte(i); - } - - public short getShort(int i) - { - return this.a.getShort(i); - } - - public int getUnsignedShort(int i) - { - return this.a.getUnsignedShort(i); - } - - public int getMedium(int i) - { - return this.a.getMedium(i); - } - - public int getUnsignedMedium(int i) - { - return this.a.getUnsignedMedium(i); - } - - public int getInt(int i) - { - return this.a.getInt(i); - } - - public long getUnsignedInt(int i) - { - return this.a.getUnsignedInt(i); - } - - public long getLong(int i) - { - return this.a.getLong(i); - } - - public char getChar(int i) - { - return this.a.getChar(i); - } - - public float getFloat(int i) - { - return this.a.getFloat(i); - } - - public double getDouble(int i) - { - return this.a.getDouble(i); - } - - public ByteBuf getBytes(int i, ByteBuf bytebuf) - { - return this.a.getBytes(i, bytebuf); - } - - public ByteBuf getBytes(int i, ByteBuf bytebuf, int j) - { - return this.a.getBytes(i, bytebuf, j); - } - - public ByteBuf getBytes(int i, ByteBuf bytebuf, int j, int k) - { - return this.a.getBytes(i, bytebuf, j, k); - } - - public ByteBuf getBytes(int i, byte[] abyte) - { - return this.a.getBytes(i, abyte); - } - - public ByteBuf getBytes(int i, byte[] abyte, int j, int k) - { - return this.a.getBytes(i, abyte, j, k); - } - - public ByteBuf getBytes(int i, ByteBuffer bytebuffer) - { - return this.a.getBytes(i, bytebuffer); - } - - public ByteBuf getBytes(int i, OutputStream outputstream, int j) throws IOException - { // CraftBukkit - throws IOException - return this.a.getBytes(i, outputstream, j); - } - - public int getBytes(int i, GatheringByteChannel gatheringbytechannel, int j) throws IOException - { // CraftBukkit - throws IOException - return this.a.getBytes(i, gatheringbytechannel, j); - } - - public ByteBuf setBoolean(int i, boolean flag) - { - return this.a.setBoolean(i, flag); - } - - public ByteBuf setByte(int i, int j) - { - return this.a.setByte(i, j); - } - - public ByteBuf setShort(int i, int j) - { - return this.a.setShort(i, j); - } - - public ByteBuf setMedium(int i, int j) - { - return this.a.setMedium(i, j); - } - - public ByteBuf setInt(int i, int j) - { - return this.a.setInt(i, j); - } - - public ByteBuf setLong(int i, long j) - { - return this.a.setLong(i, j); - } - - public ByteBuf setChar(int i, int j) - { - return this.a.setChar(i, j); - } - - public ByteBuf setFloat(int i, float f) - { - return this.a.setFloat(i, f); - } - - public ByteBuf setDouble(int i, double d0) - { - return this.a.setDouble(i, d0); - } - - public ByteBuf setBytes(int i, ByteBuf bytebuf) - { - return this.a.setBytes(i, bytebuf); - } - - public ByteBuf setBytes(int i, ByteBuf bytebuf, int j) - { - return this.a.setBytes(i, bytebuf, j); - } - - public ByteBuf setBytes(int i, ByteBuf bytebuf, int j, int k) - { - return this.a.setBytes(i, bytebuf, j, k); - } - - public ByteBuf setBytes(int i, byte[] abyte) - { - return this.a.setBytes(i, abyte); - } - - public ByteBuf setBytes(int i, byte[] abyte, int j, int k) - { - return this.a.setBytes(i, abyte, j, k); - } - - public ByteBuf setBytes(int i, ByteBuffer bytebuffer) - { - return this.a.setBytes(i, bytebuffer); - } - - public int setBytes(int i, InputStream inputstream, int j) throws IOException - { // CraftBukkit - throws IOException - return this.a.setBytes(i, inputstream, j); - } - - public int setBytes(int i, ScatteringByteChannel scatteringbytechannel, int j) throws IOException - { // CraftBukkit - throws IOException - return this.a.setBytes(i, scatteringbytechannel, j); - } - - public ByteBuf setZero(int i, int j) - { - return this.a.setZero(i, j); - } - - public boolean readBoolean() - { - return this.a.readBoolean(); - } - - public byte readByte() - { - return this.a.readByte(); - } - - public short readUnsignedByte() - { - return this.a.readUnsignedByte(); - } - - public short readShort() - { - return this.a.readShort(); - } - - public int readUnsignedShort() - { - return this.a.readUnsignedShort(); - } - - public int readMedium() - { - return this.a.readMedium(); - } - - public int readUnsignedMedium() - { - return this.a.readUnsignedMedium(); - } - - public int readInt() - { - return this.a.readInt(); - } - - public long readUnsignedInt() - { - return this.a.readUnsignedInt(); - } - - public long readLong() - { - return this.a.readLong(); - } - - public char readChar() - { - return this.a.readChar(); - } - - public float readFloat() - { - return this.a.readFloat(); - } - - public double readDouble() - { - return this.a.readDouble(); - } - - public ByteBuf readBytes(int i) - { - return this.a.readBytes(i); - } - - public ByteBuf readSlice(int i) - { - return this.a.readSlice(i); - } - - public ByteBuf readBytes(ByteBuf bytebuf) - { - return this.a.readBytes(bytebuf); - } - - public ByteBuf readBytes(ByteBuf bytebuf, int i) - { - return this.a.readBytes(bytebuf, i); - } - - public ByteBuf readBytes(ByteBuf bytebuf, int i, int j) - { - return this.a.readBytes(bytebuf, i, j); - } - - public ByteBuf readBytes(byte[] abyte) - { - return this.a.readBytes(abyte); - } - - public ByteBuf readBytes(byte[] abyte, int i, int j) - { - return this.a.readBytes(abyte, i, j); - } - - public ByteBuf readBytes(ByteBuffer bytebuffer) - { - return this.a.readBytes(bytebuffer); - } - - public ByteBuf readBytes(OutputStream outputstream, int i) throws IOException - { // CraftBukkit - throws IOException - return this.a.readBytes(outputstream, i); - } - - public int readBytes(GatheringByteChannel gatheringbytechannel, int i) throws IOException - { // CraftBukkit - throws IOException - return this.a.readBytes(gatheringbytechannel, i); - } - - public ByteBuf skipBytes(int i) - { - return this.a.skipBytes(i); - } - - public ByteBuf writeBoolean(boolean flag) - { - return this.a.writeBoolean(flag); - } - - public ByteBuf writeByte(int i) - { - return this.a.writeByte(i); - } - - public ByteBuf writeShort(int i) - { - return this.a.writeShort(i); - } - - public ByteBuf writeMedium(int i) - { - return this.a.writeMedium(i); - } - - public ByteBuf writeInt(int i) - { - return this.a.writeInt(i); - } - - public ByteBuf writeLong(long i) - { - return this.a.writeLong(i); - } - - public ByteBuf writeChar(int i) - { - return this.a.writeChar(i); - } - - public ByteBuf writeFloat(float f) - { - return this.a.writeFloat(f); - } - - public ByteBuf writeDouble(double d0) - { - return this.a.writeDouble(d0); - } - - public ByteBuf writeBytes(ByteBuf bytebuf) - { - return this.a.writeBytes(bytebuf); - } - - public ByteBuf writeBytes(ByteBuf bytebuf, int i) - { - return this.a.writeBytes(bytebuf, i); - } - - public ByteBuf writeBytes(ByteBuf bytebuf, int i, int j) - { - return this.a.writeBytes(bytebuf, i, j); - } - - public ByteBuf writeBytes(byte[] abyte) - { - return this.a.writeBytes(abyte); - } - - public ByteBuf writeBytes(byte[] abyte, int i, int j) - { - return this.a.writeBytes(abyte, i, j); - } - - public ByteBuf writeBytes(ByteBuffer bytebuffer) - { - return this.a.writeBytes(bytebuffer); - } - - public int writeBytes(InputStream inputstream, int i) throws IOException - { // CraftBukkit - throws IOException - return this.a.writeBytes(inputstream, i); - } - - public int writeBytes(ScatteringByteChannel scatteringbytechannel, int i) throws IOException - { // CraftBukkit - throws IOException - return this.a.writeBytes(scatteringbytechannel, i); - } - - public ByteBuf writeZero(int i) - { - return this.a.writeZero(i); - } - - public int indexOf(int i, int j, byte b0) - { - return this.a.indexOf(i, j, b0); - } - - public int bytesBefore(byte b0) - { - return this.a.bytesBefore(b0); - } - - public int bytesBefore(int i, byte b0) - { - return this.a.bytesBefore(i, b0); - } - - public int bytesBefore(int i, int j, byte b0) - { - return this.a.bytesBefore(i, j, b0); - } - - public int forEachByte(ByteBufProcessor bytebufprocessor) - { - return this.a.forEachByte(bytebufprocessor); - } - - public int forEachByte(int i, int j, ByteBufProcessor bytebufprocessor) - { - return this.a.forEachByte(i, j, bytebufprocessor); - } - - public int forEachByteDesc(ByteBufProcessor bytebufprocessor) - { - return this.a.forEachByteDesc(bytebufprocessor); - } - - public int forEachByteDesc(int i, int j, ByteBufProcessor bytebufprocessor) - { - return this.a.forEachByteDesc(i, j, bytebufprocessor); - } - - public ByteBuf copy() - { - return this.a.copy(); - } - - public ByteBuf copy(int i, int j) - { - return this.a.copy(i, j); - } - - public ByteBuf slice() - { - return this.a.slice(); - } - - public ByteBuf slice(int i, int j) - { - return this.a.slice(i, j); - } - - public ByteBuf duplicate() - { - return this.a.duplicate(); - } - - public int nioBufferCount() - { - return this.a.nioBufferCount(); - } - - public ByteBuffer nioBuffer() - { - return this.a.nioBuffer(); - } - - public ByteBuffer nioBuffer(int i, int j) - { - return this.a.nioBuffer(i, j); - } - - public ByteBuffer internalNioBuffer(int i, int j) - { - return this.a.internalNioBuffer(i, j); - } - - public ByteBuffer[] nioBuffers() - { - return this.a.nioBuffers(); - } - - public ByteBuffer[] nioBuffers(int i, int j) - { - return this.a.nioBuffers(i, j); - } - - public boolean hasArray() - { - return this.a.hasArray(); - } - - public byte[] array() - { - return this.a.array(); - } - - public int arrayOffset() - { - return this.a.arrayOffset(); - } - - public boolean hasMemoryAddress() - { - return this.a.hasMemoryAddress(); - } - - public long memoryAddress() - { - return this.a.memoryAddress(); - } - - public String toString(Charset charset) - { - return this.a.toString(charset); - } - - public String toString(int i, int j, Charset charset) - { - return this.a.toString(i, j, charset); - } - - public int hashCode() - { - return this.a.hashCode(); - } - - public boolean equals(Object object) - { - return this.a.equals(object); - } - - public int compareTo(ByteBuf bytebuf) - { - return this.a.compareTo(bytebuf); - } - - public String toString() - { - return this.a.toString(); - } - - public ByteBuf retain(int i) - { - return this.a.retain(i); - } - - public ByteBuf retain() - { - return this.a.retain(); - } - - public int refCnt() - { - return this.a.refCnt(); - } - - public boolean release() - { - return this.a.release(); - } - - public boolean release(int i) - { - return this.a.release(i); - } -} diff --git a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PacketPlayInCloseWindow.java b/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PacketPlayInCloseWindow.java deleted file mode 100644 index 3aec9c7fc..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PacketPlayInCloseWindow.java +++ /dev/null @@ -1,34 +0,0 @@ -package net.minecraft.server.v1_7_R4; - -public class PacketPlayInCloseWindow - extends Packet -{ - public int a; - - public PacketPlayInCloseWindow() {} - - public PacketPlayInCloseWindow(int id) - { - this.a = id; - } - - public void a(PacketPlayInListener packetplayinlistener) - { - packetplayinlistener.a(this); - } - - public void a(PacketDataSerializer packetdataserializer) - { - this.a = packetdataserializer.readByte(); - } - - public void b(PacketDataSerializer packetdataserializer) - { - packetdataserializer.writeByte(this.a); - } - - public void handle(PacketListener packetlistener) - { - a((PacketPlayInListener)packetlistener); - } -} diff --git a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PacketPlayOutAnimation.java b/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PacketPlayOutAnimation.java deleted file mode 100644 index 79fd80c40..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PacketPlayOutAnimation.java +++ /dev/null @@ -1,42 +0,0 @@ -package net.minecraft.server.v1_7_R4; - -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/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PacketPlayOutAttachEntity.java b/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PacketPlayOutAttachEntity.java deleted file mode 100644 index ef789c0a8..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PacketPlayOutAttachEntity.java +++ /dev/null @@ -1,41 +0,0 @@ -package net.minecraft.server.v1_7_R4; - -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/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PacketPlayOutEntity.java b/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PacketPlayOutEntity.java deleted file mode 100644 index 9e4f0b81d..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PacketPlayOutEntity.java +++ /dev/null @@ -1,50 +0,0 @@ -package net.minecraft.server.v1_7_R4; - -public class PacketPlayOutEntity - extends Packet -{ - public int a; - public byte b; - public byte c; - public byte d; - public byte e; - public byte f; - public boolean g; - - public PacketPlayOutEntity() {} - - public PacketPlayOutEntity(int paramInt) - { - this.a = paramInt; - } - - public void a(PacketDataSerializer paramPacketDataSerializer) - { - this.a = paramPacketDataSerializer.readInt(); - } - - public void b(PacketDataSerializer paramPacketDataSerializer) - { - paramPacketDataSerializer.writeInt(this.a); - } - - public void a(PacketPlayOutListener paramPacketPlayOutListener) - { - paramPacketPlayOutListener.a(this); - } - - public String b() - { - return String.format("id=%d", new Object[] { Integer.valueOf(this.a) }); - } - - public String toString() - { - return "Entity_" + super.toString(); - } - -@Override -public void handle(PacketListener arg0) -{ -} -} diff --git a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PacketPlayOutEntityEquipment.java b/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PacketPlayOutEntityEquipment.java deleted file mode 100644 index 0b299271f..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PacketPlayOutEntityEquipment.java +++ /dev/null @@ -1,46 +0,0 @@ -package net.minecraft.server.v1_7_R4; - -public class PacketPlayOutEntityEquipment extends Packet -{ - public int a; - public int b; - private ItemStack c; - - public PacketPlayOutEntityEquipment() {} - - public PacketPlayOutEntityEquipment(int paramInt1, int paramInt2, ItemStack paramItemStack) - { - this.a = paramInt1; - this.b = paramInt2; - this.c = (paramItemStack == null ? null : paramItemStack.cloneItemStack()); - } - - public void a(PacketDataSerializer paramPacketDataSerializer) - { - this.a = paramPacketDataSerializer.readInt(); - this.b = paramPacketDataSerializer.readShort(); - this.c = paramPacketDataSerializer.c(); - } - - public void b(PacketDataSerializer paramPacketDataSerializer) - { - paramPacketDataSerializer.writeInt(this.a); - paramPacketDataSerializer.writeShort(this.b); - paramPacketDataSerializer.a(this.c); - } - - public void a(PacketPlayOutListener paramPacketPlayOutListener) - { - paramPacketPlayOutListener.a(this); - } - - public String b() - { - return String.format("entity=%d, slot=%d, item=%s", new Object[] { Integer.valueOf(this.a), Integer.valueOf(this.b), this.c }); - } - -@Override -public void handle(PacketListener paramPacketListener) -{ -} -} diff --git a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PacketPlayOutEntityMetadata.java b/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PacketPlayOutEntityMetadata.java deleted file mode 100644 index a217bf577..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PacketPlayOutEntityMetadata.java +++ /dev/null @@ -1,43 +0,0 @@ -package net.minecraft.server.v1_7_R4; - -import java.util.List; - -public class PacketPlayOutEntityMetadata extends Packet -{ - public int a; - public List b; - - public PacketPlayOutEntityMetadata() {} - - public PacketPlayOutEntityMetadata(int paramInt, DataWatcher paramDataWatcher, boolean paramBoolean) - { - this.a = paramInt; - if (paramBoolean) { - this.b = paramDataWatcher.c(); - } else { - this.b = paramDataWatcher.b(); - } - } - - public void a(PacketDataSerializer paramPacketDataSerializer) - { - this.a = paramPacketDataSerializer.readInt(); - this.b = DataWatcher.b(paramPacketDataSerializer); - } - - public void b(PacketDataSerializer paramPacketDataSerializer) - { - paramPacketDataSerializer.writeInt(this.a); - DataWatcher.a(this.b, paramPacketDataSerializer); - } - - public void a(PacketPlayOutListener paramPacketPlayOutListener) - { - paramPacketPlayOutListener.a(this); - } - -@Override -public void handle(PacketListener arg0) -{ -} -} diff --git a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PacketPlayOutEntityTeleport.java b/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PacketPlayOutEntityTeleport.java deleted file mode 100644 index 8c29b1b95..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PacketPlayOutEntityTeleport.java +++ /dev/null @@ -1,66 +0,0 @@ -package net.minecraft.server.v1_7_R4; - -public class PacketPlayOutEntityTeleport extends Packet -{ - public int a; - public int b; - public int c; - public int d; - public byte e; - public byte f; - - public PacketPlayOutEntityTeleport() - { - } - - public PacketPlayOutEntityTeleport(Entity paramEntity) - { - this.a = paramEntity.getId(); - this.b = MathHelper.floor(paramEntity.locX * 32.0D); - this.c = MathHelper.floor(paramEntity.locY * 32.0D); - this.d = MathHelper.floor(paramEntity.locZ * 32.0D); - this.e = ((byte) (int) (paramEntity.yaw * 256.0F / 360.0F)); - this.f = ((byte) (int) (paramEntity.pitch * 256.0F / 360.0F)); - } - - public PacketPlayOutEntityTeleport(int paramInt1, int paramInt2, int paramInt3, int paramInt4, byte paramByte1, - byte paramByte2) - { - this.a = paramInt1; - this.b = paramInt2; - this.c = paramInt3; - this.d = paramInt4; - this.e = paramByte1; - this.f = paramByte2; - } - - public void a(PacketDataSerializer paramPacketDataSerializer) - { - this.a = paramPacketDataSerializer.readInt(); - this.b = paramPacketDataSerializer.readInt(); - this.c = paramPacketDataSerializer.readInt(); - this.d = paramPacketDataSerializer.readInt(); - this.e = paramPacketDataSerializer.readByte(); - this.f = paramPacketDataSerializer.readByte(); - } - - public void b(PacketDataSerializer paramPacketDataSerializer) - { - paramPacketDataSerializer.writeInt(this.a); - paramPacketDataSerializer.writeInt(this.b); - paramPacketDataSerializer.writeInt(this.c); - paramPacketDataSerializer.writeInt(this.d); - paramPacketDataSerializer.writeByte(this.e); - paramPacketDataSerializer.writeByte(this.f); - } - - public void a(PacketPlayOutListener paramPacketPlayOutListener) - { - paramPacketPlayOutListener.a(this); - } - - @Override - public void handle(PacketListener arg0) - { - } -} diff --git a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PacketPlayOutEntityVelocity.java b/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PacketPlayOutEntityVelocity.java deleted file mode 100644 index 83503e652..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PacketPlayOutEntityVelocity.java +++ /dev/null @@ -1,75 +0,0 @@ -package net.minecraft.server.v1_7_R4; - -public class PacketPlayOutEntityVelocity - extends Packet -{ - public int a; - public int b; - public int c; - public int d; - - public PacketPlayOutEntityVelocity() {} - - public PacketPlayOutEntityVelocity(Entity paramEntity) - { - this(paramEntity.getId(), paramEntity.motX, paramEntity.motY, paramEntity.motZ); - } - - public PacketPlayOutEntityVelocity(int paramInt, double paramDouble1, double paramDouble2, double paramDouble3) - { - this.a = paramInt; - double d1 = 3.9D; - if (paramDouble1 < -d1) { - paramDouble1 = -d1; - } - if (paramDouble2 < -d1) { - paramDouble2 = -d1; - } - if (paramDouble3 < -d1) { - paramDouble3 = -d1; - } - if (paramDouble1 > d1) { - paramDouble1 = d1; - } - if (paramDouble2 > d1) { - paramDouble2 = d1; - } - if (paramDouble3 > d1) { - paramDouble3 = d1; - } - this.b = ((int)(paramDouble1 * 8000.0D)); - this.c = ((int)(paramDouble2 * 8000.0D)); - this.d = ((int)(paramDouble3 * 8000.0D)); - } - - public void a(PacketDataSerializer paramPacketDataSerializer) - { - this.a = paramPacketDataSerializer.readInt(); - this.b = paramPacketDataSerializer.readShort(); - this.c = paramPacketDataSerializer.readShort(); - this.d = paramPacketDataSerializer.readShort(); - } - - public void b(PacketDataSerializer paramPacketDataSerializer) - { - paramPacketDataSerializer.writeInt(this.a); - paramPacketDataSerializer.writeShort(this.b); - paramPacketDataSerializer.writeShort(this.c); - paramPacketDataSerializer.writeShort(this.d); - } - - public void a(PacketPlayOutListener paramPacketPlayOutListener) - { - paramPacketPlayOutListener.a(this); - } - - public String b() - { - return String.format("id=%d, x=%.2f, y=%.2f, z=%.2f", new Object[] { Integer.valueOf(this.a), Float.valueOf(this.b / 8000.0F), Float.valueOf(this.c / 8000.0F), Float.valueOf(this.d / 8000.0F) }); - } - -@Override -public void handle(PacketListener arg0) -{ -} -} diff --git a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PacketPlayOutNamedEntitySpawn.java b/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PacketPlayOutNamedEntitySpawn.java deleted file mode 100644 index a7df8e757..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PacketPlayOutNamedEntitySpawn.java +++ /dev/null @@ -1,103 +0,0 @@ -package net.minecraft.server.v1_7_R4; - -import java.util.Iterator; -import java.util.List; -import java.util.UUID; - -import net.minecraft.util.com.mojang.authlib.properties.Property; -import net.minecraft.util.com.mojang.authlib.GameProfile; - -import java.io.IOException; // CraftBukkit - -public class PacketPlayOutNamedEntitySpawn extends Packet { - - public int a; - public GameProfile b; - public int c; - public int d; - public int e; - public byte f; - public byte g; - public int h; - public DataWatcher i; - public List j; - - public PacketPlayOutNamedEntitySpawn() {} - - public PacketPlayOutNamedEntitySpawn(EntityHuman entityhuman) { - this.a = entityhuman.getId(); - this.b = entityhuman.getProfile(); - this.c = MathHelper.floor(entityhuman.locX * 32.0D); - this.d = MathHelper.floor(entityhuman.locY * 32.0D); - this.e = MathHelper.floor(entityhuman.locZ * 32.0D); - this.f = (byte) ((int) (entityhuman.yaw * 256.0F / 360.0F)); - this.g = (byte) ((int) (entityhuman.pitch * 256.0F / 360.0F)); - ItemStack itemstack = entityhuman.inventory.getItemInHand(); - - this.h = itemstack == null ? 0 : Item.getId(itemstack.getItem()); - this.i = entityhuman.getDataWatcher(); - } - - public void a(PacketDataSerializer packetdataserializer) throws IOException { // CraftBukkit - added throws - this.a = packetdataserializer.a(); - UUID uuid = UUID.fromString(packetdataserializer.c(36)); - - this.b = new GameProfile(uuid, packetdataserializer.c(16)); - int i = packetdataserializer.a(); - - for (int j = 0; j < i; ++j) { - String s = packetdataserializer.c(32767); - String s1 = packetdataserializer.c(32767); - String s2 = packetdataserializer.c(32767); - - this.b.getProperties().put(s, new Property(s, s1, s2)); - } - this.c = packetdataserializer.readInt(); - this.d = packetdataserializer.readInt(); - this.e = packetdataserializer.readInt(); - this.f = packetdataserializer.readByte(); - this.g = packetdataserializer.readByte(); - this.h = packetdataserializer.readShort(); - this.j = DataWatcher.b(packetdataserializer); - } - - public void b(PacketDataSerializer packetdataserializer) throws IOException { // CraftBukkit - added throws - packetdataserializer.b(this.a); - UUID uuid = this.b.getId(); - - packetdataserializer.a( uuid == null ? "" : ( ( packetdataserializer.version >= 5 ) ? uuid.toString() : uuid.toString().replaceAll( "-", "" ) ) ); // Spigot - packetdataserializer.a(this.b.getName().length() > 16 ? this.b.getName().substring(0, 16) : this.b.getName()); // CraftBukkit - Limit name length to 16 characters - if (packetdataserializer.version >= 5 ) - { // Spigot - packetdataserializer.b(this.b.getProperties().size()); - Iterator iterator = this.b.getProperties().values().iterator(); - - while (iterator.hasNext()) { - Property property = (Property) iterator.next(); - - packetdataserializer.a(property.getName()); - packetdataserializer.a(property.getValue()); - packetdataserializer.a(property.getSignature()); - } - } // Spigot - packetdataserializer.writeInt(this.c); - packetdataserializer.writeInt(this.d); - packetdataserializer.writeInt(this.e); - packetdataserializer.writeByte(this.f); - packetdataserializer.writeByte(this.g); - packetdataserializer.writeShort(this.h); - this.i.a(packetdataserializer); - } - - public void a(PacketPlayOutListener packetplayoutlistener) { - packetplayoutlistener.a(this); - } - - public String b() { - return String.format("id=%d, gameProfile=\'%s\', x=%.2f, y=%.2f, z=%.2f, carried=%d", new Object[] { Integer.valueOf(this.a), this.b, Float.valueOf((float) this.c / 32.0F), Float.valueOf((float) this.d / 32.0F), Float.valueOf((float) this.e / 32.0F), Integer.valueOf(this.h)}); - } - - public void handle(PacketListener packetlistener) { - this.a((PacketPlayOutListener) packetlistener); - } -} \ No newline at end of file diff --git a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PacketPlayOutRelEntityMove.java b/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PacketPlayOutRelEntityMove.java deleted file mode 100644 index 567407233..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PacketPlayOutRelEntityMove.java +++ /dev/null @@ -1,36 +0,0 @@ -package net.minecraft.server.v1_7_R4; - -public class PacketPlayOutRelEntityMove - extends PacketPlayOutEntity -{ - public PacketPlayOutRelEntityMove() {} - - public PacketPlayOutRelEntityMove(int paramInt, byte paramByte1, byte paramByte2, byte paramByte3) - { - super(paramInt); - this.b = paramByte1; - this.c = paramByte2; - this.d = paramByte3; - } - - public void a(PacketDataSerializer paramPacketDataSerializer) - { - super.a(paramPacketDataSerializer); - this.b = paramPacketDataSerializer.readByte(); - this.c = paramPacketDataSerializer.readByte(); - this.d = paramPacketDataSerializer.readByte(); - } - - public void b(PacketDataSerializer paramPacketDataSerializer) - { - super.b(paramPacketDataSerializer); - paramPacketDataSerializer.writeByte(this.b); - paramPacketDataSerializer.writeByte(this.c); - paramPacketDataSerializer.writeByte(this.d); - } - - public String b() - { - return super.b() + String.format(", xa=%d, ya=%d, za=%d", new Object[] { Byte.valueOf(this.b), Byte.valueOf(this.c), Byte.valueOf(this.d) }); - } -} diff --git a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PacketPlayOutRelEntityMoveLook.java b/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PacketPlayOutRelEntityMoveLook.java deleted file mode 100644 index f86f47c13..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PacketPlayOutRelEntityMoveLook.java +++ /dev/null @@ -1,46 +0,0 @@ -package net.minecraft.server.v1_7_R4; - -public class PacketPlayOutRelEntityMoveLook - extends PacketPlayOutEntity -{ - public PacketPlayOutRelEntityMoveLook() - { - this.g = true; - } - - public PacketPlayOutRelEntityMoveLook(int paramInt, byte paramByte1, byte paramByte2, byte paramByte3, byte paramByte4, byte paramByte5) - { - super(paramInt); - this.b = paramByte1; - this.c = paramByte2; - this.d = paramByte3; - this.e = paramByte4; - this.f = paramByte5; - this.g = true; - } - - public void a(PacketDataSerializer paramPacketDataSerializer) - { - super.a(paramPacketDataSerializer); - this.b = paramPacketDataSerializer.readByte(); - this.c = paramPacketDataSerializer.readByte(); - this.d = paramPacketDataSerializer.readByte(); - this.e = paramPacketDataSerializer.readByte(); - this.f = paramPacketDataSerializer.readByte(); - } - - public void b(PacketDataSerializer paramPacketDataSerializer) - { - super.b(paramPacketDataSerializer); - paramPacketDataSerializer.writeByte(this.b); - paramPacketDataSerializer.writeByte(this.c); - paramPacketDataSerializer.writeByte(this.d); - paramPacketDataSerializer.writeByte(this.e); - paramPacketDataSerializer.writeByte(this.f); - } - - public String b() - { - return super.b() + String.format(", xa=%d, ya=%d, za=%d, yRot=%d, xRot=%d", new Object[] { Byte.valueOf(this.b), Byte.valueOf(this.c), Byte.valueOf(this.d), Byte.valueOf(this.e), Byte.valueOf(this.f) }); - } -} diff --git a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PacketPlayOutSpawnEntity.java b/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PacketPlayOutSpawnEntity.java deleted file mode 100644 index a13a7594b..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PacketPlayOutSpawnEntity.java +++ /dev/null @@ -1,144 +0,0 @@ -package net.minecraft.server.v1_7_R4; - -public class PacketPlayOutSpawnEntity extends Packet -{ - public int a; - public int b; - public int c; - public int d; - public int e; - public int f; - public int g; - public int h; - public int i; - public int j; - public int k; - - public PacketPlayOutSpawnEntity() {} - - public PacketPlayOutSpawnEntity(Entity paramEntity, int paramInt) - { - this(paramEntity, paramInt, 0); - } - - public PacketPlayOutSpawnEntity(Entity paramEntity, int paramInt1, int paramInt2) - { - this.a = paramEntity.getId(); - this.b = MathHelper.floor(paramEntity.locX * 32.0D); - this.c = MathHelper.floor(paramEntity.locY * 32.0D); - this.d = MathHelper.floor(paramEntity.locZ * 32.0D); - this.h = MathHelper.d(paramEntity.pitch * 256.0F / 360.0F); - this.i = MathHelper.d(paramEntity.yaw * 256.0F / 360.0F); - this.j = paramInt1; - this.k = paramInt2; - if (paramInt2 > 0) - { - double d1 = paramEntity.motX; - double d2 = paramEntity.motY; - double d3 = paramEntity.motZ; - double d4 = 3.9D; - if (d1 < -d4) { - d1 = -d4; - } - if (d2 < -d4) { - d2 = -d4; - } - if (d3 < -d4) { - d3 = -d4; - } - if (d1 > d4) { - d1 = d4; - } - if (d2 > d4) { - d2 = d4; - } - if (d3 > d4) { - d3 = d4; - } - this.e = ((int)(d1 * 8000.0D)); - this.f = ((int)(d2 * 8000.0D)); - this.g = ((int)(d3 * 8000.0D)); - } - } - - public void a(PacketDataSerializer paramPacketDataSerializer) - { - this.a = paramPacketDataSerializer.a(); - this.j = paramPacketDataSerializer.readByte(); - this.b = paramPacketDataSerializer.readInt(); - this.c = paramPacketDataSerializer.readInt(); - this.d = paramPacketDataSerializer.readInt(); - this.h = paramPacketDataSerializer.readByte(); - this.i = paramPacketDataSerializer.readByte(); - this.k = paramPacketDataSerializer.readInt(); - if (this.k > 0) - { - this.e = paramPacketDataSerializer.readShort(); - this.f = paramPacketDataSerializer.readShort(); - this.g = paramPacketDataSerializer.readShort(); - } - } - - public void b(PacketDataSerializer paramPacketDataSerializer) - { - paramPacketDataSerializer.b(this.a); - paramPacketDataSerializer.writeByte(this.j); - paramPacketDataSerializer.writeInt(this.b); - paramPacketDataSerializer.writeInt(this.c); - paramPacketDataSerializer.writeInt(this.d); - paramPacketDataSerializer.writeByte(this.h); - paramPacketDataSerializer.writeByte(this.i); - paramPacketDataSerializer.writeInt(this.k); - if (this.k > 0) - { - paramPacketDataSerializer.writeShort(this.e); - paramPacketDataSerializer.writeShort(this.f); - paramPacketDataSerializer.writeShort(this.g); - } - } - - public void a(PacketPlayOutListener paramPacketPlayOutListener) - { - paramPacketPlayOutListener.a(this); - } - - public String b() - { - return String.format("id=%d, type=%d, x=%.2f, y=%.2f, z=%.2f", new Object[] { Integer.valueOf(this.a), Integer.valueOf(this.j), Float.valueOf(this.b / 32.0F), Float.valueOf(this.c / 32.0F), Float.valueOf(this.d / 32.0F) }); - } - - public void a(int paramInt) - { - this.b = paramInt; - } - - public void b(int paramInt) - { - this.c = paramInt; - } - - public void c(int paramInt) - { - this.d = paramInt; - } - - public void d(int paramInt) - { - this.e = paramInt; - } - - public void e(int paramInt) - { - this.f = paramInt; - } - - public void f(int paramInt) - { - this.g = paramInt; - } - -@Override -public void handle(PacketListener arg0) -{ -} -} diff --git a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PacketPlayOutSpawnEntityLiving.java b/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PacketPlayOutSpawnEntityLiving.java deleted file mode 100644 index b234e35fb..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PacketPlayOutSpawnEntityLiving.java +++ /dev/null @@ -1,122 +0,0 @@ -package net.minecraft.server.v1_7_R4; - -import java.util.List; - -public class PacketPlayOutSpawnEntityLiving extends Packet -{ - public int a; - public int b; - public int c; - public int d; - public int e; - public int f; - public int g; - public int h; - public byte i; - public byte j; - public byte k; - public DataWatcher l; - public List m; - - public PacketPlayOutSpawnEntityLiving() - { - } - - public PacketPlayOutSpawnEntityLiving(EntityLiving paramEntityLiving) - { - this.a = paramEntityLiving.getId(); - - this.b = ((byte) EntityTypes.a(paramEntityLiving)); - this.c = paramEntityLiving.as.a(paramEntityLiving.locX); - this.d = MathHelper.floor(paramEntityLiving.locY * 32.0D); - this.e = paramEntityLiving.as.a(paramEntityLiving.locZ); - this.i = ((byte) (int) (paramEntityLiving.yaw * 256.0F / 360.0F)); - this.j = ((byte) (int) (paramEntityLiving.pitch * 256.0F / 360.0F)); - this.k = ((byte) (int) (paramEntityLiving.aP * 256.0F / 360.0F)); - - double d1 = 3.9D; - double d2 = paramEntityLiving.motX; - double d3 = paramEntityLiving.motY; - double d4 = paramEntityLiving.motZ; - if (d2 < -d1) - { - d2 = -d1; - } - if (d3 < -d1) - { - d3 = -d1; - } - if (d4 < -d1) - { - d4 = -d1; - } - if (d2 > d1) - { - d2 = d1; - } - if (d3 > d1) - { - d3 = d1; - } - if (d4 > d1) - { - d4 = d1; - } - this.f = ((int) (d2 * 8000.0D)); - this.g = ((int) (d3 * 8000.0D)); - this.h = ((int) (d4 * 8000.0D)); - - this.l = paramEntityLiving.getDataWatcher(); - } - - public void a(PacketDataSerializer paramPacketDataSerializer) - { - this.a = paramPacketDataSerializer.a(); - this.b = (paramPacketDataSerializer.readByte() & 0xFF); - this.c = paramPacketDataSerializer.readInt(); - this.d = paramPacketDataSerializer.readInt(); - this.e = paramPacketDataSerializer.readInt(); - this.i = paramPacketDataSerializer.readByte(); - this.j = paramPacketDataSerializer.readByte(); - this.k = paramPacketDataSerializer.readByte(); - this.f = paramPacketDataSerializer.readShort(); - this.g = paramPacketDataSerializer.readShort(); - this.h = paramPacketDataSerializer.readShort(); - this.m = DataWatcher.b(paramPacketDataSerializer); - } - - public void b(PacketDataSerializer paramPacketDataSerializer) - { - paramPacketDataSerializer.b(this.a); - paramPacketDataSerializer.writeByte(this.b & 0xFF); - paramPacketDataSerializer.writeInt(this.c); - paramPacketDataSerializer.writeInt(this.d); - paramPacketDataSerializer.writeInt(this.e); - paramPacketDataSerializer.writeByte(this.i); - paramPacketDataSerializer.writeByte(this.j); - paramPacketDataSerializer.writeByte(this.k); - paramPacketDataSerializer.writeShort(this.f); - paramPacketDataSerializer.writeShort(this.g); - paramPacketDataSerializer.writeShort(this.h); - this.l.a(paramPacketDataSerializer); - } - - public void a(PacketPlayOutListener paramPacketPlayOutListener) - { - paramPacketPlayOutListener.a(this); - } - - public String b() - { - return String.format( - "id=%d, type=%d, x=%.2f, y=%.2f, z=%.2f, xd=%.2f, yd=%.2f, zd=%.2f", - new Object[] { Integer.valueOf(this.a), Integer.valueOf(this.b), Float.valueOf(this.c / 32.0F), - Float.valueOf(this.d / 32.0F), Float.valueOf(this.e / 32.0F), Float.valueOf(this.f / 8000.0F), - Float.valueOf(this.g / 8000.0F), Float.valueOf(this.h / 8000.0F) }); - } - - @Override - public void handle(PacketListener arg0) - { - } -} diff --git a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PacketProcessor.java b/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PacketProcessor.java deleted file mode 100644 index 1cd96228f..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PacketProcessor.java +++ /dev/null @@ -1,44 +0,0 @@ -package net.minecraft.server.v1_7_R4; - -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.util.io.netty.util.concurrent.GenericFutureListener; - -public class PacketProcessor -{ - private List _packetVerifiers; - - public PacketProcessor() - { - _packetVerifiers = new ArrayList(); - } - - 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/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PlayerChunk.java b/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PlayerChunk.java deleted file mode 100644 index 3a12be9b5..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PlayerChunk.java +++ /dev/null @@ -1,215 +0,0 @@ -package net.minecraft.server.v1_7_R4; - -import java.util.ArrayList; -import java.util.List; - -// CraftBukkit start -import org.bukkit.craftbukkit.v1_7_R4.chunkio.ChunkIOExecutor; -import java.util.HashMap; -// CraftBukkit end - -class PlayerChunk { - - private final List b; - private final ChunkCoordIntPair location; - private short[] dirtyBlocks; - private int dirtyCount; - private int f; - private long g; - final PlayerChunkMap playerChunkMap; - // CraftBukkit start - add fields - private final HashMap players = new HashMap(); - private boolean loaded = false; - private Runnable loadedRunnable = new Runnable() { - public void run() { - PlayerChunk.this.loaded = true; - } - }; - // CraftBukkit end - - public PlayerChunk(PlayerChunkMap playerchunkmap, int i, int j) { - this.playerChunkMap = playerchunkmap; - this.b = new ArrayList(); - this.dirtyBlocks = new short[64]; - this.location = new ChunkCoordIntPair(i, j); - playerchunkmap.a().chunkProviderServer.getChunkAt(i, j, this.loadedRunnable); // CraftBukkit - } - - public void a(final EntityPlayer entityplayer) { // CraftBukkit - added final to argument - if (this.b.contains(entityplayer)) { - PlayerChunkMap.c().debug("Failed to add player. {} already is in chunk {}, {}", new Object[] { entityplayer, Integer.valueOf(this.location.x), Integer.valueOf(this.location.z)}); - } else { - if (this.b.isEmpty()) { - this.g = PlayerChunkMap.a(this.playerChunkMap).getTime(); - } - - this.b.add(entityplayer); - // CraftBukkit start - use async chunk io - Runnable playerRunnable; - if (this.loaded) { - playerRunnable = null; - entityplayer.chunkCoordIntPairQueue.add(this.location); - } else { - playerRunnable = new Runnable() { - public void run() { - entityplayer.chunkCoordIntPairQueue.add(PlayerChunk.this.location); - } - }; - this.playerChunkMap.a().chunkProviderServer.getChunkAt(this.location.x, this.location.z, playerRunnable); - } - - this.players.put(entityplayer, playerRunnable); - // CraftBukkit end - } - } - - public void b(EntityPlayer entityplayer) { - if (this.b.contains(entityplayer)) { - // CraftBukkit start - If we haven't loaded yet don't load the chunk just so we can clean it up - if (!this.loaded) { - ChunkIOExecutor.dropQueuedChunkLoad(this.playerChunkMap.a(), this.location.x, this.location.z, this.players.get(entityplayer)); - this.b.remove(entityplayer); - this.players.remove(entityplayer); - - if (this.b.isEmpty()) { - ChunkIOExecutor.dropQueuedChunkLoad(this.playerChunkMap.a(), this.location.x, this.location.z, this.loadedRunnable); - long i = (long) this.location.x + 2147483647L | (long) this.location.z + 2147483647L << 32; - PlayerChunkMap.b(this.playerChunkMap).remove(i); - PlayerChunkMap.c(this.playerChunkMap).remove(this); - } - - return; - } - // CraftBukkit end - - Chunk chunk = PlayerChunkMap.a(this.playerChunkMap).getChunkAt(this.location.x, this.location.z); - - if (chunk.isReady()) { - entityplayer.playerConnection.sendPacket(new PacketPlayOutMapChunk(chunk, true, 0)); - } - - this.players.remove(entityplayer); // CraftBukkit - this.b.remove(entityplayer); - entityplayer.chunkCoordIntPairQueue.remove(this.location); - if (this.b.isEmpty()) { - long i = (long) this.location.x + 2147483647L | (long) this.location.z + 2147483647L << 32; - - this.a(chunk); - PlayerChunkMap.b(this.playerChunkMap).remove(i); - PlayerChunkMap.c(this.playerChunkMap).remove(this); - if (this.dirtyCount > 0) { - PlayerChunkMap.d(this.playerChunkMap).remove(this); - } - - this.playerChunkMap.a().chunkProviderServer.queueUnload(this.location.x, this.location.z); - } - } - } - - public void a() { - this.a(PlayerChunkMap.a(this.playerChunkMap).getChunkAt(this.location.x, this.location.z)); - } - - private void a(Chunk chunk) { - chunk.s += PlayerChunkMap.a(this.playerChunkMap).getTime() - this.g; - this.g = PlayerChunkMap.a(this.playerChunkMap).getTime(); - } - - public void a(int i, int j, int k) { - if (this.dirtyCount == 0) { - PlayerChunkMap.d(this.playerChunkMap).add(this); - } - - this.f |= 1 << (j >> 4); - if (this.dirtyCount < 64) { - short short1 = (short) (i << 12 | k << 8 | j); - - for (int l = 0; l < this.dirtyCount; ++l) { - if (this.dirtyBlocks[l] == short1) { - return; - } - } - - this.dirtyBlocks[this.dirtyCount++] = short1; - } - } - - public void sendAll(Packet packet) { - for (int i = 0; i < this.b.size(); ++i) { - EntityPlayer entityplayer = (EntityPlayer) this.b.get(i); - - if (!entityplayer.chunkCoordIntPairQueue.contains(this.location)) { - entityplayer.playerConnection.sendPacket(packet); - } - } - } - - public void b() { - if (this.dirtyCount != 0) { - int i; - int j; - int k; - - if (this.dirtyCount == 1) { - i = this.location.x * 16 + (this.dirtyBlocks[0] >> 12 & 15); - j = this.dirtyBlocks[0] & 255; - k = this.location.z * 16 + (this.dirtyBlocks[0] >> 8 & 15); - this.sendAll(new PacketPlayOutBlockChange(i, j, k, PlayerChunkMap.a(this.playerChunkMap))); - if (PlayerChunkMap.a(this.playerChunkMap).getType(i, j, k).isTileEntity()) { - this.sendTileEntity(PlayerChunkMap.a(this.playerChunkMap).getTileEntity(i, j, k)); - } - } else { - int l; - - if (this.dirtyCount == 64) { - i = this.location.x * 16; - j = this.location.z * 16; - this.sendAll(new PacketPlayOutMapChunk(PlayerChunkMap.a(this.playerChunkMap).getChunkAt(this.location.x, this.location.z), (this.f == 0xFFFF), this.f)); // CraftBukkit - send everything (including biome) if all sections flagged - - for (k = 0; k < 16; ++k) { - if ((this.f & 1 << k) != 0) { - l = k << 4; - List list = PlayerChunkMap.a(this.playerChunkMap).getTileEntities(i, l, j, i + 16, l + 16, j + 16); - - for (int i1 = 0; i1 < list.size(); ++i1) { - this.sendTileEntity((TileEntity) list.get(i1)); - } - } - } - } else { - this.sendAll(new PacketPlayOutMultiBlockChange(this.dirtyCount, this.dirtyBlocks, PlayerChunkMap.a(this.playerChunkMap).getChunkAt(this.location.x, this.location.z))); - - for (i = 0; i < this.dirtyCount; ++i) { - j = this.location.x * 16 + (this.dirtyBlocks[i] >> 12 & 15); - k = this.dirtyBlocks[i] & 255; - l = this.location.z * 16 + (this.dirtyBlocks[i] >> 8 & 15); - if (PlayerChunkMap.a(this.playerChunkMap).getType(j, k, l).isTileEntity()) { - this.sendTileEntity(PlayerChunkMap.a(this.playerChunkMap).getTileEntity(j, k, l)); - } - } - } - } - - this.dirtyCount = 0; - this.f = 0; - } - } - - private void sendTileEntity(TileEntity tileentity) { - if (tileentity != null) { - Packet packet = tileentity.getUpdatePacket(); - - if (packet != null) { - this.sendAll(packet); - } - } - } - - static ChunkCoordIntPair a(PlayerChunk playerchunk) { - return playerchunk.location; - } - - static List b(PlayerChunk playerchunk) { - return playerchunk.b; - } -} \ No newline at end of file diff --git a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PlayerConnection.java b/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PlayerConnection.java deleted file mode 100644 index b263da632..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/PlayerConnection.java +++ /dev/null @@ -1,2672 +0,0 @@ -package net.minecraft.server.v1_7_R4; - -import java.io.ByteArrayInputStream; -import java.io.DataInputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Date; -import java.util.Iterator; -import java.util.Random; -import java.util.concurrent.Callable; - -import net.minecraft.util.com.google.common.base.Charsets; -import net.minecraft.util.com.google.common.collect.Lists; -import net.minecraft.util.io.netty.buffer.Unpooled; -import net.minecraft.util.io.netty.util.concurrent.GenericFutureListener; -import net.minecraft.util.org.apache.commons.lang3.StringUtils; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -// CraftBukkit start -import java.io.UnsupportedEncodingException; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; -import java.util.HashSet; - -import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; -import org.bukkit.craftbukkit.v1_7_R4.event.CraftEventFactory; -import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftInventoryView; -import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack; -import org.bukkit.craftbukkit.v1_7_R4.util.CraftChatMessage; -import org.bukkit.craftbukkit.v1_7_R4.util.LazyPlayerSet; -import org.bukkit.craftbukkit.v1_7_R4.util.Waitable; - -import org.bukkit.Location; -import org.bukkit.entity.Player; -import org.bukkit.event.Event; -import org.bukkit.event.block.Action; -import org.bukkit.event.block.SignChangeEvent; -import org.bukkit.event.inventory.ClickType; -import org.bukkit.event.inventory.CraftItemEvent; -import org.bukkit.event.inventory.InventoryAction; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.event.inventory.InventoryCreativeEvent; -import org.bukkit.event.inventory.InventoryType.SlotType; -import org.bukkit.event.player.AsyncPlayerChatEvent; -import org.bukkit.event.player.PlayerAnimationEvent; -import org.bukkit.event.player.PlayerChatEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerInteractEntityEvent; -import org.bukkit.event.player.PlayerItemHeldEvent; -import org.bukkit.event.player.PlayerKickEvent; -import org.bukkit.event.player.PlayerMoveEvent; -import org.bukkit.event.player.PlayerTeleportEvent; -import org.bukkit.event.player.PlayerToggleFlightEvent; -import org.bukkit.event.player.PlayerToggleSneakEvent; -import org.bukkit.event.player.PlayerToggleSprintEvent; -import org.bukkit.inventory.CraftingInventory; -import org.bukkit.inventory.InventoryView; -import org.bukkit.util.NumberConversions; - -// CraftBukkit end - -public class PlayerConnection implements PacketPlayInListener -{ - - private static final Logger c = LogManager.getLogger(); - public final NetworkManager networkManager; - private final MinecraftServer minecraftServer; - public EntityPlayer player; - private int e; - private int f; - private boolean g; - private int h; - private long i; - private static Random j = new Random(); - private long k; - private volatile int chatThrottle; - private static final AtomicIntegerFieldUpdater chatSpamField = AtomicIntegerFieldUpdater.newUpdater( - PlayerConnection.class, "chatThrottle"); // CraftBukkit - - // multithreaded field - private int x; - private IntHashMap n = new IntHashMap(); - private double y; - private double z; - private double q; - 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; - networkmanager.a((PacketListener) this); - this.player = entityplayer; - entityplayer.playerConnection = this; - - PacketVerifier = new PacketProcessor(); - - // CraftBukkit start - add fields and methods - this.server = minecraftserver.server; - } - - private final org.bukkit.craftbukkit.v1_7_R4.CraftServer server; - private int lastTick = MinecraftServer.currentTick; - private int lastDropTick = MinecraftServer.currentTick; - private int dropCount = 0; - private static final int SURVIVAL_PLACE_DISTANCE_SQUARED = 6 * 6; - private static final int CREATIVE_PLACE_DISTANCE_SQUARED = 7 * 7; - - // Get position of last block hit for BlockDamageLevel.STOPPED - private double lastPosX = Double.MAX_VALUE; - private double lastPosY = Double.MAX_VALUE; - private double lastPosZ = Double.MAX_VALUE; - private float lastPitch = Float.MAX_VALUE; - private float lastYaw = Float.MAX_VALUE; - private boolean justTeleported = false; - private boolean hasMoved; // Spigot - - // For the PacketPlayOutBlockPlace hack :( - Long lastPacket; - - // Store the last block right clicked and what type it was - private Item lastMaterial; - - public CraftPlayer getPlayer() - { - return (this.player == null) ? null : (CraftPlayer) this.player.getBukkitEntity(); - } - - private final static HashSet invalidItems = new HashSet(java.util.Arrays.asList(8, 9, 10, 11, 26, - 34, 36, 43, 51, 52, 55, 59, 60, 62, 63, 64, 68, 71, 74, 75, 83, 90, 92, 93, 94, 104, 105, 115, 117, 118, - 119, 125, 127, 132, 137, 140, 141, 142, 144)); // TODO: Check after - // every update. - - // CraftBukkit end - - public void a() - { - this.g = false; - ++this.e; - this.minecraftServer.methodProfiler.a("keepAlive"); - if ((long) this.e - this.k > 40L) - { - this.k = (long) this.e; - this.i = this.d(); - this.h = (int) this.i; - this.sendPacket(new PacketPlayOutKeepAlive(this.h)); - } - - // CraftBukkit start - for (int spam; (spam = this.chatThrottle) > 0 && !chatSpamField.compareAndSet(this, spam, spam - 1);) - ; - /* - * Use thread-safe field access instead if (this.chatThrottle > 0) { - * --this.chatThrottle; } - */ - // CraftBukkit end - - if (this.x > 0) - { - --this.x; - } - - if (this.player.x() > 0L && this.minecraftServer.getIdleTimeout() > 0 - && MinecraftServer.ar() - this.player.x() > (long) (this.minecraftServer.getIdleTimeout() * 1000 * 60)) - { - this.disconnect("You have been idle for too long!"); - } - } - - public NetworkManager b() - { - return this.networkManager; - } - - public void disconnect(String s) - { - // CraftBukkit start - fire PlayerKickEvent - String leaveMessage = EnumChatFormat.YELLOW + this.player.getName() + " left the game."; - - PlayerKickEvent event = new PlayerKickEvent(this.server.getPlayer(this.player), s, leaveMessage); - - if (this.server.getServer().isRunning()) - { - this.server.getPluginManager().callEvent(event); - } - - if (event.isCancelled()) - { - // Do not kick the player - return; - } - // Send the possibly modified leave message - s = event.getReason(); - // CraftBukkit end - ChatComponentText chatcomponenttext = new ChatComponentText(s); - - this.networkManager.handle(new PacketPlayOutKickDisconnect(chatcomponenttext), - new GenericFutureListener[] { new PlayerConnectionFuture(this, chatcomponenttext) }); - this.a(chatcomponenttext); // CraftBukkit - Process quit immediately - this.networkManager.g(); - } - - public void a(PacketPlayInSteerVehicle packetplayinsteervehicle) - { - this.player.a(packetplayinsteervehicle.c(), packetplayinsteervehicle.d(), packetplayinsteervehicle.e(), - packetplayinsteervehicle.f()); - } - - public void a(PacketPlayInFlying packetplayinflying) - { - // CraftBukkit start - Check for NaN - if (Double.isNaN(packetplayinflying.x) || Double.isNaN(packetplayinflying.y) - || Double.isNaN(packetplayinflying.z) || Double.isNaN(packetplayinflying.stance)) - { - c.warn(player.getName() + " was caught trying to crash the server with an invalid position."); - getPlayer().kickPlayer("NaN in position (Hacking?)"); // Spigot - // "Nope" -> - // Descriptive - // reason - return; - } - // CraftBukkit end - WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); - - this.g = true; - if (!this.player.viewingCredits) - { - double d0; - - if (!this.checkMovement) - { - d0 = packetplayinflying.d() - this.z; - if (packetplayinflying.c() == this.y && d0 * d0 < 0.01D && packetplayinflying.e() == this.q) - { - this.checkMovement = true; - } - } - - // CraftBukkit start - fire PlayerMoveEvent - Player player = this.getPlayer(); - // Spigot Start - if (!hasMoved) - { - Location curPos = player.getLocation(); - lastPosX = curPos.getX(); - lastPosY = curPos.getY(); - lastPosZ = curPos.getZ(); - lastYaw = curPos.getYaw(); - lastPitch = curPos.getPitch(); - hasMoved = true; - } - // Spigot End - Location from = new Location(player.getWorld(), lastPosX, lastPosY, lastPosZ, lastYaw, lastPitch); // Get - // the - // Players - // previous - // Event - // location. - Location to = player.getLocation().clone(); // Start off the To - // location as the - // Players current - // location. - - // If the packet contains movement information then we update the To - // location with the correct XYZ. - if (packetplayinflying.hasPos - && !(packetplayinflying.hasPos && packetplayinflying.y == -999.0D && packetplayinflying.stance == -999.0D)) - { - to.setX(packetplayinflying.x); - to.setY(packetplayinflying.y); - to.setZ(packetplayinflying.z); - } - - // If the packet contains look information then we update the To - // location with the correct Yaw & Pitch. - if (packetplayinflying.hasLook) - { - to.setYaw(packetplayinflying.yaw); - to.setPitch(packetplayinflying.pitch); - } - - // Prevent 40 event-calls for less than a single pixel of movement - // >.> - double delta = Math.pow(this.lastPosX - to.getX(), 2) + Math.pow(this.lastPosY - to.getY(), 2) - + Math.pow(this.lastPosZ - to.getZ(), 2); - float deltaAngle = Math.abs(this.lastYaw - to.getYaw()) + Math.abs(this.lastPitch - to.getPitch()); - - if ((delta > 1f / 256 || deltaAngle > 10f) && (this.checkMovement && !this.player.dead)) - { - this.lastPosX = to.getX(); - this.lastPosY = to.getY(); - this.lastPosZ = to.getZ(); - this.lastYaw = to.getYaw(); - this.lastPitch = to.getPitch(); - - // Skip the first time we do this - if (true) - { // Spigot - don't skip any move events - PlayerMoveEvent event = new PlayerMoveEvent(player, from, to); - this.server.getPluginManager().callEvent(event); - - // If the event is cancelled we move the player back to - // their old location. - if (event.isCancelled()) - { - this.player.playerConnection.sendPacket(new PacketPlayOutPosition(from.getX(), - from.getY() + 1.6200000047683716D, from.getZ(), from.getYaw(), from.getPitch(), false)); - return; - } - - /* - * If a Plugin has changed the To destination then we - * teleport the Player there to avoid any 'Moved wrongly' or - * 'Moved too quickly' errors. We only do this if the Event - * was not cancelled. - */ - if (!to.equals(event.getTo()) && !event.isCancelled()) - { - this.player.getBukkitEntity() - .teleport(event.getTo(), PlayerTeleportEvent.TeleportCause.UNKNOWN); - return; - } - - /* - * Check to see if the Players Location has some how changed - * during the call of the event. This can happen due to a - * plugin teleporting the player instead of using .setTo() - */ - if (!from.equals(this.getPlayer().getLocation()) && this.justTeleported) - { - this.justTeleported = false; - return; - } - } - } - - if (this.checkMovement && !this.player.dead) - { - // CraftBukkit end - double d1; - double d2; - double d3; - - if (this.player.vehicle != null) - { - float f = this.player.yaw; - float f1 = this.player.pitch; - - this.player.vehicle.ac(); - d1 = this.player.locX; - d2 = this.player.locY; - d3 = this.player.locZ; - if (packetplayinflying.k()) - { - f = packetplayinflying.g(); - f1 = packetplayinflying.h(); - } - - this.player.onGround = packetplayinflying.i(); - this.player.i(); - this.player.V = 0.0F; - this.player.setLocation(d1, d2, d3, f, f1); - if (this.player.vehicle != null) - { - this.player.vehicle.ac(); - } - - this.minecraftServer.getPlayerList().d(this.player); - if (this.checkMovement) - { - this.y = this.player.locX; - this.z = this.player.locY; - this.q = this.player.locZ; - } - - worldserver.playerJoinedWorld(this.player); - return; - } - - if (this.player.isSleeping()) - { - this.player.i(); - this.player.setLocation(this.y, this.z, this.q, this.player.yaw, this.player.pitch); - worldserver.playerJoinedWorld(this.player); - return; - } - - d0 = this.player.locY; - this.y = this.player.locX; - this.z = this.player.locY; - this.q = this.player.locZ; - d1 = this.player.locX; - d2 = this.player.locY; - d3 = this.player.locZ; - float f2 = this.player.yaw; - float f3 = this.player.pitch; - - if (packetplayinflying.j() && packetplayinflying.d() == -999.0D && packetplayinflying.f() == -999.0D) - { - packetplayinflying.a(false); - } - - double d4; - - if (packetplayinflying.j()) - { - d1 = packetplayinflying.c(); - d2 = packetplayinflying.d(); - d3 = packetplayinflying.e(); - d4 = packetplayinflying.f() - packetplayinflying.d(); - if (!this.player.isSleeping() && (d4 > 1.65D || d4 < 0.1D)) - { - this.disconnect("Illegal stance"); - c.warn(this.player.getName() + " had an illegal stance: " + d4); - return; - } - - if (Math.abs(packetplayinflying.c()) > 3.2E7D || Math.abs(packetplayinflying.e()) > 3.2E7D) - { - this.disconnect("Illegal position"); - return; - } - } - - if (packetplayinflying.k()) - { - f2 = packetplayinflying.g(); - f3 = packetplayinflying.h(); - } - - this.player.i(); - this.player.V = 0.0F; - this.player.setLocation(this.y, this.z, this.q, f2, f3); - if (!this.checkMovement) - { - return; - } - - d4 = d1 - this.player.locX; - double d5 = d2 - this.player.locY; - double d6 = d3 - this.player.locZ; - // CraftBukkit start - min to max - double d7 = Math.max(Math.abs(d4), Math.abs(this.player.motX)); - double d8 = Math.max(Math.abs(d5), Math.abs(this.player.motY)); - double d9 = Math.max(Math.abs(d6), Math.abs(this.player.motZ)); - // CraftBukkit end - double d10 = d7 * d7 + d8 * d8 + d9 * d9; - - // Spigot: make "moved too quickly" limit configurable - if (d10 > org.spigotmc.SpigotConfig.movedTooQuicklyThreshold && this.checkMovement - && (!this.minecraftServer.N() || !this.minecraftServer.M().equals(this.player.getName()))) - { // CraftBukkit - Added this.checkMovement condition to solve - // this check being triggered by teleports - c.warn(this.player.getName() + " moved too quickly! " + d4 + "," + d5 + "," + d6 + " (" + d7 + ", " - + d8 + ", " + d9 + ")"); - this.a(this.y, this.z, this.q, this.player.yaw, this.player.pitch); - return; - } - - float f4 = 0.0625F; - boolean flag = worldserver.getCubes(this.player, - this.player.boundingBox.clone().shrink((double) f4, (double) f4, (double) f4)).isEmpty(); - - if (this.player.onGround && !packetplayinflying.i() && d5 > 0.0D) - { - this.player.bj(); - } - - this.player.move(d4, d5, d6); - this.player.onGround = packetplayinflying.i(); - this.player.checkMovement(d4, d5, d6); - double d11 = d5; - - d4 = d1 - this.player.locX; - d5 = d2 - this.player.locY; - if (d5 > -0.5D || d5 < 0.5D) - { - d5 = 0.0D; - } - - d6 = d3 - this.player.locZ; - d10 = d4 * d4 + d5 * d5 + d6 * d6; - boolean flag1 = false; - - // Spigot: make "moved wrongly" limit configurable - if (d10 > org.spigotmc.SpigotConfig.movedWronglyThreshold && !this.player.isSleeping() - && !this.player.playerInteractManager.isCreative()) - { - flag1 = true; - c.warn(this.player.getName() + " moved wrongly!"); - } - - this.player.setLocation(d1, d2, d3, f2, f3); - boolean flag2 = worldserver.getCubes(this.player, - this.player.boundingBox.clone().shrink((double) f4, (double) f4, (double) f4)).isEmpty(); - - if (flag && (flag1 || !flag2) && !this.player.isSleeping()) - { - this.a(this.y, this.z, this.q, f2, f3); - return; - } - - AxisAlignedBB axisalignedbb = this.player.boundingBox.clone() - .grow((double) f4, (double) f4, (double) f4).a(0.0D, -0.55D, 0.0D); - - if (!this.minecraftServer.getAllowFlight() && !this.player.abilities.canFly - && !worldserver.c(axisalignedbb)) - { // CraftBukkit - check abilities instead of creative mode - if (d11 >= -0.03125D) - { - ++this.f; - if (this.f > 80) - { - c.warn(this.player.getName() + " was kicked for floating too long!"); - this.disconnect("Flying is not enabled on this server"); - return; - } - } - } - else - { - this.f = 0; - } - - this.player.onGround = packetplayinflying.i(); - this.minecraftServer.getPlayerList().d(this.player); - this.player.b(this.player.locY - d0, packetplayinflying.i()); - } - else if (this.e % 20 == 0) - { - this.a(this.y, this.z, this.q, this.player.yaw, this.player.pitch); - } - } - } - - public void a(double d0, double d1, double d2, float f, float f1) - { - // CraftBukkit start - Delegate to teleport(Location) - Player player = this.getPlayer(); - Location from = player.getLocation(); - Location to = new Location(this.getPlayer().getWorld(), d0, d1, d2, f, f1); - PlayerTeleportEvent event = new PlayerTeleportEvent(player, from, to, PlayerTeleportEvent.TeleportCause.UNKNOWN); - this.server.getPluginManager().callEvent(event); - - from = event.getFrom(); - to = event.isCancelled() ? from : event.getTo(); - - this.teleport(to); - } - - public void teleport(Location dest) - { - double d0, d1, d2; - float f, f1; - - d0 = dest.getX(); - d1 = dest.getY(); - d2 = dest.getZ(); - f = dest.getYaw(); - f1 = dest.getPitch(); - - // TODO: make sure this is the best way to address this. - if (Float.isNaN(f)) - { - f = 0; - } - - if (Float.isNaN(f1)) - { - f1 = 0; - } - - this.lastPosX = d0; - this.lastPosY = d1; - this.lastPosZ = d2; - this.lastYaw = f; - this.lastPitch = f1; - this.justTeleported = true; - // CraftBukkit end - - this.checkMovement = false; - this.y = d0; - this.z = d1; - this.q = d2; - this.player.setLocation(d0, d1, d2, f, f1); - this.player.playerConnection.sendPacket(new PacketPlayOutPosition(d0, d1 + 1.6200000047683716D, d2, f, f1, - false)); - } - - public void a(PacketPlayInBlockDig packetplayinblockdig) - { - if (this.player.dead) - return; // CraftBukkit - // Spigot start - if (player.activeContainer != player.defaultContainer) - { - getPlayer().closeInventory(); - } - // Spigot end - WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); - - this.player.v(); - if (packetplayinblockdig.g() == 4) - { - // CraftBukkit start - limit how quickly items can be dropped - // If the ticks aren't the same then the count starts from 0 and we - // update the lastDropTick. - if (this.lastDropTick != MinecraftServer.currentTick) - { - this.dropCount = 0; - this.lastDropTick = MinecraftServer.currentTick; - } - else - { - // Else we increment the drop count and check the amount. - this.dropCount++; - if (this.dropCount >= 20) - { - this.c.warn(this.player.getName() + " dropped their items too quickly!"); - this.disconnect("You dropped your items too quickly (Hacking?)"); - return; - } - } - // CraftBukkit end - this.player.a(false); - } - else if (packetplayinblockdig.g() == 3) - { - this.player.a(true); - } - else if (packetplayinblockdig.g() == 5) - { - this.player.bA(); - } - else - { - boolean flag = false; - - if (packetplayinblockdig.g() == 0) - { - flag = true; - } - - if (packetplayinblockdig.g() == 1) - { - flag = true; - } - - if (packetplayinblockdig.g() == 2) - { - flag = true; - } - - int i = packetplayinblockdig.c(); - int j = packetplayinblockdig.d(); - int k = packetplayinblockdig.e(); - - if (flag) - { - double d0 = this.player.locX - ((double) i + 0.5D); - double d1 = this.player.locY - ((double) j + 0.5D) + 1.5D; - double d2 = this.player.locZ - ((double) k + 0.5D); - double d3 = d0 * d0 + d1 * d1 + d2 * d2; - - if (d3 > 36.0D) - { - return; - } - - if (j >= this.minecraftServer.getMaxBuildHeight()) - { - return; - } - } - - if (packetplayinblockdig.g() == 0) - { - if (!this.minecraftServer.a(worldserver, i, j, k, this.player)) - { - this.player.playerInteractManager.dig(i, j, k, packetplayinblockdig.f()); - } - else - { - // CraftBukkit start - fire PlayerInteractEvent - CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, i, j, k, - packetplayinblockdig.f(), this.player.inventory.getItemInHand()); - this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(i, j, k, worldserver)); - // Update any tile entity data for this block - TileEntity tileentity = worldserver.getTileEntity(i, j, k); - if (tileentity != null) - { - this.player.playerConnection.sendPacket(tileentity.getUpdatePacket()); - } - // CraftBukkit end - } - } - else if (packetplayinblockdig.g() == 2) - { - this.player.playerInteractManager.a(i, j, k); - if (worldserver.getType(i, j, k).getMaterial() != Material.AIR) - { - this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(i, j, k, worldserver)); - } - } - else if (packetplayinblockdig.g() == 1) - { - this.player.playerInteractManager.c(i, j, k); - if (worldserver.getType(i, j, k).getMaterial() != Material.AIR) - { - this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(i, j, k, worldserver)); - } - } - } - } - - // Spigot start - limit place/interactions - private long lastPlace = -1; - private int packets = 0; - - public void a(PacketPlayInBlockPlace packetplayinblockplace) - { - boolean throttled = false; - if (lastPlace != -1 && packetplayinblockplace.timestamp - lastPlace < 30 && packets++ >= 4) - { - throttled = true; - } - else if (packetplayinblockplace.timestamp - lastPlace >= 30 || lastPlace == -1) - { - lastPlace = packetplayinblockplace.timestamp; - packets = 0; - } - // Spigot end - WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); - - // CraftBukkit start - if (this.player.dead) - return; - - // This is a horrible hack needed because the client sends 2 packets on - // 'right mouse click' - // aimed at a block. We shouldn't need to get the second packet if the - // data is handled - // but we cannot know what the client will do, so we might still get it - // - // If the time between packets is small enough, and the 'signature' - // similar, we discard the - // second one. This sadly has to remain until Mojang makes their packets - // saner. :( - // -- Grum - if (packetplayinblockplace.getFace() == 255) - { - if (packetplayinblockplace.getItemStack() != null - && packetplayinblockplace.getItemStack().getItem() == this.lastMaterial && this.lastPacket != null - && packetplayinblockplace.timestamp - this.lastPacket < 100) - { - this.lastPacket = null; - return; - } - } - else - { - this.lastMaterial = packetplayinblockplace.getItemStack() == null ? null : packetplayinblockplace - .getItemStack().getItem(); - this.lastPacket = packetplayinblockplace.timestamp; - } - // CraftBukkit - if rightclick decremented the item, always send the - // update packet. */ - // this is not here for CraftBukkit's own functionality; rather it is to - // fix - // a notch bug where the item doesn't update correctly. - boolean always = false; - // CraftBukkit end - // Spigot start - if (player.activeContainer != player.defaultContainer) - { - getPlayer().closeInventory(); - } - // Spigot end - - ItemStack itemstack = this.player.inventory.getItemInHand(); - boolean flag = false; - int i = packetplayinblockplace.c(); - int j = packetplayinblockplace.d(); - int k = packetplayinblockplace.e(); - int l = packetplayinblockplace.getFace(); - - this.player.v(); - if (packetplayinblockplace.getFace() == 255) - { - if (itemstack == null) - { - return; - } - - // CraftBukkit start - int itemstackAmount = itemstack.count; - // Spigot start - skip the event if throttled - if (!throttled) - { - org.bukkit.event.player.PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent( - this.player, Action.RIGHT_CLICK_AIR, itemstack); - if (event.useItemInHand() != Event.Result.DENY) - { - this.player.playerInteractManager.useItem(this.player, this.player.world, itemstack); - } - } - // Spigot end - - // CraftBukkit - notch decrements the counter by 1 in the above - // method with food, - // snowballs and so forth, but he does it in a place that doesn't - // cause the - // inventory update packet to get sent - always = (itemstack.count != itemstackAmount) || itemstack.getItem() == Item.getItemOf(Blocks.WATER_LILY); - // CraftBukkit end - } - else if (packetplayinblockplace.d() >= this.minecraftServer.getMaxBuildHeight() - 1 - && (packetplayinblockplace.getFace() == 1 || packetplayinblockplace.d() >= this.minecraftServer - .getMaxBuildHeight())) - { - ChatMessage chatmessage = new ChatMessage("build.tooHigh", - new Object[] { Integer.valueOf(this.minecraftServer.getMaxBuildHeight()) }); - - chatmessage.getChatModifier().setColor(EnumChatFormat.RED); - this.player.playerConnection.sendPacket(new PacketPlayOutChat(chatmessage)); - flag = true; - } - else - { - // CraftBukkit start - Check if we can actually do something over - // this large a distance - Location eyeLoc = this.getPlayer().getEyeLocation(); - double reachDistance = NumberConversions.square(eyeLoc.getX() - i) - + NumberConversions.square(eyeLoc.getY() - j) + NumberConversions.square(eyeLoc.getZ() - k); - if (reachDistance > (this.getPlayer().getGameMode() == org.bukkit.GameMode.CREATIVE ? CREATIVE_PLACE_DISTANCE_SQUARED - : SURVIVAL_PLACE_DISTANCE_SQUARED)) - { - return; - } - - if (throttled - || !this.player.playerInteractManager.interact(this.player, worldserver, itemstack, i, j, k, l, - packetplayinblockplace.h(), packetplayinblockplace.i(), packetplayinblockplace.j())) - { // Spigot - skip the event if throttled - always = true; // force PacketPlayOutSetSlot to be sent to - // client to update ItemStack count - } - // CraftBukkit end - - flag = true; - } - - if (flag) - { - this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(i, j, k, worldserver)); - if (l == 0) - { - --j; - } - - if (l == 1) - { - ++j; - } - - if (l == 2) - { - --k; - } - - if (l == 3) - { - ++k; - } - - if (l == 4) - { - --i; - } - - if (l == 5) - { - ++i; - } - - this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(i, j, k, worldserver)); - } - - itemstack = this.player.inventory.getItemInHand(); - if (itemstack != null && itemstack.count == 0) - { - this.player.inventory.items[this.player.inventory.itemInHandIndex] = null; - itemstack = null; - } - - if (itemstack == null || itemstack.n() == 0) - { - this.player.g = true; - this.player.inventory.items[this.player.inventory.itemInHandIndex] = ItemStack - .b(this.player.inventory.items[this.player.inventory.itemInHandIndex]); - Slot slot = this.player.activeContainer.getSlot((IInventory) this.player.inventory, - this.player.inventory.itemInHandIndex); - - this.player.activeContainer.b(); - this.player.g = false; - // CraftBukkit - TODO CHECK IF NEEDED -- new if structure might not - // need 'always'. Kept it in for now, but may be able to remove in - // future - if (!ItemStack.matches(this.player.inventory.getItemInHand(), packetplayinblockplace.getItemStack()) - || always) - { - this.sendPacket(new PacketPlayOutSetSlot(this.player.activeContainer.windowId, slot.rawSlotIndex, - this.player.inventory.getItemInHand())); - } - } - } - - public void a(IChatBaseComponent ichatbasecomponent) - { - // CraftBukkit start - Rarely it would send a disconnect line twice - if (this.processedDisconnect) - { - return; - } - else - { - this.processedDisconnect = true; - } - // CraftBukkit end - c.info(this.player.getName() + " lost connection: " + ichatbasecomponent.c()); // CraftBukkit - // - - // Don't - // toString - // the - // component - this.minecraftServer.az(); - // CraftBukkit start - Replace vanilla quit message handling with our - // own. - /* - * ChatMessage chatmessage = new ChatMessage("multiplayer.player.left", - * new Object[] { this.player.getScoreboardDisplayName()}); - * - * chatmessage.getChatModifier().setColor(EnumChatFormat.YELLOW); - * this.minecraftServer.getPlayerList().sendMessage(chatmessage); - */ - - this.player.n(); - String quitMessage = this.minecraftServer.getPlayerList().disconnect(this.player); - if ((quitMessage != null) && (quitMessage.length() > 0)) - { - this.minecraftServer.getPlayerList().sendMessage(CraftChatMessage.fromString(quitMessage)); - } - // CraftBukkit end - if (this.minecraftServer.N() && this.player.getName().equals(this.minecraftServer.M())) - { - c.info("Stopping singleplayer server as player logged out"); - this.minecraftServer.safeShutdown(); - } - } - - public void sendPacket(Packet packet) - { - if (packet instanceof PacketPlayOutChat) - { - PacketPlayOutChat packetplayoutchat = (PacketPlayOutChat) packet; - EnumChatVisibility enumchatvisibility = this.player.getChatFlags(); - - if (enumchatvisibility == EnumChatVisibility.HIDDEN) - { - return; - } - - if (enumchatvisibility == EnumChatVisibility.SYSTEM && !packetplayoutchat.d()) - { - return; - } - } - - // CraftBukkit start - if (packet == null) - { - return; - } - else if (packet instanceof PacketPlayOutSpawnPosition) - { - PacketPlayOutSpawnPosition packet6 = (PacketPlayOutSpawnPosition) packet; - this.player.compassTarget = new Location(this.getPlayer().getWorld(), packet6.x, packet6.y, packet6.z); - } - // CraftBukkit end - - try - { - PacketVerifier.processPacket(packet, this.networkManager); - } - catch (Throwable throwable) - { - CrashReport crashreport = CrashReport.a(throwable, "Sending packet"); - CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Packet being sent"); - - crashreportsystemdetails.a("Packet class", (Callable) (new CrashReportConnectionPacketClass(this, packet))); - throw new ReportedException(crashreport); - } - } - - public void a(PacketPlayInHeldItemSlot packetplayinhelditemslot) - { - // CraftBukkit start - if (this.player.dead) - return; - - if (packetplayinhelditemslot.c() >= 0 && packetplayinhelditemslot.c() < PlayerInventory.getHotbarSize()) - { - PlayerItemHeldEvent event = new PlayerItemHeldEvent(this.getPlayer(), - this.player.inventory.itemInHandIndex, packetplayinhelditemslot.c()); - this.server.getPluginManager().callEvent(event); - if (event.isCancelled()) - { - this.sendPacket(new PacketPlayOutHeldItemSlot(this.player.inventory.itemInHandIndex)); - this.player.v(); - return; - } - // CraftBukkit end - - this.player.inventory.itemInHandIndex = packetplayinhelditemslot.c(); - this.player.v(); - } - else - { - c.warn(this.player.getName() + " tried to set an invalid carried item"); - this.disconnect("Invalid hotbar selection (Hacking?)"); // CraftBukkit - // //Spigot - // "Nope" -> - // Descriptive - // reason - } - } - - public void a(PacketPlayInChat packetplayinchat) - { - if (this.player.dead || this.player.getChatFlags() == EnumChatVisibility.HIDDEN) - { // CraftBukkit - dead men tell no tales - ChatMessage chatmessage = new ChatMessage("chat.cannotSend", new Object[0]); - - chatmessage.getChatModifier().setColor(EnumChatFormat.RED); - this.sendPacket(new PacketPlayOutChat(chatmessage)); - } - else - { - this.player.v(); - String s = packetplayinchat.c(); - - s = StringUtils.normalizeSpace(s); - - for (int i = 0; i < s.length(); ++i) - { - if (!SharedConstants.isAllowedChatCharacter(s.charAt(i))) - { - // CraftBukkit start - threadsafety - if (packetplayinchat.a()) - { - Waitable waitable = new Waitable() - { - @Override - protected Object evaluate() - { - PlayerConnection.this.disconnect("Illegal characters in chat"); - return null; - } - }; - - this.minecraftServer.processQueue.add(waitable); - - try - { - waitable.get(); - } - catch (InterruptedException e) - { - Thread.currentThread().interrupt(); - } - catch (ExecutionException e) - { - throw new RuntimeException(e); - } - } - else - { - this.disconnect("Illegal characters in chat"); - } - // CraftBukkit end - return; - } - } - - // CraftBukkit start - if (!packetplayinchat.a()) - { - try - { - this.minecraftServer.server.playerCommandState = true; - this.handleCommand(s); - } - finally - { - this.minecraftServer.server.playerCommandState = false; - } - } - else if (s.isEmpty()) - { - c.warn(this.player.getName() + " tried to send an empty message"); - } - else if (getPlayer().isConversing()) - { - // Spigot start - final String message = s; - this.minecraftServer.processQueue.add(new Waitable() - { - @Override - protected Object evaluate() - { - getPlayer().acceptConversationInput(message); - return null; - } - }); - // Spigot end - } - else if (this.player.getChatFlags() == EnumChatVisibility.SYSTEM) - { // Re-add "Command Only" flag check - ChatMessage chatmessage = new ChatMessage("chat.cannotSend", new Object[0]); - - chatmessage.getChatModifier().setColor(EnumChatFormat.RED); - this.sendPacket(new PacketPlayOutChat(chatmessage)); - } - else if (true) - { - this.chat(s, true); - // CraftBukkit end - the below is for reference. :) - } - else - { - ChatMessage chatmessage1 = new ChatMessage("chat.type.text", new Object[] { - this.player.getScoreboardDisplayName(), s }); - - this.minecraftServer.getPlayerList().sendMessage(chatmessage1, false); - } - - // Spigot - spam exclusions - boolean counted = true; - for (String exclude : org.spigotmc.SpigotConfig.spamExclusions) - { - if (exclude != null && s.startsWith(exclude)) - { - counted = false; - break; - } - } - // CraftBukkit start - replaced with thread safe throttle - // this.chatThrottle += 20; - if (counted && chatSpamField.addAndGet(this, 20) > 200 - && !this.minecraftServer.getPlayerList().isOp(this.player.getProfile())) - { - if (packetplayinchat.a()) - { - Waitable waitable = new Waitable() - { - @Override - protected Object evaluate() - { - PlayerConnection.this.disconnect("disconnect.spam"); - return null; - } - }; - - this.minecraftServer.processQueue.add(waitable); - - try - { - waitable.get(); - } - catch (InterruptedException e) - { - Thread.currentThread().interrupt(); - } - catch (ExecutionException e) - { - throw new RuntimeException(e); - } - } - else - { - this.disconnect("disconnect.spam"); - } - // CraftBukkit end - } - } - } - - // CraftBukkit start - add method - public void chat(String s, boolean async) - { - if (s.isEmpty() || this.player.getChatFlags() == EnumChatVisibility.HIDDEN) - { - return; - } - - if (!async && s.startsWith("/")) - { - this.handleCommand(s); - } - else if (this.player.getChatFlags() == EnumChatVisibility.SYSTEM) - { - // Do nothing, this is coming from a plugin - } - else - { - Player player = this.getPlayer(); - AsyncPlayerChatEvent event = new AsyncPlayerChatEvent(async, player, s, new LazyPlayerSet()); - this.server.getPluginManager().callEvent(event); - - if (PlayerChatEvent.getHandlerList().getRegisteredListeners().length != 0) - { - // Evil plugins still listening to deprecated event - final PlayerChatEvent queueEvent = new PlayerChatEvent(player, event.getMessage(), event.getFormat(), - event.getRecipients()); - queueEvent.setCancelled(event.isCancelled()); - Waitable waitable = new Waitable() - { - @Override - protected Object evaluate() - { - org.bukkit.Bukkit.getPluginManager().callEvent(queueEvent); - - if (queueEvent.isCancelled()) - { - return null; - } - - String message = String.format(queueEvent.getFormat(), queueEvent.getPlayer().getDisplayName(), - queueEvent.getMessage()); - PlayerConnection.this.minecraftServer.console.sendMessage(message); - if (((LazyPlayerSet) queueEvent.getRecipients()).isLazy()) - { - for (Object player : PlayerConnection.this.minecraftServer.getPlayerList().players) - { - ((EntityPlayer) player).sendMessage(CraftChatMessage.fromString(message)); - } - } - else - { - for (Player player : queueEvent.getRecipients()) - { - player.sendMessage(message); - } - } - return null; - } - }; - if (async) - { - minecraftServer.processQueue.add(waitable); - } - else - { - waitable.run(); - } - try - { - waitable.get(); - } - catch (InterruptedException e) - { - Thread.currentThread().interrupt(); // This is proper habit - // for java. If we - // aren't handling it, - // pass it on! - } - catch (ExecutionException e) - { - throw new RuntimeException("Exception processing chat event", e.getCause()); - } - } - else - { - if (event.isCancelled()) - { - return; - } - - s = String.format(event.getFormat(), event.getPlayer().getDisplayName(), event.getMessage()); - minecraftServer.console.sendMessage(s); - if (((LazyPlayerSet) event.getRecipients()).isLazy()) - { - for (Object recipient : minecraftServer.getPlayerList().players) - { - ((EntityPlayer) recipient).sendMessage(CraftChatMessage.fromString(s)); - } - } - else - { - for (Player recipient : event.getRecipients()) - { - recipient.sendMessage(s); - } - } - } - } - } - - // CraftBukkit end - - private void handleCommand(String s) - { - org.bukkit.craftbukkit.v1_7_R4.SpigotTimings.playerCommandTimer.startTiming(); // Spigot - - // CraftBukkit start - whole method - if (org.spigotmc.SpigotConfig.logCommands) - this.c.info(this.player.getName() + " issued server command: " + s); - - CraftPlayer player = this.getPlayer(); - - PlayerCommandPreprocessEvent event = new PlayerCommandPreprocessEvent(player, s, new LazyPlayerSet()); - this.server.getPluginManager().callEvent(event); - - if (event.isCancelled()) - { - org.bukkit.craftbukkit.v1_7_R4.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot - return; - } - - try - { - if (this.server.dispatchCommand(event.getPlayer(), event.getMessage().substring(1))) - { - org.bukkit.craftbukkit.v1_7_R4.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot - return; - } - } - catch (org.bukkit.command.CommandException ex) - { - player.sendMessage(org.bukkit.ChatColor.RED - + "An internal error occurred while attempting to perform this command"); - java.util.logging.Logger.getLogger(PlayerConnection.class.getName()).log(java.util.logging.Level.SEVERE, - null, ex); - org.bukkit.craftbukkit.v1_7_R4.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot - return; - } - org.bukkit.craftbukkit.v1_7_R4.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot - // this.minecraftServer.getCommandHandler().a(this.player, s); - // CraftBukkit end - } - - public void a(PacketPlayInArmAnimation packetplayinarmanimation) - { - if (this.player.dead) - return; // CraftBukkit - this.player.v(); - if (packetplayinarmanimation.d() == 1) - { - // CraftBukkit start - Raytrace to look for 'rogue armswings' - float f = 1.0F; - float f1 = this.player.lastPitch + (this.player.pitch - this.player.lastPitch) * f; - float f2 = this.player.lastYaw + (this.player.yaw - this.player.lastYaw) * f; - double d0 = this.player.lastX + (this.player.locX - this.player.lastX) * (double) f; - double d1 = this.player.lastY + (this.player.locY - this.player.lastY) * (double) f + 1.62D - - (double) this.player.height; - double d2 = this.player.lastZ + (this.player.locZ - this.player.lastZ) * (double) f; - Vec3D vec3d = Vec3D.a(d0, d1, d2); - - float f3 = MathHelper.cos(-f2 * 0.017453292F - 3.1415927F); - float f4 = MathHelper.sin(-f2 * 0.017453292F - 3.1415927F); - float f5 = -MathHelper.cos(-f1 * 0.017453292F); - float f6 = MathHelper.sin(-f1 * 0.017453292F); - float f7 = f4 * f5; - float f8 = f3 * f5; - double d3 = player.playerInteractManager.getGameMode() == EnumGamemode.CREATIVE ? 5.0D : 4.5D; // Spigot - Vec3D vec3d1 = vec3d.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3); - MovingObjectPosition movingobjectposition = this.player.world.rayTrace(vec3d, vec3d1, false); - - if (movingobjectposition == null || movingobjectposition.type != EnumMovingObjectType.BLOCK) - { - CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, - this.player.inventory.getItemInHand()); - } - - // Arm swing animation - PlayerAnimationEvent event = new PlayerAnimationEvent(this.getPlayer()); - this.server.getPluginManager().callEvent(event); - - if (event.isCancelled()) - return; - // CraftBukkit end - - this.player.ba(); - } - } - - public void a(PacketPlayInEntityAction packetplayinentityaction) - { - // CraftBukkit start - if (this.player.dead) - return; - - this.player.v(); - if (packetplayinentityaction.d() == 1 || packetplayinentityaction.d() == 2) - { - PlayerToggleSneakEvent event = new PlayerToggleSneakEvent(this.getPlayer(), - packetplayinentityaction.d() == 1); - this.server.getPluginManager().callEvent(event); - - if (event.isCancelled()) - { - return; - } - } - - if (packetplayinentityaction.d() == 4 || packetplayinentityaction.d() == 5) - { - PlayerToggleSprintEvent event = new PlayerToggleSprintEvent(this.getPlayer(), - packetplayinentityaction.d() == 4); - this.server.getPluginManager().callEvent(event); - - if (event.isCancelled()) - { - return; - } - } - // CraftBukkit end - - if (packetplayinentityaction.d() == 1) - { - this.player.setSneaking(true); - } - else if (packetplayinentityaction.d() == 2) - { - this.player.setSneaking(false); - } - else if (packetplayinentityaction.d() == 4) - { - this.player.setSprinting(true); - } - else if (packetplayinentityaction.d() == 5) - { - this.player.setSprinting(false); - } - else if (packetplayinentityaction.d() == 3) - { - this.player.a(false, true, true); - // this.checkMovement = false; // CraftBukkit - this is handled in - // teleport - } - else if (packetplayinentityaction.d() == 6) - { - if (this.player.vehicle != null && this.player.vehicle instanceof EntityHorse) - { - ((EntityHorse) this.player.vehicle).w(packetplayinentityaction.e()); - } - } - else if (packetplayinentityaction.d() == 7 && this.player.vehicle != null - && this.player.vehicle instanceof EntityHorse) - { - ((EntityHorse) this.player.vehicle).g(this.player); - } - } - - public void a(PacketPlayInUseEntity packetplayinuseentity) - { - if (this.player.dead) - return; // CraftBukkit - WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); - Entity entity = packetplayinuseentity.a((World) worldserver); - // Spigot Start - if (entity == player) - { - disconnect("Cannot interact with self!"); - return; - } - // Spigot End - // Spigot start - if (player.activeContainer != player.defaultContainer) - { - getPlayer().closeInventory(); - } - // Spigot end - - this.player.v(); - if (entity != null) - { - boolean flag = this.player.hasLineOfSight(entity); - double d0 = 36.0D; - - if (!flag) - { - d0 = 9.0D; - } - - if (this.player.f(entity) < d0) - { - ItemStack itemInHand = this.player.inventory.getItemInHand(); // CraftBukkit - if (packetplayinuseentity.c() == EnumEntityUseAction.INTERACT) - { - // CraftBukkit start - boolean triggerTagUpdate = itemInHand != null && itemInHand.getItem() == Items.NAME_TAG - && entity instanceof EntityInsentient; - boolean triggerChestUpdate = itemInHand != null - && itemInHand.getItem() == Item.getItemOf(Blocks.CHEST) && entity instanceof EntityHorse; - boolean triggerLeashUpdate = itemInHand != null && itemInHand.getItem() == Items.LEASH - && entity instanceof EntityInsentient; - PlayerInteractEntityEvent event = new PlayerInteractEntityEvent((Player) this.getPlayer(), - entity.getBukkitEntity()); - this.server.getPluginManager().callEvent(event); - - if (triggerLeashUpdate - && (event.isCancelled() || this.player.inventory.getItemInHand() == null || this.player.inventory - .getItemInHand().getItem() != Items.LEASH)) - { - // Refresh the current leash state - this.sendPacket(new PacketPlayOutAttachEntity(1, entity, ((EntityInsentient) entity) - .getLeashHolder())); - } - - if (triggerTagUpdate - && (event.isCancelled() || this.player.inventory.getItemInHand() == null || this.player.inventory - .getItemInHand().getItem() != Items.NAME_TAG)) - { - // Refresh the current entity metadata - this.sendPacket(new PacketPlayOutEntityMetadata(entity.getId(), entity.datawatcher, true)); - } - if (triggerChestUpdate - && (event.isCancelled() || this.player.inventory.getItemInHand() == null || this.player.inventory - .getItemInHand().getItem() != Item.getItemOf(Blocks.CHEST))) - { - this.sendPacket(new PacketPlayOutEntityMetadata(entity.getId(), entity.datawatcher, true)); - } - - if (event.isCancelled()) - { - return; - } - // CraftBukkit end - - this.player.q(entity); - - // CraftBukkit start - if (itemInHand != null && itemInHand.count <= -1) - { - this.player.updateInventory(this.player.activeContainer); - } - // CraftBukkit end - } - else if (packetplayinuseentity.c() == EnumEntityUseAction.ATTACK) - { - if (entity instanceof EntityItem || entity instanceof EntityExperienceOrb - || entity instanceof EntityArrow || entity == this.player) - { - this.disconnect("Attempting to attack an invalid entity"); - this.minecraftServer.warning("Player " + this.player.getName() - + " tried to attack an invalid entity"); - return; - } - - this.player.attack(entity); - - // CraftBukkit start - if (itemInHand != null && itemInHand.count <= -1) - { - this.player.updateInventory(this.player.activeContainer); - } - // CraftBukkit end - } - } - } - } - - public void a(PacketPlayInClientCommand packetplayinclientcommand) - { - this.player.v(); - EnumClientCommand enumclientcommand = packetplayinclientcommand.c(); - - switch (ClientCommandOrdinalWrapper.a[enumclientcommand.ordinal()]) - { - case 1: - if (this.player.viewingCredits) - { - this.minecraftServer.getPlayerList().changeDimension(this.player, 0, - PlayerTeleportEvent.TeleportCause.END_PORTAL); // CraftBukkit - // - - // reroute - // logic - // through - // custom - // portal - // management - } - else if (this.player.r().getWorldData().isHardcore()) - { - if (this.minecraftServer.N() && this.player.getName().equals(this.minecraftServer.M())) - { - this.player.playerConnection.disconnect("You have died. Game over, man, it\'s game over!"); - this.minecraftServer.U(); - } - else - { - GameProfileBanEntry gameprofilebanentry = new GameProfileBanEntry(this.player.getProfile(), - (Date) null, "(You just lost the game)", (Date) null, "Death in Hardcore"); - - this.minecraftServer.getPlayerList().getProfileBans().add(gameprofilebanentry); - this.player.playerConnection.disconnect("You have died. Game over, man, it\'s game over!"); - } - } - else - { - if (this.player.getHealth() > 0.0F) - { - return; - } - - this.player = this.minecraftServer.getPlayerList().moveToWorld(this.player, 0, false); - } - break; - - case 2: - this.player.getStatisticManager().a(this.player); - break; - - case 3: - this.player.a((Statistic) AchievementList.f); - } - } - - public void a(PacketPlayInCloseWindow packetplayinclosewindow) - { - if (this.player.dead) - return; // CraftBukkit - - if (packetplayinclosewindow.a == player.activeContainer.windowId) - { - CraftEventFactory.handleInventoryCloseEvent(this.player); // CraftBukkit - - this.player.m(); - } - } - - public void a(PacketPlayInWindowClick packetplayinwindowclick) - { - if (this.player.dead) - return; // CraftBukkit - - this.player.v(); - if (this.player.activeContainer.windowId == packetplayinwindowclick.c() - && this.player.activeContainer.c(this.player)) - { - // CraftBukkit start - Call InventoryClickEvent - if (packetplayinwindowclick.d() < -1 && packetplayinwindowclick.d() != -999) - { - return; - } - - InventoryView inventory = this.player.activeContainer.getBukkitView(); - SlotType type = CraftInventoryView.getSlotType(inventory, packetplayinwindowclick.d()); - - InventoryClickEvent event = null; - ClickType click = ClickType.UNKNOWN; - InventoryAction action = InventoryAction.UNKNOWN; - - ItemStack itemstack = null; - - if (packetplayinwindowclick.d() == -1) - { - type = SlotType.OUTSIDE; // override - click = packetplayinwindowclick.e() == 0 ? ClickType.WINDOW_BORDER_LEFT : ClickType.WINDOW_BORDER_RIGHT; - action = InventoryAction.NOTHING; - } - else if (packetplayinwindowclick.h() == 0) - { - if (packetplayinwindowclick.e() == 0) - { - click = ClickType.LEFT; - } - else if (packetplayinwindowclick.e() == 1) - { - click = ClickType.RIGHT; - } - if (packetplayinwindowclick.e() == 0 || packetplayinwindowclick.e() == 1) - { - action = InventoryAction.NOTHING; // Don't want to repeat - // ourselves - if (packetplayinwindowclick.d() == -999) - { - if (player.inventory.getCarried() != null) - { - action = packetplayinwindowclick.e() == 0 ? InventoryAction.DROP_ALL_CURSOR - : InventoryAction.DROP_ONE_CURSOR; - } - } - else - { - Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.d()); - if (slot != null) - { - ItemStack clickedItem = slot.getItem(); - ItemStack cursor = player.inventory.getCarried(); - if (clickedItem == null) - { - if (cursor != null) - { - action = packetplayinwindowclick.e() == 0 ? InventoryAction.PLACE_ALL - : InventoryAction.PLACE_ONE; - } - } - else if (slot.isAllowed(player)) - { - if (cursor == null) - { - action = packetplayinwindowclick.e() == 0 ? InventoryAction.PICKUP_ALL - : InventoryAction.PICKUP_HALF; - } - else if (slot.isAllowed(cursor)) - { - if (clickedItem.doMaterialsMatch(cursor) && ItemStack.equals(clickedItem, cursor)) - { - int toPlace = packetplayinwindowclick.e() == 0 ? cursor.count : 1; - toPlace = Math.min(toPlace, clickedItem.getMaxStackSize() - clickedItem.count); - toPlace = Math.min(toPlace, slot.inventory.getMaxStackSize() - - clickedItem.count); - if (toPlace == 1) - { - action = InventoryAction.PLACE_ONE; - } - else if (toPlace == cursor.count) - { - action = InventoryAction.PLACE_ALL; - } - else if (toPlace < 0) - { - action = toPlace != -1 ? InventoryAction.PICKUP_SOME - : InventoryAction.PICKUP_ONE; // this - // happens - // with - // oversized - // stacks - } - else if (toPlace != 0) - { - action = InventoryAction.PLACE_SOME; - } - } - else if (cursor.count <= slot.getMaxStackSize()) - { - action = InventoryAction.SWAP_WITH_CURSOR; - } - } - else if (cursor.getItem() == clickedItem.getItem() - && (!cursor.usesData() || cursor.getData() == clickedItem.getData()) - && ItemStack.equals(cursor, clickedItem)) - { - if (clickedItem.count >= 0) - { - if (clickedItem.count + cursor.count <= cursor.getMaxStackSize()) - { - // As of 1.5, this is result slots - // only - action = InventoryAction.PICKUP_ALL; - } - } - } - } - } - } - } - } - else if (packetplayinwindowclick.h() == 1) - { - if (packetplayinwindowclick.e() == 0) - { - click = ClickType.SHIFT_LEFT; - } - else if (packetplayinwindowclick.e() == 1) - { - click = ClickType.SHIFT_RIGHT; - } - if (packetplayinwindowclick.e() == 0 || packetplayinwindowclick.e() == 1) - { - if (packetplayinwindowclick.d() < 0) - { - action = InventoryAction.NOTHING; - } - else - { - Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.d()); - if (slot != null && slot.isAllowed(this.player) && slot.hasItem()) - { - action = InventoryAction.MOVE_TO_OTHER_INVENTORY; - } - else - { - action = InventoryAction.NOTHING; - } - } - } - } - else if (packetplayinwindowclick.h() == 2) - { - if (packetplayinwindowclick.e() >= 0 && packetplayinwindowclick.e() < 9) - { - click = ClickType.NUMBER_KEY; - Slot clickedSlot = this.player.activeContainer.getSlot(packetplayinwindowclick.d()); - if (clickedSlot.isAllowed(player)) - { - ItemStack hotbar = this.player.inventory.getItem(packetplayinwindowclick.e()); - boolean canCleanSwap = hotbar == null - || (clickedSlot.inventory == player.inventory && clickedSlot.isAllowed(hotbar)); // the - // slot - // will - // accept - // the - // hotbar - // item - if (clickedSlot.hasItem()) - { - if (canCleanSwap) - { - action = InventoryAction.HOTBAR_SWAP; - } - else - { - int firstEmptySlot = player.inventory.getFirstEmptySlotIndex(); - if (firstEmptySlot > -1) - { - action = InventoryAction.HOTBAR_MOVE_AND_READD; - } - else - { - action = InventoryAction.NOTHING; // This is - // not - // sane! - // Mojang: - // You - // should - // test - // for - // other - // slots - // of - // same - // type - } - } - } - else if (!clickedSlot.hasItem() && hotbar != null && clickedSlot.isAllowed(hotbar)) - { - action = InventoryAction.HOTBAR_SWAP; - } - else - { - action = InventoryAction.NOTHING; - } - } - else - { - action = InventoryAction.NOTHING; - } - // Special constructor for number key - event = new InventoryClickEvent(inventory, type, packetplayinwindowclick.d(), click, action, - packetplayinwindowclick.e()); - } - } - else if (packetplayinwindowclick.h() == 3) - { - if (packetplayinwindowclick.e() == 2) - { - click = ClickType.MIDDLE; - if (packetplayinwindowclick.d() == -999) - { - action = InventoryAction.NOTHING; - } - else - { - Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.d()); - if (slot != null && slot.hasItem() && player.abilities.canInstantlyBuild - && player.inventory.getCarried() == null) - { - action = InventoryAction.CLONE_STACK; - } - else - { - action = InventoryAction.NOTHING; - } - } - } - else - { - click = ClickType.UNKNOWN; - action = InventoryAction.UNKNOWN; - } - } - else if (packetplayinwindowclick.h() == 4) - { - if (packetplayinwindowclick.d() >= 0) - { - if (packetplayinwindowclick.e() == 0) - { - click = ClickType.DROP; - Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.d()); - if (slot != null && slot.hasItem() && slot.isAllowed(player) && slot.getItem() != null - && slot.getItem().getItem() != Item.getItemOf(Blocks.AIR)) - { - action = InventoryAction.DROP_ONE_SLOT; - } - else - { - action = InventoryAction.NOTHING; - } - } - else if (packetplayinwindowclick.e() == 1) - { - click = ClickType.CONTROL_DROP; - Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.d()); - if (slot != null && slot.hasItem() && slot.isAllowed(player) && slot.getItem() != null - && slot.getItem().getItem() != Item.getItemOf(Blocks.AIR)) - { - action = InventoryAction.DROP_ALL_SLOT; - } - else - { - action = InventoryAction.NOTHING; - } - } - } - else - { - // Sane default (because this happens when they are holding - // nothing. Don't ask why.) - click = ClickType.LEFT; - if (packetplayinwindowclick.e() == 1) - { - click = ClickType.RIGHT; - } - action = InventoryAction.NOTHING; - } - } - else if (packetplayinwindowclick.h() == 5) - { - itemstack = this.player.activeContainer.clickItem(packetplayinwindowclick.d(), - packetplayinwindowclick.e(), 5, this.player); - } - else if (packetplayinwindowclick.h() == 6) - { - click = ClickType.DOUBLE_CLICK; - action = InventoryAction.NOTHING; - if (packetplayinwindowclick.d() >= 0 && this.player.inventory.getCarried() != null) - { - ItemStack cursor = this.player.inventory.getCarried(); - action = InventoryAction.NOTHING; - // Quick check for if we have any of the item - if (inventory.getTopInventory().contains( - org.bukkit.Material.getMaterial(Item.getId(cursor.getItem()))) - || inventory.getBottomInventory().contains( - org.bukkit.Material.getMaterial(Item.getId(cursor.getItem())))) - { - action = InventoryAction.COLLECT_TO_CURSOR; - } - } - } - // TODO check on updates - - if (packetplayinwindowclick.h() != 5) - { - if (click == ClickType.NUMBER_KEY) - { - event = new InventoryClickEvent(inventory, type, packetplayinwindowclick.d(), click, action, - packetplayinwindowclick.e()); - } - else - { - event = new InventoryClickEvent(inventory, type, packetplayinwindowclick.d(), click, action); - } - - org.bukkit.inventory.Inventory top = inventory.getTopInventory(); - if (packetplayinwindowclick.d() == 0 && top instanceof CraftingInventory) - { - org.bukkit.inventory.Recipe recipe = ((CraftingInventory) top).getRecipe(); - if (recipe != null) - { - if (click == ClickType.NUMBER_KEY) - { - event = new CraftItemEvent(recipe, inventory, type, packetplayinwindowclick.d(), click, - action, packetplayinwindowclick.e()); - } - else - { - event = new CraftItemEvent(recipe, inventory, type, packetplayinwindowclick.d(), click, - action); - } - } - } - - server.getPluginManager().callEvent(event); - - switch (event.getResult()) - { - case ALLOW: - case DEFAULT: - itemstack = this.player.activeContainer.clickItem(packetplayinwindowclick.d(), - packetplayinwindowclick.e(), packetplayinwindowclick.h(), this.player); - break; - case DENY: - /* - * Needs enum constructor in InventoryAction if - * (action.modifiesOtherSlots()) { - * - * } else { if (action.modifiesCursor()) { - * this.player.playerConnection.sendPacket(new - * Packet103SetSlot(-1, -1, - * this.player.inventory.getCarried())); } if - * (action.modifiesClicked()) { - * this.player.playerConnection.sendPacket(new - * Packet103SetSlot(this.player.activeContainer.windowId, - * packet102windowclick.slot, - * this.player.activeContainer.getSlot - * (packet102windowclick.slot).getItem())); } } - */ - switch (action) - { - // Modified other slots - case PICKUP_ALL: - case MOVE_TO_OTHER_INVENTORY: - case HOTBAR_MOVE_AND_READD: - case HOTBAR_SWAP: - case COLLECT_TO_CURSOR: - case UNKNOWN: - this.player.updateInventory(this.player.activeContainer); - break; - // Modified cursor and clicked - case PICKUP_SOME: - case PICKUP_HALF: - case PICKUP_ONE: - case PLACE_ALL: - case PLACE_SOME: - case PLACE_ONE: - case SWAP_WITH_CURSOR: - this.player.playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, this.player.inventory - .getCarried())); - if (this.player.activeContainer.c.size() > packetplayinwindowclick.d()) - this.player.playerConnection.sendPacket(new PacketPlayOutSetSlot( - this.player.activeContainer.windowId, packetplayinwindowclick.d(), - this.player.activeContainer.getSlot(packetplayinwindowclick.d()).getItem())); - break; - // Modified clicked only - case DROP_ALL_SLOT: - case DROP_ONE_SLOT: - this.player.playerConnection.sendPacket(new PacketPlayOutSetSlot( - this.player.activeContainer.windowId, packetplayinwindowclick.d(), - this.player.activeContainer.getSlot(packetplayinwindowclick.d()).getItem())); - break; - // Modified cursor only - case DROP_ALL_CURSOR: - case DROP_ONE_CURSOR: - case CLONE_STACK: - this.player.playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, this.player.inventory - .getCarried())); - break; - // Nothing - case NOTHING: - break; - } - return; - } - } - // CraftBukkit end - - if (ItemStack.matches(packetplayinwindowclick.g(), itemstack)) - { - this.player.playerConnection.sendPacket(new PacketPlayOutTransaction(packetplayinwindowclick.c(), - packetplayinwindowclick.f(), true)); - this.player.g = true; - this.player.activeContainer.b(); - this.player.broadcastCarriedItem(); - this.player.g = false; - } - else - { - this.n.a(this.player.activeContainer.windowId, Short.valueOf(packetplayinwindowclick.f())); - this.player.playerConnection.sendPacket(new PacketPlayOutTransaction(packetplayinwindowclick.c(), - packetplayinwindowclick.f(), false)); - this.player.activeContainer.a(this.player, false); - ArrayList arraylist = new ArrayList(); - - for (int i = 0; i < this.player.activeContainer.c.size(); ++i) - { - arraylist.add(((Slot) this.player.activeContainer.c.get(i)).getItem()); - } - - this.player.a(this.player.activeContainer, arraylist); - - // CraftBukkit start - Send a Set Slot to update the crafting - // result slot - if (type == SlotType.RESULT && itemstack != null) - { - this.player.playerConnection.sendPacket(new PacketPlayOutSetSlot( - this.player.activeContainer.windowId, 0, itemstack)); - } - // CraftBukkit end - } - } - } - - public void a(PacketPlayInEnchantItem packetplayinenchantitem) - { - this.player.v(); - if (this.player.activeContainer.windowId == packetplayinenchantitem.c() - && this.player.activeContainer.c(this.player)) - { - this.player.activeContainer.a(this.player, packetplayinenchantitem.d()); - this.player.activeContainer.b(); - } - } - - public void a(PacketPlayInSetCreativeSlot packetplayinsetcreativeslot) - { - if (this.player.playerInteractManager.isCreative()) - { - boolean flag = packetplayinsetcreativeslot.c() < 0; - ItemStack itemstack = packetplayinsetcreativeslot.getItemStack(); - boolean flag1 = packetplayinsetcreativeslot.c() >= 1 - && packetplayinsetcreativeslot.c() < 36 + PlayerInventory.getHotbarSize(); - // CraftBukkit - Add invalidItems check - boolean flag2 = itemstack == null - || itemstack.getItem() != null - && (!invalidItems.contains(Item.getId(itemstack.getItem())) || !org.spigotmc.SpigotConfig.filterCreativeItems); // Spigot - boolean flag3 = itemstack == null || itemstack.getData() >= 0 && itemstack.count <= 64 - && itemstack.count > 0; - - // CraftBukkit start - Call click event - if (flag - || (flag1 && !ItemStack.matches( - this.player.defaultContainer.getSlot(packetplayinsetcreativeslot.c()).getItem(), - packetplayinsetcreativeslot.getItemStack()))) - { // Insist on valid slot - - org.bukkit.entity.HumanEntity player = this.player.getBukkitEntity(); - InventoryView inventory = new CraftInventoryView(player, player.getInventory(), - this.player.defaultContainer); - org.bukkit.inventory.ItemStack item = CraftItemStack.asBukkitCopy(packetplayinsetcreativeslot - .getItemStack()); - - SlotType type = SlotType.QUICKBAR; - if (flag) - { - type = SlotType.OUTSIDE; - } - else if (packetplayinsetcreativeslot.c() < 36) - { - if (packetplayinsetcreativeslot.c() >= 5 && packetplayinsetcreativeslot.c() < 9) - { - type = SlotType.ARMOR; - } - else - { - type = SlotType.CONTAINER; - } - } - InventoryCreativeEvent event = new InventoryCreativeEvent(inventory, type, flag ? -999 - : packetplayinsetcreativeslot.c(), item); - server.getPluginManager().callEvent(event); - - itemstack = CraftItemStack.asNMSCopy(event.getCursor()); - - switch (event.getResult()) - { - case ALLOW: - // Plugin cleared the id / stacksize checks - flag2 = flag3 = true; - break; - case DEFAULT: - break; - case DENY: - // Reset the slot - if (packetplayinsetcreativeslot.c() >= 0) - { - this.player.playerConnection.sendPacket(new PacketPlayOutSetSlot( - this.player.defaultContainer.windowId, packetplayinsetcreativeslot.c(), - this.player.defaultContainer.getSlot(packetplayinsetcreativeslot.c()).getItem())); - this.player.playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, null)); - } - return; - } - } - // CraftBukkit end - - if (flag1 && flag2 && flag3) - { - if (itemstack == null) - { - this.player.defaultContainer.setItem(packetplayinsetcreativeslot.c(), (ItemStack) null); - } - else - { - this.player.defaultContainer.setItem(packetplayinsetcreativeslot.c(), itemstack); - } - - this.player.defaultContainer.a(this.player, true); - } - else if (flag && flag2 && flag3 && this.x < 200) - { - this.x += 20; - EntityItem entityitem = this.player.drop(itemstack, true); - - if (entityitem != null) - { - entityitem.e(); - } - } - } - } - - public void a(PacketPlayInTransaction packetplayintransaction) - { - if (this.player.dead) - return; // CraftBukkit - Short oshort = (Short) this.n.get(this.player.activeContainer.windowId); - - if (oshort != null && packetplayintransaction.d() == oshort.shortValue() - && this.player.activeContainer.windowId == packetplayintransaction.c() - && !this.player.activeContainer.c(this.player)) - { - this.player.activeContainer.a(this.player, true); - } - } - - public void a(PacketPlayInUpdateSign packetplayinupdatesign) - { - if (this.player.dead) - return; // CraftBukkit - - this.player.v(); - WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); - - if (worldserver.isLoaded(packetplayinupdatesign.c(), packetplayinupdatesign.d(), packetplayinupdatesign.e())) - { - TileEntity tileentity = worldserver.getTileEntity(packetplayinupdatesign.c(), packetplayinupdatesign.d(), - packetplayinupdatesign.e()); - - if (tileentity instanceof TileEntitySign) - { - TileEntitySign tileentitysign = (TileEntitySign) tileentity; - - if (!tileentitysign.a() || tileentitysign.b() != this.player) - { - this.minecraftServer.warning("Player " + this.player.getName() - + " just tried to change non-editable sign"); - this.sendPacket(new PacketPlayOutUpdateSign(packetplayinupdatesign.c(), packetplayinupdatesign.d(), - packetplayinupdatesign.e(), tileentitysign.lines)); // CraftBukkit - return; - } - } - - int i; - int j; - - for (j = 0; j < 4; ++j) - { - boolean flag = true; - packetplayinupdatesign.f()[j] = packetplayinupdatesign.f()[j].replaceAll("\uF700", "").replaceAll( - "\uF701", ""); // Spigot - Mac OSX sends weird chars - - if (packetplayinupdatesign.f()[j].length() > 15) - { - flag = false; - } - else - { - for (i = 0; i < packetplayinupdatesign.f()[j].length(); ++i) - { - if (!SharedConstants.isAllowedChatCharacter(packetplayinupdatesign.f()[j].charAt(i))) - { - flag = false; - } - } - } - - if (!flag) - { - packetplayinupdatesign.f()[j] = "!?"; - } - } - - if (tileentity instanceof TileEntitySign) - { - j = packetplayinupdatesign.c(); - int k = packetplayinupdatesign.d(); - - i = packetplayinupdatesign.e(); - TileEntitySign tileentitysign1 = (TileEntitySign) tileentity; - - // CraftBukkit start - Player player = this.server.getPlayer(this.player); - SignChangeEvent event = new SignChangeEvent((org.bukkit.craftbukkit.v1_7_R4.block.CraftBlock) player.getWorld() - .getBlockAt(j, k, i), this.server.getPlayer(this.player), packetplayinupdatesign.f()); - this.server.getPluginManager().callEvent(event); - - if (!event.isCancelled()) - { - tileentitysign1.lines = org.bukkit.craftbukkit.v1_7_R4.block.CraftSign.sanitizeLines(event.getLines()); - tileentitysign1.isEditable = false; - } - // System.arraycopy(packetplayinupdatesign.f(), 0, - // tileentitysign1.lines, 0, 4); - // CraftBukkit end - - tileentitysign1.update(); - worldserver.notify(j, k, i); - } - } - } - - public void a(PacketPlayInKeepAlive packetplayinkeepalive) - { - if (packetplayinkeepalive.c() == this.h) - { - int i = (int) (this.d() - this.i); - - this.player.ping = (this.player.ping * 3 + i) / 4; - } - } - - private long d() - { - return System.nanoTime() / 1000000L; - } - - public void a(PacketPlayInAbilities packetplayinabilities) - { - // CraftBukkit start - if (this.player.abilities.canFly && this.player.abilities.isFlying != packetplayinabilities.isFlying()) - { - PlayerToggleFlightEvent event = new PlayerToggleFlightEvent(this.server.getPlayer(this.player), - packetplayinabilities.isFlying()); - this.server.getPluginManager().callEvent(event); - if (!event.isCancelled()) - { - this.player.abilities.isFlying = packetplayinabilities.isFlying(); // Actually - // set - // the - // player's - // flying - // status - } - else - { - this.player.updateAbilities(); // Tell the player their ability - // was reverted - } - } - // CraftBukkit end - } - - public void a(PacketPlayInTabComplete packetplayintabcomplete) - { - ArrayList arraylist = Lists.newArrayList(); - Iterator iterator = this.minecraftServer.a(this.player, packetplayintabcomplete.c()).iterator(); - - while (iterator.hasNext()) - { - String s = (String) iterator.next(); - - arraylist.add(s); - } - - this.player.playerConnection.sendPacket(new PacketPlayOutTabComplete((String[]) arraylist - .toArray(new String[arraylist.size()]))); - } - - public void a(PacketPlayInSettings packetplayinsettings) - { - this.player.a(packetplayinsettings); - } - - public void a(PacketPlayInCustomPayload packetplayincustompayload) - { - PacketDataSerializer packetdataserializer; - ItemStack itemstack; - ItemStack itemstack1; - - // CraftBukkit start - Ignore empty payloads - if (packetplayincustompayload.length <= 0) - { - return; - } - // CraftBukkit end - - if ("MC|BEdit".equals(packetplayincustompayload.c())) - { - packetdataserializer = new PacketDataSerializer(Unpooled.wrappedBuffer(packetplayincustompayload.e())); - - try - { - itemstack = packetdataserializer.c(); - if (itemstack != null) - { - if (!ItemBookAndQuill.a(itemstack.getTag())) - { - throw new IOException("Invalid book tag!"); - } - - itemstack1 = this.player.inventory.getItemInHand(); - if (itemstack1 == null) - { - return; - } - - if (itemstack.getItem() == Items.BOOK_AND_QUILL && itemstack.getItem() == itemstack1.getItem()) - { - CraftEventFactory.handleEditBookEvent(player, itemstack); // CraftBukkit - } - - return; - } - // CraftBukkit start - } - catch (Exception exception) - { - c.error("Couldn\'t handle book info", exception); - this.disconnect("Invalid book data!"); - return; - // CraftBukkit end - } - finally - { - packetdataserializer.release(); - } - - return; - } - else if ("MC|BSign".equals(packetplayincustompayload.c())) - { - packetdataserializer = new PacketDataSerializer(Unpooled.wrappedBuffer(packetplayincustompayload.e())); - - try - { - itemstack = packetdataserializer.c(); - if (itemstack != null) - { - if (!ItemWrittenBook.a(itemstack.getTag())) - { - throw new IOException("Invalid book tag!"); - } - - itemstack1 = this.player.inventory.getItemInHand(); - if (itemstack1 == null) - { - return; - } - - if (itemstack.getItem() == Items.WRITTEN_BOOK && itemstack1.getItem() == Items.BOOK_AND_QUILL) - { - CraftEventFactory.handleEditBookEvent(player, itemstack); // CraftBukkit - } - - return; - } - // CraftBukkit start - } - catch (Throwable exception1) - { - c.error("Couldn\'t sign book", exception1); - this.disconnect("Invalid book data!"); - // CraftBukkit end - return; - } - finally - { - packetdataserializer.release(); - } - - return; - } - else - { - int i; - DataInputStream datainputstream; - - if ("MC|TrSel".equals(packetplayincustompayload.c())) - { - try - { - datainputstream = new DataInputStream(new ByteArrayInputStream(packetplayincustompayload.e())); - i = datainputstream.readInt(); - Container container = this.player.activeContainer; - - if (container instanceof ContainerMerchant) - { - ((ContainerMerchant) container).e(i); - } - // CraftBukkit start - } - catch (Throwable exception2) - { - c.error("Couldn\'t select trade", exception2); - this.disconnect("Invalid trade data!"); - // CraftBukkit end - } - } - else if ("MC|AdvCdm".equals(packetplayincustompayload.c())) - { - if (!this.minecraftServer.getEnableCommandBlock()) - { - this.player.sendMessage(new ChatMessage("advMode.notEnabled", new Object[0])); - } - else if (this.player.a(2, "") && this.player.abilities.canInstantlyBuild) - { - packetdataserializer = new PacketDataSerializer(Unpooled.wrappedBuffer(packetplayincustompayload - .e())); - - try - { - byte b0 = packetdataserializer.readByte(); - CommandBlockListenerAbstract commandblocklistenerabstract = null; - - if (b0 == 0) - { - TileEntity tileentity = this.player.world.getTileEntity(packetdataserializer.readInt(), - packetdataserializer.readInt(), packetdataserializer.readInt()); - - if (tileentity instanceof TileEntityCommand) - { - commandblocklistenerabstract = ((TileEntityCommand) tileentity).getCommandBlock(); - } - } - else if (b0 == 1) - { - Entity entity = this.player.world.getEntity(packetdataserializer.readInt()); - - if (entity instanceof EntityMinecartCommandBlock) - { - commandblocklistenerabstract = ((EntityMinecartCommandBlock) entity).getCommandBlock(); - } - } - - String s = packetdataserializer.c(packetdataserializer.readableBytes()); - - if (commandblocklistenerabstract != null) - { - commandblocklistenerabstract.setCommand(s); - commandblocklistenerabstract.e(); - this.player.sendMessage(new ChatMessage("advMode.setCommand.success", new Object[] { s })); - } - // CraftBukkit start - } - catch (Throwable exception3) - { - c.error("Couldn\'t set command block", exception3); - this.disconnect("Invalid CommandBlock data!"); - // CraftBukkit end - } - finally - { - packetdataserializer.release(); - } - } - else - { - this.player.sendMessage(new ChatMessage("advMode.notAllowed", new Object[0])); - } - } - else if ("MC|Beacon".equals(packetplayincustompayload.c())) - { - if (this.player.activeContainer instanceof ContainerBeacon) - { - try - { - datainputstream = new DataInputStream(new ByteArrayInputStream(packetplayincustompayload.e())); - i = datainputstream.readInt(); - int j = datainputstream.readInt(); - ContainerBeacon containerbeacon = (ContainerBeacon) this.player.activeContainer; - Slot slot = containerbeacon.getSlot(0); - - if (slot.hasItem()) - { - slot.a(1); - TileEntityBeacon tileentitybeacon = containerbeacon.e(); - - tileentitybeacon.d(i); - tileentitybeacon.e(j); - tileentitybeacon.update(); - } - // CraftBukkit start - } - catch (Throwable exception4) - { - c.error("Couldn\'t set beacon", exception4); - this.disconnect("Invalid beacon data!"); - // CraftBukkit end - } - } - } - else if ("MC|ItemName".equals(packetplayincustompayload.c()) - && this.player.activeContainer instanceof ContainerAnvil) - { - ContainerAnvil containeranvil = (ContainerAnvil) this.player.activeContainer; - - if (packetplayincustompayload.e() != null && packetplayincustompayload.e().length >= 1) - { - String s1 = SharedConstants.a(new String(packetplayincustompayload.e(), Charsets.UTF_8)); - - if (s1.length() <= 30) - { - containeranvil.a(s1); - } - } - else - { - containeranvil.a(""); - } - } - // CraftBukkit start - else if (packetplayincustompayload.c().equals("REGISTER")) - { - try - { - String channels = new String(packetplayincustompayload.e(), "UTF8"); - for (String channel : channels.split("\0")) - { - getPlayer().addChannel(channel); - } - } - catch (UnsupportedEncodingException ex) - { - throw new AssertionError(ex); - } - } - else if (packetplayincustompayload.c().equals("UNREGISTER")) - { - try - { - String channels = new String(packetplayincustompayload.e(), "UTF8"); - for (String channel : channels.split("\0")) - { - getPlayer().removeChannel(channel); - } - } - catch (UnsupportedEncodingException ex) - { - throw new AssertionError(ex); - } - } - else - { - server.getMessenger().dispatchIncomingMessage(player.getBukkitEntity(), packetplayincustompayload.c(), - packetplayincustompayload.e()); - } - // CraftBukkit end - } - } - - public void a(EnumProtocol enumprotocol, EnumProtocol enumprotocol1) - { - if (enumprotocol1 != EnumProtocol.PLAY) - { - throw new IllegalStateException("Unexpected change in protocol!"); - } - } - - // CraftBukkit start - Add "isDisconnected" method - public boolean isDisconnected() - { - return !this.player.joining && !NetworkManager.a(this.networkManager).config().isAutoRead(); - } - // CraftBukkit end -} diff --git a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/QueuedPacket.java b/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/QueuedPacket.java deleted file mode 100644 index 7b80b5b2a..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/QueuedPacket.java +++ /dev/null @@ -1,25 +0,0 @@ -package net.minecraft.server.v1_7_R4; - -import net.minecraft.util.io.netty.util.concurrent.GenericFutureListener; - -public class QueuedPacket -{ - private final Packet a; - private final GenericFutureListener[] b; - - public QueuedPacket(Packet packet, GenericFutureListener... agenericfuturelistener) - { - this.a = packet; - this.b = agenericfuturelistener; - } - - public static Packet a(QueuedPacket queuedpacket) - { - return queuedpacket.a; - } - - public static GenericFutureListener[] b(QueuedPacket queuedpacket) - { - return queuedpacket.b; - } -} \ No newline at end of file diff --git a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/World.java b/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/World.java deleted file mode 100644 index 75bbe8ea5..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/src/net/minecraft/server/v1_7_R4/World.java +++ /dev/null @@ -1,3955 +0,0 @@ -package net.minecraft.server.v1_7_R4; - -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Collection; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Random; -import java.util.Set; -import java.util.UUID; -import java.util.concurrent.Callable; - -// CraftBukkit start -import org.bukkit.Bukkit; -import org.bukkit.block.BlockState; -import org.bukkit.craftbukkit.v1_7_R4.util.CraftMagicNumbers; -import org.bukkit.craftbukkit.v1_7_R4.util.LongHashSet; -import org.bukkit.craftbukkit.v1_7_R4.SpigotTimings; // Spigot -import org.bukkit.generator.ChunkGenerator; -import org.bukkit.craftbukkit.v1_7_R4.CraftServer; -import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; -import org.bukkit.craftbukkit.v1_7_R4.event.CraftEventFactory; -import org.bukkit.event.block.BlockCanBuildEvent; -import org.bukkit.event.block.BlockPhysicsEvent; -import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; -import org.bukkit.event.weather.WeatherChangeEvent; -import org.bukkit.event.weather.ThunderChangeEvent; - -// CraftBukkit end - -public abstract class World implements IBlockAccess -{ - - public boolean d; - // Spigot start - guard entity list from removals - public List entityList = new ArrayList() - { - @Override - public Object remove(int index) - { - guard(); - return super.remove(index); - } - - @Override - public boolean remove(Object o) - { - guard(); - return super.remove(o); - } - - private void guard() - { - if (guardEntityList) - { - throw new java.util.ConcurrentModificationException(); - } - } - }; - // Spigot end - protected List f = new ArrayList(); - public Set tileEntityList = new HashSet(); // CraftBukkit - ArrayList -> - // HashSet - private List a = new ArrayList(); - private List b = new ArrayList(); - public List players = new ArrayList(); - public List i = new ArrayList(); - private long c = 16777215L; - public int j; - protected int k = (new Random()).nextInt(); - protected final int l = 1013904223; - protected float m; - protected float n; - protected float o; - protected float p; - public int q; - public EnumDifficulty difficulty; - public Random random = new Random(); - public WorldProvider worldProvider; // CraftBukkit - remove final - protected List u = new ArrayList(); - public IChunkProvider chunkProvider; // CraftBukkit - public - protected final IDataManager dataManager; - public WorldData worldData; // CraftBukkit - public - public boolean isLoading; - public PersistentCollection worldMaps; - public final PersistentVillage villages; - protected final VillageSiege siegeManager = new VillageSiege(this); - public final MethodProfiler methodProfiler; - private final Calendar J = Calendar.getInstance(); - public Scoreboard scoreboard = new Scoreboard(); // CraftBukkit - protected - // -> public - public boolean isStatic; - // CraftBukkit start - public, longhashset - // protected LongHashSet chunkTickList = new LongHashSet(); // Spigot - private int K; - public boolean allowMonsters; - public boolean allowAnimals; - // Added the following - public boolean captureBlockStates = false; - public boolean captureTreeGeneration = false; - public ArrayList capturedBlockStates = new ArrayList(); - public long ticksPerAnimalSpawns; - public long ticksPerMonsterSpawns; - public boolean populating; - private int tickPosition; - // CraftBukkit end - private ArrayList L; - private boolean M; - int[] I; - - // Spigot start - private boolean guardEntityList; - protected final net.minecraft.util.gnu.trove.map.hash.TLongShortHashMap chunkTickList; - protected float growthOdds = 100; - protected float modifiedOdds = 100; - private final byte chunkTickRadius; - public static boolean haveWeSilencedAPhysicsCrash; - public static String blockLocation; - public List triggerHoppersList = new ArrayList(); // Spigot, - // When - // altHopperTicking, - // tile - // entities - // being - // added - // go - // through - // here. - - public static long chunkToKey(int x, int z) - { - long k = ((((long) x) & 0xFFFF0000L) << 16) | ((((long) x) & 0x0000FFFFL) << 0); - k |= ((((long) z) & 0xFFFF0000L) << 32) | ((((long) z) & 0x0000FFFFL) << 16); - return k; - } - - public static int keyToX(long k) - { - return (int) (((k >> 16) & 0xFFFF0000) | (k & 0x0000FFFF)); - } - - public static int keyToZ(long k) - { - return (int) (((k >> 32) & 0xFFFF0000L) | ((k >> 16) & 0x0000FFFF)); - } - - // Spigot Start - Hoppers need to be born ticking. - private void initializeHoppers() - { - if (this.spigotConfig.altHopperTicking) - { - for (TileEntity o : this.triggerHoppersList) - { - o.scheduleTicks(); - if (o instanceof TileEntityHopper) - { - ((TileEntityHopper) o).convertToScheduling(); - ((TileEntityHopper) o).scheduleHopperTick(); - } - } - } - 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) - { - Block block = this.getType(a, b, c); - if (block instanceof BlockChest) - { - TileEntity tile = this.getTileEntity(a, b, c); - if (tile instanceof TileEntityChest) - { - tile.scheduleTicks(); - } - for (int i = 2; i < 6; i++) - { - // Facing class provides arrays for direction offset. - if (this.getType(a + Facing.b[i], b, c + Facing.d[i]) == block) - { - tile = this.getTileEntity(a + Facing.b[i], b, c + Facing.d[i]); - if (tile instanceof TileEntityChest) - { - tile.scheduleTicks(); - } - break; - } - } - } - } - - // Spigot end - - public BiomeBase getBiome(int i, int j) - { - if (this.isLoaded(i, 0, j)) - { - Chunk chunk = this.getChunkAtWorldCoords(i, j); - - try - { - return chunk.getBiome(i & 15, j & 15, this.worldProvider.e); - } - catch (Throwable throwable) - { - CrashReport crashreport = CrashReport.a(throwable, "Getting biome"); - CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Coordinates of biome request"); - - crashreportsystemdetails.a("Location", (Callable) (new CrashReportWorldLocation(this, i, j))); - throw new ReportedException(crashreport); - } - } - else - { - return this.worldProvider.e.getBiome(i, j); - } - } - - public WorldChunkManager getWorldChunkManager() - { - return this.worldProvider.e; - } - - // CraftBukkit start - private final CraftWorld world; - public boolean pvpMode; - public boolean keepSpawnInMemory = true; - public ChunkGenerator generator; - public final org.spigotmc.SpigotWorldConfig spigotConfig; // Spigot - - public final SpigotTimings.WorldTimingsHandler timings; // Spigot - - private Entity _startEntity; - - public CraftWorld getWorld() - { - return this.world; - } - - public CraftServer getServer() - { - return (CraftServer) Bukkit.getServer(); - } - - public Chunk getChunkIfLoaded(int x, int z) - { - return ((ChunkProviderServer) this.chunkProvider).getChunkIfLoaded(x, z); - } - - // Changed signature - added gen and env - public World(IDataManager idatamanager, String s, WorldSettings worldsettings, WorldProvider worldprovider, - MethodProfiler methodprofiler, ChunkGenerator gen, org.bukkit.World.Environment env) - { - this.spigotConfig = new org.spigotmc.SpigotWorldConfig(s); // Spigot - this.generator = gen; - this.world = new CraftWorld((WorldServer) this, gen, env); - this.ticksPerAnimalSpawns = this.getServer().getTicksPerAnimalSpawns(); // CraftBukkit - this.ticksPerMonsterSpawns = this.getServer().getTicksPerMonsterSpawns(); // CraftBukkit - // CraftBukkit end - // Spigot start - this.chunkTickRadius = (byte) ((this.getServer().getViewDistance() < 7) ? this.getServer().getViewDistance() - : 7); - this.chunkTickList = new net.minecraft.util.gnu.trove.map.hash.TLongShortHashMap( - spigotConfig.chunksPerTick * 5, 0.7f, Long.MIN_VALUE, Short.MIN_VALUE); - this.chunkTickList.setAutoCompactionFactor(0); - // Spigot end - - this.K = this.random.nextInt(12000); - this.allowMonsters = true; - this.allowAnimals = true; - this.L = new ArrayList(); - this.I = new int['\u8000']; - this.dataManager = idatamanager; - this.methodProfiler = methodprofiler; - this.worldMaps = new PersistentCollection(idatamanager); - this.worldData = idatamanager.getWorldData(); - if (worldprovider != null) - { - this.worldProvider = worldprovider; - } - else if (this.worldData != null && this.worldData.j() != 0) - { - this.worldProvider = WorldProvider.byDimension(this.worldData.j()); - } - else - { - this.worldProvider = WorldProvider.byDimension(0); - } - - if (this.worldData == null) - { - this.worldData = new WorldData(worldsettings, s); - } - else - { - this.worldData.setName(s); - } - - this.worldProvider.a(this); - this.chunkProvider = this.j(); - timings = new SpigotTimings.WorldTimingsHandler(this); // Spigot - code - // below can - // generate new - // world and - // access - // timings - if (!this.worldData.isInitialized()) - { - try - { - this.a(worldsettings); - } - catch (Throwable throwable) - { - CrashReport crashreport = CrashReport.a(throwable, "Exception initializing level"); - - try - { - this.a(crashreport); - } - catch (Throwable throwable1) - { - ; - } - - throw new ReportedException(crashreport); - } - - this.worldData.d(true); - } - - PersistentVillage persistentvillage = (PersistentVillage) this.worldMaps.get(PersistentVillage.class, - "villages"); - - if (persistentvillage == null) - { - this.villages = new PersistentVillage(this); - this.worldMaps.a("villages", this.villages); - } - else - { - this.villages = persistentvillage; - this.villages.a(this); - } - - this.B(); - this.a(); - - this.getServer().addWorld(this.world); // CraftBukkit - } - - protected abstract IChunkProvider j(); - - protected void a(WorldSettings worldsettings) - { - this.worldData.d(true); - } - - public Block b(int i, int j) - { - int k; - - for (k = 63; !this.isEmpty(i, k + 1, j); ++k) - { - ; - } - - return this.getType(i, k, j); - } - - // Spigot start - public Block getType(int i, int j, int k) - { - return getType(i, j, k, true); - } - - public Block getType(int i, int j, int k, boolean useCaptured) - { - // CraftBukkit start - tree generation - if (captureTreeGeneration && useCaptured) - { - // Spigot end - Iterator it = capturedBlockStates.iterator(); - while (it.hasNext()) - { - BlockState previous = it.next(); - if (previous.getX() == i && previous.getY() == j && previous.getZ() == k) - { - return CraftMagicNumbers.getBlock(previous.getTypeId()); - } - } - } - // CraftBukkit end - if (i >= -30000000 && k >= -30000000 && i < 30000000 && k < 30000000 && j >= 0 && j < 256) - { - Chunk chunk = null; - - try - { - chunk = this.getChunkAt(i >> 4, k >> 4); - return chunk.getType(i & 15, j, k & 15); - } - catch (Throwable throwable) - { - CrashReport crashreport = CrashReport.a(throwable, "Exception getting block type in world"); - CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Requested block coordinates"); - - crashreportsystemdetails.a("Found chunk", Boolean.valueOf(chunk == null)); - crashreportsystemdetails.a("Location", CrashReportSystemDetails.a(i, j, k)); - throw new ReportedException(crashreport); - } - } - else - { - return Blocks.AIR; - } - } - - public boolean isEmpty(int i, int j, int k) - { - return this.getType(i, j, k).getMaterial() == Material.AIR; - } - - public boolean isLoaded(int i, int j, int k) - { - return j >= 0 && j < 256 ? this.isChunkLoaded(i >> 4, k >> 4) : false; - } - - public boolean areChunksLoaded(int i, int j, int k, int l) - { - return this.b(i - l, j - l, k - l, i + l, j + l, k + l); - } - - public boolean b(int i, int j, int k, int l, int i1, int j1) - { - if (i1 >= 0 && j < 256) - { - i >>= 4; - k >>= 4; - l >>= 4; - j1 >>= 4; - - for (int k1 = i; k1 <= l; ++k1) - { - for (int l1 = k; l1 <= j1; ++l1) - { - if (!this.isChunkLoaded(k1, l1)) - { - return false; - } - } - } - - return true; - } - else - { - return false; - } - } - - protected boolean isChunkLoaded(int i, int j) - { - return this.chunkProvider.isChunkLoaded(i, j); - } - - public Chunk getChunkAtWorldCoords(int i, int j) - { - return this.getChunkAt(i >> 4, j >> 4); - } - - public Chunk getChunkAt(int i, int j) - { - return this.chunkProvider.getOrCreateChunk(i, j); - } - - public boolean setTypeAndData(int i, int j, int k, Block block, int l, int i1) - { - // CraftBukkit start - tree generation - if (this.captureTreeGeneration) - { - BlockState blockstate = null; - Iterator it = capturedBlockStates.iterator(); - while (it.hasNext()) - { - BlockState previous = it.next(); - if (previous.getX() == i && previous.getY() == j && previous.getZ() == k) - { - blockstate = previous; - it.remove(); - break; - } - } - if (blockstate == null) - { - blockstate = org.bukkit.craftbukkit.v1_7_R4.block.CraftBlockState.getBlockState(this, i, j, k, i1); - } - blockstate.setTypeId(CraftMagicNumbers.getId(block)); - blockstate.setRawData((byte) l); - this.capturedBlockStates.add(blockstate); - return true; - } - if (i >= -30000000 && k >= -30000000 && i < 30000000 && k < 30000000) - { - if (j < 0) - { - return false; - } - else if (j >= 256) - { - return false; - } - else - { - Chunk chunk = this.getChunkAt(i >> 4, k >> 4); - Block block1 = null; - - if ((i1 & 1) != 0) - { - block1 = chunk.getType(i & 15, j, k & 15); - } - - // CraftBukkit start - capture blockstates - BlockState blockstate = null; - if (this.captureBlockStates) - { - blockstate = org.bukkit.craftbukkit.v1_7_R4.block.CraftBlockState.getBlockState(this, i, j, k, i1); - this.capturedBlockStates.add(blockstate); - } - // CraftBukkit end - - boolean flag = chunk.a(i & 15, j, k & 15, block, l); - - // CraftBukkit start - remove blockstate if failed - if (!flag && this.captureBlockStates) - { - this.capturedBlockStates.remove(blockstate); - } - // CraftBukkit end - - this.methodProfiler.a("checkLight"); - this.t(i, j, k); - this.methodProfiler.b(); - // CraftBukkit start - if (flag && !this.captureBlockStates) - { // Don't notify clients or update physics while capturing - // blockstates - // Modularize client and physic updates - this.notifyAndUpdatePhysics(i, j, k, chunk, block1, block, i1); - // CraftBukkit end - } - // Spigot start - If this block is changing to that which a - // chest beneath it - // becomes able to be opened, then the chest must be updated. - // block1 is the old block. block is the new block. r returns - // true if the block type - // prevents access to a chest. - if (this.spigotConfig.altHopperTicking && block1 != null && block1.r() && !block.r()) - { - this.updateChestAndHoppers(i, j - 1, k); - } - // Spigot end - - return flag; - } - } - else - { - return false; - } - } - - // CraftBukkit start - Split off from original setTypeAndData(int i, int j, - // int k, Block block, int l, int i1) method in order to directly send - // client and physic updates - public void notifyAndUpdatePhysics(int i, int j, int k, Chunk chunk, Block oldBlock, Block newBlock, int flag) - { - // should be isReady() - if ((flag & 2) != 0 && (chunk == null || chunk.isReady())) - { // allow chunk to be null here as chunk.isReady() is false when we - // send our notification during block placement - this.notify(i, j, k); - } - - if ((flag & 1) != 0) - { - this.update(i, j, k, oldBlock); - if (newBlock.isComplexRedstone()) - { - this.updateAdjacentComparators(i, j, k, newBlock); - } - } - } - - // CraftBukkit end - - public int getData(int i, int j, int k) - { - // CraftBukkit start - tree generation - if (captureTreeGeneration) - { - Iterator it = capturedBlockStates.iterator(); - while (it.hasNext()) - { - BlockState previous = it.next(); - if (previous.getX() == i && previous.getY() == j && previous.getZ() == k) - { - return previous.getRawData(); - } - } - } - // CraftBukkit end - if (i >= -30000000 && k >= -30000000 && i < 30000000 && k < 30000000) - { - if (j < 0) - { - return 0; - } - else if (j >= 256) - { - return 0; - } - else - { - Chunk chunk = this.getChunkAt(i >> 4, k >> 4); - - i &= 15; - k &= 15; - return chunk.getData(i, j, k); - } - } - else - { - return 0; - } - } - - public boolean setData(int i, int j, int k, int l, int i1) - { - // CraftBukkit start - tree generation - if (this.captureTreeGeneration) - { - BlockState blockstate = null; - Iterator it = capturedBlockStates.iterator(); - while (it.hasNext()) - { - BlockState previous = it.next(); - if (previous.getX() == i && previous.getY() == j && previous.getZ() == k) - { - blockstate = previous; - it.remove(); - break; - } - } - if (blockstate == null) - { - blockstate = org.bukkit.craftbukkit.v1_7_R4.block.CraftBlockState.getBlockState(this, i, j, k, i1); - } - blockstate.setRawData((byte) l); - this.capturedBlockStates.add(blockstate); - return true; - } - // CraftBukkit end - if (i >= -30000000 && k >= -30000000 && i < 30000000 && k < 30000000) - { - if (j < 0) - { - return false; - } - else if (j >= 256) - { - return false; - } - else - { - Chunk chunk = this.getChunkAt(i >> 4, k >> 4); - int j1 = i & 15; - int k1 = k & 15; - boolean flag = chunk.a(j1, j, k1, l); - - if (flag) - { - Block block = chunk.getType(j1, j, k1); - - if ((i1 & 2) != 0 && (!this.isStatic || (i1 & 4) == 0) && chunk.isReady()) - { - this.notify(i, j, k); - } - - if (!this.isStatic && (i1 & 1) != 0) - { - this.update(i, j, k, block); - if (block.isComplexRedstone()) - { - this.updateAdjacentComparators(i, j, k, block); - } - } - } - - return flag; - } - } - else - { - return false; - } - } - - public boolean setAir(int i, int j, int k) - { - return this.setTypeAndData(i, j, k, Blocks.AIR, 0, 3); - } - - public boolean setAir(int i, int j, int k, boolean flag) - { - Block block = this.getType(i, j, k); - - if (block.getMaterial() == Material.AIR) - { - return false; - } - else - { - int l = this.getData(i, j, k); - - this.triggerEffect(2001, i, j, k, Block.getId(block) + (l << 12)); - if (flag) - { - block.b(this, i, j, k, l, 0); - } - - return this.setTypeAndData(i, j, k, Blocks.AIR, 0, 3); - } - } - - public boolean setTypeUpdate(int i, int j, int k, Block block) - { - return this.setTypeAndData(i, j, k, block, 0, 3); - } - - public void notify(int i, int j, int k) - { - for (int l = 0; l < this.u.size(); ++l) - { - ((IWorldAccess) this.u.get(l)).a(i, j, k); - } - } - - public void update(int i, int j, int k, Block block) - { - // CraftBukkit start - if (this.populating) - { - return; - } - // CraftBukkit end - this.applyPhysics(i, j, k, block); - } - - public void b(int i, int j, int k, int l) - { - int i1; - - if (k > l) - { - i1 = l; - l = k; - k = i1; - } - - if (!this.worldProvider.g) - { - for (i1 = k; i1 <= l; ++i1) - { - this.c(EnumSkyBlock.SKY, i, i1, j); - } - } - - this.c(i, k, j, i, l, j); - } - - public void c(int i, int j, int k, int l, int i1, int j1) - { - for (int k1 = 0; k1 < this.u.size(); ++k1) - { - ((IWorldAccess) this.u.get(k1)).a(i, j, k, l, i1, j1); - } - } - - public void applyPhysics(int i, int j, int k, Block block) - { - this.e(i - 1, j, k, block); - this.e(i + 1, j, k, block); - this.e(i, j - 1, k, block); - this.e(i, j + 1, k, block); - this.e(i, j, k - 1, block); - this.e(i, j, k + 1, block); - spigotConfig.antiXrayInstance.updateNearbyBlocks(this, i, j, k); // Spigot - } - - public void b(int i, int j, int k, Block block, int l) - { - if (l != 4) - { - this.e(i - 1, j, k, block); - } - - if (l != 5) - { - this.e(i + 1, j, k, block); - } - - if (l != 0) - { - this.e(i, j - 1, k, block); - } - - if (l != 1) - { - this.e(i, j + 1, k, block); - } - - if (l != 2) - { - this.e(i, j, k - 1, block); - } - - if (l != 3) - { - this.e(i, j, k + 1, block); - } - } - - public void e(int i, int j, int k, Block block) - { - if (!this.isStatic) - { - Block block1 = this.getType(i, j, k); - - try - { - // CraftBukkit start - CraftWorld world = ((WorldServer) this).getWorld(); - if (world != null) - { - BlockPhysicsEvent event = new BlockPhysicsEvent(world.getBlockAt(i, j, k), - CraftMagicNumbers.getId(block)); - this.getServer().getPluginManager().callEvent(event); - - if (event.isCancelled()) - { - return; - } - } - // CraftBukkit end - - block1.doPhysics(this, i, j, k, block); - } - catch (StackOverflowError stackoverflowerror) - { // Spigot Start - haveWeSilencedAPhysicsCrash = true; - blockLocation = i + ", " + j + ", " + k; // Spigot End - } - catch (Throwable throwable) - { - CrashReport crashreport = CrashReport.a(throwable, "Exception while updating neighbours"); - CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Block being updated"); - - int l; - - try - { - l = this.getData(i, j, k); - } - catch (Throwable throwable1) - { - l = -1; - } - - crashreportsystemdetails.a("Source block type", - (Callable) (new CrashReportSourceBlockType(this, block))); - CrashReportSystemDetails.a(crashreportsystemdetails, i, j, k, block1, l); - throw new ReportedException(crashreport); - } - } - } - - public boolean a(int i, int j, int k, Block block) - { - return false; - } - - public boolean i(int i, int j, int k) - { - return this.getChunkAt(i >> 4, k >> 4).d(i & 15, j, k & 15); - } - - public int j(int i, int j, int k) - { - if (j < 0) - { - return 0; - } - else - { - if (j >= 256) - { - j = 255; - } - - return this.getChunkAt(i >> 4, k >> 4).b(i & 15, j, k & 15, 0); - } - } - - public int getLightLevel(int i, int j, int k) - { - return this.b(i, j, k, true); - } - - public int b(int i, int j, int k, boolean flag) - { - if (i >= -30000000 && k >= -30000000 && i < 30000000 && k < 30000000) - { - if (flag && this.getType(i, j, k).n()) - { - int l = this.b(i, j + 1, k, false); - int i1 = this.b(i + 1, j, k, false); - int j1 = this.b(i - 1, j, k, false); - int k1 = this.b(i, j, k + 1, false); - int l1 = this.b(i, j, k - 1, false); - - if (i1 > l) - { - l = i1; - } - - if (j1 > l) - { - l = j1; - } - - if (k1 > l) - { - l = k1; - } - - if (l1 > l) - { - l = l1; - } - - return l; - } - else if (j < 0) - { - return 0; - } - else - { - if (j >= 256) - { - j = 255; - } - - Chunk chunk = this.getChunkAt(i >> 4, k >> 4); - - i &= 15; - k &= 15; - return chunk.b(i, j, k, this.j); - } - } - else - { - return 15; - } - } - - public int getHighestBlockYAt(int i, int j) - { - if (i >= -30000000 && j >= -30000000 && i < 30000000 && j < 30000000) - { - if (!this.isChunkLoaded(i >> 4, j >> 4)) - { - return 0; - } - else - { - Chunk chunk = this.getChunkAt(i >> 4, j >> 4); - - return chunk.b(i & 15, j & 15); - } - } - else - { - return 64; - } - } - - public int g(int i, int j) - { - if (i >= -30000000 && j >= -30000000 && i < 30000000 && j < 30000000) - { - if (!this.isChunkLoaded(i >> 4, j >> 4)) - { - return 0; - } - else - { - Chunk chunk = this.getChunkAt(i >> 4, j >> 4); - - return chunk.r; - } - } - else - { - return 64; - } - } - - public int b(EnumSkyBlock enumskyblock, int i, int j, int k) - { - if (j < 0) - { - j = 0; - } - - if (j >= 256) - { - j = 255; - } - - if (i >= -30000000 && k >= -30000000 && i < 30000000 && k < 30000000) - { - int l = i >> 4; - int i1 = k >> 4; - - if (!this.isChunkLoaded(l, i1)) - { - return enumskyblock.c; - } - else - { - Chunk chunk = this.getChunkAt(l, i1); - - return chunk.getBrightness(enumskyblock, i & 15, j, k & 15); - } - } - else - { - return enumskyblock.c; - } - } - - public void b(EnumSkyBlock enumskyblock, int i, int j, int k, int l) - { - if (i >= -30000000 && k >= -30000000 && i < 30000000 && k < 30000000) - { - if (j >= 0) - { - if (j < 256) - { - if (this.isChunkLoaded(i >> 4, k >> 4)) - { - Chunk chunk = this.getChunkAt(i >> 4, k >> 4); - - chunk.a(enumskyblock, i & 15, j, k & 15, l); - - for (int i1 = 0; i1 < this.u.size(); ++i1) - { - ((IWorldAccess) this.u.get(i1)).b(i, j, k); - } - } - } - } - } - } - - public void m(int i, int j, int k) - { - for (int l = 0; l < this.u.size(); ++l) - { - ((IWorldAccess) this.u.get(l)).b(i, j, k); - } - } - - public float n(int i, int j, int k) - { - return this.worldProvider.h[this.getLightLevel(i, j, k)]; - } - - public boolean w() - { - return this.j < 4; - } - - public MovingObjectPosition a(Vec3D vec3d, Vec3D vec3d1) - { - return this.rayTrace(vec3d, vec3d1, false, false, false); - } - - public MovingObjectPosition rayTrace(Vec3D vec3d, Vec3D vec3d1, boolean flag) - { - return this.rayTrace(vec3d, vec3d1, flag, false, false); - } - - public MovingObjectPosition rayTrace(Vec3D vec3d, Vec3D vec3d1, boolean flag, boolean flag1, boolean flag2) - { - if (!Double.isNaN(vec3d.a) && !Double.isNaN(vec3d.b) && !Double.isNaN(vec3d.c)) - { - if (!Double.isNaN(vec3d1.a) && !Double.isNaN(vec3d1.b) && !Double.isNaN(vec3d1.c)) - { - int i = MathHelper.floor(vec3d1.a); - int j = MathHelper.floor(vec3d1.b); - int k = MathHelper.floor(vec3d1.c); - int l = MathHelper.floor(vec3d.a); - int i1 = MathHelper.floor(vec3d.b); - int j1 = MathHelper.floor(vec3d.c); - Block block = this.getType(l, i1, j1); - int k1 = this.getData(l, i1, j1); - - if ((!flag1 || block.a(this, l, i1, j1) != null) && block.a(k1, flag)) - { - MovingObjectPosition movingobjectposition = block.a(this, l, i1, j1, vec3d, vec3d1); - - if (movingobjectposition != null) - { - return movingobjectposition; - } - } - - MovingObjectPosition movingobjectposition1 = null; - - k1 = 200; - - while (k1-- >= 0) - { - if (Double.isNaN(vec3d.a) || Double.isNaN(vec3d.b) || Double.isNaN(vec3d.c)) - { - return null; - } - - if (l == i && i1 == j && j1 == k) - { - return flag2 ? movingobjectposition1 : null; - } - - boolean flag3 = true; - boolean flag4 = true; - boolean flag5 = true; - double d0 = 999.0D; - double d1 = 999.0D; - double d2 = 999.0D; - - if (i > l) - { - d0 = (double) l + 1.0D; - } - else if (i < l) - { - d0 = (double) l + 0.0D; - } - else - { - flag3 = false; - } - - if (j > i1) - { - d1 = (double) i1 + 1.0D; - } - else if (j < i1) - { - d1 = (double) i1 + 0.0D; - } - else - { - flag4 = false; - } - - if (k > j1) - { - d2 = (double) j1 + 1.0D; - } - else if (k < j1) - { - d2 = (double) j1 + 0.0D; - } - else - { - flag5 = false; - } - - double d3 = 999.0D; - double d4 = 999.0D; - double d5 = 999.0D; - double d6 = vec3d1.a - vec3d.a; - double d7 = vec3d1.b - vec3d.b; - double d8 = vec3d1.c - vec3d.c; - - if (flag3) - { - d3 = (d0 - vec3d.a) / d6; - } - - if (flag4) - { - d4 = (d1 - vec3d.b) / d7; - } - - if (flag5) - { - d5 = (d2 - vec3d.c) / d8; - } - - boolean flag6 = false; - byte b0; - - if (d3 < d4 && d3 < d5) - { - if (i > l) - { - b0 = 4; - } - else - { - b0 = 5; - } - - vec3d.a = d0; - vec3d.b += d7 * d3; - vec3d.c += d8 * d3; - } - else if (d4 < d5) - { - if (j > i1) - { - b0 = 0; - } - else - { - b0 = 1; - } - - vec3d.a += d6 * d4; - vec3d.b = d1; - vec3d.c += d8 * d4; - } - else - { - if (k > j1) - { - b0 = 2; - } - else - { - b0 = 3; - } - - vec3d.a += d6 * d5; - vec3d.b += d7 * d5; - vec3d.c = d2; - } - - Vec3D vec3d2 = Vec3D.a(vec3d.a, vec3d.b, vec3d.c); - - l = (int) (vec3d2.a = (double) MathHelper.floor(vec3d.a)); - if (b0 == 5) - { - --l; - ++vec3d2.a; - } - - i1 = (int) (vec3d2.b = (double) MathHelper.floor(vec3d.b)); - if (b0 == 1) - { - --i1; - ++vec3d2.b; - } - - j1 = (int) (vec3d2.c = (double) MathHelper.floor(vec3d.c)); - if (b0 == 3) - { - --j1; - ++vec3d2.c; - } - - Block block1 = this.getType(l, i1, j1); - int l1 = this.getData(l, i1, j1); - - if (!flag1 || block1.a(this, l, i1, j1) != null) - { - if (block1.a(l1, flag)) - { - MovingObjectPosition movingobjectposition2 = block1.a(this, l, i1, j1, vec3d, vec3d1); - - if (movingobjectposition2 != null) - { - return movingobjectposition2; - } - } - else - { - movingobjectposition1 = new MovingObjectPosition(l, i1, j1, b0, vec3d, false); - } - } - } - - return flag2 ? movingobjectposition1 : null; - } - else - { - return null; - } - } - else - { - return null; - } - } - - public void makeSound(Entity entity, String s, float f, float f1) - { - for (int i = 0; i < this.u.size(); ++i) - { - ((IWorldAccess) this.u.get(i)).a(s, entity.locX, entity.locY - (double) entity.height, entity.locZ, f, f1); - } - } - - public void a(EntityHuman entityhuman, String s, float f, float f1) - { - for (int i = 0; i < this.u.size(); ++i) - { - ((IWorldAccess) this.u.get(i)).a(entityhuman, s, entityhuman.locX, entityhuman.locY - - (double) entityhuman.height, entityhuman.locZ, f, f1); - } - } - - public void makeSound(double d0, double d1, double d2, String s, float f, float f1) - { - for (int i = 0; i < this.u.size(); ++i) - { - ((IWorldAccess) this.u.get(i)).a(s, d0, d1, d2, f, f1); - } - } - - public void a(double d0, double d1, double d2, String s, float f, float f1, boolean flag) - { - } - - public void a(String s, int i, int j, int k) - { - for (int l = 0; l < this.u.size(); ++l) - { - ((IWorldAccess) this.u.get(l)).a(s, i, j, k); - } - } - - public void addParticle(String s, double d0, double d1, double d2, double d3, double d4, double d5) - { - for (int i = 0; i < this.u.size(); ++i) - { - ((IWorldAccess) this.u.get(i)).a(s, d0, d1, d2, d3, d4, d5); - } - } - - public boolean strikeLightning(Entity entity) - { - this.i.add(entity); - return true; - } - - public boolean addEntity(Entity entity) - { - // CraftBukkit start - Used for entities other than creatures - return this.addEntity(entity, SpawnReason.DEFAULT); // Set reason as - // DEFAULT - } - - public boolean addEntity(Entity entity, SpawnReason spawnReason) - { // Changed signature, added SpawnReason - org.spigotmc.AsyncCatcher.catchOp("entity add"); // Spigot - if (entity == null) - return false; - // CraftBukkit end - - int i = MathHelper.floor(entity.locX / 16.0D); - int j = MathHelper.floor(entity.locZ / 16.0D); - boolean flag = entity.attachedToPlayer; - - if (entity instanceof EntityHuman) - { - flag = true; - } - - // CraftBukkit start - org.bukkit.event.Cancellable event = null; - if (entity instanceof EntityLiving && !(entity instanceof EntityPlayer)) - { - boolean isAnimal = entity instanceof EntityAnimal || entity instanceof EntityWaterAnimal - || entity instanceof EntityGolem; - boolean isMonster = entity instanceof EntityMonster || entity instanceof EntityGhast - || entity instanceof EntitySlime; - - if (spawnReason != SpawnReason.CUSTOM) - { - if (isAnimal && !allowAnimals || isMonster && !allowMonsters) - { - entity.dead = true; - return false; - } - } - - event = CraftEventFactory.callCreatureSpawnEvent((EntityLiving) entity, spawnReason); - } - else if (entity instanceof EntityItem) - { - event = CraftEventFactory.callItemSpawnEvent((EntityItem) entity); - } - else if (entity.getBukkitEntity() instanceof org.bukkit.entity.Projectile) - { - // Not all projectiles extend EntityProjectile, so check for Bukkit - // interface instead - event = CraftEventFactory.callProjectileLaunchEvent(entity); - } - // Spigot start - else if (entity instanceof EntityExperienceOrb) - { - EntityExperienceOrb xp = (EntityExperienceOrb) entity; - double radius = spigotConfig.expMerge; - if (radius > 0) - { - List entities = this.getEntities(entity, entity.boundingBox.grow(radius, radius, radius)); - for (Entity e : entities) - { - if (e instanceof EntityExperienceOrb) - { - EntityExperienceOrb loopItem = (EntityExperienceOrb) e; - if (!loopItem.dead) - { - xp.value += loopItem.value; - loopItem.die(); - } - } - } - } - } // Spigot end - - if (event != null && (event.isCancelled() || entity.dead)) - { - entity.dead = true; - return false; - } - // CraftBukkit end - - if (!flag && !this.isChunkLoaded(i, j)) - { - entity.dead = true; // CraftBukkit - return false; - } - else - { - if (entity instanceof EntityHuman) - { - EntityHuman entityhuman = (EntityHuman) entity; - - this.players.add(entityhuman); - this.everyoneSleeping(); - this.b(entity); - } - - this.getChunkAt(i, j).a(entity); - this.entityList.add(entity); - this.a(entity); - return true; - } - } - - protected void a(Entity entity) - { - for (int i = 0; i < this.u.size(); ++i) - { - ((IWorldAccess) this.u.get(i)).a(entity); - } - - entity.valid = true; // CraftBukkit - } - - protected void b(Entity entity) - { - for (int i = 0; i < this.u.size(); ++i) - { - ((IWorldAccess) this.u.get(i)).b(entity); - } - - entity.valid = false; // CraftBukkit - } - - public void kill(Entity entity) - { - if (entity.passenger != null) - { - entity.passenger.mount((Entity) null); - } - - if (entity.vehicle != null) - { - entity.mount((Entity) null); - } - - entity.die(); - if (entity instanceof EntityHuman) - { - this.players.remove(entity); - // Spigot start - for (Object o : worldMaps.c) - { - if (o instanceof WorldMap) - { - WorldMap map = (WorldMap) o; - map.i.remove(entity); - for (Iterator iter = (Iterator) map.f.iterator(); iter - .hasNext();) - { - if (iter.next().trackee == entity) - { - iter.remove(); - } - } - } - } - // Spigot end - this.everyoneSleeping(); - } - } - - public void removeEntity(Entity entity) - { - org.spigotmc.AsyncCatcher.catchOp("entity remove"); // Spigot - entity.die(); - if (entity instanceof EntityHuman) - { - this.players.remove(entity); - this.everyoneSleeping(); - } - // Spigot start - if (!guardEntityList) - { // It will get removed after the tick if we are ticking - int i = entity.ah; - int j = entity.aj; - if (entity.ag && this.isChunkLoaded(i, j)) - { - this.getChunkAt(i, j).b(entity); - } - // CraftBukkit start - Decrement loop variable field if we've - // already ticked this entity - int index = this.entityList.indexOf(entity); - if (index != -1) - { - if (index <= this.tickPosition) - { - this.tickPosition--; - } - this.entityList.remove(index); - } - // CraftBukkit end - } - // Spigot end - - this.b(entity); - } - - public void addIWorldAccess(IWorldAccess iworldaccess) - { - this.u.add(iworldaccess); - } - - public List getCubes(Entity entity, AxisAlignedBB axisalignedbb) - { - this.L.clear(); - int i = MathHelper.floor(axisalignedbb.a); - int j = MathHelper.floor(axisalignedbb.d + 1.0D); - int k = MathHelper.floor(axisalignedbb.b); - int l = MathHelper.floor(axisalignedbb.e + 1.0D); - int i1 = MathHelper.floor(axisalignedbb.c); - int j1 = MathHelper.floor(axisalignedbb.f + 1.0D); - - // Spigot start - int ystart = ((k - 1) < 0) ? 0 : (k - 1); - for (int chunkx = (i >> 4); chunkx <= ((j - 1) >> 4); chunkx++) - { - int cx = chunkx << 4; - for (int chunkz = (i1 >> 4); chunkz <= ((j1 - 1) >> 4); chunkz++) - { - if (!this.isChunkLoaded(chunkx, chunkz)) - { - continue; - } - int cz = chunkz << 4; - Chunk chunk = this.getChunkAt(chunkx, chunkz); - // Compute ranges within chunk - int xstart = (i < cx) ? cx : i; - int xend = (j < (cx + 16)) ? j : (cx + 16); - int zstart = (i1 < cz) ? cz : i1; - int zend = (j1 < (cz + 16)) ? j1 : (cz + 16); - // Loop through blocks within chunk - for (int x = xstart; x < xend; x++) - { - for (int z = zstart; z < zend; z++) - { - for (int y = ystart; y < l; y++) - { - Block block = chunk.getType(x - cx, y, z - cz); - if (block != null) - { - block.a(this, x, y, z, axisalignedbb, this.L, entity); - } - } - } - } - } - } - // Spigot end - - double d0 = 0.25D; - List list = this.getEntities(entity, axisalignedbb.grow(d0, d0, d0)); - - for (int j2 = 0; j2 < list.size(); ++j2) - { - AxisAlignedBB axisalignedbb1 = ((Entity) list.get(j2)).J(); - - if (axisalignedbb1 != null && axisalignedbb1.b(axisalignedbb)) - { - this.L.add(axisalignedbb1); - } - - axisalignedbb1 = entity.h((Entity) list.get(j2)); - if (axisalignedbb1 != null && axisalignedbb1.b(axisalignedbb)) - { - this.L.add(axisalignedbb1); - } - } - - return this.L; - } - - public List a(AxisAlignedBB axisalignedbb) - { - this.L.clear(); - int i = MathHelper.floor(axisalignedbb.a); - int j = MathHelper.floor(axisalignedbb.d + 1.0D); - int k = MathHelper.floor(axisalignedbb.b); - int l = MathHelper.floor(axisalignedbb.e + 1.0D); - int i1 = MathHelper.floor(axisalignedbb.c); - int j1 = MathHelper.floor(axisalignedbb.f + 1.0D); - - for (int k1 = i; k1 < j; ++k1) - { - for (int l1 = i1; l1 < j1; ++l1) - { - if (this.isLoaded(k1, 64, l1)) - { - for (int i2 = k - 1; i2 < l; ++i2) - { - Block block; - - if (k1 >= -30000000 && k1 < 30000000 && l1 >= -30000000 && l1 < 30000000) - { - block = this.getType(k1, i2, l1); - } - else - { - block = Blocks.BEDROCK; - } - - block.a(this, k1, i2, l1, axisalignedbb, this.L, (Entity) null); - } - } - } - } - - return this.L; - } - - public int a(float f) - { - float f1 = this.c(f); - float f2 = 1.0F - (MathHelper.cos(f1 * 3.1415927F * 2.0F) * 2.0F + 0.5F); - - if (f2 < 0.0F) - { - f2 = 0.0F; - } - - if (f2 > 1.0F) - { - f2 = 1.0F; - } - - f2 = 1.0F - f2; - f2 = (float) ((double) f2 * (1.0D - (double) (this.j(f) * 5.0F) / 16.0D)); - f2 = (float) ((double) f2 * (1.0D - (double) (this.h(f) * 5.0F) / 16.0D)); - f2 = 1.0F - f2; - return (int) (f2 * 11.0F); - } - - public float c(float f) - { - return this.worldProvider.a(this.worldData.getDayTime(), f); - } - - public float y() - { - return WorldProvider.a[this.worldProvider.a(this.worldData.getDayTime())]; - } - - public float d(float f) - { - float f1 = this.c(f); - - return f1 * 3.1415927F * 2.0F; - } - - public int h(int i, int j) - { - return this.getChunkAtWorldCoords(i, j).d(i & 15, j & 15); - } - - public int i(int i, int j) - { - Chunk chunk = this.getChunkAtWorldCoords(i, j); - int k = chunk.h() + 15; - - i &= 15; - - for (j &= 15; k > 0; --k) - { - Block block = chunk.getType(i, k, j); - - if (block.getMaterial().isSolid() && block.getMaterial() != Material.LEAVES) - { - return k + 1; - } - } - - return -1; - } - - public void a(int i, int j, int k, Block block, int l) - { - } - - public void a(int i, int j, int k, Block block, int l, int i1) - { - } - - public void b(int i, int j, int k, Block block, int l, int i1) - { - } - - public void tickEntities() - { - this.methodProfiler.a("entities"); - this.methodProfiler.a("global"); - - int i; - Entity entity; - CrashReport crashreport; - CrashReportSystemDetails crashreportsystemdetails; - - for (i = 0; i < this.i.size(); ++i) - { - entity = (Entity) this.i.get(i); - // CraftBukkit start - Fixed an NPE - if (entity == null) - { - continue; - } - // CraftBukkit end - - try - { - ++entity.ticksLived; - entity.h(); - } - catch (Throwable throwable) - { - crashreport = CrashReport.a(throwable, "Ticking entity"); - crashreportsystemdetails = crashreport.a("Entity being ticked"); - if (entity == null) - { - crashreportsystemdetails.a("Entity", "~~NULL~~"); - } - else - { - entity.a(crashreportsystemdetails); - } - - throw new ReportedException(crashreport); - } - - if (entity.dead) - { - this.i.remove(i--); - } - } - - this.methodProfiler.c("remove"); - this.entityList.removeAll(this.f); - - int j; - int k; - - for (i = 0; i < this.f.size(); ++i) - { - entity = (Entity) this.f.get(i); - j = entity.ah; - k = entity.aj; - if (entity.ag && this.isChunkLoaded(j, k)) - { - this.getChunkAt(j, k).b(entity); - } - } - - for (i = 0; i < this.f.size(); ++i) - { - this.b((Entity) this.f.get(i)); - } - - this.f.clear(); - this.methodProfiler.c("regular"); - - org.spigotmc.ActivationRange.activateEntities(this); // Spigot - timings.entityTick.startTiming(); // Spigot - guardEntityList = true; // Spigot - // CraftBukkit start - Use field for loop variable - for (this.tickPosition = 0; this.tickPosition < this.entityList.size(); ++this.tickPosition) - { - entity = (Entity) this.entityList.get(this.tickPosition); - if (entity.vehicle != null) - { - if (!entity.vehicle.dead && entity.vehicle.passenger == entity) - { - continue; - } - - entity.vehicle.passenger = null; - entity.vehicle = null; - } - - this.methodProfiler.a("tick"); - if (!entity.dead) - { - try - { - SpigotTimings.tickEntityTimer.startTiming(); // Spigot - this.playerJoinedWorld(entity); - SpigotTimings.tickEntityTimer.stopTiming(); // Spigot - } - catch (Throwable throwable1) - { - crashreport = CrashReport.a(throwable1, "Ticking entity"); - crashreportsystemdetails = crashreport.a("Entity being ticked"); - entity.a(crashreportsystemdetails); - throw new ReportedException(crashreport); - } - } - - this.methodProfiler.b(); - this.methodProfiler.a("remove"); - if (entity.dead) - { - j = entity.ah; - k = entity.aj; - if (entity.ag && this.isChunkLoaded(j, k)) - { - this.getChunkAt(j, k).b(entity); - } - - guardEntityList = false; // Spigot - this.entityList.remove(this.tickPosition--); // CraftBukkit - - // Use field for - // loop variable - guardEntityList = true; // Spigot - this.b(entity); - } - - this.methodProfiler.b(); - } - guardEntityList = false; // Spigot - - timings.entityTick.stopTiming(); // Spigot - this.methodProfiler.c("blockEntities"); - timings.tileEntityTick.startTiming(); // Spigot - this.M = true; - // CraftBukkit start - From below, clean up tile entities before ticking - // them - if (!this.b.isEmpty()) - { - this.tileEntityList.removeAll(this.b); - this.b.clear(); - } - // Spigot End - - this.initializeHoppers(); // Spigot - Initializes hoppers which have - // been added recently. - Iterator iterator = this.tileEntityList.iterator(); - - while (iterator.hasNext()) - { - TileEntity tileentity = (TileEntity) iterator.next(); - // Spigot start - if (tileentity == null) - { - getServer().getLogger().severe( - "Spigot has detected a null entity and has removed it, preventing a crash"); - iterator.remove(); - continue; - } - // Spigot end - - if (!tileentity.r() && tileentity.o() && this.isLoaded(tileentity.x, tileentity.y, tileentity.z)) - { - try - { - tileentity.tickTimer.startTiming(); // Spigot - tileentity.h(); - tileentity.tickTimer.stopTiming(); // Spigot - } - catch (Throwable throwable2) - { - tileentity.tickTimer.stopTiming(); // Spigot - crashreport = CrashReport.a(throwable2, "Ticking block entity"); - crashreportsystemdetails = crashreport.a("Block entity being ticked"); - tileentity.a(crashreportsystemdetails); - throw new ReportedException(crashreport); - } - } - - if (tileentity.r()) - { - iterator.remove(); - if (this.isChunkLoaded(tileentity.x >> 4, tileentity.z >> 4)) - { - Chunk chunk = this.getChunkAt(tileentity.x >> 4, tileentity.z >> 4); - - if (chunk != null) - { - chunk.f(tileentity.x & 15, tileentity.y, tileentity.z & 15); - } - } - } - } - - timings.tileEntityTick.stopTiming(); // Spigot - timings.tileEntityPending.startTiming(); // Spigot - this.M = false; - /* - * CraftBukkit start - Moved up if (!this.b.isEmpty()) { - * this.tileEntityList.removeAll(this.b); this.b.clear(); } - */// CraftBukkit end - - this.methodProfiler.c("pendingBlockEntities"); - if (!this.a.isEmpty()) - { - for (int l = 0; l < this.a.size(); ++l) - { - TileEntity tileentity1 = (TileEntity) this.a.get(l); - - if (!tileentity1.r()) - { - /* - * CraftBukkit start - Order matters, moved down if - * (!this.tileEntityList.contains(tileentity1)) { - * this.tileEntityList.add(tileentity1); } // CraftBukkit - * end - */ - - if (this.isChunkLoaded(tileentity1.x >> 4, tileentity1.z >> 4)) - { - Chunk chunk1 = this.getChunkAt(tileentity1.x >> 4, tileentity1.z >> 4); - - if (chunk1 != null) - { - chunk1.a(tileentity1.x & 15, tileentity1.y, tileentity1.z & 15, tileentity1); - // CraftBukkit start - Moved down from above - if (!this.tileEntityList.contains(tileentity1)) - { - this.tileEntityList.add(tileentity1); - } - // CraftBukkit end - } - } - - this.notify(tileentity1.x, tileentity1.y, tileentity1.z); - } - } - - this.a.clear(); - } - - timings.tileEntityPending.stopTiming(); // Spigot - this.methodProfiler.b(); - this.methodProfiler.b(); - } - - public void a(Collection collection) - { - if (this.M) - { - this.a.addAll(collection); - } - else - { - this.tileEntityList.addAll(collection); - } - } - - public void playerJoinedWorld(Entity entity) - { - this.entityJoinedWorld(entity, true); - } - - public void entityJoinedWorld(Entity entity, boolean flag) - { - int i = MathHelper.floor(entity.locX); - int j = MathHelper.floor(entity.locZ); - byte b0 = 32; - - // Spigot start - if (!org.spigotmc.ActivationRange.checkIfActive(entity)) - { - entity.ticksLived++; - entity.inactiveTick(); - } - else - { - entity.tickTimer.startTiming(); // Spigot - // CraftBukkit end - entity.S = entity.locX; - entity.T = entity.locY; - entity.U = entity.locZ; - entity.lastYaw = entity.yaw; - entity.lastPitch = entity.pitch; - if (flag && entity.ag) - { - ++entity.ticksLived; - if (entity.vehicle != null) - { - entity.ab(); - } - else - { - entity.h(); - } - } - - this.methodProfiler.a("chunkCheck"); - if (Double.isNaN(entity.locX) || Double.isInfinite(entity.locX)) - { - entity.locX = entity.S; - } - - if (Double.isNaN(entity.locY) || Double.isInfinite(entity.locY)) - { - entity.locY = entity.T; - } - - if (Double.isNaN(entity.locZ) || Double.isInfinite(entity.locZ)) - { - entity.locZ = entity.U; - } - - if (Double.isNaN((double) entity.pitch) || Double.isInfinite((double) entity.pitch)) - { - entity.pitch = entity.lastPitch; - } - - if (Double.isNaN((double) entity.yaw) || Double.isInfinite((double) entity.yaw)) - { - entity.yaw = entity.lastYaw; - } - - int k = MathHelper.floor(entity.locX / 16.0D); - int l = MathHelper.floor(entity.locY / 16.0D); - int i1 = MathHelper.floor(entity.locZ / 16.0D); - - if (!entity.ag || entity.ah != k || entity.ai != l || entity.aj != i1) - { - if (entity.ag && this.isChunkLoaded(entity.ah, entity.aj)) - { - this.getChunkAt(entity.ah, entity.aj).a(entity, entity.ai); - } - - if (this.isChunkLoaded(k, i1)) - { - entity.ag = true; - this.getChunkAt(k, i1).a(entity); - } - else - { - entity.ag = false; - } - } - - this.methodProfiler.b(); - if (flag && entity.ag && 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 - - } - } - - public boolean b(AxisAlignedBB axisalignedbb) - { - return this.a(axisalignedbb, (Entity) null); - } - - public boolean a(AxisAlignedBB axisalignedbb, Entity entity) - { - List list = this.getEntities((Entity) null, axisalignedbb); - - for (int i = 0; i < list.size(); ++i) - { - Entity entity1 = (Entity) list.get(i); - - if (!entity1.dead && entity1.k && entity1 != entity) - { - return false; - } - } - - return true; - } - - public boolean c(AxisAlignedBB axisalignedbb) - { - int i = MathHelper.floor(axisalignedbb.a); - int j = MathHelper.floor(axisalignedbb.d + 1.0D); - int k = MathHelper.floor(axisalignedbb.b); - int l = MathHelper.floor(axisalignedbb.e + 1.0D); - int i1 = MathHelper.floor(axisalignedbb.c); - int j1 = MathHelper.floor(axisalignedbb.f + 1.0D); - - if (axisalignedbb.a < 0.0D) - { - --i; - } - - if (axisalignedbb.b < 0.0D) - { - --k; - } - - if (axisalignedbb.c < 0.0D) - { - --i1; - } - - for (int k1 = i; k1 < j; ++k1) - { - for (int l1 = k; l1 < l; ++l1) - { - for (int i2 = i1; i2 < j1; ++i2) - { - Block block = this.getType(k1, l1, i2); - - if (block.getMaterial() != Material.AIR) - { - return true; - } - } - } - } - - return false; - } - - public boolean containsLiquid(AxisAlignedBB axisalignedbb) - { - int i = MathHelper.floor(axisalignedbb.a); - int j = MathHelper.floor(axisalignedbb.d + 1.0D); - int k = MathHelper.floor(axisalignedbb.b); - int l = MathHelper.floor(axisalignedbb.e + 1.0D); - int i1 = MathHelper.floor(axisalignedbb.c); - int j1 = MathHelper.floor(axisalignedbb.f + 1.0D); - - if (axisalignedbb.a < 0.0D) - { - --i; - } - - if (axisalignedbb.b < 0.0D) - { - --k; - } - - if (axisalignedbb.c < 0.0D) - { - --i1; - } - - for (int k1 = i; k1 < j; ++k1) - { - for (int l1 = k; l1 < l; ++l1) - { - for (int i2 = i1; i2 < j1; ++i2) - { - Block block = this.getType(k1, l1, i2); - - if (block.getMaterial().isLiquid()) - { - return true; - } - } - } - } - - return false; - } - - public boolean e(AxisAlignedBB axisalignedbb) - { - int i = MathHelper.floor(axisalignedbb.a); - int j = MathHelper.floor(axisalignedbb.d + 1.0D); - int k = MathHelper.floor(axisalignedbb.b); - int l = MathHelper.floor(axisalignedbb.e + 1.0D); - int i1 = MathHelper.floor(axisalignedbb.c); - int j1 = MathHelper.floor(axisalignedbb.f + 1.0D); - - if (this.b(i, k, i1, j, l, j1)) - { - for (int k1 = i; k1 < j; ++k1) - { - for (int l1 = k; l1 < l; ++l1) - { - for (int i2 = i1; i2 < j1; ++i2) - { - Block block = this.getType(k1, l1, i2); - - if (block == Blocks.FIRE || block == Blocks.LAVA || block == Blocks.STATIONARY_LAVA) - { - return true; - } - } - } - } - } - - return false; - } - - public boolean a(AxisAlignedBB axisalignedbb, Material material, Entity entity) - { - int i = MathHelper.floor(axisalignedbb.a); - int j = MathHelper.floor(axisalignedbb.d + 1.0D); - int k = MathHelper.floor(axisalignedbb.b); - int l = MathHelper.floor(axisalignedbb.e + 1.0D); - int i1 = MathHelper.floor(axisalignedbb.c); - int j1 = MathHelper.floor(axisalignedbb.f + 1.0D); - - if (!this.b(i, k, i1, j, l, j1)) - { - return false; - } - else - { - boolean flag = false; - Vec3D vec3d = Vec3D.a(0.0D, 0.0D, 0.0D); - - for (int k1 = i; k1 < j; ++k1) - { - for (int l1 = k; l1 < l; ++l1) - { - for (int i2 = i1; i2 < j1; ++i2) - { - Block block = this.getType(k1, l1, i2); - - if (block.getMaterial() == material) - { - double d0 = (double) ((float) (l1 + 1) - BlockFluids.b(this.getData(k1, l1, i2))); - - if ((double) l >= d0) - { - flag = true; - block.a(this, k1, l1, i2, entity, vec3d); - } - } - } - } - } - - if (vec3d.b() > 0.0D && entity.aC()) - { - vec3d = vec3d.a(); - double d1 = 0.014D; - - entity.motX += vec3d.a * d1; - entity.motY += vec3d.b * d1; - entity.motZ += vec3d.c * d1; - } - - return flag; - } - } - - public boolean a(AxisAlignedBB axisalignedbb, Material material) - { - int i = MathHelper.floor(axisalignedbb.a); - int j = MathHelper.floor(axisalignedbb.d + 1.0D); - int k = MathHelper.floor(axisalignedbb.b); - int l = MathHelper.floor(axisalignedbb.e + 1.0D); - int i1 = MathHelper.floor(axisalignedbb.c); - int j1 = MathHelper.floor(axisalignedbb.f + 1.0D); - - for (int k1 = i; k1 < j; ++k1) - { - for (int l1 = k; l1 < l; ++l1) - { - for (int i2 = i1; i2 < j1; ++i2) - { - if (this.getType(k1, l1, i2).getMaterial() == material) - { - return true; - } - } - } - } - - return false; - } - - public boolean b(AxisAlignedBB axisalignedbb, Material material) - { - int i = MathHelper.floor(axisalignedbb.a); - int j = MathHelper.floor(axisalignedbb.d + 1.0D); - int k = MathHelper.floor(axisalignedbb.b); - int l = MathHelper.floor(axisalignedbb.e + 1.0D); - int i1 = MathHelper.floor(axisalignedbb.c); - int j1 = MathHelper.floor(axisalignedbb.f + 1.0D); - - for (int k1 = i; k1 < j; ++k1) - { - for (int l1 = k; l1 < l; ++l1) - { - for (int i2 = i1; i2 < j1; ++i2) - { - Block block = this.getType(k1, l1, i2); - - if (block.getMaterial() == material) - { - int j2 = this.getData(k1, l1, i2); - double d0 = (double) (l1 + 1); - - if (j2 < 8) - { - d0 = (double) (l1 + 1) - (double) j2 / 8.0D; - } - - if (d0 >= axisalignedbb.b) - { - return true; - } - } - } - } - } - - return false; - } - - public Explosion explode(Entity entity, double d0, double d1, double d2, float f, boolean flag) - { - return this.createExplosion(entity, d0, d1, d2, f, false, flag); - } - - public Explosion createExplosion(Entity entity, double d0, double d1, double d2, float f, boolean flag, - boolean flag1) - { - Explosion explosion = new Explosion(this, entity, d0, d1, d2, f); - - explosion.a = flag; - explosion.b = flag1; - explosion.a(); - explosion.a(true); - return explosion; - } - - public float a(Vec3D vec3d, AxisAlignedBB axisalignedbb) - { - double d0 = 1.0D / ((axisalignedbb.d - axisalignedbb.a) * 2.0D + 1.0D); - double d1 = 1.0D / ((axisalignedbb.e - axisalignedbb.b) * 2.0D + 1.0D); - double d2 = 1.0D / ((axisalignedbb.f - axisalignedbb.c) * 2.0D + 1.0D); - - if (d0 >= 0.0D && d1 >= 0.0D && d2 >= 0.0D) - { - int i = 0; - int j = 0; - - Vec3D vec3d2 = vec3d.a(0, 0, 0); // CraftBukkit - for (float f = 0.0F; f <= 1.0F; f = (float) ((double) f + d0)) - { - for (float f1 = 0.0F; f1 <= 1.0F; f1 = (float) ((double) f1 + d1)) - { - for (float f2 = 0.0F; f2 <= 1.0F; f2 = (float) ((double) f2 + d2)) - { - double d3 = axisalignedbb.a + (axisalignedbb.d - axisalignedbb.a) * (double) f; - double d4 = axisalignedbb.b + (axisalignedbb.e - axisalignedbb.b) * (double) f1; - double d5 = axisalignedbb.c + (axisalignedbb.f - axisalignedbb.c) * (double) f2; - - if (this.a(vec3d2.b(d3, d4, d5), vec3d) == null) - { // CraftBukkit - ++i; - } - - ++j; - } - } - } - - return (float) i / (float) j; - } - else - { - return 0.0F; - } - } - - public boolean douseFire(EntityHuman entityhuman, int i, int j, int k, int l) - { - if (l == 0) - { - --j; - } - - if (l == 1) - { - ++j; - } - - if (l == 2) - { - --k; - } - - if (l == 3) - { - ++k; - } - - if (l == 4) - { - --i; - } - - if (l == 5) - { - ++i; - } - - if (this.getType(i, j, k) == Blocks.FIRE) - { - this.a(entityhuman, 1004, i, j, k, 0); - this.setAir(i, j, k); - return true; - } - else - { - return false; - } - } - - public TileEntity getTileEntity(int i, int j, int k) - { - if (j >= 0 && j < 256) - { - TileEntity tileentity = null; - int l; - TileEntity tileentity1; - - if (this.M) - { - for (l = 0; l < this.a.size(); ++l) - { - tileentity1 = (TileEntity) this.a.get(l); - if (!tileentity1.r() && tileentity1.x == i && tileentity1.y == j && tileentity1.z == k) - { - tileentity = tileentity1; - break; - } - } - } - - if (tileentity == null) - { - Chunk chunk = this.getChunkAt(i >> 4, k >> 4); - - if (chunk != null) - { - tileentity = chunk.e(i & 15, j, k & 15); - } - } - - if (tileentity == null) - { - for (l = 0; l < this.a.size(); ++l) - { - tileentity1 = (TileEntity) this.a.get(l); - if (!tileentity1.r() && tileentity1.x == i && tileentity1.y == j && tileentity1.z == k) - { - tileentity = tileentity1; - break; - } - } - } - - return tileentity; - } - else - { - return null; - } - } - - public void setTileEntity(int i, int j, int k, TileEntity tileentity) - { - if (tileentity != null && !tileentity.r()) - { - if (this.M) - { - tileentity.x = i; - tileentity.y = j; - tileentity.z = k; - Iterator iterator = this.a.iterator(); - - while (iterator.hasNext()) - { - TileEntity tileentity1 = (TileEntity) iterator.next(); - - if (tileentity1.x == i && tileentity1.y == j && tileentity1.z == k) - { - tileentity1.s(); - iterator.remove(); - } - } - - tileentity.a(this); // Spigot - No null worlds - this.a.add(tileentity); - } - else - { - this.tileEntityList.add(tileentity); - Chunk chunk = this.getChunkAt(i >> 4, k >> 4); - - if (chunk != null) - { - chunk.a(i & 15, j, k & 15, tileentity); - } - } - } - } - - public void p(int i, int j, int k) - { - TileEntity tileentity = this.getTileEntity(i, j, k); - - if (tileentity != null && this.M) - { - tileentity.s(); - this.a.remove(tileentity); - } - else - { - if (tileentity != null) - { - this.a.remove(tileentity); - this.tileEntityList.remove(tileentity); - } - - Chunk chunk = this.getChunkAt(i >> 4, k >> 4); - - if (chunk != null) - { - chunk.f(i & 15, j, k & 15); - } - } - } - - public void a(TileEntity tileentity) - { - this.b.add(tileentity); - } - - public boolean q(int i, int j, int k) - { - AxisAlignedBB axisalignedbb = this.getType(i, j, k).a(this, i, j, k); - - return axisalignedbb != null && axisalignedbb.a() >= 1.0D; - } - - public static boolean a(IBlockAccess iblockaccess, int i, int j, int k) - { - Block block = iblockaccess.getType(i, j, k); - int l = iblockaccess.getData(i, j, k); - - return block.getMaterial().k() && block.d() ? true : (block instanceof BlockStairs ? (l & 4) == 4 - : (block instanceof BlockStepAbstract ? (l & 8) == 8 : (block instanceof BlockHopper ? true - : (block instanceof BlockSnow ? (l & 7) == 7 : false)))); - } - - public boolean c(int i, int j, int k, boolean flag) - { - if (i >= -30000000 && k >= -30000000 && i < 30000000 && k < 30000000) - { - Chunk chunk = this.chunkProvider.getOrCreateChunk(i >> 4, k >> 4); - - if (chunk != null && !chunk.isEmpty()) - { - Block block = this.getType(i, j, k); - - return block.getMaterial().k() && block.d(); - } - else - { - return flag; - } - } - else - { - return flag; - } - } - - public void B() - { - int i = this.a(1.0F); - - if (i != this.j) - { - this.j = i; - } - } - - public void setSpawnFlags(boolean flag, boolean flag1) - { - this.allowMonsters = flag; - this.allowAnimals = flag1; - } - - public void doTick() - { - this.o(); - } - - private void a() - { - if (this.worldData.hasStorm()) - { - this.n = 1.0F; - if (this.worldData.isThundering()) - { - this.p = 1.0F; - } - } - } - - protected void o() - { - if (!this.worldProvider.g) - { - if (!this.isStatic) - { - int i = this.worldData.getThunderDuration(); - - if (i <= 0) - { - if (this.worldData.isThundering()) - { - this.worldData.setThunderDuration(this.random.nextInt(12000) + 3600); - } - else - { - this.worldData.setThunderDuration(this.random.nextInt(168000) + 12000); - } - } - else - { - --i; - this.worldData.setThunderDuration(i); - if (i <= 0) - { - // CraftBukkit start - ThunderChangeEvent thunder = new ThunderChangeEvent(this.getWorld(), - !this.worldData.isThundering()); - this.getServer().getPluginManager().callEvent(thunder); - if (!thunder.isCancelled()) - { - this.worldData.setThundering(!this.worldData.isThundering()); - } - // CraftBukkit end - } - } - - this.o = this.p; - if (this.worldData.isThundering()) - { - this.p = (float) ((double) this.p + 0.01D); - } - else - { - this.p = (float) ((double) this.p - 0.01D); - } - - this.p = MathHelper.a(this.p, 0.0F, 1.0F); - int j = this.worldData.getWeatherDuration(); - - if (j <= 0) - { - if (this.worldData.hasStorm()) - { - this.worldData.setWeatherDuration(this.random.nextInt(12000) + 12000); - } - else - { - this.worldData.setWeatherDuration(this.random.nextInt(168000) + 12000); - } - } - else - { - --j; - this.worldData.setWeatherDuration(j); - if (j <= 0) - { - // CraftBukkit start - WeatherChangeEvent weather = new WeatherChangeEvent(this.getWorld(), !this.worldData.hasStorm()); - this.getServer().getPluginManager().callEvent(weather); - - if (!weather.isCancelled()) - { - this.worldData.setStorm(!this.worldData.hasStorm()); - } - // CraftBukkit end - } - } - - this.m = this.n; - if (this.worldData.hasStorm()) - { - this.n = (float) ((double) this.n + 0.01D); - } - else - { - this.n = (float) ((double) this.n - 0.01D); - } - - this.n = MathHelper.a(this.n, 0.0F, 1.0F); - } - } - } - - protected void C() - { - // this.chunkTickList.clear(); // CraftBukkit - removed - this.methodProfiler.a("buildList"); - - int i; - EntityHuman entityhuman; - int j; - int k; - int l; - - // Spigot start - int optimalChunks = spigotConfig.chunksPerTick; - // Quick conditions to allow us to exist early - if (optimalChunks <= 0 || players.isEmpty()) - { - return; - } - // Keep chunks with growth inside of the optimal chunk range - int chunksPerPlayer = Math.min(200, - Math.max(1, (int) (((optimalChunks - players.size()) / (double) players.size()) + 0.5))); - int randRange = 3 + chunksPerPlayer / 30; - // Limit to normal tick radius - including view distance - randRange = (randRange > chunkTickRadius) ? chunkTickRadius : randRange; - // odds of growth happening vs growth happening in vanilla - this.growthOdds = this.modifiedOdds = Math.max(35, Math.min(100, ((chunksPerPlayer + 1) * 100F) / 15F)); - // Spigot end - for (i = 0; i < this.players.size(); ++i) - { - entityhuman = (EntityHuman) this.players.get(i); - j = MathHelper.floor(entityhuman.locX / 16.0D); - k = MathHelper.floor(entityhuman.locZ / 16.0D); - l = this.p(); - - // Spigot start - Always update the chunk the player is on - long key = chunkToKey(j, k); - int existingPlayers = Math.max(0, chunkTickList.get(key)); // filter - // out - // -1 - chunkTickList.put(key, (short) (existingPlayers + 1)); - - // Check and see if we update the chunks surrounding the player this - // tick - for (int chunk = 0; chunk < chunksPerPlayer; chunk++) - { - int dx = (random.nextBoolean() ? 1 : -1) * random.nextInt(randRange); - int dz = (random.nextBoolean() ? 1 : -1) * random.nextInt(randRange); - long hash = chunkToKey(dx + j, dz + k); - if (!chunkTickList.contains(hash) && this.isChunkLoaded(dx + j, dz + k)) - { - chunkTickList.put(hash, (short) -1); // no players - } - } - // Spigot End - } - - this.methodProfiler.b(); - if (this.K > 0) - { - --this.K; - } - - this.methodProfiler.a("playerCheckLight"); - if (spigotConfig.randomLightUpdates && !this.players.isEmpty()) - { // Spigot - i = this.random.nextInt(this.players.size()); - entityhuman = (EntityHuman) this.players.get(i); - j = MathHelper.floor(entityhuman.locX) + this.random.nextInt(11) - 5; - k = MathHelper.floor(entityhuman.locY) + this.random.nextInt(11) - 5; - l = MathHelper.floor(entityhuman.locZ) + this.random.nextInt(11) - 5; - this.t(j, k, l); - } - - this.methodProfiler.b(); - } - - protected abstract int p(); - - protected void a(int i, int j, Chunk chunk) - { - this.methodProfiler.c("moodSound"); - if (this.K == 0 && !this.isStatic) - { - this.k = this.k * 3 + 1013904223; - int k = this.k >> 2; - int l = k & 15; - int i1 = k >> 8 & 15; - int j1 = k >> 16 & 255; - Block block = chunk.getType(l, j1, i1); - - l += i; - i1 += j; - if (block.getMaterial() == Material.AIR && this.j(l, j1, i1) <= this.random.nextInt(8) - && this.b(EnumSkyBlock.SKY, l, j1, i1) <= 0) - { - EntityHuman entityhuman = this.findNearbyPlayer((double) l + 0.5D, (double) j1 + 0.5D, - (double) i1 + 0.5D, 8.0D); - - if (entityhuman != null - && entityhuman.e((double) l + 0.5D, (double) j1 + 0.5D, (double) i1 + 0.5D) > 4.0D) - { - this.makeSound((double) l + 0.5D, (double) j1 + 0.5D, (double) i1 + 0.5D, "ambient.cave.cave", - 0.7F, 0.8F + this.random.nextFloat() * 0.2F); - this.K = this.random.nextInt(12000) + 6000; - } - } - } - - this.methodProfiler.c("checkLight"); - chunk.o(); - } - - protected void g() - { - this.C(); - } - - public boolean r(int i, int j, int k) - { - return this.d(i, j, k, false); - } - - public boolean s(int i, int j, int k) - { - return this.d(i, j, k, true); - } - - public boolean d(int i, int j, int k, boolean flag) - { - BiomeBase biomebase = this.getBiome(i, k); - float f = biomebase.a(i, j, k); - - if (f > 0.15F) - { - return false; - } - else - { - if (j >= 0 && j < 256 && this.b(EnumSkyBlock.BLOCK, i, j, k) < 10) - { - Block block = this.getType(i, j, k); - - if ((block == Blocks.STATIONARY_WATER || block == Blocks.WATER) && this.getData(i, j, k) == 0) - { - if (!flag) - { - return true; - } - - boolean flag1 = true; - - if (flag1 && this.getType(i - 1, j, k).getMaterial() != Material.WATER) - { - flag1 = false; - } - - if (flag1 && this.getType(i + 1, j, k).getMaterial() != Material.WATER) - { - flag1 = false; - } - - if (flag1 && this.getType(i, j, k - 1).getMaterial() != Material.WATER) - { - flag1 = false; - } - - if (flag1 && this.getType(i, j, k + 1).getMaterial() != Material.WATER) - { - flag1 = false; - } - - if (!flag1) - { - return true; - } - } - } - - return false; - } - } - - public boolean e(int i, int j, int k, boolean flag) - { - BiomeBase biomebase = this.getBiome(i, k); - float f = biomebase.a(i, j, k); - - if (f > 0.15F) - { - return false; - } - else if (!flag) - { - return true; - } - else - { - if (j >= 0 && j < 256 && this.b(EnumSkyBlock.BLOCK, i, j, k) < 10) - { - Block block = this.getType(i, j, k); - - if (block.getMaterial() == Material.AIR && Blocks.SNOW.canPlace(this, i, j, k)) - { - return true; - } - } - - return false; - } - } - - public boolean t(int i, int j, int k) - { - boolean flag = false; - - if (!this.worldProvider.g) - { - flag |= this.c(EnumSkyBlock.SKY, i, j, k); - } - - flag |= this.c(EnumSkyBlock.BLOCK, i, j, k); - return flag; - } - - private int a(int i, int j, int k, EnumSkyBlock enumskyblock) - { - if (enumskyblock == EnumSkyBlock.SKY && this.i(i, j, k)) - { - return 15; - } - else - { - Block block = this.getType(i, j, k); - int l = enumskyblock == EnumSkyBlock.SKY ? 0 : block.m(); - int i1 = block.k(); - - if (i1 >= 15 && block.m() > 0) - { - i1 = 1; - } - - if (i1 < 1) - { - i1 = 1; - } - - if (i1 >= 15) - { - return 0; - } - else if (l >= 14) - { - return l; - } - else - { - for (int j1 = 0; j1 < 6; ++j1) - { - int k1 = i + Facing.b[j1]; - int l1 = j + Facing.c[j1]; - int i2 = k + Facing.d[j1]; - int j2 = this.b(enumskyblock, k1, l1, i2) - i1; - - if (j2 > l) - { - l = j2; - } - - if (l >= 14) - { - return l; - } - } - - return l; - } - } - } - - public boolean c(EnumSkyBlock enumskyblock, int i, int j, int k) - { - // CraftBukkit start - Use neighbor cache instead of looking up - Chunk chunk = this.getChunkIfLoaded(i >> 4, k >> 4); - if (chunk == null || !chunk.areNeighborsLoaded(1) /* - * !this.areChunksLoaded( - * i, j, k, 17) - */) - { - // CraftBukkit end - return false; - } - else - { - int l = 0; - int i1 = 0; - - this.methodProfiler.a("getBrightness"); - int j1 = this.b(enumskyblock, i, j, k); - int k1 = this.a(i, j, k, enumskyblock); - int l1; - int i2; - int j2; - int k2; - int l2; - int i3; - int j3; - int k3; - int l3; - - if (k1 > j1) - { - this.I[i1++] = 133152; - } - else if (k1 < j1) - { - this.I[i1++] = 133152 | j1 << 18; - - while (l < i1) - { - l1 = this.I[l++]; - i2 = (l1 & 63) - 32 + i; - j2 = (l1 >> 6 & 63) - 32 + j; - k2 = (l1 >> 12 & 63) - 32 + k; - l2 = l1 >> 18 & 15; - i3 = this.b(enumskyblock, i2, j2, k2); - if (i3 == l2) - { - this.b(enumskyblock, i2, j2, k2, 0); - if (l2 > 0) - { - j3 = MathHelper.a(i2 - i); - l3 = MathHelper.a(j2 - j); - k3 = MathHelper.a(k2 - k); - if (j3 + l3 + k3 < 17) - { - for (int i4 = 0; i4 < 6; ++i4) - { - int j4 = i2 + Facing.b[i4]; - int k4 = j2 + Facing.c[i4]; - int l4 = k2 + Facing.d[i4]; - int i5 = Math.max(1, this.getType(j4, k4, l4).k()); - - i3 = this.b(enumskyblock, j4, k4, l4); - if (i3 == l2 - i5 && i1 < this.I.length) - { - this.I[i1++] = j4 - i + 32 | k4 - j + 32 << 6 | l4 - k + 32 << 12 - | l2 - i5 << 18; - } - } - } - } - } - } - - l = 0; - } - - this.methodProfiler.b(); - this.methodProfiler.a("checkedPosition < toCheckCount"); - - while (l < i1) - { - l1 = this.I[l++]; - i2 = (l1 & 63) - 32 + i; - j2 = (l1 >> 6 & 63) - 32 + j; - k2 = (l1 >> 12 & 63) - 32 + k; - l2 = this.b(enumskyblock, i2, j2, k2); - i3 = this.a(i2, j2, k2, enumskyblock); - if (i3 != l2) - { - this.b(enumskyblock, i2, j2, k2, i3); - if (i3 > l2) - { - j3 = Math.abs(i2 - i); - l3 = Math.abs(j2 - j); - k3 = Math.abs(k2 - k); - boolean flag = i1 < this.I.length - 6; - - if (j3 + l3 + k3 < 17 && flag) - { - if (this.b(enumskyblock, i2 - 1, j2, k2) < i3) - { - this.I[i1++] = i2 - 1 - i + 32 + (j2 - j + 32 << 6) + (k2 - k + 32 << 12); - } - - if (this.b(enumskyblock, i2 + 1, j2, k2) < i3) - { - this.I[i1++] = i2 + 1 - i + 32 + (j2 - j + 32 << 6) + (k2 - k + 32 << 12); - } - - if (this.b(enumskyblock, i2, j2 - 1, k2) < i3) - { - this.I[i1++] = i2 - i + 32 + (j2 - 1 - j + 32 << 6) + (k2 - k + 32 << 12); - } - - if (this.b(enumskyblock, i2, j2 + 1, k2) < i3) - { - this.I[i1++] = i2 - i + 32 + (j2 + 1 - j + 32 << 6) + (k2 - k + 32 << 12); - } - - if (this.b(enumskyblock, i2, j2, k2 - 1) < i3) - { - this.I[i1++] = i2 - i + 32 + (j2 - j + 32 << 6) + (k2 - 1 - k + 32 << 12); - } - - if (this.b(enumskyblock, i2, j2, k2 + 1) < i3) - { - this.I[i1++] = i2 - i + 32 + (j2 - j + 32 << 6) + (k2 + 1 - k + 32 << 12); - } - } - } - } - } - - this.methodProfiler.b(); - return true; - } - } - - public boolean a(boolean flag) - { - return false; - } - - public List a(Chunk chunk, boolean flag) - { - return null; - } - - public List getEntities(Entity entity, AxisAlignedBB axisalignedbb) - { - return this.getEntities(entity, axisalignedbb, (IEntitySelector) null); - } - - public List getEntities(Entity entity, AxisAlignedBB axisalignedbb, IEntitySelector ientityselector) - { - ArrayList arraylist = new ArrayList(); - int i = MathHelper.floor((axisalignedbb.a - 2.0D) / 16.0D); - int j = MathHelper.floor((axisalignedbb.d + 2.0D) / 16.0D); - int k = MathHelper.floor((axisalignedbb.c - 2.0D) / 16.0D); - int l = MathHelper.floor((axisalignedbb.f + 2.0D) / 16.0D); - - for (int i1 = i; i1 <= j; ++i1) - { - for (int j1 = k; j1 <= l; ++j1) - { - if (this.isChunkLoaded(i1, j1)) - { - this.getChunkAt(i1, j1).a(entity, axisalignedbb, arraylist, ientityselector); - } - } - } - - return arraylist; - } - - public List a(Class oclass, AxisAlignedBB axisalignedbb) - { - return this.a(oclass, axisalignedbb, (IEntitySelector) null); - } - - public List a(Class oclass, AxisAlignedBB axisalignedbb, IEntitySelector ientityselector) - { - int i = MathHelper.floor((axisalignedbb.a - 2.0D) / 16.0D); - int j = MathHelper.floor((axisalignedbb.d + 2.0D) / 16.0D); - int k = MathHelper.floor((axisalignedbb.c - 2.0D) / 16.0D); - int l = MathHelper.floor((axisalignedbb.f + 2.0D) / 16.0D); - ArrayList arraylist = new ArrayList(); - - for (int i1 = i; i1 <= j; ++i1) - { - for (int j1 = k; j1 <= l; ++j1) - { - if (this.isChunkLoaded(i1, j1)) - { - this.getChunkAt(i1, j1).a(oclass, axisalignedbb, arraylist, ientityselector); - } - } - } - - return arraylist; - } - - public Entity a(Class oclass, AxisAlignedBB axisalignedbb, Entity entity) - { - List list = this.a(oclass, axisalignedbb); - Entity entity1 = null; - double d0 = Double.MAX_VALUE; - - for (int i = 0; i < list.size(); ++i) - { - Entity entity2 = (Entity) list.get(i); - - if (entity2 != entity) - { - double d1 = entity.f(entity2); - - if (d1 <= d0) - { - entity1 = entity2; - d0 = d1; - } - } - } - - return entity1; - } - - public abstract Entity getEntity(int i); - - public void b(int i, int j, int k, TileEntity tileentity) - { - if (this.isLoaded(i, j, k)) - { - this.getChunkAtWorldCoords(i, k).e(); - } - } - - public int a(Class oclass) - { - int i = 0; - - for (int j = 0; j < this.entityList.size(); ++j) - { - Entity entity = (Entity) this.entityList.get(j); - - // CraftBukkit start - Split out persistent check, don't apply it to - // special persistent mobs - if (entity instanceof EntityInsentient) - { - EntityInsentient entityinsentient = (EntityInsentient) entity; - if (entityinsentient.isTypeNotPersistent() && entityinsentient.isPersistent()) - { - continue; - } - } - - if (oclass.isAssignableFrom(entity.getClass())) - { - // if ((!(entity instanceof EntityInsentient) || - // !((EntityInsentient) entity).isPersistent()) && - // oclass.isAssignableFrom(entity.getClass())) { - // CraftBukkit end - ++i; - } - } - - return i; - } - - public void a(List list) - { - org.spigotmc.AsyncCatcher.catchOp("entity world add"); // Spigot - // CraftBukkit start - // this.entityList.addAll(list); - Entity entity = null; - - for (int i = 0; i < list.size(); ++i) - { - entity = (Entity) list.get(i); - if (entity == null) - { - continue; - } - this.entityList.add(entity); - // CraftBukkit end - this.a((Entity) list.get(i)); - } - } - - public void b(List list) - { - this.f.addAll(list); - } - - public boolean mayPlace(Block block, int i, int j, int k, boolean flag, int l, Entity entity, ItemStack itemstack) - { - Block block1 = this.getType(i, j, k); - AxisAlignedBB axisalignedbb = flag ? null : block.a(this, i, j, k); - - // CraftBukkit start - store default return - boolean defaultReturn = axisalignedbb != null && !this.a(axisalignedbb, entity) ? false - : (block1.getMaterial() == Material.ORIENTABLE && block == Blocks.ANVIL ? true : block1.getMaterial() - .isReplaceable() && block.canPlace(this, i, j, k, l, itemstack)); - - // CraftBukkit start - BlockCanBuildEvent event = new BlockCanBuildEvent(this.getWorld().getBlockAt(i, j, k), - CraftMagicNumbers.getId(block), defaultReturn); - this.getServer().getPluginManager().callEvent(event); - - return event.isBuildable(); - // CraftBukkit end - } - - public PathEntity findPath(Entity entity, Entity entity1, float f, boolean flag, boolean flag1, boolean flag2, - boolean flag3) - { - this.methodProfiler.a("pathfind"); - int i = MathHelper.floor(entity.locX); - int j = MathHelper.floor(entity.locY + 1.0D); - int k = MathHelper.floor(entity.locZ); - int l = (int) (f + 16.0F); - int i1 = i - l; - int j1 = j - l; - int k1 = k - l; - int l1 = i + l; - int i2 = j + l; - int j2 = k + l; - ChunkCache chunkcache = new ChunkCache(this, i1, j1, k1, l1, i2, j2, 0); - PathEntity pathentity = (new Pathfinder(chunkcache, flag, flag1, flag2, flag3)).a(entity, entity1, f); - - this.methodProfiler.b(); - return pathentity; - } - - public PathEntity a(Entity entity, int i, int j, int k, float f, boolean flag, boolean flag1, boolean flag2, - boolean flag3) - { - this.methodProfiler.a("pathfind"); - int l = MathHelper.floor(entity.locX); - int i1 = MathHelper.floor(entity.locY); - int j1 = MathHelper.floor(entity.locZ); - int k1 = (int) (f + 8.0F); - int l1 = l - k1; - int i2 = i1 - k1; - int j2 = j1 - k1; - int k2 = l + k1; - int l2 = i1 + k1; - int i3 = j1 + k1; - ChunkCache chunkcache = new ChunkCache(this, l1, i2, j2, k2, l2, i3, 0); - PathEntity pathentity = (new Pathfinder(chunkcache, flag, flag1, flag2, flag3)).a(entity, i, j, k, f); - - this.methodProfiler.b(); - return pathentity; - } - - public int getBlockPower(int i, int j, int k, int l) - { - return this.getType(i, j, k).c(this, i, j, k, l); - } - - public int getBlockPower(int i, int j, int k) - { - byte b0 = 0; - int l = Math.max(b0, this.getBlockPower(i, j - 1, k, 0)); - - if (l >= 15) - { - return l; - } - else - { - l = Math.max(l, this.getBlockPower(i, j + 1, k, 1)); - if (l >= 15) - { - return l; - } - else - { - l = Math.max(l, this.getBlockPower(i, j, k - 1, 2)); - if (l >= 15) - { - return l; - } - else - { - l = Math.max(l, this.getBlockPower(i, j, k + 1, 3)); - if (l >= 15) - { - return l; - } - else - { - l = Math.max(l, this.getBlockPower(i - 1, j, k, 4)); - if (l >= 15) - { - return l; - } - else - { - l = Math.max(l, this.getBlockPower(i + 1, j, k, 5)); - return l >= 15 ? l : l; - } - } - } - } - } - } - - public boolean isBlockFacePowered(int i, int j, int k, int l) - { - return this.getBlockFacePower(i, j, k, l) > 0; - } - - public int getBlockFacePower(int i, int j, int k, int l) - { - return this.getType(i, j, k).r() ? this.getBlockPower(i, j, k) : this.getType(i, j, k).b(this, i, j, k, l); - } - - public boolean isBlockIndirectlyPowered(int i, int j, int k) - { - return this.getBlockFacePower(i, j - 1, k, 0) > 0 ? true : (this.getBlockFacePower(i, j + 1, k, 1) > 0 ? true - : (this.getBlockFacePower(i, j, k - 1, 2) > 0 ? true - : (this.getBlockFacePower(i, j, k + 1, 3) > 0 ? true - : (this.getBlockFacePower(i - 1, j, k, 4) > 0 ? true : this.getBlockFacePower(i + 1, j, - k, 5) > 0)))); - } - - public int getHighestNeighborSignal(int i, int j, int k) - { - int l = 0; - - for (int i1 = 0; i1 < 6; ++i1) - { - int j1 = this.getBlockFacePower(i + Facing.b[i1], j + Facing.c[i1], k + Facing.d[i1], i1); - - if (j1 >= 15) - { - return 15; - } - - if (j1 > l) - { - l = j1; - } - } - - return l; - } - - public EntityHuman findNearbyPlayer(Entity entity, double d0) - { - return this.findNearbyPlayer(entity.locX, entity.locY, entity.locZ, d0); - } - - public EntityHuman findNearbyPlayer(double d0, double d1, double d2, double d3) - { - double d4 = -1.0D; - EntityHuman entityhuman = null; - - for (int i = 0; i < this.players.size(); ++i) - { - EntityHuman entityhuman1 = (EntityHuman) this.players.get(i); - // CraftBukkit start - Fixed an NPE - if (entityhuman1 == null || entityhuman1.dead) - { - continue; - } - // CraftBukkit end - double d5 = entityhuman1.e(d0, d1, d2); - - if ((d3 < 0.0D || d5 < d3 * d3) && (d4 == -1.0D || d5 < d4)) - { - d4 = d5; - entityhuman = entityhuman1; - } - } - - return entityhuman; - } - - public EntityHuman findNearbyVulnerablePlayer(Entity entity, double d0) - { - return this.findNearbyVulnerablePlayer(entity.locX, entity.locY, entity.locZ, d0); - } - - public EntityHuman findNearbyVulnerablePlayer(double d0, double d1, double d2, double d3) - { - double d4 = -1.0D; - EntityHuman entityhuman = null; - - for (int i = 0; i < this.players.size(); ++i) - { - EntityHuman entityhuman1 = (EntityHuman) this.players.get(i); - // CraftBukkit start - Fixed an NPE - if (entityhuman1 == null || entityhuman1.dead) - { - continue; - } - // CraftBukkit end - - if (!entityhuman1.abilities.isInvulnerable && entityhuman1.isAlive()) - { - double d5 = entityhuman1.e(d0, d1, d2); - double d6 = d3; - - if (entityhuman1.isSneaking()) - { - d6 = d3 * 0.800000011920929D; - } - - if (entityhuman1.isInvisible()) - { - float f = entityhuman1.bE(); - - if (f < 0.1F) - { - f = 0.1F; - } - - d6 *= (double) (0.7F * f); - } - - if ((d3 < 0.0D || d5 < d6 * d6) && (d4 == -1.0D || d5 < d4)) - { - d4 = d5; - entityhuman = entityhuman1; - } - } - } - - return entityhuman; - } - - public EntityHuman a(String s) - { - for (int i = 0; i < this.players.size(); ++i) - { - EntityHuman entityhuman = (EntityHuman) this.players.get(i); - - if (s.equals(entityhuman.getName())) - { - return entityhuman; - } - } - - return null; - } - - public EntityHuman a(UUID uuid) - { - for (int i = 0; i < this.players.size(); ++i) - { - EntityHuman entityhuman = (EntityHuman) this.players.get(i); - - if (uuid.equals(entityhuman.getUniqueID())) - { - return entityhuman; - } - } - - return null; - } - - public void G() throws ExceptionWorldConflict - { // CraftBukkit - added throws - this.dataManager.checkSession(); - } - - public long getSeed() - { - return this.worldData.getSeed(); - } - - public long getTime() - { - return this.worldData.getTime(); - } - - public long getDayTime() - { - return this.worldData.getDayTime(); - } - - public void setDayTime(long i) - { - this.worldData.setDayTime(i); - } - - public ChunkCoordinates getSpawn() - { - return new ChunkCoordinates(this.worldData.c(), this.worldData.d(), this.worldData.e()); - } - - public void x(int i, int j, int k) - { - this.worldData.setSpawn(i, j, k); - } - - public boolean a(EntityHuman entityhuman, int i, int j, int k) - { - return true; - } - - public void broadcastEntityEffect(Entity entity, byte b0) - { - } - - public IChunkProvider L() - { - return this.chunkProvider; - } - - public void playBlockAction(int i, int j, int k, Block block, int l, int i1) - { - block.a(this, i, j, k, l, i1); - } - - public IDataManager getDataManager() - { - return this.dataManager; - } - - public WorldData getWorldData() - { - return this.worldData; - } - - public GameRules getGameRules() - { - return this.worldData.getGameRules(); - } - - public void everyoneSleeping() - { - } - - // CraftBukkit start - // Calls the method that checks to see if players are sleeping - // Called by CraftPlayer.setPermanentSleeping() - public void checkSleepStatus() - { - if (!this.isStatic) - { - this.everyoneSleeping(); - } - } - - // CraftBukkit end - - public float h(float f) - { - return (this.o + (this.p - this.o) * f) * this.j(f); - } - - public float j(float f) - { - return this.m + (this.n - this.m) * f; - } - - public boolean P() - { - return (double) this.h(1.0F) > 0.9D; - } - - public boolean Q() - { - return (double) this.j(1.0F) > 0.2D; - } - - public boolean isRainingAt(int i, int j, int k) - { - if (!this.Q()) - { - return false; - } - else if (!this.i(i, j, k)) - { - return false; - } - else if (this.h(i, k) > j) - { - return false; - } - else - { - BiomeBase biomebase = this.getBiome(i, k); - - return biomebase.d() ? false : (this.e(i, j, k, false) ? false : biomebase.e()); - } - } - - public boolean z(int i, int j, int k) - { - BiomeBase biomebase = this.getBiome(i, k); - - return biomebase.f(); - } - - public void a(String s, PersistentBase persistentbase) - { - this.worldMaps.a(s, persistentbase); - } - - public PersistentBase a(Class oclass, String s) - { - return this.worldMaps.get(oclass, s); - } - - public int b(String s) - { - return this.worldMaps.a(s); - } - - public void b(int i, int j, int k, int l, int i1) - { - for (int j1 = 0; j1 < this.u.size(); ++j1) - { - ((IWorldAccess) this.u.get(j1)).a(i, j, k, l, i1); - } - } - - public void triggerEffect(int i, int j, int k, int l, int i1) - { - this.a((EntityHuman) null, i, j, k, l, i1); - } - - public void a(EntityHuman entityhuman, int i, int j, int k, int l, int i1) - { - try - { - for (int j1 = 0; j1 < this.u.size(); ++j1) - { - ((IWorldAccess) this.u.get(j1)).a(entityhuman, i, j, k, l, i1); - } - } - catch (Throwable throwable) - { - CrashReport crashreport = CrashReport.a(throwable, "Playing level event"); - CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Level event being played"); - - crashreportsystemdetails.a("Block coordinates", CrashReportSystemDetails.a(j, k, l)); - crashreportsystemdetails.a("Event source", entityhuman); - crashreportsystemdetails.a("Event type", Integer.valueOf(i)); - crashreportsystemdetails.a("Event data", Integer.valueOf(i1)); - throw new ReportedException(crashreport); - } - } - - public int getHeight() - { - return 256; - } - - public int S() - { - return this.worldProvider.g ? 128 : 256; - } - - public Random A(int i, int j, int k) - { - long l = (long) i * 341873128712L + (long) j * 132897987541L + this.getWorldData().getSeed() + (long) k; - - this.random.setSeed(l); - return this.random; - } - - public ChunkPosition b(String s, int i, int j, int k) - { - return this.L().findNearestMapFeature(this, s, i, j, k); - } - - public CrashReportSystemDetails a(CrashReport crashreport) - { - CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Affected level", 1); - - crashreportsystemdetails.a("Level name", (this.worldData == null ? "????" : this.worldData.getName())); - crashreportsystemdetails.a("All players", (Callable) (new CrashReportPlayers(this))); - crashreportsystemdetails.a("Chunk stats", (Callable) (new CrashReportChunkStats(this))); - - try - { - this.worldData.a(crashreportsystemdetails); - } - catch (Throwable throwable) - { - crashreportsystemdetails.a("Level Data Unobtainable", throwable); - } - - return crashreportsystemdetails; - } - - public void d(int i, int j, int k, int l, int i1) - { - for (int j1 = 0; j1 < this.u.size(); ++j1) - { - IWorldAccess iworldaccess = (IWorldAccess) this.u.get(j1); - - iworldaccess.b(i, j, k, l, i1); - } - } - - public Calendar V() - { - if (this.getTime() % 600L == 0L) - { - this.J.setTimeInMillis(MinecraftServer.ar()); - } - - return this.J; - } - - public Scoreboard getScoreboard() - { - return this.scoreboard; - } - - public void updateAdjacentComparators(int i, int j, int k, Block block) - { - for (int l = 0; l < 4; ++l) - { - int i1 = i + Direction.a[l]; - int j1 = k + Direction.b[l]; - Block block1 = this.getType(i1, j, j1); - - if (Blocks.REDSTONE_COMPARATOR_OFF.e(block1)) - { - block1.doPhysics(this, i1, j, j1, block); - } - else if (block1.r()) - { - i1 += Direction.a[l]; - j1 += Direction.b[l]; - Block block2 = this.getType(i1, j, j1); - - if (Blocks.REDSTONE_COMPARATOR_OFF.e(block2)) - { - block2.doPhysics(this, i1, j, j1, block); - } - } - } - } - - public float b(double d0, double d1, double d2) - { - return this.B(MathHelper.floor(d0), MathHelper.floor(d1), MathHelper.floor(d2)); - } - - public float B(int i, int j, int k) - { - float f = 0.0F; - boolean flag = this.difficulty == EnumDifficulty.HARD; - - if (this.isLoaded(i, j, k)) - { - float f1 = this.y(); - - f += MathHelper.a((float) this.getChunkAtWorldCoords(i, k).s / 3600000.0F, 0.0F, 1.0F) - * (flag ? 1.0F : 0.75F); - f += f1 * 0.25F; - } - - if (this.difficulty == EnumDifficulty.EASY || this.difficulty == EnumDifficulty.PEACEFUL) - { - f *= (float) this.difficulty.a() / 2.0F; - } - - return MathHelper.a(f, 0.0F, flag ? 1.5F : 1.0F); - } - - public void X() - { - Iterator iterator = this.u.iterator(); - - while (iterator.hasNext()) - { - IWorldAccess iworldaccess = (IWorldAccess) iterator.next(); - - iworldaccess.b(); - } - } -} diff --git a/Plugins/Nautilus.Core.CraftBukkit/src/org/bukkit/craftbukkit/v1_7_R4/CraftWorld.java b/Plugins/Nautilus.Core.CraftBukkit/src/org/bukkit/craftbukkit/v1_7_R4/CraftWorld.java deleted file mode 100644 index f8c0bddd4..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/src/org/bukkit/craftbukkit/v1_7_R4/CraftWorld.java +++ /dev/null @@ -1,1399 +0,0 @@ -package org.bukkit.craftbukkit.v1_7_R4; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.Random; -import java.util.Set; -import java.util.UUID; - -import net.minecraft.server.v1_7_R4.*; - -import org.apache.commons.lang.Validate; -import org.bukkit.BlockChangeDelegate; -import org.bukkit.Bukkit; -import org.bukkit.Chunk; -import org.bukkit.ChunkSnapshot; -import org.bukkit.Difficulty; -import org.bukkit.Effect; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.TreeType; -import org.bukkit.World; -import org.bukkit.WorldType; -import org.bukkit.Effect.Type; -import org.bukkit.World.Environment; -import org.bukkit.World.Spigot; -import org.bukkit.block.Biome; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.block.BlockState; -import org.bukkit.craftbukkit.v1_7_R4.block.CraftBlock; -import org.bukkit.craftbukkit.v1_7_R4.block.CraftBlockState; -import org.bukkit.craftbukkit.v1_7_R4.entity.*; -import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack; -import org.bukkit.craftbukkit.v1_7_R4.metadata.BlockMetadataStore; -import org.bukkit.craftbukkit.v1_7_R4.util.CraftMagicNumbers; -import org.bukkit.craftbukkit.v1_7_R4.util.LongHash; -import org.bukkit.entity.*; -import org.bukkit.entity.Entity; -import org.bukkit.entity.minecart.ExplosiveMinecart; -import org.bukkit.entity.minecart.HopperMinecart; -import org.bukkit.entity.minecart.PoweredMinecart; -import org.bukkit.entity.minecart.SpawnerMinecart; -import org.bukkit.entity.minecart.StorageMinecart; -import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; -import org.bukkit.event.weather.ThunderChangeEvent; -import org.bukkit.event.weather.WeatherChangeEvent; -import org.bukkit.event.world.SpawnChangeEvent; -import org.bukkit.generator.BlockPopulator; -import org.bukkit.generator.ChunkGenerator; -import org.bukkit.inventory.ItemStack; -import org.bukkit.metadata.MetadataValue; -import org.bukkit.plugin.Plugin; -import org.bukkit.plugin.messaging.StandardMessenger; -import org.bukkit.util.Vector; - -public class CraftWorld implements World { - public static final int CUSTOM_DIMENSION_OFFSET = 10; - - private final WorldServer world; - private Environment environment; - private final CraftServer server = (CraftServer) Bukkit.getServer(); - private final ChunkGenerator generator; - private final List populators = new ArrayList(); - private final BlockMetadataStore blockMetadata = new BlockMetadataStore(this); - private int monsterSpawn = -1; - private int animalSpawn = -1; - private int waterAnimalSpawn = -1; - private int ambientSpawn = -1; - private int chunkLoadCount = 0; - private int chunkGCTickCount; - - private static final Random rand = new Random(); - - public CraftWorld(WorldServer world, ChunkGenerator gen, Environment env) { - this.world = world; - this.generator = gen; - - environment = env; - - if (server.chunkGCPeriod > 0) { - chunkGCTickCount = rand.nextInt(server.chunkGCPeriod); - } - } - - public Block getBlockAt(int x, int y, int z) { - return getChunkAt(x >> 4, z >> 4).getBlock(x & 0xF, y & 0xFF, z & 0xF); - } - - public int getBlockTypeIdAt(int x, int y, int z) { - return world.getTypeId(x, y, z); - } - - public int getHighestBlockYAt(int x, int z) { - if (!isChunkLoaded(x >> 4, z >> 4)) { - loadChunk(x >> 4, z >> 4); - } - - return world.getHighestBlockYAt(x, z); - } - - public Location getSpawnLocation() { - ChunkCoordinates spawn = world.getSpawn(); - return new Location(this, spawn.x, spawn.y, spawn.z); - } - - public boolean setSpawnLocation(int x, int y, int z) { - try { - Location previousLocation = getSpawnLocation(); - world.worldData.setSpawn(x, y, z); - - // Notify anyone who's listening. - SpawnChangeEvent event = new SpawnChangeEvent(this, previousLocation); - server.getPluginManager().callEvent(event); - - return true; - } catch (Exception e) { - return false; - } - } - - public Chunk getChunkAt(int x, int z) { - return this.world.chunkProviderServer.getChunkAt(x, z).bukkitChunk; - } - - public Chunk getChunkAt(Block block) { - return getChunkAt(block.getX() >> 4, block.getZ() >> 4); - } - - public boolean isChunkLoaded(int x, int z) { - return world.chunkProviderServer.isChunkLoaded(x, z); - } - - public Chunk[] getLoadedChunks() { - Object[] chunks = world.chunkProviderServer.chunks.values().toArray(); - org.bukkit.Chunk[] craftChunks = new CraftChunk[chunks.length]; - - for (int i = 0; i < chunks.length; i++) { - net.minecraft.server.v1_7_R4.Chunk chunk = (net.minecraft.server.v1_7_R4.Chunk) chunks[i]; - craftChunks[i] = chunk.bukkitChunk; - } - - return craftChunks; - } - - public void loadChunk(int x, int z) { - loadChunk(x, z, true); - } - - public boolean unloadChunk(Chunk chunk) { - return unloadChunk(chunk.getX(), chunk.getZ()); - } - - public boolean unloadChunk(int x, int z) { - return unloadChunk(x, z, true); - } - - public boolean unloadChunk(int x, int z, boolean save) { - return unloadChunk(x, z, save, false); - } - - public boolean unloadChunkRequest(int x, int z) { - return unloadChunkRequest(x, z, true); - } - - public boolean unloadChunkRequest(int x, int z, boolean safe) { - org.spigotmc.AsyncCatcher.catchOp( "chunk unload"); // Spigot - if (safe && isChunkInUse(x, z)) { - return false; - } - - world.chunkProviderServer.queueUnload(x, z); - - return true; - } - - public boolean unloadChunk(int x, int z, boolean save, boolean safe) { - org.spigotmc.AsyncCatcher.catchOp( "chunk unload"); // Spigot - if (safe && isChunkInUse(x, z)) { - return false; - } - - net.minecraft.server.v1_7_R4.Chunk chunk = world.chunkProviderServer.getOrCreateChunk(x, z); - if (chunk.mustSave) { // If chunk had previously been queued to save, must do save to avoid loss of that data - save = true; - } - - chunk.removeEntities(); // Always remove entities - even if discarding, need to get them out of world table - - if (save && !(chunk instanceof EmptyChunk)) { - world.chunkProviderServer.saveChunk(chunk); - world.chunkProviderServer.saveChunkNOP(chunk); - } - - world.chunkProviderServer.unloadQueue.remove(x, z); - world.chunkProviderServer.chunks.remove(LongHash.toLong(x, z)); - - return true; - } - - public boolean regenerateChunk(int x, int z) { - unloadChunk(x, z, false, false); - - world.chunkProviderServer.unloadQueue.remove(x, z); - - net.minecraft.server.v1_7_R4.Chunk chunk = null; - - if (world.chunkProviderServer.chunkProvider == null) { - chunk = world.chunkProviderServer.emptyChunk; - } else { - chunk = world.chunkProviderServer.chunkProvider.getOrCreateChunk(x, z); - } - - chunkLoadPostProcess(chunk, x, z); - - refreshChunk(x, z); - - return chunk != null; - } - - public boolean refreshChunk(int x, int z) { - if (!isChunkLoaded(x, z)) { - return false; - } - - int px = x << 4; - int pz = z << 4; - - // If there are more than 64 updates to a chunk at once, it will update all 'touched' sections within the chunk - // And will include biome data if all sections have been 'touched' - // This flags 65 blocks distributed across all the sections of the chunk, so that everything is sent, including biomes - int height = getMaxHeight() / 16; - for (int idx = 0; idx < 64; idx++) { - world.notify(px + (idx / height), ((idx % height) * 16), pz); - } - world.notify(px + 15, (height * 16) - 1, pz + 15); - - return true; - } - - public boolean isChunkInUse(int x, int z) { - return world.getPlayerChunkMap().isChunkInUse(x, z); - } - - public boolean loadChunk(int x, int z, boolean generate) { - org.spigotmc.AsyncCatcher.catchOp( "chunk load"); // Spigot - chunkLoadCount++; - if (generate) { - // Use the default variant of loadChunk when generate == true. - return world.chunkProviderServer.getChunkAt(x, z) != null; - } - - world.chunkProviderServer.unloadQueue.remove(x, z); - net.minecraft.server.v1_7_R4.Chunk chunk = world.chunkProviderServer.chunks.get(LongHash.toLong(x, z)); - - if (chunk == null) { - world.timings.syncChunkLoadTimer.startTiming(); // Spigot - chunk = world.chunkProviderServer.loadChunk(x, z); - - chunkLoadPostProcess(chunk, x, z); - world.timings.syncChunkLoadTimer.stopTiming(); // Spigot - } - return chunk != null; - } - - private void chunkLoadPostProcess(net.minecraft.server.v1_7_R4.Chunk chunk, int x, int z) { - if (chunk != null) { - world.chunkProviderServer.chunks.put(LongHash.toLong(x, z), chunk); - - chunk.addEntities(); - - if (!chunk.done && world.chunkProviderServer.isChunkLoaded(x + 1, z + 1) && world.chunkProviderServer.isChunkLoaded(x, z + 1) && world.chunkProviderServer.isChunkLoaded(x + 1, z)) { - world.chunkProviderServer.getChunkAt(world.chunkProviderServer, x, z); - } - - if (world.chunkProviderServer.isChunkLoaded(x - 1, z) && !world.chunkProviderServer.getOrCreateChunk(x - 1, z).done && world.chunkProviderServer.isChunkLoaded(x - 1, z + 1) && world.chunkProviderServer.isChunkLoaded(x, z + 1) && world.chunkProviderServer.isChunkLoaded(x - 1, z)) { - world.chunkProviderServer.getChunkAt(world.chunkProviderServer, x - 1, z); - } - - if (world.chunkProviderServer.isChunkLoaded(x, z - 1) && !world.chunkProviderServer.getOrCreateChunk(x, z - 1).done && world.chunkProviderServer.isChunkLoaded(x + 1, z - 1) && world.chunkProviderServer.isChunkLoaded(x, z - 1) && world.chunkProviderServer.isChunkLoaded(x + 1, z)) { - world.chunkProviderServer.getChunkAt(world.chunkProviderServer, x, z - 1); - } - - if (world.chunkProviderServer.isChunkLoaded(x - 1, z - 1) && !world.chunkProviderServer.getOrCreateChunk(x - 1, z - 1).done && world.chunkProviderServer.isChunkLoaded(x - 1, z - 1) && world.chunkProviderServer.isChunkLoaded(x, z - 1) && world.chunkProviderServer.isChunkLoaded(x - 1, z)) { - world.chunkProviderServer.getChunkAt(world.chunkProviderServer, x - 1, z - 1); - } - } - } - - public boolean isChunkLoaded(Chunk chunk) { - return isChunkLoaded(chunk.getX(), chunk.getZ()); - } - - public void loadChunk(Chunk chunk) { - loadChunk(chunk.getX(), chunk.getZ()); - ((CraftChunk) getChunkAt(chunk.getX(), chunk.getZ())).getHandle().bukkitChunk = chunk; - } - - public WorldServer getHandle() { - return world; - } - - public org.bukkit.entity.Item dropItem(Location loc, ItemStack item) { - Validate.notNull(item, "Cannot drop a Null item."); - Validate.isTrue(item.getTypeId() != 0, "Cannot drop AIR."); - EntityItem entity = new EntityItem(world, loc.getX(), loc.getY(), loc.getZ(), CraftItemStack.asNMSCopy(item)); - entity.pickupDelay = 10; - world.addEntity(entity); - // TODO this is inconsistent with how Entity.getBukkitEntity() works. - // However, this entity is not at the moment backed by a server entity class so it may be left. - return new CraftItem(world.getServer(), entity); - } - - public org.bukkit.entity.Item dropItemNaturally(Location loc, ItemStack item) { - double xs = world.random.nextFloat() * 0.7F + (1.0F - 0.7F) * 0.5D; - double ys = world.random.nextFloat() * 0.7F + (1.0F - 0.7F) * 0.5D; - double zs = world.random.nextFloat() * 0.7F + (1.0F - 0.7F) * 0.5D; - loc = loc.clone(); - loc.setX(loc.getX() + xs); - loc.setY(loc.getY() + ys); - loc.setZ(loc.getZ() + zs); - return dropItem(loc, item); - } - - public Arrow spawnArrow(Location loc, Vector velocity, float speed, float spread) { - Validate.notNull(loc, "Can not spawn arrow with a null location"); - Validate.notNull(velocity, "Can not spawn arrow with a null velocity"); - - EntityArrow arrow = new EntityArrow(world); - arrow.setPositionRotation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch()); - arrow.shoot(velocity.getX(), velocity.getY(), velocity.getZ(), speed, spread); - world.addEntity(arrow); - return (Arrow) arrow.getBukkitEntity(); - } - - @Deprecated - public LivingEntity spawnCreature(Location loc, CreatureType creatureType) { - return spawnCreature(loc, creatureType.toEntityType()); - } - - @Deprecated - public LivingEntity spawnCreature(Location loc, EntityType creatureType) { - Validate.isTrue(creatureType.isAlive(), "EntityType not instance of LivingEntity"); - return (LivingEntity) spawnEntity(loc, creatureType); - } - - public Entity spawnEntity(Location loc, EntityType entityType) { - return spawn(loc, entityType.getEntityClass()); - } - - public LightningStrike strikeLightning(Location loc) { - EntityLightning lightning = new EntityLightning(world, loc.getX(), loc.getY(), loc.getZ()); - world.strikeLightning(lightning); - return new CraftLightningStrike(server, lightning); - } - - public LightningStrike strikeLightningEffect(Location loc) { - EntityLightning lightning = new EntityLightning(world, loc.getX(), loc.getY(), loc.getZ(), true); - world.strikeLightning(lightning); - return new CraftLightningStrike(server, lightning); - } - - public boolean generateTree(Location loc, TreeType type) { - net.minecraft.server.v1_7_R4.WorldGenerator gen; - switch (type) { - case BIG_TREE: - gen = new WorldGenBigTree(true); - break; - case BIRCH: - gen = new WorldGenForest(true, false); - break; - case REDWOOD: - gen = new WorldGenTaiga2(true); - break; - case TALL_REDWOOD: - gen = new WorldGenTaiga1(); - break; - case JUNGLE: - gen = new WorldGenJungleTree(true, 10, 20, 3, 3); // Magic values as in BlockSapling - break; - case SMALL_JUNGLE: - gen = new WorldGenTrees(true, 4 + rand.nextInt(7), 3, 3, false); - break; - case COCOA_TREE: - gen = new WorldGenTrees(true, 4 + rand.nextInt(7), 3, 3, true); - break; - case JUNGLE_BUSH: - gen = new WorldGenGroundBush(3, 0); - break; - case RED_MUSHROOM: - gen = new WorldGenHugeMushroom(1); - break; - case BROWN_MUSHROOM: - gen = new WorldGenHugeMushroom(0); - break; - case SWAMP: - gen = new WorldGenSwampTree(); - break; - case ACACIA: - gen = new WorldGenAcaciaTree(true); - break; - case DARK_OAK: - gen = new WorldGenForestTree(true); - break; - case MEGA_REDWOOD: - gen = new WorldGenMegaTree(false, rand.nextBoolean()); - break; - case TALL_BIRCH: - gen = new WorldGenForest(true, true); - break; - case TREE: - default: - gen = new WorldGenTrees(true); - break; - } - - return gen.generate(world, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); - } - - public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate) { - world.captureTreeGeneration = true; - world.captureBlockStates = true; - boolean grownTree = generateTree(loc, type); - world.captureBlockStates = false; - world.captureTreeGeneration = false; - if (grownTree) { // Copy block data to delegate - for (BlockState blockstate : world.capturedBlockStates) { - int x = blockstate.getX(); - int y = blockstate.getY(); - int z = blockstate.getZ(); - net.minecraft.server.v1_7_R4.Block oldBlock = world.getType(x, y, z); - int typeId = blockstate.getTypeId(); - int data = blockstate.getRawData(); - int flag = ((CraftBlockState)blockstate).getFlag(); - delegate.setTypeIdAndData(x, y, z, typeId, data); - net.minecraft.server.v1_7_R4.Block newBlock = world.getType(x, y, z); - world.notifyAndUpdatePhysics(x, y, z, null, oldBlock, newBlock, flag); - } - world.capturedBlockStates.clear(); - return true; - } else { - world.capturedBlockStates.clear(); - return false; - } - } - - public TileEntity getTileEntityAt(final int x, final int y, final int z) { - return world.getTileEntity(x, y, z); - } - - public String getName() { - return world.worldData.getName(); - } - - @Deprecated - public long getId() { - return world.worldData.getSeed(); - } - - public UUID getUID() { - return world.getDataManager().getUUID(); - } - - @Override - public String toString() { - return "CraftWorld{name=" + getName() + '}'; - } - - public long getTime() { - long time = getFullTime() % 24000; - if (time < 0) time += 24000; - return time; - } - - public void setTime(long time) { - long margin = (time - getFullTime()) % 24000; - if (margin < 0) margin += 24000; - setFullTime(getFullTime() + margin); - } - - public long getFullTime() { - return world.getDayTime(); - } - - public void setFullTime(long time) { - world.setDayTime(time); - - // Forces the client to update to the new time immediately - for (Player p : getPlayers()) { - CraftPlayer cp = (CraftPlayer) p; - if (cp.getHandle().playerConnection == null) continue; - - cp.getHandle().playerConnection.sendPacket(new PacketPlayOutUpdateTime(cp.getHandle().world.getTime(), cp.getHandle().getPlayerTime(), cp.getHandle().world.getGameRules().getBoolean("doDaylightCycle"))); - } - } - - public boolean createExplosion(double x, double y, double z, float power) { - return createExplosion(x, y, z, power, false, true); - } - - public boolean createExplosion(double x, double y, double z, float power, boolean setFire) { - return createExplosion(x, y, z, power, setFire, true); - } - - public boolean createExplosion(double x, double y, double z, float power, boolean setFire, boolean breakBlocks) { - return !world.createExplosion(null, x, y, z, power, setFire, breakBlocks).wasCanceled; - } - - public boolean createExplosion(Location loc, float power) { - return createExplosion(loc, power, false); - } - - public boolean createExplosion(Location loc, float power, boolean setFire) { - return createExplosion(loc.getX(), loc.getY(), loc.getZ(), power, setFire); - } - - public Environment getEnvironment() { - return environment; - } - - public void setEnvironment(Environment env) { - if (environment != env) { - environment = env; - world.worldProvider = WorldProvider.byDimension(environment.getId()); - } - } - - public Block getBlockAt(Location location) { - return getBlockAt(location.getBlockX(), location.getBlockY(), location.getBlockZ()); - } - - public int getBlockTypeIdAt(Location location) { - return getBlockTypeIdAt(location.getBlockX(), location.getBlockY(), location.getBlockZ()); - } - - public int getHighestBlockYAt(Location location) { - return getHighestBlockYAt(location.getBlockX(), location.getBlockZ()); - } - - public Chunk getChunkAt(Location location) { - return getChunkAt(location.getBlockX() >> 4, location.getBlockZ() >> 4); - } - - public ChunkGenerator getGenerator() { - return generator; - } - - public List getPopulators() { - return populators; - } - - public Block getHighestBlockAt(int x, int z) { - return getBlockAt(x, getHighestBlockYAt(x, z), z); - } - - public Block getHighestBlockAt(Location location) { - return getHighestBlockAt(location.getBlockX(), location.getBlockZ()); - } - - public Biome getBiome(int x, int z) { - return CraftBlock.biomeBaseToBiome(this.world.getBiome(x, z)); - } - - public void setBiome(int x, int z, Biome bio) { - BiomeBase bb = CraftBlock.biomeToBiomeBase(bio); - if (this.world.isLoaded(x, 0, z)) { - net.minecraft.server.v1_7_R4.Chunk chunk = this.world.getChunkAtWorldCoords(x, z); - - if (chunk != null) { - byte[] biomevals = chunk.m(); - biomevals[((z & 0xF) << 4) | (x & 0xF)] = (byte)bb.id; - } - } - } - - public double getTemperature(int x, int z) { - return this.world.getBiome(x, z).temperature; - } - - public double getHumidity(int x, int z) { - return this.world.getBiome(x, z).humidity; - } - - public List getEntities() { - List list = new ArrayList(); - - for (Object o : world.entityList) { - if (o instanceof net.minecraft.server.v1_7_R4.Entity) { - net.minecraft.server.v1_7_R4.Entity mcEnt = (net.minecraft.server.v1_7_R4.Entity) o; - Entity bukkitEntity = mcEnt.getBukkitEntity(); - - // Assuming that bukkitEntity isn't null - if (bukkitEntity != null) { - list.add(bukkitEntity); - } - } - } - - return list; - } - - public List getLivingEntities() { - List list = new ArrayList(); - - for (Object o : world.entityList) { - if (o instanceof net.minecraft.server.v1_7_R4.Entity) { - net.minecraft.server.v1_7_R4.Entity mcEnt = (net.minecraft.server.v1_7_R4.Entity) o; - Entity bukkitEntity = mcEnt.getBukkitEntity(); - - // Assuming that bukkitEntity isn't null - if (bukkitEntity != null && bukkitEntity instanceof LivingEntity) { - list.add((LivingEntity) bukkitEntity); - } - } - } - - return list; - } - - @SuppressWarnings("unchecked") - @Deprecated - public Collection getEntitiesByClass(Class... classes) { - return (Collection)getEntitiesByClasses(classes); - } - - @SuppressWarnings("unchecked") - public Collection getEntitiesByClass(Class clazz) { - Collection list = new ArrayList(); - - for (Object entity: world.entityList) { - if (entity instanceof net.minecraft.server.v1_7_R4.Entity) { - Entity bukkitEntity = ((net.minecraft.server.v1_7_R4.Entity) entity).getBukkitEntity(); - - if (bukkitEntity == null) { - continue; - } - - Class bukkitClass = bukkitEntity.getClass(); - - if (clazz.isAssignableFrom(bukkitClass)) { - list.add((T) bukkitEntity); - } - } - } - - return list; - } - - public Collection getEntitiesByClasses(Class... classes) { - Collection list = new ArrayList(); - - for (Object entity: world.entityList) { - if (entity instanceof net.minecraft.server.v1_7_R4.Entity) { - Entity bukkitEntity = ((net.minecraft.server.v1_7_R4.Entity) entity).getBukkitEntity(); - - if (bukkitEntity == null) { - continue; - } - - Class bukkitClass = bukkitEntity.getClass(); - - for (Class clazz : classes) { - if (clazz.isAssignableFrom(bukkitClass)) { - list.add(bukkitEntity); - break; - } - } - } - } - - return list; - } - - public List getPlayers() { - List list = new ArrayList(); - - for (Object o : world.entityList) { - if (o instanceof net.minecraft.server.v1_7_R4.Entity) { - net.minecraft.server.v1_7_R4.Entity mcEnt = (net.minecraft.server.v1_7_R4.Entity) o; - Entity bukkitEntity = mcEnt.getBukkitEntity(); - - if ((bukkitEntity != null) && (bukkitEntity instanceof Player)) { - list.add((Player) bukkitEntity); - } - } - } - - return list; - } - - public void save() { - this.server.checkSaveState(); - try { - boolean oldSave = world.savingDisabled; - - world.savingDisabled = false; - world.save(true, null); - - world.savingDisabled = oldSave; - } catch (ExceptionWorldConflict ex) { - ex.printStackTrace(); - } - } - - public boolean isAutoSave() { - return !world.savingDisabled; - } - - public void setAutoSave(boolean value) { - world.savingDisabled = !value; - } - - public void setDifficulty(Difficulty difficulty) { - this.getHandle().difficulty = EnumDifficulty.getById(difficulty.getValue()); - } - - public Difficulty getDifficulty() { - return Difficulty.getByValue(this.getHandle().difficulty.ordinal()); - } - - public BlockMetadataStore getBlockMetadata() { - return blockMetadata; - } - - public boolean hasStorm() { - return world.worldData.hasStorm(); - } - - public void setStorm(boolean hasStorm) { - CraftServer server = world.getServer(); - - WeatherChangeEvent weather = new WeatherChangeEvent(this, hasStorm); - server.getPluginManager().callEvent(weather); - if (!weather.isCancelled()) { - world.worldData.setStorm(hasStorm); - - // These numbers are from Minecraft - if (hasStorm) { - setWeatherDuration(rand.nextInt(12000) + 12000); - } else { - setWeatherDuration(rand.nextInt(168000) + 12000); - } - } - } - - public int getWeatherDuration() { - return world.worldData.getWeatherDuration(); - } - - public void setWeatherDuration(int duration) { - world.worldData.setWeatherDuration(duration); - } - - public boolean isThundering() { - return hasStorm() && world.worldData.isThundering(); - } - - public void setThundering(boolean thundering) { - if (thundering && !hasStorm()) setStorm(true); - CraftServer server = world.getServer(); - - ThunderChangeEvent thunder = new ThunderChangeEvent(this, thundering); - server.getPluginManager().callEvent(thunder); - if (!thunder.isCancelled()) { - world.worldData.setThundering(thundering); - - // These numbers are from Minecraft - if (thundering) { - setThunderDuration(rand.nextInt(12000) + 3600); - } else { - setThunderDuration(rand.nextInt(168000) + 12000); - } - } - } - - public int getThunderDuration() { - return world.worldData.getThunderDuration(); - } - - public void setThunderDuration(int duration) { - world.worldData.setThunderDuration(duration); - } - - public long getSeed() { - return world.worldData.getSeed(); - } - - public boolean getPVP() { - return world.pvpMode; - } - - public void setPVP(boolean pvp) { - world.pvpMode = pvp; - } - - public void playEffect(Player player, Effect effect, int data) { - playEffect(player.getLocation(), effect, data, 0); - } - - public void playEffect(Location location, Effect effect, int data) { - playEffect(location, effect, data, 64); - } - - public void playEffect(Location loc, Effect effect, T data) { - playEffect(loc, effect, data, 64); - } - - public void playEffect(Location loc, Effect effect, T data, int radius) { - if (data != null) { - Validate.isTrue(data.getClass().equals(effect.getData()), "Wrong kind of data for this effect!"); - } else { - Validate.isTrue(effect.getData() == null, "Wrong kind of data for this effect!"); - } - - if (data != null && data.getClass().equals( org.bukkit.material.MaterialData.class )) { - org.bukkit.material.MaterialData materialData = (org.bukkit.material.MaterialData) data; - Validate.isTrue( materialData.getItemType().isBlock(), "Material must be block" ); - spigot().playEffect( loc, effect, materialData.getItemType().getId(), materialData.getData(), 0, 0, 0, 1, 1, radius ); - } else { - int dataValue = data == null ? 0 : CraftEffect.getDataValue( effect, data ); - playEffect( loc, effect, dataValue, radius ); - } - } - - public void playEffect(Location location, Effect effect, int data, int radius) { - spigot().playEffect( location, effect, data, 0, 0, 0, 0, 1, 1, radius ); - } - - public T spawn(Location location, Class clazz) throws IllegalArgumentException { - return spawn(location, clazz, SpawnReason.CUSTOM); - } - - public FallingBlock spawnFallingBlock(Location location, org.bukkit.Material material, byte data) throws IllegalArgumentException { - Validate.notNull(location, "Location cannot be null"); - Validate.notNull(material, "Material cannot be null"); - Validate.isTrue(material.isBlock(), "Material must be a block"); - - double x = location.getBlockX() + 0.5; - double y = location.getBlockY() + 0.5; - double z = location.getBlockZ() + 0.5; - - EntityFallingBlock entity = new EntityFallingBlock(world, x, y, z, net.minecraft.server.v1_7_R4.Block.getById(material.getId()), data); - entity.ticksLived = 1; - - world.addEntity(entity, SpawnReason.CUSTOM); - return (FallingBlock) entity.getBukkitEntity(); - } - - public FallingBlock spawnFallingBlock(Location location, int blockId, byte blockData) throws IllegalArgumentException { - return spawnFallingBlock(location, org.bukkit.Material.getMaterial(blockId), blockData); - } - - @SuppressWarnings("unchecked") - public T spawn(Location location, Class clazz, SpawnReason reason) throws IllegalArgumentException { - if (location == null || clazz == null) { - throw new IllegalArgumentException("Location or entity class cannot be null"); - } - - net.minecraft.server.v1_7_R4.Entity entity = null; - - double x = location.getX(); - double y = location.getY(); - double z = location.getZ(); - float pitch = location.getPitch(); - float yaw = location.getYaw(); - - // order is important for some of these - if (Boat.class.isAssignableFrom(clazz)) { - entity = new EntityBoat(world, x, y, z); - } else if (FallingBlock.class.isAssignableFrom(clazz)) { - x = location.getBlockX(); - y = location.getBlockY(); - z = location.getBlockZ(); - int type = world.getTypeId((int) x, (int) y, (int) z); - int data = world.getData((int) x, (int) y, (int) z); - - entity = new EntityFallingBlock(world, x + 0.5, y + 0.5, z + 0.5, net.minecraft.server.v1_7_R4.Block.getById(type), data); - } else if (Projectile.class.isAssignableFrom(clazz)) { - if (Snowball.class.isAssignableFrom(clazz)) { - entity = new EntitySnowball(world, x, y, z); - } else if (Egg.class.isAssignableFrom(clazz)) { - entity = new EntityEgg(world, x, y, z); - } else if (Arrow.class.isAssignableFrom(clazz)) { - entity = new EntityArrow(world); - entity.setPositionRotation(x, y, z, 0, 0); - } else if (ThrownExpBottle.class.isAssignableFrom(clazz)) { - entity = new EntityThrownExpBottle(world); - entity.setPositionRotation(x, y, z, 0, 0); - } else if (EnderPearl.class.isAssignableFrom(clazz)) { - entity = new EntityEnderPearl(world); - entity.setPositionRotation(x, y, z, 0, 0); - } else if (ThrownPotion.class.isAssignableFrom(clazz)) { - entity = new EntityPotion(world, x, y, z, CraftItemStack.asNMSCopy(new ItemStack(org.bukkit.Material.POTION, 1))); - } else if (Fireball.class.isAssignableFrom(clazz)) { - if (SmallFireball.class.isAssignableFrom(clazz)) { - entity = new EntitySmallFireball(world); - } else if (WitherSkull.class.isAssignableFrom(clazz)) { - entity = new EntityWitherSkull(world); - } else { - entity = new EntityLargeFireball(world); - } - entity.setPositionRotation(x, y, z, yaw, pitch); - Vector direction = location.getDirection().multiply(10); - ((EntityFireball) entity).setDirection(direction.getX(), direction.getY(), direction.getZ()); - } - } else if (Minecart.class.isAssignableFrom(clazz)) { - if (PoweredMinecart.class.isAssignableFrom(clazz)) { - entity = new EntityMinecartFurnace(world, x, y, z); - } else if (StorageMinecart.class.isAssignableFrom(clazz)) { - entity = new EntityMinecartChest(world, x, y, z); - } else if (ExplosiveMinecart.class.isAssignableFrom(clazz)) { - entity = new EntityMinecartTNT(world, x, y, z); - } else if (HopperMinecart.class.isAssignableFrom(clazz)) { - entity = new EntityMinecartHopper(world, x, y, z); - } else if (SpawnerMinecart.class.isAssignableFrom(clazz)) { - entity = new EntityMinecartMobSpawner(world, x, y, z); - } else { // Default to rideable minecart for pre-rideable compatibility - entity = new EntityMinecartRideable(world, x, y, z); - } - } else if (EnderSignal.class.isAssignableFrom(clazz)) { - entity = new EntityEnderSignal(world, x, y, z); - } else if (EnderCrystal.class.isAssignableFrom(clazz)) { - entity = new EntityEnderCrystal(world); - entity.setPositionRotation(x, y, z, 0, 0); - } else if (LivingEntity.class.isAssignableFrom(clazz)) { - if (Chicken.class.isAssignableFrom(clazz)) { - entity = new EntityChicken(world); - } else if (Cow.class.isAssignableFrom(clazz)) { - if (MushroomCow.class.isAssignableFrom(clazz)) { - entity = new EntityMushroomCow(world); - } else { - entity = new EntityCow(world); - } - } else if (Golem.class.isAssignableFrom(clazz)) { - if (Snowman.class.isAssignableFrom(clazz)) { - entity = new EntitySnowman(world); - } else if (IronGolem.class.isAssignableFrom(clazz)) { - entity = new EntityIronGolem(world); - } - } else if (Creeper.class.isAssignableFrom(clazz)) { - entity = new EntityCreeper(world); - } else if (Ghast.class.isAssignableFrom(clazz)) { - entity = new EntityGhast(world); - } else if (Pig.class.isAssignableFrom(clazz)) { - entity = new EntityPig(world); - } else if (Player.class.isAssignableFrom(clazz)) { - // need a net server handler for this one - } else if (Sheep.class.isAssignableFrom(clazz)) { - entity = new EntitySheep(world); - } else if (Horse.class.isAssignableFrom(clazz)) { - entity = new EntityHorse(world); - } else if (Skeleton.class.isAssignableFrom(clazz)) { - entity = new EntitySkeleton(world); - } else if (Slime.class.isAssignableFrom(clazz)) { - if (MagmaCube.class.isAssignableFrom(clazz)) { - entity = new EntityMagmaCube(world); - } else { - entity = new EntitySlime(world); - } - } else if (Spider.class.isAssignableFrom(clazz)) { - if (CaveSpider.class.isAssignableFrom(clazz)) { - entity = new EntityCaveSpider(world); - } else { - entity = new EntitySpider(world); - } - } else if (Squid.class.isAssignableFrom(clazz)) { - entity = new EntitySquid(world); - } else if (Tameable.class.isAssignableFrom(clazz)) { - if (Wolf.class.isAssignableFrom(clazz)) { - entity = new EntityWolf(world); - } else if (Ocelot.class.isAssignableFrom(clazz)) { - entity = new EntityOcelot(world); - } - } else if (PigZombie.class.isAssignableFrom(clazz)) { - entity = new EntityPigZombie(world); - } else if (Zombie.class.isAssignableFrom(clazz)) { - entity = new EntityZombie(world); - } else if (Giant.class.isAssignableFrom(clazz)) { - entity = new EntityGiantZombie(world); - } else if (Silverfish.class.isAssignableFrom(clazz)) { - entity = new EntitySilverfish(world); - } else if (Enderman.class.isAssignableFrom(clazz)) { - entity = new EntityEnderman(world); - } else if (Blaze.class.isAssignableFrom(clazz)) { - entity = new EntityBlaze(world); - } else if (Villager.class.isAssignableFrom(clazz)) { - entity = new EntityVillager(world); - } else if (Witch.class.isAssignableFrom(clazz)) { - entity = new EntityWitch(world); - } else if (Wither.class.isAssignableFrom(clazz)) { - entity = new EntityWither(world); - } else if (ComplexLivingEntity.class.isAssignableFrom(clazz)) { - if (EnderDragon.class.isAssignableFrom(clazz)) { - entity = new EntityEnderDragon(world); - } - } else if (Ambient.class.isAssignableFrom(clazz)) { - if (Bat.class.isAssignableFrom(clazz)) { - entity = new EntityBat(world); - } - } - - if (entity != null) { - entity.setLocation(x, y, z, yaw, pitch); - } - } else if (Hanging.class.isAssignableFrom(clazz)) { - Block block = getBlockAt(location); - BlockFace face = BlockFace.SELF; - if (block.getRelative(BlockFace.EAST).getTypeId() == 0) { - face = BlockFace.EAST; - } else if (block.getRelative(BlockFace.NORTH).getTypeId() == 0) { - face = BlockFace.NORTH; - } else if (block.getRelative(BlockFace.WEST).getTypeId() == 0) { - face = BlockFace.WEST; - } else if (block.getRelative(BlockFace.SOUTH).getTypeId() == 0) { - face = BlockFace.SOUTH; - } - int dir; - switch (face) { - case SOUTH: - default: - dir = 0; - break; - case WEST: - dir = 1; - break; - case NORTH: - dir = 2; - break; - case EAST: - dir = 3; - break; - } - - if (Painting.class.isAssignableFrom(clazz)) { - entity = new EntityPainting(world, (int) x, (int) y, (int) z, dir); - } else if (ItemFrame.class.isAssignableFrom(clazz)) { - entity = new EntityItemFrame(world, (int) x, (int) y, (int) z, dir); - } else if (LeashHitch.class.isAssignableFrom(clazz)) { - entity = new EntityLeash(world, (int) x, (int) y, (int) z); - entity.attachedToPlayer = true; - } - - if (entity != null && !((EntityHanging) entity).survives()) { - throw new IllegalArgumentException("Cannot spawn hanging entity for " + clazz.getName() + " at " + location); - } - } else if (TNTPrimed.class.isAssignableFrom(clazz)) { - entity = new EntityTNTPrimed(world, x, y, z, null); - } else if (ExperienceOrb.class.isAssignableFrom(clazz)) { - entity = new EntityExperienceOrb(world, x, y, z, 0); - } else if (Weather.class.isAssignableFrom(clazz)) { - // not sure what this can do - if (LightningStrike.class.isAssignableFrom(clazz)) { - entity = new EntityLightning(world, x, y, z); - // what is this, I don't even - } - } else if (Firework.class.isAssignableFrom(clazz)) { - entity = new EntityFireworks(world, x, y, z, null); - } - - if (entity != null) { - // Spigot start - if (entity instanceof EntityOcelot) - { - ( (EntityOcelot) entity ).spawnBonus = false; - } - // Spigot end - - //if (entity instanceof EntityInsentient) { - // ((EntityInsentient) entity).prepare((GroupDataEntity) null); - //} - - world.addEntity(entity, reason); - return (T) entity.getBukkitEntity(); - } - - throw new IllegalArgumentException("Cannot spawn an entity for " + clazz.getName()); - } - - public ChunkSnapshot getEmptyChunkSnapshot(int x, int z, boolean includeBiome, boolean includeBiomeTempRain) { - return CraftChunk.getEmptyChunkSnapshot(x, z, this, includeBiome, includeBiomeTempRain); - } - - public void setSpawnFlags(boolean allowMonsters, boolean allowAnimals) { - world.setSpawnFlags(allowMonsters, allowAnimals); - } - - public boolean getAllowAnimals() { - return world.allowAnimals; - } - - public boolean getAllowMonsters() { - return world.allowMonsters; - } - - public int getMaxHeight() { - return world.getHeight(); - } - - public int getSeaLevel() { - return 64; - } - - public boolean getKeepSpawnInMemory() { - return world.keepSpawnInMemory; - } - - public void setKeepSpawnInMemory(boolean keepLoaded) { - world.keepSpawnInMemory = keepLoaded; - // Grab the worlds spawn chunk - ChunkCoordinates chunkcoordinates = this.world.getSpawn(); - int chunkCoordX = chunkcoordinates.x >> 4; - int chunkCoordZ = chunkcoordinates.z >> 4; - // Cycle through the 25x25 Chunks around it to load/unload the chunks. - for (int x = -12; x <= 12; x++) { - for (int z = -12; z <= 12; z++) { - if (keepLoaded) { - loadChunk(chunkCoordX + x, chunkCoordZ + z); - } else { - if (isChunkLoaded(chunkCoordX + x, chunkCoordZ + z)) { - if (this.getHandle().getChunkAt(chunkCoordX + x, chunkCoordZ + z) instanceof EmptyChunk) { - unloadChunk(chunkCoordX + x, chunkCoordZ + z, false); - } else { - unloadChunk(chunkCoordX + x, chunkCoordZ + z); - } - } - } - } - } - } - - @Override - public int hashCode() { - return getUID().hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - - final CraftWorld other = (CraftWorld) obj; - - return this.getUID() == other.getUID(); - } - - public File getWorldFolder() { - return ((WorldNBTStorage) world.getDataManager()).getDirectory(); - } - - public void sendPluginMessage(Plugin source, String channel, byte[] message) { - StandardMessenger.validatePluginMessage(server.getMessenger(), source, channel, message); - - for (Player player : getPlayers()) { - player.sendPluginMessage(source, channel, message); - } - } - - public Set getListeningPluginChannels() { - Set result = new HashSet(); - - for (Player player : getPlayers()) { - result.addAll(player.getListeningPluginChannels()); - } - - return result; - } - - public org.bukkit.WorldType getWorldType() { - return org.bukkit.WorldType.getByName(world.getWorldData().getType().name()); - } - - public boolean canGenerateStructures() { - return world.getWorldData().shouldGenerateMapFeatures(); - } - - public long getTicksPerAnimalSpawns() { - return world.ticksPerAnimalSpawns; - } - - public void setTicksPerAnimalSpawns(int ticksPerAnimalSpawns) { - world.ticksPerAnimalSpawns = ticksPerAnimalSpawns; - } - - public long getTicksPerMonsterSpawns() { - return world.ticksPerMonsterSpawns; - } - - public void setTicksPerMonsterSpawns(int ticksPerMonsterSpawns) { - world.ticksPerMonsterSpawns = ticksPerMonsterSpawns; - } - - public void setMetadata(String metadataKey, MetadataValue newMetadataValue) { - server.getWorldMetadata().setMetadata(this, metadataKey, newMetadataValue); - } - - public List getMetadata(String metadataKey) { - return server.getWorldMetadata().getMetadata(this, metadataKey); - } - - public boolean hasMetadata(String metadataKey) { - return server.getWorldMetadata().hasMetadata(this, metadataKey); - } - - public void removeMetadata(String metadataKey, Plugin owningPlugin) { - server.getWorldMetadata().removeMetadata(this, metadataKey, owningPlugin); - } - - public int getMonsterSpawnLimit() { - if (monsterSpawn < 0) { - return server.getMonsterSpawnLimit(); - } - - return monsterSpawn; - } - - public void setMonsterSpawnLimit(int limit) { - monsterSpawn = limit; - } - - public int getAnimalSpawnLimit() { - if (animalSpawn < 0) { - return server.getAnimalSpawnLimit(); - } - - return animalSpawn; - } - - public void setAnimalSpawnLimit(int limit) { - animalSpawn = limit; - } - - public int getWaterAnimalSpawnLimit() { - if (waterAnimalSpawn < 0) { - return server.getWaterAnimalSpawnLimit(); - } - - return waterAnimalSpawn; - } - - public void setWaterAnimalSpawnLimit(int limit) { - waterAnimalSpawn = limit; - } - - public int getAmbientSpawnLimit() { - if (ambientSpawn < 0) { - return server.getAmbientSpawnLimit(); - } - - return ambientSpawn; - } - - public void setAmbientSpawnLimit(int limit) { - ambientSpawn = limit; - } - - - public void playSound(Location loc, Sound sound, float volume, float pitch) { - if (loc == null || sound == null) return; - - double x = loc.getX(); - double y = loc.getY(); - double z = loc.getZ(); - - getHandle().makeSound(x, y, z, CraftSound.getSound(sound), volume, pitch); - } - - public String getGameRuleValue(String rule) { - return getHandle().getGameRules().get(rule); - } - - public boolean setGameRuleValue(String rule, String value) { - // No null values allowed - if (rule == null || value == null) return false; - - if (!isGameRule(rule)) return false; - - getHandle().getGameRules().set(rule, value); - return true; - } - - public String[] getGameRules() { - return getHandle().getGameRules().getGameRules(); - } - - public boolean isGameRule(String rule) { - return getHandle().getGameRules().contains(rule); - } - - public void processChunkGC() { - chunkGCTickCount++; - - if (chunkLoadCount >= server.chunkGCLoadThresh && server.chunkGCLoadThresh > 0) { - chunkLoadCount = 0; - } else if (chunkGCTickCount >= server.chunkGCPeriod && server.chunkGCPeriod > 0) { - chunkGCTickCount = 0; - } else { - return; - } - - ChunkProviderServer cps = world.chunkProviderServer; - for (net.minecraft.server.v1_7_R4.Chunk chunk : cps.chunks.values()) { - // If in use, skip it - if (isChunkInUse(chunk.locX, chunk.locZ)) { - continue; - } - - // Already unloading? - if (cps.unloadQueue.contains(chunk.locX, chunk.locZ)) { - continue; - } - - // Add unload request - cps.queueUnload(chunk.locX, chunk.locZ); - } - } - // Spigot start - private final Spigot spigot = new Spigot() - { - @Override - public void playEffect( Location location, Effect effect, int id, int data, float offsetX, float offsetY, float offsetZ, float speed, int particleCount, int radius ) - { - Validate.notNull( location, "Location cannot be null" ); - Validate.notNull( effect, "Effect cannot be null" ); - Validate.notNull( location.getWorld(), "World cannot be null" ); - Packet packet; - if ( effect.getType() != Effect.Type.PARTICLE ) - { - int packetData = effect.getId(); - packet = new PacketPlayOutWorldEvent( packetData, location.getBlockX(), location.getBlockY(), location.getBlockZ(), id, false ); - } else - { - StringBuilder particleFullName = new StringBuilder(); - particleFullName.append( effect.getName() ); - if ( effect.getData() != null && ( effect.getData().equals( org.bukkit.Material.class ) || effect.getData().equals( org.bukkit.material.MaterialData.class ) ) ) - { - particleFullName.append( '_' ).append( id ); - } - if ( effect.getData() != null && effect.getData().equals( org.bukkit.material.MaterialData.class ) ) - { - particleFullName.append( '_' ).append( data ); - } - packet = new PacketPlayOutWorldParticles( particleFullName.toString(), (float) location.getX(), (float) location.getY(), (float) location.getZ(), offsetX, offsetY, offsetZ, speed, particleCount ); - } - int distance; - radius *= radius; - for ( Player player : getPlayers() ) - { - if ( ( (CraftPlayer) player ).getHandle().playerConnection == null ) - { - continue; - } - if ( !location.getWorld().equals( player.getWorld() ) ) - { - continue; - } - distance = (int) player.getLocation().distanceSquared( location ); - if ( distance <= radius ) - { - ( (CraftPlayer) player ).getHandle().playerConnection.sendPacket( packet ); - } - } - } - - @Override - public void playEffect( Location location, Effect effect ) - { - CraftWorld.this.playEffect( location, effect, 0 ); - } - - @Override - public LightningStrike strikeLightning(Location loc, boolean isSilent) - { - EntityLightning lightning = new EntityLightning( world, loc.getX(), loc.getY(), loc.getZ(), false, isSilent ); - world.strikeLightning( lightning ); - return new CraftLightningStrike( server, lightning ); - } - - @Override - public LightningStrike strikeLightningEffect(Location loc, boolean isSilent) - { - EntityLightning lightning = new EntityLightning( world, loc.getX(), loc.getY(), loc.getZ(), true, isSilent ); - world.strikeLightning( lightning ); - return new CraftLightningStrike( server, lightning ); - } - }; - - public Spigot spigot() - { - return spigot; - } - // Spigot end -} diff --git a/Plugins/Nautilus.Core.CraftBukkit/src/org/bukkit/craftbukkit/v1_7_R4/entity/CraftPlayer.java b/Plugins/Nautilus.Core.CraftBukkit/src/org/bukkit/craftbukkit/v1_7_R4/entity/CraftPlayer.java deleted file mode 100644 index 62bcb238c..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/src/org/bukkit/craftbukkit/v1_7_R4/entity/CraftPlayer.java +++ /dev/null @@ -1,1752 +0,0 @@ -package org.bukkit.craftbukkit.v1_7_R4.entity; - -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.MapMaker; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.net.InetSocketAddress; -import java.net.SocketAddress; -import java.util.Collection; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; -import java.util.logging.Level; -import java.util.logging.Logger; - -import net.minecraft.server.v1_7_R4.*; - -import net.minecraft.util.com.mojang.authlib.GameProfile; -import org.apache.commons.lang.Validate; -import org.apache.commons.lang.NotImplementedException; -import org.bukkit.*; -import org.bukkit.Achievement; -import org.bukkit.BanList; -import org.bukkit.Statistic; -import org.bukkit.Material; -import org.bukkit.Statistic.Type; -import org.bukkit.World; -import org.bukkit.configuration.serialization.DelegateDeserialization; -import org.bukkit.conversations.Conversation; -import org.bukkit.conversations.ConversationAbandonedEvent; -import org.bukkit.conversations.ManuallyAbandonedConversationCanceller; -import org.bukkit.craftbukkit.v1_7_R4.block.CraftSign; -import org.bukkit.craftbukkit.v1_7_R4.conversations.ConversationTracker; -import org.bukkit.craftbukkit.v1_7_R4.CraftEffect; -import org.bukkit.craftbukkit.v1_7_R4.CraftOfflinePlayer; -import org.bukkit.craftbukkit.v1_7_R4.CraftServer; -import org.bukkit.craftbukkit.v1_7_R4.CraftSound; -import org.bukkit.craftbukkit.v1_7_R4.CraftStatistic; -import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; -import org.bukkit.craftbukkit.v1_7_R4.map.CraftMapView; -import org.bukkit.craftbukkit.v1_7_R4.map.RenderData; -import org.bukkit.craftbukkit.v1_7_R4.scoreboard.CraftScoreboard; -import org.bukkit.craftbukkit.v1_7_R4.util.CraftChatMessage; -import org.bukkit.craftbukkit.v1_7_R4.util.CraftMagicNumbers; -import org.bukkit.entity.*; -import org.bukkit.entity.Entity; -import org.bukkit.event.player.PlayerGameModeChangeEvent; -import org.bukkit.event.player.PlayerRegisterChannelEvent; -import org.bukkit.event.player.PlayerTeleportEvent; -import org.bukkit.event.player.PlayerUnregisterChannelEvent; -import org.bukkit.inventory.InventoryView.Property; -import org.bukkit.map.MapView; -import org.bukkit.metadata.MetadataValue; -import org.bukkit.plugin.Plugin; -import org.bukkit.plugin.messaging.StandardMessenger; -import org.bukkit.scoreboard.Scoreboard; - -@DelegateDeserialization(CraftOfflinePlayer.class) -public class CraftPlayer extends CraftHumanEntity implements Player -{ - private long firstPlayed = 0; - private long lastPlayed = 0; - private boolean hasPlayedBefore = false; - private final ConversationTracker conversationTracker = new ConversationTracker(); - private final Set channels = new HashSet(); - private final Set hiddenPlayers = new HashSet(); - private int hash = 0; - private double health = 20; - private boolean scaledHealth = false; - private double healthScale = 20; - - public CraftPlayer(CraftServer server, EntityPlayer entity) - { - super(server, entity); - - firstPlayed = System.currentTimeMillis(); - } - - public GameProfile getProfile() - { - return getHandle().getProfile(); - } - - @Override - public boolean isOp() - { - return server.getHandle().isOp(getProfile()); - } - - @Override - public void setOp(boolean value) - { - if (value == isOp()) - return; - - if (value) - { - server.getHandle().addOp(getProfile()); - } - else - { - server.getHandle().removeOp(getProfile()); - } - - perm.recalculatePermissions(); - } - - public boolean isOnline() - { - for (Object obj : server.getHandle().players) - { - EntityPlayer player = (EntityPlayer) obj; - if (player.getName().equalsIgnoreCase(getName())) - { - return true; - } - } - return false; - } - - public InetSocketAddress getAddress() - { - if (getHandle().playerConnection == null) - return null; - - SocketAddress addr = getHandle().playerConnection.networkManager.getSocketAddress(); - if (addr instanceof InetSocketAddress) - { - return (InetSocketAddress) addr; - } - else - { - return null; - } - } - - @Override - public double getEyeHeight() - { - return getEyeHeight(false); - } - - @Override - public double getEyeHeight(boolean ignoreSneaking) - { - if (ignoreSneaking) - { - return 1.62D; - } - else - { - if (isSneaking()) - { - return 1.54D; - } - else - { - return 1.62D; - } - } - } - - @Override - public int _INVALID_getLastDamage() - { - return (int) getLastDamage(); - } - - @Override - public void _INVALID_setLastDamage(int i) - { - setLastDamage(i); - } - - @Override - public void sendRawMessage(String message) - { - if (getHandle().playerConnection == null) - return; - - for (IChatBaseComponent component : CraftChatMessage.fromString(message)) - { - getHandle().playerConnection.sendPacket(new PacketPlayOutChat(component)); - } - } - - @Override - public void sendMessage(String message) - { - if (!conversationTracker.isConversingModaly()) - { - this.sendRawMessage(message); - } - } - - @Override - public void sendMessage(String[] messages) - { - for (String message : messages) - { - sendMessage(message); - } - } - - @Override - public String getDisplayName() - { - return getHandle().displayName; - } - - @Override - public void setDisplayName(final String name) - { - getHandle().displayName = name == null ? getName() : name; - } - - @Override - public String getPlayerListName() - { - return getHandle().listName; - } - - @Override - public void setPlayerListName(String name) - { - String oldName = getHandle().listName; - - if (name == null) - { - name = getName(); - } - - if (oldName.equals(name)) - { - return; - } - - if (name.length() > 16) - { - throw new IllegalArgumentException("Player list names can only be a maximum of 16 characters long"); - } - - // Collisions will make for invisible people - for (int i = 0; i < server.getHandle().players.size(); ++i) - { - if (((EntityPlayer) server.getHandle().players.get(i)).listName.equals(name)) - { - throw new IllegalArgumentException(name + " is already assigned as a player list name for someone"); - } - } - - getHandle().listName = name; - - // Change the name on the client side - PacketPlayOutPlayerInfo oldpacket = new PacketPlayOutPlayerInfo(oldName, false, 9999); - PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(name, true, getHandle().ping); - for (int i = 0; i < server.getHandle().players.size(); ++i) - { - EntityPlayer entityplayer = (EntityPlayer) server.getHandle().players.get(i); - if (entityplayer.playerConnection == null) - continue; - - if (entityplayer.getBukkitEntity().canSee(this)) - { - entityplayer.playerConnection.sendPacket(oldpacket); - entityplayer.playerConnection.sendPacket(packet); - } - } - } - - @Override - public boolean equals(Object obj) - { - if (!(obj instanceof OfflinePlayer)) - { - return false; - } - OfflinePlayer other = (OfflinePlayer) obj; - if ((this.getUniqueId() == null) || (other.getUniqueId() == null)) - { - return false; - } - - boolean uuidEquals = this.getUniqueId().equals(other.getUniqueId()); - boolean idEquals = true; - - if (other instanceof CraftPlayer) - { - idEquals = this.getEntityId() == ((CraftPlayer) other).getEntityId(); - } - - return uuidEquals && idEquals; - } - - @Override - public void kickPlayer(String message) - { - org.spigotmc.AsyncCatcher.catchOp("player kick"); // Spigot - if (getHandle().playerConnection == null) - return; - - getHandle().playerConnection.disconnect(message == null ? "" : message); - } - - @Override - public void setCompassTarget(Location loc) - { - if (getHandle().playerConnection == null) - return; - - // Do not directly assign here, from the packethandler we'll assign it. - getHandle().playerConnection.sendPacket(new PacketPlayOutSpawnPosition(loc.getBlockX(), loc.getBlockY(), loc - .getBlockZ())); - } - - @Override - public Location getCompassTarget() - { - return getHandle().compassTarget; - } - - @Override - public void chat(String msg) - { - if (getHandle().playerConnection == null) - return; - - getHandle().playerConnection.chat(msg, false); - } - - @Override - public boolean performCommand(String command) - { - return server.dispatchCommand(this, command); - } - - @Override - public void playNote(Location loc, byte instrument, byte note) - { - if (getHandle().playerConnection == null) - return; - - String instrumentName = null; - switch (instrument) - { - case 0: - instrumentName = "harp"; - break; - case 1: - instrumentName = "bd"; - break; - case 2: - instrumentName = "snare"; - break; - case 3: - instrumentName = "hat"; - break; - case 4: - instrumentName = "bassattack"; - break; - } - getHandle().playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect("note." + instrumentName, loc - .getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, note)); - } - - @Override - public void playNote(Location loc, Instrument instrument, Note note) - { - if (getHandle().playerConnection == null) - return; - - String instrumentName = null; - switch (instrument.ordinal()) - { - case 0: - instrumentName = "harp"; - break; - case 1: - instrumentName = "bd"; - break; - case 2: - instrumentName = "snare"; - break; - case 3: - instrumentName = "hat"; - break; - case 4: - instrumentName = "bassattack"; - break; - } - getHandle().playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect("note." + instrumentName, loc - .getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, note.getId())); - } - - @Override - public void playSound(Location loc, Sound sound, float volume, float pitch) - { - if (sound == null) - { - return; - } - playSound(loc, CraftSound.getSound(sound), volume, pitch); - } - - @Override - public void playSound(Location loc, String sound, float volume, float pitch) - { - if (loc == null || sound == null || getHandle().playerConnection == null) - return; - - double x = loc.getBlockX() + 0.5; - double y = loc.getBlockY() + 0.5; - double z = loc.getBlockZ() + 0.5; - - PacketPlayOutNamedSoundEffect packet = new PacketPlayOutNamedSoundEffect(sound, x, y, z, volume, pitch); - getHandle().playerConnection.sendPacket(packet); - } - - @Override - public void playEffect(Location loc, Effect effect, int data) - { - if (getHandle().playerConnection == null) - return; - - int packetData = effect.getId(); - PacketPlayOutWorldEvent packet = new PacketPlayOutWorldEvent(packetData, loc.getBlockX(), loc.getBlockY(), - loc.getBlockZ(), data, false); - getHandle().playerConnection.sendPacket(packet); - } - - @Override - public void playEffect(Location loc, Effect effect, T data) - { - if (data != null) - { - Validate.isTrue(data.getClass().equals(effect.getData()), "Wrong kind of data for this effect!"); - } - else - { - Validate.isTrue(effect.getData() == null, "Wrong kind of data for this effect!"); - } - - int datavalue = data == null ? 0 : CraftEffect.getDataValue(effect, data); - playEffect(loc, effect, datavalue); - } - - @Override - public void sendBlockChange(Location loc, Material material, byte data) - { - sendBlockChange(loc, material.getId(), data); - } - - @Override - public void sendBlockChange(Location loc, int material, byte data) - { - if (getHandle().playerConnection == null) - return; - - PacketPlayOutBlockChange packet = new PacketPlayOutBlockChange(loc.getBlockX(), loc.getBlockY(), - loc.getBlockZ(), ((CraftWorld) loc.getWorld()).getHandle()); - - packet.block = CraftMagicNumbers.getBlock(material); - packet.data = data; - getHandle().playerConnection.sendPacket(packet); - } - - @Override - public void sendSignChange(Location loc, String[] lines) - { - if (getHandle().playerConnection == null) - { - return; - } - - if (lines == null) - { - lines = new String[4]; - } - - Validate.notNull(loc, "Location can not be null"); - if (lines.length < 4) - { - throw new IllegalArgumentException("Must have at least 4 lines"); - } - - // Limit to 15 chars per line and set null lines to blank - String[] astring = CraftSign.sanitizeLines(lines); - - getHandle().playerConnection.sendPacket(new PacketPlayOutUpdateSign(loc.getBlockX(), loc.getBlockY(), loc - .getBlockZ(), astring)); - } - - @Override - public boolean sendChunkChange(Location loc, int sx, int sy, int sz, byte[] data) - { - if (getHandle().playerConnection == null) - return false; - - /* - * int x = loc.getBlockX(); int y = loc.getBlockY(); int z = - * loc.getBlockZ(); - * - * int cx = x >> 4; int cz = z >> 4; - * - * if (sx <= 0 || sy <= 0 || sz <= 0) { return false; } - * - * if ((x + sx - 1) >> 4 != cx || (z + sz - 1) >> 4 != cz || y < 0 || y - * + sy > 128) { return false; } - * - * if (data.length != (sx * sy * sz * 5) / 2) { return false; } - * - * Packet51MapChunk packet = new Packet51MapChunk(x, y, z, sx, sy, sz, - * data); - * - * getHandle().playerConnection.sendPacket(packet); - * - * return true; - */ - - throw new NotImplementedException("Chunk changes do not yet work"); // TODO: - // Chunk - // changes. - } - - @Override - public void sendMap(MapView map) - { - if (getHandle().playerConnection == null) - return; - - RenderData data = ((CraftMapView) map).render(this); - for (int x = 0; x < 128; ++x) - { - byte[] bytes = new byte[131]; - bytes[1] = (byte) x; - for (int y = 0; y < 128; ++y) - { - bytes[y + 3] = data.buffer[y * 128 + x]; - } - PacketPlayOutMap packet = new PacketPlayOutMap(map.getId(), bytes); - getHandle().playerConnection.sendPacket(packet); - } - } - - @Override - public boolean teleport(Location location, PlayerTeleportEvent.TeleportCause cause) - { - EntityPlayer entity = getHandle(); - - if (getHealth() == 0 || entity.dead) - { - return false; - } - - if (entity.playerConnection == null || entity.playerConnection.isDisconnected()) - { - return false; - } - - // Spigot Start - // if (entity.vehicle != null || entity.passenger != null) { - // return false; - // } - // Spigot End - - // From = Players current Location - Location from = this.getLocation(); - // To = Players new Location if Teleport is Successful - Location to = location; - // Create & Call the Teleport Event. - PlayerTeleportEvent event = new PlayerTeleportEvent(this, from, to, cause); - server.getPluginManager().callEvent(event); - - // Return False to inform the Plugin that the Teleport was - // unsuccessful/cancelled. - if (event.isCancelled()) - { - return false; - } - - // Spigot Start - eject(); - leaveVehicle(); - // Spigot End - - // Update the From Location - from = event.getFrom(); - // Grab the new To Location dependent on whether the event was - // cancelled. - to = event.getTo(); - // Grab the To and From World Handles. - WorldServer fromWorld = ((CraftWorld) from.getWorld()).getHandle(); - WorldServer toWorld = ((CraftWorld) to.getWorld()).getHandle(); - - // Close any foreign inventory - if (getHandle().activeContainer != getHandle().defaultContainer) - { - getHandle().closeInventory(); - } - - // Check if the fromWorld and toWorld are the same. - if (fromWorld == toWorld) - { - entity.playerConnection.teleport(to); - } - else - { - server.getHandle().moveToWorld(entity, toWorld.dimension, true, to, true); - } - return true; - } - - @Override - public void setSneaking(boolean sneak) - { - getHandle().setSneaking(sneak); - } - - @Override - public boolean isSneaking() - { - return getHandle().isSneaking(); - } - - @Override - public boolean isSprinting() - { - return getHandle().isSprinting(); - } - - @Override - public void setSprinting(boolean sprinting) - { - getHandle().setSprinting(sprinting); - } - - @Override - public void loadData() - { - server.getHandle().playerFileData.load(getHandle()); - } - - @Override - public void saveData() - { - server.getHandle().playerFileData.save(getHandle()); - } - - @Deprecated - @Override - public void updateInventory() - { - getHandle().updateInventory(getHandle().activeContainer); - } - - @Override - public void setSleepingIgnored(boolean isSleeping) - { - getHandle().fauxSleeping = isSleeping; - ((CraftWorld) getWorld()).getHandle().checkSleepStatus(); - } - - @Override - public boolean isSleepingIgnored() - { - return getHandle().fauxSleeping; - } - - @Override - public void awardAchievement(Achievement achievement) - { - Validate.notNull(achievement, "Achievement cannot be null"); - if (achievement.hasParent() && !hasAchievement(achievement.getParent())) - { - awardAchievement(achievement.getParent()); - } - getHandle().getStatisticManager().setStatistic(getHandle(), CraftStatistic.getNMSAchievement(achievement), 1); - getHandle().getStatisticManager().updateStatistics(getHandle()); - } - - @Override - public void removeAchievement(Achievement achievement) - { - Validate.notNull(achievement, "Achievement cannot be null"); - for (Achievement achieve : Achievement.values()) - { - if (achieve.getParent() == achievement && hasAchievement(achieve)) - { - removeAchievement(achieve); - } - } - getHandle().getStatisticManager().setStatistic(getHandle(), CraftStatistic.getNMSAchievement(achievement), 0); - } - - @Override - public boolean hasAchievement(Achievement achievement) - { - Validate.notNull(achievement, "Achievement cannot be null"); - return getHandle().getStatisticManager().hasAchievement(CraftStatistic.getNMSAchievement(achievement)); - } - - @Override - public void incrementStatistic(Statistic statistic) - { - incrementStatistic(statistic, 1); - } - - @Override - public void decrementStatistic(Statistic statistic) - { - decrementStatistic(statistic, 1); - } - - @Override - public int getStatistic(Statistic statistic) - { - Validate.notNull(statistic, "Statistic cannot be null"); - Validate.isTrue(statistic.getType() == Type.UNTYPED, "Must supply additional paramater for this statistic"); - return getHandle().getStatisticManager().getStatisticValue(CraftStatistic.getNMSStatistic(statistic)); - } - - @Override - public void incrementStatistic(Statistic statistic, int amount) - { - Validate.isTrue(amount > 0, "Amount must be greater than 0"); - setStatistic(statistic, getStatistic(statistic) + amount); - } - - @Override - public void decrementStatistic(Statistic statistic, int amount) - { - Validate.isTrue(amount > 0, "Amount must be greater than 0"); - setStatistic(statistic, getStatistic(statistic) - amount); - } - - @Override - public void setStatistic(Statistic statistic, int newValue) - { - Validate.notNull(statistic, "Statistic cannot be null"); - Validate.isTrue(statistic.getType() == Type.UNTYPED, "Must supply additional paramater for this statistic"); - Validate.isTrue(newValue >= 0, "Value must be greater than or equal to 0"); - net.minecraft.server.v1_7_R4.Statistic nmsStatistic = CraftStatistic.getNMSStatistic(statistic); - getHandle().getStatisticManager().setStatistic(getHandle(), nmsStatistic, newValue); - } - - @Override - public void incrementStatistic(Statistic statistic, Material material) - { - incrementStatistic(statistic, material, 1); - } - - @Override - public void decrementStatistic(Statistic statistic, Material material) - { - decrementStatistic(statistic, material, 1); - } - - @Override - public int getStatistic(Statistic statistic, Material material) - { - Validate.notNull(statistic, "Statistic cannot be null"); - Validate.notNull(material, "Material cannot be null"); - Validate.isTrue(statistic.getType() == Type.BLOCK || statistic.getType() == Type.ITEM, - "This statistic does not take a Material parameter"); - net.minecraft.server.v1_7_R4.Statistic nmsStatistic = CraftStatistic.getMaterialStatistic(statistic, material); - Validate.notNull(nmsStatistic, "The supplied Material does not have a corresponding statistic"); - return getHandle().getStatisticManager().getStatisticValue(nmsStatistic); - } - - @Override - public void incrementStatistic(Statistic statistic, Material material, int amount) - { - Validate.isTrue(amount > 0, "Amount must be greater than 0"); - setStatistic(statistic, material, getStatistic(statistic, material) + amount); - } - - @Override - public void decrementStatistic(Statistic statistic, Material material, int amount) - { - Validate.isTrue(amount > 0, "Amount must be greater than 0"); - setStatistic(statistic, material, getStatistic(statistic, material) - amount); - } - - @Override - public void setStatistic(Statistic statistic, Material material, int newValue) - { - Validate.notNull(statistic, "Statistic cannot be null"); - Validate.notNull(material, "Material cannot be null"); - Validate.isTrue(newValue >= 0, "Value must be greater than or equal to 0"); - Validate.isTrue(statistic.getType() == Type.BLOCK || statistic.getType() == Type.ITEM, - "This statistic does not take a Material parameter"); - net.minecraft.server.v1_7_R4.Statistic nmsStatistic = CraftStatistic.getMaterialStatistic(statistic, material); - Validate.notNull(nmsStatistic, "The supplied Material does not have a corresponding statistic"); - getHandle().getStatisticManager().setStatistic(getHandle(), nmsStatistic, newValue); - } - - @Override - public void incrementStatistic(Statistic statistic, EntityType entityType) - { - incrementStatistic(statistic, entityType, 1); - } - - @Override - public void decrementStatistic(Statistic statistic, EntityType entityType) - { - decrementStatistic(statistic, entityType, 1); - } - - @Override - public int getStatistic(Statistic statistic, EntityType entityType) - { - Validate.notNull(statistic, "Statistic cannot be null"); - Validate.notNull(entityType, "EntityType cannot be null"); - Validate.isTrue(statistic.getType() == Type.ENTITY, "This statistic does not take an EntityType parameter"); - net.minecraft.server.v1_7_R4.Statistic nmsStatistic = CraftStatistic.getEntityStatistic(statistic, entityType); - Validate.notNull(nmsStatistic, "The supplied EntityType does not have a corresponding statistic"); - return getHandle().getStatisticManager().getStatisticValue(nmsStatistic); - } - - @Override - public void incrementStatistic(Statistic statistic, EntityType entityType, int amount) - { - Validate.isTrue(amount > 0, "Amount must be greater than 0"); - setStatistic(statistic, entityType, getStatistic(statistic, entityType) + amount); - } - - @Override - public void decrementStatistic(Statistic statistic, EntityType entityType, int amount) - { - Validate.isTrue(amount > 0, "Amount must be greater than 0"); - setStatistic(statistic, entityType, getStatistic(statistic, entityType) - amount); - } - - @Override - public void setStatistic(Statistic statistic, EntityType entityType, int newValue) - { - Validate.notNull(statistic, "Statistic cannot be null"); - Validate.notNull(entityType, "EntityType cannot be null"); - Validate.isTrue(newValue >= 0, "Value must be greater than or equal to 0"); - Validate.isTrue(statistic.getType() == Type.ENTITY, "This statistic does not take an EntityType parameter"); - net.minecraft.server.v1_7_R4.Statistic nmsStatistic = CraftStatistic.getEntityStatistic(statistic, entityType); - Validate.notNull(nmsStatistic, "The supplied EntityType does not have a corresponding statistic"); - getHandle().getStatisticManager().setStatistic(getHandle(), nmsStatistic, newValue); - } - - @Override - public void setPlayerTime(long time, boolean relative) - { - getHandle().timeOffset = time; - getHandle().relativeTime = relative; - } - - @Override - public long getPlayerTimeOffset() - { - return getHandle().timeOffset; - } - - @Override - public long getPlayerTime() - { - return getHandle().getPlayerTime(); - } - - @Override - public boolean isPlayerTimeRelative() - { - return getHandle().relativeTime; - } - - @Override - public void resetPlayerTime() - { - setPlayerTime(0, true); - } - - @Override - public void setPlayerWeather(WeatherType type) - { - getHandle().setPlayerWeather(type, true); - } - - @Override - public WeatherType getPlayerWeather() - { - return getHandle().getPlayerWeather(); - } - - @Override - public void resetPlayerWeather() - { - getHandle().resetPlayerWeather(); - } - - @Override - public boolean isBanned() - { - return server.getBanList(BanList.Type.NAME).isBanned(getName()); - } - - @Override - public void setBanned(boolean value) - { - if (value) - { - server.getBanList(BanList.Type.NAME).addBan(getName(), null, null, null); - } - else - { - server.getBanList(BanList.Type.NAME).pardon(getName()); - } - } - - @Override - public boolean isWhitelisted() - { - return server.getHandle().getWhitelist().isWhitelisted(getProfile()); - } - - @Override - public void setWhitelisted(boolean value) - { - if (value) - { - server.getHandle().addWhitelist(getProfile()); - } - else - { - server.getHandle().removeWhitelist(getProfile()); - } - } - - @Override - public void setGameMode(GameMode mode) - { - if (getHandle().playerConnection == null) - return; - - if (mode == null) - { - throw new IllegalArgumentException("Mode cannot be null"); - } - - if (mode != getGameMode()) - { - PlayerGameModeChangeEvent event = new PlayerGameModeChangeEvent(this, mode); - server.getPluginManager().callEvent(event); - if (event.isCancelled()) - { - return; - } - - getHandle().playerInteractManager.setGameMode(EnumGamemode.getById(mode.getValue())); - getHandle().fallDistance = 0; - getHandle().playerConnection.sendPacket(new PacketPlayOutGameStateChange(3, mode.getValue())); - } - } - - @Override - public GameMode getGameMode() - { - return GameMode.getByValue(getHandle().playerInteractManager.getGameMode().getId()); - } - - public void giveExp(int exp) - { - getHandle().giveExp(exp); - } - - public void giveExpLevels(int levels) - { - getHandle().levelDown(levels); - } - - public float getExp() - { - return getHandle().exp; - } - - public void setExp(float exp) - { - getHandle().exp = exp; - getHandle().lastSentExp = -1; - } - - public int getLevel() - { - return getHandle().expLevel; - } - - public void setLevel(int level) - { - getHandle().expLevel = level; - getHandle().lastSentExp = -1; - } - - public int getTotalExperience() - { - return getHandle().expTotal; - } - - public void setTotalExperience(int exp) - { - getHandle().expTotal = exp; - } - - public float getExhaustion() - { - return getHandle().getFoodData().exhaustionLevel; - } - - public void setExhaustion(float value) - { - getHandle().getFoodData().exhaustionLevel = value; - } - - public float getSaturation() - { - return getHandle().getFoodData().saturationLevel; - } - - public void setSaturation(float value) - { - getHandle().getFoodData().saturationLevel = value; - } - - public int getFoodLevel() - { - return getHandle().getFoodData().foodLevel; - } - - public void setFoodLevel(int value) - { - getHandle().getFoodData().foodLevel = value; - } - - public Location getBedSpawnLocation() - { - World world = getServer().getWorld(getHandle().spawnWorld); - ChunkCoordinates bed = getHandle().getBed(); - - if (world != null && bed != null) - { - bed = EntityHuman.getBed(((CraftWorld) world).getHandle(), bed, getHandle().isRespawnForced()); - if (bed != null) - { - return new Location(world, bed.x, bed.y, bed.z); - } - } - return null; - } - - public void setBedSpawnLocation(Location location) - { - setBedSpawnLocation(location, false); - } - - public void setBedSpawnLocation(Location location, boolean override) - { - if (location == null) - { - getHandle().setRespawnPosition(null, override); - } - else - { - getHandle().setRespawnPosition( - new ChunkCoordinates(location.getBlockX(), location.getBlockY(), location.getBlockZ()), override); - getHandle().spawnWorld = location.getWorld().getName(); - } - } - - 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 (!override && hiddenPlayers.contains(player.getUniqueId())) - return; - hiddenPlayers.add(player.getUniqueId()); - - // remove this player from the hidden player's EntityTrackerEntry - EntityTracker tracker = ((WorldServer) entity.world).tracker; - EntityPlayer other = ((CraftPlayer) player).getHandle(); - EntityTrackerEntry entry = (EntityTrackerEntry) tracker.trackedEntities.get(other.getId()); - if (entry != null) - { - entry.clear(getHandle()); - } - - // remove the hidden player from this player user list - if (hideList) - getHandle().playerConnection - .sendPacket(new PacketPlayOutPlayerInfo(player.getPlayerListName(), false, 9999)); - } - - - public void showPlayer(Player player) - { - Validate.notNull(player, "shown player cannot be null"); - if (getHandle().playerConnection == null) - return; - if (equals(player)) - return; - if (!hiddenPlayers.contains(player.getUniqueId())) - return; - hiddenPlayers.remove(player.getUniqueId()); - - EntityTracker tracker = ((WorldServer) entity.world).tracker; - EntityPlayer other = ((CraftPlayer) player).getHandle(); - EntityTrackerEntry entry = (EntityTrackerEntry) tracker.trackedEntities.get(other.getId()); - if (entry != null && !entry.trackedPlayers.contains(getHandle())) - { - entry.updatePlayer(getHandle()); - } - - getHandle().playerConnection.sendPacket(new PacketPlayOutPlayerInfo(player.getPlayerListName(), true, - getHandle().ping)); - } - - public void removeDisconnectingPlayer(Player player) - { - hiddenPlayers.remove(player.getUniqueId()); - } - - public boolean canSee(Player player) - { - return !hiddenPlayers.contains(player.getUniqueId()); - } - - public Map serialize() - { - Map result = new LinkedHashMap(); - - result.put("name", getName()); - - return result; - } - - public Player getPlayer() - { - return this; - } - - @Override - public EntityPlayer getHandle() - { - return (EntityPlayer) entity; - } - - public void setHandle(final EntityPlayer entity) - { - super.setHandle(entity); - } - - @Override - public String toString() - { - return "CraftPlayer{" + "name=" + getName() + '}'; - } - - @Override - public int hashCode() - { - if (hash == 0 || hash == 485) - { - hash = 97 * 5 + (this.getUniqueId() != null ? this.getUniqueId().hashCode() : 0); - } - return hash; - } - - public long getFirstPlayed() - { - return firstPlayed; - } - - public long getLastPlayed() - { - return lastPlayed; - } - - public boolean hasPlayedBefore() - { - return hasPlayedBefore; - } - - public void setFirstPlayed(long firstPlayed) - { - this.firstPlayed = firstPlayed; - } - - public void readExtraData(NBTTagCompound nbttagcompound) - { - hasPlayedBefore = true; - if (nbttagcompound.hasKey("bukkit")) - { - NBTTagCompound data = nbttagcompound.getCompound("bukkit"); - - if (data.hasKey("firstPlayed")) - { - firstPlayed = data.getLong("firstPlayed"); - lastPlayed = data.getLong("lastPlayed"); - } - - if (data.hasKey("newExp")) - { - EntityPlayer handle = getHandle(); - handle.newExp = data.getInt("newExp"); - handle.newTotalExp = data.getInt("newTotalExp"); - handle.newLevel = data.getInt("newLevel"); - handle.expToDrop = data.getInt("expToDrop"); - handle.keepLevel = data.getBoolean("keepLevel"); - } - } - } - - public void setExtraData(NBTTagCompound nbttagcompound) - { - if (!nbttagcompound.hasKey("bukkit")) - { - nbttagcompound.set("bukkit", new NBTTagCompound()); - } - - NBTTagCompound data = nbttagcompound.getCompound("bukkit"); - EntityPlayer handle = getHandle(); - data.setInt("newExp", handle.newExp); - data.setInt("newTotalExp", handle.newTotalExp); - data.setInt("newLevel", handle.newLevel); - data.setInt("expToDrop", handle.expToDrop); - data.setBoolean("keepLevel", handle.keepLevel); - data.setLong("firstPlayed", getFirstPlayed()); - data.setLong("lastPlayed", System.currentTimeMillis()); - data.setString("lastKnownName", handle.getName()); - } - - public boolean beginConversation(Conversation conversation) - { - return conversationTracker.beginConversation(conversation); - } - - public void abandonConversation(Conversation conversation) - { - conversationTracker.abandonConversation(conversation, new ConversationAbandonedEvent(conversation, - new ManuallyAbandonedConversationCanceller())); - } - - public void abandonConversation(Conversation conversation, ConversationAbandonedEvent details) - { - conversationTracker.abandonConversation(conversation, details); - } - - public void acceptConversationInput(String input) - { - conversationTracker.acceptConversationInput(input); - } - - public boolean isConversing() - { - return conversationTracker.isConversing(); - } - - public void sendPluginMessage(Plugin source, String channel, byte[] message) - { - StandardMessenger.validatePluginMessage(server.getMessenger(), source, channel, message); - if (getHandle().playerConnection == null) - return; - - if (channels.contains(channel)) - { - PacketPlayOutCustomPayload packet = new PacketPlayOutCustomPayload(channel, message); - getHandle().playerConnection.sendPacket(packet); - } - } - - public void setTexturePack(String url) - { - setResourcePack(url); - } - - @Override - public void setResourcePack(String url) - { - Validate.notNull(url, "Resource pack URL cannot be null"); - - getHandle().setResourcePack(url); - } - - public void addChannel(String channel) - { - com.google.common.base.Preconditions.checkState(channels.size() < 128, "Too many channels registered"); // Spigot - if (channels.add(channel)) - { - server.getPluginManager().callEvent(new PlayerRegisterChannelEvent(this, channel)); - } - } - - public void removeChannel(String channel) - { - if (channels.remove(channel)) - { - server.getPluginManager().callEvent(new PlayerUnregisterChannelEvent(this, channel)); - } - } - - public Set getListeningPluginChannels() - { - return ImmutableSet.copyOf(channels); - } - - public void sendSupportedChannels() - { - if (getHandle().playerConnection == null) - return; - Set listening = server.getMessenger().getIncomingChannels(); - - if (!listening.isEmpty()) - { - ByteArrayOutputStream stream = new ByteArrayOutputStream(); - - for (String channel : listening) - { - try - { - stream.write(channel.getBytes("UTF8")); - stream.write((byte) 0); - } - catch (IOException ex) - { - Logger.getLogger(CraftPlayer.class.getName()).log(Level.SEVERE, - "Could not send Plugin Channel REGISTER to " + getName(), ex); - } - } - - getHandle().playerConnection.sendPacket(new PacketPlayOutCustomPayload("REGISTER", stream.toByteArray())); - } - } - - @Override - public EntityType getType() - { - return EntityType.PLAYER; - } - - @Override - public void setMetadata(String metadataKey, MetadataValue newMetadataValue) - { - server.getPlayerMetadata().setMetadata(this, metadataKey, newMetadataValue); - } - - @Override - public List getMetadata(String metadataKey) - { - return server.getPlayerMetadata().getMetadata(this, metadataKey); - } - - @Override - public boolean hasMetadata(String metadataKey) - { - return server.getPlayerMetadata().hasMetadata(this, metadataKey); - } - - @Override - public void removeMetadata(String metadataKey, Plugin owningPlugin) - { - server.getPlayerMetadata().removeMetadata(this, metadataKey, owningPlugin); - } - - @Override - public boolean setWindowProperty(Property prop, int value) - { - Container container = getHandle().activeContainer; - if (container.getBukkitView().getType() != prop.getType()) - { - return false; - } - getHandle().setContainerData(container, prop.getId(), value); - return true; - } - - public void disconnect(String reason) - { - conversationTracker.abandonAllConversations(); - perm.clearPermissions(); - } - - public boolean isFlying() - { - return getHandle().abilities.isFlying; - } - - public void setFlying(boolean value) - { - if (!getAllowFlight() && value) - { - throw new IllegalArgumentException("Cannot make player fly if getAllowFlight() is false"); - } - - getHandle().abilities.isFlying = value; - getHandle().updateAbilities(); - } - - public boolean getAllowFlight() - { - return getHandle().abilities.canFly; - } - - public void setAllowFlight(boolean value) - { - if (isFlying() && !value) - { - getHandle().abilities.isFlying = false; - } - - getHandle().abilities.canFly = value; - getHandle().updateAbilities(); - } - - @Override - public int getNoDamageTicks() - { - if (getHandle().invulnerableTicks > 0) - { - return Math.max(getHandle().invulnerableTicks, getHandle().noDamageTicks); - } - else - { - return getHandle().noDamageTicks; - } - } - - public void setFlySpeed(float value) - { - validateSpeed(value); - EntityPlayer player = getHandle(); - player.abilities.flySpeed = Math.max(value, 0.0001f) / 2f; // Spigot - player.updateAbilities(); - - } - - public void setWalkSpeed(float value) - { - validateSpeed(value); - EntityPlayer player = getHandle(); - player.abilities.walkSpeed = Math.max(value, 0.0001f) / 2f; // Spigot - player.updateAbilities(); - } - - public float getFlySpeed() - { - return getHandle().abilities.flySpeed * 2f; - } - - public float getWalkSpeed() - { - return getHandle().abilities.walkSpeed * 2f; - } - - private void validateSpeed(float value) - { - if (value < 0) - { - if (value < -1f) - { - throw new IllegalArgumentException(value + " is too low"); - } - } - else - { - if (value > 1f) - { - throw new IllegalArgumentException(value + " is too high"); - } - } - } - - @Override - public void setMaxHealth(double amount) - { - super.setMaxHealth(amount); - this.health = Math.min(this.health, health); - getHandle().triggerHealthUpdate(); - } - - @Override - public void _INVALID_setMaxHealth(int i) - { - setMaxHealth(i); - } - - @Override - public void resetMaxHealth() - { - super.resetMaxHealth(); - getHandle().triggerHealthUpdate(); - } - - public CraftScoreboard getScoreboard() - { - return this.server.getScoreboardManager().getPlayerBoard(this); - } - - public void setScoreboard(Scoreboard scoreboard) - { - Validate.notNull(scoreboard, "Scoreboard cannot be null"); - PlayerConnection playerConnection = getHandle().playerConnection; - if (playerConnection == null) - { - throw new IllegalStateException("Cannot set scoreboard yet"); - } - if (playerConnection.isDisconnected()) - { - // throw new - // IllegalStateException("Cannot set scoreboard for invalid CraftPlayer"); - // // Spigot - remove this as Mojang's semi asynchronous Netty - // implementation can lead to races - } - - this.server.getScoreboardManager().setPlayerBoard(this, scoreboard); - } - - public void setHealthScale(double value) - { - Validate.isTrue((float) value > 0F, "Must be greater than 0"); - healthScale = value; - scaledHealth = true; - updateScaledHealth(); - } - - public double getHealthScale() - { - return healthScale; - } - - public void setHealthScaled(boolean scale) - { - if (scaledHealth != (scaledHealth = scale)) - { - updateScaledHealth(); - } - } - - public boolean isHealthScaled() - { - return scaledHealth; - } - - public float getScaledHealth() - { - return (float) (isHealthScaled() ? getHealth() * getHealthScale() / getMaxHealth() : getHealth()); - } - - @Override - public void _INVALID_damage(int i) - { - damage(i); - } - - @Override - public void _INVALID_damage(int i, Entity entity) - { - damage(i, entity); - } - - @Override - public double getHealth() - { - return health; - } - - @Override - public int _INVALID_getHealth() - { - return (int) getHealth(); - } - - @Override - public void _INVALID_setHealth(int i) - { - setHealth(i); - } - - @Override - public int _INVALID_getMaxHealth() - { - return (int) getMaxHealth(); - } - - public void setRealHealth(double health) - { - this.health = health; - } - - public void updateScaledHealth() - { - AttributeMapServer attributemapserver = (AttributeMapServer) getHandle().getAttributeMap(); - Set set = attributemapserver.getAttributes(); - - injectScaledMaxHealth(set, true); - - getHandle().getDataWatcher().watch(6, (float) getScaledHealth()); - getHandle().playerConnection.sendPacket(new PacketPlayOutUpdateHealth(getScaledHealth(), getHandle() - .getFoodData().getFoodLevel(), getHandle().getFoodData().getSaturationLevel())); - getHandle().playerConnection.sendPacket(new PacketPlayOutUpdateAttributes(getHandle().getId(), set)); - - set.clear(); - getHandle().maxHealthCache = getMaxHealth(); - } - - public void injectScaledMaxHealth(Collection collection, boolean force) - { - if (!scaledHealth && !force) - { - return; - } - for (Object genericInstance : collection) - { - IAttribute attribute = ((AttributeInstance) genericInstance).getAttribute(); - if (attribute.getName().equals("generic.maxHealth")) - { - collection.remove(genericInstance); - break; - } - } - // Spigot start - double healthMod = scaledHealth ? healthScale : getMaxHealth(); - if (healthMod >= Float.MAX_VALUE || healthMod <= 0) - { - healthMod = 20; // Reset health - getServer().getLogger().warning(getName() + " tried to crash the server with a large health attribute"); - } - collection.add(new AttributeModifiable(getHandle().getAttributeMap(), (new AttributeRanged("generic.maxHealth", - healthMod, 0.0D, Float.MAX_VALUE)).a("Max Health").a(true))); - // Spigot end - } - - // Spigot start - private final Player.Spigot spigot = new Player.Spigot() - { - - @Override - public InetSocketAddress getRawAddress() - { - return (InetSocketAddress) getHandle().playerConnection.networkManager.getRawAddress(); - } - - @Override - 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() - { - if (getHealth() <= 0 && isOnline()) - { - server.getServer().getPlayerList().moveToWorld(getHandle(), 0, false); - } - } - - @Override - public void playEffect(Location location, Effect effect, int id, int data, float offsetX, float offsetY, - float offsetZ, float speed, int particleCount, int radius) - { - Validate.notNull(location, "Location cannot be null"); - Validate.notNull(effect, "Effect cannot be null"); - Validate.notNull(location.getWorld(), "World cannot be null"); - Packet packet; - if (effect.getType() != Effect.Type.PARTICLE) - { - int packetData = effect.getId(); - packet = new PacketPlayOutWorldEvent(packetData, location.getBlockX(), location.getBlockY(), - location.getBlockZ(), id, false); - } - else - { - StringBuilder particleFullName = new StringBuilder(); - particleFullName.append(effect.getName()); - if (effect.getData() != null - && (effect.getData().equals(Material.class) || effect.getData().equals( - org.bukkit.material.MaterialData.class))) - { - particleFullName.append('_').append(id); - } - if (effect.getData() != null && effect.getData().equals(org.bukkit.material.MaterialData.class)) - { - particleFullName.append('_').append(data); - } - packet = new PacketPlayOutWorldParticles(particleFullName.toString(), (float) location.getX(), - (float) location.getY(), (float) location.getZ(), offsetX, offsetY, offsetZ, speed, - particleCount); - } - int distance; - radius *= radius; - if (getHandle().playerConnection == null) - { - return; - } - if (!location.getWorld().equals(getWorld())) - { - return; - } - - distance = (int) getLocation().distanceSquared(location); - if (distance <= radius) - { - getHandle().playerConnection.sendPacket(packet); - } - } - - @Override - public String getLocale() - { - return getHandle().locale; - } - - @Override - public Set getHiddenPlayers() - { - Set ret = new HashSet(); - for (UUID u : hiddenPlayers) - { - ret.add(getServer().getPlayer(u)); - } - - return java.util.Collections.unmodifiableSet(ret); - } - }; - - public Player.Spigot spigot() - { - return spigot; - } - // Spigot end -} diff --git a/Plugins/Nautilus.Core.CraftBukkit/src/org/bukkit/craftbukkit/v1_7_R4/inventory/CraftInventoryCustom.java b/Plugins/Nautilus.Core.CraftBukkit/src/org/bukkit/craftbukkit/v1_7_R4/inventory/CraftInventoryCustom.java deleted file mode 100644 index 2213bdd90..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/src/org/bukkit/craftbukkit/v1_7_R4/inventory/CraftInventoryCustom.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.bukkit.craftbukkit.v1_7_R4.inventory; - -import org.bukkit.craftbukkit.v1_7_R4.inventory.MinecraftInventory; -import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftInventory; -import org.bukkit.event.inventory.InventoryType; -import org.bukkit.inventory.InventoryHolder; - -public class CraftInventoryCustom extends CraftInventory { - public CraftInventoryCustom(InventoryHolder owner, InventoryType type) { - super(new MinecraftInventory(owner, type)); - } - - public CraftInventoryCustom(InventoryHolder owner, int size) { - super(new MinecraftInventory(owner, size)); - } - - public CraftInventoryCustom(InventoryHolder owner, int size, String title) { - super(new MinecraftInventory(owner, size, title)); - } -} diff --git a/Plugins/Nautilus.Core.CraftBukkit/src/org/bukkit/craftbukkit/v1_7_R4/inventory/CraftItemStack.java b/Plugins/Nautilus.Core.CraftBukkit/src/org/bukkit/craftbukkit/v1_7_R4/inventory/CraftItemStack.java deleted file mode 100644 index 1e41bb6e5..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/src/org/bukkit/craftbukkit/v1_7_R4/inventory/CraftItemStack.java +++ /dev/null @@ -1,415 +0,0 @@ -package org.bukkit.craftbukkit.v1_7_R4.inventory; - -import static org.bukkit.craftbukkit.v1_7_R4.inventory.CraftMetaItem.ENCHANTMENTS; -import static org.bukkit.craftbukkit.v1_7_R4.inventory.CraftMetaItem.ENCHANTMENTS_ID; -import static org.bukkit.craftbukkit.v1_7_R4.inventory.CraftMetaItem.ENCHANTMENTS_LVL; - -import java.util.Map; - -import net.minecraft.server.v1_7_R4.EnchantmentManager; -import net.minecraft.server.v1_7_R4.Item; -import net.minecraft.server.v1_7_R4.NBTTagCompound; -import net.minecraft.server.v1_7_R4.NBTTagList; - -import org.apache.commons.lang.Validate; -import org.bukkit.Material; -import org.bukkit.configuration.serialization.DelegateDeserialization; -import org.bukkit.craftbukkit.v1_7_R4.util.CraftMagicNumbers; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; - -import com.google.common.collect.ImmutableMap; - -@DelegateDeserialization(ItemStack.class) -public class CraftItemStack extends ItemStack { - - public static net.minecraft.server.v1_7_R4.ItemStack asNMSCopy(ItemStack original) { - if (original instanceof CraftItemStack) { - CraftItemStack stack = (CraftItemStack) original; - return stack.handle == null ? null : stack.handle.cloneItemStack(); - } - if (original == null || original.getTypeId() <= 0) { - return null; - } - - Item item = CraftMagicNumbers.getItem(original.getType()); - - if (item == null) { - return null; - } - - net.minecraft.server.v1_7_R4.ItemStack stack = new net.minecraft.server.v1_7_R4.ItemStack(item, original.getAmount(), original.getDurability()); - if (original.hasItemMeta()) { - setItemMeta(stack, original.getItemMeta()); - } - return stack; - } - - public static net.minecraft.server.v1_7_R4.ItemStack copyNMSStack(net.minecraft.server.v1_7_R4.ItemStack original, int amount) { - net.minecraft.server.v1_7_R4.ItemStack stack = original.cloneItemStack(); - stack.count = amount; - return stack; - } - - /** - * Copies the NMS stack to return as a strictly-Bukkit stack - */ - public static ItemStack asBukkitCopy(net.minecraft.server.v1_7_R4.ItemStack original) { - if (original == null) { - return new ItemStack(Material.AIR); - } - ItemStack stack = new ItemStack(CraftMagicNumbers.getMaterial(original.getItem()), original.count, (short) original.getData()); - if (hasItemMeta(original)) { - stack.setItemMeta(getItemMeta(original)); - } - return stack; - } - - public static CraftItemStack asCraftMirror(net.minecraft.server.v1_7_R4.ItemStack original) { - return new CraftItemStack(original); - } - - public static CraftItemStack asCraftCopy(ItemStack original) { - if (original instanceof CraftItemStack) { - CraftItemStack stack = (CraftItemStack) original; - return new CraftItemStack(stack.handle == null ? null : stack.handle.cloneItemStack()); - } - return new CraftItemStack(original); - } - - public static CraftItemStack asNewCraftStack(Item item) { - return asNewCraftStack(item, 1); - } - - public static CraftItemStack asNewCraftStack(Item item, int amount) { - return new CraftItemStack(CraftMagicNumbers.getMaterial(item), amount, (short) 0, null); - } - - net.minecraft.server.v1_7_R4.ItemStack handle; - - /** - * Mirror - */ - protected CraftItemStack(net.minecraft.server.v1_7_R4.ItemStack item) { - this.handle = item; - } - - protected CraftItemStack(ItemStack item) { - this(item.getTypeId(), item.getAmount(), item.getDurability(), item.hasItemMeta() ? item.getItemMeta() : null); - } - - protected CraftItemStack(Material type, int amount, short durability, ItemMeta itemMeta) { - setType(type); - setAmount(amount); - setDurability(durability); - setItemMeta(itemMeta); - } - - protected CraftItemStack(int typeId, int amount, short durability, ItemMeta itemMeta) { - this(Material.getMaterial(typeId), amount, durability, itemMeta); - - } - - @Override - public int getTypeId() { - return handle != null ? CraftMagicNumbers.getId(handle.getItem()) : 0; - } - - @Override - public void setTypeId(int type) { - if (getTypeId() == type) { - return; - } else if (type == 0) { - handle = null; - } else if (CraftMagicNumbers.getItem(type) == null) { // :( - handle = null; - } else if (handle == null) { - handle = new net.minecraft.server.v1_7_R4.ItemStack(CraftMagicNumbers.getItem(type), 1, 0); - } else { - handle.setItem(CraftMagicNumbers.getItem(type)); - if (hasItemMeta()) { - // This will create the appropriate item meta, which will contain all the data we intend to keep - setItemMeta(handle, getItemMeta(handle)); - } - } - setData(null); - } - - @Override - public int getAmount() { - return handle != null ? handle.count : 0; - } - - @Override - public void setAmount(int amount) { - if (handle == null) { - return; - } - if (amount == 0) { - handle = null; - } else { - handle.count = amount; - } - } - - @Override - public void setDurability(final short durability) { - // Ignore damage if item is null - if (handle != null) { - handle.setData(durability); - } - } - - @Override - public short getDurability() { - if (handle != null) { - return (short) handle.getData(); - } else { - return -1; - } - } - - @Override - public int getMaxStackSize() { - return (handle == null) ? Material.AIR.getMaxStackSize() : handle.getItem().getMaxStackSize(); - } - - @Override - public void addUnsafeEnchantment(Enchantment ench, int level) { - Validate.notNull(ench, "Cannot add null enchantment"); - - if (!makeTag(handle)) { - return; - } - NBTTagList list = getEnchantmentList(handle); - if (list == null) { - list = new NBTTagList(); - handle.tag.set(ENCHANTMENTS.NBT, list); - } - int size = list.size(); - - for (int i = 0; i < size; i++) { - NBTTagCompound tag = (NBTTagCompound) list.get(i); - short id = tag.getShort(ENCHANTMENTS_ID.NBT); - if (id == ench.getId()) { - tag.setShort(ENCHANTMENTS_LVL.NBT, (short) level); - return; - } - } - NBTTagCompound tag = new NBTTagCompound(); - tag.setShort(ENCHANTMENTS_ID.NBT, (short) ench.getId()); - tag.setShort(ENCHANTMENTS_LVL.NBT, (short) level); - list.add(tag); - } - - static boolean makeTag(net.minecraft.server.v1_7_R4.ItemStack item) { - if (item == null) { - return false; - } - - if (item.tag == null) { - item.setTag(new NBTTagCompound()); - } - - return true; - } - - @Override - public boolean containsEnchantment(Enchantment ench) { - return getEnchantmentLevel(ench) > 0; - } - - @Override - public int getEnchantmentLevel(Enchantment ench) { - Validate.notNull(ench, "Cannot find null enchantment"); - if (handle == null) { - return 0; - } - return EnchantmentManager.getEnchantmentLevel(ench.getId(), handle); - } - - @Override - public int removeEnchantment(Enchantment ench) { - Validate.notNull(ench, "Cannot remove null enchantment"); - - NBTTagList list = getEnchantmentList(handle), listCopy; - if (list == null) { - return 0; - } - int index = Integer.MIN_VALUE; - int level = Integer.MIN_VALUE; - int size = list.size(); - - for (int i = 0; i < size; i++) { - NBTTagCompound enchantment = (NBTTagCompound) list.get(i); - int id = 0xffff & enchantment.getShort(ENCHANTMENTS_ID.NBT); - if (id == ench.getId()) { - index = i; - level = 0xffff & enchantment.getShort(ENCHANTMENTS_LVL.NBT); - break; - } - } - - if (index == Integer.MIN_VALUE) { - return 0; - } - if (size == 1) { - handle.tag.remove(ENCHANTMENTS.NBT); - if (handle.tag.isEmpty()) { - handle.tag = null; - } - return level; - } - - // This is workaround for not having an index removal - listCopy = new NBTTagList(); - for (int i = 0; i < size; i++) { - if (i != index) { - listCopy.add(list.get(i)); - } - } - handle.tag.set(ENCHANTMENTS.NBT, listCopy); - - return level; - } - - @Override - public Map getEnchantments() { - return getEnchantments(handle); - } - - static Map getEnchantments(net.minecraft.server.v1_7_R4.ItemStack item) { - NBTTagList list = (item != null && item.hasEnchantments()) ? item.getEnchantments() : null; - - if (list == null || list.size() == 0) { - return ImmutableMap.of(); - } - - ImmutableMap.Builder result = ImmutableMap.builder(); - - for (int i = 0; i < list.size(); i++) { - int id = 0xffff & ((NBTTagCompound) list.get(i)).getShort(ENCHANTMENTS_ID.NBT); - int level = 0xffff & ((NBTTagCompound) list.get(i)).getShort(ENCHANTMENTS_LVL.NBT); - - result.put(Enchantment.getById(id), level); - } - - return result.build(); - } - - static NBTTagList getEnchantmentList(net.minecraft.server.v1_7_R4.ItemStack item) { - return (item != null && item.hasEnchantments()) ? item.getEnchantments() : null; - } - - @Override - public CraftItemStack clone() { - CraftItemStack itemStack = (CraftItemStack) super.clone(); - if (this.handle != null) { - itemStack.handle = this.handle.cloneItemStack(); - } - return itemStack; - } - - @Override - public ItemMeta getItemMeta() { - return getItemMeta(handle); - } - - public net.minecraft.server.v1_7_R4.ItemStack getHandle() { - return handle; - } - - public static ItemMeta getItemMeta(net.minecraft.server.v1_7_R4.ItemStack item) { - if (!hasItemMeta(item)) { - return CraftItemFactory.instance().getItemMeta(getType(item)); - } - switch (getType(item)) { - case WRITTEN_BOOK: - case BOOK_AND_QUILL: - return new CraftMetaBook(item.tag); - case SKULL_ITEM: - return new CraftMetaSkull(item.tag); - case LEATHER_HELMET: - case LEATHER_CHESTPLATE: - case LEATHER_LEGGINGS: - case LEATHER_BOOTS: - return new CraftMetaLeatherArmor(item.tag); - case POTION: - return new CraftMetaPotion(item.tag); - case MAP: - return new CraftMetaMap(item.tag); - case FIREWORK: - return new CraftMetaFirework(item.tag); - case FIREWORK_CHARGE: - return new CraftMetaCharge(item.tag); - case ENCHANTED_BOOK: - return new CraftMetaEnchantedBook(item.tag); - default: - return new CraftMetaItem(item.tag); - } - } - - static Material getType(net.minecraft.server.v1_7_R4.ItemStack item) { - Material material = Material.getMaterial(item == null ? 0 : CraftMagicNumbers.getId(item.getItem())); - return material == null ? Material.AIR : material; - } - - @Override - public boolean setItemMeta(ItemMeta itemMeta) { - return setItemMeta(handle, itemMeta); - } - - public static boolean setItemMeta(net.minecraft.server.v1_7_R4.ItemStack item, ItemMeta itemMeta) { - if (item == null) { - return false; - } - if (CraftItemFactory.instance().equals(itemMeta, null)) { - item.tag = null; - return true; - } - if (!CraftItemFactory.instance().isApplicable(itemMeta, getType(item))) { - return false; - } - - NBTTagCompound tag = new NBTTagCompound(); - item.setTag(tag); - - ((CraftMetaItem) itemMeta).applyToItem(tag); - return true; - } - - @Override - public boolean isSimilar(ItemStack stack) { - if (stack == null) { - return false; - } - if (stack == this) { - return true; - } - if (!(stack instanceof CraftItemStack)) { - return stack.getClass() == ItemStack.class && stack.isSimilar(this); - } - - CraftItemStack that = (CraftItemStack) stack; - if (handle == that.handle) { - return true; - } - if (handle == null || that.handle == null) { - return false; - } - if (!(that.getTypeId() == getTypeId() && getDurability() == that.getDurability())) { - return false; - } - return hasItemMeta() ? that.hasItemMeta() && handle.tag.equals(that.handle.tag) : !that.hasItemMeta(); - } - - @Override - public boolean hasItemMeta() { - return hasItemMeta(handle); - } - - static boolean hasItemMeta(net.minecraft.server.v1_7_R4.ItemStack item) { - return !(item == null || item.tag == null || item.tag.isEmpty()); - } -} \ No newline at end of file diff --git a/Plugins/Nautilus.Core.CraftBukkit/src/org/bukkit/craftbukkit/v1_7_R4/inventory/MinecraftInventory.java b/Plugins/Nautilus.Core.CraftBukkit/src/org/bukkit/craftbukkit/v1_7_R4/inventory/MinecraftInventory.java deleted file mode 100644 index e9204e828..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/src/org/bukkit/craftbukkit/v1_7_R4/inventory/MinecraftInventory.java +++ /dev/null @@ -1,194 +0,0 @@ -package org.bukkit.craftbukkit.v1_7_R4.inventory; - -import java.util.ArrayList; -import java.util.List; - -import org.bukkit.craftbukkit.v1_7_R4.entity.CraftHumanEntity; -import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack; -import org.bukkit.entity.HumanEntity; -import org.bukkit.event.inventory.InventoryType; -import org.bukkit.inventory.InventoryHolder; - -import net.minecraft.server.v1_7_R4.EntityHuman; -import net.minecraft.server.v1_7_R4.IInventory; -import net.minecraft.server.v1_7_R4.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 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, 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 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/Plugins/Nautilus.Core.CraftBukkit/src/org/bukkit/entity/Projectile.java b/Plugins/Nautilus.Core.CraftBukkit/src/org/bukkit/entity/Projectile.java deleted file mode 100644 index d57fe8140..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/src/org/bukkit/entity/Projectile.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.bukkit.entity; - -import org.bukkit.projectiles.ProjectileSource; - -/** - * Represents a shootable entity. - */ -public interface Projectile extends Entity { - - /** - * This method exists for legacy reasons to provide backwards - * compatibility. It will not exist at runtime and should not be used - * under any circumstances. - */ - @Deprecated - public LivingEntity _INVALID_getShooter(); - - /** - * Retrieve the shooter of this projectile. - * - * @return the {@link ProjectileSource} that shot this projectile - */ - public ProjectileSource getShooter(); - - /** - * This method exists for legacy reasons to provide backwards - * compatibility. It will not exist at runtime and should not be used - * under any circumstances. - */ - @Deprecated - public void _INVALID_setShooter(LivingEntity shooter); - - /** - * Set the shooter of this projectile. - * - * @param source the {@link ProjectileSource} that shot this projectile - */ - public void setShooter(ProjectileSource source); - - /** - * Determine if this projectile should bounce or not when it hits. - *

- * If a small fireball does not bounce it will set the target on fire. - * - * @return true if it should bounce. - */ - public boolean doesBounce(); - - /** - * Set whether or not this projectile should bounce or not when it hits - * something. - * - * @param doesBounce whether or not it should bounce. - */ - public void setBounce(boolean doesBounce); -} \ No newline at end of file diff --git a/Plugins/Nautilus.Core.CraftBukkit/src/org/bukkit/event/vehicle/VehicleExitEvent.java b/Plugins/Nautilus.Core.CraftBukkit/src/org/bukkit/event/vehicle/VehicleExitEvent.java deleted file mode 100644 index 31fa335e3..000000000 --- a/Plugins/Nautilus.Core.CraftBukkit/src/org/bukkit/event/vehicle/VehicleExitEvent.java +++ /dev/null @@ -1,56 +0,0 @@ -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; - } -} diff --git a/Plugins/Nautilus.Game.Arcade/.classpath b/Plugins/Nautilus.Game.Arcade/.classpath index 775662620..ca0083d39 100644 --- a/Plugins/Nautilus.Game.Arcade/.classpath +++ b/Plugins/Nautilus.Game.Arcade/.classpath @@ -4,7 +4,6 @@ - diff --git a/Plugins/Nautilus.Game.Arcade/Nautilus.Game.Arcade.iml b/Plugins/Nautilus.Game.Arcade/Nautilus.Game.Arcade.iml index fbc647369..5955ea339 100644 --- a/Plugins/Nautilus.Game.Arcade/Nautilus.Game.Arcade.iml +++ b/Plugins/Nautilus.Game.Arcade/Nautilus.Game.Arcade.iml @@ -11,7 +11,6 @@ - diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java index 64a59747e..fffe47c93 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -44,7 +44,8 @@ import mineplex.core.updater.Updater; import mineplex.minecraft.game.core.combat.CombatManager; import mineplex.minecraft.game.core.damage.DamageManager; import nautilus.game.arcade.game.GameServerConfig; -import net.minecraft.server.v1_7_R4.*; +import net.minecraft.server.*; +import net.minecraft.server.v1_7_R4.MinecraftServer; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java index 566110eba..6db4936e6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.UUID; import org.bukkit.ChatColor; import org.bukkit.Location; @@ -16,6 +17,7 @@ import org.bukkit.entity.Chicken; import org.bukkit.entity.Cow; import org.bukkit.entity.Entity; import org.bukkit.entity.FallingBlock; +import org.bukkit.entity.Item; import org.bukkit.entity.Pig; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -29,12 +31,12 @@ import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.inventory.PrepareItemCraftEvent; import org.bukkit.event.player.PlayerBucketEmptyEvent; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.inventory.CraftingInventory; import org.bukkit.inventory.ItemStack; -import org.bukkit.scoreboard.Score; +import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.util.Vector; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilBlock; @@ -57,7 +59,6 @@ import nautilus.game.arcade.events.PlayerDeathOutEvent; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.TeamGame; -import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.games.bridge.kits.*; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.ore.OreHider; @@ -70,6 +71,11 @@ import nautilus.game.arcade.stats.TntMinerStatTracker; public class Bridge extends TeamGame implements OreObsfucation { + /** + * When a block is broken of one of these materials, the item drop will be locked to the player that broke the block for 8 seconds. After that, anyone can pick up the item. + */ + private static final Material[] PLAYER_DROP_DELAY_MATERIALS = new Material[] { Material.LOG, Material.LOG_2, Material.IRON_ORE, Material.DIAMOND_ORE, Material.COAL_ORE, Material.GOLD_ORE, Material.WORKBENCH, Material.FURNACE }; + //Bridge Timer private int _bridgeTime = 600000; private boolean _bridgesDown = false; @@ -98,7 +104,6 @@ public class Bridge extends TeamGame implements OreObsfucation private OreHider _ore; private double _oreDensity = 2.2; - //Map Flags private int _buildHeight = -1; private int _iceForm = -1; @@ -111,6 +116,9 @@ public class Bridge extends TeamGame implements OreObsfucation private HashMap _tournamentKills = new HashMap(); private long _tournamentKillMessageTimer = 0; + //Item pickup delay for players that don't break the block + private HashMap _blockToUUIDMap = new HashMap(); + public Bridge(ArcadeManager manager) { @@ -1009,6 +1017,61 @@ public class Bridge extends TeamGame implements OreObsfucation } } + private void addBlockPickupDelay(Player owner, Block block) + { + Material blockMaterial = block.getType(); + boolean shouldAddToMap = false; + + for (int i = 0; i < PLAYER_DROP_DELAY_MATERIALS.length && !shouldAddToMap; i++) + { + if (blockMaterial.equals(PLAYER_DROP_DELAY_MATERIALS[i])) + { + shouldAddToMap = true; + } + } + + if (shouldAddToMap) + _blockToUUIDMap.put(block, owner.getUniqueId()); + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void dropItem(BlockBreakEvent event) + { + addBlockPickupDelay(event.getPlayer(), event.getBlock()); + } + + @EventHandler + public void itemSpawn(ItemSpawnEvent event) + { + Item item = event.getEntity(); + Block block = event.getLocation().getBlock(); + + UUID uuid = _blockToUUIDMap.remove(block); + + if (uuid != null) + { + item.setMetadata("owner", new FixedMetadataValue(Manager.GetPlugin(), uuid)); + } + } + + @EventHandler + public void itemPickup(PlayerPickupItemEvent event) + { + Item item = event.getItem(); + + if (item.hasMetadata("owner")) + { + FixedMetadataValue ownerData = (FixedMetadataValue) item.getMetadata("owner").get(0); + UUID ownerUUID = (UUID) ownerData.value(); + + // 8 Seconds + if (item.getTicksLived() <= 160 && !event.getPlayer().getUniqueId().equals(ownerUUID)) + { + event.setCancelled(true); + } + } + } + @EventHandler(priority = EventPriority.LOW) public void ChestProtect(EntityExplodeEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/MineStrike.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/MineStrike.java index 1fe537b7c..2cc7911e0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/MineStrike.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/MineStrike.java @@ -6,7 +6,6 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Color; import org.bukkit.Effect; @@ -71,6 +70,7 @@ import mineplex.core.recharge.RechargedEvent; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; +import mineplex.minecraft.game.core.condition.Condition.ConditionType; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; @@ -83,6 +83,7 @@ import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.game.games.minestrike.data.Bomb; import nautilus.game.arcade.game.games.minestrike.data.Bullet; import nautilus.game.arcade.game.games.minestrike.items.StrikeItem; +import nautilus.game.arcade.game.games.minestrike.items.StrikeItemType; import nautilus.game.arcade.game.games.minestrike.items.equipment.armor.Armor; import nautilus.game.arcade.game.games.minestrike.items.grenades.Grenade; import nautilus.game.arcade.game.games.minestrike.items.guns.Gun; @@ -122,6 +123,8 @@ public class MineStrike extends TeamGame private HashMap _bullets = new HashMap(); private HashMap _grenadesThrown = new HashMap(); + + private HashMap _incendiary = new HashMap(); private Bomb _bomb = null; private Item _bombItem = null; @@ -182,7 +185,8 @@ public class MineStrike extends TeamGame "Hold Right-Click to Plant Bomb", "Hold Right-Click with knife to Defuse Bomb", "Left-Click to roll Grenades", - "Right-Click to throw Grenades" + "Right-Click to throw Grenades", + "Burst Fire for greater accuracy", }; } @@ -217,7 +221,7 @@ public class MineStrike extends TeamGame //Pistol Gun gun = new Glock18(); registerGun(gun, event.GetPlayer()); - gun.giveToPlayer(event.GetPlayer()); + gun.giveToPlayer(event.GetPlayer(), true); //Knife event.GetPlayer().getInventory().setItem(2, ItemStackFactory.Instance.CreateStack(Material.IRON_AXE, (byte)0, 1, "Knife")); @@ -233,7 +237,7 @@ public class MineStrike extends TeamGame //Pistol Gun gun = new P2000(); registerGun(gun, event.GetPlayer()); - gun.giveToPlayer(event.GetPlayer()); + gun.giveToPlayer(event.GetPlayer(), true); //Knife event.GetPlayer().getInventory().setItem(2, ItemStackFactory.Instance.CreateStack(Material.IRON_SWORD, (byte)0, 1, "Knife")); @@ -437,6 +441,11 @@ public class MineStrike extends TeamGame { _grenadesThrown.put(ent, grenade); } + + public void registerIncendiary(Location loc, long endTime) + { + _incendiary.put(loc, endTime); + } public Gun getGunInHand(Player player, ItemStack overrideStack) { @@ -570,7 +579,7 @@ public class MineStrike extends TeamGame Gun gun = getGunInHand(event.getPlayer(), event.getItemDrop().getItemStack()); if (gun != null) { - gun.drop(this, event.getPlayer(), false); + gun.drop(this, event.getPlayer(), false, false); event.getItemDrop().remove(); return; } @@ -579,7 +588,7 @@ public class MineStrike extends TeamGame Grenade grenade = getGrenadeInHand(event.getPlayer(), event.getItemDrop().getItemStack()); if (grenade != null) { - grenade.drop(this, event.getPlayer(), false); + grenade.drop(this, event.getPlayer(), false, false); event.getItemDrop().remove(); return; } @@ -633,9 +642,42 @@ public class MineStrike extends TeamGame toDrop.add(item); } + //Drop Primary + boolean primaryDropped = false; for (StrikeItem item : toDrop) { - item.drop(this, player, true); + if (item.getType() == StrikeItemType.PRIMARY_WEAPON) + { + item.drop(this, player, true, false); + primaryDropped = true; + } + } + + //Drop Remaining + boolean grenadeDropped = false; + for (StrikeItem item : toDrop) + { + //Record Primary Dropped + if (item.getType() == StrikeItemType.PRIMARY_WEAPON) + continue; + + //Pistol + if (item.getType() == StrikeItemType.SECONDARY_WEAPON) + { + item.drop(this, player, true, primaryDropped); + continue; + } + + //Grenade + if (item.getType() == StrikeItemType.GRENADE) + { + item.drop(this, player, true, grenadeDropped); + grenadeDropped = true; + continue; + } + + //Other + item.drop(this, player, true, false); } //Bomb @@ -732,12 +774,18 @@ public class MineStrike extends TeamGame { Arrow arrow = (Arrow)event.getEntity(); - //Particle - UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, arrow.getLocation(), 0, 0, 0, 0, 1); + Bullet bullet = _bullets.get(arrow); - //Sound - arrow.getWorld().playSound(event.getEntity().getLocation(), Sound.ENDERMAN_HIT, 1f, 1f); + //Particle + if (bullet != null && bullet.Shooter != null) + UtilParticle.PlayParticle(bullet.Shooter, ParticleType.FIREWORKS_SPARK, arrow.getLocation(), 0, 0, 0, 0, 1); + + //Hit Block Sound + arrow.getWorld().playSound(arrow.getLocation(), Sound.ENDERMAN_HIT, 1f, 1f); + //Bullet Whiz Sound + bulletWhizzSound(arrow.getLocation(), bullet); + //Block Particle try { @@ -763,29 +811,54 @@ public class MineStrike extends TeamGame e.printStackTrace(); } + _bullets.remove(arrow); arrow.remove(); - } + } }, 0); } - - @EventHandler(priority = EventPriority.MONITOR) - public void bulletFlybySound(UpdateEvent event) + + private void bulletWhizzSound(Location bulletEndLocation, Bullet bullet) { - if (event.getType() != UpdateType.TICK) + if (bullet == null) return; - - for (Player player : UtilServer.getPlayers()) + + Location loc = bullet.Origin.clone(); + + HashSet hasPlayedFor = new HashSet(); + + if (bullet.Shooter != null) + hasPlayedFor.add(bullet.Shooter); + + //Move between points, check players + while (UtilMath.offset(loc, bulletEndLocation) > 1) { - for (Entity ent : _bullets.keySet()) + //This is used to calculate whether players are between current/end. + //Add 5 so you still hear the whizz if it hits just infront of you. + double offsetStartToEnd = UtilMath.offset(loc, bulletEndLocation) + 4; + + for (Player player : UtilServer.getPlayers()) { - if (UtilMath.offset(player.getEyeLocation(), ent.getLocation()) < 4) + if (hasPlayedFor.contains(player)) + continue; + + //Remove players who are not between current/end points + if (offsetStartToEnd < UtilMath.offset(player.getEyeLocation(), loc) && + offsetStartToEnd < UtilMath.offset(player.getEyeLocation(), bulletEndLocation)) { - if (_bullets.get(ent).bulletSound()) - { - player.playSound(ent.getLocation(), Sound.BAT_IDLE, (float)(0.2 + UtilMath.offset(player.getEyeLocation(), ent.getLocation()) / 4d), 1f); - } + hasPlayedFor.add(player); + continue; + } + + //Check + if (UtilMath.offset(player.getEyeLocation(), loc) < 4) + { + player.playSound(loc, Sound.BAT_IDLE, (float)(0.5 + Math.random() * 0.5), 1f); + hasPlayedFor.add(player); } } + + //Move Closer + loc.add(UtilAlg.getTrajectory(loc, bulletEndLocation)); } } @@ -832,7 +905,7 @@ public class MineStrike extends TeamGame if (check.subtract(from).length() < 0.8) { //Damage - event.AddMod(damager.getName(), "Knife", 25 - event.GetDamage(), false); + event.AddMod(damager.getName(), "Knife", 40 - event.GetDamage(), false); //Effect damagee.getWorld().playSound(damagee.getLocation(), Sound.IRONGOLEM_DEATH, 1f, 1f); @@ -854,11 +927,16 @@ public class MineStrike extends TeamGame return; } + + //Gun Bullet bullet = _bullets.remove(event.GetProjectile()); if (bullet == null) return; + + //Bullet Whiz Sound + bulletWhizzSound(event.GetDamageePlayer().getEyeLocation(), bullet); //Wipe previous data! event.GetCancellers().clear(); @@ -941,7 +1019,7 @@ public class MineStrike extends TeamGame { Entity bullet = bulletIterator.next(); - if (!bullet.isValid() || bullet.getTicksLived() > 200) + if (!bullet.isValid() || bullet.getTicksLived() > 40) { bulletIterator.remove(); bullet.remove(); @@ -984,7 +1062,7 @@ public class MineStrike extends TeamGame if (gun.isStack(player.getInventory().getItem(slot))) { - gun.drop(this, player, false); + gun.drop(this, player, false, false); player.getInventory().setItem(slot, null); return; } @@ -1230,7 +1308,7 @@ public class MineStrike extends TeamGame // Damage Event Manager.GetDamage().NewDamageEvent(player, null, null, DamageCause.CUSTOM, 1 + (players.get(player) * 40), - true, true, false, null, "C4 Explosion"); + true, true, false, "Bomb", "C4 Explosion"); } @@ -1534,10 +1612,17 @@ public class MineStrike extends TeamGame for (Entity ent : _bullets.keySet()) ent.remove(); _bullets.clear(); + + //Incendiary + _incendiary.clear(); //Restock Ammo for (Gun gun : _gunsEquipped.keySet()) gun.restockAmmo(_gunsEquipped.get(gun)); + + //Reset Shop + for (Player player : UtilServer.getPlayers()) + _shopManager.leaveShop(player, false, false); } @EventHandler(priority = EventPriority.HIGHEST) @@ -1664,10 +1749,12 @@ public class MineStrike extends TeamGame if (!event.getPlayer().isSneaking()) { _scoped.put(event.getPlayer(), event.getPlayer().getInventory().getHelmet()); - Manager.GetCondition().Factory().Slow("Scope", event.getPlayer(), null, 9999, 3, false, false, false, false); + Manager.GetCondition().Factory().Slow("Scope", event.getPlayer(), null, 9999, 2, false, false, false, false); event.getPlayer().getInventory().setHelmet(new ItemStack(Material.PUMPKIN)); event.getPlayer().getWorld().playSound(event.getPlayer().getEyeLocation(), Sound.GHAST_DEATH, 0.8f, 1f); + + Manager.GetCondition().Factory().Blind("Scope Blind", event.getPlayer(), null, 1, 1, false, false, false); } else { @@ -1696,7 +1783,7 @@ public class MineStrike extends TeamGame } } } - + public void removeScope(Player player) { ItemStack stack = _scoped.remove(player); @@ -1705,6 +1792,50 @@ public class MineStrike extends TeamGame player.getWorld().playSound(player.getEyeLocation(), Sound.GHAST_DEATH, 0.8f, 1f); } + + @EventHandler + public void speedUpdate(UpdateEvent event) + { + if (!IsLive()) + return; + + if (event.getType() != UpdateType.TICK) + return; + + for (Player player : GetPlayers(true)) + { + if (UtilGear.isMat(player.getItemInHand(), Material.IRON_AXE) || UtilGear.isMat(player.getItemInHand(), Material.IRON_SWORD)) + Manager.GetCondition().Factory().Speed("Knife", player, player, 1.9, 0, false, false, false); + else + Manager.GetCondition().EndCondition(player, ConditionType.SPEED, null); + } + } + + @EventHandler + public void incendiaryUpdate(UpdateEvent event) + { + if (event.getType() == UpdateType.TICK) + for (Player player : UtilServer.getPlayers()) + player.setFireTicks(0); + + if (event.getType() != UpdateType.SLOW) + return; + + Iterator fireIterator = _incendiary.keySet().iterator(); + + while (fireIterator.hasNext()) + { + Location loc = fireIterator.next(); + + if (_incendiary.get(loc) < System.currentTimeMillis()) + fireIterator.remove(); + + else + loc.getWorld().playSound(loc, Sound.PIG_DEATH, 1f, 1f); + } + } + + @Override @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/ShopManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/ShopManager.java index 5b31f7427..10f1b761d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/ShopManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/ShopManager.java @@ -15,6 +15,7 @@ import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.minestrike.items.StrikeItem; import nautilus.game.arcade.game.games.minestrike.items.StrikeItemType; import nautilus.game.arcade.game.games.minestrike.items.equipment.DefusalKit; +import nautilus.game.arcade.game.games.minestrike.items.equipment.armor.Armor; import nautilus.game.arcade.game.games.minestrike.items.equipment.armor.Helmet; import nautilus.game.arcade.game.games.minestrike.items.equipment.armor.Kevlar; import nautilus.game.arcade.game.games.minestrike.items.grenades.*; @@ -29,7 +30,6 @@ import org.bukkit.Color; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; -import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.event.inventory.InventoryClickEvent; @@ -60,7 +60,7 @@ public class ShopManager //Pistols slot = 9; - //addItem(team.GetColor() == ChatColor.RED ? new Glock18() : new USP(), player, slot++); + addItem(team.GetColor() == ChatColor.RED ? new Glock18() : new P2000(), player, slot++); addItem(new CZ75(), player, slot++); addItem(new Deagle(), player, slot++); @@ -77,9 +77,10 @@ public class ShopManager addItem(new AWP(), player, slot++); //Grenades - addItem(new FlashBang(), player, 15); - addItem(new HighExplosive(), player, 16); - addItem(new Smoke(), player, 17); + addItem(new FlashBang(), player, 14); + addItem(new HighExplosive(), player, 15); + addItem(new Smoke(), player, 16); + addItem(team.GetColor() == ChatColor.RED ? new Molotov() : new Incendiary(), player, 17); //Gear if (team.GetColor() == ChatColor.AQUA) @@ -133,20 +134,15 @@ public class ShopManager if (item instanceof Kevlar) { - System.out.println("Checking Kevlar"); - - Kevlar armor = (Kevlar)item; - if (armor.isArmor(player.getInventory().getChestplate())) + if (Armor.isArmor(player.getInventory().getChestplate())) { - System.out.println("Checking Kevlar TRUE"); return true; } } if (item instanceof Helmet) { - Helmet armor = (Helmet)item; - if (armor.isArmor(player.getInventory().getHelmet())) + if (Armor.isArmor(player.getInventory().getHelmet())) return true; } @@ -217,7 +213,7 @@ public class ShopManager { Gun gun = (Gun)item; Host.dropSlotItem(player, gun.getSlot()); - gun.giveToPlayer(player); + gun.giveToPlayer(player, true); Host.registerGun(gun, player); } @@ -226,7 +222,7 @@ public class ShopManager { Grenade grenade = (Grenade)item; - if (!grenade.giveToPlayer(player)) + if (!grenade.giveToPlayer(player, true)) { player.playSound(player.getLocation(), Sound.NOTE_BASS, 1f, 1f); return; @@ -247,7 +243,7 @@ public class ShopManager else if (item instanceof DefusalKit) { - item.giveToPlayer(player, 8); + item.giveToPlayer(player, 8, false); } _money.put(player, getMoney(player) - item.getCost()); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/StrikeItem.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/StrikeItem.java index 646418cd0..774af73d7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/StrikeItem.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/StrikeItem.java @@ -30,6 +30,8 @@ public abstract class StrikeItem private int _cost; private int _gemCost; private Material _skin; + + private String _ownerName; private ItemStack _stack = null; @@ -77,7 +79,17 @@ public abstract class StrikeItem return _skin; } - public void drop(MineStrike game, Player player, boolean natural) + public String getOwnerName() + { + return _ownerName; + } + + public void setOwnerName(String ownerName) + { + _ownerName = ownerName; + } + + public void drop(MineStrike game, Player player, boolean natural, boolean onlyDeregisterAndRemove) { Entity ent; @@ -94,14 +106,21 @@ public abstract class StrikeItem if (this instanceof Gun) { game.deregisterGun((Gun)this); - game.registerDroppedGun(ent, (Gun)this); + + if (!onlyDeregisterAndRemove) + game.registerDroppedGun(ent, (Gun)this); } else if (this instanceof Grenade) { game.deregisterGrenade((Grenade)this); - game.registerDroppedGrenade(ent, (Grenade)this); + + if (!onlyDeregisterAndRemove) + game.registerDroppedGrenade(ent, (Grenade)this); } + + if (onlyDeregisterAndRemove) + ent.remove(); } public ItemStack getStack() @@ -124,8 +143,11 @@ public abstract class StrikeItem return UtilGear.isMat(stack, _skin); } - public void giveToPlayer(Player player, int slot) + public void giveToPlayer(Player player, int slot, boolean setOwnerName) { + if (setOwnerName) + _ownerName = player.getName(); + fixStackName(); player.getInventory().setItem(slot, getStack()); @@ -138,7 +160,7 @@ public abstract class StrikeItem public void fixStackName() { ItemMeta meta = _stack.getItemMeta(); - meta.setDisplayName(C.Bold + getName()); + meta.setDisplayName((_ownerName == null ? "" : _ownerName + "'s ") + C.Bold + getName() + ChatColor.RESET); _stack.setItemMeta(meta); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/equipment/armor/Kevlar.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/equipment/armor/Kevlar.java index 3b0fe5ad6..329fd4e15 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/equipment/armor/Kevlar.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/equipment/armor/Kevlar.java @@ -11,6 +11,6 @@ public class Kevlar extends Armor { "Reduces bullet damage by 25%" }, - 350, 0, Material.LEATHER_CHESTPLATE); + 650, 0, Material.LEATHER_CHESTPLATE); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/FireGrenadeBase.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/FireGrenadeBase.java new file mode 100644 index 000000000..00d525b5e --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/FireGrenadeBase.java @@ -0,0 +1,86 @@ +package nautilus.game.arcade.game.games.minestrike.items.grenades; + +import java.util.HashMap; + +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilParticle.ParticleType; +import nautilus.game.arcade.game.games.minestrike.MineStrike; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Entity; + +public abstract class FireGrenadeBase extends Grenade +{ + private long _baseTime; + + public FireGrenadeBase(String name, int price, int gemCost, Material skin, long burnTime) + { + super(name, new String[] + { + + }, + price, gemCost, Material.PORK, 1); + + _baseTime = burnTime; + } + + @Override + public boolean updateCustom(MineStrike game, Entity ent) + { + if (UtilEnt.isGrounded(ent)) + { + createFire(game, ent.getLocation()); + + return true; + } + + return false; + } + + private void createFire(final MineStrike game, final Location loc) + { + //Sound + loc.getWorld().playSound(loc, Sound.IRONGOLEM_THROW, 1f, 1f); + + //Particle + UtilParticle.PlayParticle(ParticleType.LAVA, loc.add(0, 0.2, 0), 0.3f, 0f, 0.3f, 0, 30); + + //Fire Blocks + final HashMap blocks = UtilBlock.getInRadius(loc, 3.5d); + for (final Block block : blocks.keySet()) + { + if (block.getType() != Material.AIR) + continue; + + if (!UtilBlock.solid(block.getRelative(BlockFace.DOWN))) + continue; + + UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(game.Manager.GetPlugin(), new Runnable() + { + public void run() + { + game.Manager.GetBlockRestore().Add(block, 51, (byte)0, (long) (_baseTime + blocks.get(block) * _baseTime)); + } + }, 60 - (int)(60d * blocks.get(block))); + } + + //Initial Burn Sound + UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(game.Manager.GetPlugin(), new Runnable() + { + public void run() + { + loc.getWorld().playSound(loc, Sound.PIG_DEATH, 1f, 1f); + } + }, 20); + + //Register + game.registerIncendiary(loc, System.currentTimeMillis() + (_baseTime*2-4000)); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/Grenade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/Grenade.java index 0c2ef44de..6456810fe 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/Grenade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/Grenade.java @@ -36,7 +36,7 @@ public abstract class Grenade extends StrikeItem _limit = limit; } - public boolean giveToPlayer(Player player) + public boolean giveToPlayer(Player player, boolean setOwnerName) { int slot = 3; @@ -58,7 +58,7 @@ public abstract class Grenade extends StrikeItem if (slot > 6) return false; - giveToPlayer(player, slot); + giveToPlayer(player, slot, setOwnerName); return true; } @@ -181,7 +181,7 @@ public abstract class Grenade extends StrikeItem @Override public boolean pickup(MineStrike game, Player player) { - if (giveToPlayer(player)) + if (giveToPlayer(player, false)) { game.registerGrenade(this, player); game.deregisterDroppedGrenade(this); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/Incendiary.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/Incendiary.java index 06df38081..cfb9cecf8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/Incendiary.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/Incendiary.java @@ -1,48 +1,11 @@ package nautilus.game.arcade.game.games.minestrike.items.grenades; -import java.util.HashMap; - -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilPlayer; -import nautilus.game.arcade.game.games.minestrike.MineStrike; - import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.block.Block; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -public class Incendiary extends Grenade +public class Incendiary extends FireGrenadeBase { public Incendiary() { - super("HE Grenade", new String[] - { - - }, - 300, 0, Material.APPLE, 1); - } - - @Override - public boolean updateCustom(MineStrike game, Entity ent) - { - if (UtilEnt.isGrounded(ent)) - { - createFire(ent.getLocation().getBlock()); - - return true; - } - - return false; - } - - private void createFire(Block block) - { - // TODO Auto-generated method stub - + super("Incendiary", 600, 0, Material.PORK, 10000); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/Molotov.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/Molotov.java index 44e51979b..f48224fd4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/Molotov.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/Molotov.java @@ -1,6 +1,11 @@ package nautilus.game.arcade.game.games.minestrike.items.grenades; -public class Molotov -{ +import org.bukkit.Material; +public class Molotov extends FireGrenadeBase +{ + public Molotov() + { + super("Molotov", 400, 0, Material.GRILLED_PORK, 8000); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/Gun.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/Gun.java index d9c98ae03..e24527c5d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/Gun.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/Gun.java @@ -2,6 +2,7 @@ package nautilus.game.arcade.game.games.minestrike.items.guns; import mineplex.core.common.util.C; import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; @@ -23,7 +24,6 @@ import org.bukkit.Sound; import org.bukkit.entity.Arrow; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; -import org.bukkit.entity.Snowball; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.util.Vector; @@ -42,12 +42,12 @@ public abstract class Gun extends StrikeItem protected double _dropOffPerBlock; protected double _bulletSpeed; protected Sound _fireSound; - + protected double _coneMin; protected double _coneMax; protected double _coneReduceRate; protected double _coneIncreaseRate; - + //Active Data protected int _loadedAmmo; @@ -55,7 +55,7 @@ public abstract class Gun extends StrikeItem protected double _cone; protected double _lastMove; protected long _lastMoveTime; - + public Gun(StrikeItemType type, GunType gunType, String name, String[] desc, int cost, int gemCost, int clipSize, int clipReserve, @@ -68,7 +68,7 @@ public abstract class Gun extends StrikeItem super(type, name, desc, cost, gemCost, skin); _gunType = gunType; - + if (type == StrikeItemType.PRIMARY_WEAPON) _slot = 0; else @@ -81,15 +81,15 @@ public abstract class Gun extends StrikeItem _damage = damage; _dropOffPerBlock = dropOffPerBlock; _bulletSpeed = bulletSpeed; - + _fireSound = sound; - + _coneMin = coneMin; _coneMax = coneMax; _coneIncreaseRate = coneIncrease; _coneReduceRate = coneReduce; _cone = _coneMin; - + _loadedAmmo = clipSize; _reserveAmmo = clipReserve * clipSize; @@ -108,7 +108,8 @@ public abstract class Gun extends StrikeItem { public void run() { - shootOnce(player, game); + if (game.IsAlive(player)) + shootOnce(player, game); } }, 2); } @@ -122,7 +123,8 @@ public abstract class Gun extends StrikeItem { public void run() { - shootOnce(player, game); + if (game.IsAlive(player)) + shootOnce(player, game); } }, i); } @@ -141,14 +143,16 @@ public abstract class Gun extends StrikeItem //Use Ammo _loadedAmmo--; updateWeaponName(player); - + //Effect soundFire(player.getLocation()); - - for (Player other : UtilServer.getPlayers()) - if (!player.equals(other)) - UtilParticle.PlayParticle(other, ParticleType.EXPLODE, player.getEyeLocation().add(player.getLocation().getDirection().multiply(1.5)), 0, 0, 0, 0, 1); - + + //Visual + Location loc = player.getEyeLocation().add(player.getLocation().getDirection().multiply(1.2)); + loc.add(UtilAlg.getRight(player.getLocation().getDirection()).multiply(0.5)); + loc.add(UtilAlg.getDown(player.getLocation().getDirection()).multiply(0.3)); + UtilParticle.PlayParticle(ParticleType.EXPLODE, loc, 0, 0, 0, 0, 1); + game.registerBullet(fireBullet(player, game)); } @@ -156,18 +160,18 @@ public abstract class Gun extends StrikeItem { //Shoot Entity bullet = player.launchProjectile(Arrow.class); - + //COF double cone = getCone(player); - + //Calc Vector cof = new Vector(Math.random() - 0.5, (Math.random() - 0.2) * (5d/8d), Math.random() - 0.5); cof.normalize(); cof.multiply(cone); - + cof.add(player.getLocation().getDirection()); cof.normalize(); - + bullet.setVelocity(cof.multiply(game.isInstantBullets() ? 200 : _bulletSpeed)); //Increase COF @@ -175,28 +179,28 @@ public abstract class Gun extends StrikeItem return new Bullet(bullet, this, player, game); } - + public double getCone(Player player) { double cone = _cone; - + //Move Penalty if (!UtilTime.elapsed(_lastMoveTime, 75)) cone += _lastMove * _gunType.getMovePenalty(); - + //Sprint Penalty if (player.isSprinting()) cone += _gunType.getSprintPenalty(); - + //Airborne Penalty else if (!UtilEnt.isGrounded(player)) cone += _gunType.getJumpPenalty(); - + //Crouch else if (player.isSneaking() && _gunType != GunType.SNIPER) cone = cone * 0.8; - - + + //Sniper Zoomed if (_gunType == GunType.SNIPER) { @@ -205,7 +209,7 @@ public abstract class Gun extends StrikeItem cone -= _cone; } } - + return cone; } @@ -247,17 +251,17 @@ public abstract class Gun extends StrikeItem //Update updateWeaponName(player); } - + @Override public void fixStackName() { updateWeaponName(null); } - + public void updateWeaponName(Player player) { ItemMeta meta = getStack().getItemMeta(); - meta.setDisplayName(C.Bold + getName() + ChatColor.RESET + " " + C.cGreen + _loadedAmmo + ChatColor.RESET + " / " + C.cYellow + _reserveAmmo); + meta.setDisplayName((getOwnerName() == null ? "" : getOwnerName() + "'s ") + C.Bold + getName() + ChatColor.RESET + " " + C.cGreen + _loadedAmmo + ChatColor.RESET + " / " + C.cYellow + _reserveAmmo); getStack().setItemMeta(meta); if (player != null) @@ -295,30 +299,30 @@ public abstract class Gun extends StrikeItem { loc.getWorld().playSound(loc, Sound.PISTON_EXTEND, 1f, 1.6f); } - + public void soundRefire(Location loc) { - + } - public void giveToPlayer(Player player) + public void giveToPlayer(Player player, boolean setOwner) { - giveToPlayer(player, _slot); + giveToPlayer(player, _slot, setOwner); } public int getSlot() { return _slot; } - + public void moveEvent(PlayerMoveEvent event) { double dist = UtilMath.offset(event.getFrom(), event.getTo()); - + _lastMove = dist; _lastMoveTime = System.currentTimeMillis(); } - + public void reduceCone() { _cone = Math.max(_coneMin, _cone - (_coneReduceRate / 20d)); @@ -328,7 +332,7 @@ public abstract class Gun extends StrikeItem { if (!isHolding(event.GetPlayer())) return; - + if (event.GetAbility().equals(getName() + " Shoot")) { soundRefire(event.GetPlayer().getEyeLocation()); @@ -338,18 +342,18 @@ public abstract class Gun extends StrikeItem soundReloaded(event.GetPlayer().getEyeLocation()); } } - + @Override public boolean pickup(MineStrike game, Player player) { if (player.getInventory().getItem(_slot) != null && player.getInventory().getItem(_slot).getType() != Material.AIR) return false; - - giveToPlayer(player); - + + giveToPlayer(player, false); + game.registerGun(this, player); game.deregisterDroppedGun(this); - + return true; } @@ -359,10 +363,10 @@ public abstract class Gun extends StrikeItem _reserveAmmo = _clipReserve * _clipSize; updateWeaponName(player); - + player.setHealth(20); } - + @Override public String getShopItemType() { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/pistol/Glock18.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/pistol/Glock18.java index b29eef007..937761e0c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/pistol/Glock18.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/pistol/Glock18.java @@ -16,7 +16,7 @@ public class Glock18 extends Gun { }, - 0, 0, //Cost, Gem Cost + 200, 0, //Cost, Gem Cost 20, 6, //Clip Size, Spare Ammo 120, 2000, //ROF, Reload Time 5, 0.01, 3.5, //Damage, Dropoff, Bullet Speed diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/pistol/P2000.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/pistol/P2000.java index 332867422..77f7b0be6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/pistol/P2000.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/pistol/P2000.java @@ -16,7 +16,7 @@ public class P2000 extends Gun { }, - 0, 0, //Cost, Gem Cost + 200, 0, //Cost, Gem Cost 13, 4, //Clip Size, Spare Ammo 130, 2200, //ROF, Reload Time 6, 0.01, 3.5, //Damage, Dropoff, Bullet Speed diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/rifle/AWP.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/rifle/AWP.java index 149f84a72..8da4b7724 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/rifle/AWP.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/rifle/AWP.java @@ -24,4 +24,6 @@ public class AWP extends Gun 0, 0, //COF Inc per Bullet, COF Dec per Second Material.GOLD_SPADE, Sound.DRINK); } + + } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java index 42d3a857f..d591c5116 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java @@ -44,11 +44,14 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.MapUtil; import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilText.TextAlign; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilWorld; diff --git a/Website/LOC.Website.Common/Contexts/Repository.cs b/Website/LOC.Website.Common/Contexts/Repository.cs index de90ffa75..9b19981d9 100644 --- a/Website/LOC.Website.Common/Contexts/Repository.cs +++ b/Website/LOC.Website.Common/Contexts/Repository.cs @@ -69,6 +69,10 @@ } throw; } + catch (Exception e) + { + Log("ERROR", PREFIX + String.Join("; ", e.InnerException.InnerException.Message)); + } } public virtual void Delete(TEntity entity) where TEntity : class diff --git a/Website/LOC.Website.Common/LOC.Website.Common.csproj b/Website/LOC.Website.Common/LOC.Website.Common.csproj index bcce2c618..4cd3ebb12 100644 --- a/Website/LOC.Website.Common/LOC.Website.Common.csproj +++ b/Website/LOC.Website.Common/LOC.Website.Common.csproj @@ -58,6 +58,7 @@ + diff --git a/Website/LOC.Website.Common/Models/AccountAdministrator.cs b/Website/LOC.Website.Common/Models/AccountAdministrator.cs index 67a0492bb..96a6b8824 100644 --- a/Website/LOC.Website.Common/Models/AccountAdministrator.cs +++ b/Website/LOC.Website.Common/Models/AccountAdministrator.cs @@ -15,6 +15,7 @@ using Data; using LOC.Website.Common.Contexts; using System.Data.Entity.Infrastructure; + using System.Transactions; public class AccountAdministrator : IAccountAdministrator { @@ -542,106 +543,120 @@ { Rank rank = null; - using (var repository = _repositoryFactory.CreateRepository()) + try { - var account = repository.Where(x => String.Equals(x.Name, token.Name)).Include(x => x.Rank).FirstOrDefault(); - rank = repository.Where(x => String.Equals(x.Name, token.Rank)).FirstOrDefault(); - - if (account == null) - return "ALL"; - - if (account.Rank.Name == "ADMIN" || account.Rank.Name == "OWNER" || account.Rank.Name == "DEVELOPER" || account.Rank.Name == "YOUTUBE") - return account.Rank.Name; - - if (rank == null) - return account.Rank.ToString(); - - account.Rank = rank; - account.RankExpire = DateTime.Now.AddMonths(1); - account.RankPerm = token.Perm; - - repository.Edit(account); - - if ((rank.Name == "HERO" || rank.Name == "ULTRA") && token.Perm) + using (var repository = _repositoryFactory.CreateRepository()) { - addAccountTransaction(repository, account, "Bacon Brawl Bebe Piggles", 0, 0); - addAccountTransaction(repository, account, "Bacon Brawl `Pig`", 0, 0); - addAccountTransaction(repository, account, "A Barbarians Life Barbarian Archer", 0, 0); - addAccountTransaction(repository, account, "A Barbarians Life Bomber", 0, 0); - addAccountTransaction(repository, account, "The Bridges Archer", 0, 0); - addAccountTransaction(repository, account, "The Bridges Bomber", 0, 0); - addAccountTransaction(repository, account, "The Bridges Brawler", 0, 0); - addAccountTransaction(repository, account, "The Bridges Miner", 0, 0); - addAccountTransaction(repository, account, "Castle Siege Castle Assassin", 0, 0); - addAccountTransaction(repository, account, "Castle Siege Castle Brawler", 0, 0); - addAccountTransaction(repository, account, "Castle Siege Castle Knight", 0, 0); - addAccountTransaction(repository, account, "Castle Siege Undead Archer", 0, 0); - addAccountTransaction(repository, account, "Castle Siege Undead Zombie", 0, 0); - addAccountTransaction(repository, account, "Death Tag Runner Archer", 0, 0); - addAccountTransaction(repository, account, "Death Tag Runner Traitor", 0, 0); - addAccountTransaction(repository, account, "Dragon Escape Disruptor", 0, 0); - addAccountTransaction(repository, account, "Dragon Escape Warper", 0, 0); - addAccountTransaction(repository, account, "Dragons Marksman", 0, 0); - addAccountTransaction(repository, account, "Dragons Pyrotechnic", 0, 0); - addAccountTransaction(repository, account, "Block Hunt Instant Hider", 0, 0); - addAccountTransaction(repository, account, "Block Hunt Shocking Hider", 0, 0); - addAccountTransaction(repository, account, "Block Hunt Radar Hunter", 0, 0); - addAccountTransaction(repository, account, "Block Hunt TNT Hunter", 0, 0); - addAccountTransaction(repository, account, "Super Paintball Machine Gun", 0, 0); - addAccountTransaction(repository, account, "Super Paintball Shotgun", 0, 0); - addAccountTransaction(repository, account, "One in the Quiver Brawler", 0, 0); - addAccountTransaction(repository, account, "One in the Quiver Enchanter", 0, 0); - addAccountTransaction(repository, account, "Runner Archer", 0, 0); - addAccountTransaction(repository, account, "Runner Frosty", 0, 0); - addAccountTransaction(repository, account, "Sheep Quest Archer", 0, 0); - addAccountTransaction(repository, account, "Sheep Quest Brute", 0, 0); - addAccountTransaction(repository, account, "Super Smash Mobs Blaze", 0, 0); - addAccountTransaction(repository, account, "Super Smash Mobs Chicken", 0, 0); - addAccountTransaction(repository, account, "Super Smash Mobs Mad Cow", 0, 0); - addAccountTransaction(repository, account, "Super Smash Mobs Creeper", 0, 0); - addAccountTransaction(repository, account, "Super Smash Mobs Enderman", 0, 0); - addAccountTransaction(repository, account, "Super Smash Mobs Undead Knight", 0, 0); - addAccountTransaction(repository, account, "Super Smash Mobs Magma Cube", 0, 0); - addAccountTransaction(repository, account, "Super Smash Mobs Pig", 0, 0); - addAccountTransaction(repository, account, "Super Smash Mobs Skeletal Horse", 0, 0); - addAccountTransaction(repository, account, "Super Smash Mobs Sky Squid", 0, 0); - addAccountTransaction(repository, account, "Super Smash Mobs Snowman", 0, 0); - addAccountTransaction(repository, account, "Super Smash Mobs Witch", 0, 0); - addAccountTransaction(repository, account, "Super Smash Mobs Wither", 0, 0); - addAccountTransaction(repository, account, "Super Smash Mobs Wither Skeleton", 0, 0); - addAccountTransaction(repository, account, "Super Smash Mobs Wolf", 0, 0); - addAccountTransaction(repository, account, "Snake Super Snake", 0, 0); - addAccountTransaction(repository, account, "Snake Other Snake", 0, 0); - addAccountTransaction(repository, account, "Sneaky Assassins Ranged Assassin", 0, 0); - addAccountTransaction(repository, account, "Sneaky Assassins Revealer", 0, 0); - addAccountTransaction(repository, account, "Super Spleef Archer", 0, 0); - addAccountTransaction(repository, account, "Super Spleef Brawler", 0, 0); - addAccountTransaction(repository, account, "Squid Shooter Squid Blaster", 0, 0); - addAccountTransaction(repository, account, "Squid Shooter Squid Sniper", 0, 0); - addAccountTransaction(repository, account, "Survival Games Archer", 0, 0); - addAccountTransaction(repository, account, "Survival Games Assassin", 0, 0); - addAccountTransaction(repository, account, "Survival Games Beastmaster", 0, 0); - addAccountTransaction(repository, account, "Survival Games Bomber", 0, 0); - addAccountTransaction(repository, account, "Survival Games Brawler", 0, 0); - addAccountTransaction(repository, account, "Survival Games Necromancer", 0, 0); - addAccountTransaction(repository, account, "Turf Wars Infiltrator", 0, 0); - addAccountTransaction(repository, account, "Turf Wars Shredder", 0, 0); - addAccountTransaction(repository, account, "Zombie Survival Survivor Archer", 0, 0); - addAccountTransaction(repository, account, "Zombie Survival Survivor Rogue", 0, 0); + var account = repository.Where(x => String.Equals(x.Name, token.Name)).Include(x => x.Rank).FirstOrDefault(); + rank = repository.Where(x => String.Equals(x.Name, token.Rank)).FirstOrDefault(); + + if (account == null) + return "ALL"; + + if (account.Rank.Name == "ADMIN" || account.Rank.Name == "OWNER" || account.Rank.Name == "DEVELOPER" || account.Rank.Name == "YOUTUBE") + return account.Rank.Name; + + if (rank == null) + return account.Rank.ToString(); + + repository.Attach(account); + repository.Edit(account); + + var expire = DateTime.Now.AddMonths(1).AddMilliseconds(-DateTime.Now.Millisecond); + + account.Rank = rank; + account.RankExpire = expire; + account.RankPerm = token.Perm; + + repository.CommitChanges(); + + repository.Edit(account); + + if ((rank.Name == "HERO" || rank.Name == "ULTRA") && token.Perm) + { + addAccountTransaction(repository, account, "Bacon Brawl Bebe Piggles", 0, 0); + addAccountTransaction(repository, account, "Bacon Brawl `Pig`", 0, 0); + addAccountTransaction(repository, account, "A Barbarians Life Barbarian Archer", 0, 0); + addAccountTransaction(repository, account, "A Barbarians Life Bomber", 0, 0); + addAccountTransaction(repository, account, "The Bridges Archer", 0, 0); + addAccountTransaction(repository, account, "The Bridges Bomber", 0, 0); + addAccountTransaction(repository, account, "The Bridges Brawler", 0, 0); + addAccountTransaction(repository, account, "The Bridges Miner", 0, 0); + addAccountTransaction(repository, account, "Castle Siege Castle Assassin", 0, 0); + addAccountTransaction(repository, account, "Castle Siege Castle Brawler", 0, 0); + addAccountTransaction(repository, account, "Castle Siege Castle Knight", 0, 0); + addAccountTransaction(repository, account, "Castle Siege Undead Archer", 0, 0); + addAccountTransaction(repository, account, "Castle Siege Undead Zombie", 0, 0); + addAccountTransaction(repository, account, "Death Tag Runner Archer", 0, 0); + addAccountTransaction(repository, account, "Death Tag Runner Traitor", 0, 0); + addAccountTransaction(repository, account, "Dragon Escape Disruptor", 0, 0); + addAccountTransaction(repository, account, "Dragon Escape Warper", 0, 0); + addAccountTransaction(repository, account, "Dragons Marksman", 0, 0); + addAccountTransaction(repository, account, "Dragons Pyrotechnic", 0, 0); + addAccountTransaction(repository, account, "Block Hunt Instant Hider", 0, 0); + addAccountTransaction(repository, account, "Block Hunt Shocking Hider", 0, 0); + addAccountTransaction(repository, account, "Block Hunt Radar Hunter", 0, 0); + addAccountTransaction(repository, account, "Block Hunt TNT Hunter", 0, 0); + addAccountTransaction(repository, account, "Super Paintball Machine Gun", 0, 0); + addAccountTransaction(repository, account, "Super Paintball Shotgun", 0, 0); + addAccountTransaction(repository, account, "One in the Quiver Brawler", 0, 0); + addAccountTransaction(repository, account, "One in the Quiver Enchanter", 0, 0); + addAccountTransaction(repository, account, "Runner Archer", 0, 0); + addAccountTransaction(repository, account, "Runner Frosty", 0, 0); + addAccountTransaction(repository, account, "Sheep Quest Archer", 0, 0); + addAccountTransaction(repository, account, "Sheep Quest Brute", 0, 0); + addAccountTransaction(repository, account, "Super Smash Mobs Blaze", 0, 0); + addAccountTransaction(repository, account, "Super Smash Mobs Chicken", 0, 0); + addAccountTransaction(repository, account, "Super Smash Mobs Mad Cow", 0, 0); + addAccountTransaction(repository, account, "Super Smash Mobs Creeper", 0, 0); + addAccountTransaction(repository, account, "Super Smash Mobs Enderman", 0, 0); + addAccountTransaction(repository, account, "Super Smash Mobs Undead Knight", 0, 0); + addAccountTransaction(repository, account, "Super Smash Mobs Magma Cube", 0, 0); + addAccountTransaction(repository, account, "Super Smash Mobs Pig", 0, 0); + addAccountTransaction(repository, account, "Super Smash Mobs Skeletal Horse", 0, 0); + addAccountTransaction(repository, account, "Super Smash Mobs Sky Squid", 0, 0); + addAccountTransaction(repository, account, "Super Smash Mobs Snowman", 0, 0); + addAccountTransaction(repository, account, "Super Smash Mobs Witch", 0, 0); + addAccountTransaction(repository, account, "Super Smash Mobs Wither", 0, 0); + addAccountTransaction(repository, account, "Super Smash Mobs Wither Skeleton", 0, 0); + addAccountTransaction(repository, account, "Super Smash Mobs Wolf", 0, 0); + addAccountTransaction(repository, account, "Snake Super Snake", 0, 0); + addAccountTransaction(repository, account, "Snake Other Snake", 0, 0); + addAccountTransaction(repository, account, "Sneaky Assassins Ranged Assassin", 0, 0); + addAccountTransaction(repository, account, "Sneaky Assassins Revealer", 0, 0); + addAccountTransaction(repository, account, "Super Spleef Archer", 0, 0); + addAccountTransaction(repository, account, "Super Spleef Brawler", 0, 0); + addAccountTransaction(repository, account, "Squid Shooter Squid Blaster", 0, 0); + addAccountTransaction(repository, account, "Squid Shooter Squid Sniper", 0, 0); + addAccountTransaction(repository, account, "Survival Games Archer", 0, 0); + addAccountTransaction(repository, account, "Survival Games Assassin", 0, 0); + addAccountTransaction(repository, account, "Survival Games Beastmaster", 0, 0); + addAccountTransaction(repository, account, "Survival Games Bomber", 0, 0); + addAccountTransaction(repository, account, "Survival Games Brawler", 0, 0); + addAccountTransaction(repository, account, "Survival Games Necromancer", 0, 0); + addAccountTransaction(repository, account, "Turf Wars Infiltrator", 0, 0); + addAccountTransaction(repository, account, "Turf Wars Shredder", 0, 0); + addAccountTransaction(repository, account, "Zombie Survival Survivor Archer", 0, 0); + addAccountTransaction(repository, account, "Zombie Survival Survivor Rogue", 0, 0); + } + + repository.CommitChanges(); + + _logger.Log("INFO", "TOKEN " + token.Name + "'s rank has been updated to " + token.Rank + " " + (token.Perm ? "Permanently" : "Monthly") + "." + " Rank expire : " + account.RankExpire.ToString()); } - repository.CommitChanges(); - - _logger.Log("INFO", "TOKEN " + token.Name + "'s rank has been updated to " + token.Rank + " " + (token.Perm ? "Permanently" : "Monthly") + "." + " Rank expire : " + account.RankExpire.ToString()); + using (var repository = _repositoryFactory.CreateRepository()) + { + var account = repository.Where(x => String.Equals(x.Name, token.Name)).Include(x => x.Rank).FirstOrDefault(); + _logger.Log("INFO", "ACCOUNT " + account.Name + "'s rank is " + account.Rank.Name + " " + (account.RankPerm ? "Permanently" : "Monthly") + "." + " Rank expire : " + account.RankExpire.ToString()); + } } - - using (var repository = _repositoryFactory.CreateRepository()) + catch (Exception ex) { - var account = repository.Where(x => String.Equals(x.Name, token.Name)).Include(x => x.Rank).FirstOrDefault(); - _logger.Log("INFO", "ACCOUNT " + account.Name + "'s rank is " + account.Rank.Name + " " + (account.RankPerm ? "Permanently" : "Monthly") + "." + " Rank expire : " + account.RankExpire.ToString()); + _logger.Log("ERROR", "Applying UpdateRank : " + String.Join("; ", ex.InnerException.InnerException.Message)); } - return rank.Name.ToString(); + return rank == null ? token.Rank : rank.Name.ToString(); } public void RemoveBan(RemovePunishmentToken token) @@ -682,7 +697,7 @@ { var account = repository.Where(x => x.AccountId == accountId).Include(x => x.Transactions).First(); - var accountTransaction = new Transaction {Account = account, SalesPackage = salesPackage, Fee = fee, Profit = (gross - fee), Time = DateTime.Now}; + var accountTransaction = new LOC.Core.Model.Sales.Transaction {Account = account, SalesPackage = salesPackage, Fee = fee, Profit = (gross - fee), Time = DateTime.Now}; repository.Attach(salesPackage); @@ -690,7 +705,7 @@ repository.Edit(account); if (account.Transactions == null) - account.Transactions = new List(); + account.Transactions = new List(); account.Transactions.Add(accountTransaction); account.Gems += salesPackage.Gems; @@ -724,7 +739,7 @@ Rank = repository.Where(x => x.RankId == 1).First(), Gems = 0, Coins = 0, - Transactions = new List(), + Transactions = new List(), PvpTransactions = new List(), IpAddresses = new List(), MacAddresses = new List(), diff --git a/Website/LOC.Website.Web/LOC.Website.Web.Publish.xml b/Website/LOC.Website.Web/LOC.Website.Web.Publish.xml index f6af927bc..bdefbafe8 100644 --- a/Website/LOC.Website.Web/LOC.Website.Web.Publish.xml +++ b/Website/LOC.Website.Web/LOC.Website.Web.Publish.xml @@ -614,7 +614,7 @@ - + @@ -622,7 +622,7 @@ - + @@ -692,9 +692,9 @@ - + - + diff --git a/Website/LOCWebsite.suo b/Website/LOCWebsite.suo index 04d379ca9..60dbf9eda 100644 Binary files a/Website/LOCWebsite.suo and b/Website/LOCWebsite.suo differ