27
27
import net .minecraft .enchantment .InfoEnchantment ;
28
28
import net .minecraft .entity .LivingEntity ;
29
29
import net .minecraft .entity .player .PlayerEntity ;
30
+ import net .minecraft .item .ArmorItem ;
30
31
import net .minecraft .item .Items ;
31
32
import net .minecraft .server .network .ServerPlayerEntity ;
32
33
import net .minecraft .server .network .packet .PlayerMoveC2SPacket ;
@@ -117,6 +118,9 @@ public static void resetCracker(String reason) {
117
118
public static void onDropItem () {
118
119
if (expectedThrows > 0 )
119
120
expectedThrows --;
121
+ else if (canMaintainPlayerRNG ())
122
+ for (int i = 0 ; i < 4 ; i ++)
123
+ playerRand .nextInt ();
120
124
else
121
125
resetCracker ("dropItem" );
122
126
}
@@ -162,22 +166,37 @@ public static void onGiveCommand() {
162
166
}
163
167
164
168
public static void onAnvilUse () {
165
- resetCracker ("anvil" );
169
+ if (canMaintainPlayerRNG ())
170
+ playerRand .nextInt ();
171
+ else
172
+ resetCracker ("anvil" );
166
173
}
167
174
168
175
public static void onFrostWalker () {
169
176
resetCracker ("frostWalker" );
170
177
}
171
178
172
- public static void onBaseOfArthropods () {
173
- resetCracker ("baneOfArthropods" );
179
+ public static void onBaneOfArthropods () {
180
+ if (canMaintainPlayerRNG ())
181
+ playerRand .nextInt ();
182
+ else
183
+ resetCracker ("baneOfArthropods" );
174
184
}
175
185
176
- public static void onUnbreaking ( int amount , int unbreakingLevel ) {
177
- resetCracker ("unbreaking " );
186
+ public static void onRecreatePlayer ( ) {
187
+ resetCracker ("recreated " );
178
188
}
179
189
180
- public static void onUnbreakingUncertain (int minAmount , int maxAmount , int unbreakingLevel ) {
190
+ public static void onUnbreaking (ItemStack stack , int amount , int unbreakingLevel ) {
191
+ if (canMaintainPlayerRNG ())
192
+ for (int i = 0 ; i < amount ; i ++)
193
+ if (!(stack .getItem () instanceof ArmorItem ) || playerRand .nextFloat () >= 0.6 )
194
+ playerRand .nextInt (unbreakingLevel + 1 );
195
+ else
196
+ resetCracker ("unbreaking" );
197
+ }
198
+
199
+ public static void onUnbreakingUncertain (ItemStack stack , int minAmount , int maxAmount , int unbreakingLevel ) {
181
200
resetCracker ("unbreaking" );
182
201
}
183
202
@@ -187,7 +206,7 @@ public static void onItemDamage(int amount, LivingEntity holder, ItemStack stack
187
206
if (amount > 0 ) {
188
207
int unbreakingLevel = EnchantmentHelper .getLevel (Enchantments .UNBREAKING , stack );
189
208
if (unbreakingLevel > 0 )
190
- onUnbreaking (amount , unbreakingLevel );
209
+ onUnbreaking (stack , amount , unbreakingLevel );
191
210
}
192
211
}
193
212
}
@@ -199,12 +218,16 @@ public static void onItemDamageUncertain(int minAmount, int maxAmount, LivingEnt
199
218
if (maxAmount > 0 ) {
200
219
int unbreakingLevel = EnchantmentHelper .getLevel (Enchantments .UNBREAKING , stack );
201
220
if (unbreakingLevel > 0 )
202
- onUnbreakingUncertain (minAmount , maxAmount , unbreakingLevel );
221
+ onUnbreakingUncertain (stack , minAmount , maxAmount , unbreakingLevel );
203
222
}
204
223
}
205
224
}
206
225
}
207
226
227
+ private static boolean canMaintainPlayerRNG () {
228
+ return TempRules .playerRNGMaintenance && TempRules .enchCrackState == EnumCrackState .CRACKED ;
229
+ }
230
+
208
231
// RENDERING
209
232
/*
210
233
* This section is in charge of rendering the overlay on the enchantment GUI
0 commit comments