aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-vineflower/net/minecraft/world/entity/monster/Spider.java.patch
blob: 8019035f121fe544fc74b3fee0b59f92f15ff57d (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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
--- a/net/minecraft/world/entity/monster/Spider.java
+++ b/net/minecraft/world/entity/monster/Spider.java
@@ -17,12 +17,12 @@
 import net.minecraft.world.effect.MobEffects;
 import net.minecraft.world.entity.Entity;
 import net.minecraft.world.entity.EntityDimensions;
+import net.minecraft.world.entity.EntityPose;
 import net.minecraft.world.entity.EntityType;
+import net.minecraft.world.entity.EnumMobSpawn;
+import net.minecraft.world.entity.EnumMonsterType;
+import net.minecraft.world.entity.GroupDataEntity;
 import net.minecraft.world.entity.LivingEntity;
-import net.minecraft.world.entity.MobSpawnType;
-import net.minecraft.world.entity.MobType;
-import net.minecraft.world.entity.Pose;
-import net.minecraft.world.entity.SpawnGroupData;
 import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
 import net.minecraft.world.entity.ai.attributes.Attributes;
 import net.minecraft.world.entity.ai.goal.FloatGoal;
@@ -40,11 +40,12 @@
 import net.minecraft.world.level.Level;
 import net.minecraft.world.level.ServerLevelAccessor;
 import net.minecraft.world.level.block.Blocks;
-import net.minecraft.world.level.block.state.BlockState;
+import net.minecraft.world.level.block.state.IBlockData;
 import net.minecraft.world.phys.Vec3;
 import org.joml.Vector3f;
 
 public class Spider extends Monster {
+
     private static final EntityDataAccessor<Byte> DATA_FLAGS_ID = SynchedEntityData.defineId(Spider.class, EntityDataSerializers.BYTE);
     private static final float SPIDER_SPECIAL_EFFECT_CHANCE = 0.1F;
 
@@ -57,17 +58,17 @@
         this.goalSelector.addGoal(1, new FloatGoal(this));
         this.goalSelector.addGoal(3, new LeapAtTargetGoal(this, 0.4F));
         this.goalSelector.addGoal(4, new Spider.SpiderAttackGoal(this));
-        this.goalSelector.addGoal(5, new WaterAvoidingRandomStrollGoal(this, 0.8));
+        this.goalSelector.addGoal(5, new WaterAvoidingRandomStrollGoal(this, 0.8D));
         this.goalSelector.addGoal(6, new LookAtPlayerGoal(this, Player.class, 8.0F));
         this.goalSelector.addGoal(6, new RandomLookAroundGoal(this));
-        this.targetSelector.addGoal(1, new HurtByTargetGoal(this));
+        this.targetSelector.addGoal(1, new HurtByTargetGoal(this, new Class[0]));
         this.targetSelector.addGoal(2, new Spider.SpiderTargetGoal<>(this, Player.class));
         this.targetSelector.addGoal(3, new Spider.SpiderTargetGoal<>(this, IronGolem.class));
     }
 
     @Override
-    protected Vector3f getPassengerAttachmentPoint(Entity entity, EntityDimensions entityDimensions, float f) {
-        return new Vector3f(0.0F, entityDimensions.height * 0.85F, 0.0F);
+    protected Vector3f getPassengerAttachmentPoint(Entity entity, EntityDimensions entitysize, float f) {
+        return new Vector3f(0.0F, entitysize.height * 0.85F, 0.0F);
     }
 
     @Override
@@ -78,7 +79,7 @@
     @Override
     protected void defineSynchedData() {
         super.defineSynchedData();
-        this.entityData.define(DATA_FLAGS_ID, (byte)0);
+        this.entityData.define(Spider.DATA_FLAGS_ID, (byte) 0);
     }
 
     @Override
@@ -87,10 +88,11 @@
         if (!this.level().isClientSide) {
             this.setClimbing(this.horizontalCollision);
         }
+
     }
 
     public static AttributeSupplier.Builder createAttributes() {
-        return Monster.createMonsterAttributes().add(Attributes.MAX_HEALTH, 16.0).add(Attributes.MOVEMENT_SPEED, 0.3F);
+        return Monster.createMonsterAttributes().add(Attributes.MAX_HEALTH, 16.0D).add(Attributes.MOVEMENT_SPEED, 0.30000001192092896D);
     }
 
     @Override
@@ -109,7 +111,7 @@
     }
 
     @Override
-    protected void playStepSound(BlockPos pos, BlockState block) {
+    protected void playStepSound(BlockPos pos, IBlockData block) {
         this.playSound(SoundEvents.SPIDER_STEP, 0.15F, 1.0F);
     }
 
@@ -119,72 +121,76 @@
     }
 
     @Override
-    public void makeStuckInBlock(BlockState state, Vec3 motionMultiplier) {
+    public void makeStuckInBlock(IBlockData state, Vec3 motionMultiplier) {
         if (!state.is(Blocks.COBWEB)) {
             super.makeStuckInBlock(state, motionMultiplier);
         }
+
     }
 
     @Override
-    public MobType getMobType() {
-        return MobType.ARTHROPOD;
+    public EnumMonsterType getMobType() {
+        return EnumMonsterType.ARTHROPOD;
     }
 
     @Override
     public boolean canBeAffected(MobEffectInstance potioneffect) {
-        return potioneffect.getEffect() != MobEffects.POISON && super.canBeAffected(potioneffect);
+        return potioneffect.getEffect() == MobEffects.POISON ? false : super.canBeAffected(potioneffect);
     }
 
     public boolean isClimbing() {
-        return (this.entityData.get(DATA_FLAGS_ID) & 1) != 0;
+        return ((Byte) this.entityData.get(Spider.DATA_FLAGS_ID) & 1) != 0;
     }
 
     public void setClimbing(boolean climbing) {
-        byte b = this.entityData.get(DATA_FLAGS_ID);
+        byte b0 = (Byte) this.entityData.get(Spider.DATA_FLAGS_ID);
+
         if (climbing) {
-            b = (byte)(b | 1);
+            b0 = (byte) (b0 | 1);
         } else {
-            b = (byte)(b & -2);
+            b0 &= -2;
         }
 
-        this.entityData.set(DATA_FLAGS_ID, b);
+        this.entityData.set(Spider.DATA_FLAGS_ID, b0);
     }
 
     @Nullable
     @Override
-    public SpawnGroupData finalizeSpawn(
-        ServerLevelAccessor level, DifficultyInstance difficulty, MobSpawnType reason, @Nullable SpawnGroupData spawnData, @Nullable CompoundTag dataTag
-    ) {
-        SpawnGroupData var9 = super.finalizeSpawn(level, difficulty, reason, spawnData, dataTag);
-        RandomSource random = level.getRandom();
-        if (random.nextInt(100) == 0) {
-            Skeleton skeleton = EntityType.SKELETON.create(this.level());
-            if (skeleton != null) {
-                skeleton.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0F);
-                skeleton.finalizeSpawn(level, difficulty, reason, null, null);
-                skeleton.startRiding(this);
+    public GroupDataEntity finalizeSpawn(ServerLevelAccessor level, DifficultyInstance difficulty, EnumMobSpawn reason, @Nullable GroupDataEntity spawnData, @Nullable CompoundTag dataTag) {
+        Object object = super.finalizeSpawn(level, difficulty, reason, spawnData, dataTag);
+        RandomSource randomsource = level.getRandom();
+
+        if (randomsource.nextInt(100) == 0) {
+            Skeleton entityskeleton = (Skeleton) EntityType.SKELETON.create(this.level());
+
+            if (entityskeleton != null) {
+                entityskeleton.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0F);
+                entityskeleton.finalizeSpawn(level, difficulty, reason, (GroupDataEntity) null, (CompoundTag) null);
+                entityskeleton.startRiding(this);
             }
         }
 
-        if (var9 == null) {
-            var9 = new Spider.SpiderEffectsGroupData();
-            if (level.getDifficulty() == Difficulty.HARD && random.nextFloat() < 0.1F * difficulty.getSpecialMultiplier()) {
-                ((Spider.SpiderEffectsGroupData)var9).setRandomEffect(random);
+        if (object == null) {
+            object = new Spider.SpiderEffectsGroupData();
+            if (level.getDifficulty() == Difficulty.HARD && randomsource.nextFloat() < 0.1F * difficulty.getSpecialMultiplier()) {
+                ((Spider.SpiderEffectsGroupData) object).setRandomEffect(randomsource);
             }
         }
 
-        if (var9 instanceof Spider.SpiderEffectsGroupData spiderEffectsGroupData) {
-            MobEffect mobEffect = spiderEffectsGroupData.effect;
-            if (mobEffect != null) {
-                this.addEffect(new MobEffectInstance(mobEffect, -1));
+        if (object instanceof Spider.SpiderEffectsGroupData) {
+            Spider.SpiderEffectsGroupData entityspider_groupdataspider = (Spider.SpiderEffectsGroupData) object;
+            MobEffect mobeffectlist = entityspider_groupdataspider.effect;
+
+            if (mobeffectlist != null) {
+                this.addEffect(new MobEffectInstance(mobeffectlist, -1), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.SPIDER_SPAWN); // CraftBukkit
             }
         }
 
-        return (SpawnGroupData)var9;
+        return (GroupDataEntity) object;
     }
 
     @Override
-    protected float getStandingEyeHeight(Pose pose, EntityDimensions size) {
+    protected float getStandingEyeHeight(EntityPose pose, EntityDimensions size) {
         return 0.65F;
     }
 
@@ -193,9 +199,10 @@
         return entity.getBbWidth() <= this.getBbWidth() ? -0.3125F : 0.0F;
     }
 
-    static class SpiderAttackGoal extends MeleeAttackGoal {
+    private static class SpiderAttackGoal extends MeleeAttackGoal {
+
         public SpiderAttackGoal(Spider spider) {
-            super(spider, 1.0, true);
+            super(spider, 1.0D, true);
         }
 
         @Override
@@ -205,9 +212,10 @@
 
         @Override
         public boolean canContinueToUse() {
-            float lightLevelDependentMagicValue = this.mob.getLightLevelDependentMagicValue();
-            if (lightLevelDependentMagicValue >= 0.5F && this.mob.getRandom().nextInt(100) == 0) {
-                this.mob.setTarget(null);
+            float f = this.mob.getLightLevelDependentMagicValue();
+
+            if (f >= 0.5F && this.mob.getRandom().nextInt(100) == 0) {
+                this.mob.setTarget((LivingEntity) null);
                 return false;
             } else {
                 return super.canContinueToUse();
@@ -215,33 +223,40 @@
         }
     }
 
-    public static class SpiderEffectsGroupData implements SpawnGroupData {
+    private static class SpiderTargetGoal<T extends LivingEntity> extends NearestAttackableTargetGoal<T> {
+
+        public SpiderTargetGoal(Spider spider, Class<T> entityTypeToTarget) {
+            super(spider, entityTypeToTarget, true);
+        }
+
+        @Override
+        public boolean canUse() {
+            float f = this.mob.getLightLevelDependentMagicValue();
+
+            return f >= 0.5F ? false : super.canUse();
+        }
+    }
+
+    public static class SpiderEffectsGroupData implements GroupDataEntity {
+
         @Nullable
         public MobEffect effect;
 
+        public SpiderEffectsGroupData() {}
+
         public void setRandomEffect(RandomSource random) {
-            int randomInt = random.nextInt(5);
-            if (randomInt <= 1) {
+            int i = random.nextInt(5);
+
+            if (i <= 1) {
                 this.effect = MobEffects.MOVEMENT_SPEED;
-            } else if (randomInt <= 2) {
+            } else if (i <= 2) {
                 this.effect = MobEffects.DAMAGE_BOOST;
-            } else if (randomInt <= 3) {
+            } else if (i <= 3) {
                 this.effect = MobEffects.REGENERATION;
-            } else if (randomInt <= 4) {
+            } else if (i <= 4) {
                 this.effect = MobEffects.INVISIBILITY;
             }
-        }
-    }
 
-    static class SpiderTargetGoal<T extends LivingEntity> extends NearestAttackableTargetGoal<T> {
-        public SpiderTargetGoal(Spider spider, Class<T> entityTypeToTarget) {
-            super(spider, entityTypeToTarget, true);
         }
-
-        @Override
-        public boolean canUse() {
-            float lightLevelDependentMagicValue = this.mob.getLightLevelDependentMagicValue();
-            return !(lightLevelDependentMagicValue >= 0.5F) && super.canUse();
-        }
     }
 }