Archiviert
13
0

Vehicle Dismount Event Improvements

player.getVehicle() was returning null during the event. Paper had added lots of code to
cause the player to remount the entity on cancel.

I've simplified the diff and made player.getVehicle() work during the event by setting the
vehicle back during the event, and only set it to null if the event is not cancelled.
Dieser Commit ist enthalten in:
Aikar 2016-12-29 00:53:02 -05:00
Ursprung 49aca0c04d
Commit c148342731
3 geänderte Dateien mit 39 neuen und 88 gelöschten Zeilen

Datei anzeigen

@ -1,94 +1,45 @@
From 6b61c540e2b3ce1833af6411ba1627ac98ab08d3 Mon Sep 17 00:00:00 2001
From bfeefa77f4a6e6a10d13927a766fd76a9c492764 Mon Sep 17 00:00:00 2001
From: Zach Brown <zach.brown@destroystokyo.com>
Date: Fri, 22 Apr 2016 18:20:05 -0500
Subject: [PATCH] Vehicle Event Cancellation Changes
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index ae6638d..3e20704 100644
index ae6638d39..0818ff854 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -1803,6 +1803,10 @@ public abstract class Entity implements ICommandListener {
}
}
+ return this.mountEntity(entity, flag, false); // Paper - OBFHELPER
+ }
+
+ public boolean mountEntity(Entity entity, boolean flag, boolean suppressEvents) { // Paper
if (!flag && (!this.n(entity) || !entity.q(this))) {
return false;
} else {
@@ -1811,7 +1815,7 @@ public abstract class Entity implements ICommandListener {
}
this.au = entity;
- this.au.o(this);
+ this.au.addRider(this, suppressEvents); // Paper
return true;
}
}
@@ -1838,12 +1842,20 @@ public abstract class Entity implements ICommandListener {
}
protected void o(Entity entity) {
+ // Paper start - OBFHELPER
+ this.addRider(entity, false);
+ }
+
+ private void addRider(Entity entity, boolean suppressEvents) {
+ // Paper end
if (entity.bB() != this) {
throw new IllegalStateException("Use x.startRiding(y), not y.addPassenger(x)");
@@ -70,7 +70,7 @@ public abstract class Entity implements ICommandListener {
public boolean i;
public final List<Entity> passengers;
protected int j;
- private Entity au;
+ private Entity au;public void setVehicle(Entity entity) { this.au = entity; } // Paper // OBFHELPER
public boolean attachedToPlayer;
public World world;
public double lastX;
@@ -1880,6 +1880,7 @@ public abstract class Entity implements ICommandListener {
throw new IllegalStateException("Use x.stopRiding(y), not y.removePassenger(x)");
} else {
// CraftBukkit start
com.google.common.base.Preconditions.checkState(!entity.passengers.contains(this), "Circular entity riding! %s %s", this, entity);
+ if (!suppressEvents) { // Paper - Make event calls suppressible
+ // =============================================================
+ entity.setVehicle(this); // Paper - Set the vehicle back for the event
CraftEntity craft = (CraftEntity) entity.getBukkitEntity().getVehicle();
Entity orig = craft == null ? null : craft.getHandle();
if (getBukkitEntity() instanceof Vehicle && entity.getBukkitEntity() instanceof LivingEntity && entity.world.isChunkLoaded((int) entity.locX >> 4, (int) entity.locZ >> 4, false)) { // Boolean not used
@@ -1866,6 +1878,8 @@ public abstract class Entity implements ICommandListener {
return;
}
// Spigot end
+ // =============================================================
+ } // Paper - end suppressible block
if (!this.world.isClientSide && entity instanceof EntityHuman && !(this.bw() instanceof EntityHuman)) {
this.passengers.add(0, entity);
} else {
@@ -1891,16 +1905,29 @@ public abstract class Entity implements ICommandListener {
CraftEntity craftn = (CraftEntity) entity.getBukkitEntity().getVehicle();
Entity n = craftn == null ? null : craftn.getHandle();
if (event.isCancelled() || n != orig) {
+ this.cancelDismount(entity); // Paper
return;
if (getBukkitEntity() instanceof Vehicle && entity.getBukkitEntity() instanceof LivingEntity) {
@@ -1895,7 +1896,13 @@ public abstract class Entity implements ICommandListener {
}
}
// CraftBukkit end
- Bukkit.getPluginManager().callEvent( new org.spigotmc.event.entity.EntityDismountEvent(entity.getBukkitEntity(), this.getBukkitEntity())); // Spigot
+ // Paper start - make EntityDismountEvent cancellable
+ if (!new org.spigotmc.event.entity.EntityDismountEvent(entity.getBukkitEntity(), this.getBukkitEntity()).callEvent()) {
+ this.cancelDismount(entity);
+ return;
+ }
+ entity.setVehicle(null);
+ // Paper end
+
this.passengers.remove(entity);
entity.j = 60;
}
}
+ // Paper start
+ private void cancelDismount(Entity dismounter) {
+ this.passengers.remove(dismounter);
+ dismounter.mountEntity(this, false, true);
+ }
+ // Paper end
+
protected boolean q(Entity entity) {
return this.bx().size() < 1;
}
--
2.9.3
2.11.0

Datei anzeigen

@ -1,11 +1,11 @@
From 0c284c4378d5a4660ee4ab4c3b45874d64d4ce58 Mon Sep 17 00:00:00 2001
From c01c75fa73fa69042e41cd421bb744654fb21843 Mon Sep 17 00:00:00 2001
From: Zach Brown <zach.brown@destroystokyo.com>
Date: Sun, 22 May 2016 20:20:55 -0500
Subject: [PATCH] Optional old TNT cannon behaviors
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index 4d6a309..2a4d1da 100644
index 4d6a30966..2a4d1dae7 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -333,4 +333,12 @@ public class PaperWorldConfig {
@ -22,7 +22,7 @@ index 4d6a309..2a4d1da 100644
+ }
}
diff --git a/src/main/java/net/minecraft/server/BlockDiodeAbstract.java b/src/main/java/net/minecraft/server/BlockDiodeAbstract.java
index 59ee13d..40c9f18 100644
index 59ee13de8..40c9f18bf 100644
--- a/src/main/java/net/minecraft/server/BlockDiodeAbstract.java
+++ b/src/main/java/net/minecraft/server/BlockDiodeAbstract.java
@@ -76,6 +76,17 @@ public abstract class BlockDiodeAbstract extends BlockFacingHorizontal {
@ -62,7 +62,7 @@ index 59ee13d..40c9f18 100644
int i = aenumdirection.length;
diff --git a/src/main/java/net/minecraft/server/BlockRedstoneTorch.java b/src/main/java/net/minecraft/server/BlockRedstoneTorch.java
index c7e095a..7412362 100644
index c7e095a11..741236289 100644
--- a/src/main/java/net/minecraft/server/BlockRedstoneTorch.java
+++ b/src/main/java/net/minecraft/server/BlockRedstoneTorch.java
@@ -52,6 +52,12 @@ public class BlockRedstoneTorch extends BlockTorch {
@ -110,7 +110,7 @@ index c7e095a..7412362 100644
return this.isOn && iblockdata.get(BlockRedstoneTorch.FACING) != enumdirection ? 15 : 0;
}
diff --git a/src/main/java/net/minecraft/server/BlockRedstoneWire.java b/src/main/java/net/minecraft/server/BlockRedstoneWire.java
index 5a0f026..20b9465 100644
index 5a0f026b1..20b9465e7 100644
--- a/src/main/java/net/minecraft/server/BlockRedstoneWire.java
+++ b/src/main/java/net/minecraft/server/BlockRedstoneWire.java
@@ -20,7 +20,7 @@ public class BlockRedstoneWire extends Block {
@ -160,7 +160,7 @@ index 5a0f026..20b9465 100644
int i = aenumdirection.length;
diff --git a/src/main/java/net/minecraft/server/BlockTNT.java b/src/main/java/net/minecraft/server/BlockTNT.java
index 6b6aa89..5cec416 100644
index 6b6aa892a..5cec4160c 100644
--- a/src/main/java/net/minecraft/server/BlockTNT.java
+++ b/src/main/java/net/minecraft/server/BlockTNT.java
@@ -29,7 +29,11 @@ public class BlockTNT extends Block {
@ -190,7 +190,7 @@ index 6b6aa89..5cec416 100644
world.addEntity(entitytntprimed);
world.a((EntityHuman) null, entitytntprimed.locX, entitytntprimed.locY, entitytntprimed.locZ, SoundEffects.gV, SoundCategory.BLOCKS, 1.0F, 1.0F);
diff --git a/src/main/java/net/minecraft/server/DispenserRegistry.java b/src/main/java/net/minecraft/server/DispenserRegistry.java
index dbfb8ab..537408a 100644
index dbfb8ab3e..537408a15 100644
--- a/src/main/java/net/minecraft/server/DispenserRegistry.java
+++ b/src/main/java/net/minecraft/server/DispenserRegistry.java
@@ -481,7 +481,11 @@ public class DispenserRegistry {
@ -207,7 +207,7 @@ index dbfb8ab..537408a 100644
world.getServer().getPluginManager().callEvent(event);
}
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 0a6fbf1..768d89d 100644
index 44c5a253f..fc43007c6 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -1041,6 +1041,12 @@ public abstract class Entity implements ICommandListener {
@ -248,7 +248,7 @@ index 0a6fbf1..768d89d 100644
this.motX += d0;
this.motY += d1;
this.motZ += d2;
@@ -2473,6 +2490,12 @@ public abstract class Entity implements ICommandListener {
@@ -2453,6 +2470,12 @@ public abstract class Entity implements ICommandListener {
}
public boolean bg() {
@ -262,7 +262,7 @@ index 0a6fbf1..768d89d 100644
}
diff --git a/src/main/java/net/minecraft/server/EntityFallingBlock.java b/src/main/java/net/minecraft/server/EntityFallingBlock.java
index 307a44c..bb01929 100644
index 307a44c85..bb01929e8 100644
--- a/src/main/java/net/minecraft/server/EntityFallingBlock.java
+++ b/src/main/java/net/minecraft/server/EntityFallingBlock.java
@@ -280,4 +280,19 @@ public class EntityFallingBlock extends Entity {
@ -286,7 +286,7 @@ index 307a44c..bb01929 100644
+ // Paper end
}
diff --git a/src/main/java/net/minecraft/server/EntityTNTPrimed.java b/src/main/java/net/minecraft/server/EntityTNTPrimed.java
index 25e471d..e796ade 100644
index 25e471d37..e796ade87 100644
--- a/src/main/java/net/minecraft/server/EntityTNTPrimed.java
+++ b/src/main/java/net/minecraft/server/EntityTNTPrimed.java
@@ -32,6 +32,7 @@ public class EntityTNTPrimed extends Entity {
@ -366,7 +366,7 @@ index 25e471d..e796ade 100644
+ // Paper end
}
diff --git a/src/main/java/net/minecraft/server/Explosion.java b/src/main/java/net/minecraft/server/Explosion.java
index d7bc6a0..f2785d8 100644
index d7bc6a0ed..f2785d86c 100644
--- a/src/main/java/net/minecraft/server/Explosion.java
+++ b/src/main/java/net/minecraft/server/Explosion.java
@@ -149,9 +149,15 @@ public class Explosion {
@ -389,5 +389,5 @@ index d7bc6a0..f2785d8 100644
EntityHuman entityhuman = (EntityHuman) entity;
--
2.9.3
2.11.0

Datei anzeigen

@ -1,11 +1,11 @@
From 02c7903ebfbe8ab570d4b8bc08d0521aec472a93 Mon Sep 17 00:00:00 2001
From 30addba14e7374eb4107ccfca3dd8a4697766231 Mon Sep 17 00:00:00 2001
From: Zach Brown <zach.brown@destroystokyo.com>
Date: Fri, 16 Dec 2016 22:10:35 -0600
Subject: [PATCH] Vanished players don't have rights
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 5abd80b..272974b 100644
index 5e3f697e6..ea36c53bc 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -68,7 +68,7 @@ public abstract class Entity implements ICommandListener {
@ -16,9 +16,9 @@ index 5abd80b..272974b 100644
+ public boolean i; public boolean blocksEntitySpawning() { return i; } // Paper - OBFHELPER
public final List<Entity> passengers;
protected int j;
private Entity au;
private Entity au;public void setVehicle(Entity entity) { this.au = entity; } // Paper // OBFHELPER
diff --git a/src/main/java/net/minecraft/server/ItemBlock.java b/src/main/java/net/minecraft/server/ItemBlock.java
index eb32871..a380e61 100644
index eb32871bd..a380e615b 100644
--- a/src/main/java/net/minecraft/server/ItemBlock.java
+++ b/src/main/java/net/minecraft/server/ItemBlock.java
@@ -20,7 +20,7 @@ public class ItemBlock extends Item {
@ -31,7 +31,7 @@ index eb32871..a380e61 100644
IBlockData iblockdata1 = this.a.getPlacedState(world, blockposition, enumdirection, f, f1, f2, i, entityhuman);
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index fb346c0..d8c8579 100644
index fb346c0e7..d8c857918 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -1796,6 +1796,33 @@ public abstract class World implements IBlockAccess {
@ -78,7 +78,7 @@ index fb346c0..d8c8579 100644
this.getServer().getPluginManager().callEvent(event);
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
index a7f827b..21a8cc7 100644
index a7f827b67..21a8cc7f0 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -797,6 +797,13 @@ public class CraftEventFactory {
@ -96,5 +96,5 @@ index a7f827b..21a8cc7 100644
return event;
}
--
2.9.3
2.11.0