13
0
geforkt von Mirrors/Paper

Option to prevent armor stands from doing entity lookups

Dieser Commit ist enthalten in:
Hugo Manrique 2018-07-23 12:57:39 +02:00
Ursprung 85be8cc620
Commit 1549b076df
2 geänderte Dateien mit 43 neuen und 26 gelöschten Zeilen

Datei anzeigen

@ -97,7 +97,15 @@
} }
} }
@@ -341,7 +362,7 @@ @@ -327,6 +348,7 @@
@Override
protected void pushEntities() {
+ if (!this.level().paperConfig().entities.armorStands.doCollisionEntityLookups) return; // Paper - Option to prevent armor stands from doing entity lookups
List<Entity> list = this.level().getEntities((Entity) this, this.getBoundingBox(), ArmorStand.RIDABLE_MINECARTS);
Iterator iterator = list.iterator();
@@ -341,7 +363,7 @@
} }
@Override @Override
@ -106,7 +114,7 @@
ItemStack itemstack = player.getItemInHand(hand); ItemStack itemstack = player.getItemInHand(hand);
if (!this.isMarker() && !itemstack.is(Items.NAME_TAG)) { if (!this.isMarker() && !itemstack.is(Items.NAME_TAG)) {
@@ -350,11 +371,11 @@ @@ -350,11 +372,11 @@
} else if (player.level().isClientSide) { } else if (player.level().isClientSide) {
return InteractionResult.SUCCESS_SERVER; return InteractionResult.SUCCESS_SERVER;
} else { } else {
@ -121,7 +129,7 @@
if (this.hasItemInSlot(enumitemslot2) && this.swapItem(player, enumitemslot2, itemstack, hand)) { if (this.hasItemInSlot(enumitemslot2) && this.swapItem(player, enumitemslot2, itemstack, hand)) {
return InteractionResult.SUCCESS_SERVER; return InteractionResult.SUCCESS_SERVER;
@@ -364,7 +385,7 @@ @@ -364,7 +386,7 @@
return InteractionResult.FAIL; return InteractionResult.FAIL;
} }
@ -130,7 +138,7 @@
return InteractionResult.FAIL; return InteractionResult.FAIL;
} }
@@ -380,39 +401,57 @@ @@ -380,39 +402,57 @@
} }
} }
@ -204,7 +212,7 @@
this.setItemSlot(slot, stack.copyWithCount(1)); this.setItemSlot(slot, stack.copyWithCount(1));
return true; return true;
} else if (!stack.isEmpty() && stack.getCount() > 1) { } else if (!stack.isEmpty() && stack.getCount() > 1) {
@@ -427,6 +466,7 @@ @@ -427,6 +467,7 @@
player.setItemInHand(hand, itemstack1); player.setItemInHand(hand, itemstack1);
return true; return true;
} }
@ -212,7 +220,7 @@
} }
@Override @Override
@@ -436,12 +476,22 @@ @@ -436,12 +477,22 @@
} else if (!world.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && source.getEntity() instanceof Mob) { } else if (!world.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && source.getEntity() instanceof Mob) {
return false; return false;
} else if (source.is(DamageTypeTags.BYPASSES_INVULNERABILITY)) { } else if (source.is(DamageTypeTags.BYPASSES_INVULNERABILITY)) {
@ -238,7 +246,7 @@
return false; return false;
} else if (source.is(DamageTypeTags.IGNITES_ARMOR_STANDS)) { } else if (source.is(DamageTypeTags.IGNITES_ARMOR_STANDS)) {
if (this.isOnFire()) { if (this.isOnFire()) {
@@ -463,8 +513,8 @@ @@ -463,8 +514,8 @@
} else { } else {
Entity entity = source.getEntity(); Entity entity = source.getEntity();
@ -249,7 +257,7 @@
if (!entityhuman.getAbilities().mayBuild) { if (!entityhuman.getAbilities().mayBuild) {
return false; return false;
@@ -474,7 +524,7 @@ @@ -474,7 +525,7 @@
if (source.isCreativePlayer()) { if (source.isCreativePlayer()) {
this.playBrokenSound(); this.playBrokenSound();
this.showBreakingParticles(); this.showBreakingParticles();
@ -258,7 +266,7 @@
return true; return true;
} else { } else {
long i = world.getGameTime(); long i = world.getGameTime();
@@ -486,7 +536,7 @@ @@ -486,7 +537,7 @@
} else { } else {
this.brokenByPlayer(world, source); this.brokenByPlayer(world, source);
this.showBreakingParticles(); this.showBreakingParticles();
@ -267,7 +275,7 @@
} }
return true; return true;
@@ -536,7 +586,7 @@ @@ -536,7 +587,7 @@
f1 -= amount; f1 -= amount;
if (f1 <= 0.5F) { if (f1 <= 0.5F) {
this.brokenByAnything(world, damageSource); this.brokenByAnything(world, damageSource);
@ -276,7 +284,7 @@
} else { } else {
this.setHealth(f1); this.setHealth(f1);
this.gameEvent(GameEvent.ENTITY_DAMAGE, damageSource.getEntity()); this.gameEvent(GameEvent.ENTITY_DAMAGE, damageSource.getEntity());
@@ -548,13 +598,13 @@ @@ -548,13 +599,13 @@
ItemStack itemstack = new ItemStack(Items.ARMOR_STAND); ItemStack itemstack = new ItemStack(Items.ARMOR_STAND);
itemstack.set(DataComponents.CUSTOM_NAME, this.getCustomName()); itemstack.set(DataComponents.CUSTOM_NAME, this.getCustomName());
@ -292,7 +300,7 @@
ItemStack itemstack; ItemStack itemstack;
int i; int i;
@@ -562,7 +612,7 @@ @@ -562,7 +613,7 @@
for (i = 0; i < this.handItems.size(); ++i) { for (i = 0; i < this.handItems.size(); ++i) {
itemstack = (ItemStack) this.handItems.get(i); itemstack = (ItemStack) this.handItems.get(i);
if (!itemstack.isEmpty()) { if (!itemstack.isEmpty()) {
@ -301,7 +309,7 @@
this.handItems.set(i, ItemStack.EMPTY); this.handItems.set(i, ItemStack.EMPTY);
} }
} }
@@ -570,15 +620,16 @@ @@ -570,15 +621,16 @@
for (i = 0; i < this.armorItems.size(); ++i) { for (i = 0; i < this.armorItems.size(); ++i) {
itemstack = (ItemStack) this.armorItems.get(i); itemstack = (ItemStack) this.armorItems.get(i);
if (!itemstack.isEmpty()) { if (!itemstack.isEmpty()) {
@ -320,7 +328,7 @@
} }
@Override @Override
@@ -663,10 +714,24 @@ @@ -663,10 +715,24 @@
public boolean isBaby() { public boolean isBaby() {
return this.isSmall(); return this.isSmall();
} }
@ -346,7 +354,7 @@
this.gameEvent(GameEvent.ENTITY_DIE); this.gameEvent(GameEvent.ENTITY_DIE);
} }
@@ -788,7 +853,7 @@ @@ -788,7 +854,7 @@
@Override @Override
public boolean skipAttackInteraction(Entity attacker) { public boolean skipAttackInteraction(Entity attacker) {
@ -355,7 +363,7 @@
} }
@Override @Override
@@ -882,4 +947,13 @@ @@ -882,4 +948,13 @@
public boolean canBeSeenByAnyone() { public boolean canBeSeenByAnyone() {
return !this.isInvisible() && !this.isMarker(); return !this.isInvisible() && !this.isMarker();
} }

Datei anzeigen

@ -237,7 +237,7 @@
+ // Paper start - if loaded + // Paper start - if loaded
@Nullable @Nullable
+ @Override @Override
+ public final ChunkAccess getChunkIfLoadedImmediately(int x, int z) { + public final ChunkAccess getChunkIfLoadedImmediately(int x, int z) {
+ return ((ServerLevel)this).chunkSource.getChunkAtIfLoadedImmediately(x, z); + return ((ServerLevel)this).chunkSource.getChunkAtIfLoadedImmediately(x, z);
+ } + }
@ -290,7 +290,7 @@
+ return getWorldBorder().isWithinBounds(blockposition) ? getBlockStateIfLoaded(blockposition) : null; + return getWorldBorder().isWithinBounds(blockposition) ? getBlockStateIfLoaded(blockposition) : null;
+ } + }
+ +
@Override + @Override
public ChunkAccess getChunk(int chunkX, int chunkZ, ChunkStatus leastStatus, boolean create) { public ChunkAccess getChunk(int chunkX, int chunkZ, ChunkStatus leastStatus, boolean create) {
+ // Paper end + // Paper end
ChunkAccess ichunkaccess = this.getChunkSource().getChunk(chunkX, chunkZ, leastStatus, create); ChunkAccess ichunkaccess = this.getChunkSource().getChunk(chunkX, chunkZ, leastStatus, create);
@ -475,7 +475,7 @@
return chunk.getBlockState(pos); return chunk.getBlockState(pos);
} }
@@ -446,32 +720,44 @@ @@ -446,34 +720,53 @@
this.pendingBlockEntityTickers.clear(); this.pendingBlockEntityTickers.clear();
} }
@ -528,16 +528,25 @@
+ // Paper end - Prevent block entity and entity crashes + // Paper end - Prevent block entity and entity crashes
} }
} }
+ // Paper start - Option to prevent armor stands from doing entity lookups
+ @Override
+ public boolean noCollision(@Nullable Entity entity, AABB box) {
+ if (entity instanceof net.minecraft.world.entity.decoration.ArmorStand && !entity.level().paperConfig().entities.armorStands.doCollisionEntityLookups) return false;
+ return LevelAccessor.super.noCollision(entity, box);
+ }
+ // Paper end - Option to prevent armor stands from doing entity lookups
@@ -510,13 +796,29 @@ public boolean shouldTickDeath(Entity entity) {
return true;
@@ -510,13 +803,29 @@
@Nullable @Nullable
@Override @Override
public BlockEntity getBlockEntity(BlockPos pos) { public BlockEntity getBlockEntity(BlockPos pos) {
- return this.isOutsideBuildHeight(pos) ? null : (!this.isClientSide && Thread.currentThread() != this.thread ? null : this.getChunkAt(pos).getBlockEntity(pos, LevelChunk.EntityCreationType.IMMEDIATE)); - return this.isOutsideBuildHeight(pos) ? null : (!this.isClientSide && Thread.currentThread() != this.thread ? null : this.getChunkAt(pos).getBlockEntity(pos, LevelChunk.EntityCreationType.IMMEDIATE));
+ // CraftBukkit start + // CraftBukkit start
+ return this.getBlockEntity(pos, true); + return this.getBlockEntity(pos, true);
+ } }
+
+ @Nullable + @Nullable
+ public BlockEntity getBlockEntity(BlockPos blockposition, boolean validate) { + public BlockEntity getBlockEntity(BlockPos blockposition, boolean validate) {
+ if (this.capturedTileEntities.containsKey(blockposition)) { + if (this.capturedTileEntities.containsKey(blockposition)) {
@ -545,8 +554,8 @@
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+ return this.isOutsideBuildHeight(blockposition) ? null : (!this.isClientSide && Thread.currentThread() != this.thread ? null : this.getChunkAt(blockposition).getBlockEntity(blockposition, LevelChunk.EntityCreationType.IMMEDIATE)); + return this.isOutsideBuildHeight(blockposition) ? null : (!this.isClientSide && Thread.currentThread() != this.thread ? null : this.getChunkAt(blockposition).getBlockEntity(blockposition, LevelChunk.EntityCreationType.IMMEDIATE));
} + }
+
public void setBlockEntity(BlockEntity blockEntity) { public void setBlockEntity(BlockEntity blockEntity) {
BlockPos blockposition = blockEntity.getBlockPos(); BlockPos blockposition = blockEntity.getBlockPos();
@ -560,7 +569,7 @@
this.getChunkAt(blockposition).addAndRegisterBlockEntity(blockEntity); this.getChunkAt(blockposition).addAndRegisterBlockEntity(blockEntity);
} }
} }
@@ -643,7 +945,7 @@ @@ -643,7 +952,7 @@
for (int k = 0; k < j; ++k) { for (int k = 0; k < j; ++k) {
EnderDragonPart entitycomplexpart = aentitycomplexpart[k]; EnderDragonPart entitycomplexpart = aentitycomplexpart[k];
@ -569,7 +578,7 @@
if (t0 != null && predicate.test(t0)) { if (t0 != null && predicate.test(t0)) {
result.add(t0); result.add(t0);
@@ -912,7 +1214,7 @@ @@ -912,7 +1221,7 @@
public static enum ExplosionInteraction implements StringRepresentable { public static enum ExplosionInteraction implements StringRepresentable {