33
33
import rina .onepop .club .api .social .management .SocialManager ;
34
34
import rina .onepop .club .api .social .type .SocialType ;
35
35
import rina .onepop .club .api .strict .StrictUtilityInjector ;
36
+ import rina .onepop .club .api .util .chat .ChatUtil ;
36
37
import rina .onepop .club .api .util .client .NullUtil ;
37
38
import rina .onepop .club .api .util .entity .EntityUtil ;
38
39
import rina .onepop .club .api .util .item .SlotUtil ;
@@ -74,11 +75,12 @@ public class ModuleAutoCrystalRewrite extends Module {
74
75
public static ValueBoolean settingWallCheck = new ValueBoolean ("Wall Check" , "WallCheck" , "Enable wall check." , false );
75
76
public static ValueNumber settingWallRange = new ValueNumber ("Wall Range" , "WallRange" , "Prevents blocks in wall." , 4f , 2f , 5f );
76
77
public static ValueBoolean settingBreakAnimation = new ValueBoolean ("Break Animation" , "BreakAnimation" , "idk mwmw" , false );
77
- public static ValueNumber settingBreakPriority = new ValueNumber ("Break Priority" , "BreakPriority" , "Break priority for needed time." , 0 , 0 , 3 );
78
78
public static ValueNumber settingBreakRange = new ValueNumber ("Break Range" , "BreakRange" , "Sets break range." , 4f , 2f , 6f );
79
79
public static ValueNumber settingPlaceRange = new ValueNumber ("Place Range" , "PlaceRange" , "Sets place range." , 4f , 2f , 6f );
80
- public static ValueNumber settingPlaceDelay = new ValueNumber ("Place Delay" , "PlaceDelay" , "Sets place delay." , 33 , 0 , 50 );
81
- public static ValueNumber settingBreakDelay = new ValueNumber ("Break Delay" , "BreakDelay" , "Sets break delay." , 33 , 0 , 50 );
80
+ public static ValueNumber settingPlaceDelay = new ValueNumber ("Place Delay" , "PlaceDelay" , "Sets place delay." , 33 , 0 , 500 );
81
+ public static ValueBoolean settingPlaceAnimation = new ValueBoolean ("Place Animation" , "PlaceAnimation" , "sends place animation to server" , true );
82
+ public static ValueNumber settingBreakDelay = new ValueNumber ("Break Delay" , "BreakDelay" , "Sets break delay." , 33 , 0 , 500 );
83
+ public static ValueNumber settingBreakAsyncDelay = new ValueNumber ("Async Break Delay" , "AsyncBreakDelay" , "Sets break delay." , 33 , 0 , 500 );
82
84
public static ValueNumber settingSelfDamage = new ValueNumber ("Self Damage" , "SelfDamage" , "Self damage." , 9 , 1 , 36 );
83
85
public static ValueNumber settingMinimumDamage = new ValueNumber ("Min. Damage" , "Min. Damage" , "Sets minimum damage." , 4 , 0 , 36 );
84
86
public static ValueNumber settingFacingY = new ValueNumber ("Facing Y" , "FacingY" , "Sets the facing Y from place." , 1f , 0f , 1f );
@@ -96,6 +98,7 @@ public class ModuleAutoCrystalRewrite extends Module {
96
98
97
99
private final TurokTick rotationDelayMS = new TurokTick ();
98
100
private final TurokTick cooldownDelayMS = new TurokTick ();
101
+ private final TurokTick asyncBreakDelayMS = new TurokTick ();
99
102
private boolean multiConnection ;
100
103
101
104
private float yaw ;
@@ -106,6 +109,7 @@ public class ModuleAutoCrystalRewrite extends Module {
106
109
107
110
private EntityPlayer entity ;
108
111
private BlockPos position ;
112
+ private BlockPos lastPlaceBreakedPos ;
109
113
110
114
private boolean isCrystalInOffhand ;
111
115
private boolean isCrystalInMainHand ;
@@ -149,8 +153,8 @@ public void onSetting() {
149
153
settingBreakRange .setEnabled (settingTab .getValue () == Tab .CRYSTAL );
150
154
settingPlaceRange .setEnabled (settingTab .getValue () == Tab .CRYSTAL );
151
155
settingPlaceDelay .setEnabled (settingTab .getValue () == Tab .CRYSTAL );
152
- settingBreakPriority .setEnabled (settingTab .getValue () == Tab .CRYSTAL );
153
156
settingBreakAnimation .setEnabled (settingTab .getValue () == Tab .CRYSTAL );
157
+ settingBreakAsyncDelay .setEnabled (settingTab .getValue () == Tab .CRYSTAL && settingPredict .getValue ());
154
158
settingBreakDelay .setEnabled (settingTab .getValue () == Tab .CRYSTAL );
155
159
settingWallCheck .setEnabled (settingTab .getValue () == Tab .CRYSTAL );
156
160
settingWallRange .setEnabled (settingTab .getValue () == Tab .CRYSTAL && settingWallCheck .getValue ());
@@ -191,17 +195,6 @@ public void onDirectDraw3D() {
191
195
192
196
@ Listener
193
197
public void onPacketSend (PacketEvent .Send event ) {
194
- int priority = settingBreakPriority .getValue ().intValue ();
195
- if (event .getPacket () instanceof CPacketUseEntity && priority > 0 && priority != 3 ) {
196
- CPacketUseEntity useEntity = (CPacketUseEntity ) event .getPacket ();
197
- useEntity .hand = this .handAttack ;
198
- if ((useEntity .entityId = this .findCrystal ()) == -1 ) {
199
- event .setCanceled (true );
200
- } else {
201
- this .hitCount .add (useEntity .entityId );
202
- }
203
- }
204
-
205
198
if (event .getPacket () instanceof CPacketPlayerTryUseItemOnBlock && settingStrictPriority .getValue () == Priority .HIGH && this .entity != null ) {
206
199
final CPacketPlayerTryUseItemOnBlock packet = (CPacketPlayerTryUseItemOnBlock ) event .getPacket ();
207
200
event .setCanceled (!CrystalUtil .isCrystalPlaceable (packet .getPos (), settingPlace113 .getValue (), true ));
@@ -213,19 +206,24 @@ public void onPacketSend(PacketEvent.Send event) {
213
206
}
214
207
215
208
public void doBreakCrystal (SPacketSpawnObject packet ) {
209
+ if (this .entity == null || !this .breakDelayMS .isPassedMS (settingBreakDelay .getValue ().intValue ())) {
210
+ return ;
211
+ }
212
+
216
213
CPacketUseEntity attack = new CPacketUseEntity ();
217
214
attack .entityId = packet .getEntityID ();
218
215
attack .action = CPacketUseEntity .Action .ATTACK ;
219
216
attack .hand = this .handAttack ;
220
217
221
218
BlockPos pos = new BlockPos (packet .getX (), packet .getY (), packet .getZ ());
222
- boolean mustBreak = false ;
219
+ boolean in = this .placeCount .contains (pos .down ());
220
+ boolean mustBreak = this .placeCount .contains (pos .down ());
223
221
224
222
if (!mustBreak ) {
225
223
float damage = 0.5f ;
226
224
227
225
if (mc .player .getDistance (pos .x , pos .y , pos .z ) < settingBreakRange .getValue ().floatValue ()) {
228
- float entityDamage = CrystalUtil .calculateDamage (pos .z , pos .y , pos .z , this .entity );
226
+ float entityDamage = CrystalUtil .calculateDamage (pos .x , pos .y , pos .z , this .entity );
229
227
float selfDamage = CrystalUtil .calculateDamage (pos .x , pos .y , pos .z , mc .player );
230
228
231
229
if (entityDamage > damage && selfDamage < settingSelfDamage .getValue ().floatValue ()) {
@@ -244,53 +242,21 @@ public void doBreakCrystal(SPacketSpawnObject packet) {
244
242
mc .player .connection .sendPacket (new CPacketAnimation (EnumHand .MAIN_HAND ));
245
243
}
246
244
247
- this .hitCount .add (attack .entityId );
248
- this .placeCount .remove (pos );
249
- }
250
-
251
- @ Listener (priority = ListenerPriority .HIGHEST )
252
- public void onPacketReceive (PacketEvent .Receive event ) {
253
- if (event .getPacket () instanceof SPacketSpawnObject && settingPredict .getValue ()) {
254
- final SPacketSpawnObject packet = (SPacketSpawnObject ) event .getPacket ();
255
- final BlockPos pos = new BlockPos (packet .getX (), packet .getY (), packet .getZ ()).down ();
256
-
257
- if (packet .getType () == 51 && this .placeCount .contains (pos )) {
258
- final CPacketUseEntity attack = new CPacketUseEntity ();
259
-
260
- attack .entityId = packet .getEntityID ();
261
- attack .action = CPacketUseEntity .Action .ATTACK ;
262
- attack .hand = this .handAttack ;
263
-
264
- mc .player .connection .sendPacket (attack );
265
- mc .player .connection .sendPacket (new CPacketAnimation (EnumHand .MAIN_HAND ));
266
-
267
- this .hitCount .add (packet .getEntityID ());
268
-
269
- this .placeCount .remove (pos );
270
- this .placeDelayMS .reset ();
271
- this .breakDelayMS .reset ();
272
- }
245
+ if (in ) {
246
+ this .placeCount .remove (pos .down ());
273
247
}
274
248
275
- if (event .getPacket () instanceof SPacketSoundEffect && settingNoSoundDelay .getValue ()) {
276
- final SPacketSoundEffect packet = (SPacketSoundEffect ) event .getPacket ();
277
-
278
- if (packet .getCategory () == SoundCategory .BLOCKS && packet .getSound () == SoundEvents .ENTITY_GENERIC_EXPLODE ) {
279
- boolean hitList = false ;
249
+ this .breakDelayMS .reset ();
250
+ }
280
251
281
- for ( Entity entities : ISLClass . mc . world . loadedEntityList ) {
282
- if ( entities instanceof EntityEnderCrystal ) {
283
- if ( entities . getDistance ( packet . getX (), packet . getY (), packet . getZ ()) <= 6.0f ) {
284
- entities . setDead ();
285
- hitList = true ;
286
- }
252
+ public void doCleanCrystals ( SPacketSoundEffect packet ) {
253
+ if ( packet . getCategory () == SoundCategory . BLOCKS && packet . getSound () == SoundEvents . ENTITY_GENERIC_EXPLODE ) {
254
+ for ( Entity entities : ISLClass . mc . world . loadedEntityList ) {
255
+ if ( entities instanceof EntityEnderCrystal ) {
256
+ if ( entities . getDistance ( packet . getX (), packet . getY (), packet . getZ ()) <= 6.0f ) {
257
+ entities . setDead ();
287
258
}
288
259
}
289
-
290
- if (hitList ) {
291
- this .placeCount .clear ();
292
- this .hitCount .clear ();
293
- }
294
260
}
295
261
}
296
262
}
@@ -307,6 +273,11 @@ public void onDirectTick() {
307
273
if (!settingIncreaseTicks .getValue () && (this .isCrystalInMainHand || this .isCrystalInOffhand ) && this .isEntityTargeted (this .entity )) {
308
274
this .update ();
309
275
}
276
+
277
+ if (this .lastPlaceBreakedPos != null ) {
278
+ this .placeCount .remove (this .lastPlaceBreakedPos );
279
+ this .lastPlaceBreakedPos = null ;
280
+ }
310
281
}
311
282
312
283
@ Listener (priority = ListenerPriority .LOW )
@@ -358,52 +329,23 @@ public void onClientTickEvent(ClientTickEvent event) {
358
329
}
359
330
360
331
protected void update () {
361
- if (this .breakDelayMS .isPassedMS (settingBreakDelay .getValue ().floatValue ())) {
362
- switch (settingBreakPriority .getValue ().intValue ()) {
363
- case 1 : {
364
- this .breakPacket .entityId = -1 ;
365
- this .breakPacket .action = CPacketUseEntity .Action .ATTACK ;
366
- this .breakPacket .hand = this .handAttack ;
367
- mc .player .connection .sendPacket (this .breakPacket );
368
- this .breakDelayMS .reset ();
369
- break ;
370
- }
371
- case 3 : {
372
- if (this .breakDelayMS .isPassedMS (settingBreakDelay .getValue ().floatValue () * 5 )) {
373
- this .entityID = this .findCrystalBreak ();
374
- if (this .entityID != -1 ) {
375
- this .breakPacket .entityId = this .entityID ;
376
- this .breakPacket .action = CPacketUseEntity .Action .ATTACK ;
377
- this .breakPacket .hand = this .handAttack ;
378
-
379
- mc .player .connection .sendPacket (this .breakPacket );
380
- if (settingBreakAnimation .getValue ()) {
381
- mc .player .connection .sendPacket (new CPacketAnimation (EnumHand .MAIN_HAND ));
382
- }
383
-
384
- //this.hitCount.add(this.breakPacket.entityId);
385
- this .breakDelayMS .reset ();
386
- }
387
- }
388
- break ;
332
+ boolean predict = settingPredict .getValue ();
333
+ TurokTick breakDelay = predict ? this .asyncBreakDelayMS : this .breakDelayMS ;
334
+ int delay = predict ? settingBreakAsyncDelay .getValue ().intValue () : settingBreakDelay .getValue ().intValue ();
335
+
336
+ if (breakDelay .isPassedMS (delay )) {
337
+ this .entityID = this .findCrystalBreak ();
338
+ if (this .entityID != -1 ) {
339
+ this .breakPacket .entityId = this .entityID ;
340
+ this .breakPacket .action = CPacketUseEntity .Action .ATTACK ;
341
+ this .breakPacket .hand = this .handAttack ;
342
+
343
+ mc .player .connection .sendPacket (this .breakPacket );
344
+ if (settingBreakAnimation .getValue ()) {
345
+ mc .player .connection .sendPacket (new CPacketAnimation (EnumHand .MAIN_HAND ));
389
346
}
390
- default : {
391
- this .entityID = this .findCrystalBreak ();
392
- if (this .entityID != -1 ) {
393
- this .breakPacket .entityId = this .entityID ;
394
- this .breakPacket .action = CPacketUseEntity .Action .ATTACK ;
395
- this .breakPacket .hand = this .handAttack ;
396
-
397
- mc .player .connection .sendPacket (this .breakPacket );
398
- if (settingBreakAnimation .getValue ()) {
399
- mc .player .connection .sendPacket (new CPacketAnimation (EnumHand .MAIN_HAND ));
400
- }
401
347
402
- this .hitCount .add (this .breakPacket .entityId );
403
- this .breakDelayMS .reset ();
404
- }
405
- break ;
406
- }
348
+ breakDelay .reset ();
407
349
}
408
350
}
409
351
@@ -433,7 +375,10 @@ protected void update() {
433
375
this .placePacket .position = this .position ;
434
376
435
377
mc .player .connection .sendPacket (this .placePacket );
436
- mc .player .connection .sendPacket (new CPacketAnimation (this .placePacket .getHand ()));
378
+
379
+ if (settingPlaceAnimation .getValue ()) {
380
+ mc .player .connection .sendPacket (new CPacketAnimation (this .placePacket .getHand ()));
381
+ }
437
382
438
383
this .placeCount .add (this .position );
439
384
this .placeDelayMS .reset ();
0 commit comments