mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-15 14:13:56 +01:00
Support all projectiles in the invisible players patch
also cleans up the code a bit
This commit is contained in:
parent
5a1fd5b46c
commit
3081e4c401
1 changed files with 27 additions and 27 deletions
|
@ -1,30 +1,21 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Zach Brown <1254957+zachbr@users.noreply.github.com>
|
||||
Date: Sun, 18 May 2014 16:35:38 -0500
|
||||
Date: Mon, 21 Jul 2014 18:46:53 -0500
|
||||
Subject: [PATCH] Invisible players don't have rights
|
||||
|
||||
Adapted from CraftBukkit PR #1319 https://github.com/Bukkit/CraftBukkit/pull/1319
|
||||
|
||||
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 @@ package net.minecraft.server;
|
||||
import java.util.List;
|
||||
|
||||
// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.entity.CraftPlayer; // PaperSpigot
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.entity.EntityCombustByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
@@ -0,0 +0,0 @@ public class EntityArrow extends Entity implements IProjectile {
|
||||
float f2;
|
||||
float f3;
|
||||
|
||||
+ // PaperSpigot start - Allow projectiles and arrows to pass through players the shooter can't see
|
||||
+ if(movingobjectposition != null && movingobjectposition.entity instanceof EntityPlayer && shooter != null && shooter instanceof EntityPlayer) {
|
||||
+ CraftPlayer playerBlocking = ((EntityPlayer) movingobjectposition.entity).getBukkitEntity();
|
||||
+ CraftPlayer playerShooter = ((EntityPlayer)shooter).getBukkitEntity();
|
||||
+ if(!playerShooter.canSee(playerBlocking)) {
|
||||
+ // PaperSpigot start - Allow arrows to fly through players
|
||||
+ if (movingobjectposition != null && movingobjectposition.entity instanceof EntityPlayer && shooter != null && shooter instanceof EntityPlayer) {
|
||||
+ if (!((EntityPlayer) shooter).getBukkitEntity().canSee(((EntityPlayer) movingobjectposition.entity).getBukkitEntity())) {
|
||||
+ movingobjectposition = null;
|
||||
+ }
|
||||
+ }
|
||||
|
@ -33,27 +24,36 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
if (movingobjectposition != null) {
|
||||
org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this); // CraftBukkit - Call event
|
||||
|
||||
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 {
|
||||
}
|
||||
}
|
||||
|
||||
+ // PaperSpigot start - Allow projectiles to fly through 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 == EnumMovingObjectType.BLOCK && this.world.getType(movingobjectposition.b, movingobjectposition.c, movingobjectposition.d) == Blocks.PORTAL) {
|
||||
this.ah();
|
||||
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/server/World.java
|
||||
+++ b/src/main/java/net/minecraft/server/World.java
|
||||
@@ -0,0 +0,0 @@ import java.util.concurrent.Callable;
|
||||
// CraftBukkit start
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.block.BlockState;
|
||||
+import org.bukkit.craftbukkit.entity.CraftPlayer; // PaperSpigot
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
import org.bukkit.craftbukkit.util.LongHashSet;
|
||||
import org.bukkit.craftbukkit.SpigotTimings; // Spigot
|
||||
@@ -0,0 +0,0 @@ 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 when the player can't see an invisible player
|
||||
+ if (entity != null && entity instanceof EntityPlayer && entity1 != null && entity1 instanceof EntityPlayer) {
|
||||
+ CraftPlayer placer = ((EntityPlayer)entity).getBukkitEntity();
|
||||
+ CraftPlayer blocking = ((EntityPlayer)entity1).getBukkitEntity();
|
||||
+ if(!placer.canSee(blocking)) {
|
||||
+ // PaperSpigot start - Allow block placement if the placer cannot see the blocker
|
||||
+ if (entity instanceof EntityPlayer && entity1 instanceof EntityPlayer) {
|
||||
+ if (!((EntityPlayer) entity).getBukkitEntity().canSee(((EntityPlayer) entity1).getBukkitEntity())) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ }
|
||||
|
|
Loading…
Reference in a new issue