13
0
geforkt von Mirrors/Paper

SPIGOT-387: Remove redundant custom vehicle handling.

By: md_5 <git@md-5.net>
Dieser Commit ist enthalten in:
CraftBukkit/Spigot 2015-01-09 16:59:18 +11:00
Ursprung a58b5b1e87
Commit 04c9a53768
3 geänderte Dateien mit 38 neuen und 71 gelöschten Zeilen

Datei anzeigen

@ -1,5 +1,5 @@
--- ../work/decompile-8eb82bde//net/minecraft/server/Entity.java 2015-01-04 20:00:32.717671452 +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-04 20:00:32.721671452 +0000 +++ src/main/java/net/minecraft/server/Entity.java 2015-01-09 16:56:08.181542844 +1100
@@ -6,8 +6,40 @@ @@ -6,8 +6,40 @@
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
@ -315,7 +315,7 @@
+ } + }
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+
+ // CraftBukkit start - Exempt Vehicles from notch's sanity check + // CraftBukkit start - Exempt Vehicles from notch's sanity check
+ if (!(getBukkitEntity() instanceof Vehicle)) { + if (!(getBukkitEntity() instanceof Vehicle)) {
+ if (Math.abs(this.motX) > 10.0D) { + if (Math.abs(this.motX) > 10.0D) {
@ -331,7 +331,7 @@
+ } + }
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+
+ // CraftBukkit start - Reset world + // CraftBukkit start - Reset world
+ if (this instanceof EntityPlayer) { + if (this instanceof EntityPlayer) {
+ Server server = Bukkit.getServer(); + Server server = Bukkit.getServer();
@ -371,14 +371,11 @@
EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY + (double) f, this.locZ, itemstack); EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY + (double) f, this.locZ, itemstack);
entityitem.p(); entityitem.p();
@@ -1276,16 +1491,76 @@ @@ -1275,17 +1490,70 @@
return (double) this.length * 0.75D;
} }
public void mount(Entity entity) { + // CraftBukkit start
+ // CraftBukkit start
+ setPassengerOf(entity);
+ }
+
+ protected CraftEntity bukkitEntity; + protected CraftEntity bukkitEntity;
+ +
+ public CraftEntity getBukkitEntity() { + public CraftEntity getBukkitEntity() {
@ -388,10 +385,7 @@
+ return bukkitEntity; + return bukkitEntity;
+ } + }
+ +
+ public void setPassengerOf(Entity entity) { public void mount(Entity entity) {
+ // b(null) doesn't really fly for overloaded methods,
+ // so this method is needed
+
+ Entity originalVehicle = this.vehicle; + Entity originalVehicle = this.vehicle;
+ Entity originalPassenger = this.vehicle == null ? null : this.vehicle.passenger; + Entity originalPassenger = this.vehicle == null ? null : this.vehicle.passenger;
+ PluginManager pluginManager = Bukkit.getPluginManager(); + PluginManager pluginManager = Bukkit.getPluginManager();
@ -437,7 +431,7 @@
+ if (event.isCancelled() || this.vehicle != originalVehicle || (this.vehicle != null && this.vehicle.passenger != originalPassenger)) { + 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 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) { + 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.passenger = null;
+ this.vehicle = null; + this.vehicle = null;
+ } + }
@ -448,7 +442,7 @@
if (this.vehicle != null) { if (this.vehicle != null) {
this.vehicle.passenger = null; this.vehicle.passenger = null;
} }
@@ -1406,10 +1681,50 @@ @@ -1406,10 +1674,50 @@
} }
public void onLightningStrike(EntityLightning entitylightning) { public void onLightningStrike(EntityLightning entitylightning) {
@ -500,7 +494,7 @@
} }
} }
@@ -1546,32 +1861,82 @@ @@ -1546,32 +1854,82 @@
if (!this.world.isStatic && !this.dead) { if (!this.world.isStatic && !this.dead) {
this.world.methodProfiler.a("changeDimension"); this.world.methodProfiler.a("changeDimension");
MinecraftServer minecraftserver = MinecraftServer.getServer(); MinecraftServer minecraftserver = MinecraftServer.getServer();
@ -588,7 +582,7 @@
} }
this.dead = true; this.dead = true;
@@ -1680,8 +2045,27 @@ @@ -1680,8 +2038,27 @@
return this.boundingBox; return this.boundingBox;
} }

Datei anzeigen

@ -1,5 +1,5 @@
--- ../work/decompile-8eb82bde//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 2014-12-28 16:04:32.820373755 +0000 +++ src/main/java/net/minecraft/server/EntityPlayer.java 2015-01-09 16:51:30.962362579 +1100
@@ -13,6 +13,17 @@ @@ -13,6 +13,17 @@
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
@ -50,7 +50,7 @@
} }
public void a(NBTTagCompound nbttagcompound) { public void a(NBTTagCompound nbttagcompound) {
@@ -81,13 +108,39 @@ @@ -81,14 +108,40 @@
this.playerInteractManager.setGameMode(EnumGamemode.getById(nbttagcompound.getInt("playerGameType"))); this.playerInteractManager.setGameMode(EnumGamemode.getById(nbttagcompound.getInt("playerGameType")));
} }
} }
@ -62,8 +62,8 @@
super.b(nbttagcompound); super.b(nbttagcompound);
nbttagcompound.setInt("playerGameType", this.playerInteractManager.getGameMode().getId()); nbttagcompound.setInt("playerGameType", this.playerInteractManager.getGameMode().getId());
+ this.getBukkitEntity().setExtraData(nbttagcompound); // CraftBukkit + this.getBukkitEntity().setExtraData(nbttagcompound); // CraftBukkit
+ } }
+
+ // CraftBukkit start - World fallback code, either respawn location or global spawn + // CraftBukkit start - World fallback code, either respawn location or global spawn
+ public void spawnIn(World world) { + public void spawnIn(World world) {
+ super.spawnIn(world); + super.spawnIn(world);
@ -86,11 +86,12 @@
+ } + }
+ this.dimension = ((WorldServer) this.world).dimension; + this.dimension = ((WorldServer) this.world).dimension;
+ this.playerInteractManager.a((WorldServer) world); + this.playerInteractManager.a((WorldServer) world);
} + }
+ // CraftBukkit end + // CraftBukkit end
+
public void levelDown(int i) { public void levelDown(int i) {
super.levelDown(i); super.levelDown(i);
this.lastSentExp = -1;
@@ -114,6 +167,11 @@ @@ -114,6 +167,11 @@
} }
@ -288,35 +289,7 @@
if (this.isSleeping()) { if (this.isSleeping()) {
this.u().getTracker().sendPacketToEntity(this, new PacketPlayOutAnimation(this, 2)); this.u().getTracker().sendPacketToEntity(this, new PacketPlayOutAnimation(this, 2));
} }
@@ -454,14 +566,23 @@ @@ -490,19 +602,46 @@
}
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 @@
this.playerConnection.sendPacket(new PacketPlayOutOpenSignEditor(tileentitysign.getPosition())); this.playerConnection.sendPacket(new PacketPlayOutOpenSignEditor(tileentitysign.getPosition()));
} }
@ -365,7 +338,7 @@
if (this.activeContainer != this.defaultContainer) { if (this.activeContainer != this.defaultContainer) {
this.closeInventory(); this.closeInventory();
} }
@@ -510,9 +658,11 @@ @@ -510,9 +649,11 @@
if (iinventory instanceof ITileInventory) { if (iinventory instanceof ITileInventory) {
ITileInventory itileinventory = (ITileInventory) iinventory; ITileInventory itileinventory = (ITileInventory) iinventory;
@ -378,7 +351,7 @@
return; return;
} }
} }
@@ -520,10 +670,10 @@ @@ -520,10 +661,10 @@
this.nextContainerCounter(); this.nextContainerCounter();
if (iinventory instanceof ITileEntityContainer) { if (iinventory instanceof ITileEntityContainer) {
this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, ((ITileEntityContainer) iinventory).getContainerName(), iinventory.getScoreboardDisplayName(), iinventory.getSize())); this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, ((ITileEntityContainer) iinventory).getContainerName(), iinventory.getScoreboardDisplayName(), iinventory.getSize()));
@ -391,7 +364,7 @@
} }
this.activeContainer.windowId = this.containerCounter; this.activeContainer.windowId = this.containerCounter;
@@ -531,8 +681,14 @@ @@ -531,8 +672,14 @@
} }
public void openTrade(IMerchant imerchant) { public void openTrade(IMerchant imerchant) {
@ -407,7 +380,7 @@
this.activeContainer.windowId = this.containerCounter; this.activeContainer.windowId = this.containerCounter;
this.activeContainer.addSlotListener(this); this.activeContainer.addSlotListener(this);
InventoryMerchant inventorymerchant = ((ContainerMerchant) this.activeContainer).e(); InventoryMerchant inventorymerchant = ((ContainerMerchant) this.activeContainer).e();
@@ -552,13 +708,20 @@ @@ -552,13 +699,20 @@
} }
public void openHorseInventory(EntityHorse entityhorse, IInventory iinventory) { public void openHorseInventory(EntityHorse entityhorse, IInventory iinventory) {
@ -429,7 +402,7 @@
this.activeContainer.windowId = this.containerCounter; this.activeContainer.windowId = this.containerCounter;
this.activeContainer.addSlotListener(this); this.activeContainer.addSlotListener(this);
} }
@@ -587,6 +750,11 @@ @@ -587,6 +741,11 @@
public void a(Container container, List list) { public void a(Container container, List list) {
this.playerConnection.sendPacket(new PacketPlayOutWindowItems(container.windowId, list)); this.playerConnection.sendPacket(new PacketPlayOutWindowItems(container.windowId, list));
this.playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, this.inventory.getCarried())); this.playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, this.inventory.getCarried()));
@ -441,7 +414,7 @@
} }
public void setContainerData(Container container, int i, int j) { public void setContainerData(Container container, int i, int j) {
@@ -601,6 +769,7 @@ @@ -601,6 +760,7 @@
} }
public void closeInventory() { public void closeInventory() {
@ -449,24 +422,24 @@
this.playerConnection.sendPacket(new PacketPlayOutCloseWindow(this.activeContainer.windowId)); this.playerConnection.sendPacket(new PacketPlayOutCloseWindow(this.activeContainer.windowId));
this.p(); this.p();
} }
@@ -681,7 +850,16 @@ @@ -681,7 +841,16 @@
public void triggerHealthUpdate() { public void triggerHealthUpdate() {
this.bK = -1.0E8F; this.bK = -1.0E8F;
+ this.lastSentExp = -1; // CraftBukkit - Added to reset + this.lastSentExp = -1; // CraftBukkit - Added to reset
} + }
+ +
+ // CraftBukkit start - Support multi-line messages + // CraftBukkit start - Support multi-line messages
+ public void sendMessage(IChatBaseComponent[] ichatbasecomponent) { + public void sendMessage(IChatBaseComponent[] ichatbasecomponent) {
+ for (IChatBaseComponent component : ichatbasecomponent) { + for (IChatBaseComponent component : ichatbasecomponent) {
+ this.sendMessage(component); + this.sendMessage(component);
+ } + }
+ } }
+ // CraftBukkit end + // CraftBukkit end
public void b(IChatBaseComponent ichatbasecomponent) { public void b(IChatBaseComponent ichatbasecomponent) {
this.playerConnection.sendPacket(new PacketPlayOutChat(ichatbasecomponent)); this.playerConnection.sendPacket(new PacketPlayOutChat(ichatbasecomponent));
@@ -747,6 +925,8 @@ @@ -747,6 +916,8 @@
} }
public void a(EnumGamemode enumgamemode) { public void a(EnumGamemode enumgamemode) {
@ -475,7 +448,7 @@
this.playerInteractManager.setGameMode(enumgamemode); this.playerInteractManager.setGameMode(enumgamemode);
this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(3, (float) enumgamemode.getId())); this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(3, (float) enumgamemode.getId()));
if (enumgamemode == EnumGamemode.SPECTATOR) { if (enumgamemode == EnumGamemode.SPECTATOR) {
@@ -757,6 +937,7 @@ @@ -757,6 +928,7 @@
this.updateAbilities(); this.updateAbilities();
this.bO(); this.bO();
@ -483,7 +456,7 @@
} }
public boolean v() { public boolean v() {
@@ -768,6 +949,7 @@ @@ -768,6 +940,7 @@
} }
public boolean a(int i, String s) { public boolean a(int i, String s) {
@ -491,7 +464,7 @@
if ("seed".equals(s) && !this.server.ad()) { if ("seed".equals(s) && !this.server.ad()) {
return true; return true;
} else if (!"tell".equals(s) && !"help".equals(s) && !"me".equals(s) && !"trigger".equals(s)) { } else if (!"tell".equals(s) && !"help".equals(s) && !"me".equals(s) && !"trigger".equals(s)) {
@@ -781,6 +963,9 @@ @@ -781,6 +954,9 @@
} else { } else {
return true; return true;
} }
@ -501,7 +474,7 @@
} }
public String w() { public String w() {
@@ -867,6 +1052,129 @@ @@ -867,6 +1043,129 @@
} }
public IChatBaseComponent getPlayerListName() { public IChatBaseComponent getPlayerListName() {

Datei anzeigen

@ -302,7 +302,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
public boolean setPassenger(org.bukkit.entity.Entity passenger) { public boolean setPassenger(org.bukkit.entity.Entity passenger) {
if (passenger instanceof CraftEntity) { if (passenger instanceof CraftEntity) {
((CraftEntity) passenger).getHandle().setPassengerOf(getHandle()); ((CraftEntity) passenger).getHandle().mount(getHandle());
return true; return true;
} else { } else {
return false; return false;
@ -318,7 +318,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
return false; return false;
} }
getHandle().passenger.setPassengerOf(null); getHandle().passenger.mount(null);
return true; return true;
} }
@ -414,7 +414,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
return false; return false;
} }
getHandle().setPassengerOf(null); getHandle().mount(null);
return true; return true;
} }