aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-spigotflower/net/minecraft/world/entity/projectile/ThrownPotion.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/entity/projectile/ThrownPotion.java.patch')
-rw-r--r--patch-remap/mache-spigotflower/net/minecraft/world/entity/projectile/ThrownPotion.java.patch380
1 files changed, 380 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/entity/projectile/ThrownPotion.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/entity/projectile/ThrownPotion.java.patch
new file mode 100644
index 0000000000..f92606dd2d
--- /dev/null
+++ b/patch-remap/mache-spigotflower/net/minecraft/world/entity/projectile/ThrownPotion.java.patch
@@ -0,0 +1,380 @@
+--- a/net/minecraft/world/entity/projectile/ThrownPotion.java
++++ b/net/minecraft/world/entity/projectile/ThrownPotion.java
+@@ -7,13 +7,13 @@
+ import net.minecraft.core.BlockPos;
+ import net.minecraft.core.Direction;
+ import net.minecraft.nbt.CompoundTag;
++import net.minecraft.server.level.ServerPlayer;
+ import net.minecraft.tags.BlockTags;
+ import net.minecraft.world.effect.MobEffect;
+ import net.minecraft.world.effect.MobEffectInstance;
+ import net.minecraft.world.entity.AreaEffectCloud;
+ import net.minecraft.world.entity.Entity;
+ import net.minecraft.world.entity.EntityType;
+-import net.minecraft.world.entity.LivingEntity;
+ import net.minecraft.world.entity.animal.axolotl.Axolotl;
+ import net.minecraft.world.entity.player.Player;
+ import net.minecraft.world.item.Item;
+@@ -24,67 +24,73 @@
+ import net.minecraft.world.item.alchemy.Potions;
+ import net.minecraft.world.level.Level;
+ import net.minecraft.world.level.block.AbstractCandleBlock;
+-import net.minecraft.world.level.block.CampfireBlock;
+-import net.minecraft.world.level.block.state.BlockState;
++import net.minecraft.world.level.block.state.IBlockData;
+ import net.minecraft.world.phys.AABB;
+ 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.0D;
+ private static final double SPLASH_RANGE_SQ = 16.0D;
+- public static final Predicate<LivingEntity> WATER_SENSITIVE_OR_ON_FIRE = (livingentity) -> {
+- return livingentity.isSensitiveToWater() || livingentity.isOnFire();
++ public static final Predicate<net.minecraft.world.entity.LivingEntity> WATER_SENSITIVE_OR_ON_FIRE = (entityliving) -> {
++ return entityliving.isSensitiveToWater() || entityliving.isOnFire();
+ };
+
+- public ThrownPotion(EntityType<? extends ThrownPotion> entitytype, Level level) {
+- super(entitytype, level);
++ public ThrownPotion(EntityType<? extends ThrownPotion> entityType, Level level) {
++ super(entityType, level);
+ }
+
+- public ThrownPotion(Level level, LivingEntity livingentity) {
+- super(EntityType.POTION, livingentity, level);
++ public ThrownPotion(Level level, net.minecraft.world.entity.LivingEntity shooter) {
++ super(EntityType.POTION, shooter, level);
+ }
+
+- public ThrownPotion(Level level, double d0, double d1, double d2) {
+- super(EntityType.POTION, d0, d1, d2, level);
++ public ThrownPotion(Level level, double x, double d1, double y) {
++ super(EntityType.POTION, x, d1, y, level);
+ }
+
+ @Override
+- @Override
+ protected Item getDefaultItem() {
+ return Items.SPLASH_POTION;
+ }
+
+ @Override
+- @Override
+ protected float getGravity() {
+ return 0.05F;
+ }
+
+ @Override
+- @Override
+- protected void onHitBlock(BlockHitResult blockhitresult) {
+- super.onHitBlock(blockhitresult);
++ protected void onHitBlock(BlockHitResult result) {
++ super.onHitBlock(result);
+ if (!this.level().isClientSide) {
+ ItemStack itemstack = this.getItem();
+- Potion potion = PotionUtils.getPotion(itemstack);
++ Potion potionregistry = PotionUtils.getPotion(itemstack);
+ List<MobEffectInstance> list = PotionUtils.getMobEffects(itemstack);
+- boolean flag = potion == Potions.WATER && list.isEmpty();
+- Direction direction = blockhitresult.getDirection();
+- BlockPos blockpos = blockhitresult.getBlockPos();
+- BlockPos blockpos1 = blockpos.relative(direction);
++ boolean flag = potionregistry == Potions.WATER && list.isEmpty();
++ Direction enumdirection = result.getDirection();
++ BlockPos blockposition = result.getBlockPos();
++ BlockPos blockposition1 = blockposition.relative(enumdirection);
+
+ if (flag) {
+- this.dowseFire(blockpos1);
+- this.dowseFire(blockpos1.relative(direction.getOpposite()));
++ this.dowseFire(blockposition1);
++ this.dowseFire(blockposition1.relative(enumdirection.getOpposite()));
+ Iterator iterator = Direction.Plane.HORIZONTAL.iterator();
+
+ while (iterator.hasNext()) {
+- Direction direction1 = (Direction) iterator.next();
++ Direction enumdirection1 = (Direction) iterator.next();
+
+- this.dowseFire(blockpos1.relative(direction1));
++ this.dowseFire(blockposition1.relative(enumdirection1));
+ }
+ }
+
+@@ -92,26 +98,25 @@
+ }
+
+ @Override
+- @Override
+- protected void onHit(HitResult hitresult) {
+- super.onHit(hitresult);
++ protected void onHit(HitResult result) {
++ super.onHit(result);
+ if (!this.level().isClientSide) {
+ ItemStack itemstack = this.getItem();
+- Potion potion = PotionUtils.getPotion(itemstack);
++ Potion potionregistry = PotionUtils.getPotion(itemstack);
+ List<MobEffectInstance> list = PotionUtils.getMobEffects(itemstack);
+- boolean flag = potion == Potions.WATER && list.isEmpty();
++ boolean flag = potionregistry == Potions.WATER && list.isEmpty();
+
+ if (flag) {
+ this.applyWater();
+- } else if (!list.isEmpty()) {
++ } else if (true || !list.isEmpty()) { // CraftBukkit - Call event even if no effects to apply
+ if (this.isLingering()) {
+- this.makeAreaOfEffectCloud(itemstack, potion);
++ this.makeAreaOfEffectCloud(itemstack, potionregistry, result); // CraftBukkit - Pass MovingObjectPosition
+ } else {
+- this.applySplash(list, hitresult.getType() == HitResult.Type.ENTITY ? ((EntityHitResult) hitresult).getEntity() : null);
++ this.applySplash(list, result.getType() == HitResult.EnumMovingObjectType.ENTITY ? ((EntityHitResult) result).getEntity() : null, result); // CraftBukkit - Pass MovingObjectPosition
+ }
+ }
+
+- int i = potion.hasInstantEffects() ? 2007 : 2002;
++ int i = potionregistry.hasInstantEffects() ? 2007 : 2002;
+
+ this.level().levelEvent(i, this.blockPosition(), PotionUtils.getColor(itemstack));
+ this.discard();
+@@ -119,26 +124,26 @@
+ }
+
+ private void applyWater() {
+- AABB aabb = this.getBoundingBox().inflate(4.0D, 2.0D, 4.0D);
+- List<LivingEntity> list = this.level().getEntitiesOfClass(LivingEntity.class, aabb, ThrownPotion.WATER_SENSITIVE_OR_ON_FIRE);
++ AABB axisalignedbb = this.getBoundingBox().inflate(4.0D, 2.0D, 4.0D);
++ List<net.minecraft.world.entity.LivingEntity> list = this.level().getEntitiesOfClass(net.minecraft.world.entity.LivingEntity.class, axisalignedbb, ThrownPotion.WATER_SENSITIVE_OR_ON_FIRE);
+ Iterator iterator = list.iterator();
+
+ while (iterator.hasNext()) {
+- LivingEntity livingentity = (LivingEntity) iterator.next();
+- double d0 = this.distanceToSqr((Entity) livingentity);
++ net.minecraft.world.entity.LivingEntity entityliving = (net.minecraft.world.entity.LivingEntity) iterator.next();
++ double d0 = this.distanceToSqr((Entity) entityliving);
+
+ if (d0 < 16.0D) {
+- if (livingentity.isSensitiveToWater()) {
+- livingentity.hurt(this.damageSources().indirectMagic(this, this.getOwner()), 1.0F);
++ if (entityliving.isSensitiveToWater()) {
++ entityliving.hurt(this.damageSources().indirectMagic(this, this.getOwner()), 1.0F);
+ }
+
+- if (livingentity.isOnFire() && livingentity.isAlive()) {
+- livingentity.extinguishFire();
++ if (entityliving.isOnFire() && entityliving.isAlive()) {
++ entityliving.extinguishFire();
+ }
+ }
+ }
+
+- List<Axolotl> list1 = this.level().getEntitiesOfClass(Axolotl.class, aabb);
++ List<Axolotl> list1 = this.level().getEntitiesOfClass(Axolotl.class, axisalignedbb);
+ Iterator iterator1 = list1.iterator();
+
+ while (iterator1.hasNext()) {
+@@ -149,100 +154,145 @@
+
+ }
+
+- private void applySplash(List<MobEffectInstance> list, @Nullable Entity entity) {
+- AABB aabb = this.getBoundingBox().inflate(4.0D, 2.0D, 4.0D);
+- List<LivingEntity> list1 = this.level().getEntitiesOfClass(LivingEntity.class, aabb);
++ 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
+
+ if (!list1.isEmpty()) {
+ Entity entity1 = this.getEffectSource();
+ Iterator iterator = list1.iterator();
+
+ while (iterator.hasNext()) {
+- LivingEntity livingentity = (LivingEntity) iterator.next();
++ net.minecraft.world.entity.LivingEntity entityliving = (net.minecraft.world.entity.LivingEntity) iterator.next();
+
+- if (livingentity.isAffectedByPotions()) {
+- double d0 = this.distanceToSqr((Entity) livingentity);
++ if (entityliving.isAffectedByPotions()) {
++ double d0 = this.distanceToSqr((Entity) entityliving);
+
+ if (d0 < 16.0D) {
+ double d1;
+
+- if (livingentity == entity) {
++ if (entityliving == entity) {
+ d1 = 1.0D;
+ } else {
+ d1 = 1.0D - Math.sqrt(d0) / 4.0D;
+ }
+
+- Iterator iterator1 = list.iterator();
++ // CraftBukkit start
++ affected.put((LivingEntity) entityliving.getBukkitEntity(), d1);
++ }
++ }
++ }
++ }
+
+- while (iterator1.hasNext()) {
+- MobEffectInstance mobeffectinstance = (MobEffectInstance) iterator1.next();
+- MobEffect mobeffect = mobeffectinstance.getEffect();
++ 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;
++ }
+
+- if (mobeffect.isInstantenous()) {
+- mobeffect.applyInstantenousEffect(this, this.getOwner(), livingentity, mobeffectinstance.getAmplifier(), d1);
+- } else {
+- int i = mobeffectinstance.mapDuration((j) -> {
+- return (int) (d1 * (double) j + 0.5D);
+- });
+- MobEffectInstance mobeffectinstance1 = new MobEffectInstance(mobeffect, i, mobeffectinstance.getAmplifier(), mobeffectinstance.isAmbient(), mobeffectinstance.isVisible());
++ net.minecraft.world.entity.LivingEntity entityliving = ((CraftLivingEntity) victim).getHandle();
++ double d1 = event.getIntensity(victim);
++ // CraftBukkit end
+
+- if (!mobeffectinstance1.endsWithin(20)) {
+- livingentity.addEffect(mobeffectinstance1, entity1);
+- }
+- }
++ 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 itemstack, Potion potion) {
+- AreaEffectCloud areaeffectcloud = new AreaEffectCloud(this.level(), this.getX(), this.getY(), this.getZ());
++ 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 LivingEntity) {
+- areaeffectcloud.setOwner((LivingEntity) entity);
++ if (entity instanceof net.minecraft.world.entity.LivingEntity) {
++ entityareaeffectcloud.setOwner((net.minecraft.world.entity.LivingEntity) entity);
+ }
+
+- areaeffectcloud.setRadius(3.0F);
+- areaeffectcloud.setRadiusOnUse(-0.5F);
+- areaeffectcloud.setWaitTime(10);
+- areaeffectcloud.setRadiusPerTick(-areaeffectcloud.getRadius() / (float) areaeffectcloud.getDuration());
+- areaeffectcloud.setPotion(potion);
++ entityareaeffectcloud.setRadius(3.0F);
++ entityareaeffectcloud.setRadiusOnUse(-0.5F);
++ entityareaeffectcloud.setWaitTime(10);
++ entityareaeffectcloud.setRadiusPerTick(-entityareaeffectcloud.getRadius() / (float) entityareaeffectcloud.getDuration());
++ entityareaeffectcloud.setPotion(potionregistry);
+ Iterator iterator = PotionUtils.getCustomEffects(itemstack).iterator();
+
+ while (iterator.hasNext()) {
+- MobEffectInstance mobeffectinstance = (MobEffectInstance) iterator.next();
++ MobEffectInstance mobeffect = (MobEffectInstance) iterator.next();
+
+- areaeffectcloud.addEffect(new MobEffectInstance(mobeffectinstance));
++ entityareaeffectcloud.addEffect(new MobEffectInstance(mobeffect));
+ }
+
+- CompoundTag compoundtag = itemstack.getTag();
++ CompoundTag nbttagcompound = itemstack.getTag();
+
+- if (compoundtag != null && compoundtag.contains("CustomPotionColor", 99)) {
+- areaeffectcloud.setFixedColor(compoundtag.getInt("CustomPotionColor"));
++ if (nbttagcompound != null && nbttagcompound.contains("CustomPotionColor", 99)) {
++ entityareaeffectcloud.setFixedColor(nbttagcompound.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() {
++ public boolean isLingering() {
+ return this.getItem().is(Items.LINGERING_POTION);
+ }
+
+- private void dowseFire(BlockPos blockpos) {
+- BlockState blockstate = this.level().getBlockState(blockpos);
++ private void dowseFire(BlockPos pos) {
++ IBlockData iblockdata = this.level().getBlockState(pos);
+
+- if (blockstate.is(BlockTags.FIRE)) {
+- this.level().destroyBlock(blockpos, false, this);
+- } else if (AbstractCandleBlock.isLit(blockstate)) {
+- AbstractCandleBlock.extinguish((Player) null, blockstate, this.level(), blockpos);
+- } else if (CampfireBlock.isLitCampfire(blockstate)) {
+- this.level().levelEvent((Player) null, 1009, blockpos, 0);
+- CampfireBlock.dowse(this.getOwner(), this.level(), blockpos, blockstate);
+- this.level().setBlockAndUpdate(blockpos, (BlockState) blockstate.setValue(CampfireBlock.LIT, false));
++ 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
+ }
+
+ }