1
0
Fork 0
mirror of https://github.com/PaperMC/Paper.git synced 2025-01-31 03:50:36 +01:00

Restrict BlockProjectileSource#launchProjectile

Spigot recently revamped their CraftBlockProjectileSource impl to make use of
the the ProjectileItem logic. During this move however, a couple of types were
added which do not provide a sensible ProjectileItem implementation.

The commit restricts the API once again to types that represent useful
ProjectileItems, removing support for the trident, enderpearl and breeze variant
of the windcharge.
This commit is contained in:
Lulu13022002 2024-10-21 18:17:45 +02:00
parent 5912598c02
commit 33ff3dff21

View file

@ -12,7 +12,7 @@ public net.minecraft.world.entity.projectile.ShulkerBullet targetDeltaZ
public net.minecraft.world.entity.projectile.ShulkerBullet currentMoveDirection
public net.minecraft.world.entity.projectile.ShulkerBullet flightSteps
public net.minecraft.world.entity.projectile.AbstractArrow soundEvent
public net/minecraft/world/entity/projectile/AbstractArrow setPickupItemStack(Lnet/minecraft/world/item/ItemStack;)V
public net.minecraft.world.entity.projectile.AbstractArrow setPickupItemStack(Lnet/minecraft/world/item/ItemStack;)V
public net.minecraft.world.entity.projectile.ThrownTrident dealtDamage
public net.minecraft.world.entity.projectile.Arrow NO_EFFECT_COLOR
public net.minecraft.world.entity.projectile.Projectile hasBeenShot
@ -864,14 +864,39 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
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 {
item = Items.SNOWBALL;
} else if (Egg.class.isAssignableFrom(projectile)) {
item = Items.EGG;
- } else if (EnderPearl.class.isAssignableFrom(projectile)) {
+ } else if (false && EnderPearl.class.isAssignableFrom(projectile)) { // Paper - more projectile API - disallow enderpearl, it is not a projectile item
item = Items.ENDER_PEARL;
} else if (ThrownExpBottle.class.isAssignableFrom(projectile)) {
item = Items.EXPERIENCE_BOTTLE;
@@ -0,0 +0,0 @@ public class CraftBlockProjectileSource implements BlockProjectileSource {
item = Items.TIPPED_ARROW;
} else if (SpectralArrow.class.isAssignableFrom(projectile)) {
item = Items.SPECTRAL_ARROW;
- } else {
+ } else if (org.bukkit.entity.Arrow.class.isAssignableFrom(projectile)) { // Paper - more projectile API - disallow trident
item = Items.ARROW;
}
} else if (Fireball.class.isAssignableFrom(projectile)) {
if (AbstractWindCharge.class.isAssignableFrom(projectile)) {
- if (AbstractWindCharge.class.isAssignableFrom(projectile)) {
+ if (org.bukkit.entity.WindCharge.class.isAssignableFrom(projectile)) { // Paper - more projectile API - only allow wind charge not breeze wind charge
item = Items.WIND_CHARGE;
- } else {
+ } else if (org.bukkit.entity.SmallFireball.class.isAssignableFrom(projectile)) { // Paper - more projectile API - only allow firing fire charges.
item = Items.FIRE_CHARGE;
}
} else if (Firework.class.isAssignableFrom(projectile)) {
item = Items.FIREWORK_ROCKET;
}
- Preconditions.checkArgument(item instanceof ProjectileItem, "Projectile not supported");
+ Preconditions.checkArgument(item instanceof ProjectileItem, "Projectile '%s' not supported", projectile.getSimpleName()); // Paper - more projectile API - include simple name in exception
ItemStack itemstack = new ItemStack(item);
ProjectileItem projectileItem = (ProjectileItem) item;
@@ -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);