File size: 40,557 Bytes
d46f4a3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
package net.minecraft.client.renderer;

import java.util.HashMap;
import java.util.Map;
import java.util.function.Supplier;
import net.minecraft.client.Camera;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.resources.sounds.SimpleSoundInstance;
import net.minecraft.client.resources.sounds.SoundInstance;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.Holder;
import net.minecraft.core.particles.ItemParticleOption;
import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.core.particles.SculkChargeParticleOptions;
import net.minecraft.core.particles.ShriekParticleOption;
import net.minecraft.core.particles.SimpleParticleType;
import net.minecraft.core.registries.Registries;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.util.Mth;
import net.minecraft.util.ParticleUtils;
import net.minecraft.util.RandomSource;
import net.minecraft.util.valueproviders.IntProvider;
import net.minecraft.util.valueproviders.UniformInt;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.BoneMealItem;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.JukeboxSong;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.BrushableBlock;
import net.minecraft.world.level.block.ComposterBlock;
import net.minecraft.world.level.block.MultifaceBlock;
import net.minecraft.world.level.block.PointedDripstoneBlock;
import net.minecraft.world.level.block.SculkShriekerBlock;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.entity.trialspawner.TrialSpawner;
import net.minecraft.world.level.block.entity.vault.VaultBlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

@OnlyIn(Dist.CLIENT)
public class LevelEventHandler {
    private final Minecraft minecraft;
    private final Level level;
    private final LevelRenderer levelRenderer;
    private final Map<BlockPos, SoundInstance> playingJukeboxSongs = new HashMap<>();

    public LevelEventHandler(Minecraft p_364747_, Level p_361496_, LevelRenderer p_368459_) {
        this.minecraft = p_364747_;
        this.level = p_361496_;
        this.levelRenderer = p_368459_;
    }

    public void globalLevelEvent(int p_364279_, BlockPos p_361580_, int p_363929_) {
        switch (p_364279_) {
            case 1023:
            case 1028:
            case 1038:
                Camera camera = this.minecraft.gameRenderer.getMainCamera();
                if (camera.isInitialized()) {
                    Vec3 vec3 = Vec3.atCenterOf(p_361580_).subtract(camera.getPosition()).normalize();
                    Vec3 vec31 = camera.getPosition().add(vec3.scale(2.0));
                    if (p_364279_ == 1023) {
                        this.level.playLocalSound(vec31.x, vec31.y, vec31.z, SoundEvents.WITHER_SPAWN, SoundSource.HOSTILE, 1.0F, 1.0F, false);
                    } else if (p_364279_ == 1038) {
                        this.level.playLocalSound(vec31.x, vec31.y, vec31.z, SoundEvents.END_PORTAL_SPAWN, SoundSource.HOSTILE, 1.0F, 1.0F, false);
                    } else {
                        this.level.playLocalSound(vec31.x, vec31.y, vec31.z, SoundEvents.ENDER_DRAGON_DEATH, SoundSource.HOSTILE, 5.0F, 1.0F, false);
                    }
                }
        }
    }

    public void levelEvent(int p_368193_, BlockPos p_362689_, int p_368262_) {
        RandomSource randomsource = this.level.random;
        switch (p_368193_) {
            case 1000:
                this.level.playLocalSound(p_362689_, SoundEvents.DISPENSER_DISPENSE, SoundSource.BLOCKS, 1.0F, 1.0F, false);
                break;
            case 1001:
                this.level.playLocalSound(p_362689_, SoundEvents.DISPENSER_FAIL, SoundSource.BLOCKS, 1.0F, 1.2F, false);
                break;
            case 1002:
                this.level.playLocalSound(p_362689_, SoundEvents.DISPENSER_LAUNCH, SoundSource.BLOCKS, 1.0F, 1.2F, false);
                break;
            case 1004:
                this.level.playLocalSound(p_362689_, SoundEvents.FIREWORK_ROCKET_SHOOT, SoundSource.NEUTRAL, 1.0F, 1.2F, false);
                break;
            case 1009:
                if (p_368262_ == 0) {
                    this.level
                        .playLocalSound(
                            p_362689_,
                            SoundEvents.FIRE_EXTINGUISH,
                            SoundSource.BLOCKS,
                            0.5F,
                            2.6F + (randomsource.nextFloat() - randomsource.nextFloat()) * 0.8F,
                            false
                        );
                } else if (p_368262_ == 1) {
                    this.level
                        .playLocalSound(
                            p_362689_,
                            SoundEvents.GENERIC_EXTINGUISH_FIRE,
                            SoundSource.BLOCKS,
                            0.7F,
                            1.6F + (randomsource.nextFloat() - randomsource.nextFloat()) * 0.4F,
                            false
                        );
                }
                break;
            case 1010:
                this.level.registryAccess().lookupOrThrow(Registries.JUKEBOX_SONG).get(p_368262_).ifPresent(p_368563_ -> this.playJukeboxSong(p_368563_, p_362689_));
                break;
            case 1011:
                this.stopJukeboxSongAndNotifyNearby(p_362689_);
                break;
            case 1015:
                this.level
                    .playLocalSound(
                        p_362689_, SoundEvents.GHAST_WARN, SoundSource.HOSTILE, 10.0F, (randomsource.nextFloat() - randomsource.nextFloat()) * 0.2F + 1.0F, false
                    );
                break;
            case 1016:
                this.level
                    .playLocalSound(
                        p_362689_, SoundEvents.GHAST_SHOOT, SoundSource.HOSTILE, 10.0F, (randomsource.nextFloat() - randomsource.nextFloat()) * 0.2F + 1.0F, false
                    );
                break;
            case 1017:
                this.level
                    .playLocalSound(
                        p_362689_, SoundEvents.ENDER_DRAGON_SHOOT, SoundSource.HOSTILE, 10.0F, (randomsource.nextFloat() - randomsource.nextFloat()) * 0.2F + 1.0F, false
                    );
                break;
            case 1018:
                this.level
                    .playLocalSound(
                        p_362689_, SoundEvents.BLAZE_SHOOT, SoundSource.HOSTILE, 2.0F, (randomsource.nextFloat() - randomsource.nextFloat()) * 0.2F + 1.0F, false
                    );
                break;
            case 1019:
                this.level
                    .playLocalSound(
                        p_362689_, SoundEvents.ZOMBIE_ATTACK_WOODEN_DOOR, SoundSource.HOSTILE, 2.0F, (randomsource.nextFloat() - randomsource.nextFloat()) * 0.2F + 1.0F, false
                    );
                break;
            case 1020:
                this.level
                    .playLocalSound(
                        p_362689_, SoundEvents.ZOMBIE_ATTACK_IRON_DOOR, SoundSource.HOSTILE, 2.0F, (randomsource.nextFloat() - randomsource.nextFloat()) * 0.2F + 1.0F, false
                    );
                break;
            case 1021:
                this.level
                    .playLocalSound(
                        p_362689_, SoundEvents.ZOMBIE_BREAK_WOODEN_DOOR, SoundSource.HOSTILE, 2.0F, (randomsource.nextFloat() - randomsource.nextFloat()) * 0.2F + 1.0F, false
                    );
                break;
            case 1022:
                this.level
                    .playLocalSound(
                        p_362689_, SoundEvents.WITHER_BREAK_BLOCK, SoundSource.HOSTILE, 2.0F, (randomsource.nextFloat() - randomsource.nextFloat()) * 0.2F + 1.0F, false
                    );
                break;
            case 1024:
                this.level
                    .playLocalSound(
                        p_362689_, SoundEvents.WITHER_SHOOT, SoundSource.HOSTILE, 2.0F, (randomsource.nextFloat() - randomsource.nextFloat()) * 0.2F + 1.0F, false
                    );
                break;
            case 1025:
                this.level
                    .playLocalSound(
                        p_362689_, SoundEvents.BAT_TAKEOFF, SoundSource.NEUTRAL, 0.05F, (randomsource.nextFloat() - randomsource.nextFloat()) * 0.2F + 1.0F, false
                    );
                break;
            case 1026:
                this.level
                    .playLocalSound(
                        p_362689_, SoundEvents.ZOMBIE_INFECT, SoundSource.HOSTILE, 2.0F, (randomsource.nextFloat() - randomsource.nextFloat()) * 0.2F + 1.0F, false
                    );
                break;
            case 1027:
                this.level
                    .playLocalSound(
                        p_362689_, SoundEvents.ZOMBIE_VILLAGER_CONVERTED, SoundSource.HOSTILE, 2.0F, (randomsource.nextFloat() - randomsource.nextFloat()) * 0.2F + 1.0F, false
                    );
                break;
            case 1029:
                this.level.playLocalSound(p_362689_, SoundEvents.ANVIL_DESTROY, SoundSource.BLOCKS, 1.0F, randomsource.nextFloat() * 0.1F + 0.9F, false);
                break;
            case 1030:
                this.level.playLocalSound(p_362689_, SoundEvents.ANVIL_USE, SoundSource.BLOCKS, 1.0F, randomsource.nextFloat() * 0.1F + 0.9F, false);
                break;
            case 1031:
                this.level.playLocalSound(p_362689_, SoundEvents.ANVIL_LAND, SoundSource.BLOCKS, 0.3F, this.level.random.nextFloat() * 0.1F + 0.9F, false);
                break;
            case 1032:
                this.minecraft.getSoundManager().play(SimpleSoundInstance.forLocalAmbience(SoundEvents.PORTAL_TRAVEL, randomsource.nextFloat() * 0.4F + 0.8F, 0.25F));
                break;
            case 1033:
                this.level.playLocalSound(p_362689_, SoundEvents.CHORUS_FLOWER_GROW, SoundSource.BLOCKS, 1.0F, 1.0F, false);
                break;
            case 1034:
                this.level.playLocalSound(p_362689_, SoundEvents.CHORUS_FLOWER_DEATH, SoundSource.BLOCKS, 1.0F, 1.0F, false);
                break;
            case 1035:
                this.level.playLocalSound(p_362689_, SoundEvents.BREWING_STAND_BREW, SoundSource.BLOCKS, 1.0F, 1.0F, false);
                break;
            case 1039:
                this.level.playLocalSound(p_362689_, SoundEvents.PHANTOM_BITE, SoundSource.HOSTILE, 0.3F, this.level.random.nextFloat() * 0.1F + 0.9F, false);
                break;
            case 1040:
                this.level
                    .playLocalSound(
                        p_362689_, SoundEvents.ZOMBIE_CONVERTED_TO_DROWNED, SoundSource.HOSTILE, 2.0F, (randomsource.nextFloat() - randomsource.nextFloat()) * 0.2F + 1.0F, false
                    );
                break;
            case 1041:
                this.level
                    .playLocalSound(
                        p_362689_, SoundEvents.HUSK_CONVERTED_TO_ZOMBIE, SoundSource.HOSTILE, 2.0F, (randomsource.nextFloat() - randomsource.nextFloat()) * 0.2F + 1.0F, false
                    );
                break;
            case 1042:
                this.level.playLocalSound(p_362689_, SoundEvents.GRINDSTONE_USE, SoundSource.BLOCKS, 1.0F, this.level.random.nextFloat() * 0.1F + 0.9F, false);
                break;
            case 1043:
                this.level.playLocalSound(p_362689_, SoundEvents.BOOK_PAGE_TURN, SoundSource.BLOCKS, 1.0F, this.level.random.nextFloat() * 0.1F + 0.9F, false);
                break;
            case 1044:
                this.level.playLocalSound(p_362689_, SoundEvents.SMITHING_TABLE_USE, SoundSource.BLOCKS, 1.0F, this.level.random.nextFloat() * 0.1F + 0.9F, false);
                break;
            case 1045:
                this.level.playLocalSound(p_362689_, SoundEvents.POINTED_DRIPSTONE_LAND, SoundSource.BLOCKS, 2.0F, this.level.random.nextFloat() * 0.1F + 0.9F, false);
                break;
            case 1046:
                this.level.playLocalSound(p_362689_, SoundEvents.POINTED_DRIPSTONE_DRIP_LAVA_INTO_CAULDRON, SoundSource.BLOCKS, 2.0F, this.level.random.nextFloat() * 0.1F + 0.9F, false);
                break;
            case 1047:
                this.level.playLocalSound(p_362689_, SoundEvents.POINTED_DRIPSTONE_DRIP_WATER_INTO_CAULDRON, SoundSource.BLOCKS, 2.0F, this.level.random.nextFloat() * 0.1F + 0.9F, false);
                break;
            case 1048:
                this.level
                    .playLocalSound(
                        p_362689_, SoundEvents.SKELETON_CONVERTED_TO_STRAY, SoundSource.HOSTILE, 2.0F, (randomsource.nextFloat() - randomsource.nextFloat()) * 0.2F + 1.0F, false
                    );
                break;
            case 1049:
                this.level.playLocalSound(p_362689_, SoundEvents.CRAFTER_CRAFT, SoundSource.BLOCKS, 1.0F, 1.0F, false);
                break;
            case 1050:
                this.level.playLocalSound(p_362689_, SoundEvents.CRAFTER_FAIL, SoundSource.BLOCKS, 1.0F, 1.0F, false);
                break;
            case 1051:
                this.level
                    .playLocalSound(p_362689_, SoundEvents.WIND_CHARGE_THROW, SoundSource.BLOCKS, 0.5F, 0.4F / (this.level.getRandom().nextFloat() * 0.4F + 0.8F), false);
                break;
            case 1500:
                ComposterBlock.handleFill(this.level, p_362689_, p_368262_ > 0);
                break;
            case 1501:
                this.level
                    .playLocalSound(
                        p_362689_, SoundEvents.LAVA_EXTINGUISH, SoundSource.BLOCKS, 0.5F, 2.6F + (randomsource.nextFloat() - randomsource.nextFloat()) * 0.8F, false
                    );

                for (int l2 = 0; l2 < 8; l2++) {
                    this.level
                        .addParticle(
                            ParticleTypes.LARGE_SMOKE,
                            (double)p_362689_.getX() + randomsource.nextDouble(),
                            (double)p_362689_.getY() + 1.2,
                            (double)p_362689_.getZ() + randomsource.nextDouble(),
                            0.0,
                            0.0,
                            0.0
                        );
                }
                break;
            case 1502:
                this.level
                    .playLocalSound(
                        p_362689_, SoundEvents.REDSTONE_TORCH_BURNOUT, SoundSource.BLOCKS, 0.5F, 2.6F + (randomsource.nextFloat() - randomsource.nextFloat()) * 0.8F, false
                    );

                for (int k2 = 0; k2 < 5; k2++) {
                    double d12 = (double)p_362689_.getX() + randomsource.nextDouble() * 0.6 + 0.2;
                    double d17 = (double)p_362689_.getY() + randomsource.nextDouble() * 0.6 + 0.2;
                    double d22 = (double)p_362689_.getZ() + randomsource.nextDouble() * 0.6 + 0.2;
                    this.level.addParticle(ParticleTypes.SMOKE, d12, d17, d22, 0.0, 0.0, 0.0);
                }
                break;
            case 1503:
                this.level.playLocalSound(p_362689_, SoundEvents.END_PORTAL_FRAME_FILL, SoundSource.BLOCKS, 1.0F, 1.0F, false);

                for (int j2 = 0; j2 < 16; j2++) {
                    double d11 = (double)p_362689_.getX() + (5.0 + randomsource.nextDouble() * 6.0) / 16.0;
                    double d16 = (double)p_362689_.getY() + 0.8125;
                    double d21 = (double)p_362689_.getZ() + (5.0 + randomsource.nextDouble() * 6.0) / 16.0;
                    this.level.addParticle(ParticleTypes.SMOKE, d11, d16, d21, 0.0, 0.0, 0.0);
                }
                break;
            case 1504:
                PointedDripstoneBlock.spawnDripParticle(this.level, p_362689_, this.level.getBlockState(p_362689_));
                break;
            case 1505:
                BoneMealItem.addGrowthParticles(this.level, p_362689_, p_368262_);
                this.level.playLocalSound(p_362689_, SoundEvents.BONE_MEAL_USE, SoundSource.BLOCKS, 1.0F, 1.0F, false);
                break;
            case 2000:
                this.shootParticles(p_368262_, p_362689_, randomsource, ParticleTypes.SMOKE);
                break;
            case 2001:
                BlockState blockstate1 = Block.stateById(p_368262_);
                if (!blockstate1.isAir()) {
                    SoundType soundtype = blockstate1.getSoundType();
                    this.level
                        .playLocalSound(
                            p_362689_, soundtype.getBreakSound(), SoundSource.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F, false
                        );
                }

                this.level.addDestroyBlockEffect(p_362689_, blockstate1);
                break;
            case 2002:
            case 2007:
                Vec3 vec3 = Vec3.atBottomCenterOf(p_362689_);

                for (int j = 0; j < 8; j++) {
                    this.levelRenderer
                        .addParticle(
                            new ItemParticleOption(ParticleTypes.ITEM, new ItemStack(Items.SPLASH_POTION)),
                            vec3.x,
                            vec3.y,
                            vec3.z,
                            randomsource.nextGaussian() * 0.15,
                            randomsource.nextDouble() * 0.2,
                            randomsource.nextGaussian() * 0.15
                        );
                }

                float f2 = (float)(p_368262_ >> 16 & 0xFF) / 255.0F;
                float f3 = (float)(p_368262_ >> 8 & 0xFF) / 255.0F;
                float f5 = (float)(p_368262_ >> 0 & 0xFF) / 255.0F;
                ParticleOptions particleoptions = p_368193_ == 2007 ? ParticleTypes.INSTANT_EFFECT : ParticleTypes.EFFECT;

                for (int i2 = 0; i2 < 100; i2++) {
                    double d10 = randomsource.nextDouble() * 4.0;
                    double d15 = randomsource.nextDouble() * Math.PI * 2.0;
                    double d20 = Math.cos(d15) * d10;
                    double d24 = 0.01 + randomsource.nextDouble() * 0.5;
                    double d25 = Math.sin(d15) * d10;
                    Particle particle1 = this.levelRenderer
                        .addParticleInternal(
                            particleoptions,
                            particleoptions.getType().getOverrideLimiter(),
                            vec3.x + d20 * 0.1,
                            vec3.y + 0.3,
                            vec3.z + d25 * 0.1,
                            d20,
                            d24,
                            d25
                        );
                    if (particle1 != null) {
                        float f1 = 0.75F + randomsource.nextFloat() * 0.25F;
                        particle1.setColor(f2 * f1, f3 * f1, f5 * f1);
                        particle1.setPower((float)d10);
                    }
                }

                this.level.playLocalSound(p_362689_, SoundEvents.SPLASH_POTION_BREAK, SoundSource.NEUTRAL, 1.0F, randomsource.nextFloat() * 0.1F + 0.9F, false);
                break;
            case 2003:
                double d0 = (double)p_362689_.getX() + 0.5;
                double d5 = (double)p_362689_.getY();
                double d7 = (double)p_362689_.getZ() + 0.5;

                for (int i3 = 0; i3 < 8; i3++) {
                    this.levelRenderer
                        .addParticle(
                            new ItemParticleOption(ParticleTypes.ITEM, new ItemStack(Items.ENDER_EYE)),
                            d0,
                            d5,
                            d7,
                            randomsource.nextGaussian() * 0.15,
                            randomsource.nextDouble() * 0.2,
                            randomsource.nextGaussian() * 0.15
                        );
                }

                for (double d9 = 0.0; d9 < Math.PI * 2; d9 += Math.PI / 20) {
                    this.levelRenderer
                        .addParticle(
                            ParticleTypes.PORTAL, d0 + Math.cos(d9) * 5.0, d5 - 0.4, d7 + Math.sin(d9) * 5.0, Math.cos(d9) * -5.0, 0.0, Math.sin(d9) * -5.0
                        );
                    this.levelRenderer
                        .addParticle(
                            ParticleTypes.PORTAL, d0 + Math.cos(d9) * 5.0, d5 - 0.4, d7 + Math.sin(d9) * 5.0, Math.cos(d9) * -7.0, 0.0, Math.sin(d9) * -7.0
                        );
                }
                break;
            case 2004:
                for (int l = 0; l < 20; l++) {
                    double d6 = (double)p_362689_.getX() + 0.5 + (randomsource.nextDouble() - 0.5) * 2.0;
                    double d8 = (double)p_362689_.getY() + 0.5 + (randomsource.nextDouble() - 0.5) * 2.0;
                    double d13 = (double)p_362689_.getZ() + 0.5 + (randomsource.nextDouble() - 0.5) * 2.0;
                    this.level.addParticle(ParticleTypes.SMOKE, d6, d8, d13, 0.0, 0.0, 0.0);
                    this.level.addParticle(ParticleTypes.FLAME, d6, d8, d13, 0.0, 0.0, 0.0);
                }
                break;
            case 2006:
                for (int l1 = 0; l1 < 200; l1++) {
                    float f10 = randomsource.nextFloat() * 4.0F;
                    float f11 = randomsource.nextFloat() * (float) (Math.PI * 2);
                    double d14 = (double)(Mth.cos(f11) * f10);
                    double d19 = 0.01 + randomsource.nextDouble() * 0.5;
                    double d23 = (double)(Mth.sin(f11) * f10);
                    Particle particle = this.levelRenderer
                        .addParticleInternal(
                            ParticleTypes.DRAGON_BREATH,
                            false,
                            (double)p_362689_.getX() + d14 * 0.1,
                            (double)p_362689_.getY() + 0.3,
                            (double)p_362689_.getZ() + d23 * 0.1,
                            d14,
                            d19,
                            d23
                        );
                    if (particle != null) {
                        particle.setPower(f10);
                    }
                }

                if (p_368262_ == 1) {
                    this.level.playLocalSound(p_362689_, SoundEvents.DRAGON_FIREBALL_EXPLODE, SoundSource.HOSTILE, 1.0F, randomsource.nextFloat() * 0.1F + 0.9F, false);
                }
                break;
            case 2008:
                this.level
                    .addParticle(
                        ParticleTypes.EXPLOSION,
                        (double)p_362689_.getX() + 0.5,
                        (double)p_362689_.getY() + 0.5,
                        (double)p_362689_.getZ() + 0.5,
                        0.0,
                        0.0,
                        0.0
                    );
                break;
            case 2009:
                for (int k1 = 0; k1 < 8; k1++) {
                    this.level
                        .addParticle(
                            ParticleTypes.CLOUD,
                            (double)p_362689_.getX() + randomsource.nextDouble(),
                            (double)p_362689_.getY() + 1.2,
                            (double)p_362689_.getZ() + randomsource.nextDouble(),
                            0.0,
                            0.0,
                            0.0
                        );
                }
                break;
            case 2010:
                this.shootParticles(p_368262_, p_362689_, randomsource, ParticleTypes.WHITE_SMOKE);
                break;
            case 2011:
                ParticleUtils.spawnParticleInBlock(this.level, p_362689_, p_368262_, ParticleTypes.HAPPY_VILLAGER);
                break;
            case 2012:
                ParticleUtils.spawnParticleInBlock(this.level, p_362689_, p_368262_, ParticleTypes.HAPPY_VILLAGER);
                break;
            case 2013:
                ParticleUtils.spawnSmashAttackParticles(this.level, p_362689_, p_368262_);
                break;
            case 3000:
                this.level
                    .addParticle(
                        ParticleTypes.EXPLOSION_EMITTER,
                        true,
                        true,
                        (double)p_362689_.getX() + 0.5,
                        (double)p_362689_.getY() + 0.5,
                        (double)p_362689_.getZ() + 0.5,
                        0.0,
                        0.0,
                        0.0
                    );
                this.level
                    .playLocalSound(
                        p_362689_,
                        SoundEvents.END_GATEWAY_SPAWN,
                        SoundSource.BLOCKS,
                        10.0F,
                        (1.0F + (this.level.random.nextFloat() - this.level.random.nextFloat()) * 0.2F) * 0.7F,
                        false
                    );
                break;
            case 3001:
                this.level.playLocalSound(p_362689_, SoundEvents.ENDER_DRAGON_GROWL, SoundSource.HOSTILE, 64.0F, 0.8F + this.level.random.nextFloat() * 0.3F, false);
                break;
            case 3002:
                if (p_368262_ >= 0 && p_368262_ < Direction.Axis.VALUES.length) {
                    ParticleUtils.spawnParticlesAlongAxis(
                        Direction.Axis.VALUES[p_368262_], this.level, p_362689_, 0.125, ParticleTypes.ELECTRIC_SPARK, UniformInt.of(10, 19)
                    );
                } else {
                    ParticleUtils.spawnParticlesOnBlockFaces(this.level, p_362689_, ParticleTypes.ELECTRIC_SPARK, UniformInt.of(3, 5));
                }
                break;
            case 3003:
                ParticleUtils.spawnParticlesOnBlockFaces(this.level, p_362689_, ParticleTypes.WAX_ON, UniformInt.of(3, 5));
                this.level.playLocalSound(p_362689_, SoundEvents.HONEYCOMB_WAX_ON, SoundSource.BLOCKS, 1.0F, 1.0F, false);
                break;
            case 3004:
                ParticleUtils.spawnParticlesOnBlockFaces(this.level, p_362689_, ParticleTypes.WAX_OFF, UniformInt.of(3, 5));
                break;
            case 3005:
                ParticleUtils.spawnParticlesOnBlockFaces(this.level, p_362689_, ParticleTypes.SCRAPE, UniformInt.of(3, 5));
                break;
            case 3006:
                int k = p_368262_ >> 6;
                if (k > 0) {
                    if (randomsource.nextFloat() < 0.3F + (float)k * 0.1F) {
                        float f4 = 0.15F + 0.02F * (float)k * (float)k * randomsource.nextFloat();
                        float f6 = 0.4F + 0.3F * (float)k * randomsource.nextFloat();
                        this.level.playLocalSound(p_362689_, SoundEvents.SCULK_BLOCK_CHARGE, SoundSource.BLOCKS, f4, f6, false);
                    }

                    byte b0 = (byte)(p_368262_ & 63);
                    IntProvider intprovider = UniformInt.of(0, k);
                    float f7 = 0.005F;
                    Supplier<Vec3> supplier = () -> new Vec3(
                            Mth.nextDouble(randomsource, -0.005F, 0.005F),
                            Mth.nextDouble(randomsource, -0.005F, 0.005F),
                            Mth.nextDouble(randomsource, -0.005F, 0.005F)
                        );
                    if (b0 == 0) {
                        for (Direction direction : Direction.values()) {
                            float f = direction == Direction.DOWN ? (float) Math.PI : 0.0F;
                            double d4 = direction.getAxis() == Direction.Axis.Y ? 0.65 : 0.57;
                            ParticleUtils.spawnParticlesOnBlockFace(this.level, p_362689_, new SculkChargeParticleOptions(f), intprovider, direction, supplier, d4);
                        }
                    } else {
                        for (Direction direction1 : MultifaceBlock.unpack(b0)) {
                            float f13 = direction1 == Direction.UP ? (float) Math.PI : 0.0F;
                            double d18 = 0.35;
                            ParticleUtils.spawnParticlesOnBlockFace(this.level, p_362689_, new SculkChargeParticleOptions(f13), intprovider, direction1, supplier, 0.35);
                        }
                    }
                } else {
                    this.level.playLocalSound(p_362689_, SoundEvents.SCULK_BLOCK_CHARGE, SoundSource.BLOCKS, 1.0F, 1.0F, false);
                    boolean flag1 = this.level.getBlockState(p_362689_).isCollisionShapeFullBlock(this.level, p_362689_);
                    int j1 = flag1 ? 40 : 20;
                    float f8 = flag1 ? 0.45F : 0.25F;
                    float f9 = 0.07F;

                    for (int j3 = 0; j3 < j1; j3++) {
                        float f12 = 2.0F * randomsource.nextFloat() - 1.0F;
                        float f14 = 2.0F * randomsource.nextFloat() - 1.0F;
                        float f15 = 2.0F * randomsource.nextFloat() - 1.0F;
                        this.level
                            .addParticle(
                                ParticleTypes.SCULK_CHARGE_POP,
                                (double)p_362689_.getX() + 0.5 + (double)(f12 * f8),
                                (double)p_362689_.getY() + 0.5 + (double)(f14 * f8),
                                (double)p_362689_.getZ() + 0.5 + (double)(f15 * f8),
                                (double)(f12 * 0.07F),
                                (double)(f14 * 0.07F),
                                (double)(f15 * 0.07F)
                            );
                    }
                }
                break;
            case 3007:
                for (int i1 = 0; i1 < 10; i1++) {
                    this.level
                        .addParticle(
                            new ShriekParticleOption(i1 * 5),
                            (double)p_362689_.getX() + 0.5,
                            (double)p_362689_.getY() + SculkShriekerBlock.TOP_Y,
                            (double)p_362689_.getZ() + 0.5,
                            0.0,
                            0.0,
                            0.0
                        );
                }

                BlockState blockstate2 = this.level.getBlockState(p_362689_);
                boolean flag = blockstate2.hasProperty(BlockStateProperties.WATERLOGGED) && blockstate2.getValue(BlockStateProperties.WATERLOGGED);
                if (!flag) {
                    this.level
                        .playLocalSound(
                            (double)p_362689_.getX() + 0.5,
                            (double)p_362689_.getY() + SculkShriekerBlock.TOP_Y,
                            (double)p_362689_.getZ() + 0.5,
                            SoundEvents.SCULK_SHRIEKER_SHRIEK,
                            SoundSource.BLOCKS,
                            2.0F,
                            0.6F + this.level.random.nextFloat() * 0.4F,
                            false
                        );
                }
                break;
            case 3008:
                BlockState blockstate = Block.stateById(p_368262_);
                if (blockstate.getBlock() instanceof BrushableBlock brushableblock) {
                    this.level.playLocalSound(p_362689_, brushableblock.getBrushCompletedSound(), SoundSource.PLAYERS, 1.0F, 1.0F, false);
                }

                this.level.addDestroyBlockEffect(p_362689_, blockstate);
                break;
            case 3009:
                ParticleUtils.spawnParticlesOnBlockFaces(this.level, p_362689_, ParticleTypes.EGG_CRACK, UniformInt.of(3, 6));
                break;
            case 3011:
                TrialSpawner.addSpawnParticles(this.level, p_362689_, randomsource, TrialSpawner.FlameParticle.decode(p_368262_).particleType);
                break;
            case 3012:
                this.level
                    .playLocalSound(
                        p_362689_, SoundEvents.TRIAL_SPAWNER_SPAWN_MOB, SoundSource.BLOCKS, 1.0F, (randomsource.nextFloat() - randomsource.nextFloat()) * 0.2F + 1.0F, true
                    );
                TrialSpawner.addSpawnParticles(this.level, p_362689_, randomsource, TrialSpawner.FlameParticle.decode(p_368262_).particleType);
                break;
            case 3013:
                this.level
                    .playLocalSound(
                        p_362689_, SoundEvents.TRIAL_SPAWNER_DETECT_PLAYER, SoundSource.BLOCKS, 1.0F, (randomsource.nextFloat() - randomsource.nextFloat()) * 0.2F + 1.0F, true
                    );
                TrialSpawner.addDetectPlayerParticles(this.level, p_362689_, randomsource, p_368262_, ParticleTypes.TRIAL_SPAWNER_DETECTED_PLAYER);
                break;
            case 3014:
                this.level
                    .playLocalSound(
                        p_362689_, SoundEvents.TRIAL_SPAWNER_EJECT_ITEM, SoundSource.BLOCKS, 1.0F, (randomsource.nextFloat() - randomsource.nextFloat()) * 0.2F + 1.0F, true
                    );
                TrialSpawner.addEjectItemParticles(this.level, p_362689_, randomsource);
                break;
            case 3015:
                if (this.level.getBlockEntity(p_362689_) instanceof VaultBlockEntity vaultblockentity) {
                    VaultBlockEntity.Client.emitActivationParticles(
                        this.level,
                        vaultblockentity.getBlockPos(),
                        vaultblockentity.getBlockState(),
                        vaultblockentity.getSharedData(),
                        p_368262_ == 0 ? ParticleTypes.SMALL_FLAME : ParticleTypes.SOUL_FIRE_FLAME
                    );
                    this.level
                        .playLocalSound(
                            p_362689_,
                            SoundEvents.VAULT_ACTIVATE,
                            SoundSource.BLOCKS,
                            1.0F,
                            (randomsource.nextFloat() - randomsource.nextFloat()) * 0.2F + 1.0F,
                            true
                        );
                }
                break;
            case 3016:
                VaultBlockEntity.Client.emitDeactivationParticles(this.level, p_362689_, p_368262_ == 0 ? ParticleTypes.SMALL_FLAME : ParticleTypes.SOUL_FIRE_FLAME);
                this.level
                    .playLocalSound(
                        p_362689_, SoundEvents.VAULT_DEACTIVATE, SoundSource.BLOCKS, 1.0F, (randomsource.nextFloat() - randomsource.nextFloat()) * 0.2F + 1.0F, true
                    );
                break;
            case 3017:
                TrialSpawner.addEjectItemParticles(this.level, p_362689_, randomsource);
                break;
            case 3018:
                for (int i = 0; i < 10; i++) {
                    double d1 = randomsource.nextGaussian() * 0.02;
                    double d2 = randomsource.nextGaussian() * 0.02;
                    double d3 = randomsource.nextGaussian() * 0.02;
                    this.level
                        .addParticle(
                            ParticleTypes.POOF,
                            (double)p_362689_.getX() + randomsource.nextDouble(),
                            (double)p_362689_.getY() + randomsource.nextDouble(),
                            (double)p_362689_.getZ() + randomsource.nextDouble(),
                            d1,
                            d2,
                            d3
                        );
                }

                this.level
                    .playLocalSound(
                        p_362689_, SoundEvents.COBWEB_PLACE, SoundSource.BLOCKS, 1.0F, (randomsource.nextFloat() - randomsource.nextFloat()) * 0.2F + 1.0F, true
                    );
                break;
            case 3019:
                this.level
                    .playLocalSound(
                        p_362689_, SoundEvents.TRIAL_SPAWNER_DETECT_PLAYER, SoundSource.BLOCKS, 1.0F, (randomsource.nextFloat() - randomsource.nextFloat()) * 0.2F + 1.0F, true
                    );
                TrialSpawner.addDetectPlayerParticles(this.level, p_362689_, randomsource, p_368262_, ParticleTypes.TRIAL_SPAWNER_DETECTED_PLAYER_OMINOUS);
                break;
            case 3020:
                this.level
                    .playLocalSound(
                        p_362689_,
                        SoundEvents.TRIAL_SPAWNER_OMINOUS_ACTIVATE,
                        SoundSource.BLOCKS,
                        p_368262_ == 0 ? 0.3F : 1.0F,
                        (randomsource.nextFloat() - randomsource.nextFloat()) * 0.2F + 1.0F,
                        true
                    );
                TrialSpawner.addDetectPlayerParticles(this.level, p_362689_, randomsource, 0, ParticleTypes.TRIAL_SPAWNER_DETECTED_PLAYER_OMINOUS);
                TrialSpawner.addBecomeOminousParticles(this.level, p_362689_, randomsource);
                break;
            case 3021:
                this.level
                    .playLocalSound(
                        p_362689_, SoundEvents.TRIAL_SPAWNER_SPAWN_ITEM, SoundSource.BLOCKS, 1.0F, (randomsource.nextFloat() - randomsource.nextFloat()) * 0.2F + 1.0F, true
                    );
                TrialSpawner.addSpawnParticles(this.level, p_362689_, randomsource, TrialSpawner.FlameParticle.decode(p_368262_).particleType);
        }
    }

    private void shootParticles(int p_365984_, BlockPos p_363841_, RandomSource p_369818_, SimpleParticleType p_368421_) {
        Direction direction = Direction.from3DDataValue(p_365984_);
        int i = direction.getStepX();
        int j = direction.getStepY();
        int k = direction.getStepZ();

        for (int l = 0; l < 10; l++) {
            double d0 = p_369818_.nextDouble() * 0.2 + 0.01;
            double d1 = (double)p_363841_.getX() + (double)i * 0.6 + 0.5 + (double)i * 0.01 + (p_369818_.nextDouble() - 0.5) * (double)k * 0.5;
            double d2 = (double)p_363841_.getY() + (double)j * 0.6 + 0.5 + (double)j * 0.01 + (p_369818_.nextDouble() - 0.5) * (double)j * 0.5;
            double d3 = (double)p_363841_.getZ() + (double)k * 0.6 + 0.5 + (double)k * 0.01 + (p_369818_.nextDouble() - 0.5) * (double)i * 0.5;
            double d4 = (double)i * d0 + p_369818_.nextGaussian() * 0.01;
            double d5 = (double)j * d0 + p_369818_.nextGaussian() * 0.01;
            double d6 = (double)k * d0 + p_369818_.nextGaussian() * 0.01;
            this.levelRenderer.addParticle(p_368421_, d1, d2, d3, d4, d5, d6);
        }
    }

    private void playJukeboxSong(Holder<JukeboxSong> p_369005_, BlockPos p_367637_) {
        this.stopJukeboxSong(p_367637_);
        JukeboxSong jukeboxsong = p_369005_.value();
        SoundEvent soundevent = jukeboxsong.soundEvent().value();
        SoundInstance soundinstance = SimpleSoundInstance.forJukeboxSong(soundevent, Vec3.atCenterOf(p_367637_));
        this.playingJukeboxSongs.put(p_367637_, soundinstance);
        this.minecraft.getSoundManager().play(soundinstance);
        this.minecraft.gui.setNowPlaying(jukeboxsong.description());
        this.notifyNearbyEntities(this.level, p_367637_, true);
    }

    private void stopJukeboxSong(BlockPos p_364210_) {
        SoundInstance soundinstance = this.playingJukeboxSongs.remove(p_364210_);
        if (soundinstance != null) {
            this.minecraft.getSoundManager().stop(soundinstance);
        }
    }

    private void stopJukeboxSongAndNotifyNearby(BlockPos p_362905_) {
        this.stopJukeboxSong(p_362905_);
        this.notifyNearbyEntities(this.level, p_362905_, false);
    }

    private void notifyNearbyEntities(Level p_366051_, BlockPos p_362804_, boolean p_363434_) {
        for (LivingEntity livingentity : p_366051_.getEntitiesOfClass(LivingEntity.class, new AABB(p_362804_).inflate(3.0))) {
            livingentity.setRecordPlayingNearby(p_362804_, p_363434_);
        }
    }
}