Updated Upstream (Bukkit/CraftBukkit) (#11501)

Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
bb4e97c6 Add support for Java 23
bc6874dd Bump asm to 9.7.1
50e8a00b PR-1064: Add specific getTopInventory methods for InventoryView derivatives
758b0a0f SPIGOT-7911: Fix Location#isWorldLoaded() for re-loaded worlds
133a64a7 Improve Registry#getOrThrow messages
be0f5957 PR-1058: Add tests for Minecraft registry <-> Bukkit fields
d1b31df2 PR-1062: Clarify BeaconView documentation
3fab4384 PR-1060: Cache Material to BlockType and ItemType conversion
967a7301 SPIGOT-7906: Increase YAML nesting limit to 100
6ecf033d SPIGOT-7899: Smithing recipes don't require inputs

CraftBukkit Changes:
0a7bd6c81 PR-1493: Improve reroute performance and add some tests
54941524c Add support for Java 23
f4d957fff SPIGOT-7915: Fix World#getKeepSpawnInMemory() using Spawn Radius rather than Spawn Chunk Radius
ded183674 Fix HIDE_ENCHANTS flag in items without enchantments
308785a0a Bump asm to 9.7.1 and re-add ClassReader to ClassWriter
72ce823cd PR-1487: Add specific getTopInventory methods for InventoryView derivatives
11a5e840c SPIGOT-7907, PR-1484: Improve merchant recipe item matching behavior to more closely align with older versions
45b66f7e4 SPIGOT-7909: Always set HIDE_ENCHANTS flag to item if flag is set
963459791 Increase outdated build delay
fc5b2d75f SPIGOT-7910: Fix launching breeze wind charge from API and improve dispenser launch API
c7d6428f2 SPIGOT-7856, PR-1483: End platform not dropping items after replacing blocks
2a5572b52 SPIGOT-7780, PR-1482: Cannot edit chunks during unload event
527041ab5 SPIGOT-7902, PR-1477: Fix CraftMetaPotion#hasCustomEffects() does not check if customEffects (List) is empty
5529a1769 Implement base methods for tags
30fbdbaaf Improve Registry#getOrThrow messages
6b71a7322 PR-1475: Add tests for Minecraft registry <-> Bukkit fields
5f24c255c SPIGOT-7908: Mark junit-platform-suite-engine as test scope
e4c92ef65 PR-1473: Change tests to use suites, to run tests in different environments and feature flags
d25e1e722 PR-1481: Fix BeaconView#set[X]Effect(null)
d69a05362 PR-1480: Fix PerMaterialTest#isEdible test running for legacy materials
bb3284a89 PR-1479: Use custom #isBlock method in legacy init instead of the one in Material, since it relies on legacy being init
98c57cbbe SPIGOT-7904: Fix NPE for PlayerItemBreakEvent
f35bae9ec Fix missing hasJukeboxPlayable
8a6f8b6d8 SPIGOT-7881: CTRL+Pick Block saves position data into item
7913b3be7 SPIGOT-7899: Smithing recipes don't require inputs
This commit is contained in:
Bjarne Koll
2024-10-21 00:06:54 +02:00
parent 64705c224b
commit 7c5395237d
79 changed files with 755 additions and 582 deletions

View File

@@ -547,27 +547,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} else if (ThrownPotion.class.isAssignableFrom(projectile)) {
if (LingeringPotion.class.isAssignableFrom(projectile)) {
launch = new net.minecraft.world.entity.projectile.ThrownPotion(world, this.getHandle());
@@ -0,0 +0,0 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
launch = new net.minecraft.world.entity.projectile.WitherSkull(world, this.getHandle(), vec);
} else if (DragonFireball.class.isAssignableFrom(projectile)) {
launch = new net.minecraft.world.entity.projectile.DragonFireball(world, this.getHandle(), vec);
- } else if (WindCharge.class.isAssignableFrom(projectile)) {
- launch = EntityType.WIND_CHARGE.create(world);
- ((net.minecraft.world.entity.projectile.windcharge.WindCharge) launch).setOwner(this.getHandle());
- ((net.minecraft.world.entity.projectile.windcharge.WindCharge) launch).assignDirectionalMovement(vec, 0.1D);
+ // Paper start - more projectile API - correctly launch wind charges
+ } else if (org.bukkit.entity.AbstractWindCharge.class.isAssignableFrom(projectile)) {
+ if (org.bukkit.entity.BreezeWindCharge.class.isAssignableFrom(projectile)) {
+ launch = EntityType.BREEZE_WIND_CHARGE.create(world);
+ } else {
+ launch = EntityType.WIND_CHARGE.create(world);
+ }
+ ((net.minecraft.world.entity.projectile.windcharge.AbstractWindCharge) launch).setOwner(this.getHandle());
+ ((net.minecraft.world.entity.projectile.windcharge.AbstractWindCharge) launch).shootFromRotation(this.getHandle(), this.getHandle().getXRot(), this.getHandle().getYRot(), 0.0F, 1.5F, 1.0F); // Paper - copied from net.minecraft.world.item.WindChargeItem.use
+ // Paper end - more projectile API - correctly launch wind charges
} else {
launch = new LargeFireball(world, this.getHandle(), vec, 1);
}
@@ -0,0 +0,0 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
} else if (Firework.class.isAssignableFrom(projectile)) {
Location location = this.getEyeLocation();
@@ -880,116 +859,38 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ public <T extends Projectile> T launchProjectile(Class<? extends T> projectile, Vector velocity, java.util.function.Consumer<? super T> function) {
+ // Paper end - launchProjectile consumer
Preconditions.checkArgument(this.getBlock().getType() == Material.DISPENSER, "Block is no longer dispenser");
- // Copied from BlockDispenser.dispense()
- BlockSource sourceblock = new BlockSource((ServerLevel) this.dispenserBlock.getLevel(), this.dispenserBlock.getBlockPos(), this.dispenserBlock.getBlockState(), this.dispenserBlock);
- // Copied from DispenseBehaviorProjectile
- Position iposition = DispenserBlock.getDispensePosition(sourceblock);
- Direction enumdirection = (Direction) sourceblock.state().getValue(DispenserBlock.FACING);
- net.minecraft.world.level.Level world = this.dispenserBlock.getLevel();
- net.minecraft.world.entity.Entity launch = null;
+ // Paper start - rewrite whole method to match ProjectileDispenseBehavior
+ net.minecraft.world.item.Item item = null;
if (Snowball.class.isAssignableFrom(projectile)) {
- launch = new net.minecraft.world.entity.projectile.Snowball(world, iposition.x(), iposition.y(), iposition.z());
+ item = net.minecraft.world.item.Items.SNOWBALL;
} else if (Egg.class.isAssignableFrom(projectile)) {
- launch = new ThrownEgg(world, iposition.x(), iposition.y(), iposition.z());
- } else if (EnderPearl.class.isAssignableFrom(projectile)) {
- launch = new ThrownEnderpearl(world, null);
- launch.setPos(iposition.x(), iposition.y(), iposition.z());
+ item = net.minecraft.world.item.Items.EGG;
} else if (ThrownExpBottle.class.isAssignableFrom(projectile)) {
- launch = new ThrownExperienceBottle(world, iposition.x(), iposition.y(), iposition.z());
+ item = net.minecraft.world.item.Items.EXPERIENCE_BOTTLE;
} else if (ThrownPotion.class.isAssignableFrom(projectile)) {
if (LingeringPotion.class.isAssignableFrom(projectile)) {
- launch = new net.minecraft.world.entity.projectile.ThrownPotion(world, iposition.x(), iposition.y(), iposition.z());
- ((net.minecraft.world.entity.projectile.ThrownPotion) launch).setItem(CraftItemStack.asNMSCopy(new ItemStack(org.bukkit.Material.LINGERING_POTION, 1)));
+ item = net.minecraft.world.item.Items.LINGERING_POTION;
} else {
- launch = new net.minecraft.world.entity.projectile.ThrownPotion(world, iposition.x(), iposition.y(), iposition.z());
- ((net.minecraft.world.entity.projectile.ThrownPotion) launch).setItem(CraftItemStack.asNMSCopy(new ItemStack(org.bukkit.Material.SPLASH_POTION, 1)));
+ item = net.minecraft.world.item.Items.SPLASH_POTION;
}
} else if (AbstractArrow.class.isAssignableFrom(projectile)) {
- if (TippedArrow.class.isAssignableFrom(projectile)) {
- launch = new net.minecraft.world.entity.projectile.Arrow(world, iposition.x(), iposition.y(), iposition.z(), new net.minecraft.world.item.ItemStack(net.minecraft.world.item.Items.ARROW), null);
- ((Arrow) launch.getBukkitEntity()).setBasePotionType(PotionType.WATER);
- } else if (SpectralArrow.class.isAssignableFrom(projectile)) {
- launch = new net.minecraft.world.entity.projectile.SpectralArrow(world, iposition.x(), iposition.y(), iposition.z(), new net.minecraft.world.item.ItemStack(net.minecraft.world.item.Items.SPECTRAL_ARROW), null);
+ if (SpectralArrow.class.isAssignableFrom(projectile)) {
+ item = net.minecraft.world.item.Items.SPECTRAL_ARROW;
} else {
- launch = new net.minecraft.world.entity.projectile.Arrow(world, iposition.x(), iposition.y(), iposition.z(), new net.minecraft.world.item.ItemStack(net.minecraft.world.item.Items.ARROW), null);
- }
- ((net.minecraft.world.entity.projectile.AbstractArrow) launch).pickup = net.minecraft.world.entity.projectile.AbstractArrow.Pickup.ALLOWED;
- ((net.minecraft.world.entity.projectile.AbstractArrow) launch).projectileSource = this;
- } else if (Fireball.class.isAssignableFrom(projectile)) {
- double d0 = iposition.x() + (double) ((float) enumdirection.getStepX() * 0.3F);
- double d1 = iposition.y() + (double) ((float) enumdirection.getStepY() * 0.3F);
- double d2 = iposition.z() + (double) ((float) enumdirection.getStepZ() * 0.3F);
- RandomSource random = world.random;
- double d3 = random.nextGaussian() * 0.05D + (double) enumdirection.getStepX();
- double d4 = random.nextGaussian() * 0.05D + (double) enumdirection.getStepY();
- double d5 = random.nextGaussian() * 0.05D + (double) enumdirection.getStepZ();
-
- if (SmallFireball.class.isAssignableFrom(projectile)) {
- launch = new net.minecraft.world.entity.projectile.SmallFireball(world, null, new Vec3(d0, d1, d2));
- } else if (WitherSkull.class.isAssignableFrom(projectile)) {
- launch = EntityType.WITHER_SKULL.create(world);
- launch.setPos(d0, d1, d2);
-
- ((AbstractHurtingProjectile) launch).assignDirectionalMovement(new Vec3(d3, d4, d5), 0.1D);
+
// Copied from BlockDispenser.dispense()
BlockSource sourceblock = new BlockSource((ServerLevel) this.dispenserBlock.getLevel(), this.dispenserBlock.getBlockPos(), this.dispenserBlock.getBlockState(), this.dispenserBlock);
// Copied from DispenseBehaviorProjectile
@@ -0,0 +0,0 @@ public class CraftBlockProjectileSource implements BlockProjectileSource {
} else if (Fireball.class.isAssignableFrom(projectile)) {
if (AbstractWindCharge.class.isAssignableFrom(projectile)) {
item = Items.WIND_CHARGE;
- } else {
- launch = EntityType.FIREBALL.create(world);
- launch.setPos(d0, d1, d2);
-
- ((AbstractHurtingProjectile) launch).assignDirectionalMovement(new Vec3(d3, d4, d5), 0.1D);
+ item = net.minecraft.world.item.Items.ARROW;
+ } else if (org.bukkit.entity.SmallFireball.class.isAssignableFrom(projectile)) { // Paper - more projectile API - only allow firing fire charges.
item = Items.FIRE_CHARGE;
}
+ } else if (org.bukkit.entity.WindCharge.class.isAssignableFrom(projectile)) {
+ item = net.minecraft.world.item.Items.WIND_CHARGE;
+ } else if (org.bukkit.entity.Firework.class.isAssignableFrom(projectile)) {
+ item = net.minecraft.world.item.Items.FIREWORK_ROCKET;
+ } else if (SmallFireball.class.isAssignableFrom(projectile)) {
+ item = net.minecraft.world.item.Items.FIRE_CHARGE;
+ }
} else if (Firework.class.isAssignableFrom(projectile)) {
@@ -0,0 +0,0 @@ public class CraftBlockProjectileSource implements BlockProjectileSource {
Position iposition = dispenseConfig.positionFunction().getDispensePosition(sourceblock, enumdirection);
net.minecraft.world.entity.projectile.Projectile launch = projectileItem.asProjectile(world, iposition, itemstack, enumdirection);
- ((AbstractHurtingProjectile) launch).projectileSource = this;
+ if (!(item instanceof net.minecraft.world.item.ProjectileItem projectileItem)) {
+ throw new IllegalArgumentException("Projectile '%s' is not supported".formatted(projectile.getSimpleName()));
- if (Fireball.class.isAssignableFrom(projectile)) {
+ if (false && Fireball.class.isAssignableFrom(projectile)) { // Paper - more project API - dispensers cannot launch anything but fire charges.
AbstractHurtingProjectile customFireball = null;
if (WitherSkull.class.isAssignableFrom(projectile)) {
launch = customFireball = EntityType.WITHER_SKULL.create(world);
@@ -0,0 +0,0 @@ public class CraftBlockProjectileSource implements BlockProjectileSource {
}
}
- Preconditions.checkArgument(launch != null, "Projectile not supported");
+ net.minecraft.world.item.ProjectileItem.DispenseConfig config = projectileItem.createDispenseConfig();
+ net.minecraft.world.level.block.state.BlockState state = this.dispenserBlock.getBlockState();
+ net.minecraft.world.level.Level world = this.dispenserBlock.getLevel();
+ BlockSource pointer = new BlockSource((ServerLevel) world, this.dispenserBlock.getBlockPos(), state, this.dispenserBlock); // copied from DispenseBlock#dispenseFrom
+ Direction facing = state.getValue(DispenserBlock.FACING);
+ Position pos = config.positionFunction().getDispensePosition(pointer, facing);
- if (launch instanceof net.minecraft.world.entity.projectile.Projectile) {
- if (launch instanceof ThrowableProjectile) {
- ((ThrowableProjectile) launch).projectileSource = this;
- }
- // Values from DispenseBehaviorProjectile
- float a = 6.0F;
- float b = 1.1F;
- if (launch instanceof net.minecraft.world.entity.projectile.ThrownPotion || launch instanceof ThrownExpBottle) {
- // Values from respective DispenseBehavior classes
- a *= 0.5F;
- b *= 1.25F;
- }
- // Copied from DispenseBehaviorProjectile
- ((net.minecraft.world.entity.projectile.Projectile) launch).shoot((double) enumdirection.getStepX(), (double) ((float) enumdirection.getStepY() + 0.1F), (double) enumdirection.getStepZ(), b, a);
- }
+ net.minecraft.world.entity.projectile.Projectile launch = projectileItem.asProjectile(world, pos, new net.minecraft.world.item.ItemStack(item), facing);
+ // some projectile are not shoot and doesn't rely on the config for power/uncertainty
+ projectileItem.shoot(launch, facing.getStepX(), facing.getStepY(), facing.getStepZ(), config.power(), config.uncertainty());
+ launch.projectileSource = this;
+ // Paper end
- if (launch instanceof net.minecraft.world.entity.projectile.AbstractArrow arrow) {
+ if (false && launch instanceof net.minecraft.world.entity.projectile.AbstractArrow arrow) { // Paper - more projectile API - this is set by the respective ArrowItem when constructing the projectile
arrow.pickup = net.minecraft.world.entity.projectile.AbstractArrow.Pickup.ALLOWED;
}
launch.projectileSource = this;
@@ -0,0 +0,0 @@ public class CraftBlockProjectileSource implements BlockProjectileSource {
if (velocity != null) {
((T) launch.getBukkitEntity()).setVelocity(velocity);
}