Remove broken code (#12171)
This commit is contained in:
@ -1,14 +1,6 @@
|
|||||||
--- a/net/minecraft/world/entity/projectile/ThrownPotion.java
|
--- a/net/minecraft/world/entity/projectile/ThrownPotion.java
|
||||||
+++ b/net/minecraft/world/entity/projectile/ThrownPotion.java
|
+++ b/net/minecraft/world/entity/projectile/ThrownPotion.java
|
||||||
@@ -9,6 +_,7 @@
|
@@ -82,51 +_,86 @@
|
||||||
import net.minecraft.core.Holder;
|
|
||||||
import net.minecraft.core.component.DataComponents;
|
|
||||||
import net.minecraft.server.level.ServerLevel;
|
|
||||||
+import net.minecraft.server.level.ServerPlayer;
|
|
||||||
import net.minecraft.tags.BlockTags;
|
|
||||||
import net.minecraft.world.damagesource.DamageSource;
|
|
||||||
import net.minecraft.world.effect.MobEffect;
|
|
||||||
@@ -82,51 +_,87 @@
|
|
||||||
@Override
|
@Override
|
||||||
protected void onHit(HitResult result) {
|
protected void onHit(HitResult result) {
|
||||||
super.onHit(result);
|
super.onHit(result);
|
||||||
@ -28,12 +20,12 @@
|
|||||||
+ } else if (true || potionContents.hasEffects()) { // CraftBukkit - Call event even if no effects to apply
|
+ } else if (true || potionContents.hasEffects()) { // CraftBukkit - Call event even if no effects to apply
|
||||||
if (this.isLingering()) {
|
if (this.isLingering()) {
|
||||||
- this.makeAreaOfEffectCloud(potionContents);
|
- this.makeAreaOfEffectCloud(potionContents);
|
||||||
+ showParticles = this.makeAreaOfEffectCloud(potionContents, result); // CraftBukkit - Pass MovingObjectPosition // Paper
|
+ showParticles = this.makeAreaOfEffectCloud(potionContents, result); // CraftBukkit - Pass HitResult // Paper
|
||||||
} else {
|
} else {
|
||||||
- this.applySplash(
|
- this.applySplash(
|
||||||
- serverLevel, potionContents.getAllEffects(), result.getType() == HitResult.Type.ENTITY ? ((EntityHitResult)result).getEntity() : null
|
- serverLevel, potionContents.getAllEffects(), result.getType() == HitResult.Type.ENTITY ? ((EntityHitResult)result).getEntity() : null
|
||||||
+ showParticles = this.applySplash(
|
+ showParticles = this.applySplash( // Paper - Fix potions splash events
|
||||||
+ serverLevel, potionContents.getAllEffects(), result != null && result.getType() == HitResult.Type.ENTITY ? ((EntityHitResult)result).getEntity() : null, result // CraftBukkit - Pass MovingObjectPosition // Paper - More projectile API
|
+ serverLevel, potionContents.getAllEffects(), result != null && result.getType() == HitResult.Type.ENTITY ? ((EntityHitResult)result).getEntity() : null, result // CraftBukkit - Pass HitResult // Paper - More projectile API
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -48,7 +40,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
- private void applyWater(ServerLevel level) {
|
- private void applyWater(ServerLevel level) {
|
||||||
+ private static final Predicate<net.minecraft.world.entity.LivingEntity> APPLY_WATER_GET_ENTITIES_PREDICATE = ThrownPotion.WATER_SENSITIVE_OR_ON_FIRE.or(Axolotl.class::isInstance); // Paper - Fix potions splash events
|
+ private static final Predicate<LivingEntity> APPLY_WATER_GET_ENTITIES_PREDICATE = ThrownPotion.WATER_SENSITIVE_OR_ON_FIRE.or(Axolotl.class::isInstance); // Paper - Fix potions splash events
|
||||||
+
|
+
|
||||||
+ private boolean applyWater(ServerLevel level, @Nullable HitResult result) { // Paper - Fix potions splash events
|
+ private boolean applyWater(ServerLevel level, @Nullable HitResult result) { // Paper - Fix potions splash events
|
||||||
AABB aabb = this.getBoundingBox().inflate(4.0, 2.0, 4.0);
|
AABB aabb = this.getBoundingBox().inflate(4.0, 2.0, 4.0);
|
||||||
@ -67,20 +59,19 @@
|
|||||||
if (d < 16.0) {
|
if (d < 16.0) {
|
||||||
if (livingEntity.isSensitiveToWater()) {
|
if (livingEntity.isSensitiveToWater()) {
|
||||||
- livingEntity.hurtServer(level, this.damageSources().indirectMagic(this, this.getOwner()), 1.0F);
|
- livingEntity.hurtServer(level, this.damageSources().indirectMagic(this, this.getOwner()), 1.0F);
|
||||||
+ affected.put(livingEntity.getBukkitLivingEntity(), 1.0);
|
+ affected.put(livingEntity.getBukkitLivingEntity(), 1.0); // Paper - Fix potions splash events
|
||||||
+ // livingEntity.hurtServer(level, this.damageSources().indirectMagic(this, this.getOwner()), 1.0F);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (livingEntity.isOnFire() && livingEntity.isAlive()) {
|
if (livingEntity.isOnFire() && livingEntity.isAlive()) {
|
||||||
- livingEntity.extinguishFire();
|
- livingEntity.extinguishFire();
|
||||||
+ extinguish.add(livingEntity.getBukkitLivingEntity());
|
+ extinguish.add(livingEntity.getBukkitLivingEntity()); // Paper - Fix potions splash events
|
||||||
+ // livingEntity.extinguishFire();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- for (Axolotl axolotl : this.level().getEntitiesOfClass(Axolotl.class, aabb)) {
|
- for (Axolotl axolotl : this.level().getEntitiesOfClass(Axolotl.class, aabb)) {
|
||||||
- axolotl.rehydrate();
|
- axolotl.rehydrate();
|
||||||
|
+ // Paper start - Fix potions splash events
|
||||||
+ io.papermc.paper.event.entity.WaterBottleSplashEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callWaterBottleSplashEvent(
|
+ io.papermc.paper.event.entity.WaterBottleSplashEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callWaterBottleSplashEvent(
|
||||||
+ this, result, affected, rehydrate, extinguish
|
+ this, result, affected, rehydrate, extinguish
|
||||||
+ );
|
+ );
|
||||||
@ -102,14 +93,14 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
- private void applySplash(ServerLevel level, Iterable<MobEffectInstance> effects, @Nullable Entity entity) {
|
- private void applySplash(ServerLevel level, Iterable<MobEffectInstance> effects, @Nullable Entity entity) {
|
||||||
+ private boolean applySplash(ServerLevel level, Iterable<MobEffectInstance> effects, @Nullable Entity entity, @Nullable HitResult result) { // CraftBukkit - Pass MovingObjectPosition // Paper - Fix potions splash events & More projectile API
|
+ private boolean applySplash(ServerLevel level, Iterable<MobEffectInstance> effects, @Nullable Entity entity, @Nullable HitResult result) { // CraftBukkit - Pass HitResult // Paper - Fix potions splash events & More projectile API
|
||||||
AABB aabb = this.getBoundingBox().inflate(4.0, 2.0, 4.0);
|
AABB aabb = this.getBoundingBox().inflate(4.0, 2.0, 4.0);
|
||||||
List<LivingEntity> entitiesOfClass = level.getEntitiesOfClass(LivingEntity.class, aabb);
|
List<LivingEntity> entitiesOfClass = level.getEntitiesOfClass(LivingEntity.class, aabb);
|
||||||
+ java.util.Map<org.bukkit.entity.LivingEntity, Double> affected = new java.util.HashMap<>(); // CraftBukkit
|
+ java.util.Map<org.bukkit.entity.LivingEntity, Double> affected = new java.util.HashMap<>(); // CraftBukkit
|
||||||
if (!entitiesOfClass.isEmpty()) {
|
if (!entitiesOfClass.isEmpty()) {
|
||||||
Entity effectSource = this.getEffectSource();
|
Entity effectSource = this.getEffectSource();
|
||||||
|
|
||||||
@@ -135,33 +_,57 @@
|
@@ -135,12 +_,31 @@
|
||||||
double d = this.distanceToSqr(livingEntity);
|
double d = this.distanceToSqr(livingEntity);
|
||||||
if (d < 16.0) {
|
if (d < 16.0) {
|
||||||
double d1;
|
double d1;
|
||||||
@ -120,69 +111,45 @@
|
|||||||
d1 = 1.0 - Math.sqrt(d) / 4.0;
|
d1 = 1.0 - Math.sqrt(d) / 4.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
- for (MobEffectInstance mobEffectInstance : effects) {
|
|
||||||
- Holder<MobEffect> effect = mobEffectInstance.getEffect();
|
|
||||||
- if (effect.value().isInstantenous()) {
|
|
||||||
- effect.value().applyInstantenousEffect(level, this, this.getOwner(), livingEntity, mobEffectInstance.getAmplifier(), d1);
|
|
||||||
- } else {
|
|
||||||
- int i = mobEffectInstance.mapDuration(i1 -> (int)(d1 * i1 + 0.5));
|
|
||||||
- MobEffectInstance mobEffectInstance1 = new MobEffectInstance(
|
|
||||||
- effect, i, mobEffectInstance.getAmplifier(), mobEffectInstance.isAmbient(), mobEffectInstance.isVisible()
|
|
||||||
- );
|
|
||||||
- if (!mobEffectInstance1.endsWithin(20)) {
|
|
||||||
- livingEntity.addEffect(mobEffectInstance1, effectSource);
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
+ affected.put(livingEntity.getBukkitLivingEntity(), d1);
|
+ affected.put(livingEntity.getBukkitLivingEntity(), d1);
|
||||||
|
+ // CraftBukkit start
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+ org.bukkit.event.entity.PotionSplashEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPotionSplashEvent(this, result, affected);
|
+ org.bukkit.event.entity.PotionSplashEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPotionSplashEvent(this, result, affected);
|
||||||
+ if (!event.isCancelled() && entitiesOfClass != null && !entitiesOfClass.isEmpty()) { // do not process effects if there are no effects to process
|
+ if (!event.isCancelled() && !entitiesOfClass.isEmpty()) { // do not process effects if there are no effects to process
|
||||||
+ Entity effectSource = this.getEffectSource();
|
+ Entity effectSource = this.getEffectSource();
|
||||||
+ for (org.bukkit.entity.LivingEntity victim : event.getAffectedEntities()) {
|
+ for (org.bukkit.entity.LivingEntity victim : event.getAffectedEntities()) {
|
||||||
+ if (!(victim instanceof org.bukkit.craftbukkit.entity.CraftLivingEntity craftLivingEntity)) {
|
+ if (!(victim instanceof org.bukkit.craftbukkit.entity.CraftLivingEntity craftLivingEntity)) {
|
||||||
+ continue;
|
+ continue;
|
||||||
+ }
|
+ }
|
||||||
+ net.minecraft.world.entity.LivingEntity livingEntity = craftLivingEntity.getHandle();
|
+ LivingEntity livingEntity = craftLivingEntity.getHandle();
|
||||||
+ double d1 = event.getIntensity(victim);
|
+ double d1 = event.getIntensity(victim);
|
||||||
|
+ {
|
||||||
|
+ {
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
+ for (MobEffectInstance mobEffectInstance : effects) {
|
for (MobEffectInstance mobEffectInstance : effects) {
|
||||||
+ Holder<MobEffect> effect = mobEffectInstance.getEffect();
|
Holder<MobEffect> effect = mobEffectInstance.getEffect();
|
||||||
+ // CraftBukkit start - Abide by PVP settings - for players only!
|
if (effect.value().isInstantenous()) {
|
||||||
+ if (!this.level().pvpMode && this.getOwner() instanceof ServerPlayer && livingEntity instanceof ServerPlayer && livingEntity != this.getOwner()) {
|
@@ -151,7 +_,7 @@
|
||||||
+ MobEffect mobEffect = effect.value();
|
effect, i, mobEffectInstance.getAmplifier(), mobEffectInstance.isAmbient(), mobEffectInstance.isVisible()
|
||||||
+ if (mobEffect == net.minecraft.world.effect.MobEffects.MOVEMENT_SLOWDOWN || mobEffect == net.minecraft.world.effect.MobEffects.DIG_SLOWDOWN || mobEffect == net.minecraft.world.effect.MobEffects.HARM || mobEffect == net.minecraft.world.effect.MobEffects.BLINDNESS
|
);
|
||||||
+ || mobEffect == net.minecraft.world.effect.MobEffects.HUNGER || mobEffect == net.minecraft.world.effect.MobEffects.WEAKNESS || mobEffect == net.minecraft.world.effect.MobEffects.POISON) {
|
if (!mobEffectInstance1.endsWithin(20)) {
|
||||||
+ continue;
|
- livingEntity.addEffect(mobEffectInstance1, effectSource);
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ // CraftBukkit end
|
|
||||||
+ if (effect.value().isInstantenous()) {
|
|
||||||
+ effect.value().applyInstantenousEffect(level, this, this.getOwner(), livingEntity, mobEffectInstance.getAmplifier(), d1);
|
|
||||||
+ } else {
|
|
||||||
+ int i = mobEffectInstance.mapDuration(i1 -> (int)(d1 * i1 + 0.5));
|
|
||||||
+ MobEffectInstance mobEffectInstance1 = new MobEffectInstance(
|
|
||||||
+ effect, i, mobEffectInstance.getAmplifier(), mobEffectInstance.isAmbient(), mobEffectInstance.isVisible()
|
|
||||||
+ );
|
|
||||||
+ if (!mobEffectInstance1.endsWithin(20)) {
|
|
||||||
+ livingEntity.addEffect(mobEffectInstance1, effectSource, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.POTION_SPLASH); // CraftBukkit
|
+ livingEntity.addEffect(mobEffectInstance1, effectSource, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.POTION_SPLASH); // CraftBukkit
|
||||||
+ }
|
}
|
||||||
+ }
|
}
|
||||||
+ }
|
}
|
||||||
+ }
|
@@ -159,9 +_,10 @@
|
||||||
+ }
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+ return !event.isCancelled(); // Paper - Fix potions splash events
|
+ return !event.isCancelled(); // Paper - Fix potions splash events
|
||||||
}
|
}
|
||||||
|
|
||||||
- private void makeAreaOfEffectCloud(PotionContents potionContents) {
|
- private void makeAreaOfEffectCloud(PotionContents potionContents) {
|
||||||
+ private boolean makeAreaOfEffectCloud(PotionContents potionContents, @Nullable HitResult result) { // CraftBukkit - Pass MovingObjectPosition // Paper - More projectile API
|
+ private boolean makeAreaOfEffectCloud(PotionContents potionContents, @Nullable HitResult result) { // CraftBukkit - Pass HitResult // Paper - More projectile API
|
||||||
AreaEffectCloud areaEffectCloud = new AreaEffectCloud(this.level(), this.getX(), this.getY(), this.getZ());
|
AreaEffectCloud areaEffectCloud = new AreaEffectCloud(this.level(), this.getX(), this.getY(), this.getZ());
|
||||||
if (this.getOwner() instanceof LivingEntity livingEntity) {
|
if (this.getOwner() instanceof LivingEntity livingEntity) {
|
||||||
areaEffectCloud.setOwner(livingEntity);
|
areaEffectCloud.setOwner(livingEntity);
|
||||||
@ -197,41 +164,30 @@
|
|||||||
+ if (!(event.isCancelled() || areaEffectCloud.isRemoved() || (!event.allowsEmptyCreation() && (noEffects && !areaEffectCloud.potionContents.hasEffects())))) { // Paper - don't spawn area effect cloud if the effects were empty and not changed during the event handling
|
+ if (!(event.isCancelled() || areaEffectCloud.isRemoved() || (!event.allowsEmptyCreation() && (noEffects && !areaEffectCloud.potionContents.hasEffects())))) { // Paper - don't spawn area effect cloud if the effects were empty and not changed during the event handling
|
||||||
+ this.level().addFreshEntity(areaEffectCloud);
|
+ this.level().addFreshEntity(areaEffectCloud);
|
||||||
+ } else {
|
+ } else {
|
||||||
+ areaEffectCloud.discard(null); // CraftBukkit - add Bukkit remove cause
|
+ areaEffectCloud.discard(null); // add Bukkit remove cause
|
||||||
+ }
|
+ }
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
+ return !event.isCancelled(); // Paper - Fix potions splash events
|
+ return !event.isCancelled(); // Paper - Fix potions splash events
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLingering() {
|
public boolean isLingering() {
|
||||||
@@ -182,13 +_,25 @@
|
@@ -182,13 +_,19 @@
|
||||||
private void dowseFire(BlockPos pos) {
|
private void dowseFire(BlockPos pos) {
|
||||||
BlockState blockState = this.level().getBlockState(pos);
|
BlockState blockState = this.level().getBlockState(pos);
|
||||||
if (blockState.is(BlockTags.FIRE)) {
|
if (blockState.is(BlockTags.FIRE)) {
|
||||||
- this.level().destroyBlock(pos, false, this);
|
|
||||||
+ // CraftBukkit start
|
|
||||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this, pos, blockState.getFluidState().createLegacyBlock())) { // Paper - fix wrong block state
|
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this, pos, blockState.getFluidState().createLegacyBlock())) { // Paper - fix wrong block state
|
||||||
+ this.level().destroyBlock(pos, false, this);
|
this.level().destroyBlock(pos, false, this);
|
||||||
+ }
|
+ } // CraftBukkit
|
||||||
+ // CraftBukkit end
|
|
||||||
} else if (AbstractCandleBlock.isLit(blockState)) {
|
} else if (AbstractCandleBlock.isLit(blockState)) {
|
||||||
- AbstractCandleBlock.extinguish(null, blockState, this.level(), pos);
|
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this, pos, blockState.setValue(AbstractCandleBlock.LIT, Boolean.valueOf(false)))) { // CraftBukkit
|
||||||
+ // CraftBukkit start
|
AbstractCandleBlock.extinguish(null, blockState, this.level(), pos);
|
||||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this, pos, blockState.setValue(AbstractCandleBlock.LIT, false))) {
|
+ } // CraftBukkit
|
||||||
+ AbstractCandleBlock.extinguish(null, blockState, this.level(), pos);
|
|
||||||
+ }
|
|
||||||
+ // CraftBukkit end
|
|
||||||
} else if (CampfireBlock.isLitCampfire(blockState)) {
|
} else if (CampfireBlock.isLitCampfire(blockState)) {
|
||||||
- this.level().levelEvent(null, 1009, pos, 0);
|
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this, pos, blockState.setValue(CampfireBlock.LIT, Boolean.valueOf(false)))) { // CraftBukkit
|
||||||
- CampfireBlock.dowse(this.getOwner(), this.level(), pos, blockState);
|
this.level().levelEvent(null, 1009, pos, 0);
|
||||||
- this.level().setBlockAndUpdate(pos, blockState.setValue(CampfireBlock.LIT, Boolean.valueOf(false)));
|
CampfireBlock.dowse(this.getOwner(), this.level(), pos, blockState);
|
||||||
+ // CraftBukkit start
|
this.level().setBlockAndUpdate(pos, blockState.setValue(CampfireBlock.LIT, Boolean.valueOf(false)));
|
||||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this, pos, blockState.setValue(CampfireBlock.LIT, false))) {
|
+ } // CraftBukkit
|
||||||
+ this.level().levelEvent(null, 1009, pos, 0);
|
|
||||||
+ CampfireBlock.dowse(this.getOwner(), this.level(), pos, blockState);
|
|
||||||
+ this.level().setBlockAndUpdate(pos, blockState.setValue(CampfireBlock.LIT, false));
|
|
||||||
+ }
|
|
||||||
+ // CraftBukkit end
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user