mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-01 17:01:56 +01:00
More 1.14 patches
This commit is contained in:
parent
86e7cee50c
commit
be2fdf029f
9 changed files with 179 additions and 242 deletions
|
@ -9,7 +9,7 @@ This should hopefully avoid duplicate entities ever being created
|
|||
if the entity was to end up in 2 different chunk slices
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
||||
index 5d187e5d7d..01abe5e376 100644
|
||||
index 8b6a52d72..0c8a2ac90 100644
|
||||
--- a/src/main/java/net/minecraft/server/Chunk.java
|
||||
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
||||
@@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess {
|
||||
|
@ -39,13 +39,13 @@ index 5d187e5d7d..01abe5e376 100644
|
|||
if (!entity.inChunk || entity.getCurrentChunk() != this) entityCounts.increment(entity.getMinecraftKeyString()); // Paper
|
||||
entity.inChunk = true;
|
||||
@@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess {
|
||||
entity.chunkZ = this.locZ;
|
||||
entity.chunkY = k;
|
||||
entity.chunkZ = this.loc.z;
|
||||
this.entitySlices[k].add(entity);
|
||||
// Paper start
|
||||
+ entity.entitySlice = this.entitySlices[k]; // Paper
|
||||
this.markDirty();
|
||||
if (entity instanceof EntityItem) {
|
||||
itemCounts[k]++;
|
||||
this.markDirty(); // Paper
|
||||
}
|
||||
|
||||
@@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess {
|
||||
}
|
||||
// Paper start
|
||||
|
@ -57,7 +57,7 @@ index 5d187e5d7d..01abe5e376 100644
|
|||
return;
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
||||
index 539273afbc..ead5af991c 100644
|
||||
index 57a4481c5..4648a93b0 100644
|
||||
--- a/src/main/java/net/minecraft/server/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/server/Entity.java
|
||||
@@ -0,0 +0,0 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Sat, 28 Jul 2018 12:09:20 -0400
|
||||
Subject: [PATCH] Always process chunk removal in removeEntity
|
||||
|
||||
Spigot might skip chunk registration changes in removeEntity
|
||||
which can keep them in the chunk when they shouldnt be if done
|
||||
during entity ticking.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
||||
index 1929e9d2ae..1cbe6e17b7 100644
|
||||
--- a/src/main/java/net/minecraft/server/World.java
|
||||
+++ b/src/main/java/net/minecraft/server/World.java
|
||||
@@ -0,0 +0,0 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
||||
this.everyoneSleeping();
|
||||
}
|
||||
|
||||
- if (!guardEntityList) { // Spigot - It will get removed after the tick if we are ticking
|
||||
+ // if (!guardEntityList) { // Spigot - It will get removed after the tick if we are ticking // Paper - move down
|
||||
int i = entity.chunkX;
|
||||
int j = entity.chunkZ;
|
||||
|
||||
Chunk chunk = entity.getCurrentChunk(); // Paper
|
||||
if (chunk != null) chunk.removeEntity(entity); // Paper
|
||||
|
||||
+ if (!guardEntityList) { // Spigot - It will get removed after the tick if we are ticking // Paper - always remove from current chunk above
|
||||
// CraftBukkit start - Decrement loop variable field if we've already ticked this entity
|
||||
int index = this.entityList.indexOf(entity);
|
||||
if (index != -1) {
|
||||
--
|
|
@ -11,7 +11,7 @@ Returns true if getDamage() == 0 or has damage tag or other tag is set.
|
|||
Check the `ItemMetaTest#testTaggedButNotMeta` method to see how this method behaves.
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
|
||||
index bc8fb28163..ca9399bdbe 100644
|
||||
index 1a7849767..2f872b640 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
|
||||
@@ -0,0 +0,0 @@ public final class CraftItemStack extends ItemStack {
|
||||
|
@ -24,17 +24,17 @@ index bc8fb28163..ca9399bdbe 100644
|
|||
|
||||
static boolean hasItemMeta(net.minecraft.server.ItemStack item) {
|
||||
diff --git a/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java b/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java
|
||||
index d4f4508cce..3a2793f322 100644
|
||||
index 93c4e1239..2c9481042 100644
|
||||
--- a/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java
|
||||
+++ b/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java
|
||||
@@ -0,0 +0,0 @@ import static org.hamcrest.Matchers.*;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
+import java.util.Collections; // Paper
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.destroystokyo.paper.inventory.meta.ArmorStandMeta; // Paper
|
||||
@@ -0,0 +0,0 @@ public class ItemMetaTest extends AbstractTestingBase {
|
||||
|
||||
assertThat("noTag and enchanted stacks should not be similar", noTag.isSimilar(enchanted), is(false));
|
||||
|
|
|
@ -5,31 +5,31 @@ Subject: [PATCH] EntityTransformedEvent
|
|||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityMushroomCow.java b/src/main/java/net/minecraft/server/EntityMushroomCow.java
|
||||
index 141c17bf80..dde9f1e61e 100644
|
||||
index 55048af34..ed990ddef 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityMushroomCow.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityMushroomCow.java
|
||||
@@ -0,0 +0,0 @@ public class EntityMushroomCow extends EntityCow {
|
||||
if (CraftEventFactory.callEntityTransformEvent(this, entitycow, EntityTransformEvent.TransformReason.SHEARED).isCancelled()) {
|
||||
return false;
|
||||
}
|
||||
+ if (!new com.destroystokyo.paper.event.entity.EntityTransformedEvent(this.getBukkitEntity(), entitycow.getBukkitEntity(), com.destroystokyo.paper.event.entity.EntityTransformedEvent.TransformedReason.SHEARED).callEvent()) return false; // Paper
|
||||
this.world.addEntity(entitycow, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SHEARED);
|
||||
if (CraftEventFactory.callEntityTransformEvent(this, entitycow, EntityTransformEvent.TransformReason.SHEARED).isCancelled()) {
|
||||
return false;
|
||||
}
|
||||
+ if (!new com.destroystokyo.paper.event.entity.EntityTransformedEvent(this.getBukkitEntity(), entitycow.getBukkitEntity(), com.destroystokyo.paper.event.entity.EntityTransformedEvent.TransformedReason.SHEARED).callEvent()) return false; // Paper
|
||||
this.world.addEntity(entitycow, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SHEARED);
|
||||
|
||||
this.die(); // CraftBukkit - from above
|
||||
this.die(); // CraftBukkit - from above
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityVillager.java b/src/main/java/net/minecraft/server/EntityVillager.java
|
||||
index 78acac4ca7..f01e776fe5 100644
|
||||
index bc04086d7..d489a5a8c 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityVillager.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityVillager.java
|
||||
@@ -0,0 +0,0 @@ public class EntityVillager extends EntityAgeable implements NPC, IMerchant {
|
||||
if (CraftEventFactory.callEntityTransformEvent(this, entitywitch, EntityTransformEvent.TransformReason.LIGHTNING).isCancelled()) {
|
||||
return;
|
||||
}
|
||||
+ if (!new com.destroystokyo.paper.event.entity.EntityTransformedEvent(this.getBukkitEntity(), entitywitch.getBukkitEntity(), com.destroystokyo.paper.event.entity.EntityTransformedEvent.TransformedReason.LIGHTNING).callEvent()) return; // Paper
|
||||
this.world.addEntity(entitywitch, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING);
|
||||
// CraftBukkit end
|
||||
this.die();
|
||||
@@ -0,0 +0,0 @@ public class EntityVillager extends EntityVillagerAbstract implements Reputation
|
||||
if (CraftEventFactory.callEntityTransformEvent(this, entitywitch, EntityTransformEvent.TransformReason.LIGHTNING).isCancelled()) {
|
||||
return;
|
||||
}
|
||||
+ if (!new com.destroystokyo.paper.event.entity.EntityTransformedEvent(this.getBukkitEntity(), entitywitch.getBukkitEntity(), com.destroystokyo.paper.event.entity.EntityTransformedEvent.TransformedReason.LIGHTNING).callEvent()) return; // Paper
|
||||
this.world.addEntity(entitywitch, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING);
|
||||
// CraftBukkit end
|
||||
this.die();
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityZombie.java b/src/main/java/net/minecraft/server/EntityZombie.java
|
||||
index 7a943a6c27..7998b80c17 100644
|
||||
index d9d993860..92d1cd851 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityZombie.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityZombie.java
|
||||
@@ -0,0 +0,0 @@ public class EntityZombie extends EntityMonster {
|
||||
|
@ -45,19 +45,19 @@ index 7a943a6c27..7998b80c17 100644
|
|||
return;
|
||||
}
|
||||
+ if (!new com.destroystokyo.paper.event.entity.EntityTransformedEvent(this.getBukkitEntity(), entityvillager.getBukkitEntity(), com.destroystokyo.paper.event.entity.EntityTransformedEvent.TransformedReason.INFECTED).callEvent()) return; // Paper
|
||||
this.world.kill(entityvillager); // CraftBukkit - from above
|
||||
entityvillager.die(); // CraftBukkit - from above
|
||||
this.world.addEntity(entityzombievillager, CreatureSpawnEvent.SpawnReason.INFECTION); // CraftBukkit - add SpawnReason
|
||||
// CraftBukkit end
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityZombieVillager.java b/src/main/java/net/minecraft/server/EntityZombieVillager.java
|
||||
index 670e38eb8e..359ac8b88c 100644
|
||||
index 042afd269..d7205a57e 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityZombieVillager.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityZombieVillager.java
|
||||
@@ -0,0 +0,0 @@ public class EntityZombieVillager extends EntityZombie {
|
||||
@@ -0,0 +0,0 @@ public class EntityZombieVillager extends EntityZombie implements VillagerDataHo
|
||||
if (CraftEventFactory.callEntityTransformEvent(this, entityvillager, EntityTransformEvent.TransformReason.CURED).isCancelled()) {
|
||||
return;
|
||||
}
|
||||
+ if (!new com.destroystokyo.paper.event.entity.EntityTransformedEvent(this.getBukkitEntity(), entityvillager.getBukkitEntity(), com.destroystokyo.paper.event.entity.EntityTransformedEvent.TransformedReason.CURED).callEvent()) return; // Paper
|
||||
this.world.kill(this); // CraftBukkit - from above
|
||||
this.world.addEntity(entityvillager, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CURED); // CraftBukkit - add SpawnReason
|
||||
this.die(); // CraftBukkit - from above
|
||||
worldserver.addEntity(entityvillager, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CURED); // CraftBukkit - add SpawnReason
|
||||
// CraftBukkit end
|
||||
--
|
|
@ -6,23 +6,23 @@ Subject: [PATCH] Mark chunk dirty anytime entities change to guarantee it
|
|||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
||||
index e8c06e01b4..5d187e5d7d 100644
|
||||
index 54bb7f551..8b6a52d72 100644
|
||||
--- a/src/main/java/net/minecraft/server/Chunk.java
|
||||
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
||||
@@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess {
|
||||
entity.chunkZ = this.locZ;
|
||||
entity.chunkY = k;
|
||||
entity.chunkZ = this.loc.z;
|
||||
this.entitySlices[k].add(entity);
|
||||
// Paper start
|
||||
+ this.markDirty();
|
||||
if (entity instanceof EntityItem) {
|
||||
itemCounts[k]++;
|
||||
} else if (entity instanceof IInventory) {
|
||||
+ this.markDirty(); // Paper
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess {
|
||||
if (!this.entitySlices[i].remove(entity)) {
|
||||
return;
|
||||
}
|
||||
+ this.markDirty();
|
||||
if (entity instanceof EntityItem) {
|
||||
itemCounts[i]--;
|
||||
} else if (entity instanceof IInventory) {
|
||||
entityCounts.decrement(entity.getMinecraftKeyString());
|
||||
+ this.markDirty(); // Paper
|
||||
// Paper end
|
||||
}
|
||||
|
||||
--
|
|
@ -1,65 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Mon, 23 Jul 2018 23:40:04 -0400
|
||||
Subject: [PATCH] Optimize Region File Cache
|
||||
|
||||
CraftBukkit added synchronization to read and write methods. This adds
|
||||
much more contention on this object for accessing region files, as
|
||||
the entire read and write of NBT data is now a blocking operation.
|
||||
|
||||
This causes issues when something then simply needs to check if a chunk exists
|
||||
on the main thread, causing a block...
|
||||
|
||||
However, this synchronization was unnecessary, because there is already
|
||||
enough synchronization done to keep things safe
|
||||
|
||||
1) Obtaining a Region File: Those methods are still static synchronized.
|
||||
Meaning we can safely obtain a Region File concurrently.
|
||||
|
||||
2) RegionFile data access: Methods reading and manipulating data from
|
||||
a region file are also marked synchronized, ensuring that no 2 processes
|
||||
are reading or writing data at the same time.
|
||||
|
||||
3) Checking a region file for chunkExists: getOffset is also synchronized
|
||||
ensuring that even if a chunk is currently being written, it will be safe.
|
||||
|
||||
By removing these synchronizations, we reduce the locking to only
|
||||
when data is being write or read.
|
||||
|
||||
GZIP compression and NBT Buffer creation will no longer be part of the
|
||||
synchronized context, reducing lock times.
|
||||
|
||||
Ultimately: This brings us back to Vanilla, which has had no indication of region file loss.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/RegionFileCache.java b/src/main/java/net/minecraft/server/RegionFileCache.java
|
||||
index 964996976a..d072222390 100644
|
||||
--- a/src/main/java/net/minecraft/server/RegionFileCache.java
|
||||
+++ b/src/main/java/net/minecraft/server/RegionFileCache.java
|
||||
@@ -0,0 +0,0 @@ public class RegionFileCache {
|
||||
|
||||
@Nullable
|
||||
// CraftBukkit start - call sites hoisted for synchronization
|
||||
- public static synchronized NBTTagCompound read(File file, int i, int j) throws IOException {
|
||||
+ public static NBTTagCompound read(File file, int i, int j) throws IOException { // Paper - remove synchronization
|
||||
RegionFile regionfile = a(file, i, j);
|
||||
|
||||
DataInputStream datainputstream = regionfile.a(i & 31, j & 31);
|
||||
@@ -0,0 +0,0 @@ public class RegionFileCache {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
- public static synchronized void write(File file, int i, int j, NBTTagCompound nbttagcompound) throws IOException {
|
||||
+ public static void write(File file, int i, int j, NBTTagCompound nbttagcompound) throws IOException {
|
||||
int attempts = 0; Exception laste = null; while (attempts++ < 5) { try { // Paper
|
||||
RegionFile regionfile = a(file, i, j);
|
||||
|
||||
@@ -0,0 +0,0 @@ public class RegionFileCache {
|
||||
// Paper end
|
||||
}
|
||||
|
||||
- public static synchronized boolean chunkExists(File file, int i, int j) {
|
||||
+ public static boolean chunkExists(File file, int i, int j) { // Paper - remove synchronization
|
||||
RegionFile regionfile = b(file, i, j);
|
||||
|
||||
return regionfile != null ? regionfile.d(i & 31, j & 31) : false;
|
||||
--
|
|
@ -18,42 +18,46 @@ an invalid entity.
|
|||
This should reduce log occurrences of dupe uuid messages.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
|
||||
index 2c4a4fc6b7..485bce9872 100644
|
||||
index 0fed039f3..2e9686b43 100644
|
||||
--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
|
||||
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
|
||||
@@ -0,0 +0,0 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
|
||||
|
||||
Iterator iterator;
|
||||
@@ -0,0 +0,0 @@ public class ChunkRegionLoader {
|
||||
NBTTagCompound nbttagcompound4;
|
||||
Iterator iterator1;
|
||||
|
||||
+ java.util.List<Entity> toUpdate = new java.util.ArrayList<>(); // Paper
|
||||
for (int j = 0; j < chunk.getEntitySlices().length; ++j) {
|
||||
iterator = chunk.getEntitySlices()[j].iterator();
|
||||
if (ichunkaccess.getChunkStatus().getType() == ChunkStatus.Type.LEVELCHUNK) {
|
||||
Chunk chunk = (Chunk) ichunkaccess;
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
Entity entity = (Entity) iterator.next();
|
||||
+ // Paper start
|
||||
+ if ((int)Math.floor(entity.locX) >> 4 != chunk.locX || (int)Math.floor(entity.locZ) >> 4 != chunk.locZ) {
|
||||
+ LogManager.getLogger().warn(entity + " is not in this chunk, skipping save. This a bug fix to a vanilla bug. Do not report this to PaperMC please.");
|
||||
+ toUpdate.add(entity);
|
||||
+ continue;
|
||||
+ }
|
||||
+ if (entity.dead) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ // Paper end
|
||||
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
||||
@@ -0,0 +0,0 @@ public class ChunkRegionLoader {
|
||||
|
||||
if (entity.d(nbttagcompound1)) {
|
||||
@@ -0,0 +0,0 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
|
||||
while (iterator2.hasNext()) {
|
||||
Entity entity = (Entity) iterator2.next();
|
||||
+ // Paper start
|
||||
+ if ((int)Math.floor(entity.locX) >> 4 != chunk.getPos().x || (int)Math.floor(entity.locZ) >> 4 != chunk.getPos().z) {
|
||||
+ LogManager.getLogger().warn(entity + " is not in this chunk, skipping save. This a bug fix to a vanilla bug. Do not report this to PaperMC please.");
|
||||
+ toUpdate.add(entity);
|
||||
+ continue;
|
||||
+ }
|
||||
+ if (entity.dead) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
nbttagcompound4 = new NBTTagCompound();
|
||||
if (entity.d(nbttagcompound4)) {
|
||||
@@ -0,0 +0,0 @@ public class ChunkRegionLoader {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+ // Paper start - move entities to the correct chunk
|
||||
+ for (Entity entity : toUpdate) {
|
||||
+ world.entityJoinedWorld(entity, false);
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
+ // Paper start - move entities to the correct chunk
|
||||
+ for (Entity entity : toUpdate) {
|
||||
+ ((WorldServer)world).entityJoinedWorld(entity);
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
} else {
|
||||
ProtoChunk protochunk = (ProtoChunk) ichunkaccess;
|
||||
|
||||
nbttagcompound.set("Entities", nbttaglist1);
|
||||
NBTTagList nbttaglist2 = new NBTTagList();
|
||||
--
|
|
@ -5,45 +5,45 @@ Subject: [PATCH] SkeletonHorse Additions
|
|||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityHorseSkeleton.java b/src/main/java/net/minecraft/server/EntityHorseSkeleton.java
|
||||
index 06f37f28af..eae2b26655 100644
|
||||
index 9ac34dfa8..b96726456 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityHorseSkeleton.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityHorseSkeleton.java
|
||||
@@ -0,0 +0,0 @@ public class EntityHorseSkeleton extends EntityHorseAbstract {
|
||||
|
||||
private final PathfinderGoalHorseTrap bM = new PathfinderGoalHorseTrap(this);
|
||||
private boolean bN;
|
||||
- private int bO;
|
||||
+ private int bO; public int getTrapTime() { return this.bO; } // Paper - OBFHELPER
|
||||
private final PathfinderGoalHorseTrap bJ = new PathfinderGoalHorseTrap(this);
|
||||
private boolean bK;
|
||||
- private int bL;
|
||||
+ private int bL; public int getTrapTime() { return this.bL; } // Paper - OBFHELPER
|
||||
|
||||
public EntityHorseSkeleton(World world) {
|
||||
super(EntityTypes.SKELETON_HORSE, world);
|
||||
public EntityHorseSkeleton(EntityTypes<? extends EntityHorseSkeleton> entitytypes, World world) {
|
||||
super(entitytypes, world);
|
||||
@@ -0,0 +0,0 @@ public class EntityHorseSkeleton extends EntityHorseAbstract {
|
||||
return 0.96F;
|
||||
}
|
||||
|
||||
+ public boolean isTrap() { return this.dy(); } // Paper - OBFHELPER
|
||||
public boolean dy() {
|
||||
return this.bN;
|
||||
+ public boolean isTrap() { return this.dV(); } // Paper - OBFHELPER
|
||||
public boolean dV() {
|
||||
return this.bK;
|
||||
}
|
||||
|
||||
+ public void setTrap(boolean trap) { this.s(trap); } // Paper - OBFHELPER
|
||||
public void s(boolean flag) {
|
||||
if (flag != this.bN) {
|
||||
this.bN = flag;
|
||||
+ public void setTrap(boolean trap) { this.r(trap); } // Paper - OBFHELPER
|
||||
public void r(boolean flag) {
|
||||
if (flag != this.bK) {
|
||||
this.bK = flag;
|
||||
diff --git a/src/main/java/net/minecraft/server/PathfinderGoalHorseTrap.java b/src/main/java/net/minecraft/server/PathfinderGoalHorseTrap.java
|
||||
index a6979fe859..d4fdcbdfd6 100644
|
||||
index 7b0a6f82f..f09374413 100644
|
||||
--- a/src/main/java/net/minecraft/server/PathfinderGoalHorseTrap.java
|
||||
+++ b/src/main/java/net/minecraft/server/PathfinderGoalHorseTrap.java
|
||||
@@ -0,0 +0,0 @@ public class PathfinderGoalHorseTrap extends PathfinderGoal {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void e() {
|
||||
+ if (!new com.destroystokyo.paper.event.entity.SkeletonHorseTrapEvent((org.bukkit.entity.SkeletonHorse) this.a.getBukkitEntity()).callEvent()) return; // Paper
|
||||
DifficultyDamageScaler difficultydamagescaler = this.a.world.getDamageScaler(new BlockPosition(this.a));
|
||||
|
||||
this.a.s(false);
|
||||
this.a.r(false);
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeletonHorse.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeletonHorse.java
|
||||
index e822c2200d..496d0c0cac 100644
|
||||
index e822c2200..2a7d1d4ec 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeletonHorse.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeletonHorse.java
|
||||
@@ -0,0 +0,0 @@ public class CraftSkeletonHorse extends CraftAbstractHorse implements SkeletonHo
|
||||
|
@ -57,14 +57,17 @@ index e822c2200d..496d0c0cac 100644
|
|||
+ return (EntityHorseSkeleton) super.getHandle();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int getTrapTime() {
|
||||
+ return getHandle().getTrapTime();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isTrap() {
|
||||
+ return getHandle().isTrap();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setTrap(boolean trap) {
|
||||
+ getHandle().setTrap(trap);
|
||||
+ }
|
||||
|
|
|
@ -5,81 +5,106 @@ 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
|
||||
index 6598b87eef..539273afbc 100644
|
||||
index 8dd589aae..57a4481c5 100644
|
||||
--- a/src/main/java/net/minecraft/server/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/server/Entity.java
|
||||
@@ -0,0 +0,0 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
||||
private static int entityCount;
|
||||
private final EntityTypes<?> g; public EntityTypes<?> getEntityType() { return g; } // Paper - OBFHELPER
|
||||
private static double e = 1.0D;
|
||||
private final EntityTypes<?> f;
|
||||
private int id;
|
||||
- public boolean j;
|
||||
+ public boolean j; public boolean blocksEntitySpawning() { return j; } // Paper - OBFHELPER
|
||||
- public boolean i;
|
||||
+ public boolean i; public final boolean blocksEntitySpawning() { return this.i; } // Paper - OBFHELPER
|
||||
public final List<Entity> passengers;
|
||||
protected int k;
|
||||
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
|
||||
index bf7e0d17e..c5d5876c2 100644
|
||||
--- a/src/main/java/net/minecraft/server/IEntityAccess.java
|
||||
+++ b/src/main/java/net/minecraft/server/IEntityAccess.java
|
||||
@@ -0,0 +0,0 @@ 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);
|
||||
});
|
||||
@@ -0,0 +0,0 @@ public interface IEntityAccess {
|
||||
|
||||
@Nullable
|
||||
default <T extends EntityLiving> T a(Class<? extends T> oclass, PathfinderTargetCondition pathfindertargetcondition, @Nullable EntityLiving entityliving, double d0, double d1, double d2, AxisAlignedBB axisalignedbb) {
|
||||
- return this.a(this.a(oclass, axisalignedbb, (Predicate) null), pathfindertargetcondition, entityliving, d0, d1, d2);
|
||||
+ return this.a(this.a(oclass, axisalignedbb, (Predicate<T>) null), pathfindertargetcondition, entityliving, d0, d1, d2); // Paper - decompile fix
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -0,0 +0,0 @@ public interface IEntityAccess {
|
||||
Iterator iterator = list.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
- T t1 = (EntityLiving) iterator.next();
|
||||
+ T t1 = (T) iterator.next(); // Paper - decompile fix
|
||||
|
||||
if (pathfindertargetcondition.a(entityliving, t1)) {
|
||||
double d4 = t1.e(d0, d1, d2);
|
||||
@@ -0,0 +0,0 @@ public interface IEntityAccess {
|
||||
Iterator iterator = list.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
- T t0 = (EntityLiving) iterator.next();
|
||||
+ T t0 = (T) iterator.next(); // Paper - decompile fix
|
||||
|
||||
if (pathfindertargetcondition.a(entityliving, t0)) {
|
||||
list1.add(t0);
|
||||
diff --git a/src/main/java/net/minecraft/server/IWorldReader.java b/src/main/java/net/minecraft/server/IWorldReader.java
|
||||
index 0930552b1..c0aa21703 100644
|
||||
--- a/src/main/java/net/minecraft/server/IWorldReader.java
|
||||
+++ b/src/main/java/net/minecraft/server/IWorldReader.java
|
||||
@@ -0,0 +0,0 @@ public interface IWorldReader extends IIBlockAccess {
|
||||
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
|
||||
index f27d565e1e..49ad201c6e 100644
|
||||
index 59b1e6ce2..b90cc6652 100644
|
||||
--- a/src/main/java/net/minecraft/server/ItemBlock.java
|
||||
+++ b/src/main/java/net/minecraft/server/ItemBlock.java
|
||||
@@ -0,0 +0,0 @@ public class ItemBlock extends Item {
|
||||
|
||||
protected boolean b(BlockActionContext blockactioncontext, IBlockData iblockdata) {
|
||||
EntityHuman entityhuman = blockactioncontext.getEntity();
|
||||
VoxelShapeCollision voxelshapecollision = entityhuman == null ? VoxelShapeCollision.a() : VoxelShapeCollision.a((Entity) entityhuman);
|
||||
// CraftBukkit start - store default return
|
||||
- boolean defaultReturn = iblockdata.canPlace(blockactioncontext.getWorld(), blockactioncontext.getClickPosition()) && blockactioncontext.getWorld().a(iblockdata, blockactioncontext.getClickPosition());
|
||||
- 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 = iblockdata.canPlace(world, blockactioncontext.getClickPosition()) && world.a(iblockdata, blockactioncontext.getClickPosition()) && world.checkNoVisiblePlayerCollisions(blockactioncontext.getEntity(), iblockdata.getCollisionShape(world, blockactioncontext.getClickPosition())); // Paper - Use our entity search
|
||||
+ 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/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
||||
index 28fca165cd..1929e9d2ae 100644
|
||||
--- a/src/main/java/net/minecraft/server/World.java
|
||||
+++ b/src/main/java/net/minecraft/server/World.java
|
||||
@@ -0,0 +0,0 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
||||
}
|
||||
}
|
||||
|
||||
+ // Paper start - Based on method below
|
||||
+ /**
|
||||
+ * @param entity causing the action ex. block placer
|
||||
+ * @param voxelshape area to search within
|
||||
+ * @return if there are no visible players colliding
|
||||
+ */
|
||||
+ public boolean checkNoVisiblePlayerCollisions(@Nullable Entity entity, VoxelShape voxelshape) {
|
||||
+ if (voxelshape.isEmpty()) {
|
||||
+ return true;
|
||||
+ } else {
|
||||
+ List list = this.getEntities((Entity) null, voxelshape.getBoundingBox());
|
||||
+
|
||||
+ for (int i = 0; i < list.size(); ++i) {
|
||||
+ Entity entity1 = (Entity) list.get(i);
|
||||
+
|
||||
+ if (entity instanceof EntityPlayer && entity1 instanceof EntityPlayer) {
|
||||
+ if (!((EntityPlayer) entity).getBukkitEntity().canSee(((EntityPlayer) entity1).getBukkitEntity())) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (!entity1.dead && entity1.blocksEntitySpawning()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
public boolean a(@Nullable Entity entity, VoxelShape voxelshape) {
|
||||
if (voxelshape.isEmpty()) {
|
||||
return true;
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||
index 2cfe8afe13..0a3a121cbc 100644
|
||||
index de081ca1c..c09f7e7c4 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||
@@ -0,0 +0,0 @@ public class CraftEventFactory {
|
||||
Projectile projectile = (Projectile) entity.getBukkitEntity();
|
||||
org.bukkit.entity.Entity collided = position.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) {
|
||||
|
|
Loading…
Reference in a new issue