Co-authored-by: Bjarne Koll <git@lynxplay.dev>
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
Co-authored-by: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com>
Co-authored-by: MiniDigger | Martin <admin@minidigger.dev>
Co-authored-by: Nassim Jahnke <nassim@njahnke.dev>
Co-authored-by: Noah van der Aa <ndvdaa@gmail.com>
Co-authored-by: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
Co-authored-by: Shane Freeder <theboyetronic@gmail.com>
Co-authored-by: Spottedleaf <Spottedleaf@users.noreply.github.com>
Co-authored-by: Tamion <70228790+notTamion@users.noreply.github.com>
Co-authored-by: Warrior <50800980+Warriorrrr@users.noreply.github.com>
This commit is contained in:
Nassim Jahnke
2025-04-12 17:26:44 +02:00
parent 0767902699
commit f00727c57e
2092 changed files with 50551 additions and 48729 deletions

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/item/EggItem.java
+++ b/net/minecraft/world/item/EggItem.java
@@ -23,22 +_,36 @@
@@ -23,22 +_,35 @@
@Override
public InteractionResult use(Level level, Player player, InteractionHand hand) {
ItemStack itemInHand = player.getItemInHand(hand);
@@ -14,19 +14,20 @@
- 0.5F,
- 0.4F / (level.getRandom().nextFloat() * 0.4F + 0.8F)
- );
if (level instanceof ServerLevel serverLevel) {
- Projectile.spawnProjectileFromRotation(ThrownEgg::new, serverLevel, itemInHand, player, 0.0F, PROJECTILE_SHOOT_POWER, 1.0F);
+ // CraftBukkit start
+ // Paper start - PlayerLaunchProjectileEvent
+ final Projectile.Delayed<ThrownEgg> thrownEgg = Projectile.spawnProjectileFromRotationDelayed(ThrownEgg::new, serverLevel, itemInHand, player, 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) player.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemInHand), (org.bukkit.entity.Projectile) thrownEgg.projectile().getBukkitEntity());
+ if (event.callEvent() && thrownEgg.attemptSpawn()) {
+ if (event.shouldConsume()) {
+ itemInHand.consume(1, player);
+ } else {
+ player.containerMenu.sendAllDataToRemote();
+ }
+ level.playSound(
- if (level instanceof ServerLevel serverLevel) {
- Projectile.spawnProjectileFromRotation(ThrownEgg::new, serverLevel, itemInHand, player, 0.0F, 1.5F, 1.0F);
- }
+ // Paper start
+ final Projectile.Delayed<ThrownEgg> thrownEgg = Projectile.spawnProjectileFromRotationDelayed(ThrownEgg::new, (ServerLevel) level, itemInHand, player, 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) player.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemInHand), (org.bukkit.entity.Projectile) thrownEgg.projectile().getBukkitEntity());
+ if (event.callEvent() && thrownEgg.attemptSpawn()) {
+ if (event.shouldConsume()) {
+ itemInHand.consume(1, player);
+ } else {
+ player.containerMenu.sendAllDataToRemote();
+ }
+ level.playSound(
+ // Paper end
+ null,
+ player.getX(),
+ player.getY(),
@@ -35,19 +36,18 @@
+ SoundSource.PLAYERS,
+ 0.5F,
+ 0.4F / (level.getRandom().nextFloat() * 0.4F + 0.8F)
+ );
+ player.awardStat(Stats.ITEM_USED.get(this));
+ } else {
+ // Paper end - PlayerLaunchProjectileEvent
+ player.containerMenu.sendAllDataToRemote();
+ return InteractionResult.FAIL;
+ }
+ // CraftBukkit end
}
-
+ );
+ // Paper - move up
- player.awardStat(Stats.ITEM_USED.get(this));
- itemInHand.consume(1, player);
+ // Paper - PlayerLaunchProjectileEvent - moved up
+ player.awardStat(Stats.ITEM_USED.get(this));
+ // Paper start
+ } else {
+ player.containerMenu.sendAllDataToRemote();
+ return InteractionResult.FAIL;
+ }
+ // CraftBukkit end
return InteractionResult.SUCCESS;
}