geforkt von Mirrors/Paper
Update projectile launch to 1.21.2
Dieser Commit ist enthalten in:
Ursprung
25c384ac38
Commit
5a3a8af328
75
patches/server/PlayerElytraBoostEvent.patch
Normale Datei
75
patches/server/PlayerElytraBoostEvent.patch
Normale Datei
@ -0,0 +1,75 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: BillyGalbreath <Blake.Galbreath@GMail.com>
|
||||||
|
Date: Sat, 21 Jul 2018 01:59:59 -0500
|
||||||
|
Subject: [PATCH] PlayerElytraBoostEvent
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
|
||||||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
|
||||||
|
@@ -0,0 +0,0 @@ public abstract class Projectile extends Entity implements TraceableEntity {
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Paper start - delayed projectile spawning
|
||||||
|
+ public record Delayed<T extends Projectile>(
|
||||||
|
+ T projectile,
|
||||||
|
+ ServerLevel world,
|
||||||
|
+ ItemStack projectileStack
|
||||||
|
+ ) {
|
||||||
|
+ // Taken from net.minecraft.world.entity.projectile.Projectile.spawnProjectile(T, net.minecraft.server.level.ServerLevel, net.minecraft.world.item.ItemStack, java.util.function.Consumer<T>)
|
||||||
|
+ public boolean attemptSpawn() {
|
||||||
|
+ if (!world.addFreshEntity(projectile)) return false;
|
||||||
|
+ projectile.applyOnProjectileSpawned(this.world, this.projectileStack);
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public T spawn() {
|
||||||
|
+ this.attemptSpawn();
|
||||||
|
+ return projectile();
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ // Paper end - delayed projectile spawning
|
||||||
|
+
|
||||||
|
public static <T extends Projectile> T spawnProjectile(T projectile, ServerLevel world, ItemStack projectileStack, Consumer<T> beforeSpawn) {
|
||||||
|
+ // Paper start - delayed projectile spawning
|
||||||
|
+ return spawnProjectileDelayed(projectile, world, projectileStack, beforeSpawn).spawn();
|
||||||
|
+ }
|
||||||
|
+ public static <T extends Projectile> Delayed<T> spawnProjectileDelayed(T projectile, ServerLevel world, ItemStack projectileStack, Consumer<T> beforeSpawn) {
|
||||||
|
+ // Paper end - delayed projectile spawning
|
||||||
|
beforeSpawn.accept(projectile);
|
||||||
|
- if (world.addFreshEntity(projectile)) // CraftBukkit
|
||||||
|
- projectile.applyOnProjectileSpawned(world, projectileStack);
|
||||||
|
- return projectile;
|
||||||
|
+ return new Delayed<>(projectile, world, projectileStack); // Paper - delayed projectile spawning
|
||||||
|
}
|
||||||
|
|
||||||
|
public void applyOnProjectileSpawned(ServerLevel world, ItemStack projectileStack) {
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/item/FireworkRocketItem.java b/src/main/java/net/minecraft/world/item/FireworkRocketItem.java
|
||||||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/item/FireworkRocketItem.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/item/FireworkRocketItem.java
|
||||||
|
@@ -0,0 +0,0 @@ public class FireworkRocketItem extends Item implements ProjectileItem {
|
||||||
|
if (user.isFallFlying()) {
|
||||||
|
ItemStack itemStack = user.getItemInHand(hand);
|
||||||
|
if (world instanceof ServerLevel serverLevel) {
|
||||||
|
- Projectile.spawnProjectile(new FireworkRocketEntity(world, itemStack, user), serverLevel, itemStack, f -> f.spawningEntity = user.getUUID()); // Paper - firework api - assign spawning entity uuid
|
||||||
|
- itemStack.consume(1, user);
|
||||||
|
- user.awardStat(Stats.ITEM_USED.get(this));
|
||||||
|
+ // Paper start - PlayerElytraBoostEvent
|
||||||
|
+ final Projectile.Delayed<FireworkRocketEntity> delayed = Projectile.spawnProjectileDelayed(new FireworkRocketEntity(world, itemStack, user), serverLevel, itemStack, f -> f.spawningEntity = user.getUUID()); // Paper - firework api - assign spawning entity uuid
|
||||||
|
+ com.destroystokyo.paper.event.player.PlayerElytraBoostEvent event = new com.destroystokyo.paper.event.player.PlayerElytraBoostEvent((org.bukkit.entity.Player) user.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemStack), (org.bukkit.entity.Firework) delayed.projectile().getBukkitEntity(), org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(hand));
|
||||||
|
+ if (event.callEvent() && delayed.attemptSpawn()) {
|
||||||
|
+ user.awardStat(Stats.ITEM_USED.get(this)); // Moved up from below
|
||||||
|
+ if (event.shouldConsume() && !user.hasInfiniteMaterials()) {
|
||||||
|
+ itemStack.shrink(1); // Moved up from below
|
||||||
|
+ } else ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory();
|
||||||
|
+ } else {
|
||||||
|
+ ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory();
|
||||||
|
+ }
|
||||||
|
+ // Moved up consume/stat
|
||||||
|
+ // Paper end - PlayerElytraBoostEvent
|
||||||
|
}
|
||||||
|
|
||||||
|
return InteractionResult.SUCCESS;
|
@ -4,43 +4,58 @@ Date: Sat, 21 Jul 2018 03:11:03 -0500
|
|||||||
Subject: [PATCH] PlayerLaunchProjectileEvent
|
Subject: [PATCH] PlayerLaunchProjectileEvent
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
|
||||||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
|
||||||
|
@@ -0,0 +0,0 @@ public abstract class Projectile extends Entity implements TraceableEntity {
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
}
|
||||||
diff --git a/src/main/java/net/minecraft/world/item/EggItem.java b/src/main/java/net/minecraft/world/item/EggItem.java
|
diff --git a/src/main/java/net/minecraft/world/item/EggItem.java b/src/main/java/net/minecraft/world/item/EggItem.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/world/item/EggItem.java
|
--- a/src/main/java/net/minecraft/world/item/EggItem.java
|
||||||
+++ b/src/main/java/net/minecraft/world/item/EggItem.java
|
+++ b/src/main/java/net/minecraft/world/item/EggItem.java
|
||||||
@@ -0,0 +0,0 @@ public class EggItem extends Item implements ProjectileItem {
|
@@ -0,0 +0,0 @@ public class EggItem extends Item implements ProjectileItem {
|
||||||
|
// 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
|
||||||
entityegg.setItem(itemstack);
|
if (world instanceof ServerLevel worldserver) {
|
||||||
entityegg.shootFromRotation(user, user.getXRot(), user.getYRot(), 0.0F, 1.5F, 1.0F);
|
// CraftBukkit start
|
||||||
- // CraftBukkit start
|
- if (Projectile.spawnProjectileFromRotation(ThrownEgg::new, worldserver, itemstack, user, 0.0F, 1.5F, 1.0F).isRemoved()) {
|
||||||
- if (!world.addFreshEntity(entityegg)) {
|
|
||||||
+ // Paper start - PlayerLaunchProjectileEvent
|
+ // 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) entityegg.getBukkitEntity());
|
+ final Projectile.Delayed<ThrownEgg> thrownEgg = Projectile.spawnProjectileFromRotationDelayed(ThrownEgg::new, worldserver, itemstack, user, 0.0F, 1.5F, 1.0F);
|
||||||
+ if (event.callEvent() && world.addFreshEntity(entityegg)) {
|
+ 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()) {
|
+ if (event.shouldConsume()) {
|
||||||
+ itemstack.consume(1, user);
|
+ itemstack.consume(1, user);
|
||||||
+ } else if (user instanceof net.minecraft.server.level.ServerPlayer) {
|
+ } else if (user instanceof net.minecraft.server.level.ServerPlayer) {
|
||||||
+ ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory();
|
+ ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory();
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ world.playSound((Player) null, user.getX(), user.getY(), user.getZ(), net.minecraft.sounds.SoundEvents.EGG_THROW, net.minecraft.sounds.SoundSource.PLAYERS, 0.5F, 0.4F / (net.minecraft.world.entity.Entity.SHARED_RANDOM.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));
|
||||||
+ user.awardStat(Stats.ITEM_USED.get(this));
|
+ user.awardStat(Stats.ITEM_USED.get(this));
|
||||||
+ } else {
|
+ } else {
|
||||||
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 InteractionResultHolder.fail(itemstack);
|
@@ -0,0 +0,0 @@ public class EggItem extends Item implements ProjectileItem {
|
||||||
}
|
// CraftBukkit end
|
||||||
- // CraftBukkit end
|
|
||||||
+ // Paper end - PlayerLaunchProjectileEvent
|
|
||||||
}
|
}
|
||||||
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 start - PlayerLaunchProjectileEvent; moved up
|
- 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
|
||||||
+ */ // Paper end - PlayerLaunchProjectileEvent
|
return InteractionResult.SUCCESS;
|
||||||
return InteractionResultHolder.sidedSuccess(itemstack, world.isClientSide());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/item/EnderpearlItem.java b/src/main/java/net/minecraft/world/item/EnderpearlItem.java
|
diff --git a/src/main/java/net/minecraft/world/item/EnderpearlItem.java b/src/main/java/net/minecraft/world/item/EnderpearlItem.java
|
||||||
@ -49,39 +64,34 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+++ b/src/main/java/net/minecraft/world/item/EnderpearlItem.java
|
+++ b/src/main/java/net/minecraft/world/item/EnderpearlItem.java
|
||||||
@@ -0,0 +0,0 @@ public class EnderpearlItem extends Item {
|
@@ -0,0 +0,0 @@ public class EnderpearlItem extends Item {
|
||||||
|
|
||||||
entityenderpearl.setItem(itemstack);
|
if (world instanceof ServerLevel worldserver) {
|
||||||
entityenderpearl.shootFromRotation(user, user.getXRot(), user.getYRot(), 0.0F, 1.5F, 1.0F);
|
// CraftBukkit start
|
||||||
- if (!world.addFreshEntity(entityenderpearl)) {
|
- if (Projectile.spawnProjectileFromRotation(ThrownEnderpearl::new, worldserver, itemstack, user, 0.0F, 1.5F, 1.0F).isRemoved()) {
|
||||||
+ // Paper start - PlayerLaunchProjectileEvent
|
+ // 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) entityenderpearl.getBukkitEntity());
|
+ final Projectile.Delayed<ThrownEnderpearl> thrownEnderpearl = Projectile.spawnProjectileFromRotationDelayed(ThrownEnderpearl::new, worldserver, itemstack, user, 0.0F, 1.5F, 1.0F);
|
||||||
+ if (event.callEvent() && world.addFreshEntity(entityenderpearl)) {
|
+ 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()) {
|
+ if (event.shouldConsume()) {
|
||||||
+ itemstack.consume(1, user);
|
+ itemstack.consume(1, user);
|
||||||
+ } else if (user instanceof net.minecraft.server.level.ServerPlayer) {
|
+ } else if (user instanceof net.minecraft.server.level.ServerPlayer) {
|
||||||
+ ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory();
|
+ ((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 / (net.minecraft.world.entity.Entity.SHARED_RANDOM.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));
|
||||||
+ user.awardStat(Stats.ITEM_USED.get(this));
|
+ user.awardStat(Stats.ITEM_USED.get(this));
|
||||||
+ user.getCooldowns().addCooldown(this, 20);
|
|
||||||
+ } else {
|
+ } else {
|
||||||
+ // Paper end - PlayerLaunchProjectileEvent
|
+ // 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();
|
||||||
}
|
}
|
||||||
@@ -0,0 +0,0 @@ public class EnderpearlItem extends Item {
|
@@ -0,0 +0,0 @@ public class EnderpearlItem extends Item {
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
+ /* // Paper start - PlayerLaunchProjectileEvent; moved up
|
|
||||||
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));
|
||||||
user.getCooldowns().addCooldown(this, 20);
|
|
||||||
// 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 end - PlayerLaunchProjectileEvent; moved up
|
+ // Paper - PlayerLaunchProjectileEvent - moved up
|
||||||
return InteractionResultHolder.sidedSuccess(itemstack, world.isClientSide());
|
return InteractionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/net/minecraft/world/item/ExperienceBottleItem.java b/src/main/java/net/minecraft/world/item/ExperienceBottleItem.java
|
diff --git a/src/main/java/net/minecraft/world/item/ExperienceBottleItem.java b/src/main/java/net/minecraft/world/item/ExperienceBottleItem.java
|
||||||
@ -90,7 +100,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+++ b/src/main/java/net/minecraft/world/item/ExperienceBottleItem.java
|
+++ b/src/main/java/net/minecraft/world/item/ExperienceBottleItem.java
|
||||||
@@ -0,0 +0,0 @@ public class ExperienceBottleItem extends Item implements ProjectileItem {
|
@@ -0,0 +0,0 @@ public class ExperienceBottleItem extends Item implements ProjectileItem {
|
||||||
@Override
|
@Override
|
||||||
public InteractionResultHolder<ItemStack> 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);
|
||||||
- world.playSound(
|
- world.playSound(
|
||||||
- null,
|
- null,
|
||||||
@ -102,15 +112,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
- 0.5F,
|
- 0.5F,
|
||||||
- 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)
|
- 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)
|
||||||
- );
|
- );
|
||||||
+ // Paper - PlayerLaunchProjectileEvent; moved down
|
+ // Paper - PlayerLaunchProjectileEvent - moved down
|
||||||
if (!world.isClientSide) {
|
if (world instanceof ServerLevel serverLevel) {
|
||||||
ThrownExperienceBottle thrownExperienceBottle = new ThrownExperienceBottle(world, user);
|
- Projectile.spawnProjectileFromRotation(ThrownExperienceBottle::new, serverLevel, itemStack, user, -20.0F, 0.7F, 1.0F);
|
||||||
thrownExperienceBottle.setItem(itemStack);
|
|
||||||
thrownExperienceBottle.shootFromRotation(user, user.getXRot(), user.getYRot(), -20.0F, 0.7F, 1.0F);
|
|
||||||
- world.addFreshEntity(thrownExperienceBottle);
|
|
||||||
+ // Paper start - PlayerLaunchProjectileEvent
|
+ // 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) thrownExperienceBottle.getBukkitEntity());
|
+ final Projectile.Delayed<ThrownExperienceBottle> thrownExperienceBottle = Projectile.spawnProjectileFromRotationDelayed(ThrownExperienceBottle::new, serverLevel, itemStack, user, -20.0F, 0.7F, 1.0F);
|
||||||
+ if (event.callEvent() && world.addFreshEntity(thrownExperienceBottle)) {
|
+ 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()) {
|
+ if (event.shouldConsume()) {
|
||||||
+ itemStack.consume(1, user);
|
+ itemStack.consume(1, user);
|
||||||
+ } else if (user instanceof net.minecraft.server.level.ServerPlayer) {
|
+ } else if (user instanceof net.minecraft.server.level.ServerPlayer) {
|
||||||
@ -127,21 +135,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ 0.5F,
|
+ 0.5F,
|
||||||
+ 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)
|
+ 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)
|
||||||
+ );
|
+ );
|
||||||
+ user.awardStat(Stats.ITEM_USED.get(this));
|
|
||||||
+ } else {
|
+ } else {
|
||||||
+ 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 InteractionResultHolder.fail(itemStack);
|
+ return InteractionResult.FAIL;
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end - PlayerLaunchProjectileEvent
|
+ // Paper end - PlayerLaunchProjectileEvent
|
||||||
}
|
}
|
||||||
|
|
||||||
+ /* // Paper start - PlayerLaunchProjectileEvent; moved up
|
- 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
|
||||||
+ */ // Paper end - PlayerLaunchProjectileEvent
|
return InteractionResult.SUCCESS;
|
||||||
return InteractionResultHolder.sidedSuccess(itemStack, world.isClientSide());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/item/FireworkRocketItem.java b/src/main/java/net/minecraft/world/item/FireworkRocketItem.java
|
diff --git a/src/main/java/net/minecraft/world/item/FireworkRocketItem.java b/src/main/java/net/minecraft/world/item/FireworkRocketItem.java
|
||||||
@ -149,20 +155,28 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
--- a/src/main/java/net/minecraft/world/item/FireworkRocketItem.java
|
--- a/src/main/java/net/minecraft/world/item/FireworkRocketItem.java
|
||||||
+++ b/src/main/java/net/minecraft/world/item/FireworkRocketItem.java
|
+++ b/src/main/java/net/minecraft/world/item/FireworkRocketItem.java
|
||||||
@@ -0,0 +0,0 @@ public class FireworkRocketItem extends Item implements ProjectileItem {
|
@@ -0,0 +0,0 @@ public class FireworkRocketItem extends Item implements ProjectileItem {
|
||||||
itemStack
|
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(),
|
||||||
|
@@ -0,0 +0,0 @@ public class FireworkRocketItem extends Item implements ProjectileItem {
|
||||||
|
serverLevel,
|
||||||
|
itemStack, f -> f.spawningEntity = context.getPlayer() == null ? null : context.getPlayer().getUUID() // Paper - firework api - assign spawning entity uuid
|
||||||
);
|
);
|
||||||
fireworkRocketEntity.spawningEntity = context.getPlayer() == null ? null : context.getPlayer().getUUID(); // Paper
|
|
||||||
- level.addFreshEntity(fireworkRocketEntity);
|
|
||||||
- itemStack.shrink(1);
|
- itemStack.shrink(1);
|
||||||
+ // Paper start - PlayerLaunchProjectileEvent
|
+ // 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.getBukkitEntity());
|
+ 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() || !level.addFreshEntity(fireworkRocketEntity)) return InteractionResult.PASS;
|
+ if (!event.callEvent() || fireworkRocketEntity.attemptSpawn()) return InteractionResult.PASS;
|
||||||
+ if (event.shouldConsume() && !context.getPlayer().getAbilities().instabuild) itemStack.shrink(1);
|
+ 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();
|
+ else if (context.getPlayer() instanceof net.minecraft.server.level.ServerPlayer) ((net.minecraft.server.level.ServerPlayer) context.getPlayer()).getBukkitEntity().updateInventory();
|
||||||
+ // Paper end - PlayerLaunchProjectileEvent
|
+ // Paper end - PlayerLaunchProjectileEvent
|
||||||
}
|
}
|
||||||
|
|
||||||
return InteractionResult.sidedSuccess(level.isClientSide);
|
return InteractionResult.SUCCESS;
|
||||||
diff --git a/src/main/java/net/minecraft/world/item/LingeringPotionItem.java b/src/main/java/net/minecraft/world/item/LingeringPotionItem.java
|
diff --git a/src/main/java/net/minecraft/world/item/LingeringPotionItem.java b/src/main/java/net/minecraft/world/item/LingeringPotionItem.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/world/item/LingeringPotionItem.java
|
--- a/src/main/java/net/minecraft/world/item/LingeringPotionItem.java
|
||||||
@ -170,10 +184,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
@@ -0,0 +0,0 @@ public class LingeringPotionItem extends ThrowablePotionItem {
|
@@ -0,0 +0,0 @@ public class LingeringPotionItem extends ThrowablePotionItem {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InteractionResultHolder<ItemStack> use(Level world, Player user, InteractionHand hand) {
|
public InteractionResult use(Level world, Player user, InteractionHand hand) {
|
||||||
+ // Paper start - PlayerLaunchProjectileEvent
|
+ // Paper start - PlayerLaunchProjectileEvent
|
||||||
+ InteractionResultHolder<ItemStack> wrapper = super.use(world, user, hand);
|
+ final InteractionResult wrapper = super.use(world, user, hand);
|
||||||
+ if (wrapper.getResult() != net.minecraft.world.InteractionResult.FAIL) {
|
+ if (wrapper instanceof InteractionResult.Fail) return wrapper;
|
||||||
+ // Paper end - PlayerLaunchProjectileEvent
|
+ // Paper end - PlayerLaunchProjectileEvent
|
||||||
world.playSound(
|
world.playSound(
|
||||||
null,
|
null,
|
||||||
@ -183,10 +197,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)
|
0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)
|
||||||
);
|
);
|
||||||
- return super.use(world, user, hand);
|
- return super.use(world, user, hand);
|
||||||
+ // Paper start - PlayerLaunchProjectileEvent
|
+ return wrapper; // Paper - PlayerLaunchProjectileEvent
|
||||||
+ }
|
|
||||||
+ return wrapper;
|
|
||||||
+ // Paper end - PlayerLaunchProjectileEvent
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/net/minecraft/world/item/SnowballItem.java b/src/main/java/net/minecraft/world/item/SnowballItem.java
|
diff --git a/src/main/java/net/minecraft/world/item/SnowballItem.java b/src/main/java/net/minecraft/world/item/SnowballItem.java
|
||||||
@ -194,36 +205,36 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
--- a/src/main/java/net/minecraft/world/item/SnowballItem.java
|
--- a/src/main/java/net/minecraft/world/item/SnowballItem.java
|
||||||
+++ b/src/main/java/net/minecraft/world/item/SnowballItem.java
|
+++ b/src/main/java/net/minecraft/world/item/SnowballItem.java
|
||||||
@@ -0,0 +0,0 @@ public class SnowballItem extends Item implements ProjectileItem {
|
@@ -0,0 +0,0 @@ public class SnowballItem extends Item implements ProjectileItem {
|
||||||
|
// CraftBukkit start - moved down
|
||||||
entitysnowball.setItem(itemstack);
|
// 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));
|
||||||
entitysnowball.shootFromRotation(user, user.getXRot(), user.getYRot(), 0.0F, 1.5F, 1.0F);
|
if (world instanceof ServerLevel worldserver) {
|
||||||
- if (world.addFreshEntity(entitysnowball)) {
|
- if (Projectile.spawnProjectileFromRotation(Snowball::new, worldserver, itemstack, user, 0.0F, 1.5F, 1.0F).isAlive()) {
|
||||||
- itemstack.consume(1, user);
|
- itemstack.consume(1, user);
|
||||||
+ // Paper start - PlayerLaunchProjectileEvent
|
+ // Paper start - PlayerLaunchProjectileEvent
|
||||||
|
+ final Projectile.Delayed<Snowball> snowball = Projectile.spawnProjectileFromRotationDelayed(Snowball::new, worldserver, itemstack, user, 0.0F, 1.5F, 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) entitysnowball.getBukkitEntity());
|
+ 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) entitysnowball.getBukkitEntity());
|
||||||
+ if (event.callEvent() && world.addFreshEntity(entitysnowball)) {
|
+ if (event.callEvent() && snowball.attemptSpawn()) {
|
||||||
+ user.awardStat(Stats.ITEM_USED.get(this));
|
+ user.awardStat(Stats.ITEM_USED.get(this));
|
||||||
+ if (event.shouldConsume()) {
|
+ if (event.shouldConsume()) {
|
||||||
+ // Paper end - PlayerLaunchProjectileEvent
|
|
||||||
+ itemstack.consume(1, user);
|
+ itemstack.consume(1, user);
|
||||||
+ } else if (user instanceof net.minecraft.server.level.ServerPlayer) { // Paper - PlayerLaunchProjectileEvent
|
+ } else if (user instanceof net.minecraft.server.level.ServerPlayer) {
|
||||||
+ ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory(); // Paper - PlayerLaunchProjectileEvent
|
+ ((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) {
|
||||||
- ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory();
|
+ } else { if (user instanceof net.minecraft.server.level.ServerPlayer) { // Paper - PlayerLaunchProjectileEvent - return fail
|
||||||
+ } else { // Paper - PlayerLaunchProjectileEvent
|
((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory();
|
||||||
+ if (user instanceof net.minecraft.server.level.ServerPlayer) ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory(); // Paper - PlayerLaunchProjectileEvent
|
- }
|
||||||
+ return InteractionResultHolder.fail(itemstack); // Paper - PlayerLaunchProjectileEvent
|
+ } 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));
|
||||||
+ // user.awardStat(Stats.ITEM_USED.get(this)); // Paper - PlayerLaunchProjectileEvent; moved up
|
+ // Paper - PlayerLaunchProjectileEvent - moved up
|
||||||
// itemstack.consume(1, entityhuman); // CraftBukkit - moved up
|
// itemstack.consume(1, entityhuman); // CraftBukkit - moved up
|
||||||
return InteractionResultHolder.sidedSuccess(itemstack, world.isClientSide());
|
return InteractionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/net/minecraft/world/item/SplashPotionItem.java b/src/main/java/net/minecraft/world/item/SplashPotionItem.java
|
diff --git a/src/main/java/net/minecraft/world/item/SplashPotionItem.java b/src/main/java/net/minecraft/world/item/SplashPotionItem.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
@ -232,10 +243,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
@@ -0,0 +0,0 @@ public class SplashPotionItem extends ThrowablePotionItem {
|
@@ -0,0 +0,0 @@ public class SplashPotionItem extends ThrowablePotionItem {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InteractionResultHolder<ItemStack> use(Level world, Player user, InteractionHand hand) {
|
public InteractionResult use(Level world, Player user, InteractionHand hand) {
|
||||||
+ // Paper start - PlayerLaunchProjectileEvent
|
+ // Paper start - PlayerLaunchProjectileEvent
|
||||||
+ InteractionResultHolder<ItemStack> wrapper = super.use(world, user, hand);
|
+ final InteractionResult wrapper = super.use(world, user, hand);
|
||||||
+ if (wrapper.getResult() != net.minecraft.world.InteractionResult.FAIL) {
|
+ if (wrapper instanceof InteractionResult.Fail) return wrapper;
|
||||||
+ // Paper end - PlayerLaunchProjectileEvent
|
+ // Paper end - PlayerLaunchProjectileEvent
|
||||||
world.playSound(
|
world.playSound(
|
||||||
null,
|
null,
|
||||||
@ -245,10 +256,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)
|
0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)
|
||||||
);
|
);
|
||||||
- return super.use(world, user, hand);
|
- return super.use(world, user, hand);
|
||||||
+ // Paper start - PlayerLaunchProjectileEvent
|
+ return wrapper; // Paper - PlayerLaunchProjectileEvent
|
||||||
+ }
|
|
||||||
+ return wrapper;
|
|
||||||
+ // Paper end - PlayerLaunchProjectileEvent
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/net/minecraft/world/item/ThrowablePotionItem.java b/src/main/java/net/minecraft/world/item/ThrowablePotionItem.java
|
diff --git a/src/main/java/net/minecraft/world/item/ThrowablePotionItem.java b/src/main/java/net/minecraft/world/item/ThrowablePotionItem.java
|
||||||
@ -256,13 +264,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
--- a/src/main/java/net/minecraft/world/item/ThrowablePotionItem.java
|
--- a/src/main/java/net/minecraft/world/item/ThrowablePotionItem.java
|
||||||
+++ b/src/main/java/net/minecraft/world/item/ThrowablePotionItem.java
|
+++ b/src/main/java/net/minecraft/world/item/ThrowablePotionItem.java
|
||||||
@@ -0,0 +0,0 @@ public class ThrowablePotionItem extends PotionItem implements ProjectileItem {
|
@@ -0,0 +0,0 @@ public class ThrowablePotionItem extends PotionItem implements ProjectileItem {
|
||||||
ThrownPotion thrownPotion = new ThrownPotion(world, user);
|
public InteractionResult use(Level world, Player user, InteractionHand hand) {
|
||||||
thrownPotion.setItem(itemStack);
|
ItemStack itemStack = user.getItemInHand(hand);
|
||||||
thrownPotion.shootFromRotation(user, user.getXRot(), user.getYRot(), -20.0F, 0.5F, 1.0F);
|
if (world instanceof ServerLevel serverLevel) {
|
||||||
- world.addFreshEntity(thrownPotion);
|
- Projectile.spawnProjectileFromRotation(ThrownPotion::new, serverLevel, itemStack, user, -20.0F, 0.5F, 1.0F);
|
||||||
+ // Paper start - PlayerLaunchProjectileEvent
|
+ // 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.getBukkitEntity());
|
+ final Projectile.Delayed<ThrownPotion> thrownPotion = Projectile.spawnProjectileFromRotationDelayed(ThrownPotion::new, serverLevel, itemStack, user, -20.0F, 0.5F, 1.0F);
|
||||||
+ if (event.callEvent() && world.addFreshEntity(thrownPotion)) {
|
+ // 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()) {
|
+ if (event.shouldConsume()) {
|
||||||
+ itemStack.consume(1, user);
|
+ itemStack.consume(1, user);
|
||||||
+ } else if (user instanceof net.minecraft.server.level.ServerPlayer) {
|
+ } else if (user instanceof net.minecraft.server.level.ServerPlayer) {
|
||||||
@ -274,16 +284,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ 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 InteractionResultHolder.fail(itemStack);
|
+ return InteractionResult.FAIL;
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end - PlayerLaunchProjectileEvent
|
+ // Paper end - PlayerLaunchProjectileEvent
|
||||||
}
|
}
|
||||||
|
|
||||||
+ /* // Paper start - PlayerLaunchProjectileEvent; moved up
|
- user.awardStat(Stats.ITEM_USED.get(this));
|
||||||
user.awardStat(Stats.ITEM_USED.get(this));
|
- itemStack.consume(1, user);
|
||||||
itemStack.consume(1, user);
|
+ // Paper - PlayerLaunchProjectileEvent - move up
|
||||||
+ */ // Paper end
|
return InteractionResult.SUCCESS;
|
||||||
return InteractionResultHolder.sidedSuccess(itemStack, world.isClientSide());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/item/TridentItem.java b/src/main/java/net/minecraft/world/item/TridentItem.java
|
diff --git a/src/main/java/net/minecraft/world/item/TridentItem.java b/src/main/java/net/minecraft/world/item/TridentItem.java
|
||||||
@ -291,58 +300,66 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
--- a/src/main/java/net/minecraft/world/item/TridentItem.java
|
--- a/src/main/java/net/minecraft/world/item/TridentItem.java
|
||||||
+++ b/src/main/java/net/minecraft/world/item/TridentItem.java
|
+++ b/src/main/java/net/minecraft/world/item/TridentItem.java
|
||||||
@@ -0,0 +0,0 @@ public class TridentItem extends Item implements ProjectileItem {
|
@@ -0,0 +0,0 @@ public class TridentItem extends Item implements ProjectileItem {
|
||||||
}
|
|
||||||
|
|
||||||
// CraftBukkit start
|
// itemstack.hurtWithoutBreaking(1, entityhuman); // CraftBukkit - moved down
|
||||||
- if (!world.addFreshEntity(entitythrowntrident)) {
|
if (f == 0.0F) {
|
||||||
|
- ThrownTrident entitythrowntrident = (ThrownTrident) Projectile.spawnProjectileFromRotation(ThrownTrident::new, worldserver, stack, entityhuman, 0.0F, 2.5F, 1.0F);
|
||||||
|
- // CraftBukkit start
|
||||||
|
- if (entitythrowntrident.isRemoved()) {
|
||||||
+ // Paper start - PlayerLaunchProjectileEvent
|
+ // 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) entitythrowntrident.getBukkitEntity());
|
+ Projectile.Delayed<ThrownTrident> tridentDelayed = Projectile.spawnProjectileFromRotationDelayed(ThrownTrident::new, worldserver, stack, entityhuman, 0.0F, 2.5F, 1.0F);
|
||||||
+ if (!event.callEvent() || !world.addFreshEntity(entitythrowntrident)) {
|
+ // 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
|
+ // 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;
|
return false;
|
||||||
}
|
}
|
||||||
|
- stack.hurtWithoutBreaking(1, entityhuman);
|
||||||
+ if (event.shouldConsume()) { // Paper - PlayerLaunchProjectileEvent
|
+ ThrownTrident entitythrowntrident = tridentDelayed.projectile(); // Paper - PlayerLaunchProjectileEvent
|
||||||
stack.hurtAndBreak(1, entityhuman, LivingEntity.getSlotForHand(user.getUsedItemHand()));
|
+ if (event.shouldConsume()) stack.hurtWithoutBreaking(1, entityhuman); // Paper - PlayerLaunchProjectileEvent
|
||||||
+ } // 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
|
||||||
|
|
||||||
world.playSound((Player) null, (Entity) entitythrowntrident, (SoundEvent) holder.value(), SoundSource.PLAYERS, 1.0F, 1.0F);
|
if (entityhuman.hasInfiniteMaterials()) {
|
||||||
- if (!entityhuman.hasInfiniteMaterials()) {
|
entitythrowntrident.pickup = AbstractArrow.Pickup.CREATIVE_ONLY;
|
||||||
+ if (event.shouldConsume() && !entityhuman.hasInfiniteMaterials()) { // Paper - PlayerLaunchProjectileEvent
|
- } else {
|
||||||
|
+ } else if (event.shouldConsume()) { // Paper - PlayerLaunchProjectileEvent
|
||||||
entityhuman.getInventory().removeItem(stack);
|
entityhuman.getInventory().removeItem(stack);
|
||||||
}
|
}
|
||||||
// CraftBukkit start - SPIGOT-5458 also need in this branch :(
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/item/WindChargeItem.java b/src/main/java/net/minecraft/world/item/WindChargeItem.java
|
diff --git a/src/main/java/net/minecraft/world/item/WindChargeItem.java b/src/main/java/net/minecraft/world/item/WindChargeItem.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/world/item/WindChargeItem.java
|
--- a/src/main/java/net/minecraft/world/item/WindChargeItem.java
|
||||||
+++ b/src/main/java/net/minecraft/world/item/WindChargeItem.java
|
+++ b/src/main/java/net/minecraft/world/item/WindChargeItem.java
|
||||||
@@ -0,0 +0,0 @@ public class WindChargeItem extends Item implements ProjectileItem {
|
@@ -0,0 +0,0 @@ public class WindChargeItem extends Item implements ProjectileItem {
|
||||||
|
public InteractionResult use(Level world, Player user, InteractionHand hand) {
|
||||||
@Override
|
ItemStack itemStack = user.getItemInHand(hand);
|
||||||
public InteractionResultHolder<ItemStack> use(Level world, Player user, InteractionHand hand) {
|
if (world instanceof ServerLevel serverLevel) {
|
||||||
+ ItemStack itemStack = user.getItemInHand(hand); // Paper - PlayerLaunchProjectileEvent; moved from below
|
- Projectile.spawnProjectileFromRotation(
|
||||||
+ boolean shouldConsume = true; // Paper - PlayerLaunchProjectileEvent
|
+ final Projectile.Delayed<WindCharge> windCharge = Projectile.spawnProjectileFromRotationDelayed( // Paper - PlayerLaunchProjectileEvent
|
||||||
if (!world.isClientSide()) {
|
(world2, shooter, stack) -> new WindCharge(user, world, user.position().x(), user.getEyePosition().y(), user.position().z()),
|
||||||
WindCharge windCharge = new WindCharge(user, world, user.position().x(), user.getEyePosition().y(), user.position().z());
|
serverLevel,
|
||||||
windCharge.shootFromRotation(user, user.getXRot(), user.getYRot(), 0.0F, 1.5F, 1.0F);
|
itemStack,
|
||||||
- world.addFreshEntity(windCharge);
|
@@ -0,0 +0,0 @@ public class WindChargeItem extends Item implements ProjectileItem {
|
||||||
+ // Paper start - PlayerLaunchProjectileEvent
|
1.5F,
|
||||||
+ 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.getBukkitEntity());
|
1.0F
|
||||||
+ if (!event.callEvent() || !world.addFreshEntity(windCharge)) {
|
);
|
||||||
|
+ 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();
|
+ user.containerMenu.sendAllDataToRemote();
|
||||||
+ if (user instanceof net.minecraft.server.level.ServerPlayer player) {
|
+ if (user instanceof net.minecraft.server.level.ServerPlayer player) {
|
||||||
+ player.connection.send(new net.minecraft.network.protocol.game.ClientboundCooldownPacket(this, 0)); // prevent visual desync of cooldown on the slot
|
+ player.connection.send(new net.minecraft.network.protocol.game.ClientboundCooldownPacket(user.getCooldowns().getCooldownGroup(itemStack), 0)); // prevent visual desync of cooldown on the slot
|
||||||
+ }
|
+ }
|
||||||
+ return InteractionResultHolder.fail(itemStack);
|
+ return InteractionResult.FAIL;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ shouldConsume = event.shouldConsume();
|
+ user.awardStat(Stats.ITEM_USED.get(this));
|
||||||
+ if (!shouldConsume && !user.hasInfiniteMaterials()) {
|
+ if (event.shouldConsume()) itemStack.consume(1, user);
|
||||||
|
+ else if (!user.hasInfiniteMaterials()) {
|
||||||
+ user.containerMenu.sendAllDataToRemote();
|
+ user.containerMenu.sendAllDataToRemote();
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end - PlayerLaunchProjectileEvent
|
+ // Paper end - PlayerLaunchProjectileEvent
|
||||||
@ -353,11 +370,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
0.5F,
|
0.5F,
|
||||||
0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)
|
0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)
|
||||||
);
|
);
|
||||||
- ItemStack itemStack = user.getItemInHand(hand);
|
- user.awardStat(Stats.ITEM_USED.get(this));
|
||||||
user.getCooldowns().addCooldown(this, 10);
|
|
||||||
user.awardStat(Stats.ITEM_USED.get(this));
|
|
||||||
- itemStack.consume(1, user);
|
- itemStack.consume(1, user);
|
||||||
+ if (shouldConsume) itemStack.consume(1, user); // Paper - PlayerLaunchProjectileEvent
|
return InteractionResult.SUCCESS;
|
||||||
return InteractionResultHolder.sidedSuccess(itemStack, world.isClientSide());
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,33 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: BillyGalbreath <Blake.Galbreath@GMail.com>
|
|
||||||
Date: Sat, 21 Jul 2018 01:59:59 -0500
|
|
||||||
Subject: [PATCH] PlayerElytraBoostEvent
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/item/FireworkRocketItem.java b/src/main/java/net/minecraft/world/item/FireworkRocketItem.java
|
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/item/FireworkRocketItem.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/item/FireworkRocketItem.java
|
|
||||||
@@ -0,0 +0,0 @@ public class FireworkRocketItem extends Item implements ProjectileItem {
|
|
||||||
if (!world.isClientSide) {
|
|
||||||
FireworkRocketEntity fireworkRocketEntity = new FireworkRocketEntity(world, itemStack, user);
|
|
||||||
fireworkRocketEntity.spawningEntity = user.getUUID(); // Paper
|
|
||||||
- world.addFreshEntity(fireworkRocketEntity);
|
|
||||||
- itemStack.consume(1, user);
|
|
||||||
- user.awardStat(Stats.ITEM_USED.get(this));
|
|
||||||
+ // Paper start - PlayerElytraBoostEvent
|
|
||||||
+ com.destroystokyo.paper.event.player.PlayerElytraBoostEvent event = new com.destroystokyo.paper.event.player.PlayerElytraBoostEvent((org.bukkit.entity.Player) user.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemStack), (org.bukkit.entity.Firework) fireworkRocketEntity.getBukkitEntity(), org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(hand));
|
|
||||||
+ if (event.callEvent() && world.addFreshEntity(fireworkRocketEntity)) {
|
|
||||||
+ user.awardStat(Stats.ITEM_USED.get(this));
|
|
||||||
+ if (event.shouldConsume() && !user.hasInfiniteMaterials()) {
|
|
||||||
+ itemStack.shrink(1);
|
|
||||||
+ } else ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory();
|
|
||||||
+ } else if (user instanceof net.minecraft.server.level.ServerPlayer) {
|
|
||||||
+ ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory();
|
|
||||||
+ // Paper end - PlayerElytraBoostEvent
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ // user.awardStat(Stats.ITEM_USED.get(this)); // Paper - PlayerElytraBoostEvent; move up
|
|
||||||
}
|
|
||||||
|
|
||||||
return InteractionResultHolder.sidedSuccess(user.getItemInHand(hand), world.isClientSide());
|
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren