Add Player Collision API. Thanks to @lazertester and @mrapple for the implementation.
This commit is contained in:
parent
f9c6a78ef4
commit
5eb704605d
41
Bukkit-Patches/0016-Player-Collision-API.patch
Normal file
41
Bukkit-Patches/0016-Player-Collision-API.patch
Normal file
@ -0,0 +1,41 @@
|
||||
From 36b0eed14a6230d0e47ac5484186ce568ae60490 Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <md_5@live.com.au>
|
||||
Date: Sat, 3 Aug 2013 19:20:50 +1000
|
||||
Subject: [PATCH] Player Collision API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
|
||||
index a809f18..fb21501 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Player.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Player.java
|
||||
@@ -725,6 +725,27 @@ public interface Player extends HumanEntity, Conversable, CommandSender, Offline
|
||||
{
|
||||
throw new UnsupportedOperationException( "Not supported yet." );
|
||||
}
|
||||
+
|
||||
+ /**
|
||||
+ * Gets whether the player collides with entities
|
||||
+ *
|
||||
+ * @return the player's collision toggle state
|
||||
+ */
|
||||
+ public boolean getCollidesWithEntities()
|
||||
+ {
|
||||
+ throw new UnsupportedOperationException( "Not supported yet." );
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets whether the player collides with entities
|
||||
+ *
|
||||
+ * @param collides whether the player should collide with entities or
|
||||
+ * not.
|
||||
+ */
|
||||
+ public void setCollidesWithEntities(boolean collides)
|
||||
+ {
|
||||
+ throw new UnsupportedOperationException( "Not supported yet." );
|
||||
+ }
|
||||
}
|
||||
|
||||
Spigot spigot();
|
||||
--
|
||||
1.8.1.2
|
||||
|
84
CraftBukkit-Patches/0024-Player-Collision-API.patch
Normal file
84
CraftBukkit-Patches/0024-Player-Collision-API.patch
Normal file
@ -0,0 +1,84 @@
|
||||
From 1bd195c36f5a4405afa8667244b0b0d871de5d10 Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <md_5@live.com.au>
|
||||
Date: Sat, 3 Aug 2013 19:27:07 +1000
|
||||
Subject: [PATCH] Player Collision API
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
|
||||
index e1a3ca1..6770e04 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityHuman.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
|
||||
@@ -410,7 +410,7 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen
|
||||
|
||||
List list = this.world.getEntities(this, axisalignedbb);
|
||||
|
||||
- if (list != null) {
|
||||
+ if (list != null && this.L()) { // Spigot: Add this.L() condition
|
||||
for (int i = 0; i < list.size(); ++i) {
|
||||
Entity entity = (Entity) list.get(i);
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
|
||||
index 6b8b8dd..34683a5 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
||||
@@ -1462,7 +1462,7 @@ public abstract class EntityLiving extends Entity {
|
||||
protected void bi() {
|
||||
List list = this.world.getEntities(this, this.boundingBox.grow(0.20000000298023224D, 0.0D, 0.20000000298023224D));
|
||||
|
||||
- if (list != null && !list.isEmpty()) {
|
||||
+ if (this.L() && list != null && !list.isEmpty()) { // Spigot: Add this.L() condition
|
||||
for (int i = 0; i < list.size(); ++i) {
|
||||
Entity entity = (Entity) list.get(i);
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
|
||||
index 58e5217..6d2e765 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
|
||||
@@ -53,6 +53,21 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
||||
public boolean keepLevel = false;
|
||||
public double maxHealthCache;
|
||||
// CraftBukkit end
|
||||
+ // Spigot start
|
||||
+ public boolean collidesWithEntities = true;
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean L()
|
||||
+ {
|
||||
+ return this.collidesWithEntities && super.L();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean K()
|
||||
+ {
|
||||
+ return this.collidesWithEntities && super.K();
|
||||
+ }
|
||||
+ // Spigot end
|
||||
|
||||
public EntityPlayer(MinecraftServer minecraftserver, World world, String s, PlayerInteractManager playerinteractmanager) {
|
||||
super(world, s);
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
index 6e9834f..b858b3d 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -1077,6 +1077,18 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
// Spigot start
|
||||
private final Spigot spigot = new Spigot()
|
||||
{
|
||||
+ @Override
|
||||
+ public boolean getCollidesWithEntities()
|
||||
+ {
|
||||
+ return getHandle().collidesWithEntities;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setCollidesWithEntities(boolean collides)
|
||||
+ {
|
||||
+ getHandle().collidesWithEntities = collides;
|
||||
+ getHandle().m = collides; // First boolean of Entity
|
||||
+ }
|
||||
};
|
||||
|
||||
public Spigot spigot()
|
||||
--
|
||||
1.8.1.2
|
||||
|
Loading…
Reference in New Issue
Block a user