Paper/Spigot-Server-Patches/0004-Vanished-players-don-t-have-rights.patch
2015-03-09 16:02:50 -05:00

79 lines
4.3 KiB
Diff

From 8ae819d36ca20264aec0d137ea473e856b5ca8e3 Mon Sep 17 00:00:00 2001
From: Zach Brown <zach.brown@destroystokyo.com>
Date: Sat, 7 Mar 2015 19:50:01 -0600
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 46f6374..6aa8cad 100644
--- a/src/main/java/net/minecraft/server/EntityArrow.java
+++ b/src/main/java/net/minecraft/server/EntityArrow.java
@@ -220,6 +220,14 @@ public class EntityArrow extends Entity implements IProjectile {
float f2;
float f3;
+ // PaperSpigot 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;
+ }
+ }
+ // PaperSpigot end
+
if (movingobjectposition != null) {
org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this); // CraftBukkit - Call event
if (movingobjectposition.entity != null) {
diff --git a/src/main/java/net/minecraft/server/EntityProjectile.java b/src/main/java/net/minecraft/server/EntityProjectile.java
index d4e5971..fbcb6ac 100644
--- a/src/main/java/net/minecraft/server/EntityProjectile.java
+++ b/src/main/java/net/minecraft/server/EntityProjectile.java
@@ -147,6 +147,14 @@ public abstract class EntityProjectile extends Entity implements IProjectile {
}
}
+ // PaperSpigot 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;
+ }
+ }
+ // PaperSpigot end
+
if (movingobjectposition != null) {
if (movingobjectposition.type == MovingObjectPosition.EnumMovingObjectType.BLOCK && this.world.getType(movingobjectposition.a()).getBlock() == Blocks.PORTAL) {
this.d(movingobjectposition.a());
diff --git a/src/main/java/net/minecraft/server/ItemBlock.java b/src/main/java/net/minecraft/server/ItemBlock.java
index 451a0bb..24601c7 100644
--- a/src/main/java/net/minecraft/server/ItemBlock.java
+++ b/src/main/java/net/minecraft/server/ItemBlock.java
@@ -25,7 +25,7 @@ public class ItemBlock extends Item {
return false;
} else if (!entityhuman.a(blockposition, enumdirection, itemstack)) {
return false;
- } else if (world.a(this.a, blockposition, false, enumdirection, (Entity) null, itemstack)) {
+ } else if (world.a(this.a, blockposition, false, enumdirection, entityhuman, itemstack)) { // PaperSpigot - Pass entityhuman instead of null
int i = this.filterData(itemstack.getData());
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 eb1efce..79f3a35 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -1668,6 +1668,13 @@ public abstract class World implements IBlockAccess {
for (int i = 0; i < list.size(); ++i) {
Entity entity1 = (Entity) list.get(i);
+ // PaperSpigot start - Allow block placement if the placer cannot see the vanished blocker
+ if (entity instanceof EntityPlayer && entity1 instanceof EntityPlayer) {
+ if (!((EntityPlayer) entity).getBukkitEntity().canSee(((EntityPlayer) entity1).getBukkitEntity())) {
+ continue;
+ }
+ }
+
if (!entity1.dead && entity1.k && entity1 != entity && (entity == null || entity.vehicle != entity1 && entity.passenger != entity1)) {
return false;
}
--
1.9.1