More param name fixes

This commit is contained in:
Nassim Jahnke 2024-12-20 12:45:19 +01:00
parent 42a2ccff55
commit f3c1eb3dc0
No known key found for this signature in database
GPG key ID: EF6771C01F6EF02F
19 changed files with 68 additions and 86 deletions

View file

@ -79,20 +79,3 @@
return;
}
}
@@ -299,14 +_,14 @@
this.waitTime = waitTime;
}
- public void setOwner(@Nullable LivingEntity owner) {
+ public void setOwner(@Nullable net.minecraft.world.entity.LivingEntity owner) {
this.owner = owner;
this.ownerUUID = owner == null ? null : owner.getUUID();
}
@Nullable
@Override
- public LivingEntity getOwner() {
+ public net.minecraft.world.entity.LivingEntity getOwner() {
if (this.owner != null && !this.owner.isRemoved()) {
return this.owner;
} else {

View file

@ -300,8 +300,8 @@
+ this.setRemoved(reason, null);
+ }
+
+ public void remove(Entity.RemovalReason entity_removalreason, org.bukkit.event.entity.EntityRemoveEvent.Cause cause) {
+ this.setRemoved(entity_removalreason, cause);
+ public void remove(Entity.RemovalReason reason, org.bukkit.event.entity.EntityRemoveEvent.Cause eventCause) {
+ this.setRemoved(reason, eventCause);
+ // CraftBukkit end
}

View file

@ -61,7 +61,7 @@
} else {
- this.moveTo(x + 0.5, y, z + 0.5, this.getYRot(), this.getXRot());
+ // CraftBukkit start
+ org.bukkit.event.entity.EntityTeleportEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTeleportEvent(this, x + 0.5D, y, z + 0.5D);
+ org.bukkit.event.entity.EntityTeleportEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTeleportEvent(this, x + 0.5, y, z + 0.5);
+ if (event.isCancelled() || event.getTo() == null) { // Paper - prevent NP on null event to location
+ return false;
+ }

View file

@ -85,21 +85,19 @@
public void finalizeSpawnChildFromBreeding(ServerLevel level, Animal animal, @Nullable AgeableMob baby) {
- Optional.ofNullable(this.getLoveCause()).or(() -> Optional.ofNullable(animal.getLoveCause())).ifPresent(player -> {
- player.awardStat(Stats.ANIMALS_BRED);
- CriteriaTriggers.BRED_ANIMALS.trigger(player, this, animal, baby);
- });
+ // CraftBukkit start
+ this.finalizeSpawnChildFromBreeding(level, animal, baby, this.getRandom().nextInt(7) + 1);
+ }
+ public void finalizeSpawnChildFromBreeding(ServerLevel level, Animal animal, @Nullable AgeableMob baby, int experience) {
+ // CraftBukkit end
+ // Paper start
+ ServerPlayer entityplayer = this.getLoveCause();
+ if (entityplayer == null) entityplayer = animal.getLoveCause();
+ if (entityplayer != null) {
+ ServerPlayer player = this.getLoveCause();
+ if (player == null) player = animal.getLoveCause();
+ if (player != null) {
+ // Paper end
+ entityplayer.awardStat(Stats.ANIMALS_BRED);
+ CriteriaTriggers.BRED_ANIMALS.trigger(entityplayer, this, animal, baby);
player.awardStat(Stats.ANIMALS_BRED);
CriteriaTriggers.BRED_ANIMALS.trigger(player, this, animal, baby);
- });
+ } // Paper
this.setAge(6000);
animal.setAge(6000);
@ -110,7 +108,7 @@
- level.addFreshEntity(new ExperienceOrb(level, this.getX(), this.getY(), this.getZ(), this.getRandom().nextInt(7) + 1));
+ // CraftBukkit start - use event experience
+ if (experience > 0) {
+ level.addFreshEntity(new ExperienceOrb(level, this.getX(), this.getY(), this.getZ(), experience, org.bukkit.entity.ExperienceOrb.SpawnReason.BREED, entityplayer, baby)); // Paper
+ level.addFreshEntity(new ExperienceOrb(level, this.getX(), this.getY(), this.getZ(), experience, org.bukkit.entity.ExperienceOrb.SpawnReason.BREED, player, baby)); // Paper
+ }
+ // CraftBukkit end
}

View file

@ -59,23 +59,19 @@
}
}
@@ -489,11 +_,12 @@
@Nullable
BeehiveBlockEntity getBeehiveBlockEntity() {
- if (this.hivePos == null) {
- return null;
- } else {
@@ -492,7 +_,11 @@
if (this.hivePos == null) {
return null;
} else {
- return this.isTooFarAway(this.hivePos) ? null : this.level().getBlockEntity(this.hivePos, BlockEntityType.BEEHIVE).orElse(null);
+ // Paper start - move over logic to accommodate isTooFarAway with chunk load check
+ if (this.hivePos != null && !this.isTooFarAway(this.hivePos) && this.level().getChunkIfLoadedImmediately(this.hivePos.getX() >> 4, this.hivePos.getZ() >> 4) != null) {
+ return this.level().getBlockEntity(this.hivePos, BlockEntityType.BEEHIVE).orElse(null);
+ // Paper start - move over logic to accommodate isTooFarAway with chunk load check
+ return this.isTooFarAway(this.hivePos) || this.level().getChunkIfLoadedImmediately(this.hivePos.getX() >> 4, this.hivePos.getZ() >> 4) == null
+ ? null
+ : this.level().getBlockEntity(this.hivePos, BlockEntityType.BEEHIVE).orElse(null);
+ // Paper end
}
+ return null;
+ // Paper end
}
boolean isHiveValid() {
@@ -525,6 +_,7 @@
}

View file

@ -115,7 +115,7 @@
- fox.setAge(-24000);
- fox.moveTo(this.animal.getX(), this.animal.getY(), this.animal.getZ(), 0.0F, 0.0F);
- serverLevel.addFreshEntityWithPassengers(fox);
+ level.addFreshEntityWithPassengers(fox, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason
+ serverLevel.addFreshEntityWithPassengers(fox, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason
this.level.broadcastEntityEvent(this.animal, (byte)18);
if (serverLevel.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
- this.level

View file

@ -19,7 +19,7 @@
this.gameEvent(GameEvent.SHEAR, player);
itemInHand.hurtAndBreak(1, player, getSlotForHand(hand));
}
@@ -163,15 +_,32 @@
@@ -163,15 +_,31 @@
@Override
public void shear(ServerLevel level, SoundSource soundSource, ItemStack shears) {
@ -48,8 +48,7 @@
- }
+ // Paper start - custom shear drops; moved drop generation to separate method
+ drops.forEach(drop -> {
+ ItemEntity entityitem = new ItemEntity(this.level(), this.getX(), this.getY(1.0D), this.getZ(), drop);
+ this.spawnAtLocation(level, entityitem);
+ this.spawnAtLocation(level, new ItemEntity(this.level(), this.getX(), this.getY(1.0), this.getZ(), drop));
});
- });
+ // Paper end - custom shear drops

View file

@ -49,10 +49,10 @@
- (serverLevel, itemStack) -> {
- for (int i = 0; i < itemStack.getCount(); i++) {
- ItemEntity itemEntity = this.spawnAtLocation(serverLevel, itemStack.copyWithCount(1), 1.0F);
+ drops.forEach(itemstack1 -> { // Paper - custom drops - loop in generated default drops
+ drops.forEach(itemStack -> { // Paper - custom drops - loop in generated default drops
+ if (true) { // Paper - custom drops - loop in generated default drops
+ this.forceDrops = true; // CraftBukkit
+ ItemEntity itemEntity = this.spawnAtLocation(level, itemstack1, 1.0F); // Paper - custom drops - copy already done above
+ ItemEntity itemEntity = this.spawnAtLocation(level, itemStack, 1.0F); // Paper - custom drops - copy already done above
+ this.forceDrops = false; // CraftBukkit
if (itemEntity != null) {
itemEntity.setDeltaMovement(

View file

@ -64,9 +64,9 @@
- this.dropFromShearingLootTable(
- level, BuiltInLootTables.SHEAR_SNOW_GOLEM, shears, (serverLevel, itemStack) -> this.spawnAtLocation(serverLevel, itemStack, this.getEyeHeight())
- );
+ drops.forEach(itemstack1 -> { // Paper - custom shear drops
+ drops.forEach(itemStack -> { // Paper - custom shear drops
+ this.forceDrops = true; // CraftBukkit
+ this.spawnAtLocation(level, itemstack1, this.getEyeHeight());
+ this.spawnAtLocation(level, itemStack, this.getEyeHeight());
+ this.forceDrops = false; // CraftBukkit
+ });
}

View file

@ -18,7 +18,7 @@
+ // Paper start - Don't use level random in entity constructors (to make them thread-safe)
+ this(EntityType.ITEM, level);
+ this.setPos(posX, posY, posZ);
+ this.setDeltaMovement(this.random.nextDouble() * 0.2D - 0.1D, 0.2D, this.random.nextDouble() * 0.2D - 0.1D);
+ this.setDeltaMovement(this.random.nextDouble() * 0.2 - 0.1, 0.2, this.random.nextDouble() * 0.2 - 0.1);
+ this.setItem(itemStack);
+ // Paper end - Don't use level random in entity constructors
}

View file

@ -5,7 +5,7 @@
protected void doFreezeConversion() {
- this.convertTo(EntityType.STRAY, ConversionParams.single(this, true, true), mob -> {
+ final Stray stray = this.convertTo(EntityType.STRAY, ConversionParams.single(this, true, true), (entityskeletonstray) -> { // Paper - Fix issues with mob conversion; reset conversion time to prevent event spam
+ final Stray stray = this.convertTo(EntityType.STRAY, ConversionParams.single(this, true, true), mob -> { // Paper - Fix issues with mob conversion; reset conversion time to prevent event spam
if (!this.isSilent()) {
this.level().levelEvent(null, 1048, this.blockPosition(), 0);
}

View file

@ -37,7 +37,7 @@
+ }
+
+ @Override
+ public void remove(Entity.RemovalReason entity_removalreason, org.bukkit.event.entity.EntityRemoveEvent.Cause cause) {
+ public void remove(Entity.RemovalReason reason, org.bukkit.event.entity.EntityRemoveEvent.Cause eventCause) {
+ // CraftBukkit end
int size = this.getSize();
if (!this.level().isClientSide && size > 1 && this.isDeadOrDying()) {
@ -53,7 +53,7 @@
+ if (!event.isCancelled() && event.getCount() > 0) {
+ i1 = event.getCount();
+ } else {
+ super.remove(entity_removalreason, cause); // CraftBukkit - add Bukkit remove cause
+ super.remove(reason, eventCause); // CraftBukkit - add Bukkit remove cause
+ return;
+ }
+ java.util.List<net.minecraft.world.entity.LivingEntity> slimes = new java.util.ArrayList<>(i1);
@ -78,7 +78,7 @@
+ }
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTransformEvent(this, slimes, org.bukkit.event.entity.EntityTransformEvent.TransformReason.SPLIT).isCancelled()) {
+ super.remove(entity_removalreason, cause); // CraftBukkit - add Bukkit remove cause
+ super.remove(reason, eventCause); // CraftBukkit - add Bukkit remove cause
+ return;
+ }
+ for (LivingEntity living : slimes) {
@ -88,7 +88,7 @@
}
- super.remove(reason);
+ super.remove(entity_removalreason, cause); // CraftBukkit - add Bukkit remove cause
+ super.remove(reason, eventCause); // CraftBukkit - add Bukkit remove cause
}
@Override

View file

@ -55,7 +55,7 @@
public Inventory(Player player) {
this.player = player;
}
@@ -50,10 +_,32 @@
@@ -50,10 +_,39 @@
private boolean hasRemainingSpaceForItem(ItemStack destination, ItemStack origin) {
return !destination.isEmpty()
@ -68,24 +68,31 @@
+ }
+
+ // CraftBukkit start - Watch method above! :D
+ public int canHold(ItemStack itemstack) {
+ int remains = itemstack.getCount();
+ for (int i = 0; i < this.items.size(); ++i) {
+ ItemStack itemstack1 = this.getItem(i);
+ if (itemstack1.isEmpty()) return itemstack.getCount();
+
+ if (this.hasRemainingSpaceForItem(itemstack1, itemstack)) {
+ remains -= (itemstack1.getMaxStackSize() < this.getMaxStackSize() ? itemstack1.getMaxStackSize() : this.getMaxStackSize()) - itemstack1.getCount();
+ public int canHold(ItemStack itemStack) {
+ int remains = itemStack.getCount();
+ for (int slot = 0; slot < this.items.size(); ++slot) {
+ ItemStack itemInSlot = this.getItem(slot);
+ if (itemInSlot.isEmpty()) {
+ return itemStack.getCount();
+ }
+ if (remains <= 0) return itemstack.getCount();
+ }
+ ItemStack offhandItemStack = this.getItem(this.items.size() + this.armor.size());
+ if (this.hasRemainingSpaceForItem(offhandItemStack, itemstack)) {
+ remains -= (offhandItemStack.getMaxStackSize() < this.getMaxStackSize() ? offhandItemStack.getMaxStackSize() : this.getMaxStackSize()) - offhandItemStack.getCount();
+ }
+ if (remains <= 0) return itemstack.getCount();
+
+ return itemstack.getCount() - remains;
+ if (this.hasRemainingSpaceForItem(itemInSlot, itemStack)) {
+ remains -= (itemInSlot.getMaxStackSize() < this.getMaxStackSize() ? itemInSlot.getMaxStackSize() : this.getMaxStackSize()) - itemInSlot.getCount();
+ }
+ if (remains <= 0) {
+ return itemStack.getCount();
+ }
+ }
+
+ ItemStack itemInOffhand = this.getItem(this.items.size() + this.armor.size());
+ if (this.hasRemainingSpaceForItem(itemInOffhand, itemStack)) {
+ remains -= (itemInOffhand.getMaxStackSize() < this.getMaxStackSize() ? itemInOffhand.getMaxStackSize() : this.getMaxStackSize()) - itemInOffhand.getCount();
+ }
+ if (remains <= 0) {
+ return itemStack.getCount();
+ }
+
+ return itemStack.getCount() - remains;
+ }
+ // CraftBukkit end

View file

@ -462,8 +462,8 @@
+ }
+
+ @Override
+ public void remove(Entity.RemovalReason entity_removalreason, org.bukkit.event.entity.EntityRemoveEvent.Cause cause) {
+ super.remove(entity_removalreason, cause);
+ public void remove(Entity.RemovalReason reason, org.bukkit.event.entity.EntityRemoveEvent.Cause eventCause) {
+ super.remove(reason, eventCause);
+ // CraftBukkit end
this.inventoryMenu.removed(this);
if (this.containerMenu != null && this.hasContainerOpen()) {

View file

@ -14,8 +14,8 @@
+ return this.finalTarget;
+ }
+
+ public void setTarget(Entity e) {
+ this.finalTarget = e;
+ public void setTarget(Entity finalTarget) {
+ this.finalTarget = finalTarget;
+ this.currentMoveDirection = Direction.UP;
+ this.selectNextMoveDirection(Direction.Axis.X);
+ }

View file

@ -79,20 +79,19 @@
@Override
public void remove(Entity.RemovalReason reason) {
- if (!this.level().isClientSide && reason.shouldDestroy() && this.isLeashed()) {
+ // CraftBukkit start - add Bukkit remove cause
+ this.remove(reason, null);
+ }
+
+ @Override
+ public void remove(Entity.RemovalReason entity_removalreason, org.bukkit.event.entity.EntityRemoveEvent.Cause cause) {
+ public void remove(Entity.RemovalReason reason, org.bukkit.event.entity.EntityRemoveEvent.Cause eventCause) {
+ // CraftBukkit end
+ if (!this.level().isClientSide && entity_removalreason.shouldDestroy() && this.isLeashed()) {
if (!this.level().isClientSide && reason.shouldDestroy() && this.isLeashed()) {
this.dropLeash();
}
- super.remove(reason);
+ super.remove(entity_removalreason, cause); // CraftBukkit - add Bukkit remove cause
+ super.remove(reason, eventCause); // CraftBukkit - add Bukkit remove cause
}
@Override

View file

@ -19,7 +19,7 @@
public double getSlowdownFactor() {
- return this.minecart.isVehicle() ? 0.997 : 0.975;
+ if (this.minecart.frictionState == net.kyori.adventure.util.TriState.FALSE) return 1; // Paper
+ return this.minecart.isVehicle() || !this.minecart.slowWhenEmpty ? 0.997D : 0.975D; // CraftBukkit - add !this.slowWhenEmpty
+ return this.minecart.isVehicle() || !this.minecart.slowWhenEmpty ? 0.997 : 0.975; // CraftBukkit - add !this.slowWhenEmpty
}
@Override

View file

@ -53,6 +53,6 @@
public double getSlowdownFactor() {
- return this.minecart.isVehicle() ? 0.997 : 0.96;
+ if (this.minecart.frictionState == net.kyori.adventure.util.TriState.FALSE) return 1; // Paper
+ return this.minecart.isVehicle() || !this.minecart.slowWhenEmpty ? 0.997D : 0.96D; // CraftBukkit - add !this.slowWhenEmpty
+ return this.minecart.isVehicle() || !this.minecart.slowWhenEmpty ? 0.997 : 0.96; // CraftBukkit - add !this.slowWhenEmpty
}
}

View file

@ -160,11 +160,11 @@
slot.setChanged();
+ // CraftBukkit start - Make sure the client has the right slot contents
+ if (player instanceof ServerPlayer && slot.getMaxStackSize() != 64) {
+ ((ServerPlayer) player).connection.send(new ClientboundContainerSetSlotPacket(this.containerId, this.incrementStateId(), slot.index, slot.getItem()));
+ if (player instanceof ServerPlayer serverPlayer && slot.getMaxStackSize() != 64) {
+ serverPlayer.connection.send(new ClientboundContainerSetSlotPacket(this.containerId, this.incrementStateId(), slot.index, slot.getItem()));
+ // Updating a crafting inventory makes the client reset the result slot, have to send it again
+ if (this.getBukkitView().getType() == org.bukkit.event.inventory.InventoryType.WORKBENCH || this.getBukkitView().getType() == org.bukkit.event.inventory.InventoryType.CRAFTING) {
+ ((ServerPlayer) player).connection.send(new ClientboundContainerSetSlotPacket(this.containerId, this.incrementStateId(), 0, this.getSlot(0).getItem()));
+ serverPlayer.connection.send(new ClientboundContainerSetSlotPacket(this.containerId, this.incrementStateId(), 0, this.getSlot(0).getItem()));
+ }
+ }
+ // CraftBukkit end