diff options
author | md_5 <git@md-5.net> | 2015-01-09 16:59:18 +1100 |
---|---|---|
committer | md_5 <git@md-5.net> | 2015-01-09 16:59:40 +1100 |
commit | 4470462a54954109ebb39dcd0cc3bb4be983a050 (patch) | |
tree | 214bc87dcb6ef8e5adee6a4eb4eb44ffc84b7626 | |
parent | ba8f63080d2a6d89b3f98f48026c09b09a08b5c7 (diff) | |
download | craftbukkit-4470462a54954109ebb39dcd0cc3bb4be983a050.tar craftbukkit-4470462a54954109ebb39dcd0cc3bb4be983a050.tar.gz craftbukkit-4470462a54954109ebb39dcd0cc3bb4be983a050.tar.lz craftbukkit-4470462a54954109ebb39dcd0cc3bb4be983a050.tar.xz craftbukkit-4470462a54954109ebb39dcd0cc3bb4be983a050.zip |
SPIGOT-387: Remove redundant custom vehicle handling.
-rw-r--r-- | nms-patches/Entity.patch | 30 | ||||
-rw-r--r-- | nms-patches/EntityPlayer.patch | 73 | ||||
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java | 6 |
3 files changed, 38 insertions, 71 deletions
diff --git a/nms-patches/Entity.patch b/nms-patches/Entity.patch index 44025a59..36f8960a 100644 --- a/nms-patches/Entity.patch +++ b/nms-patches/Entity.patch @@ -1,5 +1,5 @@ ---- ../work/decompile-8eb82bde//net/minecraft/server/Entity.java 2015-01-04 20:00:32.717671452 +0000 -+++ src/main/java/net/minecraft/server/Entity.java 2015-01-04 20:00:32.721671452 +0000 +--- ../work/decompile-8eb82bde/net/minecraft/server/Entity.java 2015-01-09 16:56:08.177542854 +1100 ++++ src/main/java/net/minecraft/server/Entity.java 2015-01-09 16:56:08.181542844 +1100 @@ -6,8 +6,40 @@ import java.util.UUID; import java.util.concurrent.Callable; @@ -315,7 +315,7 @@ + } + } + // CraftBukkit end -+ + + // CraftBukkit start - Exempt Vehicles from notch's sanity check + if (!(getBukkitEntity() instanceof Vehicle)) { + if (Math.abs(this.motX) > 10.0D) { @@ -331,7 +331,7 @@ + } + } + // CraftBukkit end - ++ + // CraftBukkit start - Reset world + if (this instanceof EntityPlayer) { + Server server = Bukkit.getServer(); @@ -371,14 +371,11 @@ EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY + (double) f, this.locZ, itemstack); entityitem.p(); -@@ -1276,16 +1491,76 @@ +@@ -1275,17 +1490,70 @@ + return (double) this.length * 0.75D; } - public void mount(Entity entity) { -+ // CraftBukkit start -+ setPassengerOf(entity); -+ } -+ ++ // CraftBukkit start + protected CraftEntity bukkitEntity; + + public CraftEntity getBukkitEntity() { @@ -388,10 +385,7 @@ + return bukkitEntity; + } + -+ public void setPassengerOf(Entity entity) { -+ // b(null) doesn't really fly for overloaded methods, -+ // so this method is needed -+ + public void mount(Entity entity) { + Entity originalVehicle = this.vehicle; + Entity originalPassenger = this.vehicle == null ? null : this.vehicle.passenger; + PluginManager pluginManager = Bukkit.getPluginManager(); @@ -437,7 +431,7 @@ + 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.setPositionRotation(this.vehicle.locX, this.vehicle.getBoundingBox().b + (double) this.vehicle.length, this.vehicle.locZ, this.yaw, this.pitch); + this.vehicle.passenger = null; + this.vehicle = null; + } @@ -448,7 +442,7 @@ if (this.vehicle != null) { this.vehicle.passenger = null; } -@@ -1406,10 +1681,50 @@ +@@ -1406,10 +1674,50 @@ } public void onLightningStrike(EntityLightning entitylightning) { @@ -500,7 +494,7 @@ } } -@@ -1546,32 +1861,82 @@ +@@ -1546,32 +1854,82 @@ if (!this.world.isStatic && !this.dead) { this.world.methodProfiler.a("changeDimension"); MinecraftServer minecraftserver = MinecraftServer.getServer(); @@ -588,7 +582,7 @@ } this.dead = true; -@@ -1680,8 +2045,27 @@ +@@ -1680,8 +2038,27 @@ return this.boundingBox; } diff --git a/nms-patches/EntityPlayer.patch b/nms-patches/EntityPlayer.patch index 679fb6be..fa7e23bc 100644 --- a/nms-patches/EntityPlayer.patch +++ b/nms-patches/EntityPlayer.patch @@ -1,5 +1,5 @@ ---- ../work/decompile-8eb82bde//net/minecraft/server/EntityPlayer.java 2014-12-28 16:04:32.820373755 +0000 -+++ src/main/java/net/minecraft/server/EntityPlayer.java 2014-12-28 16:04:32.820373755 +0000 +--- ../work/decompile-8eb82bde/net/minecraft/server/EntityPlayer.java 2015-01-09 16:51:30.962362579 +1100 ++++ src/main/java/net/minecraft/server/EntityPlayer.java 2015-01-09 16:51:30.962362579 +1100 @@ -13,6 +13,17 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -50,7 +50,7 @@ } public void a(NBTTagCompound nbttagcompound) { -@@ -81,13 +108,39 @@ +@@ -81,14 +108,40 @@ this.playerInteractManager.setGameMode(EnumGamemode.getById(nbttagcompound.getInt("playerGameType"))); } } @@ -62,8 +62,8 @@ 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); @@ -86,11 +86,12 @@ + } + this.dimension = ((WorldServer) this.world).dimension; + this.playerInteractManager.a((WorldServer) world); - } ++ } + // CraftBukkit end - ++ public void levelDown(int i) { super.levelDown(i); + this.lastSentExp = -1; @@ -114,6 +167,11 @@ } @@ -288,35 +289,7 @@ if (this.isSleeping()) { this.u().getTracker().sendPacketToEntity(this, new PacketPlayOutAnimation(this, 2)); } -@@ -454,14 +566,23 @@ - } - - public void mount(Entity entity) { -- Entity entity1 = this.vehicle; -+ // 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.mount(entity); -- if (entity != entity1) { -+ 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, Block block, BlockPosition blockposition) {} -@@ -490,19 +611,46 @@ +@@ -490,19 +602,46 @@ this.playerConnection.sendPacket(new PacketPlayOutOpenSignEditor(tileentitysign.getPosition())); } @@ -365,7 +338,7 @@ if (this.activeContainer != this.defaultContainer) { this.closeInventory(); } -@@ -510,9 +658,11 @@ +@@ -510,9 +649,11 @@ if (iinventory instanceof ITileInventory) { ITileInventory itileinventory = (ITileInventory) iinventory; @@ -378,7 +351,7 @@ return; } } -@@ -520,10 +670,10 @@ +@@ -520,10 +661,10 @@ this.nextContainerCounter(); if (iinventory instanceof ITileEntityContainer) { this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, ((ITileEntityContainer) iinventory).getContainerName(), iinventory.getScoreboardDisplayName(), iinventory.getSize())); @@ -391,7 +364,7 @@ } this.activeContainer.windowId = this.containerCounter; -@@ -531,8 +681,14 @@ +@@ -531,8 +672,14 @@ } public void openTrade(IMerchant imerchant) { @@ -407,7 +380,7 @@ this.activeContainer.windowId = this.containerCounter; this.activeContainer.addSlotListener(this); InventoryMerchant inventorymerchant = ((ContainerMerchant) this.activeContainer).e(); -@@ -552,13 +708,20 @@ +@@ -552,13 +699,20 @@ } public void openHorseInventory(EntityHorse entityhorse, IInventory iinventory) { @@ -429,7 +402,7 @@ this.activeContainer.windowId = this.containerCounter; this.activeContainer.addSlotListener(this); } -@@ -587,6 +750,11 @@ +@@ -587,6 +741,11 @@ 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())); @@ -441,7 +414,7 @@ } public void setContainerData(Container container, int i, int j) { -@@ -601,6 +769,7 @@ +@@ -601,6 +760,7 @@ } public void closeInventory() { @@ -449,24 +422,24 @@ this.playerConnection.sendPacket(new PacketPlayOutCloseWindow(this.activeContainer.windowId)); this.p(); } -@@ -681,7 +850,16 @@ +@@ -681,7 +841,16 @@ public void triggerHealthUpdate() { this.bK = -1.0E8F; + this.lastSentExp = -1; // CraftBukkit - Added to reset - } ++ } + + // CraftBukkit start - Support multi-line messages + public void sendMessage(IChatBaseComponent[] ichatbasecomponent) { + for (IChatBaseComponent component : ichatbasecomponent) { + this.sendMessage(component); + } -+ } + } + // CraftBukkit end public void b(IChatBaseComponent ichatbasecomponent) { this.playerConnection.sendPacket(new PacketPlayOutChat(ichatbasecomponent)); -@@ -747,6 +925,8 @@ +@@ -747,6 +916,8 @@ } public void a(EnumGamemode enumgamemode) { @@ -475,7 +448,7 @@ this.playerInteractManager.setGameMode(enumgamemode); this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(3, (float) enumgamemode.getId())); if (enumgamemode == EnumGamemode.SPECTATOR) { -@@ -757,6 +937,7 @@ +@@ -757,6 +928,7 @@ this.updateAbilities(); this.bO(); @@ -483,7 +456,7 @@ } public boolean v() { -@@ -768,6 +949,7 @@ +@@ -768,6 +940,7 @@ } public boolean a(int i, String s) { @@ -491,7 +464,7 @@ if ("seed".equals(s) && !this.server.ad()) { return true; } else if (!"tell".equals(s) && !"help".equals(s) && !"me".equals(s) && !"trigger".equals(s)) { -@@ -781,6 +963,9 @@ +@@ -781,6 +954,9 @@ } else { return true; } @@ -501,7 +474,7 @@ } public String w() { -@@ -867,6 +1052,129 @@ +@@ -867,6 +1043,129 @@ } public IChatBaseComponent getPlayerListName() { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java index dee0d4ef..705381f9 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -302,7 +302,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { public boolean setPassenger(org.bukkit.entity.Entity passenger) { if (passenger instanceof CraftEntity) { - ((CraftEntity) passenger).getHandle().setPassengerOf(getHandle()); + ((CraftEntity) passenger).getHandle().mount(getHandle()); return true; } else { return false; @@ -318,7 +318,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { return false; } - getHandle().passenger.setPassengerOf(null); + getHandle().passenger.mount(null); return true; } @@ -414,7 +414,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { return false; } - getHandle().setPassengerOf(null); + getHandle().mount(null); return true; } |