diff options
author | MiniDigger | Martin <[email protected]> | 2024-01-14 11:04:49 +0100 |
---|---|---|
committer | MiniDigger | Martin <[email protected]> | 2024-01-14 11:04:49 +0100 |
commit | bee74680e607c2e29b038329f62181238911cd83 (patch) | |
tree | 708fd1a4a0227d9071243adf2a42d5e9e96cde4a /patch-remap/mache-vineflower/net/minecraft/world/entity/animal/Pufferfish.java.patch | |
parent | 0a44692ef6ff6e255d48eb3ba1bb114166eafda9 (diff) | |
download | Paper-softspoon.tar.gz Paper-softspoon.zip |
add remapped patches as a testsoftspoon
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/entity/animal/Pufferfish.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/world/entity/animal/Pufferfish.java.patch | 179 |
1 files changed, 179 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/entity/animal/Pufferfish.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/entity/animal/Pufferfish.java.patch new file mode 100644 index 0000000000..105bd6b9c1 --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/world/entity/animal/Pufferfish.java.patch @@ -0,0 +1,179 @@ +--- a/net/minecraft/world/entity/animal/Pufferfish.java ++++ b/net/minecraft/world/entity/animal/Pufferfish.java +@@ -1,5 +1,6 @@ + package net.minecraft.world.entity.animal; + ++import java.util.Iterator; + import java.util.List; + import java.util.function.Predicate; + import net.minecraft.nbt.CompoundTag; +@@ -14,11 +15,11 @@ + import net.minecraft.world.effect.MobEffectInstance; + import net.minecraft.world.effect.MobEffects; + import net.minecraft.world.entity.EntityDimensions; ++import net.minecraft.world.entity.EntityPose; + import net.minecraft.world.entity.EntityType; ++import net.minecraft.world.entity.EnumMonsterType; + import net.minecraft.world.entity.LivingEntity; + import net.minecraft.world.entity.Mob; +-import net.minecraft.world.entity.MobType; +-import net.minecraft.world.entity.Pose; + import net.minecraft.world.entity.ai.goal.Goal; + import net.minecraft.world.entity.ai.targeting.TargetingConditions; + import net.minecraft.world.entity.player.Player; +@@ -27,15 +28,14 @@ + import net.minecraft.world.level.Level; + + public class Pufferfish extends AbstractFish { ++ + private static final EntityDataAccessor<Integer> PUFF_STATE = SynchedEntityData.defineId(Pufferfish.class, EntityDataSerializers.INT); + int inflateCounter; + int deflateTimer; +- private static final Predicate<LivingEntity> SCARY_MOB = entity -> (!(entity instanceof Player) || !((Player)entity).isCreative()) +- && (entity.getType() == EntityType.AXOLOTL || entity.getMobType() != MobType.WATER); +- static final TargetingConditions targetingConditions = TargetingConditions.forNonCombat() +- .ignoreInvisibilityTesting() +- .ignoreLineOfSight() +- .selector(SCARY_MOB); ++ private static final Predicate<LivingEntity> SCARY_MOB = (entityliving) -> { ++ return entityliving instanceof Player && ((Player) entityliving).isCreative() ? false : entityliving.getType() == EntityType.AXOLOTL || entityliving.getMobType() != EnumMonsterType.WATER; ++ }; ++ static final TargetingConditions targetingConditions = TargetingConditions.forNonCombat().ignoreInvisibilityTesting().ignoreLineOfSight().selector(Pufferfish.SCARY_MOB); + public static final int STATE_SMALL = 0; + public static final int STATE_MID = 1; + public static final int STATE_FULL = 2; +@@ -48,20 +48,20 @@ + @Override + protected void defineSynchedData() { + super.defineSynchedData(); +- this.entityData.define(PUFF_STATE, 0); ++ this.entityData.define(Pufferfish.PUFF_STATE, 0); + } + + public int getPuffState() { +- return this.entityData.get(PUFF_STATE); ++ return (Integer) this.entityData.get(Pufferfish.PUFF_STATE); + } + + public void setPuffState(int puffState) { +- this.entityData.set(PUFF_STATE, puffState); ++ this.entityData.set(Pufferfish.PUFF_STATE, puffState); + } + + @Override + public void onSyncedDataUpdated(EntityDataAccessor<?> key) { +- if (PUFF_STATE.equals(key)) { ++ if (Pufferfish.PUFF_STATE.equals(key)) { + this.refreshDimensions(); + } + +@@ -103,7 +103,7 @@ + this.setPuffState(2); + } + +- this.inflateCounter++; ++ ++this.inflateCounter; + } else if (this.getPuffState() != 0) { + if (this.deflateTimer > 60 && this.getPuffState() == 2) { + this.playSound(SoundEvents.PUFFER_FISH_BLOW_OUT, this.getSoundVolume(), this.getVoicePitch()); +@@ -113,7 +113,7 @@ + this.setPuffState(0); + } + +- this.deflateTimer++; ++ ++this.deflateTimer; + } + } + +@@ -124,32 +124,44 @@ + public void aiStep() { + super.aiStep(); + if (this.isAlive() && this.getPuffState() > 0) { +- for (Mob mob : this.level().getEntitiesOfClass(Mob.class, this.getBoundingBox().inflate(0.3), entity -> targetingConditions.test(this, entity))) { +- if (mob.isAlive()) { +- this.touch(mob); ++ List<Mob> list = this.level().getEntitiesOfClass(Mob.class, this.getBoundingBox().inflate(0.3D), (entityinsentient) -> { ++ return Pufferfish.targetingConditions.test(this, entityinsentient); ++ }); ++ Iterator iterator = list.iterator(); ++ ++ while (iterator.hasNext()) { ++ Mob entityinsentient = (Mob) iterator.next(); ++ ++ if (entityinsentient.isAlive()) { ++ this.touch(entityinsentient); + } + } + } ++ + } + + private void touch(Mob mob) { +- int puffState = this.getPuffState(); +- if (mob.hurt(this.damageSources().mobAttack(this), (float)(1 + puffState))) { +- mob.addEffect(new MobEffectInstance(MobEffects.POISON, 60 * puffState, 0), this); ++ int i = this.getPuffState(); ++ ++ if (mob.hurt(this.damageSources().mobAttack(this), (float) (1 + i))) { ++ mob.addEffect(new MobEffectInstance(MobEffects.POISON, 60 * i, 0), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit + this.playSound(SoundEvents.PUFFER_FISH_STING, 1.0F, 1.0F); + } ++ + } + + @Override + public void playerTouch(Player entity) { +- int puffState = this.getPuffState(); +- if (entity instanceof ServerPlayer && puffState > 0 && entity.hurt(this.damageSources().mobAttack(this), (float)(1 + puffState))) { ++ int i = this.getPuffState(); ++ ++ if (entity instanceof ServerPlayer && i > 0 && entity.hurt(this.damageSources().mobAttack(this), (float) (1 + i))) { + if (!this.isSilent()) { +- ((ServerPlayer)entity).connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.PUFFER_FISH_STING, 0.0F)); ++ ((ServerPlayer) entity).connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.PUFFER_FISH_STING, 0.0F)); + } + +- entity.addEffect(new MobEffectInstance(MobEffects.POISON, 60 * puffState, 0), this); ++ entity.addEffect(new MobEffectInstance(MobEffects.POISON, 60 * i, 0), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit + } ++ + } + + @Override +@@ -173,7 +185,7 @@ + } + + @Override +- public EntityDimensions getDimensions(Pose pose) { ++ public EntityDimensions getDimensions(EntityPose pose) { + return super.getDimensions(pose).scale(getScale(this.getPuffState())); + } + +@@ -188,7 +200,8 @@ + } + } + +- static class PufferfishPuffGoal extends Goal { ++ private static class PufferfishPuffGoal extends Goal { ++ + private final Pufferfish fish; + + public PufferfishPuffGoal(Pufferfish fish) { +@@ -197,12 +210,11 @@ + + @Override + public boolean canUse() { +- List<LivingEntity> entitiesOfClass = this.fish +- .level() +- .getEntitiesOfClass( +- LivingEntity.class, this.fish.getBoundingBox().inflate(2.0), livingEntity -> Pufferfish.targetingConditions.test(this.fish, livingEntity) +- ); +- return !entitiesOfClass.isEmpty(); ++ List<LivingEntity> list = this.fish.level().getEntitiesOfClass(LivingEntity.class, this.fish.getBoundingBox().inflate(2.0D), (entityliving) -> { ++ return Pufferfish.targetingConditions.test(this.fish, entityliving); ++ }); ++ ++ return !list.isEmpty(); + } + + @Override |