mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-01 04:32:11 -07:00
check global player list where appropriate
Makes certain entities check all players when searching for a player instead of just checking players in their world.
This commit is contained in:
@@ -136,7 +136,7 @@
|
|||||||
+
|
+
|
||||||
+ int minChunkX = minBlockX >> 4;
|
+ int minChunkX = minBlockX >> 4;
|
||||||
+ int minChunkZ = minBlockZ >> 4;
|
+ int minChunkZ = minBlockZ >> 4;
|
||||||
+
|
|
||||||
+ int maxChunkX = maxBlockX >> 4;
|
+ int maxChunkX = maxBlockX >> 4;
|
||||||
+ int maxChunkZ = maxBlockZ >> 4;
|
+ int maxChunkZ = maxBlockZ >> 4;
|
||||||
+
|
+
|
||||||
@@ -227,7 +227,7 @@
|
|||||||
+ boolean flag2 = minecraftserver.forceSynchronousWrites();
|
+ boolean flag2 = minecraftserver.forceSynchronousWrites();
|
||||||
+ DataFixer datafixer = minecraftserver.getFixerUpper();
|
+ DataFixer datafixer = minecraftserver.getFixerUpper();
|
||||||
+ EntityPersistentStorage<Entity> entitypersistentstorage = new EntityStorage(new SimpleRegionStorage(new RegionStorageInfo(convertable_conversionsession.getLevelId(), resourcekey, "entities"), convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), datafixer, flag2, DataFixTypes.ENTITY_CHUNK), this, minecraftserver);
|
+ EntityPersistentStorage<Entity> entitypersistentstorage = new EntityStorage(new SimpleRegionStorage(new RegionStorageInfo(convertable_conversionsession.getLevelId(), resourcekey, "entities"), convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), datafixer, flag2, DataFixTypes.ENTITY_CHUNK), this, minecraftserver);
|
||||||
|
+
|
||||||
this.entityManager = new PersistentEntitySectionManager<>(Entity.class, new ServerLevel.EntityCallbacks(), entitypersistentstorage);
|
this.entityManager = new PersistentEntitySectionManager<>(Entity.class, new ServerLevel.EntityCallbacks(), entitypersistentstorage);
|
||||||
- StructureTemplateManager structuretemplatemanager = server.getStructureManager();
|
- StructureTemplateManager structuretemplatemanager = server.getStructureManager();
|
||||||
- int j = server.getPlayerList().getViewDistance();
|
- int j = server.getPlayerList().getViewDistance();
|
||||||
@@ -839,15 +839,14 @@
|
|||||||
case NONE:
|
case NONE:
|
||||||
explosion_effect = Explosion.BlockInteraction.KEEP;
|
explosion_effect = Explosion.BlockInteraction.KEEP;
|
||||||
break;
|
break;
|
||||||
@@ -1143,17 +1491,28 @@
|
@@ -1144,16 +1492,27 @@
|
||||||
break;
|
|
||||||
case TRIGGER:
|
case TRIGGER:
|
||||||
explosion_effect = Explosion.BlockInteraction.TRIGGER_BLOCK;
|
explosion_effect = Explosion.BlockInteraction.TRIGGER_BLOCK;
|
||||||
+ break;
|
break;
|
||||||
+ // CraftBukkit start - handle custom explosion type
|
+ // CraftBukkit start - handle custom explosion type
|
||||||
+ case STANDARD:
|
+ case STANDARD:
|
||||||
+ explosion_effect = Explosion.BlockInteraction.DESTROY;
|
+ explosion_effect = Explosion.BlockInteraction.DESTROY;
|
||||||
break;
|
+ break;
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
default:
|
default:
|
||||||
throw new MatchException((String) null, (Throwable) null);
|
throw new MatchException((String) null, (Throwable) null);
|
||||||
@@ -1139,7 +1138,7 @@
|
|||||||
String s = "onTrackingStart called during navigation iteration";
|
String s = "onTrackingStart called during navigation iteration";
|
||||||
|
|
||||||
Util.logAndPauseIfInIde("onTrackingStart called during navigation iteration", new IllegalStateException("onTrackingStart called during navigation iteration"));
|
Util.logAndPauseIfInIde("onTrackingStart called during navigation iteration", new IllegalStateException("onTrackingStart called during navigation iteration"));
|
||||||
@@ -1895,6 +2353,15 @@
|
@@ -1895,10 +2353,27 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
entity.updateDynamicGameEventListener(DynamicGameEventListener::remove);
|
entity.updateDynamicGameEventListener(DynamicGameEventListener::remove);
|
||||||
@@ -1155,3 +1154,15 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onSectionChange(Entity entity) {
|
public void onSectionChange(Entity entity) {
|
||||||
|
entity.updateDynamicGameEventListener(DynamicGameEventListener::move);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ // Paper start - check global player list where appropriate
|
||||||
|
+ @Override
|
||||||
|
+ @Nullable
|
||||||
|
+ public Player getGlobalPlayerByUUID(UUID uuid) {
|
||||||
|
+ return this.server.getPlayerList().getPlayer(uuid);
|
||||||
|
+ }
|
||||||
|
+ // Paper end - check global player list where appropriate
|
||||||
|
}
|
||||||
|
@@ -1050,7 +1050,7 @@
|
|||||||
+ };
|
+ };
|
||||||
+ float freezingModifier = freezing.apply((double) f).floatValue();
|
+ float freezingModifier = freezing.apply((double) f).floatValue();
|
||||||
+ f += freezingModifier;
|
+ f += freezingModifier;
|
||||||
+
|
|
||||||
+ com.google.common.base.Function<Double, Double> hardHat = new com.google.common.base.Function<Double, Double>() {
|
+ com.google.common.base.Function<Double, Double> hardHat = new com.google.common.base.Function<Double, Double>() {
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public Double apply(Double f) {
|
+ public Double apply(Double f) {
|
||||||
@@ -1175,7 +1175,7 @@
|
|||||||
+ float absorptionModifier = (float) -event.getDamage(DamageModifier.ABSORPTION);
|
+ float absorptionModifier = (float) -event.getDamage(DamageModifier.ABSORPTION);
|
||||||
+ this.setAbsorptionAmount(Math.max(this.getAbsorptionAmount() - absorptionModifier, 0.0F));
|
+ this.setAbsorptionAmount(Math.max(this.getAbsorptionAmount() - absorptionModifier, 0.0F));
|
||||||
+ float f2 = absorptionModifier;
|
+ float f2 = absorptionModifier;
|
||||||
|
+
|
||||||
+ if (f2 > 0.0F && f2 < 3.4028235E37F && this instanceof net.minecraft.world.entity.player.Player) {
|
+ if (f2 > 0.0F && f2 < 3.4028235E37F && this instanceof net.minecraft.world.entity.player.Player) {
|
||||||
+ ((net.minecraft.world.entity.player.Player) this).awardStat(Stats.DAMAGE_ABSORBED, Math.round(f2 * 10.0F));
|
+ ((net.minecraft.world.entity.player.Player) this).awardStat(Stats.DAMAGE_ABSORBED, Math.round(f2 * 10.0F));
|
||||||
+ }
|
+ }
|
||||||
@@ -1367,7 +1367,7 @@
|
|||||||
if (this.tickCount % 20 == 0) {
|
if (this.tickCount % 20 == 0) {
|
||||||
this.getCombatTracker().recheckStatus();
|
this.getCombatTracker().recheckStatus();
|
||||||
}
|
}
|
||||||
@@ -2687,37 +3282,15 @@
|
@@ -2687,38 +3282,16 @@
|
||||||
gameprofilerfiller.pop();
|
gameprofilerfiller.pop();
|
||||||
gameprofilerfiller.push("rangeChecks");
|
gameprofilerfiller.push("rangeChecks");
|
||||||
|
|
||||||
@@ -1390,7 +1390,9 @@
|
|||||||
- while (this.yBodyRot - this.yBodyRotO >= 180.0F) {
|
- while (this.yBodyRot - this.yBodyRotO >= 180.0F) {
|
||||||
- this.yBodyRotO += 360.0F;
|
- this.yBodyRotO += 360.0F;
|
||||||
- }
|
- }
|
||||||
-
|
+ this.yHeadRotO += Math.round((this.yHeadRot - this.yHeadRotO) / 360.0F) * 360.0F;
|
||||||
|
+ // Paper end
|
||||||
|
|
||||||
- while (this.getXRot() - this.xRotO < -180.0F) {
|
- while (this.getXRot() - this.xRotO < -180.0F) {
|
||||||
- this.xRotO -= 360.0F;
|
- this.xRotO -= 360.0F;
|
||||||
- }
|
- }
|
||||||
@@ -1406,11 +1408,10 @@
|
|||||||
- while (this.yHeadRot - this.yHeadRotO >= 180.0F) {
|
- while (this.yHeadRot - this.yHeadRotO >= 180.0F) {
|
||||||
- this.yHeadRotO += 360.0F;
|
- this.yHeadRotO += 360.0F;
|
||||||
- }
|
- }
|
||||||
+ this.yHeadRotO += Math.round((this.yHeadRot - this.yHeadRotO) / 360.0F) * 360.0F;
|
-
|
||||||
+ // Paper end
|
|
||||||
|
|
||||||
gameprofilerfiller.pop();
|
gameprofilerfiller.pop();
|
||||||
this.animStep += f2;
|
this.animStep += f2;
|
||||||
|
if (this.isFallFlying()) {
|
||||||
@@ -2741,7 +3314,7 @@
|
@@ -2741,7 +3314,7 @@
|
||||||
this.elytraAnimationState.tick();
|
this.elytraAnimationState.tick();
|
||||||
}
|
}
|
||||||
@@ -1562,6 +1563,15 @@
|
|||||||
this.dismountVehicle(entity);
|
this.dismountVehicle(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -3258,7 +3877,7 @@
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onItemPickup(ItemEntity item) {
|
||||||
|
- Entity entity = item.getOwner();
|
||||||
|
+ Entity entity = item.thrower != null ? this.level().getGlobalPlayerByUUID(item.thrower) : null; // Paper - check global player list where appropriate
|
||||||
|
|
||||||
|
if (entity instanceof ServerPlayer) {
|
||||||
|
CriteriaTriggers.THROWN_ITEM_PICKED_UP_BY_ENTITY.trigger((ServerPlayer) entity, item.getItem(), this);
|
||||||
@@ -3284,7 +3903,8 @@
|
@@ -3284,7 +3903,8 @@
|
||||||
Vec3 vec3d = new Vec3(this.getX(), this.getEyeY(), this.getZ());
|
Vec3 vec3d = new Vec3(this.getX(), this.getEyeY(), this.getZ());
|
||||||
Vec3 vec3d1 = new Vec3(entity.getX(), entityY, entity.getZ());
|
Vec3 vec3d1 = new Vec3(entity.getX(), entityY, entity.getZ());
|
||||||
@@ -1643,7 +1653,7 @@
|
|||||||
+ org.bukkit.inventory.EquipmentSlot hand = org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(enumhand);
|
+ org.bukkit.inventory.EquipmentSlot hand = org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(enumhand);
|
||||||
+ event = new PlayerItemConsumeEvent((Player) this.getBukkitEntity(), craftItem, hand); // Paper
|
+ event = new PlayerItemConsumeEvent((Player) this.getBukkitEntity(), craftItem, hand); // Paper
|
||||||
+ this.level().getCraftServer().getPluginManager().callEvent(event);
|
+ this.level().getCraftServer().getPluginManager().callEvent(event);
|
||||||
|
+
|
||||||
+ if (event.isCancelled()) {
|
+ if (event.isCancelled()) {
|
||||||
+ // Update client
|
+ // Update client
|
||||||
+ Consumable consumable = this.useItem.get(DataComponents.CONSUMABLE);
|
+ Consumable consumable = this.useItem.get(DataComponents.CONSUMABLE);
|
||||||
@@ -1667,7 +1677,7 @@
|
|||||||
+ }
|
+ }
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
+
|
|
||||||
if (itemstack != this.useItem) {
|
if (itemstack != this.useItem) {
|
||||||
this.setItemInHand(enumhand, itemstack);
|
this.setItemInHand(enumhand, itemstack);
|
||||||
}
|
}
|
||||||
|
@@ -118,6 +118,15 @@
|
|||||||
|
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
EquipmentSlot enumitemslot = (EquipmentSlot) iterator.next();
|
EquipmentSlot enumitemslot = (EquipmentSlot) iterator.next();
|
||||||
|
@@ -240,7 +262,7 @@
|
||||||
|
entityvillager.finalizeSpawn(world, world.getCurrentDifficultyAt(entityvillager.blockPosition()), EntitySpawnReason.CONVERSION, (SpawnGroupData) null);
|
||||||
|
entityvillager.refreshBrain(world);
|
||||||
|
if (this.conversionStarter != null) {
|
||||||
|
- Player entityhuman = world.getPlayerByUUID(this.conversionStarter);
|
||||||
|
+ Player entityhuman = world.getGlobalPlayerByUUID(this.conversionStarter); // Paper - check global player list where appropriate
|
||||||
|
|
||||||
|
if (entityhuman instanceof ServerPlayer) {
|
||||||
|
CriteriaTriggers.CURED_ZOMBIE_VILLAGER.trigger((ServerPlayer) entityhuman, this, entityvillager);
|
||||||
@@ -248,12 +270,16 @@
|
@@ -248,12 +270,16 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -62,3 +62,15 @@
|
|||||||
default boolean hasNearbyAlivePlayer(double x, double y, double z, double range) {
|
default boolean hasNearbyAlivePlayer(double x, double y, double z, double range) {
|
||||||
for (Player player : this.players()) {
|
for (Player player : this.players()) {
|
||||||
if (EntitySelector.NO_SPECTATORS.test(player) && EntitySelector.LIVING_ENTITY_STILL_ALIVE.test(player)) {
|
if (EntitySelector.NO_SPECTATORS.test(player) && EntitySelector.LIVING_ENTITY_STILL_ALIVE.test(player)) {
|
||||||
|
@@ -124,4 +165,11 @@
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ // Paper start - check global player list where appropriate
|
||||||
|
+ @Nullable
|
||||||
|
+ default Player getGlobalPlayerByUUID(UUID uuid) {
|
||||||
|
+ return this.getPlayerByUUID(uuid);
|
||||||
|
+ }
|
||||||
|
+ // Paper end - check global player list where appropriate
|
||||||
|
}
|
||||||
|
@@ -1,6 +1,20 @@
|
|||||||
--- a/net/minecraft/world/level/block/entity/SculkShriekerBlockEntity.java
|
--- a/net/minecraft/world/level/block/entity/SculkShriekerBlockEntity.java
|
||||||
+++ b/net/minecraft/world/level/block/entity/SculkShriekerBlockEntity.java
|
+++ b/net/minecraft/world/level/block/entity/SculkShriekerBlockEntity.java
|
||||||
@@ -190,7 +190,7 @@
|
@@ -105,6 +105,13 @@
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public static ServerPlayer tryGetPlayer(@Nullable Entity entity) {
|
||||||
|
+ // Paper start - check global player list where appropriate; ensure level is the same for sculk events
|
||||||
|
+ final ServerPlayer player = tryGetPlayer0(entity);
|
||||||
|
+ return player != null && player.level() == entity.level() ? player : null;
|
||||||
|
+ }
|
||||||
|
+ @Nullable
|
||||||
|
+ private static ServerPlayer tryGetPlayer0(@Nullable Entity entity) {
|
||||||
|
+ // Paper end - check global player list where appropriate
|
||||||
|
if (entity instanceof ServerPlayer) {
|
||||||
|
return (ServerPlayer)entity;
|
||||||
|
} else {
|
||||||
|
@@ -190,7 +197,7 @@
|
||||||
private boolean trySummonWarden(ServerLevel world) {
|
private boolean trySummonWarden(ServerLevel world) {
|
||||||
return this.warningLevel >= 4
|
return this.warningLevel >= 4
|
||||||
&& SpawnUtil.trySpawnMob(
|
&& SpawnUtil.trySpawnMob(
|
||||||
|
Reference in New Issue
Block a user