1
1
package com .faboslav .friendsandfoes .mixin ;
2
2
3
3
import com .faboslav .friendsandfoes .FriendsAndFoes ;
4
- import com .faboslav .friendsandfoes .api .IllusionerEntityAccess ;
4
+ import com .faboslav .friendsandfoes .advancements . api .IllusionerEntityAccess ;
5
5
import com .faboslav .friendsandfoes .util .RandomGenerator ;
6
6
import net .minecraft .entity .EntityType ;
7
7
import net .minecraft .entity .EquipmentSlot ;
@@ -72,6 +72,11 @@ protected IllusionerEntityMixin(
72
72
@ Override
73
73
public void initDataTracker () {
74
74
super .initDataTracker ();
75
+
76
+ if (FriendsAndFoes .getConfig ().enableIllusioner == false ) {
77
+ return ;
78
+ }
79
+
75
80
this .dataTracker .startTracking (IS_ILLUSION , false );
76
81
this .dataTracker .startTracking (WAS_ATTACKED , false );
77
82
this .dataTracker .startTracking (TICKS_UNTIL_DESPAWN , 0 );
@@ -81,6 +86,11 @@ public void initDataTracker() {
81
86
@ Override
82
87
public void writeCustomDataToNbt (NbtCompound nbt ) {
83
88
super .writeCustomDataToNbt (nbt );
89
+
90
+ if (FriendsAndFoes .getConfig ().enableIllusioner == false ) {
91
+ return ;
92
+ }
93
+
84
94
nbt .putBoolean (IS_ILLUSION_NBT_NAME , this .isIllusion ());
85
95
nbt .putBoolean (WAS_ATTACKED_NBT_NAME , this .wasAttacked ());
86
96
nbt .putInt (TICKS_UNTIL_DESPAWN_NBT_NAME , this .getTicksUntilDespawn ());
@@ -90,6 +100,11 @@ public void writeCustomDataToNbt(NbtCompound nbt) {
90
100
@ Override
91
101
public void readCustomDataFromNbt (NbtCompound nbt ) {
92
102
super .readCustomDataFromNbt (nbt );
103
+
104
+ if (FriendsAndFoes .getConfig ().enableIllusioner == false ) {
105
+ return ;
106
+ }
107
+
93
108
this .setIsIllusion (nbt .getBoolean (IS_ILLUSION_NBT_NAME ));
94
109
this .setWasAttacked (nbt .getBoolean (WAS_ATTACKED_NBT_NAME ));
95
110
this .setTicksUntilDespawn (nbt .getInt (TICKS_UNTIL_DESPAWN_NBT_NAME ));
@@ -99,11 +114,12 @@ public void readCustomDataFromNbt(NbtCompound nbt) {
99
114
@ Override
100
115
public void initGoals () {
101
116
super .initGoals ();
117
+
102
118
this .goalSelector .add (0 , new SwimGoal (this ));
103
119
this .goalSelector .add (1 , new LookAtTargetGoal ());
104
120
this .goalSelector .add (2 , new FleeEntityGoal (this , IronGolemEntity .class , 8.0F , 0.6D , 1.0D ));
105
121
106
- if (! this .isIllusion ()) {
122
+ if (FriendsAndFoes . getConfig (). enableIllusioner == false || this .isIllusion () == false ) {
107
123
this .goalSelector .add (3 , BlindTargetGoalFactory .newBlindTargetGoal ((IllusionerEntity ) (Object ) this ));
108
124
}
109
125
@@ -119,12 +135,12 @@ public void initGoals() {
119
135
120
136
@ Override
121
137
public void tick () {
138
+ super .tick ();
139
+
122
140
if (FriendsAndFoes .getConfig ().enableIllusioner == false ) {
123
- this . discard () ;
141
+ return ;
124
142
}
125
143
126
- super .tick ();
127
-
128
144
if (this .getWorld ().isClient ()) {
129
145
return ;
130
146
}
@@ -158,6 +174,10 @@ public void tick() {
158
174
public void tickMovement () {
159
175
super .tickMovement ();
160
176
177
+ if (FriendsAndFoes .getConfig ().enableIllusioner == false ) {
178
+ return ;
179
+ }
180
+
161
181
if (
162
182
this .world .isClient ()
163
183
|| !this .isIllusion ()
@@ -181,19 +201,31 @@ public void tickMovement() {
181
201
182
202
@ Override
183
203
public boolean shouldDropXp () {
184
- return !this .isIllusion ();
204
+ if (FriendsAndFoes .getConfig ().enableIllusioner == false ) {
205
+ return super .shouldDropXp ();
206
+ }
207
+
208
+ return this .isIllusion () == false ;
185
209
}
186
210
187
211
@ Override
188
212
protected boolean shouldDropLoot () {
189
- return !this .isIllusion ();
213
+ if (FriendsAndFoes .getConfig ().enableIllusioner == false ) {
214
+ return super .shouldDropLoot ();
215
+ }
216
+
217
+ return this .isIllusion () == false ;
190
218
}
191
219
192
220
@ Override
193
221
public boolean damage (
194
222
DamageSource source ,
195
223
float amount
196
224
) {
225
+ if (FriendsAndFoes .getConfig ().enableIllusioner == false ) {
226
+ return super .damage (source , amount );
227
+ }
228
+
197
229
if (
198
230
source .getAttacker () instanceof IllusionerEntity
199
231
|| (
0 commit comments