forked from kettingpowered/Ketting-1-20-x
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'kettingpowered:1.20.x' into 1.20.x
- Loading branch information
Showing
11 changed files
with
1,335 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 110 additions & 0 deletions
110
patches/minecraft/net/minecraft/world/entity/AreaEffectCloud.java.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
--- a/net/minecraft/world/entity/AreaEffectCloud.java | ||
+++ b/net/minecraft/world/entity/AreaEffectCloud.java | ||
@@ -5,6 +_,8 @@ | ||
import com.mojang.brigadier.StringReader; | ||
import com.mojang.brigadier.exceptions.CommandSyntaxException; | ||
import com.mojang.logging.LogUtils; | ||
+ | ||
+import java.util.Iterator; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.UUID; | ||
@@ -20,12 +_,14 @@ | ||
import net.minecraft.network.syncher.SynchedEntityData; | ||
import net.minecraft.server.level.ServerLevel; | ||
import net.minecraft.util.Mth; | ||
+import net.minecraft.world.effect.MobEffect; | ||
import net.minecraft.world.effect.MobEffectInstance; | ||
import net.minecraft.world.item.alchemy.Potion; | ||
import net.minecraft.world.item.alchemy.PotionUtils; | ||
import net.minecraft.world.item.alchemy.Potions; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraft.world.level.material.PushReaction; | ||
+import org.bukkit.craftbukkit.v1_20_R2.entity.CraftLivingEntity; | ||
import org.slf4j.Logger; | ||
|
||
public class AreaEffectCloud extends Entity implements TraceableEntity { | ||
@@ -41,16 +_,16 @@ | ||
public static final float DEFAULT_WIDTH = 6.0F; | ||
public static final float HEIGHT = 0.5F; | ||
private static final String TAG_EFFECTS = "effects"; | ||
- private Potion potion = Potions.EMPTY; | ||
- private final List<MobEffectInstance> effects = Lists.newArrayList(); | ||
+ public Potion potion = Potions.EMPTY; | ||
+ public final List<MobEffectInstance> effects = Lists.newArrayList(); | ||
private final Map<Entity, Integer> victims = Maps.newHashMap(); | ||
private int duration = 600; | ||
private int waitTime = 20; | ||
- private int reapplicationDelay = 20; | ||
+ public int reapplicationDelay = 20; | ||
private boolean fixedColor; | ||
- private int durationOnUse; | ||
- private float radiusOnUse; | ||
- private float radiusPerTick; | ||
+ public int durationOnUse; | ||
+ public float radiusOnUse; | ||
+ public float radiusPerTick; | ||
@Nullable | ||
private LivingEntity owner; | ||
@Nullable | ||
@@ -150,6 +_,18 @@ | ||
this.duration = p_19735_; | ||
} | ||
|
||
+ // Spigot start - copied from below | ||
+ @Override | ||
+ public void inactiveTick() { | ||
+ super.inactiveTick(); | ||
+ | ||
+ if (this.tickCount >= this.waitTime + this.duration) { | ||
+ this.discard(); | ||
+ return; | ||
+ } | ||
+ } | ||
+ // Spigot end | ||
+ | ||
public void tick() { | ||
super.tick(); | ||
boolean flag = this.isWaiting(); | ||
@@ -239,19 +_,35 @@ | ||
} else { | ||
List<LivingEntity> list1 = this.level().getEntitiesOfClass(LivingEntity.class, this.getBoundingBox()); | ||
if (!list1.isEmpty()) { | ||
+ List<org.bukkit.entity.LivingEntity> entities = new java.util.ArrayList<org.bukkit.entity.LivingEntity>(); // CraftBukkit | ||
for(LivingEntity livingentity : list1) { | ||
if (!this.victims.containsKey(livingentity) && livingentity.isAffectedByPotions()) { | ||
double d8 = livingentity.getX() - this.getX(); | ||
double d1 = livingentity.getZ() - this.getZ(); | ||
double d3 = d8 * d8 + d1 * d1; | ||
if (d3 <= (double)(f * f)) { | ||
- this.victims.put(livingentity, this.tickCount + this.reapplicationDelay); | ||
- | ||
- for(MobEffectInstance mobeffectinstance1 : list) { | ||
- if (mobeffectinstance1.getEffect().isInstantenous()) { | ||
- mobeffectinstance1.getEffect().applyInstantenousEffect(this, this.getOwner(), livingentity, mobeffectinstance1.getAmplifier(), 0.5D); | ||
+ // CraftBukkit start | ||
+ entities.add((org.bukkit.entity.LivingEntity) livingentity.getBukkitEntity()); | ||
+ } | ||
+ } | ||
+ } | ||
+ | ||
+ org.bukkit.event.entity.AreaEffectCloudApplyEvent event = org.bukkit.craftbukkit.v1_20_R2.event.CraftEventFactory.callAreaEffectCloudApplyEvent(this, entities); | ||
+ if (!event.isCancelled()) { | ||
+ for (org.bukkit.entity.LivingEntity entity : event.getAffectedEntities()) { | ||
+ if (entity instanceof CraftLivingEntity) { | ||
+ LivingEntity entityliving = ((CraftLivingEntity) entity).getHandle(); | ||
+ // CraftBukkit end | ||
+ this.victims.put(entityliving, this.tickCount + this.reapplicationDelay); | ||
+ Iterator iterator2 = list.iterator(); | ||
+ | ||
+ while (iterator2.hasNext()) { | ||
+ MobEffectInstance mobeffect1 = (MobEffectInstance) iterator2.next(); | ||
+ | ||
+ if (mobeffect1.getEffect().isInstantenous()) { | ||
+ mobeffect1.getEffect().applyInstantenousEffect(this, this.getOwner(), entityliving, mobeffect1.getAmplifier(), 0.5D); | ||
} else { | ||
- livingentity.addEffect(new MobEffectInstance(mobeffectinstance1), this); | ||
+ entityliving.addEffect(new MobEffectInstance(mobeffect1), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.AREA_EFFECT_CLOUD); // CraftBukkit | ||
} | ||
} | ||
|
Oops, something went wrong.