Add ProjectileCollideEvent
Base our vanish changes on top of that event.
This commit is contained in:
75
Spigot-API-Patches/Add-ProjectileCollideEvent.patch
Normal file
75
Spigot-API-Patches/Add-ProjectileCollideEvent.patch
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Techcable <Techcable@outlook.com>
|
||||||
|
Date: Fri, 16 Dec 2016 21:25:39 -0600
|
||||||
|
Subject: [PATCH] Add ProjectileCollideEvent
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/ProjectileCollideEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/ProjectileCollideEvent.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/com/destroystokyo/paper/event/entity/ProjectileCollideEvent.java
|
||||||
|
@@ -0,0 +0,0 @@
|
||||||
|
+package com.destroystokyo.paper.event.entity;
|
||||||
|
+
|
||||||
|
+import org.bukkit.entity.Entity;
|
||||||
|
+import org.bukkit.entity.Projectile;
|
||||||
|
+import org.bukkit.event.Cancellable;
|
||||||
|
+import org.bukkit.event.HandlerList;
|
||||||
|
+import org.bukkit.event.entity.EntityEvent;
|
||||||
|
+
|
||||||
|
+/**
|
||||||
|
+ * Called when an projectile collides with an entity
|
||||||
|
+ * <p>
|
||||||
|
+ * This event is called <b>before</b> {@link org.bukkit.event.entity.EntityDamageByEntityEvent}, and cancelling it will allow the projectile to continue flying
|
||||||
|
+ */
|
||||||
|
+public class ProjectileCollideEvent extends EntityEvent implements Cancellable {
|
||||||
|
+ private final Entity collidedWith;
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Get the entity the projectile collided with
|
||||||
|
+ *
|
||||||
|
+ * @return the entity collided with
|
||||||
|
+ */
|
||||||
|
+ public Entity getCollidedWith() {
|
||||||
|
+ return collidedWith;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public ProjectileCollideEvent(Projectile what, Entity collidedWith) {
|
||||||
|
+ super(what);
|
||||||
|
+ this.collidedWith = collidedWith;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Get the projectile that collided
|
||||||
|
+ *
|
||||||
|
+ * @return the projectile that collided
|
||||||
|
+ */
|
||||||
|
+ public Projectile getEntity() {
|
||||||
|
+ return (Projectile) super.getEntity();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static final HandlerList handlerList = new HandlerList();
|
||||||
|
+
|
||||||
|
+ public static HandlerList getHandlerList() {
|
||||||
|
+ return handlerList;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public HandlerList getHandlers() {
|
||||||
|
+ return handlerList;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private boolean cancelled = false;
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public boolean isCancelled() {
|
||||||
|
+ return cancelled;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public void setCancelled(boolean cancel) {
|
||||||
|
+ this.cancelled = cancel;
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
--
|
||||||
109
Spigot-Server-Patches/Add-ProjectileCollideEvent.patch
Normal file
109
Spigot-Server-Patches/Add-ProjectileCollideEvent.patch
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Techcable <Techcable@outlook.com>
|
||||||
|
Date: Fri, 16 Dec 2016 21:25:39 -0600
|
||||||
|
Subject: [PATCH] Add ProjectileCollideEvent
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/EntityArrow.java b/src/main/java/net/minecraft/server/EntityArrow.java
|
||||||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/EntityArrow.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/EntityArrow.java
|
||||||
|
@@ -0,0 +0,0 @@ public abstract class EntityArrow extends Entity implements IProjectile {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Paper start - Call ProjectileCollideEvent
|
||||||
|
+ if (movingobjectposition != null && movingobjectposition.entity != null) {
|
||||||
|
+ com.destroystokyo.paper.event.entity.ProjectileCollideEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileCollideEvent(this, movingobjectposition);
|
||||||
|
+ if (event.isCancelled()) {
|
||||||
|
+ movingobjectposition = null;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ // Paper end
|
||||||
|
+
|
||||||
|
if (movingobjectposition != null) {
|
||||||
|
this.a(movingobjectposition);
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/EntityFireball.java b/src/main/java/net/minecraft/server/EntityFireball.java
|
||||||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/EntityFireball.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/EntityFireball.java
|
||||||
|
@@ -0,0 +0,0 @@ public abstract class EntityFireball extends Entity {
|
||||||
|
++this.f;
|
||||||
|
MovingObjectPosition movingobjectposition = ProjectileHelper.a(this, true, this.f >= 25, this.shooter);
|
||||||
|
|
||||||
|
+ // Paper start - Call ProjectileCollideEvent
|
||||||
|
+ if (movingobjectposition != null && movingobjectposition.entity != null) {
|
||||||
|
+ com.destroystokyo.paper.event.entity.ProjectileCollideEvent event = CraftEventFactory.callProjectileCollideEvent(this, movingobjectposition);
|
||||||
|
+ if (event.isCancelled()) {
|
||||||
|
+ movingobjectposition = null;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ // Paper end
|
||||||
|
+
|
||||||
|
if (movingobjectposition != null) {
|
||||||
|
this.a(movingobjectposition);
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/EntityFishingHook.java b/src/main/java/net/minecraft/server/EntityFishingHook.java
|
||||||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/EntityFishingHook.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/EntityFishingHook.java
|
||||||
|
@@ -0,0 +0,0 @@ public class EntityFishingHook extends Entity {
|
||||||
|
|
||||||
|
vec3d = new Vec3D(this.locX, this.locY, this.locZ);
|
||||||
|
vec3d1 = new Vec3D(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ);
|
||||||
|
+
|
||||||
|
+ // Paper start - Call ProjectileCollideEvent
|
||||||
|
+ if (movingobjectposition != null && movingobjectposition.entity != null) {
|
||||||
|
+ com.destroystokyo.paper.event.entity.ProjectileCollideEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileCollideEvent(this, movingobjectposition);
|
||||||
|
+ if (event.isCancelled()) {
|
||||||
|
+ movingobjectposition = null;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ // Paper end
|
||||||
|
+
|
||||||
|
if (movingobjectposition != null) {
|
||||||
|
vec3d1 = new Vec3D(movingobjectposition.pos.x, movingobjectposition.pos.y, movingobjectposition.pos.z);
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/EntityProjectile.java b/src/main/java/net/minecraft/server/EntityProjectile.java
|
||||||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/EntityProjectile.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/EntityProjectile.java
|
||||||
|
@@ -0,0 +0,0 @@ public abstract class EntityProjectile extends Entity implements IProjectile {
|
||||||
|
movingobjectposition = new MovingObjectPosition(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Paper start - Call ProjectileCollideEvent
|
||||||
|
+ if (movingobjectposition != null && movingobjectposition.entity != null) {
|
||||||
|
+ com.destroystokyo.paper.event.entity.ProjectileCollideEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileCollideEvent(this, movingobjectposition);
|
||||||
|
+ if (event.isCancelled()) {
|
||||||
|
+ movingobjectposition = null;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ // Paper end
|
||||||
|
+
|
||||||
|
if (movingobjectposition != null) {
|
||||||
|
if (movingobjectposition.type == MovingObjectPosition.EnumMovingObjectType.BLOCK && this.world.getType(movingobjectposition.a()).getBlock() == Blocks.PORTAL) {
|
||||||
|
this.e(movingobjectposition.a());
|
||||||
|
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||||
|
@@ -0,0 +0,0 @@ public class CraftEventFactory {
|
||||||
|
return CraftItemStack.asNMSCopy(bitem);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Paper start
|
||||||
|
+ public static com.destroystokyo.paper.event.entity.ProjectileCollideEvent callProjectileCollideEvent(Entity entity, MovingObjectPosition position) {
|
||||||
|
+ Projectile projectile = (Projectile) entity.getBukkitEntity();
|
||||||
|
+ org.bukkit.entity.Entity collided = position.entity.getBukkitEntity();
|
||||||
|
+ com.destroystokyo.paper.event.entity.ProjectileCollideEvent event = new com.destroystokyo.paper.event.entity.ProjectileCollideEvent(projectile, collided);
|
||||||
|
+ Bukkit.getPluginManager().callEvent(event);
|
||||||
|
+ return event;
|
||||||
|
+ }
|
||||||
|
+ // Paper end
|
||||||
|
+
|
||||||
|
public static ProjectileLaunchEvent callProjectileLaunchEvent(Entity entity) {
|
||||||
|
Projectile bukkitEntity = (Projectile) entity.getBukkitEntity();
|
||||||
|
ProjectileLaunchEvent event = new ProjectileLaunchEvent(bukkitEntity);
|
||||||
|
--
|
||||||
@@ -5,7 +5,7 @@ Subject: [PATCH] Configurable lava flow speed
|
|||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||||
index 2ec50685c..b5a106d5b 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||||
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||||
@@ -0,0 +0,0 @@ public class PaperWorldConfig {
|
@@ -0,0 +0,0 @@ public class PaperWorldConfig {
|
||||||
@@ -21,7 +21,7 @@ index 2ec50685c..b5a106d5b 100644
|
|||||||
+ }
|
+ }
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/net/minecraft/server/BlockFlowing.java b/src/main/java/net/minecraft/server/BlockFlowing.java
|
diff --git a/src/main/java/net/minecraft/server/BlockFlowing.java b/src/main/java/net/minecraft/server/BlockFlowing.java
|
||||||
index 8e9de3bcb..765a37160 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/server/BlockFlowing.java
|
--- a/src/main/java/net/minecraft/server/BlockFlowing.java
|
||||||
+++ b/src/main/java/net/minecraft/server/BlockFlowing.java
|
+++ b/src/main/java/net/minecraft/server/BlockFlowing.java
|
||||||
@@ -0,0 +0,0 @@ public class BlockFlowing extends BlockFluids {
|
@@ -0,0 +0,0 @@ public class BlockFlowing extends BlockFluids {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ Subject: [PATCH] Configurable speed for water flowing over lava
|
|||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||||
index d44fdaea6..06d152762 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||||
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||||
@@ -0,0 +0,0 @@ public class PaperWorldConfig {
|
@@ -0,0 +0,0 @@ public class PaperWorldConfig {
|
||||||
@@ -20,7 +20,7 @@ index d44fdaea6..06d152762 100644
|
|||||||
+ }
|
+ }
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/net/minecraft/server/BlockFlowing.java b/src/main/java/net/minecraft/server/BlockFlowing.java
|
diff --git a/src/main/java/net/minecraft/server/BlockFlowing.java b/src/main/java/net/minecraft/server/BlockFlowing.java
|
||||||
index c9294a58d..f4ac7bafa 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/server/BlockFlowing.java
|
--- a/src/main/java/net/minecraft/server/BlockFlowing.java
|
||||||
+++ b/src/main/java/net/minecraft/server/BlockFlowing.java
|
+++ b/src/main/java/net/minecraft/server/BlockFlowing.java
|
||||||
@@ -0,0 +0,0 @@ public class BlockFlowing extends BlockFluids {
|
@@ -0,0 +0,0 @@ public class BlockFlowing extends BlockFluids {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ Subject: [PATCH] Fast draining
|
|||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||||
index 356265e91..2ec50685c 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||||
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||||
@@ -0,0 +0,0 @@ public class PaperWorldConfig {
|
@@ -0,0 +0,0 @@ public class PaperWorldConfig {
|
||||||
@@ -21,7 +21,7 @@ index 356265e91..2ec50685c 100644
|
|||||||
+ }
|
+ }
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/net/minecraft/server/BlockFlowing.java b/src/main/java/net/minecraft/server/BlockFlowing.java
|
diff --git a/src/main/java/net/minecraft/server/BlockFlowing.java b/src/main/java/net/minecraft/server/BlockFlowing.java
|
||||||
index 801b9cb7b..8e9de3bcb 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/server/BlockFlowing.java
|
--- a/src/main/java/net/minecraft/server/BlockFlowing.java
|
||||||
+++ b/src/main/java/net/minecraft/server/BlockFlowing.java
|
+++ b/src/main/java/net/minecraft/server/BlockFlowing.java
|
||||||
@@ -0,0 +0,0 @@ public class BlockFlowing extends BlockFluids {
|
@@ -0,0 +0,0 @@ public class BlockFlowing extends BlockFluids {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ Subject: [PATCH] Stop updating flowing block if material has changed
|
|||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/BlockFlowing.java b/src/main/java/net/minecraft/server/BlockFlowing.java
|
diff --git a/src/main/java/net/minecraft/server/BlockFlowing.java b/src/main/java/net/minecraft/server/BlockFlowing.java
|
||||||
index f4ac7bafa..801b9cb7b 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/server/BlockFlowing.java
|
--- a/src/main/java/net/minecraft/server/BlockFlowing.java
|
||||||
+++ b/src/main/java/net/minecraft/server/BlockFlowing.java
|
+++ b/src/main/java/net/minecraft/server/BlockFlowing.java
|
||||||
@@ -0,0 +0,0 @@ public class BlockFlowing extends BlockFluids {
|
@@ -0,0 +0,0 @@ public class BlockFlowing extends BlockFluids {
|
||||||
|
|||||||
@@ -1,67 +1,9 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
From: Zach Brown <1254957+zachbr@users.noreply.github.com>
|
From: Zach Brown <1254957+zachbr@users.noreply.github.com>
|
||||||
Date: Mon, 29 Feb 2016 21:20:21 -0600
|
Date: Fri, 16 Dec 2016 22:10:35 -0600
|
||||||
Subject: [PATCH] Vanished players don't have rights
|
Subject: [PATCH] Vanished players don't have rights
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/EntityArrow.java b/src/main/java/net/minecraft/server/EntityArrow.java
|
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
||||||
--- a/src/main/java/net/minecraft/server/EntityArrow.java
|
|
||||||
+++ b/src/main/java/net/minecraft/server/EntityArrow.java
|
|
||||||
@@ -0,0 +0,0 @@ public abstract class EntityArrow extends Entity implements IProjectile {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
+ // Paper start - Allow arrows to fly through vanished players the shooter can't see
|
|
||||||
+ if (movingobjectposition != null && movingobjectposition.entity instanceof EntityPlayer && shooter != null && shooter instanceof EntityPlayer) {
|
|
||||||
+ if (!((EntityPlayer) shooter).getBukkitEntity().canSee(((EntityPlayer) movingobjectposition.entity).getBukkitEntity())) {
|
|
||||||
+ movingobjectposition = null;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ // Paper end
|
|
||||||
+
|
|
||||||
if (movingobjectposition != null) {
|
|
||||||
this.a(movingobjectposition);
|
|
||||||
}
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/EntityFishingHook.java b/src/main/java/net/minecraft/server/EntityFishingHook.java
|
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
||||||
--- a/src/main/java/net/minecraft/server/EntityFishingHook.java
|
|
||||||
+++ b/src/main/java/net/minecraft/server/EntityFishingHook.java
|
|
||||||
@@ -0,0 +0,0 @@ public class EntityFishingHook extends Entity {
|
|
||||||
|
|
||||||
vec3d = new Vec3D(this.locX, this.locY, this.locZ);
|
|
||||||
vec3d1 = new Vec3D(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ);
|
|
||||||
+
|
|
||||||
+ // Paper start - Allow fishing hooks to fly through vanished players the shooter can't see
|
|
||||||
+ if (movingobjectposition != null && movingobjectposition.entity instanceof EntityPlayer && owner != null && owner instanceof EntityPlayer) {
|
|
||||||
+ if (!((EntityPlayer) owner).getBukkitEntity().canSee(((EntityPlayer) movingobjectposition.entity).getBukkitEntity())) {
|
|
||||||
+ movingobjectposition = null;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ // Paper end
|
|
||||||
+
|
|
||||||
if (movingobjectposition != null) {
|
|
||||||
vec3d1 = new Vec3D(movingobjectposition.pos.x, movingobjectposition.pos.y, movingobjectposition.pos.z);
|
|
||||||
}
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/EntityProjectile.java b/src/main/java/net/minecraft/server/EntityProjectile.java
|
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
||||||
--- a/src/main/java/net/minecraft/server/EntityProjectile.java
|
|
||||||
+++ b/src/main/java/net/minecraft/server/EntityProjectile.java
|
|
||||||
@@ -0,0 +0,0 @@ public abstract class EntityProjectile extends Entity implements IProjectile {
|
|
||||||
movingobjectposition = new MovingObjectPosition(entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
+ // Paper start - Allow projectiles to fly through vanished players the shooter can't see
|
|
||||||
+ if (movingobjectposition != null && movingobjectposition.entity instanceof EntityPlayer && shooter != null && shooter instanceof EntityPlayer) {
|
|
||||||
+ if (!((EntityPlayer) shooter).getBukkitEntity().canSee(((EntityPlayer) movingobjectposition.entity).getBukkitEntity())) {
|
|
||||||
+ movingobjectposition = null;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ // Paper end
|
|
||||||
+
|
|
||||||
if (movingobjectposition != null) {
|
|
||||||
if (movingobjectposition.type == MovingObjectPosition.EnumMovingObjectType.BLOCK && this.world.getType(movingobjectposition.a()).getBlock() == Blocks.PORTAL) {
|
|
||||||
this.e(movingobjectposition.a());
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/ItemBlock.java b/src/main/java/net/minecraft/server/ItemBlock.java
|
diff --git a/src/main/java/net/minecraft/server/ItemBlock.java b/src/main/java/net/minecraft/server/ItemBlock.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/server/ItemBlock.java
|
--- a/src/main/java/net/minecraft/server/ItemBlock.java
|
||||||
@@ -71,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
ItemStack itemstack = entityhuman.b(enumhand);
|
ItemStack itemstack = entityhuman.b(enumhand);
|
||||||
|
|
||||||
- if (!itemstack.isEmpty() && entityhuman.a(blockposition, enumdirection, itemstack) && world.a(this.a, blockposition, false, enumdirection, (Entity) null)) {
|
- if (!itemstack.isEmpty() && entityhuman.a(blockposition, enumdirection, itemstack) && world.a(this.a, blockposition, false, enumdirection, (Entity) null)) {
|
||||||
+ if (!itemstack.isEmpty() && entityhuman.a(blockposition, enumdirection, itemstack) && world.a(this.a, blockposition, false, enumdirection, entityhuman)) { // Paper - Pass entityhuman instead of null
|
+ if (!itemstack.isEmpty() && entityhuman.a(blockposition, enumdirection, itemstack) && world.a(this.a, blockposition, false, enumdirection, entityhuman)) { // Paper - Pass entityhuman instead of null
|
||||||
int i = this.filterData(itemstack.getData());
|
int i = this.filterData(itemstack.getData());
|
||||||
IBlockData iblockdata1 = this.a.getPlacedState(world, blockposition, enumdirection, f, f1, f2, i, entityhuman);
|
IBlockData iblockdata1 = this.a.getPlacedState(world, blockposition, enumdirection, f, f1, f2, i, entityhuman);
|
||||||
|
|
||||||
@@ -80,18 +22,64 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
--- a/src/main/java/net/minecraft/server/World.java
|
--- a/src/main/java/net/minecraft/server/World.java
|
||||||
+++ b/src/main/java/net/minecraft/server/World.java
|
+++ b/src/main/java/net/minecraft/server/World.java
|
||||||
@@ -0,0 +0,0 @@ public abstract class World implements IBlockAccess {
|
@@ -0,0 +0,0 @@ public abstract class World implements IBlockAccess {
|
||||||
for (int i = 0; i < list.size(); ++i) {
|
return this.a(axisalignedbb, (Entity) null);
|
||||||
Entity entity1 = (Entity) list.get(i);
|
}
|
||||||
|
|
||||||
+ // Paper start - Allow block placement if the placer cannot see the vanished blocker
|
+ // Paper start - Based on method below
|
||||||
|
+ /**
|
||||||
|
+ * @param axisalignedbb area to search within
|
||||||
|
+ * @param entity causing the action ex. block placer
|
||||||
|
+ * @return if there are no visible players colliding
|
||||||
|
+ */
|
||||||
|
+ public boolean checkNoVisiblePlayerCollisions(AxisAlignedBB axisalignedbb, @Nullable Entity entity) {
|
||||||
|
+ List list = this.getEntities((Entity) null, axisalignedbb);
|
||||||
|
+
|
||||||
|
+ for (int i = 0; i < list.size(); ++i) {
|
||||||
|
+ Entity entity1 = (Entity) list.get(i);
|
||||||
|
+
|
||||||
+ if (entity instanceof EntityPlayer && entity1 instanceof EntityPlayer) {
|
+ if (entity instanceof EntityPlayer && entity1 instanceof EntityPlayer) {
|
||||||
+ if (!((EntityPlayer) entity).getBukkitEntity().canSee(((EntityPlayer) entity1).getBukkitEntity())) {
|
+ if (!((EntityPlayer) entity).getBukkitEntity().canSee(((EntityPlayer) entity1).getBukkitEntity())) {
|
||||||
+ continue;
|
+ continue;
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end
|
|
||||||
+
|
+
|
||||||
if (!entity1.dead && entity1.i && entity1 != entity && (entity == null || entity1.x(entity))) {
|
+ if (!entity1.dead && entity1.i) {
|
||||||
return false;
|
+ return false;
|
||||||
}
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+ // Paper end
|
||||||
|
+
|
||||||
|
public boolean a(AxisAlignedBB axisalignedbb, @Nullable Entity entity) {
|
||||||
|
List list = this.getEntities((Entity) null, axisalignedbb);
|
||||||
|
|
||||||
|
@@ -0,0 +0,0 @@ public abstract class World implements IBlockAccess {
|
||||||
|
AxisAlignedBB axisalignedbb = flag ? null : block.getBlockData().c(this, blockposition);
|
||||||
|
|
||||||
|
// CraftBukkit start - store default return
|
||||||
|
- boolean defaultReturn = axisalignedbb != Block.k && !this.a(axisalignedbb.a(blockposition), entity) ? false : (iblockdata.getMaterial() == Material.ORIENTABLE && block == Blocks.ANVIL ? true : iblockdata.getMaterial().isReplaceable() && block.canPlace(this, blockposition, enumdirection));
|
||||||
|
+ boolean defaultReturn = axisalignedbb != Block.k && !this.checkNoVisiblePlayerCollisions(axisalignedbb.a(blockposition), entity) ? false : (iblockdata.getMaterial() == Material.ORIENTABLE && block == Blocks.ANVIL ? true : iblockdata.getMaterial().isReplaceable() && block.canPlace(this, blockposition, enumdirection)); // Paper - Use our entity search
|
||||||
|
BlockCanBuildEvent event = new BlockCanBuildEvent(this.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), CraftMagicNumbers.getId(block), defaultReturn);
|
||||||
|
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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||||
|
@@ -0,0 +0,0 @@ public class CraftEventFactory {
|
||||||
|
Projectile projectile = (Projectile) entity.getBukkitEntity();
|
||||||
|
org.bukkit.entity.Entity collided = position.entity.getBukkitEntity();
|
||||||
|
com.destroystokyo.paper.event.entity.ProjectileCollideEvent event = new com.destroystokyo.paper.event.entity.ProjectileCollideEvent(projectile, collided);
|
||||||
|
+
|
||||||
|
+ if (projectile.getShooter() instanceof Player && collided instanceof Player) {
|
||||||
|
+ if (!((Player) projectile.getShooter()).canSee((Player) collided)) {
|
||||||
|
+ event.setCancelled(true);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
return event;
|
||||||
|
}
|
||||||
--
|
--
|
||||||
Reference in New Issue
Block a user