aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/projectile/ThrownPotion.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/projectile/ThrownPotion.java.patch')
-rw-r--r--patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/projectile/ThrownPotion.java.patch185
1 files changed, 185 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/projectile/ThrownPotion.java.patch b/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/projectile/ThrownPotion.java.patch
new file mode 100644
index 0000000000..430cfe9c4f
--- /dev/null
+++ b/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/projectile/ThrownPotion.java.patch
@@ -0,0 +1,185 @@
+--- a/net/minecraft/world/entity/projectile/ThrownPotion.java
++++ b/net/minecraft/world/entity/projectile/ThrownPotion.java
+@@ -28,6 +29,16 @@
+ import net.minecraft.world.phys.BlockHitResult;
+ import net.minecraft.world.phys.EntityHitResult;
+ import net.minecraft.world.phys.HitResult;
++// CraftBukkit start
++import java.util.HashMap;
++import java.util.Map;
++import net.minecraft.world.effect.MobEffects;
++import net.minecraft.world.level.block.Blocks;
++import net.minecraft.world.level.block.CampfireBlock;
++import org.bukkit.craftbukkit.entity.CraftLivingEntity;
++import org.bukkit.craftbukkit.event.CraftEventFactory;
++import org.bukkit.entity.LivingEntity;
++// CraftBukkit end
+
+ public class ThrownPotion extends ThrowableItemProjectile implements ItemSupplier {
+ public static final double SPLASH_RANGE = 4.0;
+@@ -88,11 +108,11 @@
+ boolean flag = potion == Potions.WATER && mobEffects.isEmpty();
+ if (flag) {
+ this.applyWater();
+- } else if (!mobEffects.isEmpty()) {
++ } else if (true || !list.isEmpty()) { // CraftBukkit - Call event even if no effects to apply
+ if (this.isLingering()) {
+- this.makeAreaOfEffectCloud(item, potion);
++ this.makeAreaOfEffectCloud(itemstack, potionregistry, result); // CraftBukkit - Pass MovingObjectPosition
+ } else {
+- this.applySplash(mobEffects, result.getType() == HitResult.Type.ENTITY ? ((EntityHitResult)result).getEntity() : null);
++ this.applySplash(list, result.getType() == HitResult.EnumMovingObjectType.ENTITY ? ((EntityHitResult) result).getEntity() : null, result); // CraftBukkit - Pass MovingObjectPosition
+ }
+ }
+
+@@ -123,11 +154,10 @@
+ }
+ }
+
+- private void applySplash(List<MobEffectInstance> effectInstances, @Nullable Entity target) {
+- AABB aABB = this.getBoundingBox().inflate(4.0, 2.0, 4.0);
+- List<LivingEntity> entitiesOfClass = this.level().getEntitiesOfClass(LivingEntity.class, aABB);
+- if (!entitiesOfClass.isEmpty()) {
+- Entity effectSource = this.getEffectSource();
++ private void applySplash(List<MobEffectInstance> list, @Nullable Entity entity, HitResult position) { // CraftBukkit - Pass MovingObjectPosition
++ AABB axisalignedbb = this.getBoundingBox().inflate(4.0D, 2.0D, 4.0D);
++ List<net.minecraft.world.entity.LivingEntity> list1 = this.level().getEntitiesOfClass(net.minecraft.world.entity.LivingEntity.class, axisalignedbb);
++ Map<LivingEntity, Double> affected = new HashMap<LivingEntity, Double>(); // CraftBukkit
+
+ for (LivingEntity livingEntity : entitiesOfClass) {
+ if (livingEntity.isAffectedByPotions()) {
+@@ -140,31 +178,62 @@
+ d1 = 1.0 - Math.sqrt(d) / 4.0;
+ }
+
+- for (MobEffectInstance mobEffectInstance : effectInstances) {
+- MobEffect effect = mobEffectInstance.getEffect();
+- if (effect.isInstantenous()) {
+- effect.applyInstantenousEffect(this, this.getOwner(), livingEntity, mobEffectInstance.getAmplifier(), d1);
+- } else {
+- int i = mobEffectInstance.mapDuration(i1 -> (int)(d1 * (double)i1 + 0.5));
+- MobEffectInstance mobEffectInstance1 = new MobEffectInstance(
+- effect, i, mobEffectInstance.getAmplifier(), mobEffectInstance.isAmbient(), mobEffectInstance.isVisible()
+- );
+- if (!mobEffectInstance1.endsWithin(20)) {
+- livingEntity.addEffect(mobEffectInstance1, effectSource);
+- }
+- }
++ // CraftBukkit start
++ affected.put((LivingEntity) entityliving.getBukkitEntity(), d1);
++ }
++ }
++ }
++ }
++
++ org.bukkit.event.entity.PotionSplashEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPotionSplashEvent(this, position, affected);
++ if (!event.isCancelled() && list != null && !list.isEmpty()) { // do not process effects if there are no effects to process
++ Entity entity1 = this.getEffectSource();
++ for (LivingEntity victim : event.getAffectedEntities()) {
++ if (!(victim instanceof CraftLivingEntity)) {
++ continue;
++ }
++
++ net.minecraft.world.entity.LivingEntity entityliving = ((CraftLivingEntity) victim).getHandle();
++ double d1 = event.getIntensity(victim);
++ // CraftBukkit end
++
++ Iterator iterator1 = list.iterator();
++
++ while (iterator1.hasNext()) {
++ MobEffectInstance mobeffect = (MobEffectInstance) iterator1.next();
++ MobEffect mobeffectlist = mobeffect.getEffect();
++ // CraftBukkit start - Abide by PVP settings - for players only!
++ if (!this.level().pvpMode && this.getOwner() instanceof ServerPlayer && entityliving instanceof ServerPlayer && entityliving != this.getOwner()) {
++ if (mobeffectlist == MobEffects.MOVEMENT_SLOWDOWN || mobeffectlist == MobEffects.DIG_SLOWDOWN || mobeffectlist == MobEffects.HARM || mobeffectlist == MobEffects.BLINDNESS
++ || mobeffectlist == MobEffects.HUNGER || mobeffectlist == MobEffects.WEAKNESS || mobeffectlist == MobEffects.POISON) {
++ continue;
+ }
+ }
++ // CraftBukkit end
++
++ if (mobeffectlist.isInstantenous()) {
++ mobeffectlist.applyInstantenousEffect(this, this.getOwner(), entityliving, mobeffect.getAmplifier(), d1);
++ } else {
++ int i = mobeffect.mapDuration((j) -> {
++ return (int) (d1 * (double) j + 0.5D);
++ });
++ MobEffectInstance mobeffect1 = new MobEffectInstance(mobeffectlist, i, mobeffect.getAmplifier(), mobeffect.isAmbient(), mobeffect.isVisible());
++
++ if (!mobeffect1.endsWithin(20)) {
++ entityliving.addEffect(mobeffect1, entity1, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.POTION_SPLASH); // CraftBukkit
++ }
++ }
+ }
+ }
+ }
+ }
+
+- private void makeAreaOfEffectCloud(ItemStack stack, Potion potion) {
+- AreaEffectCloud areaEffectCloud = new AreaEffectCloud(this.level(), this.getX(), this.getY(), this.getZ());
+- Entity owner = this.getOwner();
+- if (owner instanceof LivingEntity) {
+- areaEffectCloud.setOwner((LivingEntity)owner);
++ private void makeAreaOfEffectCloud(ItemStack itemstack, Potion potionregistry, HitResult position) { // CraftBukkit - Pass MovingObjectPosition
++ AreaEffectCloud entityareaeffectcloud = new AreaEffectCloud(this.level(), this.getX(), this.getY(), this.getZ());
++ Entity entity = this.getOwner();
++
++ if (entity instanceof net.minecraft.world.entity.LivingEntity) {
++ entityareaeffectcloud.setOwner((net.minecraft.world.entity.LivingEntity) entity);
+ }
+
+ areaEffectCloud.setRadius(3.0F);
+@@ -182,7 +256,14 @@
+ areaEffectCloud.setFixedColor(tag.getInt("CustomPotionColor"));
+ }
+
+- this.level().addFreshEntity(areaEffectCloud);
++ // CraftBukkit start
++ org.bukkit.event.entity.LingeringPotionSplashEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callLingeringPotionSplashEvent(this, position, entityareaeffectcloud);
++ if (!(event.isCancelled() || entityareaeffectcloud.isRemoved())) {
++ this.level().addFreshEntity(entityareaeffectcloud);
++ } else {
++ entityareaeffectcloud.discard();
++ }
++ // CraftBukkit end
+ }
+
+ private boolean isLingering() {
+@@ -190,15 +271,28 @@
+ }
+
+ private void dowseFire(BlockPos pos) {
+- BlockState blockState = this.level().getBlockState(pos);
+- if (blockState.is(BlockTags.FIRE)) {
+- this.level().destroyBlock(pos, false, this);
+- } else if (AbstractCandleBlock.isLit(blockState)) {
+- AbstractCandleBlock.extinguish(null, blockState, this.level(), pos);
+- } else if (CampfireBlock.isLitCampfire(blockState)) {
+- this.level().levelEvent(null, 1009, pos, 0);
+- CampfireBlock.dowse(this.getOwner(), this.level(), pos, blockState);
+- this.level().setBlockAndUpdate(pos, blockState.setValue(CampfireBlock.LIT, Boolean.valueOf(false)));
++ IBlockData iblockdata = this.level().getBlockState(pos);
++
++ if (iblockdata.is(BlockTags.FIRE)) {
++ // CraftBukkit start
++ if (CraftEventFactory.callEntityChangeBlockEvent(this, pos, Blocks.AIR.defaultBlockState())) {
++ this.level().destroyBlock(pos, false, this);
++ }
++ // CraftBukkit end
++ } else if (AbstractCandleBlock.isLit(iblockdata)) {
++ // CraftBukkit start
++ if (CraftEventFactory.callEntityChangeBlockEvent(this, pos, iblockdata.setValue(AbstractCandleBlock.LIT, false))) {
++ AbstractCandleBlock.extinguish((Player) null, iblockdata, this.level(), pos);
++ }
++ // CraftBukkit end
++ } else if (CampfireBlock.isLitCampfire(iblockdata)) {
++ // CraftBukkit start
++ if (CraftEventFactory.callEntityChangeBlockEvent(this, pos, iblockdata.setValue(CampfireBlock.LIT, false))) {
++ this.level().levelEvent((Player) null, 1009, pos, 0);
++ CampfireBlock.dowse(this.getOwner(), this.level(), pos, iblockdata);
++ this.level().setBlockAndUpdate(pos, (IBlockData) iblockdata.setValue(CampfireBlock.LIT, false));
++ }
++ // CraftBukkit end
+ }
+ }
+ }