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; 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); + this.setRemoved(reason, null);
+ } + }
+ +
+ 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) {
+ this.setRemoved(entity_removalreason, cause); + this.setRemoved(reason, eventCause);
+ // CraftBukkit end + // CraftBukkit end
} }

View file

@ -61,7 +61,7 @@
} else { } else {
- this.moveTo(x + 0.5, y, z + 0.5, this.getYRot(), this.getXRot()); - this.moveTo(x + 0.5, y, z + 0.5, this.getYRot(), this.getXRot());
+ // CraftBukkit start + // 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 + if (event.isCancelled() || event.getTo() == null) { // Paper - prevent NP on null event to location
+ return false; + return false;
+ } + }

View file

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

View file

@ -59,23 +59,19 @@
} }
} }
@@ -489,11 +_,12 @@ @@ -492,7 +_,11 @@
if (this.hivePos == null) {
@Nullable return null;
BeehiveBlockEntity getBeehiveBlockEntity() { } else {
- if (this.hivePos == null) {
- return null;
- } else {
- return this.isTooFarAway(this.hivePos) ? null : this.level().getBlockEntity(this.hivePos, BlockEntityType.BEEHIVE).orElse(null); - 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 + // 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.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); + ? null
} + : this.level().getBlockEntity(this.hivePos, BlockEntityType.BEEHIVE).orElse(null);
+ return null;
+ // Paper end + // Paper end
} }
}
boolean isHiveValid() {
@@ -525,6 +_,7 @@ @@ -525,6 +_,7 @@
} }

View file

@ -115,7 +115,7 @@
- fox.setAge(-24000); - fox.setAge(-24000);
- fox.moveTo(this.animal.getX(), this.animal.getY(), this.animal.getZ(), 0.0F, 0.0F); - fox.moveTo(this.animal.getX(), this.animal.getY(), this.animal.getZ(), 0.0F, 0.0F);
- serverLevel.addFreshEntityWithPassengers(fox); - 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); this.level.broadcastEntityEvent(this.animal, (byte)18);
if (serverLevel.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { if (serverLevel.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
- this.level - this.level

View file

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

View file

@ -49,10 +49,10 @@
- (serverLevel, itemStack) -> { - (serverLevel, itemStack) -> {
- for (int i = 0; i < itemStack.getCount(); i++) { - for (int i = 0; i < itemStack.getCount(); i++) {
- ItemEntity itemEntity = this.spawnAtLocation(serverLevel, itemStack.copyWithCount(1), 1.0F); - 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 + if (true) { // Paper - custom drops - loop in generated default drops
+ this.forceDrops = true; // CraftBukkit + 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 + this.forceDrops = false; // CraftBukkit
if (itemEntity != null) { if (itemEntity != null) {
itemEntity.setDeltaMovement( itemEntity.setDeltaMovement(

View file

@ -64,9 +64,9 @@
- this.dropFromShearingLootTable( - this.dropFromShearingLootTable(
- level, BuiltInLootTables.SHEAR_SNOW_GOLEM, shears, (serverLevel, itemStack) -> this.spawnAtLocation(serverLevel, itemStack, this.getEyeHeight()) - 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.forceDrops = true; // CraftBukkit
+ this.spawnAtLocation(level, itemstack1, this.getEyeHeight()); + this.spawnAtLocation(level, itemStack, this.getEyeHeight());
+ this.forceDrops = false; // CraftBukkit + 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) + // Paper start - Don't use level random in entity constructors (to make them thread-safe)
+ this(EntityType.ITEM, level); + this(EntityType.ITEM, level);
+ this.setPos(posX, posY, posZ); + 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); + this.setItem(itemStack);
+ // Paper end - Don't use level random in entity constructors + // Paper end - Don't use level random in entity constructors
} }

View file

@ -5,7 +5,7 @@
protected void doFreezeConversion() { protected void doFreezeConversion() {
- this.convertTo(EntityType.STRAY, ConversionParams.single(this, true, true), mob -> { - 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()) { if (!this.isSilent()) {
this.level().levelEvent(null, 1048, this.blockPosition(), 0); this.level().levelEvent(null, 1048, this.blockPosition(), 0);
} }

View file

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

View file

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

View file

@ -462,8 +462,8 @@
+ } + }
+ +
+ @Override + @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) {
+ super.remove(entity_removalreason, cause); + super.remove(reason, eventCause);
+ // CraftBukkit end + // CraftBukkit end
this.inventoryMenu.removed(this); this.inventoryMenu.removed(this);
if (this.containerMenu != null && this.hasContainerOpen()) { if (this.containerMenu != null && this.hasContainerOpen()) {

View file

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

View file

@ -79,20 +79,19 @@
@Override @Override
public void remove(Entity.RemovalReason reason) { public void remove(Entity.RemovalReason reason) {
- if (!this.level().isClientSide && reason.shouldDestroy() && this.isLeashed()) {
+ // CraftBukkit start - add Bukkit remove cause + // CraftBukkit start - add Bukkit remove cause
+ this.remove(reason, null); + this.remove(reason, null);
+ } + }
+ +
+ @Override + @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 + // CraftBukkit end
+ if (!this.level().isClientSide && entity_removalreason.shouldDestroy() && this.isLeashed()) { if (!this.level().isClientSide && reason.shouldDestroy() && this.isLeashed()) {
this.dropLeash(); this.dropLeash();
} }
- super.remove(reason); - super.remove(reason);
+ super.remove(entity_removalreason, cause); // CraftBukkit - add Bukkit remove cause + super.remove(reason, eventCause); // CraftBukkit - add Bukkit remove cause
} }
@Override @Override

View file

@ -19,7 +19,7 @@
public double getSlowdownFactor() { public double getSlowdownFactor() {
- return this.minecart.isVehicle() ? 0.997 : 0.975; - return this.minecart.isVehicle() ? 0.997 : 0.975;
+ if (this.minecart.frictionState == net.kyori.adventure.util.TriState.FALSE) return 1; // Paper + 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 @Override

View file

@ -53,6 +53,6 @@
public double getSlowdownFactor() { public double getSlowdownFactor() {
- return this.minecart.isVehicle() ? 0.997 : 0.96; - return this.minecart.isVehicle() ? 0.997 : 0.96;
+ if (this.minecart.frictionState == net.kyori.adventure.util.TriState.FALSE) return 1; // Paper + 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(); slot.setChanged();
+ // CraftBukkit start - Make sure the client has the right slot contents + // CraftBukkit start - Make sure the client has the right slot contents
+ if (player instanceof ServerPlayer && slot.getMaxStackSize() != 64) { + if (player instanceof ServerPlayer serverPlayer && slot.getMaxStackSize() != 64) {
+ ((ServerPlayer) player).connection.send(new ClientboundContainerSetSlotPacket(this.containerId, this.incrementStateId(), slot.index, slot.getItem())); + 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 + // 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) { + 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 + // CraftBukkit end