Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 04:20:04 +01:00
38b3182a90
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: befcf86d SPIGOT-7740: Fix using new map cursor types 09229095 Add EntityDamageEvent.DamageCause#CAMPFIRE CraftBukkit Changes: a1d2cd152 SPIGOT-7747: Mob head is not dropped when mob was blown up by a charged creeper 8078294bc SPIGOT-7746: Server Crashing when Players Getting into End Portals 8d842e250 SPIGOT-7744: Fix exception for shooting projectiles with flame enchantment 64e0ad129 SPIGOT-7744: Fix crash when shooting arrows in creative mode 819f7a10a Fix player items not dropping on death 0a0229bb5 Implement DamageCause#CAMPFIRE and minor improvement in exception for Unhandled block damage
110 Zeilen
6.7 KiB
Diff
110 Zeilen
6.7 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
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/world/entity/projectile/Projectile.java b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
|
|
index a39de724848d6dc796dd99dde5206f20e513fd18..30eb86b52f00cfa61af4f93aca50ffc3547c95e8 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
|
|
@@ -288,6 +288,15 @@ public abstract class Projectile extends Entity implements TraceableEntity {
|
|
} else {
|
|
Entity entity1 = this.getOwner();
|
|
|
|
+ // Paper start - Cancel hit for vanished players
|
|
+ if (entity1 instanceof net.minecraft.server.level.ServerPlayer && entity instanceof net.minecraft.server.level.ServerPlayer) {
|
|
+ org.bukkit.entity.Player collided = (org.bukkit.entity.Player) entity.getBukkitEntity();
|
|
+ org.bukkit.entity.Player shooter = (org.bukkit.entity.Player) entity1.getBukkitEntity();
|
|
+ if (!shooter.canSee(collided)) {
|
|
+ return false;
|
|
+ }
|
|
+ }
|
|
+ // Paper end - Cancel hit for vanished players
|
|
return entity1 == null || this.leftOwner || !entity1.isPassengerOfSameVehicle(entity);
|
|
}
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/item/BlockItem.java b/src/main/java/net/minecraft/world/item/BlockItem.java
|
|
index 6ca74a5cf691ee92c84bd031e875f72440df6b32..cee3f1200af602b5dfd0b27d05eb01826c5bbb1d 100644
|
|
--- a/src/main/java/net/minecraft/world/item/BlockItem.java
|
|
+++ b/src/main/java/net/minecraft/world/item/BlockItem.java
|
|
@@ -174,7 +174,8 @@ public class BlockItem extends Item {
|
|
Player entityhuman = context.getPlayer();
|
|
CollisionContext voxelshapecollision = entityhuman == null ? CollisionContext.empty() : CollisionContext.of(entityhuman);
|
|
// CraftBukkit start - store default return
|
|
- boolean defaultReturn = (!this.mustSurvive() || state.canSurvive(context.getLevel(), context.getClickedPos())) && context.getLevel().isUnobstructed(state, context.getClickedPos(), voxelshapecollision);
|
|
+ Level world = context.getLevel(); // Paper - Cancel hit for vanished players
|
|
+ boolean defaultReturn = (!this.mustSurvive() || state.canSurvive(context.getLevel(), context.getClickedPos())) && world.checkEntityCollision(state, entityhuman, voxelshapecollision, context.getClickedPos(), true); // Paper - Cancel hit for vanished players
|
|
org.bukkit.entity.Player player = (context.getPlayer() instanceof ServerPlayer) ? (org.bukkit.entity.Player) context.getPlayer().getBukkitEntity() : null;
|
|
|
|
BlockCanBuildEvent event = new BlockCanBuildEvent(CraftBlock.at(context.getLevel(), context.getClickedPos()), player, CraftBlockData.fromData(state), defaultReturn);
|
|
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
|
index 16c244f56813479b2e51f1d883ff739949fc86e3..c0b0a9328faf93b85ceaf6cc9989f1a59520c7f4 100644
|
|
--- a/src/main/java/net/minecraft/world/level/Level.java
|
|
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
|
@@ -265,6 +265,45 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
|
this.tileLimiter = new org.spigotmc.TickLimiter(this.spigotConfig.tileMaxTickTime);
|
|
}
|
|
|
|
+ // Paper start - Cancel hit for vanished players
|
|
+ // ret true if no collision
|
|
+ public final boolean checkEntityCollision(BlockState data, Entity source, net.minecraft.world.phys.shapes.CollisionContext voxelshapedcollision,
|
|
+ BlockPos position, boolean checkCanSee) {
|
|
+ // Copied from IWorldReader#a(IBlockData, BlockPosition, VoxelShapeCollision) & EntityAccess#a(Entity, VoxelShape)
|
|
+ net.minecraft.world.phys.shapes.VoxelShape voxelshape = data.getCollisionShape(this, position, voxelshapedcollision);
|
|
+ if (voxelshape.isEmpty()) {
|
|
+ return true;
|
|
+ }
|
|
+
|
|
+ voxelshape = voxelshape.move((double) position.getX(), (double) position.getY(), (double) position.getZ());
|
|
+ if (voxelshape.isEmpty()) {
|
|
+ return true;
|
|
+ }
|
|
+
|
|
+ List<Entity> entities = this.getEntities(null, voxelshape.bounds());
|
|
+ for (int i = 0, len = entities.size(); i < len; ++i) {
|
|
+ Entity entity = entities.get(i);
|
|
+
|
|
+ if (checkCanSee && source instanceof net.minecraft.server.level.ServerPlayer && entity instanceof net.minecraft.server.level.ServerPlayer
|
|
+ && !((net.minecraft.server.level.ServerPlayer) source).getBukkitEntity().canSee(((net.minecraft.server.level.ServerPlayer) entity).getBukkitEntity())) {
|
|
+ continue;
|
|
+ }
|
|
+
|
|
+ // !entity1.dead && entity1.i && (entity == null || !entity1.x(entity));
|
|
+ // elide the last check since vanilla calls with entity = null
|
|
+ // only we care about the source for the canSee check
|
|
+ if (entity.isRemoved() || !entity.blocksBuilding) {
|
|
+ continue;
|
|
+ }
|
|
+
|
|
+ if (net.minecraft.world.phys.shapes.Shapes.joinIsNotEmpty(voxelshape, net.minecraft.world.phys.shapes.Shapes.create(entity.getBoundingBox()), net.minecraft.world.phys.shapes.BooleanOp.AND)) {
|
|
+ return false;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ return true;
|
|
+ }
|
|
+ // Paper end - Cancel hit for vanished players
|
|
@Override
|
|
public boolean isClientSide() {
|
|
return this.isClientSide;
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
index 8d86649579cb7eb90e3866ed81f2ba4f342f8b1c..635982e7c9bb650f72a987e2f866d6f91b75efcf 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
@@ -1301,6 +1301,14 @@ public class CraftEventFactory {
|
|
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;
|
|
}
|