geforkt von Mirrors/Paper
ab347c4c96
Upstream has released updates that appears 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: 42d5a714 SPIGOT-5899: Hoglins API similar to Piglins 2c1ee10e SPIGOT-5887: ClickType doesn't include off hand swaps 5ff7c7ce SPIGOT-5886: Missing BlockData CraftBukkit Changes:7560f5f5
SPIGOT-5905: Fix hex colours not being allowed in MOTDd47c47ee
SPIGOT-5889: Villager using composter should call EntityChangeBlockEvent2fe6b4a3
SPIGOT-5899: Hoglins API similar to Piglinse09dbeca
SPIGOT-5887: ClickType doesn't include off hand swaps23aac2a5
SPIGOT-5903: EntityDismountEvent cannot be triggered asynchronously92cbf656
SPIGOT-5884: Tab completions lost on reloadData / minecraft:reloadfb4e54ad
SPIGOT-5902: PlayerRespawnEvent places player at spawn before event is calledaa8f3d5a
SPIGOT-5901: Structures are generated in all worlds based on the setting for the main worlda0c35937
SPIGOT-5895: PlayerChangedWorldEvent#getFrom is incorrect89c0a5c3
SPIGOT-5886: Missing BlockData Spigot Changes: 0287a20d SPIGOT-5903: EntityDismountEvent cannot be triggered asynchronously
180 Zeilen
11 KiB
Diff
180 Zeilen
11 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/server/BlockBase.java b/src/main/java/net/minecraft/server/BlockBase.java
|
|
index 26d446077bb563ca3c5bb0339695b3364a3e41bf..88a1db211286fc8a6164312d7eb0839c00969e0e 100644
|
|
--- a/src/main/java/net/minecraft/server/BlockBase.java
|
|
+++ b/src/main/java/net/minecraft/server/BlockBase.java
|
|
@@ -453,6 +453,7 @@ public abstract class BlockBase {
|
|
return this.a != null ? this.a.b : this.b(iblockaccess, blockposition, VoxelShapeCollision.a());
|
|
}
|
|
|
|
+ public final VoxelShape getCollisionShape(IBlockAccess iblockaccess, BlockPosition blockposition, VoxelShapeCollision voxelshapecollision) { return this.b(iblockaccess, blockposition, voxelshapecollision); } // Paper - OBFHELPER
|
|
public VoxelShape b(IBlockAccess iblockaccess, BlockPosition blockposition, VoxelShapeCollision voxelshapecollision) {
|
|
return this.getBlock().c(this.p(), iblockaccess, blockposition, voxelshapecollision);
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
|
index 8e128fa303b345a10535630fd58442435ef1e439..af6f0c391e6e410f0bf4e4e6ddf6fd18bb4d26ed 100644
|
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
|
@@ -98,7 +98,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
|
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;
|
|
@Nullable
|
|
diff --git a/src/main/java/net/minecraft/server/EntityFireworks.java b/src/main/java/net/minecraft/server/EntityFireworks.java
|
|
index 5ac7957016d1ca6bc78ced0bcf3767d358677f45..ca92579304d060e2b718aab6f3e3f006d52f93e5 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityFireworks.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityFireworks.java
|
|
@@ -118,7 +118,6 @@ public class EntityFireworks extends IProjectile {
|
|
this.move(EnumMoveType.SELF, vec3d);
|
|
this.setMot(vec3d);
|
|
}
|
|
-
|
|
MovingObjectPosition movingobjectposition = ProjectileHelper.a(this, this::a, RayTrace.BlockCollisionOption.COLLIDER);
|
|
|
|
if (!this.noclip) {
|
|
diff --git a/src/main/java/net/minecraft/server/IProjectile.java b/src/main/java/net/minecraft/server/IProjectile.java
|
|
index cdf80e50de0840002f62f4c1df4fbcc4e13675d7..ea5f5845a8d202e62da3ae1bfb1e4dbd7f5e185e 100644
|
|
--- a/src/main/java/net/minecraft/server/IProjectile.java
|
|
+++ b/src/main/java/net/minecraft/server/IProjectile.java
|
|
@@ -129,8 +129,14 @@ public abstract class IProjectile extends Entity {
|
|
protected boolean a(Entity entity) {
|
|
if (!entity.isSpectator() && entity.isAlive() && entity.isInteractable()) {
|
|
Entity entity1 = this.getShooter();
|
|
-
|
|
+ // Paper start - Cancel hit for vanished players
|
|
+ if (entity1 instanceof EntityPlayer && entity instanceof EntityPlayer) {
|
|
+ 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;
|
|
+ }
|
|
return entity1 == null || this.d || !entity1.isSameVehicle(entity);
|
|
+ // Paper end
|
|
} else {
|
|
return false;
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/ItemBlock.java b/src/main/java/net/minecraft/server/ItemBlock.java
|
|
index 6c7f677f68d89d7e08c07a0f24268c5a638b4076..33d38a9a8a55c7a26d9a584e8058f42556b6ed59 100644
|
|
--- a/src/main/java/net/minecraft/server/ItemBlock.java
|
|
+++ b/src/main/java/net/minecraft/server/ItemBlock.java
|
|
@@ -139,7 +139,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.isCheckCollisions() || iblockdata.canPlace(blockactioncontext.getWorld(), blockactioncontext.getClickPosition())) && blockactioncontext.getWorld().a(iblockdata, blockactioncontext.getClickPosition(), voxelshapecollision);
|
|
+ World world = blockactioncontext.getWorld(); // Paper
|
|
+ boolean defaultReturn = (!this.isCheckCollisions() || iblockdata.canPlace(blockactioncontext.getWorld(), blockactioncontext.getClickPosition())) && world.checkEntityCollision(iblockdata, entityhuman, voxelshapecollision, blockactioncontext.getClickPosition(), 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/net/minecraft/server/VoxelShape.java b/src/main/java/net/minecraft/server/VoxelShape.java
|
|
index e985b0efc20f7d271be1c7ffc2670ab89fc3a6a7..c2b8c9820663f95f58f0c3a62cd9ec99c835a82f 100644
|
|
--- a/src/main/java/net/minecraft/server/VoxelShape.java
|
|
+++ b/src/main/java/net/minecraft/server/VoxelShape.java
|
|
@@ -46,6 +46,7 @@ public abstract class VoxelShape {
|
|
return this.a.a();
|
|
}
|
|
|
|
+ public final VoxelShape offset(double x, double y, double z) { return this.a(x, y, z); } // Paper - OBFHELPER
|
|
public VoxelShape a(double d0, double d1, double d2) {
|
|
return (VoxelShape) (this.isEmpty() ? VoxelShapes.a() : new VoxelShapeArray(this.a, new DoubleListOffset(this.a(EnumDirection.EnumAxis.X), d0), new DoubleListOffset(this.a(EnumDirection.EnumAxis.Y), d1), new DoubleListOffset(this.a(EnumDirection.EnumAxis.Z), d2)));
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/VoxelShapes.java b/src/main/java/net/minecraft/server/VoxelShapes.java
|
|
index 86f6f082fe2991ea9065b09c9680b76ca1cf7154..b6e2a3d8d0cf510f497c6f974356fafaf2adc13b 100644
|
|
--- a/src/main/java/net/minecraft/server/VoxelShapes.java
|
|
+++ b/src/main/java/net/minecraft/server/VoxelShapes.java
|
|
@@ -35,6 +35,7 @@ public final class VoxelShapes {
|
|
return a(new AxisAlignedBB(d0, d1, d2, d3, d4, d5));
|
|
}
|
|
|
|
+ public static final VoxelShape of(AxisAlignedBB axisAlignedbb) { return VoxelShapes.a(axisAlignedbb); } // Paper - OBFHELPER
|
|
public static VoxelShape a(AxisAlignedBB axisalignedbb) {
|
|
int i = a(axisalignedbb.minX, axisalignedbb.maxX);
|
|
int j = a(axisalignedbb.minY, axisalignedbb.maxY);
|
|
@@ -129,6 +130,7 @@ public final class VoxelShapes {
|
|
}
|
|
}
|
|
|
|
+ public static final boolean applyOperation(VoxelShape voxelshape, VoxelShape voxelshape1, OperatorBoolean operatorboolean) { return VoxelShapes.c(voxelshape, voxelshape1, operatorboolean); } // Paper - OBFHELPER
|
|
public static boolean c(VoxelShape voxelshape, VoxelShape voxelshape1, OperatorBoolean operatorboolean) {
|
|
if (operatorboolean.apply(false, false)) {
|
|
throw (IllegalArgumentException) SystemUtils.c(new IllegalArgumentException());
|
|
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
|
index 2e19fbddb6ede4abf02c79b4e72d11f89db05433..ca3e831e3191dd8ffe7f2b6ab9ecc05acfe1b0af 100644
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
|
@@ -172,6 +172,46 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
|
|
this.tileLimiter = new org.spigotmc.TickLimiter(spigotConfig.tileMaxTickTime);
|
|
}
|
|
|
|
+ // Paper start
|
|
+ // ret true if no collision
|
|
+ public final boolean checkEntityCollision(IBlockData data, Entity source, VoxelShapeCollision voxelshapedcollision,
|
|
+ BlockPosition position, boolean checkCanSee) {
|
|
+ // Copied from IWorldReader#a(IBlockData, BlockPosition, VoxelShapeCollision) & EntityAccess#a(Entity, VoxelShape)
|
|
+ VoxelShape voxelshape = data.getCollisionShape(this, position, voxelshapedcollision);
|
|
+ if (voxelshape.isEmpty()) {
|
|
+ return true;
|
|
+ }
|
|
+
|
|
+ voxelshape = voxelshape.offset((double) position.getX(), (double) position.getY(), (double) position.getZ());
|
|
+ if (voxelshape.isEmpty()) {
|
|
+ return true;
|
|
+ }
|
|
+
|
|
+ List<Entity> entities = this.getEntities(null, voxelshape.getBoundingBox());
|
|
+ for (int i = 0, len = entities.size(); i < len; ++i) {
|
|
+ Entity entity = entities.get(i);
|
|
+
|
|
+ if (checkCanSee && source instanceof EntityPlayer && entity instanceof EntityPlayer
|
|
+ && !((EntityPlayer) source).getBukkitEntity().canSee(((EntityPlayer) 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.dead || !entity.blocksEntitySpawning()) {
|
|
+ continue;
|
|
+ }
|
|
+
|
|
+ if (VoxelShapes.applyOperation(voxelshape, VoxelShapes.of(entity.getBoundingBox()), OperatorBoolean.AND)) {
|
|
+ return false;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ return true;
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
@Override
|
|
public boolean s_() {
|
|
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 bed1d3f460be8af3378d0ab1d8ff53c0885021f9..bfa9fd738159d2517c2ec16323a856c5850c0534 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
@@ -1193,6 +1193,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;
|
|
}
|