Backport a few 1.10 fixes that should are relevant for 1.9.4

Fixes:
SPIGOT-2380
SPIGOT-1124
SPIGOT-2322
SPIGOT-2348
This commit is contained in:
Zach Brown 2016-06-11 22:52:15 -05:00
parent 171a079cd2
commit fcf419512d
No known key found for this signature in database
GPG key ID: CC9DA35FC5450B76
4 changed files with 154 additions and 0 deletions

View file

@ -0,0 +1,47 @@
From 36f323685571e1dfa2056aea47c91f96bd1dae75 Mon Sep 17 00:00:00 2001
From: md_5 <git@md-5.net>
Date: Sat, 11 Jun 2016 22:33:51 -0500
Subject: [PATCH] SPIGOT-2380: Hitting in the air will always load the chunk at
0,0
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
index f2d9461..fc5ba08 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -191,7 +191,7 @@ public class CraftEventFactory {
if (action != Action.LEFT_CLICK_AIR && action != Action.RIGHT_CLICK_AIR) {
throw new IllegalArgumentException(String.format("%s performing %s with %s", who, action, itemstack)); // Spigot
}
- return callPlayerInteractEvent(who, action, new BlockPosition(0, 256, 0), EnumDirection.SOUTH, itemstack, hand);
+ return callPlayerInteractEvent(who, action, null, EnumDirection.SOUTH, itemstack, hand);
}
public static PlayerInteractEvent callPlayerInteractEvent(EntityHuman who, Action action, BlockPosition position, EnumDirection direction, ItemStack itemstack, EnumHand hand) {
@@ -205,11 +205,10 @@ public class CraftEventFactory {
CraftWorld craftWorld = (CraftWorld) player.getWorld();
CraftServer craftServer = (CraftServer) player.getServer();
- Block blockClicked = craftWorld.getBlockAt(position.getX(), position.getY(), position.getZ());
- BlockFace blockFace = CraftBlock.notchToBlockFace(direction);
-
- if (position.getY() > 255) {
- blockClicked = null;
+ Block blockClicked = null;
+ if (position != null) {
+ blockClicked = craftWorld.getBlockAt(position.getX(), position.getY(), position.getZ());
+ } else {
switch (action) {
case LEFT_CLICK_BLOCK:
action = Action.LEFT_CLICK_AIR;
@@ -219,6 +218,7 @@ public class CraftEventFactory {
break;
}
}
+ BlockFace blockFace = CraftBlock.notchToBlockFace(direction);
if (itemInHand.getType() == Material.AIR || itemInHand.getAmount() == 0) {
itemInHand = null;
--
2.8.3

View file

@ -0,0 +1,22 @@
From 0cb35fe76a8bd74a6f5c029cf8d4632bd5f1cd82 Mon Sep 17 00:00:00 2001
From: md_5 <git@md-5.net>
Date: Sat, 11 Jun 2016 22:36:12 -0500
Subject: [PATCH] SPIGOT-1124: Changed To-Location on Teleport event ignored
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index cf27086..16db36e 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -682,7 +682,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
PlayerTeleportEvent event = new PlayerTeleportEvent(player, from.clone(), to.clone(), PlayerTeleportEvent.TeleportCause.UNKNOWN);
this.server.getPluginManager().callEvent(event);
- if (event.isCancelled() || to.equals(event.getTo())) {
+ if (event.isCancelled() || !to.equals(event.getTo())) {
set.clear(); // Can't relative teleport
to = event.isCancelled() ? event.getFrom() : event.getTo();
d0 = to.getX();
--
2.8.3

View file

@ -0,0 +1,49 @@
From 90a08c724d28636bbbd47a7364f66bc26111dd29 Mon Sep 17 00:00:00 2001
From: md_5 <git@md-5.net>
Date: Sat, 11 Jun 2016 22:41:13 -0500
Subject: [PATCH] SPIGOT-2322: Chunks generating with missing / corrupted data.
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index 4a2cad6..33b3db7 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
@@ -105,14 +105,23 @@ public class ChunkProviderServer implements IChunkProvider {
if (loader != null && loader.chunkExists(world, i, j)) {
chunk = ChunkIOExecutor.syncChunkLoad(world, loader, this, i, j);
}
- /* chunk = this.loadChunk(i, j);
+ }
+
+ return chunk;
+ }
+
+ @Nullable
+ public Chunk originalGetOrLoadChunkAt(int i, int j) {
+ // CraftBukkit end
+ Chunk chunk = this.getLoadedChunkAt(i, j);
+
+ if (chunk == null) {
+ chunk = this.loadChunk(i, j);
if (chunk != null) {
this.chunks.put(ChunkCoordIntPair.a(i, j), chunk);
chunk.addEntities();
chunk.loadNearby(this, this.chunkGenerator);
}
- */
- // CraftBukkit end
}
return chunk;
@@ -161,7 +170,7 @@ public class ChunkProviderServer implements IChunkProvider {
}
public Chunk originalGetChunkAt(int i, int j) {
- Chunk chunk = this.getLoadedChunkAt(i, j);
+ Chunk chunk = this.originalGetOrLoadChunkAt(i, j);
boolean newChunk = false;
// CraftBukkit end
--
2.8.3

View file

@ -0,0 +1,36 @@
From 82c7ab1d2357cc85903cfd762d51fcede6a5fcd8 Mon Sep 17 00:00:00 2001
From: md_5 <git@md-5.net>
Date: Sat, 11 Jun 2016 22:47:52 -0500
Subject: [PATCH] SPIGOT-2348: EntityTeleportEvent cancellation
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
index 129bca8..c4c0308 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -2348,16 +2348,14 @@ public abstract class EntityLiving extends Entity {
// this.enderTeleportTo(this.locX, this.locY, this.locZ);
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;
+ if (!teleport.isCancelled()) {
+ Location to = teleport.getTo();
+ this.enderTeleportTo(to.getX(), to.getY(), to.getZ());
+ if (world.getCubes(this, this.getBoundingBox()).isEmpty() && !world.containsLiquid(this.getBoundingBox())) {
+ flag = true;
+ }
}
-
- Location to = teleport.getTo();
- this.enderTeleportTo(to.getX(), to.getY(), to.getZ());
// CraftBukkit end
- if (world.getCubes(this, this.getBoundingBox()).isEmpty() && !world.containsLiquid(this.getBoundingBox())) {
- flag = true;
- }
}
}
--
2.8.3