-
Notifications
You must be signed in to change notification settings - Fork 48
/
ChromaticEventManager.java
2759 lines (2570 loc) · 104 KB
/
ChromaticEventManager.java
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
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*******************************************************************************
* @author Reika Kalseki
*
* Copyright 2017
*
* All rights reserved.
* Distribution of the software in any form is only allowed with
* explicit, prior permission from the owner.
******************************************************************************/
package Reika.ChromatiCraft;
import java.io.File;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import java.util.UUID;
import com.xcompwiz.mystcraft.api.event.LinkEvent;
import net.minecraft.block.Block;
import net.minecraft.block.BlockCrops;
import net.minecraft.block.material.Material;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.boss.EntityDragon;
import net.minecraft.entity.boss.EntityWither;
import net.minecraft.entity.item.EntityEnderCrystal;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.item.EntityTNTPrimed;
import net.minecraft.entity.item.EntityXPOrb;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.monster.EntityEnderman;
import net.minecraft.entity.monster.EntityGhast;
import net.minecraft.entity.monster.EntityPigZombie;
import net.minecraft.entity.monster.EntitySkeleton;
import net.minecraft.entity.monster.EntitySlime;
import net.minecraft.entity.monster.EntitySpider;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.passive.EntitySheep;
import net.minecraft.entity.passive.EntityTameable;
import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagIntArray;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.MovingObjectPosition.MovingObjectType;
import net.minecraft.util.Vec3;
import net.minecraft.world.ChunkPosition;
import net.minecraft.world.EnumSkyBlock;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.gen.feature.WorldGenAbstractTree;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.common.EnumPlantType;
import net.minecraftforge.common.ForgeChunkManager.ForceChunkEvent;
import net.minecraftforge.common.ForgeChunkManager.Ticket;
import net.minecraftforge.common.IPlantable;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
import net.minecraftforge.event.entity.living.EnderTeleportEvent;
import net.minecraftforge.event.entity.living.LivingAttackEvent;
import net.minecraftforge.event.entity.living.LivingDeathEvent;
import net.minecraftforge.event.entity.living.LivingDropsEvent;
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
import net.minecraftforge.event.entity.living.LivingFallEvent;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent;
import net.minecraftforge.event.entity.living.LivingSpawnEvent;
import net.minecraftforge.event.entity.living.LivingSpawnEvent.CheckSpawn;
import net.minecraftforge.event.entity.player.AttackEntityEvent;
import net.minecraftforge.event.entity.player.BonemealEvent;
import net.minecraftforge.event.entity.player.EntityItemPickupEvent;
import net.minecraftforge.event.entity.player.FillBucketEvent;
import net.minecraftforge.event.entity.player.PlayerEvent.BreakSpeed;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action;
import net.minecraftforge.event.entity.player.PlayerPickupXpEvent;
import net.minecraftforge.event.terraingen.ChunkProviderEvent;
import net.minecraftforge.event.world.BlockEvent;
import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent;
import net.minecraftforge.event.world.ExplosionEvent;
import net.minecraftforge.event.world.WorldEvent;
import Reika.ChromatiCraft.API.Interfaces.CustomEnderDragon;
import Reika.ChromatiCraft.Auxiliary.ChromaAux;
import Reika.ChromatiCraft.Auxiliary.ChromaFX;
import Reika.ChromatiCraft.Auxiliary.ChromaStacks;
import Reika.ChromatiCraft.Auxiliary.ChromaTeleporter;
import Reika.ChromatiCraft.Auxiliary.FocusCrystalTrade;
import Reika.ChromatiCraft.Auxiliary.LumenTurretDamage;
import Reika.ChromatiCraft.Auxiliary.PylonDamage;
import Reika.ChromatiCraft.Auxiliary.Ability.AbilityHelper;
import Reika.ChromatiCraft.Auxiliary.RecipeManagers.PoolRecipes;
import Reika.ChromatiCraft.Auxiliary.RecipeManagers.PoolRecipes.PoolRecipe;
import Reika.ChromatiCraft.Base.ChromaDimensionBiome;
import Reika.ChromatiCraft.Base.TileEntity.TileEntityCrystalBase;
import Reika.ChromatiCraft.Base.TileEntity.TileEntityLocusPoint;
import Reika.ChromatiCraft.Block.BlockActiveChroma;
import Reika.ChromatiCraft.Block.BlockActiveChroma.TileEntityChroma;
import Reika.ChromatiCraft.Block.BlockFakeSky;
import Reika.ChromatiCraft.Block.Dye.BlockDyeSapling;
import Reika.ChromatiCraft.Block.Dye.BlockRainbowSapling;
import Reika.ChromatiCraft.Block.Worldgen.BlockCliffStone.Variants;
import Reika.ChromatiCraft.Block.Worldgen.BlockLootChest.TileEntityLootChest;
import Reika.ChromatiCraft.Block.Worldgen.BlockSparkle.BlockTypes;
import Reika.ChromatiCraft.Block.Worldgen.BlockStructureShield;
import Reika.ChromatiCraft.Entity.EntityBallLightning;
import Reika.ChromatiCraft.Entity.EntityChromaEnderCrystal;
import Reika.ChromatiCraft.Entity.EntityGlowCloud;
import Reika.ChromatiCraft.Items.ItemFertilitySeed;
import Reika.ChromatiCraft.Items.ItemInfoFragment;
import Reika.ChromatiCraft.Items.Tools.ItemChromaBook;
import Reika.ChromatiCraft.Items.Tools.ItemFloatstoneBoots;
import Reika.ChromatiCraft.Items.Tools.ItemInventoryLinker;
import Reika.ChromatiCraft.Items.Tools.Powered.ItemPurifyCrystal;
import Reika.ChromatiCraft.Items.Tools.Powered.ItemSpawnerBypass;
import Reika.ChromatiCraft.Magic.CrystalPotionController;
import Reika.ChromatiCraft.Magic.ElementTagCompound;
import Reika.ChromatiCraft.Magic.MonumentCompletionRitual;
import Reika.ChromatiCraft.Magic.PlayerElementBuffer;
import Reika.ChromatiCraft.Magic.WarpNetwork;
import Reika.ChromatiCraft.Magic.Artefact.UABombingEffects;
import Reika.ChromatiCraft.Magic.Artefact.UATrades.UATrade;
import Reika.ChromatiCraft.Magic.Enchantment.EnchantmentAggroMask;
import Reika.ChromatiCraft.Magic.Enchantment.EnchantmentBossKill;
import Reika.ChromatiCraft.Magic.Enchantment.EnchantmentDataKeeper;
import Reika.ChromatiCraft.Magic.Enchantment.EnchantmentPhasingSequence;
import Reika.ChromatiCraft.Magic.Enchantment.EnchantmentUseRepair;
import Reika.ChromatiCraft.Magic.Enchantment.EnchantmentWeaponAOE;
import Reika.ChromatiCraft.Magic.Lore.LoreManager;
import Reika.ChromatiCraft.Magic.Progression.ProgressStage;
import Reika.ChromatiCraft.ModInterface.MystPages;
import Reika.ChromatiCraft.ModInterface.Bees.ChromaBeeHelpers;
import Reika.ChromatiCraft.ModInterface.Bees.EfficientFlowerCache;
import Reika.ChromatiCraft.ModInterface.Bees.TileEntityLumenAlveary;
import Reika.ChromatiCraft.ModInterface.ThaumCraft.ChromaAspectManager;
import Reika.ChromatiCraft.ModInterface.VoidRitual.TileEntityVoidMonsterTrap;
import Reika.ChromatiCraft.ModInterface.VoidRitual.VoidMonsterDestructionRitual;
import Reika.ChromatiCraft.ModInterface.VoidRitual.VoidMonsterDestructionRitual.VoidMonsterRitualDamage;
import Reika.ChromatiCraft.Registry.ChromaBlocks;
import Reika.ChromatiCraft.Registry.ChromaEnchants;
import Reika.ChromatiCraft.Registry.ChromaItems;
import Reika.ChromatiCraft.Registry.ChromaOptions;
import Reika.ChromatiCraft.Registry.ChromaPackets;
import Reika.ChromatiCraft.Registry.ChromaSounds;
import Reika.ChromatiCraft.Registry.ChromaTiles;
import Reika.ChromatiCraft.Registry.Chromabilities;
import Reika.ChromatiCraft.Registry.CrystalElement;
import Reika.ChromatiCraft.Registry.ExtraChromaIDs;
import Reika.ChromatiCraft.TileEntity.TileEntityDataNode;
import Reika.ChromatiCraft.TileEntity.AOE.TileEntityAIShutdown;
import Reika.ChromatiCraft.TileEntity.AOE.TileEntityAuraPoint;
import Reika.ChromatiCraft.TileEntity.AOE.TileEntityItemCollector;
import Reika.ChromatiCraft.TileEntity.AOE.TileEntityLampController;
import Reika.ChromatiCraft.TileEntity.AOE.TileEntityMultiBuilder;
import Reika.ChromatiCraft.TileEntity.AOE.Defence.TileEntityChromaLamp;
import Reika.ChromatiCraft.TileEntity.AOE.Defence.TileEntityCloakingTower;
import Reika.ChromatiCraft.TileEntity.AOE.Defence.TileEntityCrystalBeacon;
import Reika.ChromatiCraft.TileEntity.AOE.Defence.TileEntityExplosionShield;
import Reika.ChromatiCraft.TileEntity.AOE.Effect.TileEntityProtectionUpgrade;
import Reika.ChromatiCraft.TileEntity.Networking.TileEntityCrystalBroadcaster;
import Reika.ChromatiCraft.TileEntity.Networking.TileEntityCrystalRepeater;
import Reika.ChromatiCraft.TileEntity.Plants.TileEntityHeatLily;
import Reika.ChromatiCraft.TileEntity.Processing.TileEntityAutoEnchanter;
import Reika.ChromatiCraft.TileEntity.Recipe.TileEntityAuraInfuser;
import Reika.ChromatiCraft.TileEntity.Technical.TileEntityStructControl;
import Reika.ChromatiCraft.World.BiomeGlowingCliffs;
import Reika.ChromatiCraft.World.BiomeGlowingCliffs.GlowingTreeGen;
import Reika.ChromatiCraft.World.BiomeRainbowForest;
import Reika.ChromatiCraft.World.EndOverhaulManager;
import Reika.ChromatiCraft.World.Dimension.CheatingPreventionSystem;
import Reika.ChromatiCraft.World.Dimension.ChromaDimensionManager;
import Reika.ChromatiCraft.World.Dimension.ChromaDimensionManager.Biomes;
import Reika.ChromatiCraft.World.Dimension.ChromaDimensionTicker;
import Reika.ChromatiCraft.World.Dimension.ChunkProviderChroma;
import Reika.ChromatiCraft.World.Dimension.WorldProviderChroma;
import Reika.ChromatiCraft.World.Dimension.Structure.BridgeGenerator;
import Reika.CritterPet.API.TamedCritter;
import Reika.DragonAPI.APIPacketHandler.PacketIDs;
import Reika.DragonAPI.DragonAPIInit;
import Reika.DragonAPI.ModList;
import Reika.DragonAPI.ASM.DependentMethodStripper.ClassDependent;
import Reika.DragonAPI.ASM.DependentMethodStripper.ModDependent;
import Reika.DragonAPI.IO.ReikaFileReader;
import Reika.DragonAPI.Instantiable.RayTracer;
import Reika.DragonAPI.Instantiable.Data.BlockStruct.AbstractSearch.PropagationCondition;
import Reika.DragonAPI.Instantiable.Data.BlockStruct.AbstractSearch.TerminationCondition;
import Reika.DragonAPI.Instantiable.Data.BlockStruct.BreadthFirstSearch;
import Reika.DragonAPI.Instantiable.Data.Immutable.BlockBox;
import Reika.DragonAPI.Instantiable.Data.Immutable.Coordinate;
import Reika.DragonAPI.Instantiable.Data.Immutable.WorldLocation;
import Reika.DragonAPI.Instantiable.Event.ApplyPotionEvent;
import Reika.DragonAPI.Instantiable.Event.AttackAggroEvent;
import Reika.DragonAPI.Instantiable.Event.BlockConsumedByFireEvent;
import Reika.DragonAPI.Instantiable.Event.BlockSpreadEvent;
import Reika.DragonAPI.Instantiable.Event.BlockSpreadEvent.BlockDeathEvent;
import Reika.DragonAPI.Instantiable.Event.BlockTickEvent;
import Reika.DragonAPI.Instantiable.Event.BlockTillEvent;
import Reika.DragonAPI.Instantiable.Event.CanSeeSkyEvent;
import Reika.DragonAPI.Instantiable.Event.ChunkPopulationEvent;
import Reika.DragonAPI.Instantiable.Event.EnderAttackTPEvent;
import Reika.DragonAPI.Instantiable.Event.EntityCollisionEvents.CollisionBoxEvent;
import Reika.DragonAPI.Instantiable.Event.EntityCollisionEvents.RaytraceEvent;
import Reika.DragonAPI.Instantiable.Event.EntitySpawnerCheckEvent;
import Reika.DragonAPI.Instantiable.Event.FarmlandTrampleEvent;
import Reika.DragonAPI.Instantiable.Event.FireSpreadEvent;
import Reika.DragonAPI.Instantiable.Event.GenLayerBeachEvent;
import Reika.DragonAPI.Instantiable.Event.GenLayerRiverEvent;
import Reika.DragonAPI.Instantiable.Event.GetPlayerLookEvent;
import Reika.DragonAPI.Instantiable.Event.GrassSustainCropEvent;
import Reika.DragonAPI.Instantiable.Event.HarvestLevelEvent;
import Reika.DragonAPI.Instantiable.Event.IceFreezeEvent;
import Reika.DragonAPI.Instantiable.Event.ItemStackUpdateEvent;
import Reika.DragonAPI.Instantiable.Event.ItemUpdateEvent;
import Reika.DragonAPI.Instantiable.Event.LavaFreezeEvent;
import Reika.DragonAPI.Instantiable.Event.LavaSpawnFireEvent;
import Reika.DragonAPI.Instantiable.Event.LeafDecayEvent;
import Reika.DragonAPI.Instantiable.Event.MobTargetingEvent;
import Reika.DragonAPI.Instantiable.Event.PigZombieAggroSpreadEvent;
import Reika.DragonAPI.Instantiable.Event.PlayerKeepInventoryEvent;
import Reika.DragonAPI.Instantiable.Event.PlayerPlaceBlockEvent;
import Reika.DragonAPI.Instantiable.Event.PlayerSprintEvent;
import Reika.DragonAPI.Instantiable.Event.SetBlockEvent;
import Reika.DragonAPI.Instantiable.Event.SlotEvent.AddToSlotEvent;
import Reika.DragonAPI.Instantiable.Event.SlotEvent.ClickItemInSlotEvent;
import Reika.DragonAPI.Instantiable.Event.SlotEvent.RemoveFromSlotEvent;
import Reika.DragonAPI.Instantiable.Event.SpawnerCheckPlayerEvent;
import Reika.DragonAPI.Instantiable.Event.TileEntityMoveEvent;
import Reika.DragonAPI.Instantiable.Event.VillagerTradeEvent;
import Reika.DragonAPI.Instantiable.Event.Client.SinglePlayerLogoutEvent;
import Reika.DragonAPI.Instantiable.IO.PacketTarget;
import Reika.DragonAPI.Interfaces.Block.SemiUnbreakable;
import Reika.DragonAPI.Interfaces.Entity.ClampedDamage;
import Reika.DragonAPI.Interfaces.Item.ActivatedInventoryItem;
import Reika.DragonAPI.Libraries.ReikaAABBHelper;
import Reika.DragonAPI.Libraries.ReikaDirectionHelper;
import Reika.DragonAPI.Libraries.ReikaEnchantmentHelper;
import Reika.DragonAPI.Libraries.ReikaEntityHelper;
import Reika.DragonAPI.Libraries.ReikaInventoryHelper;
import Reika.DragonAPI.Libraries.ReikaPlayerAPI;
import Reika.DragonAPI.Libraries.IO.ReikaChatHelper;
import Reika.DragonAPI.Libraries.IO.ReikaPacketHelper;
import Reika.DragonAPI.Libraries.IO.ReikaSoundHelper;
import Reika.DragonAPI.Libraries.Java.ReikaJavaLibrary;
import Reika.DragonAPI.Libraries.Java.ReikaObfuscationHelper;
import Reika.DragonAPI.Libraries.Java.ReikaRandomHelper;
import Reika.DragonAPI.Libraries.Registry.ReikaItemHelper;
import Reika.DragonAPI.Libraries.Registry.ReikaParticleHelper;
import Reika.DragonAPI.Libraries.Registry.ReikaTreeHelper;
import Reika.DragonAPI.Libraries.World.ReikaBlockHelper;
import Reika.DragonAPI.ModInteract.ReikaTwilightHelper;
import Reika.DragonAPI.ModInteract.DeepInteract.ReikaMystcraftHelper;
import Reika.DragonAPI.ModInteract.DeepInteract.ReikaThaumHelper;
import Reika.DragonAPI.ModInteract.ItemHandlers.ArsMagicaHandler;
import Reika.DragonAPI.ModInteract.ItemHandlers.IC2RubberLogHandler;
import Reika.DragonAPI.ModInteract.ItemHandlers.ThaumIDHandler;
import Reika.DragonAPI.ModInteract.ItemHandlers.TinkerToolHandler;
import Reika.DragonAPI.ModInteract.ItemHandlers.TinkerToolHandler.ToolPartType;
import Reika.DragonAPI.ModRegistry.InterfaceCache;
import Reika.VoidMonster.API.PlayerLookAtVoidMonsterEvent;
import Reika.VoidMonster.API.VoidMonsterEatLightEvent;
import Reika.VoidMonster.Entity.EntityVoidMonster;
import WayofTime.alchemicalWizardry.api.event.TeleposeEvent;
import am2.api.events.SpellCastingEvent;
import am2.api.spell.component.interfaces.ISpellComponent;
import appeng.api.networking.IGrid;
import appeng.api.networking.IGridHost;
import appeng.api.networking.IGridNode;
import cpw.mods.fml.common.eventhandler.Event;
import cpw.mods.fml.common.eventhandler.Event.Result;
import cpw.mods.fml.common.eventhandler.EventPriority;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent;
import cpw.mods.fml.common.network.FMLNetworkEvent.ClientDisconnectionFromServerEvent;
import forestry.api.multiblock.IAlvearyComponent;
import thaumcraft.api.aspects.Aspect;
import thaumcraft.common.entities.monster.EntityWisp;
public class ChromaticEventManager {
public static final ChromaticEventManager instance = new ChromaticEventManager();
private final Random rand = new Random();
private boolean applyingAOE;
private boolean applyingPhasing;
public EntityPlayer collectItemPlayer;
private final HashSet<Coordinate> playerBreakCache = new HashSet();
private ChromaticEventManager() {
}
/*
@ModDependent(ModList.THAUMCRAFT)
public void scanTCPylons(PlayerUseItemEvent.Tick evt) {
EntityPlayer ep = evt.entityPlayer;
if (ep.worldObj.isRemote) {
MovingObjectPosition mov = ReikaPlayerAPI.getLookedAtBlockClient(4.5, false);//is.getItem().getMovingObjectPositionFromPlayer(world, ep, false);
if (mov != null) {
if (ChromaTiles.getTile(ep.worldObj, mov.blockX, mov.blockY, mov.blockZ) == ChromaTiles.PYLON) {
TileEntityCrystalPylon te = (TileEntityCrystalPylon)ep.worldObj.getTileEntity(mov.blockX, mov.blockY, mov.blockZ);
ModInteraction.triggerPylonScanProgress(ep, te);
}
}
}
}
*/
@SubscribeEvent
@ModDependent(ModList.APPENG)
public void registerPatternHandler(PlayerInteractEvent evt) {
if (evt.action == Action.RIGHT_CLICK_BLOCK && !evt.world.isRemote) {
TileEntity te = evt.world.getTileEntity(evt.x, evt.y, evt.z);
if (te instanceof IGridHost) {
IGridNode node = ((IGridHost)te).getGridNode(evt.face == -1 ? ForgeDirection.UNKNOWN : ForgeDirection.VALID_DIRECTIONS[evt.face]);
if (node != null) {
IGrid grid = node.getGrid();
//NetworkEventBus bus = ((Grid)grid).eventBus;
//bus.readClass();
}
}
}
}
@SubscribeEvent
public void fakeJABBACompat(PlayerInteractEvent evt) {
if (evt.action == Action.RIGHT_CLICK_BLOCK && !evt.world.isRemote) {
if (evt.world.getBlock(evt.x, evt.y, evt.z) == ChromaBlocks.LOOTCHEST.getBlockInstance()) {
TileEntityLootChest te = (TileEntityLootChest)evt.world.getTileEntity(evt.x, evt.y, evt.z);
EntityPlayer ep = evt.entityPlayer;
if (te.isOwnedBy(ep)) {
ItemStack held = ep.getCurrentEquippedItem();
ItemStack dolly = ReikaItemHelper.lookupItem("JABBA:mover");
if (dolly != null && ReikaItemHelper.matchStacks(held, dolly)) {
ItemStack chest = ChromaBlocks.LOOTCHEST.getStackOf();
if (chest.stackTagCompound == null)
chest.stackTagCompound = new NBTTagCompound();
NBTTagList tag = new NBTTagList();
te.writeItems(tag);
ReikaInventoryHelper.clearInventory(te);
te.worldObj.setBlockToAir(te.xCoord, te.yCoord, te.zCoord);
chest.stackTagCompound.setTag("cached", tag);
ReikaPlayerAPI.addOrDropItem(chest, ep);
//ReikaItemHelper.dropItem(te.worldObj, te.xCoord, te.yCoord+1, te.zCoord, chest);
ReikaSoundHelper.playSoundFromServerAtBlock(te.worldObj, te.xCoord, te.yCoord, te.zCoord, "random.pop", 1, 1, true);
evt.setCanceled(true);
}
}
}
}
}
@SubscribeEvent
public void addBlockBreakProgress(BlockEvent.BreakEvent evt) {
EntityPlayer ep = evt.getPlayer();
if (ep != null && !ReikaPlayerAPI.isFake(ep)) {
if (ReikaBlockHelper.isOre(evt.block, evt.blockMetadata))
ProgressStage.MINE.stepPlayerTo(ep);
if (evt.block instanceof BlockCrops || (evt.block instanceof IPlantable && ((IPlantable)evt.block).getPlantType(evt.world, evt.x, evt.y, evt.z) == EnumPlantType.Crop))
ProgressStage.HARVEST.stepPlayerTo(ep);
}
}
@SubscribeEvent
public void addPotionProgress(ApplyPotionEvent evt) {
if (evt.entityLiving instanceof EntityPlayer) {
ProgressStage.POTION.stepPlayerTo((EntityPlayer)evt.entityLiving);
}
}
@SubscribeEvent
public void makeSparkleObsidian(LavaFreezeEvent evt) {
if (evt.world.provider.dimensionId == ExtraChromaIDs.DIMID.getValue()) {
ChromaDimensionBiome biome = (ChromaDimensionBiome)evt.world.getBiomeGenForCoords(evt.xCoord, evt.zCoord);
if (biome.biomeType == Biomes.SPARKLE) {
BlockTypes bs = evt.originalPlacement == Blocks.obsidian ? BlockTypes.OBSIDIAN : BlockTypes.COBBLE;
evt.setBlock(ChromaBlocks.SPARKLE.getBlockInstance(), bs.ordinal(), 3);
evt.setCanceled(true);
}
}
}
@SubscribeEvent
public void rightClickLexicon(ClickItemInSlotEvent evt) {
if (ChromaItems.HELP.matchWith(evt.itemInSlot)) {
//evt.player.openGui(ChromatiCraft.instance, ChromaGuis.BOOKEMPTIES.ordinal(), evt.player.worldObj, 0, 0, 0);
ItemStack cur = evt.player.inventory.getItemStack();
if (ChromaItems.FRAGMENT.matchWith(cur) && cur.stackTagCompound == null) {
int amt = evt.buttonID == 0 ? cur.stackSize : 1;
ItemChromaBook.addBlanks(evt.itemInSlot, amt);
cur.stackSize -= amt;
if (cur.stackSize <= 0)
evt.player.inventory.setItemStack(null);
evt.setCanceled(true);
}
else if (cur == null && evt.buttonID == 1) {
int stored = ItemChromaBook.getBlanksStored(evt.itemInSlot);
if (stored > 0) {
int take = 1;//Math.min(8, stored);
ItemChromaBook.addBlanks(evt.itemInSlot, -take);
evt.player.inventory.setItemStack(ChromaItems.FRAGMENT.getCraftedProduct(take));
evt.setCanceled(true);
}
}
}
}
@SubscribeEvent
public void stopBiggerOakDecay(LeafDecayEvent evt) {
if (evt.world instanceof World) {
BiomeGenBase b = ((World)evt.world).getBiomeGenForCoords(evt.xCoord, evt.zCoord);
if (ChromatiCraft.isEnderForest(b) || BiomeGlowingCliffs.isGlowingCliffs(b)) {
if (evt.world.getBlock(evt.xCoord, evt.yCoord, evt.zCoord) == ReikaTreeHelper.OAK.getLogID()) {
if (!this.canBiomeOakDecay((World)evt.world, evt.xCoord, evt.yCoord, evt.zCoord)) {
evt.setResult(Result.DENY);
}
}
}
}
}
protected boolean canBiomeOakDecay(World world, final int x, final int y, final int z) {
TerminationCondition t = new TerminationCondition(){
@Override
public boolean isValidTerminus(World world, int dx, int dy, int dz) {
Block b = world.getBlock(dx, dy, dz);
return b.isWood(world, x, y, z) && ReikaTreeHelper.getTree(b, world.getBlockMetadata(dx, dy, dz)) == ReikaTreeHelper.OAK;
}
};
PropagationCondition c = new PropagationCondition(){
@Override
public boolean isValidLocation(World world, int dx, int dy, int dz, Coordinate from) {
return ReikaTreeHelper.getTree(world.getBlock(dx, dy, dz), world.getBlockMetadata(dx, dy, dz)) == ReikaTreeHelper.OAK;
}
};
BreadthFirstSearch s = new BreadthFirstSearch(x, y, z, c, t);
s.limit = BlockBox.block(x, y, z).expand(7, 15, 7);
s.depthLimit = 32;
s.complete(world);
return s.getResult().isEmpty();
}
/*
@SubscribeEvent
public void noLaunchpadFallDamage(LivingFallEvent ev) {
Coordinate c = new Coordinate(ev.entityLiving.posX, ev.entityLiving.posY-0.5, ev.entityLiving.posZ);
ChromaTiles te = ChromaTiles.getTile(ev.entityLiving.worldObj, c.xCoord, c.yCoord, c.zCoord);
boolean flag1 = te == ChromaTiles.LAUNCHPAD;
boolean flag2 = c.getBlock(ev.entityLiving.worldObj) == ChromaBlocks.PYLONSTRUCT.getBlockInstance();
if (flag1 || flag2) {
ev.setCanceled(true);
ev.distance = 0;
}
}*/
@ModDependent(ModList.VOIDMONSTER)
@SubscribeEvent(priority = EventPriority.LOWEST)
public void makeRitualMonsterNotAttackable(LivingHurtEvent evt) {
if (VoidMonsterDestructionRitual.isFocusOfActiveRitual(evt.entity)) {
if (!(evt.source instanceof VoidMonsterRitualDamage)) {
evt.setCanceled(true);
}
}
}
@SubscribeEvent
@ModDependent(ModList.IC2)
public void handleRubberLogPlacement(PlayerPlaceBlockEvent evt) {
ItemStack held = evt.player.getCurrentEquippedItem();
if (held != null && IC2RubberLogHandler.getInstance().isCrop(evt.block, held.getItemDamage()) && IC2RubberLogHandler.getInstance().isRipeCrop(evt.block, held.getItemDamage())) {
evt.setCanceled(true);
Block b = IC2RubberLogHandler.getInstance().logBlock;
ForgeDirection dir = ReikaDirectionHelper.getFromLookDirection(evt.player, false);
//ReikaJavaLibrary.pConsole(dir);
int meta = IC2RubberLogHandler.getInstance().getMeta(dir.getOpposite());
evt.setBlock(b, meta, 3);
ReikaSoundHelper.playPlaceSound(evt.world, evt.xCoord, evt.yCoord, evt.zCoord, b);
held.stackSize--;
if (held.stackSize <= 0)
held = null;
evt.player.setCurrentItemOrArmor(0, held);
}
}
@SubscribeEvent
public void applyIdentityRetention(BlockEvent.BreakEvent evt) {
if (EnchantmentDataKeeper.handleBreak(evt.world, evt.x, evt.y, evt.z, evt.block, evt.blockMetadata, evt.getPlayer())) {
evt.setCanceled(true);
evt.world.setBlock(evt.x, evt.y, evt.z, Blocks.air);
}
}
@SubscribeEvent
public void noDimWarpMobs(EntityJoinWorldEvent evt) {
if (evt.world.provider.dimensionId == ExtraChromaIDs.DIMID.getValue()) {
if (ChromaDimensionManager.isDisallowedEntity(evt.entity)) {
evt.setCanceled(true);
}
}
}
@SubscribeEvent
@ModDependent(ModList.VOIDMONSTER)
public void triggerVoidMonsterTeleport(ExplosionEvent.Start evt) {
if (evt.explosion.exploder instanceof EntityTNTPrimed && !evt.world.isRemote) {
if (TileEntityVoidMonsterTrap.handleTNTTrigger(evt.world, evt.explosion.exploder))
evt.setCanceled(true);
}
}
@SubscribeEvent
@ModDependent(ModList.VOIDMONSTER)
public void preventVoidMonsterRedstoneCrystalTorchEat(VoidMonsterEatLightEvent evt) {
if (this.isCrystallineRedstoneTorch(evt.world, evt.xCoord, evt.yCoord, evt.zCoord, evt.block, evt.metadata)) {
evt.setCanceled(true);
}
}
public boolean isCrystallineRedstoneTorch(IBlockAccess world, int x, int y, int z, Block b, int meta) {
if (b == Blocks.redstone_torch || b == Blocks.unlit_redstone_torch) {
if (meta == 5) {
Block b2 = world.getBlock(x, y-1, z);
if (b2 == ChromaBlocks.PYLONSTRUCT.getBlockInstance() || b2 instanceof BlockStructureShield) {
return true;
}
}
}
return false;
}
@SubscribeEvent
public void overrideCollision(CollisionBoxEvent evt) {
evt.box = ChromaAux.getInterceptedCollisionBox(evt.entity, evt.world, evt.xCoord, evt.yCoord, evt.zCoord, evt.box);
}
@SubscribeEvent
public void overrideRaytrace(RaytraceEvent evt) {
evt.result = ChromaAux.getInterceptedRaytrace(evt.entity, evt.pos1, evt.pos2, evt.flag1, evt.flag2, evt.flag3, evt.result);
}
@SubscribeEvent(priority = EventPriority.LOWEST)
public void delegateEnchantGui(PlayerInteractEvent evt) {
if (evt.entityPlayer.isSneaking())
return;
if (ChromaItems.BUCKET.matchWith(evt.entityPlayer.getCurrentEquippedItem()))
return;
if (evt.entityPlayer.getCurrentEquippedItem() != null && evt.entityPlayer.getCurrentEquippedItem().getItem() instanceof ItemBlock)
return;
if (evt.action == Action.RIGHT_CLICK_BLOCK) {
if (ChromaTiles.getTile(evt.world, evt.x, evt.y-1, evt.z) == ChromaTiles.ENCHANTER) {
if (((TileEntityAutoEnchanter)evt.world.getTileEntity(evt.x, evt.y-1, evt.z)).isAssisted()) {
ChromaTiles.ENCHANTER.getBlock().onBlockActivated(evt.world, evt.x, evt.y-1, evt.z, evt.entityPlayer, evt.face, 0, 0, 0);
evt.setCanceled(true);
}
}
}
}
@SubscribeEvent(priority = EventPriority.LOWEST)
public void lockT2EnderEyes(EntityItemPickupEvent evt) {
if (evt.item.getEntityItem().getItem() == ChromaItems.ENDEREYE.getItemInstance()) {
NBTTagCompound tag = evt.item.getEntityItem().stackTagCompound;
if (tag != null && tag.hasKey("owner")) {
UUID uid = UUID.fromString(tag.getString("owner"));
if (!uid.equals(evt.entityPlayer.getPersistentID()))
evt.setCanceled(true);
}
}
}
/*
@SubscribeEvent(priority = EventPriority.LOWEST)
public void clampGlowCloudCount(WorldEvent.PotentialSpawns evt) {
}
*/
@SubscribeEvent
public void toggleSpawners(SpawnerCheckPlayerEvent evt) {
if (ItemSpawnerBypass.isActive(evt.player)) {
RayTracer rt = RayTracer.getVisualLOS();
rt.addTransparentBlock(Blocks.mob_spawner);
rt.addTransparentBlock(Blocks.web);
rt.setOrigins(evt.spawner.getSpawnerX()+0.5, evt.spawner.getSpawnerY()+0.5, evt.spawner.getSpawnerZ()+0.5, evt.player.posX, evt.player.posY, evt.player.posZ);
if (evt.player.getDistanceSq(evt.spawner.getSpawnerX()+0.5, evt.spawner.getSpawnerY()+0.5, evt.spawner.getSpawnerZ()+0.5) <= evt.spawner.activatingRangeFromPlayer*evt.spawner.activatingRangeFromPlayer)
evt.player.getEntityData().setLong("spawnerpass", evt.player.worldObj.getTotalWorldTime());
if (!rt.isClearLineOfSight(evt.player.worldObj)) {
evt.setResult(Result.DENY);
}
}
}
@ModDependent(ModList.FORESTRY)
@SubscribeEvent(priority = EventPriority.LOWEST)
public void resyncAlvearies(PlayerInteractEvent evt) {
if (evt.action == Action.RIGHT_CLICK_BLOCK) {
TileEntity te = evt.world.getTileEntity(evt.x, evt.y, evt.z);
if (te instanceof IAlvearyComponent && !(te instanceof TileEntityLumenAlveary)) {
IAlvearyComponent iae = (IAlvearyComponent)te;
try {
TileEntityLumenAlveary te2 = ChromaBeeHelpers.getLumenAlvearyController(iae.getMultiblockLogic().getController(), evt.world, iae.getCoordinates());
if (te2 != null) {
EfficientFlowerCache eff = te2.getFlowerCache();
if (eff != null) {
eff.forceUpdate(te2);
}
te2.syncAllData(true);
}
}
catch (AbstractMethodError e) {
String s = "Cannot fetch multiblock logic for alveary part "+iae+"; it is using an old verison of the API! This is a bug in its mod!";
ChromatiCraft.logger.log(s);
ReikaChatHelper.write("Error processing "+iae+"; it is using an outdated API. This is a bug in that mod.");
}
}
}
}
@SubscribeEvent(priority = EventPriority.LOWEST)
public void growGlowcliffsTrees(PlayerInteractEvent evt) {
if (evt.action == Action.RIGHT_CLICK_BLOCK && !evt.world.isRemote) {
if (BiomeGlowingCliffs.isGlowingCliffs(evt.world.getBiomeGenForCoords(evt.x, evt.z))) {
if (evt.world.getBlock(evt.x, evt.y, evt.z) == Blocks.sapling && evt.world.getBlockMetadata(evt.x, evt.y, evt.z)%8 == 0) {
ItemStack is = evt.entityPlayer.getCurrentEquippedItem();
if (is != null && is.getItem() == Items.glowstone_dust && rand.nextInt(3) == 0) {
evt.world.setBlock(evt.x, evt.y, evt.z, Blocks.air);
WorldGenAbstractTree tree = ChromatiCraft.glowingcliffs.getUndergroundTreeGen(rand, true, 12); //default chance is 40
((GlowingTreeGen)tree).setGlowChance(10);
tree.setScale(1.0D, 1.0D, 1.0D);
int n = 8;
boolean flag = tree.generate(evt.world, rand, evt.x, evt.y, evt.z);
while (!flag && n <= 8) {
flag = tree.generate(evt.world, rand, evt.x, evt.y, evt.z);
n++;
}
if (flag) {
tree.func_150524_b(evt.world, rand, evt.x, evt.y, evt.z);
}
is.stackSize--;
}
}
}
}
}
@SubscribeEvent(priority = EventPriority.LOWEST)
public void interceptChunkPopulation(ChunkPopulationEvent evt) {
if (evt.world.provider.dimensionId == ExtraChromaIDs.DIMID.getValue()) {
((WorldProviderChroma)evt.world.provider).getChunkGenerator().onPopulationHook(evt.generator, evt.loader, evt.chunkX, evt.chunkZ);
evt.setCanceled(true);
}
}
@SubscribeEvent(priority = EventPriority.LOWEST)
public void updateFakeSkyBlocks(SetBlockEvent.Post evt) {
if (!evt.isWorldgen)
BlockFakeSky.updateColumn(evt.world, evt.xCoord, evt.yCoord, evt.zCoord);
}
@SubscribeEvent(priority = EventPriority.LOWEST)
public void applyFakeSkyBlocks(CanSeeSkyEvent evt) {
if (BlockFakeSky.isForcedSky(evt.world, evt.xCoord, evt.yCoord, evt.zCoord))
evt.setResult(Result.ALLOW);
}
@SubscribeEvent(priority = EventPriority.LOWEST)
public void removeMetaAlloy(BlockEvent.BreakEvent evt) {
if (!evt.world.isRemote && evt.world.provider.dimensionId == 0 && evt.block == ChromaBlocks.METAALLOYLAMP.getBlockInstance()) {
TileEntityDataNode.removeMetaAlloy(evt.world, evt.x, evt.y, evt.z);
}
}
@SubscribeEvent(priority = EventPriority.LOWEST, receiveCanceled = true)
public void preventSomeGrassBreakInDimension(BreakSpeed evt) {
if (evt.entityPlayer.worldObj.provider.dimensionId == ExtraChromaIDs.DIMID.getValue()) {
if (WorldProviderChroma.isUnbreakableTerrain(evt.entityPlayer.worldObj, evt.x, evt.y, evt.z)) {
evt.setCanceled(true);
}
}
}
@SubscribeEvent(priority=EventPriority.LOWEST)
public void preventSomeGrassBreakInDimension(ExplosionEvent.Detonate evt) {
if (evt.world.provider.dimensionId == ExtraChromaIDs.DIMID.getValue()) {
Iterator<ChunkPosition> it = evt.explosion.affectedBlockPositions.iterator();
while (it.hasNext()) {
ChunkPosition p = it.next();
if (WorldProviderChroma.isUnbreakableTerrain(evt.world, p.chunkPosX, p.chunkPosY, p.chunkPosZ)) {
it.remove();
}
}
}
}
/*
@SubscribeEvent(priority = EventPriority.LOWEST)
public void voxelBuild(PlayerPlaceBlockEvent evt) {
if (Chromabilities.VOXELPLACE.enabledOn(evt.player) && !evt.block.hasTileEntity(evt.metadata)) {
double r = 3.5;
for (int i = MathHelper.floor_double(-r); i <= MathHelper.ceiling_double_int(r); i++) {
for (int j = MathHelper.floor_double(-r); j <= MathHelper.ceiling_double_int(r); j++) {
for (int k = MathHelper.floor_double(-r); k <= MathHelper.ceiling_double_int(r); k++) {
if (ReikaMathLibrary.py3d(i, j, k) <= r) {
int dx = evt.xCoord+i;
int dy = evt.yCoord+j;
int dz = evt.zCoord+k;
ItemStack is = evt.player.getCurrentEquippedItem();
if (is != null && is.stackSize > 0 && evt.world.getBlock(dx, dy, dz).isAir(evt.world, dx, dy, dz)) {
evt.world.setBlock(dx, dy, dz, evt.block, evt.metadata, 3);
if (!evt.player.capabilities.isCreativeMode)
is.stackSize--;
}
}
}
}
}
}
}*/
@SubscribeEvent(priority = EventPriority.LOWEST)
public void multiBuild(PlayerPlaceBlockEvent evt) {
if (evt.player != null)
TileEntityMultiBuilder.placeBlock(evt.world, evt.xCoord, evt.yCoord, evt.zCoord, evt.block, evt.metadata, evt.player, evt.player.getCurrentEquippedItem());
}
@SubscribeEvent(priority = EventPriority.LOWEST)
public void multiBuild(BlockEvent.BreakEvent evt) {
TileEntityMultiBuilder.breakBlock(evt.world, evt.x, evt.y, evt.z, evt.block, evt.blockMetadata, evt.getPlayer());
}
@SubscribeEvent(priority = EventPriority.LOWEST)
public void clearCachedTiles(SinglePlayerLogoutEvent evt) {
this.clearCaches();
}
@SubscribeEvent(priority = EventPriority.LOWEST)
public void clearCachedTiles(ClientDisconnectionFromServerEvent evt) {
this.clearCaches();
}
public void clearCaches() {
TileEntityItemCollector.clearCache();
TileEntityLocusPoint.clearCache();
TileEntityLampController.clearCache();
TileEntityChromaLamp.clearCache();
TileEntityCloakingTower.clearCache();
TileEntityCrystalBeacon.clearCache();
TileEntityMultiBuilder.clearCache();
TileEntityExplosionShield.clearCache();
TileEntityVoidMonsterTrap.clearCache();
TileEntityAuraInfuser.clearCache();
MonumentCompletionRitual.clearRituals();
BlockFakeSky.clearCache();
LoreManager.instance.clearOnLogout();
WarpNetwork.instance.clear();
EndOverhaulManager.instance.clear();
}
@SubscribeEvent(priority = EventPriority.LOWEST)
public void keepLumaFogsNatural(LivingSpawnEvent.SpecialSpawn evt) {
if (evt.entityLiving instanceof EntityGlowCloud) {
evt.setCanceled(true); //prevent onSpawnWithEgg call
}
}
@SubscribeEvent(priority = EventPriority.LOWEST)
public void preventSpawnsInEndTendrils(LivingSpawnEvent.CheckSpawn evt) {
if (evt.world.provider.dimensionId == 1) {
double distChSq = (evt.x*evt.x+evt.z*evt.z)/256;
if (distChSq > 55 && distChSq < EndOverhaulManager.MIN_DIST_SQ_CH+140) {
evt.setResult(Result.DENY);
//ReikaJavaLibrary.pConsole("Preventing spawn of "+evt.entityLiving+" @ "+evt.x+","+evt.z+"="+distChSq);
}
}
}
@SubscribeEvent(priority = EventPriority.LOWEST)
public void preventFertilitySeedReuse(EntityItemPickupEvent evt) {
if (evt.item.getEntityItem().getItem() == ChromaItems.FERTILITYSEED.getItemInstance()) {
if (evt.item.age >= ItemFertilitySeed.INITIAL_DELAY)
evt.setCanceled(true);
}
}
@SubscribeEvent
public void reloadBroacastAirCache(SetBlockEvent.Post evt) {
if (!evt.isWorldgen)
TileEntityCrystalBroadcaster.updateAirCaches(evt.world, evt.xCoord, evt.yCoord, evt.zCoord);
}
/*
@SubscribeEvent
public void preventCliffShadows(LightCalculationEvent evt) {
//if (BiomeGlowingCliffs.isGlowingCliffs(evt.world.getBiomeGenForCoords(evt.x, evt.z))) {
// evt.setCanceled(true);
//}
ImmutablePair<Integer, Integer> val = GlowingCliffsAuxGenerator.TEMP_ISLAND_CACHE.get(new Coordinate(evt.x, 0, evt.z));
if (val != null) {
if (evt.y > /*val.left*//*evt.world.getTopSolidOrLiquidBlock(evt.x, evt.z) && evt.y < val.right) {
//evt.setCanceled(true);
}
}
}
*/
@SubscribeEvent
public void allowCliffGrassCrops(GrassSustainCropEvent evt) {
if (BiomeGlowingCliffs.isGlowingCliffs(evt.getBiome())) {
evt.setResult(Result.ALLOW);
}
}
@SubscribeEvent
public void createCliffFarmland(BlockTillEvent evt) {
if (BiomeGlowingCliffs.isGlowingCliffs(evt.getBiome())) {
//ReikaJavaLibrary.pConsole(evt.x+","+evt.y+","+evt.z+": "+evt.world.getBlock(evt.x, evt.y+1, evt.z).isOpaqueCube());
evt.tilledBlock = ChromaBlocks.CLIFFSTONE.getBlockInstance();
evt.tilledMeta = Variants.FARMLAND.getMeta(false, false);
}
}
@SubscribeEvent
public void preventCliffStackedGrass(BlockDeathEvent evt) {
if (evt.getClass() != BlockDeathEvent.class)
return;
if (evt.getBlock(0, 1, 0).isOpaqueCube()) {
if (BiomeGlowingCliffs.isGlowingCliffs(evt.getBiome()) || evt.getBlock(0, -1, 0) == ChromaBlocks.CLIFFSTONE.getBlockInstance()) {
//ReikaJavaLibrary.pConsole(evt.x+","+evt.y+","+evt.z+": "+evt.world.getBlock(evt.x, evt.y+1, evt.z).isOpaqueCube());
evt.setResult(Result.ALLOW);
}
}
}
@SubscribeEvent
public void preventCliffStackedGrass(BlockSpreadEvent evt) {
if (evt.getClass() != BlockSpreadEvent.class)
return;
if (evt.getBlock(0, 1, 0).isOpaqueCube()) {
if (BiomeGlowingCliffs.isGlowingCliffs(evt.getBiome()) || evt.getBlock(0, -1, 0) == ChromaBlocks.CLIFFSTONE.getBlockInstance()) {
//ReikaJavaLibrary.pConsole(evt.x+","+evt.y+","+evt.z+": "+evt.world.getBlock(evt.x, evt.y+1, evt.z).isOpaqueCube());
evt.setResult(Result.DENY);
}
}
}
@SubscribeEvent
public void preventCliffFire(LavaSpawnFireEvent evt) {
if (BiomeGlowingCliffs.isGlowingCliffs(evt.getBiome())) {
evt.setCanceled(true);
}
}
@SubscribeEvent
public void preventCliffFire(FireSpreadEvent evt) {
if (BiomeGlowingCliffs.isGlowingCliffs(evt.getBiome())) {
evt.setCanceled(true);
}
}
@SubscribeEvent
public void preventCliffBeaches(GenLayerBeachEvent evt) {
if (evt.originalBiomeID.biomeID == ExtraChromaIDs.LUMINOUSCLIFFS.getValue()) {
evt.beachIDToPlace = ExtraChromaIDs.LUMINOUSEDGE.getValue();
}
}
@SubscribeEvent
public void biomeSpecificRivers(GenLayerRiverEvent evt) {
if (evt.originalBiomeID == ExtraChromaIDs.LUMINOUSCLIFFS.getValue() || evt.originalBiomeID == ExtraChromaIDs.LUMINOUSEDGE.getValue()) {
evt.setResult(Result.DENY);
}
else if (evt.originalBiomeID == ExtraChromaIDs.RAINBOWFOREST.getValue()) {
evt.riverBiomeID = ExtraChromaIDs.RAINBOWRIVER.getValue();
}
}
@SubscribeEvent
public void blendCliffEdgesAndShapeCliffs(ChunkProviderEvent.ReplaceBiomeBlocks evt) {
if (evt.world != null && evt.blockArray != null) {
BiomeGlowingCliffs.blendTerrainEdgesAndGenCliffs(evt.world, evt.chunkX, evt.chunkZ, evt.blockArray, evt.metaArray);
}
}
@SubscribeEvent
public void changeLightSpawnCurve(LivingSpawnEvent.CheckSpawn evt) {
int x = MathHelper.floor_double(evt.x);
int z = MathHelper.floor_double(evt.z);
if (BiomeGlowingCliffs.isGlowingCliffs(evt.world.getBiomeGenForCoords(x, z))) {
if (evt.entityLiving instanceof EntityCreeper)
evt.setResult(Result.DENY);
else if (evt.entityLiving instanceof EntitySkeleton || evt.entityLiving instanceof EntitySpider || evt.entityLiving instanceof EntityZombie) {
int y = MathHelper.floor_double(evt.entityLiving.boundingBox.minY);
float block = evt.world.getSavedLightValue(EnumSkyBlock.Block, x, y, z);
float sky = evt.world.getSavedLightValue(EnumSkyBlock.Sky, x, y, z)*Math.max(0, 1-Math.min(evt.world.skylightSubtracted, 8)/8F);
if (sky > 4)
evt.setResult(Result.DENY);
float c = block*1.25F+sky*2F;
if (c >= 7 || rand.nextInt(7) < c)
evt.setResult(Result.DENY);
}
}
}
@SubscribeEvent
public void preventCliffCreepers(LivingSpawnEvent evt) {
if (BiomeGlowingCliffs.isGlowingCliffs(evt.world.getBiomeGenForCoords(MathHelper.floor_double(evt.x), MathHelper.floor_double(evt.z)))) {
if (evt.entityLiving instanceof EntityCreeper)
evt.entityLiving.setDead();
}
}
@SubscribeEvent
public void preventCliffsFreeze(IceFreezeEvent evt) {
if (BiomeGlowingCliffs.isGlowingCliffs(evt.getBiome())) {
evt.setResult(Result.DENY);
}
}
@SubscribeEvent
public void buyUnknownArtefact(VillagerTradeEvent evt) {
if (evt.trade instanceof UATrade) {
if (ReikaRandomHelper.doWithChance(UABombingEffects.TRADE_BOMBING_CHANCE))
UABombingEffects.instance.trigger((Entity)evt.villager);
if (evt.villager instanceof EntityVillager) {
EntityVillager ev = (EntityVillager)evt.villager;
ev.setRevengeTarget(evt.entityPlayer);
}
}
}
@SubscribeEvent
public void buyFocusCrystals(VillagerTradeEvent evt) {
//ReikaJavaLibrary.pConsole(evt.trade);
if (evt.trade instanceof FocusCrystalTrade) {
ProgressStage.FOCUSCRYSTAL.stepPlayerTo(evt.entityPlayer);
}
}
@SubscribeEvent
public void onAddArmor(AddToSlotEvent evt) {
int id = evt.slotID;
if (evt.inventory instanceof InventoryPlayer && evt.slotID == 36) { //foot armor
ItemStack pre = evt.getPreviousItem();
if (pre != null && ItemFloatstoneBoots.isFloatBoots(pre)) {
ItemStack is = evt.getItem();
if (is == null || !ItemFloatstoneBoots.isFloatBoots(is)) {
if (!((InventoryPlayer)evt.inventory).player.capabilities.isCreativeMode) {
((InventoryPlayer)evt.inventory).player.capabilities.allowFlying = false;
((InventoryPlayer)evt.inventory).player.capabilities.isFlying = false;
}
}
}
}
}
@SubscribeEvent
public void onRemoveArmor(RemoveFromSlotEvent evt) {
int id = evt.slotID;
if (evt.slotID == 36) { //foot armor
ItemStack is = evt.getItem();
if (is != null && ItemFloatstoneBoots.isFloatBoots(is)) {
if (!evt.player.capabilities.isCreativeMode) {
evt.player.capabilities.allowFlying = false;
evt.player.capabilities.isFlying = false;
}
}
}
}
@SubscribeEvent
public void noFloatstoneTrample(FarmlandTrampleEvent ev) {
if (ev.entity instanceof EntityLivingBase) {
ItemStack boots = ((EntityLivingBase)ev.entity).getEquipmentInSlot(1);
if (boots != null && ItemFloatstoneBoots.isFloatBoots(boots)) {
ev.setResult(Result.DENY);
}