aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-spigotflower/net/minecraft/world/entity/animal/Pufferfish.java.patch
blob: b99f78dc6547a30e249b6b5987e737743a3f9973 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
--- a/net/minecraft/world/entity/animal/Pufferfish.java
+++ b/net/minecraft/world/entity/animal/Pufferfish.java
@@ -15,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;
@@ -32,21 +32,20 @@
     private static final EntityDataAccessor<Integer> PUFF_STATE = SynchedEntityData.defineId(Pufferfish.class, EntityDataSerializers.INT);
     int inflateCounter;
     int deflateTimer;
-    private static final Predicate<LivingEntity> SCARY_MOB = (livingentity) -> {
-        return livingentity instanceof Player && ((Player) livingentity).isCreative() ? false : livingentity.getType() == EntityType.AXOLOTL || livingentity.getMobType() != MobType.WATER;
+    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;
 
-    public Pufferfish(EntityType<? extends Pufferfish> entitytype, Level level) {
-        super(entitytype, level);
+    public Pufferfish(EntityType<? extends Pufferfish> entityType, Level level) {
+        super(entityType, level);
         this.refreshDimensions();
     }
 
     @Override
-    @Override
     protected void defineSynchedData() {
         super.defineSynchedData();
         this.entityData.define(Pufferfish.PUFF_STATE, 0);
@@ -56,49 +55,43 @@
         return (Integer) this.entityData.get(Pufferfish.PUFF_STATE);
     }
 
-    public void setPuffState(int i) {
-        this.entityData.set(Pufferfish.PUFF_STATE, i);
+    public void setPuffState(int puffState) {
+        this.entityData.set(Pufferfish.PUFF_STATE, puffState);
     }
 
     @Override
-    @Override
-    public void onSyncedDataUpdated(EntityDataAccessor<?> entitydataaccessor) {
-        if (Pufferfish.PUFF_STATE.equals(entitydataaccessor)) {
+    public void onSyncedDataUpdated(EntityDataAccessor<?> key) {
+        if (Pufferfish.PUFF_STATE.equals(key)) {
             this.refreshDimensions();
         }
 
-        super.onSyncedDataUpdated(entitydataaccessor);
+        super.onSyncedDataUpdated(key);
     }
 
     @Override
-    @Override
-    public void addAdditionalSaveData(CompoundTag compoundtag) {
-        super.addAdditionalSaveData(compoundtag);
-        compoundtag.putInt("PuffState", this.getPuffState());
+    public void addAdditionalSaveData(CompoundTag compound) {
+        super.addAdditionalSaveData(compound);
+        compound.putInt("PuffState", this.getPuffState());
     }
 
     @Override
-    @Override
-    public void readAdditionalSaveData(CompoundTag compoundtag) {
-        super.readAdditionalSaveData(compoundtag);
-        this.setPuffState(Math.min(compoundtag.getInt("PuffState"), 2));
+    public void readAdditionalSaveData(CompoundTag compound) {
+        super.readAdditionalSaveData(compound);
+        this.setPuffState(Math.min(compound.getInt("PuffState"), 2));
     }
 
     @Override
-    @Override
     public ItemStack getBucketItemStack() {
         return new ItemStack(Items.PUFFERFISH_BUCKET);
     }
 
     @Override
-    @Override
     protected void registerGoals() {
         super.registerGoals();
         this.goalSelector.addGoal(1, new Pufferfish.PufferfishPuffGoal(this));
     }
 
     @Override
-    @Override
     public void tick() {
         if (!this.level().isClientSide && this.isAlive() && this.isEffectiveAi()) {
             if (this.inflateCounter > 0) {
@@ -128,20 +121,19 @@
     }
 
     @Override
-    @Override
     public void aiStep() {
         super.aiStep();
         if (this.isAlive() && this.getPuffState() > 0) {
-            List<Mob> list = this.level().getEntitiesOfClass(Mob.class, this.getBoundingBox().inflate(0.3D), (mob) -> {
-                return Pufferfish.targetingConditions.test(this, 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 mob = (Mob) iterator.next();
+                Mob entityinsentient = (Mob) iterator.next();
 
-                if (mob.isAlive()) {
-                    this.touch(mob);
+                if (entityinsentient.isAlive()) {
+                    this.touch(entityinsentient);
                 }
             }
         }
@@ -152,59 +144,53 @@
         int i = this.getPuffState();
 
         if (mob.hurt(this.damageSources().mobAttack(this), (float) (1 + i))) {
-            mob.addEffect(new MobEffectInstance(MobEffects.POISON, 60 * i, 0), this);
+            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
-    @Override
-    public void playerTouch(Player player) {
+    public void playerTouch(Player entity) {
         int i = this.getPuffState();
 
-        if (player instanceof ServerPlayer && i > 0 && player.hurt(this.damageSources().mobAttack(this), (float) (1 + i))) {
+        if (entity instanceof ServerPlayer && i > 0 && entity.hurt(this.damageSources().mobAttack(this), (float) (1 + i))) {
             if (!this.isSilent()) {
-                ((ServerPlayer) player).connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.PUFFER_FISH_STING, 0.0F));
+                ((ServerPlayer) entity).connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.PUFFER_FISH_STING, 0.0F));
             }
 
-            player.addEffect(new MobEffectInstance(MobEffects.POISON, 60 * i, 0), this);
+            entity.addEffect(new MobEffectInstance(MobEffects.POISON, 60 * i, 0), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
         }
 
     }
 
     @Override
-    @Override
     protected SoundEvent getAmbientSound() {
         return SoundEvents.PUFFER_FISH_AMBIENT;
     }
 
     @Override
-    @Override
     protected SoundEvent getDeathSound() {
         return SoundEvents.PUFFER_FISH_DEATH;
     }
 
     @Override
-    @Override
-    protected SoundEvent getHurtSound(DamageSource damagesource) {
+    protected SoundEvent getHurtSound(DamageSource damageSource) {
         return SoundEvents.PUFFER_FISH_HURT;
     }
 
     @Override
-    @Override
     protected SoundEvent getFlopSound() {
         return SoundEvents.PUFFER_FISH_FLOP;
     }
 
     @Override
-    @Override
-    public EntityDimensions getDimensions(Pose pose) {
+    public EntityDimensions getDimensions(EntityPose pose) {
         return super.getDimensions(pose).scale(getScale(this.getPuffState()));
     }
 
-    private static float getScale(int i) {
-        switch (i) {
+    private static float getScale(int puffState) {
+        switch (puffState) {
             case 0:
                 return 0.5F;
             case 1:
@@ -218,29 +204,26 @@
 
         private final Pufferfish fish;
 
-        public PufferfishPuffGoal(Pufferfish pufferfish) {
-            this.fish = pufferfish;
+        public PufferfishPuffGoal(Pufferfish fish) {
+            this.fish = fish;
         }
 
         @Override
-        @Override
         public boolean canUse() {
-            List<LivingEntity> list = this.fish.level().getEntitiesOfClass(LivingEntity.class, this.fish.getBoundingBox().inflate(2.0D), (livingentity) -> {
-                return Pufferfish.targetingConditions.test(this.fish, livingentity);
+            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
-        @Override
         public void start() {
             this.fish.inflateCounter = 1;
             this.fish.deflateTimer = 0;
         }
 
         @Override
-        @Override
         public void stop() {
             this.fish.inflateCounter = 0;
         }