2019-06-14 02:27:40 +00:00
|
|
|
From f2b1eae290b09ed2df91f723cc70c581adf93a44 Mon Sep 17 00:00:00 2001
|
2019-04-30 22:51:03 +00:00
|
|
|
From: Hugo Manrique <hugmanrique@gmail.com>
|
|
|
|
Date: Mon, 23 Jul 2018 14:22:26 +0200
|
|
|
|
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
|
2019-06-06 15:36:57 +00:00
|
|
|
index 291a8029ed..fe9881fdf2 100644
|
2019-04-30 22:51:03 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
2019-05-06 02:58:04 +00:00
|
|
|
@@ -97,7 +97,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
2019-04-30 22:51:03 +00:00
|
|
|
private static double e = 1.0D;
|
|
|
|
private final EntityTypes<?> f;
|
|
|
|
private int id;
|
|
|
|
- public boolean i;
|
|
|
|
+ public boolean i; public final boolean blocksEntitySpawning() { return this.i; } // Paper - OBFHELPER
|
|
|
|
public final List<Entity> passengers;
|
|
|
|
protected int j;
|
|
|
|
private Entity vehicle;
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/IEntityAccess.java b/src/main/java/net/minecraft/server/IEntityAccess.java
|
2019-06-06 15:36:57 +00:00
|
|
|
index ee22bb0387..e5a013ffd2 100644
|
2019-04-30 22:51:03 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/IEntityAccess.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/IEntityAccess.java
|
|
|
|
@@ -22,9 +22,18 @@ public interface IEntityAccess {
|
|
|
|
return this.getEntities(entity, axisalignedbb, IEntitySelector.f);
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Paper start
|
|
|
|
default boolean a(@Nullable Entity entity, VoxelShape voxelshape) {
|
|
|
|
+ return this.checkEntityCollision(entity, voxelshape, false);
|
|
|
|
+ }
|
|
|
|
+ default boolean checkEntityCollision(Entity entity, VoxelShape voxelshape, boolean checkCanSee) {
|
|
|
|
return voxelshape.isEmpty() ? true : this.getEntities(entity, voxelshape.getBoundingBox()).stream().filter((entity1) -> {
|
|
|
|
+ if (entity instanceof EntityPlayer && entity1 instanceof EntityPlayer
|
|
|
|
+ && !((EntityPlayer)entity).getBukkitEntity().canSee(((EntityPlayer)entity1).getBukkitEntity())) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
return !entity1.dead && entity1.i && (entity == null || !entity1.x(entity));
|
|
|
|
+ // Paper end
|
|
|
|
}).noneMatch((entity1) -> {
|
|
|
|
return VoxelShapes.c(voxelshape, VoxelShapes.a(entity1.getBoundingBox()), OperatorBoolean.AND);
|
|
|
|
});
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/IWorldReader.java b/src/main/java/net/minecraft/server/IWorldReader.java
|
2019-06-06 15:36:57 +00:00
|
|
|
index 7308c0c319..ed3f793f20 100644
|
2019-04-30 22:51:03 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/IWorldReader.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/IWorldReader.java
|
2019-05-27 06:14:14 +00:00
|
|
|
@@ -84,7 +84,12 @@ public interface IWorldReader extends IIBlockAccess {
|
2019-04-30 22:51:03 +00:00
|
|
|
return ChunkStatus.EMPTY;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Paper start
|
|
|
|
default boolean a(IBlockData iblockdata, BlockPosition blockposition, VoxelShapeCollision voxelshapecollision) {
|
|
|
|
+ return this.checkEntityCollision(iblockdata, blockposition, voxelshapecollision, false);
|
|
|
|
+ }
|
|
|
|
+ default boolean checkEntityCollision(IBlockData iblockdata, BlockPosition blockposition, VoxelShapeCollision voxelshapecollision, boolean checkCanSee) {
|
|
|
|
+ // Paper end
|
|
|
|
VoxelShape voxelshape = iblockdata.b((IBlockAccess) this, blockposition, voxelshapecollision);
|
|
|
|
|
|
|
|
return voxelshape.isEmpty() || this.a((Entity) null, voxelshape.a((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ()));
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/ItemBlock.java b/src/main/java/net/minecraft/server/ItemBlock.java
|
2019-06-06 15:36:57 +00:00
|
|
|
index 59b1e6ce2e..b90cc6652b 100644
|
2019-04-30 22:51:03 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/ItemBlock.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/ItemBlock.java
|
|
|
|
@@ -126,7 +126,8 @@ public class ItemBlock extends Item {
|
|
|
|
EntityHuman entityhuman = blockactioncontext.getEntity();
|
|
|
|
VoxelShapeCollision voxelshapecollision = entityhuman == null ? VoxelShapeCollision.a() : VoxelShapeCollision.a((Entity) entityhuman);
|
|
|
|
// CraftBukkit start - store default return
|
|
|
|
- boolean defaultReturn = (!this.d() || iblockdata.canPlace(blockactioncontext.getWorld(), blockactioncontext.getClickPosition())) && blockactioncontext.getWorld().a(iblockdata, blockactioncontext.getClickPosition(), voxelshapecollision);
|
|
|
|
+ final World world = blockactioncontext.getWorld(); // Paper
|
|
|
|
+ boolean defaultReturn = (!this.d() || iblockdata.canPlace(world, blockactioncontext.getClickPosition())) && world.checkEntityCollision(iblockdata, blockactioncontext.getClickPosition(), voxelshapecollision, true); // Paper
|
|
|
|
org.bukkit.entity.Player player = (blockactioncontext.getEntity() instanceof EntityPlayer) ? (org.bukkit.entity.Player) blockactioncontext.getEntity().getBukkitEntity() : null;
|
|
|
|
|
|
|
|
BlockCanBuildEvent event = new BlockCanBuildEvent(CraftBlock.at(blockactioncontext.getWorld(), blockactioncontext.getClickPosition()), player, CraftBlockData.fromData(iblockdata), defaultReturn);
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
2019-06-06 15:36:57 +00:00
|
|
|
index 309cbd0dc6..78baaf6253 100644
|
2019-04-30 22:51:03 +00:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
2019-05-27 10:57:28 +00:00
|
|
|
@@ -1136,6 +1136,14 @@ public class CraftEventFactory {
|
2019-04-30 22:51:03 +00:00
|
|
|
Projectile projectile = (Projectile) entity.getBukkitEntity();
|
|
|
|
org.bukkit.entity.Entity collided = position.getEntity().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);
|
|
|
|
+ return event;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
Bukkit.getPluginManager().callEvent(event);
|
|
|
|
return event;
|
|
|
|
}
|
|
|
|
--
|
|
|
|
2.21.0
|
|
|
|
|