readd bukkit extra data to entity tags

This commit is contained in:
Lulu13022002
2024-12-16 18:07:41 +01:00
parent 48be22a63e
commit 9e8a2de45b
8 changed files with 38 additions and 42 deletions

View File

@@ -5,7 +5,7 @@
private boolean disconnected;
private int requestedViewDistance = 2;
- public String language = "en_us";
+ public String language = null; // CraftBukkit - default // Paper - default to null
+ public String language = null; // Paper - default to null
+ public java.util.Locale adventure$locale = java.util.Locale.US; // Paper
@Nullable
private Vec3 startingToFallPosition;
@@ -106,7 +106,7 @@
this.advancements = server.getPlayerList().getPlayerAdvancements(this);
- this.moveTo(this.adjustSpawnLocation(level, level.getSharedSpawnPos()).getBottomCenter(), 0.0F, 0.0F);
- this.updateOptions(clientInformation);
+ // this.moveTo(this.adjustSpawnLocation(level, level.getSharedSpawnPos()).getBottomCenter(), 0.0F, 0.0F); // Paper - Don't move existing players to world spawn
+ // this.moveTo(this.adjustSpawnLocation(level, level.getSharedSpawnPos()).getBottomCenter(), 0.0F, 0.0F); // Paper - Don't move existing players to world spawn
+ this.updateOptionsNoEvents(clientInformation); // Paper - don't call options events on login
this.object = null;
+
@@ -196,6 +196,14 @@
if (compound.contains("SpawnX", 99) && compound.contains("SpawnY", 99) && compound.contains("SpawnZ", 99)) {
this.respawnPosition = new BlockPos(compound.getInt("SpawnX"), compound.getInt("SpawnY"), compound.getInt("SpawnZ"));
this.respawnForced = compound.getBoolean("SpawnForced");
@@ -475,6 +_,7 @@
.resultOrPartial(LOGGER::error)
.ifPresent(spawnDimension -> compound.put("SpawnDimension", spawnDimension));
}
+ this.getBukkitEntity().setExtraData(compound); // CraftBukkit
compound.putBoolean("spawn_extra_particles_on_fall", this.spawnExtraParticlesOnFall);
if (this.raidOmenPosition != null) {
@@ -490,7 +_,18 @@
private void saveParentVehicle(CompoundTag tag) {
Entity rootVehicle = this.getRootVehicle();

View File

@@ -1,20 +1,12 @@
--- a/net/minecraft/world/entity/ai/behavior/PrepareRamNearestTarget.java
+++ b/net/minecraft/world/entity/ai/behavior/PrepareRamNearestTarget.java
@@ -10,6 +_,7 @@
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerLevel;
+import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundSource;
import net.minecraft.util.Mth;
@@ -75,6 +_,16 @@
.flatMap(
nearestVisibleLivingEntities -> nearestVisibleLivingEntities.findClosest(livingEntity -> this.ramTargeting.test(level, entity, livingEntity))
)
+ // CraftBukkit start
+ .map((entityliving) -> {
+ org.bukkit.event.entity.EntityTargetEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTargetLivingEvent(entity, entityliving, (entityliving instanceof ServerPlayer) ? org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER : org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_ENTITY);
+ org.bukkit.event.entity.EntityTargetEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTargetLivingEvent(entity, entityliving, (entityliving instanceof net.minecraft.server.level.ServerPlayer) ? org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER : org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_ENTITY);
+ if (event.isCancelled() || event.getTarget() == null) {
+ return null;
+ }

View File

@@ -4,9 +4,9 @@
inventory.removeItemType(Items.WHEAT, i3);
ItemStack itemStack = inventory.addItem(new ItemStack(Items.BREAD, min));
if (!itemStack.isEmpty()) {
+ villager.forceDrops = true; // Paper - Add missing forceDrop toggle
+ villager.forceDrops = true; // Paper - Add missing forceDrop toggles
villager.spawnAtLocation(level, itemStack, 0.5F);
+ villager.forceDrops = false; // Paper - Add missing forceDrop toggle
+ villager.forceDrops = false; // Paper - Add missing forceDrop toggles
}
}
}

View File

@@ -13,8 +13,8 @@
+ public void addFlag(final Goal.Flag flag) {
+ this.flags.add(flag);
+ }
+
+ // Paper end - Mob Goal API
+
protected int adjustedTickDelay(int adjustment) {
return this.requiresUpdateEveryTick() ? adjustment : reducedTickDelay(adjustment);
}
@@ -25,7 +25,7 @@
+ // Paper start - Mob goal api
+ private com.destroystokyo.paper.entity.ai.PaperVanillaGoal<?> vanillaGoal;
+ public <T extends org.bukkit.entity.Mob> com.destroystokyo.paper.entity.ai.Goal<T> asPaperVanillaGoal() {
+ if(this.vanillaGoal == null) {
+ if (this.vanillaGoal == null) {
+ this.vanillaGoal = new com.destroystokyo.paper.entity.ai.PaperVanillaGoal<>(this);
+ }
+ //noinspection unchecked

View File

@@ -14,7 +14,7 @@
@Override
public void stop() {
- this.mob.setTarget(null);
+ this.mob.setTarget((LivingEntity) null, org.bukkit.event.entity.EntityTargetEvent.TargetReason.FORGOT_TARGET, true); // CraftBukkit
+ this.mob.setTarget(null, org.bukkit.event.entity.EntityTargetEvent.TargetReason.FORGOT_TARGET, true); // CraftBukkit
this.targetMob = null;
}

View File

@@ -1,12 +1,10 @@
--- a/net/minecraft/world/entity/ai/sensing/Sensor.java
+++ b/net/minecraft/world/entity/ai/sensing/Sensor.java
@@ -29,8 +_,19 @@
@@ -29,8 +_,17 @@
.ignoreInvisibilityTesting();
private final int scanRate;
private long timeToTick;
+ // Paper start - configurable sensor tick rate and timings
+ private final String configKey;
+ // Paper end
+ private final String configKey; // Paper - configurable sensor tick rate and timings
public Sensor(int scanRate) {
+ // Paper start - configurable sensor tick rate and timings
@@ -20,14 +18,12 @@
this.scanRate = scanRate;
this.timeToTick = RANDOM.nextInt(scanRate);
}
@@ -41,7 +_,9 @@
@@ -41,7 +_,7 @@
public final void tick(ServerLevel level, E entity) {
if (--this.timeToTick <= 0L) {
- this.timeToTick = this.scanRate;
+ // Paper start - configurable sensor tick rate and timings
+ this.timeToTick = java.util.Objects.requireNonNullElse(level.paperConfig().tickRates.sensor.get(entity.getType(), this.configKey), this.scanRate);
+ // Paper end
+ this.timeToTick = java.util.Objects.requireNonNullElse(level.paperConfig().tickRates.sensor.get(entity.getType(), this.configKey), this.scanRate); // Paper - configurable sensor tick rate and timings
this.updateTargetingConditionRanges(entity);
this.doTick(level, entity);
}