geforkt von Mirrors/Paper
PlayerLaunchProjectileEvent
Dieser Commit ist enthalten in:
Ursprung
a949eef7aa
Commit
925d397466
@ -29,10 +29,26 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,11 +219,34 @@
|
@@ -189,7 +197,12 @@
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static <T extends Projectile> T spawnProjectileFromRotation(Projectile.ProjectileFactory<T> creator, ServerLevel world, ItemStack projectileStack, LivingEntity shooter, float roll, float power, float divergence) {
|
||||||
|
- return Projectile.spawnProjectile(creator.create(world, shooter, projectileStack), world, projectileStack, (iprojectile) -> {
|
||||||
|
+ // Paper start - PlayerLaunchProjectileEvent
|
||||||
|
+ return spawnProjectileFromRotationDelayed(creator, world, projectileStack, shooter, roll, power, divergence).spawn();
|
||||||
|
+ }
|
||||||
|
+ public static <T extends Projectile> Delayed<T> spawnProjectileFromRotationDelayed(Projectile.ProjectileFactory<T> creator, ServerLevel world, ItemStack projectileStack, LivingEntity shooter, float roll, float power, float divergence) {
|
||||||
|
+ return Projectile.spawnProjectileDelayed(creator.create(world, shooter, projectileStack), world, projectileStack, (iprojectile) -> {
|
||||||
|
+ // Paper end - PlayerLaunchProjectileEvent
|
||||||
|
iprojectile.shootFromRotation(shooter, shooter.getXRot(), shooter.getYRot(), roll, power, divergence);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
@@ -209,13 +222,36 @@
|
||||||
|
public static <T extends Projectile> T spawnProjectile(T projectile, ServerLevel world, ItemStack projectileStack) {
|
||||||
|
return Projectile.spawnProjectile(projectile, world, projectileStack, (iprojectile) -> {
|
||||||
|
});
|
||||||
|
+ }
|
||||||
|
+
|
||||||
+ // Paper start - delayed projectile spawning
|
+ // Paper start - delayed projectile spawning
|
||||||
+ public record Delayed<T extends Projectile>(
|
+ public record Delayed<T extends Projectile>(
|
||||||
+ T projectile,
|
+ T projectile,
|
||||||
@ -50,9 +66,9 @@
|
|||||||
+ this.attemptSpawn();
|
+ this.attemptSpawn();
|
||||||
+ return projectile();
|
+ return projectile();
|
||||||
+ }
|
+ }
|
||||||
+ }
|
}
|
||||||
+ // Paper end - delayed projectile spawning
|
+ // Paper end - delayed projectile spawning
|
||||||
+
|
|
||||||
public static <T extends Projectile> T spawnProjectile(T projectile, ServerLevel world, ItemStack projectileStack, Consumer<T> beforeSpawn) {
|
public static <T extends Projectile> T spawnProjectile(T projectile, ServerLevel world, ItemStack projectileStack, Consumer<T> beforeSpawn) {
|
||||||
+ // Paper start - delayed projectile spawning
|
+ // Paper start - delayed projectile spawning
|
||||||
+ return spawnProjectileDelayed(projectile, world, projectileStack, beforeSpawn).spawn();
|
+ return spawnProjectileDelayed(projectile, world, projectileStack, beforeSpawn).spawn();
|
||||||
@ -67,7 +83,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void applyOnProjectileSpawned(ServerLevel world, ItemStack projectileStack) {
|
public void applyOnProjectileSpawned(ServerLevel world, ItemStack projectileStack) {
|
||||||
@@ -232,6 +263,17 @@
|
@@ -232,6 +268,17 @@
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,7 +101,7 @@
|
|||||||
protected ProjectileDeflection hitTargetOrDeflectSelf(HitResult hitResult) {
|
protected ProjectileDeflection hitTargetOrDeflectSelf(HitResult hitResult) {
|
||||||
if (hitResult.getType() == HitResult.Type.ENTITY) {
|
if (hitResult.getType() == HitResult.Type.ENTITY) {
|
||||||
EntityHitResult movingobjectpositionentity = (EntityHitResult) hitResult;
|
EntityHitResult movingobjectpositionentity = (EntityHitResult) hitResult;
|
||||||
@@ -309,6 +351,11 @@
|
@@ -309,6 +356,11 @@
|
||||||
protected void onHitEntity(EntityHitResult entityHitResult) {}
|
protected void onHitEntity(EntityHitResult entityHitResult) {}
|
||||||
|
|
||||||
protected void onHitBlock(BlockHitResult blockHitResult) {
|
protected void onHitBlock(BlockHitResult blockHitResult) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
--- a/net/minecraft/world/item/EggItem.java
|
--- a/net/minecraft/world/item/EggItem.java
|
||||||
+++ b/net/minecraft/world/item/EggItem.java
|
+++ b/net/minecraft/world/item/EggItem.java
|
||||||
@@ -25,10 +25,18 @@
|
@@ -25,13 +25,32 @@
|
||||||
public InteractionResult use(Level world, Player user, InteractionHand hand) {
|
public InteractionResult use(Level world, Player user, InteractionHand hand) {
|
||||||
ItemStack itemstack = user.getItemInHand(hand);
|
ItemStack itemstack = user.getItemInHand(hand);
|
||||||
|
|
||||||
@ -8,16 +8,33 @@
|
|||||||
+ // world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); // CraftBukkit - moved down
|
+ // world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); // CraftBukkit - moved down
|
||||||
if (world instanceof ServerLevel worldserver) {
|
if (world instanceof ServerLevel worldserver) {
|
||||||
- Projectile.spawnProjectileFromRotation(ThrownEgg::new, worldserver, itemstack, user, 0.0F, EggItem.PROJECTILE_SHOOT_POWER, 1.0F);
|
- Projectile.spawnProjectileFromRotation(ThrownEgg::new, worldserver, itemstack, user, 0.0F, EggItem.PROJECTILE_SHOOT_POWER, 1.0F);
|
||||||
|
- }
|
||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
+ if (Projectile.spawnProjectileFromRotation(ThrownEgg::new, worldserver, itemstack, user, 0.0F, EggItem.PROJECTILE_SHOOT_POWER, 1.0F).isRemoved()) {
|
+ // Paper start - PlayerLaunchProjectileEvent
|
||||||
|
+ final Projectile.Delayed<ThrownEgg> thrownEgg = Projectile.spawnProjectileFromRotationDelayed(ThrownEgg::new, worldserver, itemstack, user, 0.0F, EggItem.PROJECTILE_SHOOT_POWER, 1.0F);
|
||||||
|
+ com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) user.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack), (org.bukkit.entity.Projectile) thrownEgg.projectile().getBukkitEntity());
|
||||||
|
+ if (event.callEvent() && thrownEgg.attemptSpawn()) {
|
||||||
|
+ if (event.shouldConsume()) {
|
||||||
|
+ itemstack.consume(1, user);
|
||||||
|
+ } else if (user instanceof net.minecraft.server.level.ServerPlayer) {
|
||||||
|
+ ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory();
|
||||||
|
+ }
|
||||||
|
|
||||||
|
- user.awardStat(Stats.ITEM_USED.get(this));
|
||||||
|
- itemstack.consume(1, user);
|
||||||
|
+ world.playSound((Player) null, user.getX(), user.getY(), user.getZ(), SoundEvents.EGG_THROW, SoundSource.PLAYERS, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
|
||||||
|
+ user.awardStat(Stats.ITEM_USED.get(this));
|
||||||
|
+ } else {
|
||||||
|
+ // Paper end - PlayerLaunchProjectileEvent
|
||||||
+ if (user instanceof net.minecraft.server.level.ServerPlayer) {
|
+ if (user instanceof net.minecraft.server.level.ServerPlayer) {
|
||||||
+ ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory();
|
+ ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory();
|
||||||
+ }
|
+ }
|
||||||
+ return InteractionResult.FAIL;
|
+ return InteractionResult.FAIL;
|
||||||
+ }
|
+ }
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
}
|
+ }
|
||||||
+ world.playSound((Player) null, user.getX(), user.getY(), user.getZ(), SoundEvents.EGG_THROW, SoundSource.PLAYERS, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
|
+ world.playSound((Player) null, user.getX(), user.getY(), user.getZ(), SoundEvents.EGG_THROW, SoundSource.PLAYERS, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
|
||||||
|
+ // Paper - PlayerLaunchProjectileEvent - moved up
|
||||||
|
return InteractionResult.SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
user.awardStat(Stats.ITEM_USED.get(this));
|
|
||||||
itemstack.consume(1, user);
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
--- a/net/minecraft/world/item/EnderpearlItem.java
|
--- a/net/minecraft/world/item/EnderpearlItem.java
|
||||||
+++ b/net/minecraft/world/item/EnderpearlItem.java
|
+++ b/net/minecraft/world/item/EnderpearlItem.java
|
||||||
@@ -23,10 +23,17 @@
|
@@ -23,13 +23,32 @@
|
||||||
public InteractionResult use(Level world, Player user, InteractionHand hand) {
|
public InteractionResult use(Level world, Player user, InteractionHand hand) {
|
||||||
ItemStack itemstack = user.getItemInHand(hand);
|
ItemStack itemstack = user.getItemInHand(hand);
|
||||||
|
|
||||||
@ -8,7 +8,20 @@
|
|||||||
if (world instanceof ServerLevel worldserver) {
|
if (world instanceof ServerLevel worldserver) {
|
||||||
- Projectile.spawnProjectileFromRotation(ThrownEnderpearl::new, worldserver, itemstack, user, 0.0F, EnderpearlItem.PROJECTILE_SHOOT_POWER, 1.0F);
|
- Projectile.spawnProjectileFromRotation(ThrownEnderpearl::new, worldserver, itemstack, user, 0.0F, EnderpearlItem.PROJECTILE_SHOOT_POWER, 1.0F);
|
||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
+ if (Projectile.spawnProjectileFromRotation(ThrownEnderpearl::new, worldserver, itemstack, user, 0.0F, EnderpearlItem.PROJECTILE_SHOOT_POWER, 1.0F).isRemoved()) {
|
+ // Paper start - PlayerLaunchProjectileEvent
|
||||||
|
+ final Projectile.Delayed<ThrownEnderpearl> thrownEnderpearl = Projectile.spawnProjectileFromRotationDelayed(ThrownEnderpearl::new, worldserver, itemstack, user, 0.0F, EnderpearlItem.PROJECTILE_SHOOT_POWER, 1.0F);
|
||||||
|
+ com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) user.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack), (org.bukkit.entity.Projectile) thrownEnderpearl.projectile().getBukkitEntity());
|
||||||
|
+ if (event.callEvent() && thrownEnderpearl.attemptSpawn()) {
|
||||||
|
+ if (event.shouldConsume()) {
|
||||||
|
+ itemstack.consume(1, user);
|
||||||
|
+ } else if (user instanceof net.minecraft.server.level.ServerPlayer) {
|
||||||
|
+ ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ world.playSound((Player) null, user.getX(), user.getY(), user.getZ(), SoundEvents.ENDER_PEARL_THROW, SoundSource.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
|
||||||
|
+ user.awardStat(Stats.ITEM_USED.get(this));
|
||||||
|
+ } else {
|
||||||
|
+ // Paper end - PlayerLaunchProjectileEvent
|
||||||
+ if (user instanceof net.minecraft.server.level.ServerPlayer) {
|
+ if (user instanceof net.minecraft.server.level.ServerPlayer) {
|
||||||
+ ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory();
|
+ ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory();
|
||||||
+ }
|
+ }
|
||||||
@ -18,5 +31,9 @@
|
|||||||
+ world.playSound((Player) null, user.getX(), user.getY(), user.getZ(), SoundEvents.ENDER_PEARL_THROW, SoundSource.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
|
+ world.playSound((Player) null, user.getX(), user.getY(), user.getZ(), SoundEvents.ENDER_PEARL_THROW, SoundSource.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
|
|
||||||
user.awardStat(Stats.ITEM_USED.get(this));
|
- user.awardStat(Stats.ITEM_USED.get(this));
|
||||||
itemstack.consume(1, user);
|
- itemstack.consume(1, user);
|
||||||
|
+ // Paper - PlayerLaunchProjectileEvent - moved up
|
||||||
|
return InteractionResult.SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -0,0 +1,54 @@
|
|||||||
|
--- a/net/minecraft/world/item/ExperienceBottleItem.java
|
||||||
|
+++ b/net/minecraft/world/item/ExperienceBottleItem.java
|
||||||
|
@@ -21,22 +21,38 @@
|
||||||
|
@Override
|
||||||
|
public InteractionResult use(Level world, Player user, InteractionHand hand) {
|
||||||
|
ItemStack itemStack = user.getItemInHand(hand);
|
||||||
|
- world.playSound(
|
||||||
|
- null,
|
||||||
|
- user.getX(),
|
||||||
|
- user.getY(),
|
||||||
|
- user.getZ(),
|
||||||
|
- SoundEvents.EXPERIENCE_BOTTLE_THROW,
|
||||||
|
- SoundSource.NEUTRAL,
|
||||||
|
- 0.5F,
|
||||||
|
- 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)
|
||||||
|
- );
|
||||||
|
+ // Paper - PlayerLaunchProjectileEvent - moved down
|
||||||
|
if (world instanceof ServerLevel serverLevel) {
|
||||||
|
- Projectile.spawnProjectileFromRotation(ThrownExperienceBottle::new, serverLevel, itemStack, user, -20.0F, 0.7F, 1.0F);
|
||||||
|
+ // Paper start - PlayerLaunchProjectileEvent
|
||||||
|
+ final Projectile.Delayed<ThrownExperienceBottle> thrownExperienceBottle = Projectile.spawnProjectileFromRotationDelayed(ThrownExperienceBottle::new, serverLevel, itemStack, user, -20.0F, 0.7F, 1.0F);
|
||||||
|
+ com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) user.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemStack), (org.bukkit.entity.Projectile) thrownExperienceBottle.projectile().getBukkitEntity());
|
||||||
|
+ if (event.callEvent() && thrownExperienceBottle.attemptSpawn()) {
|
||||||
|
+ if (event.shouldConsume()) {
|
||||||
|
+ itemStack.consume(1, user);
|
||||||
|
+ } else if (user instanceof net.minecraft.server.level.ServerPlayer) {
|
||||||
|
+ ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ world.playSound(
|
||||||
|
+ null,
|
||||||
|
+ user.getX(),
|
||||||
|
+ user.getY(),
|
||||||
|
+ user.getZ(),
|
||||||
|
+ SoundEvents.EXPERIENCE_BOTTLE_THROW,
|
||||||
|
+ SoundSource.NEUTRAL,
|
||||||
|
+ 0.5F,
|
||||||
|
+ 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)
|
||||||
|
+ );
|
||||||
|
+ } else {
|
||||||
|
+ if (user instanceof net.minecraft.server.level.ServerPlayer) {
|
||||||
|
+ ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory();
|
||||||
|
+ }
|
||||||
|
+ return InteractionResult.FAIL;
|
||||||
|
+ }
|
||||||
|
+ // Paper end - PlayerLaunchProjectileEvent
|
||||||
|
}
|
||||||
|
|
||||||
|
- user.awardStat(Stats.ITEM_USED.get(this));
|
||||||
|
- itemStack.consume(1, user);
|
||||||
|
+ // Paper - PlayerLaunchProjectileEvent - moved up
|
||||||
|
return InteractionResult.SUCCESS;
|
||||||
|
}
|
||||||
|
|
@ -1,15 +1,32 @@
|
|||||||
--- a/net/minecraft/world/item/FireworkRocketItem.java
|
--- a/net/minecraft/world/item/FireworkRocketItem.java
|
||||||
+++ b/net/minecraft/world/item/FireworkRocketItem.java
|
+++ b/net/minecraft/world/item/FireworkRocketItem.java
|
||||||
@@ -43,7 +43,7 @@
|
@@ -33,7 +33,7 @@
|
||||||
|
ItemStack itemStack = context.getItemInHand();
|
||||||
|
Vec3 vec3 = context.getClickLocation();
|
||||||
|
Direction direction = context.getClickedFace();
|
||||||
|
- Projectile.spawnProjectile(
|
||||||
|
+ final Projectile.Delayed<FireworkRocketEntity> fireworkRocketEntity = Projectile.spawnProjectileDelayed( // Paper - PlayerLaunchProjectileEvent
|
||||||
|
new FireworkRocketEntity(
|
||||||
|
level,
|
||||||
|
context.getPlayer(),
|
||||||
|
@@ -43,9 +43,14 @@
|
||||||
itemStack
|
itemStack
|
||||||
),
|
),
|
||||||
serverLevel,
|
serverLevel,
|
||||||
- itemStack
|
- itemStack
|
||||||
+ itemStack, f -> f.spawningEntity = context.getPlayer() == null ? null : context.getPlayer().getUUID() // Paper - firework api - assign spawning entity uuid
|
+ itemStack, f -> f.spawningEntity = context.getPlayer() == null ? null : context.getPlayer().getUUID() // Paper - firework api - assign spawning entity uuid
|
||||||
);
|
);
|
||||||
itemStack.shrink(1);
|
- itemStack.shrink(1);
|
||||||
|
+ // Paper start - PlayerLaunchProjectileEvent
|
||||||
|
+ com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) context.getPlayer().getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemStack), (org.bukkit.entity.Firework) fireworkRocketEntity.projectile().getBukkitEntity());
|
||||||
|
+ if (!event.callEvent() || !fireworkRocketEntity.attemptSpawn()) return InteractionResult.PASS;
|
||||||
|
+ if (event.shouldConsume() && !context.getPlayer().hasInfiniteMaterials()) itemStack.shrink(1);
|
||||||
|
+ else if (context.getPlayer() instanceof net.minecraft.server.level.ServerPlayer) ((net.minecraft.server.level.ServerPlayer) context.getPlayer()).getBukkitEntity().updateInventory();
|
||||||
|
+ // Paper end - PlayerLaunchProjectileEvent
|
||||||
}
|
}
|
||||||
@@ -56,9 +56,19 @@
|
|
||||||
|
return InteractionResult.SUCCESS;
|
||||||
|
@@ -56,9 +61,19 @@
|
||||||
if (user.isFallFlying()) {
|
if (user.isFallFlying()) {
|
||||||
ItemStack itemStack = user.getItemInHand(hand);
|
ItemStack itemStack = user.getItemInHand(hand);
|
||||||
if (world instanceof ServerLevel serverLevel) {
|
if (world instanceof ServerLevel serverLevel) {
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
--- a/net/minecraft/world/item/LingeringPotionItem.java
|
||||||
|
+++ b/net/minecraft/world/item/LingeringPotionItem.java
|
||||||
|
@@ -24,6 +24,10 @@
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InteractionResult use(Level world, Player user, InteractionHand hand) {
|
||||||
|
+ // Paper start - PlayerLaunchProjectileEvent
|
||||||
|
+ final InteractionResult wrapper = super.use(world, user, hand);
|
||||||
|
+ if (wrapper instanceof InteractionResult.Fail) return wrapper;
|
||||||
|
+ // Paper end - PlayerLaunchProjectileEvent
|
||||||
|
world.playSound(
|
||||||
|
null,
|
||||||
|
user.getX(),
|
||||||
|
@@ -34,6 +38,6 @@
|
||||||
|
0.5F,
|
||||||
|
0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)
|
||||||
|
);
|
||||||
|
- return super.use(world, user, hand);
|
||||||
|
+ return wrapper; // Paper - PlayerLaunchProjectileEvent
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
--- a/net/minecraft/world/item/SnowballItem.java
|
--- a/net/minecraft/world/item/SnowballItem.java
|
||||||
+++ b/net/minecraft/world/item/SnowballItem.java
|
+++ b/net/minecraft/world/item/SnowballItem.java
|
||||||
@@ -25,13 +25,21 @@
|
@@ -25,13 +25,30 @@
|
||||||
public InteractionResult use(Level world, Player user, InteractionHand hand) {
|
public InteractionResult use(Level world, Player user, InteractionHand hand) {
|
||||||
ItemStack itemstack = user.getItemInHand(hand);
|
ItemStack itemstack = user.getItemInHand(hand);
|
||||||
|
|
||||||
@ -9,18 +9,28 @@
|
|||||||
+ // world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
|
+ // world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
|
||||||
if (world instanceof ServerLevel worldserver) {
|
if (world instanceof ServerLevel worldserver) {
|
||||||
- Projectile.spawnProjectileFromRotation(Snowball::new, worldserver, itemstack, user, 0.0F, SnowballItem.PROJECTILE_SHOOT_POWER, 1.0F);
|
- Projectile.spawnProjectileFromRotation(Snowball::new, worldserver, itemstack, user, 0.0F, SnowballItem.PROJECTILE_SHOOT_POWER, 1.0F);
|
||||||
+ if (Projectile.spawnProjectileFromRotation(Snowball::new, worldserver, itemstack, user, 0.0F, SnowballItem.PROJECTILE_SHOOT_POWER, 1.0F).isAlive()) {
|
+ // Paper start - PlayerLaunchProjectileEvent
|
||||||
+ itemstack.consume(1, user);
|
+ final Projectile.Delayed<Snowball> snowball = Projectile.spawnProjectileFromRotationDelayed(Snowball::new, worldserver, itemstack, user, 0.0F, SnowballItem.PROJECTILE_SHOOT_POWER, 1.0F);
|
||||||
|
+ com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) user.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack), (org.bukkit.entity.Projectile) snowball.projectile().getBukkitEntity());
|
||||||
|
+ if (event.callEvent() && snowball.attemptSpawn()) {
|
||||||
|
+ user.awardStat(Stats.ITEM_USED.get(this));
|
||||||
|
+ if (event.shouldConsume()) {
|
||||||
|
+ itemstack.consume(1, user);
|
||||||
|
+ } else if (user instanceof net.minecraft.server.level.ServerPlayer) {
|
||||||
|
+ ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory();
|
||||||
|
+ }
|
||||||
|
+ // Paper end - PlayerLaunchProjectileEvent
|
||||||
+
|
+
|
||||||
+ world.playSound((Player) null, user.getX(), user.getY(), user.getZ(), SoundEvents.SNOWBALL_THROW, SoundSource.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
|
+ world.playSound((Player) null, user.getX(), user.getY(), user.getZ(), SoundEvents.SNOWBALL_THROW, SoundSource.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
|
||||||
+ } else if (user instanceof net.minecraft.server.level.ServerPlayer) {
|
+ } else { if (user instanceof net.minecraft.server.level.ServerPlayer) { // Paper - PlayerLaunchProjectileEvent - return fail
|
||||||
+ ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory();
|
+ ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory();
|
||||||
+ }
|
+ } return InteractionResult.FAIL; } // Paper - PlayerLaunchProjectileEvent - return fail
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
}
|
}
|
||||||
|
|
||||||
user.awardStat(Stats.ITEM_USED.get(this));
|
- user.awardStat(Stats.ITEM_USED.get(this));
|
||||||
- itemstack.consume(1, user);
|
- itemstack.consume(1, user);
|
||||||
|
+ // Paper - PlayerLaunchProjectileEvent - moved up
|
||||||
+ // itemstack.consume(1, entityhuman); // CraftBukkit - moved up
|
+ // itemstack.consume(1, entityhuman); // CraftBukkit - moved up
|
||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
--- a/net/minecraft/world/item/SplashPotionItem.java
|
||||||
|
+++ b/net/minecraft/world/item/SplashPotionItem.java
|
||||||
|
@@ -14,6 +14,10 @@
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InteractionResult use(Level world, Player user, InteractionHand hand) {
|
||||||
|
+ // Paper start - PlayerLaunchProjectileEvent
|
||||||
|
+ final InteractionResult wrapper = super.use(world, user, hand);
|
||||||
|
+ if (wrapper instanceof InteractionResult.Fail) return wrapper;
|
||||||
|
+ // Paper end - PlayerLaunchProjectileEvent
|
||||||
|
world.playSound(
|
||||||
|
null,
|
||||||
|
user.getX(),
|
||||||
|
@@ -24,6 +28,6 @@
|
||||||
|
0.5F,
|
||||||
|
0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)
|
||||||
|
);
|
||||||
|
- return super.use(world, user, hand);
|
||||||
|
+ return wrapper; // Paper - PlayerLaunchProjectileEvent
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
--- a/net/minecraft/world/item/ThrowablePotionItem.java
|
||||||
|
+++ b/net/minecraft/world/item/ThrowablePotionItem.java
|
||||||
|
@@ -22,11 +22,28 @@
|
||||||
|
public InteractionResult use(Level world, Player user, InteractionHand hand) {
|
||||||
|
ItemStack itemStack = user.getItemInHand(hand);
|
||||||
|
if (world instanceof ServerLevel serverLevel) {
|
||||||
|
- Projectile.spawnProjectileFromRotation(ThrownPotion::new, serverLevel, itemStack, user, -20.0F, PROJECTILE_SHOOT_POWER, 1.0F);
|
||||||
|
+ // Paper start - PlayerLaunchProjectileEvent
|
||||||
|
+ final Projectile.Delayed<ThrownPotion> thrownPotion = Projectile.spawnProjectileFromRotationDelayed(ThrownPotion::new, serverLevel, itemStack, user, -20.0F, PROJECTILE_SHOOT_POWER, 1.0F);
|
||||||
|
+ // Paper start - PlayerLaunchProjectileEvent
|
||||||
|
+ com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) user.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemStack), (org.bukkit.entity.Projectile) thrownPotion.projectile().getBukkitEntity());
|
||||||
|
+ if (event.callEvent() && thrownPotion.attemptSpawn()) {
|
||||||
|
+ if (event.shouldConsume()) {
|
||||||
|
+ itemStack.consume(1, user);
|
||||||
|
+ } else if (user instanceof net.minecraft.server.level.ServerPlayer) {
|
||||||
|
+ ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ user.awardStat(Stats.ITEM_USED.get(this));
|
||||||
|
+ } else {
|
||||||
|
+ if (user instanceof net.minecraft.server.level.ServerPlayer) {
|
||||||
|
+ ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory();
|
||||||
|
+ }
|
||||||
|
+ return InteractionResult.FAIL;
|
||||||
|
+ }
|
||||||
|
+ // Paper end - PlayerLaunchProjectileEvent
|
||||||
|
}
|
||||||
|
|
||||||
|
- user.awardStat(Stats.ITEM_USED.get(this));
|
||||||
|
- itemStack.consume(1, user);
|
||||||
|
+ // Paper - PlayerLaunchProjectileEvent - move up
|
||||||
|
return InteractionResult.SUCCESS;
|
||||||
|
}
|
||||||
|
|
@ -1,27 +1,36 @@
|
|||||||
--- a/net/minecraft/world/item/TridentItem.java
|
--- a/net/minecraft/world/item/TridentItem.java
|
||||||
+++ b/net/minecraft/world/item/TridentItem.java
|
+++ b/net/minecraft/world/item/TridentItem.java
|
||||||
@@ -86,9 +86,19 @@
|
@@ -86,18 +86,37 @@
|
||||||
if (world instanceof ServerLevel) {
|
if (world instanceof ServerLevel) {
|
||||||
ServerLevel worldserver = (ServerLevel) world;
|
ServerLevel worldserver = (ServerLevel) world;
|
||||||
|
|
||||||
- stack.hurtWithoutBreaking(1, entityhuman);
|
- stack.hurtWithoutBreaking(1, entityhuman);
|
||||||
+ // itemstack.hurtWithoutBreaking(1, entityhuman); // CraftBukkit - moved down
|
+ // itemstack.hurtWithoutBreaking(1, entityhuman); // CraftBukkit - moved down
|
||||||
if (f == 0.0F) {
|
if (f == 0.0F) {
|
||||||
ThrownTrident entitythrowntrident = (ThrownTrident) Projectile.spawnProjectileFromRotation(ThrownTrident::new, worldserver, stack, entityhuman, 0.0F, 2.5F, 1.0F);
|
- ThrownTrident entitythrowntrident = (ThrownTrident) Projectile.spawnProjectileFromRotation(ThrownTrident::new, worldserver, stack, entityhuman, 0.0F, 2.5F, 1.0F);
|
||||||
+ // CraftBukkit start
|
+ // Paper start - PlayerLaunchProjectileEvent
|
||||||
+ if (entitythrowntrident.isRemoved()) {
|
+ Projectile.Delayed<ThrownTrident> tridentDelayed = Projectile.spawnProjectileFromRotationDelayed(ThrownTrident::new, worldserver, stack, entityhuman, 0.0F, 2.5F, 1.0F);
|
||||||
|
+ // Paper start - PlayerLaunchProjectileEvent
|
||||||
|
+ com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(stack), (org.bukkit.entity.Projectile) tridentDelayed.projectile().getBukkitEntity());
|
||||||
|
+ if (!event.callEvent() || !tridentDelayed.attemptSpawn()) {
|
||||||
|
+ // CraftBukkit start
|
||||||
|
+ // Paper end - PlayerLaunchProjectileEvent
|
||||||
+ if (entityhuman instanceof net.minecraft.server.level.ServerPlayer) {
|
+ if (entityhuman instanceof net.minecraft.server.level.ServerPlayer) {
|
||||||
+ ((net.minecraft.server.level.ServerPlayer) entityhuman).getBukkitEntity().updateInventory();
|
+ ((net.minecraft.server.level.ServerPlayer) entityhuman).getBukkitEntity().updateInventory();
|
||||||
+ }
|
+ }
|
||||||
+ return false;
|
+ return false;
|
||||||
+ }
|
+ }
|
||||||
+ stack.hurtWithoutBreaking(1, entityhuman);
|
+ ThrownTrident entitythrowntrident = tridentDelayed.projectile(); // Paper - PlayerLaunchProjectileEvent
|
||||||
|
+ if (event.shouldConsume()) stack.hurtWithoutBreaking(1, entityhuman); // Paper - PlayerLaunchProjectileEvent
|
||||||
+ entitythrowntrident.pickupItemStack = stack.copy(); // SPIGOT-4511 update since damage call moved
|
+ entitythrowntrident.pickupItemStack = stack.copy(); // SPIGOT-4511 update since damage call moved
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
|
|
||||||
if (entityhuman.hasInfiniteMaterials()) {
|
if (entityhuman.hasInfiniteMaterials()) {
|
||||||
entitythrowntrident.pickup = AbstractArrow.Pickup.CREATIVE_ONLY;
|
entitythrowntrident.pickup = AbstractArrow.Pickup.CREATIVE_ONLY;
|
||||||
@@ -98,6 +108,10 @@
|
- } else {
|
||||||
|
+ } else if (event.shouldConsume()) { // Paper - PlayerLaunchProjectileEvent
|
||||||
|
entityhuman.getInventory().removeItem(stack);
|
||||||
|
}
|
||||||
|
|
||||||
world.playSound((Player) null, (Entity) entitythrowntrident, (SoundEvent) holder.value(), SoundSource.PLAYERS, 1.0F, 1.0F);
|
world.playSound((Player) null, (Entity) entitythrowntrident, (SoundEvent) holder.value(), SoundSource.PLAYERS, 1.0F, 1.0F);
|
||||||
return true;
|
return true;
|
||||||
@ -32,7 +41,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,6 +126,7 @@
|
@@ -112,6 +131,7 @@
|
||||||
f3 *= f / f6;
|
f3 *= f / f6;
|
||||||
f4 *= f / f6;
|
f4 *= f / f6;
|
||||||
f5 *= f / f6;
|
f5 *= f / f6;
|
||||||
|
@ -0,0 +1,42 @@
|
|||||||
|
--- a/net/minecraft/world/item/WindChargeItem.java
|
||||||
|
+++ b/net/minecraft/world/item/WindChargeItem.java
|
||||||
|
@@ -27,7 +27,7 @@
|
||||||
|
public InteractionResult use(Level world, Player user, InteractionHand hand) {
|
||||||
|
ItemStack itemStack = user.getItemInHand(hand);
|
||||||
|
if (world instanceof ServerLevel serverLevel) {
|
||||||
|
- Projectile.spawnProjectileFromRotation(
|
||||||
|
+ final Projectile.Delayed<WindCharge> windCharge = Projectile.spawnProjectileFromRotationDelayed( // Paper - PlayerLaunchProjectileEvent
|
||||||
|
(world2, shooter, stack) -> new WindCharge(user, world, user.position().x(), user.getEyePosition().y(), user.position().z()),
|
||||||
|
serverLevel,
|
||||||
|
itemStack,
|
||||||
|
@@ -36,6 +36,21 @@
|
||||||
|
PROJECTILE_SHOOT_POWER,
|
||||||
|
1.0F
|
||||||
|
);
|
||||||
|
+ com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) user.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemStack), (org.bukkit.entity.Projectile) windCharge.projectile().getBukkitEntity());
|
||||||
|
+ if (!event.callEvent() || !windCharge.attemptSpawn()) {
|
||||||
|
+ user.containerMenu.sendAllDataToRemote();
|
||||||
|
+ if (user instanceof net.minecraft.server.level.ServerPlayer player) {
|
||||||
|
+ player.connection.send(new net.minecraft.network.protocol.game.ClientboundCooldownPacket(user.getCooldowns().getCooldownGroup(itemStack), 0)); // prevent visual desync of cooldown on the slot
|
||||||
|
+ }
|
||||||
|
+ return InteractionResult.FAIL;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ user.awardStat(Stats.ITEM_USED.get(this));
|
||||||
|
+ if (event.shouldConsume()) itemStack.consume(1, user);
|
||||||
|
+ else if (!user.hasInfiniteMaterials()) {
|
||||||
|
+ user.containerMenu.sendAllDataToRemote();
|
||||||
|
+ }
|
||||||
|
+ // Paper end - PlayerLaunchProjectileEvent
|
||||||
|
}
|
||||||
|
|
||||||
|
world.playSound(
|
||||||
|
@@ -48,8 +63,6 @@
|
||||||
|
0.5F,
|
||||||
|
0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)
|
||||||
|
);
|
||||||
|
- user.awardStat(Stats.ITEM_USED.get(this));
|
||||||
|
- itemStack.consume(1, user);
|
||||||
|
return InteractionResult.SUCCESS;
|
||||||
|
}
|
||||||
|
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren