forked from ACGaming/OpenBlocksReopened
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOpenBlocks.java
More file actions
918 lines (746 loc) · 39.3 KB
/
OpenBlocks.java
File metadata and controls
918 lines (746 loc) · 39.3 KB
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
package openblocks;
import com.google.common.collect.Lists;
import java.util.List;
import info.openmods.openblocks.Tags;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.entity.EntityLiving;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.StatBase;
import net.minecraft.stats.StatBasic;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.datafix.DataFixer;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLConstructionEvent;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLInterModComms;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.common.registry.EntityRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.registries.IForgeRegistry;
import openblocks.advancements.Criterions;
import openblocks.common.CanvasReplaceBlacklist;
import openblocks.common.CommandInventory;
import openblocks.common.DonationUrlManager;
import openblocks.common.ElevatorActionHandler;
import openblocks.common.ElevatorBlockRules;
import openblocks.common.EntityEventHandler;
import openblocks.common.FluidXpUtils;
import openblocks.common.GameRuleManager;
import openblocks.common.GuideActionHandler;
import openblocks.common.LootHandler;
import openblocks.common.LuggageDropHandler;
import openblocks.common.MagnetWhitelists;
import openblocks.common.MapDataManager;
import openblocks.common.PedometerHandler;
import openblocks.common.PlayerDeathHandler;
import openblocks.common.PlayerInventoryStore;
import openblocks.common.RadioVillagerTrades;
import openblocks.common.ServerTickHandler;
import openblocks.common.block.BlockAutoAnvil;
import openblocks.common.block.BlockAutoEnchantmentTable;
import openblocks.common.block.BlockBearTrap;
import openblocks.common.block.BlockBigButton;
import openblocks.common.block.BlockBigButtonWood;
import openblocks.common.block.BlockBlockBreaker;
import openblocks.common.block.BlockBlockPlacer;
import openblocks.common.block.BlockBuilderGuide;
import openblocks.common.block.BlockCannon;
import openblocks.common.block.BlockCanvas;
import openblocks.common.block.BlockCanvasGlass;
import openblocks.common.block.BlockDonationStation;
import openblocks.common.block.BlockDrawingTable;
import openblocks.common.block.BlockElevator;
import openblocks.common.block.BlockElevatorRotating;
import openblocks.common.block.BlockFan;
import openblocks.common.block.BlockFlag;
import openblocks.common.block.BlockGoldenEgg;
import openblocks.common.block.BlockGrave;
import openblocks.common.block.BlockGuide;
import openblocks.common.block.BlockHeal;
import openblocks.common.block.BlockImaginary;
import openblocks.common.block.BlockItemDropper;
import openblocks.common.block.BlockLadder;
import openblocks.common.block.BlockPaintCan;
import openblocks.common.block.BlockPaintMixer;
import openblocks.common.block.BlockPath;
import openblocks.common.block.BlockProjector;
import openblocks.common.block.BlockRopeLadder;
import openblocks.common.block.BlockScaffolding;
import openblocks.common.block.BlockSky;
import openblocks.common.block.BlockSponge;
import openblocks.common.block.BlockSprinkler;
import openblocks.common.block.BlockTank;
import openblocks.common.block.BlockTarget;
import openblocks.common.block.BlockTrophy;
import openblocks.common.block.BlockVacuumHopper;
import openblocks.common.block.BlockVillageHighlighter;
import openblocks.common.block.BlockXPBottler;
import openblocks.common.block.BlockXPDrain;
import openblocks.common.block.BlockXPShower;
import openblocks.common.entity.EntityCartographer;
import openblocks.common.entity.EntityCartographer.MapJobs;
import openblocks.common.entity.EntityGlyph;
import openblocks.common.entity.EntityGoldenEye;
import openblocks.common.entity.EntityHangGlider;
import openblocks.common.entity.EntityItemProjectile;
import openblocks.common.entity.EntityLuggage;
import openblocks.common.entity.EntityMagnet;
import openblocks.common.entity.EntityMiniMe;
import openblocks.common.entity.EntityMountedBlock;
import openblocks.common.entity.EntityXPOrbNoFly;
import openblocks.common.item.ItemCartographer;
import openblocks.common.item.ItemCraneBackpack;
import openblocks.common.item.ItemCraneControl;
import openblocks.common.item.ItemCursor;
import openblocks.common.item.ItemDevNull;
import openblocks.common.item.ItemElevator;
import openblocks.common.item.ItemEmptyMap;
import openblocks.common.item.ItemEpicEraser;
import openblocks.common.item.ItemFlagBlock;
import openblocks.common.item.ItemGlyph;
import openblocks.common.item.ItemGoldenEye;
import openblocks.common.item.ItemGuide;
import openblocks.common.item.ItemHangGlider;
import openblocks.common.item.ItemHeightMap;
import openblocks.common.item.ItemImaginary;
import openblocks.common.item.ItemImaginationGlasses;
import openblocks.common.item.ItemImaginationGlasses.ItemCrayonGlasses;
import openblocks.common.item.ItemInfoBook;
import openblocks.common.item.ItemLuggage;
import openblocks.common.item.ItemOBGeneric;
import openblocks.common.item.ItemOBGenericUnstackable;
import openblocks.common.item.ItemPaintBrush;
import openblocks.common.item.ItemPaintCan;
import openblocks.common.item.ItemPedometer;
import openblocks.common.item.ItemSkyBlock;
import openblocks.common.item.ItemSleepingBag;
import openblocks.common.item.ItemSlimalyzer;
import openblocks.common.item.ItemSonicGlasses;
import openblocks.common.item.ItemSpongeOnAStick;
import openblocks.common.item.ItemSqueegee;
import openblocks.common.item.ItemStencil;
import openblocks.common.item.ItemTankBlock;
import openblocks.common.item.ItemTastyClay;
import openblocks.common.item.ItemTrophyBlock;
import openblocks.common.item.ItemWrench;
import openblocks.common.item.ItemXpBucket;
import openblocks.common.sync.SyncableBlockLayers;
import openblocks.common.tileentity.TileEntityAutoAnvil;
import openblocks.common.tileentity.TileEntityAutoEnchantmentTable;
import openblocks.common.tileentity.TileEntityBearTrap;
import openblocks.common.tileentity.TileEntityBigButton;
import openblocks.common.tileentity.TileEntityBigButtonWood;
import openblocks.common.tileentity.TileEntityBlockBreaker;
import openblocks.common.tileentity.TileEntityBlockPlacer;
import openblocks.common.tileentity.TileEntityBuilderGuide;
import openblocks.common.tileentity.TileEntityCannon;
import openblocks.common.tileentity.TileEntityCanvas;
import openblocks.common.tileentity.TileEntityCanvasGlass;
import openblocks.common.tileentity.TileEntityDonationStation;
import openblocks.common.tileentity.TileEntityDrawingTable;
import openblocks.common.tileentity.TileEntityElevatorRotating;
import openblocks.common.tileentity.TileEntityFan;
import openblocks.common.tileentity.TileEntityFlag;
import openblocks.common.tileentity.TileEntityGoldenEgg;
import openblocks.common.tileentity.TileEntityGrave;
import openblocks.common.tileentity.TileEntityGuide;
import openblocks.common.tileentity.TileEntityHealBlock;
import openblocks.common.tileentity.TileEntityImaginary;
import openblocks.common.tileentity.TileEntityItemDropper;
import openblocks.common.tileentity.TileEntityPaintCan;
import openblocks.common.tileentity.TileEntityPaintMixer;
import openblocks.common.tileentity.TileEntityProjector;
import openblocks.common.tileentity.TileEntitySprinkler;
import openblocks.common.tileentity.TileEntityTank;
import openblocks.common.tileentity.TileEntityTarget;
import openblocks.common.tileentity.TileEntityTrophy;
import openblocks.common.tileentity.TileEntityVacuumHopper;
import openblocks.common.tileentity.TileEntityVillageHighlighter;
import openblocks.common.tileentity.TileEntityXPBottler;
import openblocks.common.tileentity.TileEntityXPDrain;
import openblocks.common.tileentity.TileEntityXPShower;
import openblocks.enchantments.flimflams.BaneFlimFlam;
import openblocks.enchantments.flimflams.DummyCreepersFlimFlam;
import openblocks.enchantments.flimflams.EffectFlimFlam;
import openblocks.enchantments.flimflams.EncaseFlimFlam;
import openblocks.enchantments.flimflams.FlimFlamRegistry;
import openblocks.enchantments.flimflams.InventoryShuffleFlimFlam;
import openblocks.enchantments.flimflams.InvisibleMobsFlimFlam;
import openblocks.enchantments.flimflams.ItemDropFlimFlam;
import openblocks.enchantments.flimflams.LoreFlimFlam;
import openblocks.enchantments.flimflams.MountFlimFlam;
import openblocks.enchantments.flimflams.RenameFlimFlam;
import openblocks.enchantments.flimflams.SheepDyeFlimFlam;
import openblocks.enchantments.flimflams.SkyblockFlimFlam;
import openblocks.enchantments.flimflams.SnowballsFlimFlam;
import openblocks.enchantments.flimflams.SoundFlimFlam;
import openblocks.enchantments.flimflams.SquidFilmFlam;
import openblocks.enchantments.flimflams.TeleportFlimFlam;
import openblocks.enchantments.flimflams.UselessToolFlimFlam;
import openblocks.events.ElevatorActionEvent;
import openblocks.events.GuideActionEvent;
import openblocks.events.PlayerActionEvent;
import openblocks.rpc.IColorChanger;
import openblocks.rpc.IGuideAnimationTrigger;
import openblocks.rpc.IItemDropper;
import openblocks.rpc.ILevelChanger;
import openblocks.rpc.IRotatable;
import openblocks.rpc.IStencilCrafter;
import openblocks.rpc.ITriggerable;
import openblocks.rubbish.BrickManager;
import openblocks.rubbish.CommandFlimFlam;
import openblocks.rubbish.CommandLuck;
import openmods.Log;
import openmods.OpenMods;
import openmods.block.OpenBlock;
import openmods.config.BlockInstances;
import openmods.config.ItemInstances;
import openmods.config.game.FactoryRegistry;
import openmods.config.game.GameRegistryObjectsProvider;
import openmods.config.game.ModStartupHelper;
import openmods.config.game.RegisterBlock;
import openmods.config.game.RegisterItem;
import openmods.config.properties.ConfigProcessing;
import openmods.entity.EntityBlock;
import openmods.item.ItemGeneric;
import openmods.liquids.ContainerBucketFillHandler;
import openmods.liquids.SingleFluidBucketFillHandler;
import openmods.network.event.NetworkEventEntry;
import openmods.network.event.NetworkEventManager;
import openmods.network.rpc.MethodEntry;
import openmods.network.rpc.RpcCallDispatcher;
import openmods.sync.SyncableObjectType;
import openmods.sync.SyncableObjectTypeRegistry;
import openmods.utils.EnchantmentUtils;
@Mod(modid = OpenBlocks.MOD_ID, name = OpenBlocks.NAME, version = OpenBlocks.VERSION, guiFactory = OpenBlocks.GUI_FACTORY)
public class OpenBlocks {
public static final String MOD_ID = Tags.MOD_ID;
public static final String NAME = Tags.NAME;
public static final String VERSION = Tags.VERSION;
public static final String PROXY_SERVER = "openblocks.common.ServerProxy";
public static final String PROXY_CLIENT = "openblocks.client.ClientProxy";
public static final String GUI_FACTORY = "openblocks.client.ModGuiFactory";
private static final int ENTITY_HANGGLIDER_ID = 701;
private static final int ENTITY_LUGGAGE_ID = 702;
private static final int ENTITY_MAGNET_ID = 703;
private static final int ENTITY_BLOCK_ID = 704;
private static final int ENTITY_CARTOGRAPHER_ID = 705;
private static final int ENTITY_CANON_ITEM_ID = 706;
private static final int ENTITY_GOLDEN_EYE_ID = 707;
private static final int ENTITY_MAGNET_PLAYER_ID = 708;
private static final int ENTITY_XP_ID = 709;
private static final int ENTITY_MINIME_ID = 710;
private static final int ENTITY_GLYPH_ID = 711;
@Instance(MOD_ID)
public static OpenBlocks instance;
@SidedProxy(clientSide = OpenBlocks.PROXY_CLIENT, serverSide = OpenBlocks.PROXY_SERVER)
public static IOpenBlocksProxy proxy;
private final ApiSetup apiSetup = new ApiSetup();
public static class Blocks implements BlockInstances {
@RegisterBlock(type = BlockLadder.class, id = "ladder")
public static Block ladder;
@RegisterBlock(type = BlockGuide.class, id = "guide", tileEntity = TileEntityGuide.class, itemBlock = ItemGuide.class)
public static Block guide;
@RegisterBlock(type = BlockBuilderGuide.class, id = "builder_guide", tileEntity = TileEntityBuilderGuide.class, itemBlock = ItemGuide.class)
public static Block builderGuide;
@RegisterBlock(type = BlockElevator.class, id = "elevator", itemBlock = ItemElevator.class, registerDefaultItemModel = false)
public static Block elevator;
@RegisterBlock(type = BlockElevatorRotating.class, id = "elevator_rotating", tileEntity = TileEntityElevatorRotating.class, itemBlock = ItemElevator.class, registerDefaultItemModel = false)
public static Block elevatorRotating;
@RegisterBlock(type = BlockHeal.class, id = "heal", tileEntity = TileEntityHealBlock.class)
public static Block heal;
@RegisterBlock(type = BlockTarget.class, id = "target", tileEntity = TileEntityTarget.class)
public static Block target;
@RegisterBlock(type = BlockGrave.class, id = "grave", tileEntity = TileEntityGrave.class)
public static Block grave;
@RegisterBlock(type = BlockFlag.class, id = "flag", tileEntity = TileEntityFlag.class, itemBlock = ItemFlagBlock.class)
public static Block flag;
@RegisterBlock(type = BlockTank.class, id = "tank", tileEntity = TileEntityTank.class, itemBlock = ItemTankBlock.class)
public static Block tank;
@RegisterBlock(type = BlockTrophy.class, id = "trophy", tileEntity = TileEntityTrophy.class, itemBlock = ItemTrophyBlock.class)
public static Block trophy;
@RegisterBlock(type = BlockBearTrap.class, id = "beartrap", tileEntity = TileEntityBearTrap.class)
public static Block bearTrap;
@RegisterBlock(type = BlockSprinkler.class, id = "sprinkler", tileEntity = TileEntitySprinkler.class)
public static Block sprinkler;
@RegisterBlock(type = BlockCannon.class, id = "cannon", tileEntity = TileEntityCannon.class)
public static OpenBlock cannon;
@RegisterBlock(type = BlockVacuumHopper.class, id = "vacuum_hopper", tileEntity = TileEntityVacuumHopper.class, legacyIds = "vacuumhopper")
public static Block vacuumHopper;
@RegisterBlock(type = BlockSponge.class, id = "sponge")
public static Block sponge;
@RegisterBlock(type = BlockBigButton.class, id = "big_button", tileEntity = TileEntityBigButton.class, legacyIds = "bigbutton")
public static Block bigButton;
@RegisterBlock(type = BlockBigButtonWood.class, id = "big_button_wood", tileEntity = TileEntityBigButtonWood.class)
public static Block bigButtonWood;
@RegisterBlock(id = "imaginary", tileEntity = TileEntityImaginary.class, itemBlock = ItemImaginary.class, customItemModels = ItemImaginary.ModelProvider.class, registerDefaultItemModel = false)
public static BlockImaginary imaginary;
@RegisterBlock(type = BlockFan.class, id = "fan", tileEntity = TileEntityFan.class)
public static Block fan;
@RegisterBlock(type = BlockXPBottler.class, id = "xp_bottler", tileEntity = TileEntityXPBottler.class, legacyIds = "xpbottler")
public static Block xpBottler;
@RegisterBlock(type = BlockVillageHighlighter.class, id = "village_highlighter", tileEntity = TileEntityVillageHighlighter.class)
public static Block villageHighlighter;
@RegisterBlock(type = BlockPath.class, id = "path")
public static Block path;
@RegisterBlock(type = BlockAutoAnvil.class, id = "auto_anvil", tileEntity = TileEntityAutoAnvil.class, legacyIds = "autoanvil")
public static Block autoAnvil;
@RegisterBlock(type = BlockAutoEnchantmentTable.class, id = "auto_enchantment_table", tileEntity = TileEntityAutoEnchantmentTable.class, legacyIds = "autoenchantmenttable")
public static Block autoEnchantmentTable;
@RegisterBlock(type = BlockXPDrain.class, id = "xp_drain", tileEntity = TileEntityXPDrain.class, legacyIds = "xpdrain")
public static Block xpDrain;
@RegisterBlock(type = BlockBlockBreaker.class, id = "block_breaker", tileEntity = TileEntityBlockBreaker.class, legacyIds = "blockbreaker")
public static Block blockBreaker;
@RegisterBlock(type = BlockBlockPlacer.class, id = "block_placer", tileEntity = TileEntityBlockPlacer.class, legacyIds = "blockPlacer")
public static Block blockPlacer;
@RegisterBlock(type = BlockItemDropper.class, id = "item_dropper", tileEntity = TileEntityItemDropper.class, legacyIds = "itemDropper")
public static Block itemDropper;
@RegisterBlock(type = BlockRopeLadder.class, id = "rope_ladder", legacyIds = "ropeladder")
public static Block ropeLadder;
@RegisterBlock(type = BlockDonationStation.class, id = "donation_station", tileEntity = TileEntityDonationStation.class, legacyIds = "donationStation")
public static Block donationStation;
@RegisterBlock(type = BlockPaintMixer.class, id = "paint_mixer", tileEntity = TileEntityPaintMixer.class, legacyIds = "paintmixer")
public static Block paintMixer;
@RegisterBlock(type = BlockCanvas.class, id = "canvas", tileEntity = TileEntityCanvas.class)
public static Block canvas;
@RegisterBlock(type = BlockPaintCan.class, id = "paint_can", tileEntity = TileEntityPaintCan.class, itemBlock = ItemPaintCan.class, legacyIds = "paintcan")
public static Block paintCan;
@RegisterBlock(type = BlockCanvasGlass.class, id = "canvas_glass", tileEntity = TileEntityCanvasGlass.class, legacyIds = "canvasglass")
public static Block canvasGlass;
@RegisterBlock(type = BlockProjector.class, id = "projector", tileEntity = TileEntityProjector.class)
public static Block projector;
@RegisterBlock(type = BlockDrawingTable.class, id = "drawing_table", tileEntity = TileEntityDrawingTable.class, legacyIds = "drawingtable")
public static Block drawingTable;
@RegisterBlock(type = BlockSky.class, id = "sky", itemBlock = ItemSkyBlock.class, unlocalizedName = "sky.normal")
public static Block sky;
@RegisterBlock(type = BlockXPShower.class, id = "xp_shower", tileEntity = TileEntityXPShower.class, legacyIds = "xpshower")
public static Block xpShower;
@RegisterBlock(type = BlockGoldenEgg.class, id = "golden_egg", tileEntity = TileEntityGoldenEgg.class, legacyIds = "goldenegg")
public static Block goldenEgg;
@RegisterBlock(type = BlockScaffolding.class, id = "scaffolding", itemBlock = BlockScaffolding.Item.class)
public static Block scaffolding;
}
public static class Items implements ItemInstances {
@RegisterItem(type = ItemHangGlider.class, id = "hang_glider", legacyIds = "hangglider")
public static Item hangGlider;
@RegisterItem(type = ItemOBGeneric.class, id = "generic", registerDefaultModel = false)
public static ItemGeneric generic;
@RegisterItem(type = ItemLuggage.class, id = "luggage")
public static Item luggage;
@RegisterItem(type = ItemSonicGlasses.class, id = "sonic_glasses", legacyIds = "sonicglasses")
public static Item sonicGlasses;
@RegisterItem(type = ItemImaginationGlasses.class, id = "pencil_glasses", unlocalizedName = "glasses.pencil", legacyIds = "pencilGlasses")
public static Item pencilGlasses;
@RegisterItem(type = ItemCrayonGlasses.class, id = "crayon_glasses", unlocalizedName = "glasses.crayon", legacyIds = "crayonGlasses")
public static Item crayonGlasses;
@RegisterItem(type = ItemImaginationGlasses.class, id = "technicolor_glasses", unlocalizedName = "glasses.technicolor", legacyIds = "technicolorGlasses")
public static Item technicolorGlasses;
@RegisterItem(type = ItemImaginationGlasses.class, id = "serious_glasses", unlocalizedName = "glasses.admin", legacyIds = "seriousGlasses")
public static Item seriousGlasses;
@RegisterItem(type = ItemCraneControl.class, id = "crane_control", legacyIds = "craneControl")
public static Item craneControl;
@RegisterItem(type = ItemCraneBackpack.class, id = "crane_backpack", legacyIds = "craneBackpack")
public static Item craneBackpack;
@RegisterItem(type = ItemSlimalyzer.class, id = "slimalyzer")
public static Item slimalyzer;
@RegisterItem(type = ItemXpBucket.class, id = "xp_bucket", legacyIds = "filledbucket")
public static Item xpBucket;
@RegisterItem(type = ItemSleepingBag.class, id = "sleeping_bag", legacyIds = "sleepingBag")
public static Item sleepingBag;
@RegisterItem(type = ItemPaintBrush.class, id = "paintbrush", legacyIds = "paintBrush")
public static Item paintBrush;
@RegisterItem(type = ItemStencil.class, id = "stencil", registerDefaultModel = false)
public static Item stencil;
@RegisterItem(type = ItemSqueegee.class, id = "squeegee")
public static Item squeegee;
@RegisterItem(type = ItemHeightMap.class, id = "height_map", legacyIds = "heightMap")
public static Item heightMap;
@RegisterItem(type = ItemEmptyMap.class, id = "empty_map", legacyIds = "emptyMap")
public static Item emptyMap;
@RegisterItem(type = ItemCartographer.class, id = "cartographer")
public static Item cartographer;
@RegisterItem(type = ItemTastyClay.class, id = "tasty_clay", legacyIds = "tastyClay")
public static Item tastyClay;
@RegisterItem(type = ItemGoldenEye.class, id = "golden_eye", legacyIds = "goldenEye")
public static Item goldenEye;
@RegisterItem(type = ItemOBGenericUnstackable.class, id = "generic_unstackable", registerDefaultModel = false, legacyIds = "genericUnstackable")
public static ItemGeneric genericUnstackable;
@RegisterItem(type = ItemCursor.class, id = "cursor")
public static Item cursor;
@RegisterItem(type = ItemInfoBook.class, id = "info_book", legacyIds = "infoBook")
public static Item infoBook;
@RegisterItem(type = ItemDevNull.class, id = "dev_null", legacyIds = "devnull")
public static Item devNull;
@RegisterItem(type = ItemSpongeOnAStick.class, id = "sponge_on_a_stick", legacyIds = "spongeonastick")
public static Item spongeonastick;
@RegisterItem(type = ItemPedometer.class, id = "pedometer")
public static Item pedometer;
@RegisterItem(type = ItemEpicEraser.class, id = "epic_eraser", legacyIds = "epicEraser")
public static Item epicEraser;
@RegisterItem(type = ItemWrench.class, id = "wrench")
public static Item wrench;
@RegisterItem(type = ItemGlyph.class, id = "glyph")
public static Item glyph;
}
public static ResourceLocation location(String path) {
return new ResourceLocation("openblocks", path);
}
public static class Fluids {
/**
* Instance of fluid that is added to fluid registry.
* It may not be used as default fluid, so don't compare directly with other fluids.
* FluidStacks created with this fluid should always be valid.
*/
public static final Fluid xpJuice = new Fluid("xpjuice", location("blocks/xp_juice_still"), location("blocks/xp_juice_flowing"))
.setLuminosity(10)
.setDensity(800)
.setViscosity(1500)
.setUnlocalizedName("openblocks.xp_juice")
.setEmptySound(SoundEvents.ENTITY_PLAYER_LEVELUP)
.setFillSound(SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP);
}
@ObjectHolder(MOD_ID)
@EventBusSubscriber
public static class Sounds {
// TODO subtitles where sensible
// TODO remove categories from sounds.json
@ObjectHolder("elevator.activate")
public static final SoundEvent BLOCK_ELEVATOR_ACTIVATE = null;
@ObjectHolder("grave.rob")
public static final SoundEvent BLOCK_GRAVE_ROB = null;
@ObjectHolder("beartrap.open")
public static final SoundEvent BLOCK_BEARTRAP_OPEN = null;
@ObjectHolder("beartrap.close")
public static final SoundEvent BLOCK_BEARTRAP_CLOSE = null;
@ObjectHolder("cannon.activate")
public static final SoundEvent BLOCK_CANNON_ACTIVATE = null;
@ObjectHolder("target.open")
public static final SoundEvent BLOCK_TARGET_OPEN = null;
@ObjectHolder("target.close")
public static final SoundEvent BLOCK_TARGET_CLOSE = null;
@ObjectHolder("bottler.signal")
public static final SoundEvent BLOCK_XPBOTTLER_DONE = null;
@ObjectHolder("crayon.place")
public static final SoundEvent ITEM_CRAYON_PLACE = null;
@ObjectHolder("luggage.walk")
public static final SoundEvent ENTITY_LUGGAGE_WALK = null;
@ObjectHolder("luggage.eat.food")
public static final SoundEvent ENTITY_LUGGAGE_EAT_FOOD = null;
@ObjectHolder("luggage.eat.item")
public static final SoundEvent ENTITY_LUGGAGE_EAT_ITEM = null;
@ObjectHolder("minecraft:entity.painting.place")
public static final SoundEvent ENTITY_GLYPH_PLACE = null;
@ObjectHolder("minecraft:entity.painting.break")
public static final SoundEvent ENTITY_GLYPH_BREAK = null;
@ObjectHolder("pedometer.use")
public static final SoundEvent ITEM_PEDOMETER_USE = null;
@ObjectHolder("slimalyzer.signal")
public static final SoundEvent ITEM_SLIMALYZER_PING = null;
@ObjectHolder("squeegee.use")
public static final SoundEvent ITEM_SQUEEGEE_ACTION = null;
@ObjectHolder("best.feature.ever.fart")
public static final SoundEvent PLAYER_WHOOPS = null;
@ObjectHolder("annoying.mosquito")
public static final SoundEvent MISC_MOSQUITO = null;
@ObjectHolder("annoying.alarmclock")
public static final SoundEvent MISC_ALARM_CLOCK = null;
@ObjectHolder("annoying.vibrate")
public static final SoundEvent MISC_VIBRATE = null;
@SubscribeEvent
public static void registerSounds(RegistryEvent.Register<SoundEvent> evt) {
final IForgeRegistry<SoundEvent> registry = evt.getRegistry();
registerSound(registry, "elevator.activate");
registerSound(registry, "grave.rob");
registerSound(registry, "crayon.place");
registerSound(registry, "luggage.walk");
registerSound(registry, "luggage.eat.food");
registerSound(registry, "luggage.eat.item");
registerSound(registry, "pedometer.use");
registerSound(registry, "slimalyzer.signal");
registerSound(registry, "squeegee.use");
registerSound(registry, "best.feature.ever.fart");
registerSound(registry, "annoying.mosquito");
registerSound(registry, "annoying.alarmclock");
registerSound(registry, "annoying.vibrate");
registerSound(registry, "beartrap.open");
registerSound(registry, "beartrap.close");
registerSound(registry, "cannon.activate");
registerSound(registry, "target.open");
registerSound(registry, "target.close");
registerSound(registry, "bottler.signal");
}
private static void registerSound(IForgeRegistry<SoundEvent> registry, String id) {
final ResourceLocation resourceLocation = location(id);
registry.register(new SoundEvent(resourceLocation).setRegistryName(resourceLocation));
}
}
@ObjectHolder(MOD_ID)
public static class Enchantments {
@ObjectHolder("explosive")
public static final Enchantment explosive = null;
@ObjectHolder("last_stand")
public static final Enchantment lastStand = null;
@ObjectHolder("flim_flam")
public static final Enchantment flimFlam = null;
}
private static CreativeTabs createTabOpenBlocks() {
return new CreativeTabs("tabOpenBlocks") {
@Override
public ItemStack createIcon() {
if (OpenBlocks.Blocks.flag != null) {
return new ItemStack(OpenBlocks.Blocks.flag, 1, BlockFlag.DEFAULT_COLOR.vanillaBlockId);
} else {
return new ItemStack(net.minecraft.init.Blocks.SPONGE);
}
}
@Override
@SideOnly(Side.CLIENT)
public void displayAllRelevantItems(NonNullList<ItemStack> result) {
super.displayAllRelevantItems(result);
if (Enchantments.explosive != null) EnchantmentUtils.addAllBooks(Enchantments.explosive, result);
if (Enchantments.lastStand != null) EnchantmentUtils.addAllBooks(Enchantments.lastStand, result);
if (Enchantments.flimFlam != null) EnchantmentUtils.addAllBooks(Enchantments.flimFlam, result);
}
};
}
public static final StatBase brickStat = new StatBasic("openblocks.dropped",
new TextComponentTranslation("stat.openblocks.bricksDropped"),
StatBase.simpleStatType).registerStat();
private final ModStartupHelper startupHelper = new ModStartupHelper("openblocks") {
@Override
protected void populateConfig(Configuration config) {
ConfigProcessing.processAnnotations(MOD_ID, config, Config.class);
}
@Override
protected void setupConfigPre(GameRegistryObjectsProvider gameConfig) {
gameConfig.setCreativeTab(OpenBlocks::createTabOpenBlocks);
gameConfig.addModIdToRemap("OpenBlocks");
}
@Override
protected void setupItemFactory(FactoryRegistry<Item> itemFactory) {
itemFactory.registerFactory("pencil_glasses", () -> new ItemImaginationGlasses(ItemImaginationGlasses.Type.PENCIL));
itemFactory.registerFactory("technicolor_glasses", () -> new ItemImaginationGlasses(ItemImaginationGlasses.Type.TECHNICOLOR));
itemFactory.registerFactory("serious_glasses", () -> new ItemImaginationGlasses(ItemImaginationGlasses.Type.BASTARD));
}
};
@EventHandler
public void construct(FMLConstructionEvent evt) {
apiSetup.injectProvider();
}
@EventBusSubscriber
public static class RegistryEntries {
@SubscribeEvent
public static void registerSyncTypes(RegistryEvent.Register<SyncableObjectType> type) {
SyncableObjectTypeRegistry.startRegistration(type.getRegistry())
.register(MapJobs.class)
.register(SyncableBlockLayers.class);
}
@SubscribeEvent
public static void registerMethodTypes(RegistryEvent.Register<MethodEntry> evt) {
RpcCallDispatcher.startMethodRegistration(evt.getRegistry())
.registerInterface(IRotatable.class)
.registerInterface(IStencilCrafter.class)
.registerInterface(IColorChanger.class)
.registerInterface(ILevelChanger.class)
.registerInterface(ITriggerable.class)
.registerInterface(IGuideAnimationTrigger.class)
.registerInterface(IItemDropper.class);
}
@SubscribeEvent
public static void registerNetworkEvents(RegistryEvent.Register<NetworkEventEntry> evt) {
NetworkEventManager.startRegistration(evt.getRegistry())
.register(MapDataManager.MapDataRequestEvent.class)
.register(MapDataManager.MapDataResponseEvent.class)
.register(MapDataManager.MapUpdatesEvent.class)
.register(ElevatorActionEvent.class)
.register(PlayerActionEvent.class)
.register(GuideActionEvent.class)
.register(EntityMiniMe.OwnerChangeEvent.class);
}
}
private static final String decorateEntityName(String name) {
return "openblocks." + name;
}
@EventHandler
public void preInit(FMLPreInitializationEvent evt) {
// needed first, to properly initialize delegates
FluidRegistry.registerFluid(Fluids.xpJuice);
if (Config.registerUniversalXpBucket) {
FluidRegistry.addBucketForFluid(Fluids.xpJuice);
}
Criterions.init();
startupHelper.registerBlocksHolder(OpenBlocks.Blocks.class);
startupHelper.registerItemsHolder(OpenBlocks.Items.class);
startupHelper.preInit(evt.getSuggestedConfigurationFile());
Config.register();
apiSetup.setupApis();
apiSetup.installHolderAccess(evt.getAsmData());
NetworkRegistry.INSTANCE.registerGuiHandler(instance, OpenMods.proxy.wrapHandler(new OpenBlocksGuiHandler()));
MinecraftForge.EVENT_BUS.register(new PlayerDeathHandler());
if (OpenBlocks.Items.cursor != null) {
// TODO maybe figure way to validate GUIs over distance?
// was: GuiOpenHandler: handler for PlayerOpenContainerEvent
}
EntityRegistry.registerModEntity(location("luggage"), EntityLuggage.class, decorateEntityName("luggage"), ENTITY_LUGGAGE_ID, OpenBlocks.instance, 64, 1, true);
EntityRegistry.registerModEntity(location("xp_orb_no_fly"), EntityXPOrbNoFly.class, decorateEntityName("xp_orb_no_fly"), ENTITY_XP_ID, OpenBlocks.instance, 64, 1, true);
EntityRegistry.registerModEntity(location("hang_glider"), EntityHangGlider.class, decorateEntityName("hang_glider"), ENTITY_HANGGLIDER_ID, OpenBlocks.instance, 64, 1, true);
EntityRegistry.registerModEntity(location("magnet"), EntityMagnet.class, decorateEntityName("magnet"), ENTITY_MAGNET_ID, OpenBlocks.instance, 64, 1, true);
EntityRegistry.registerModEntity(location("mounted_block"), EntityMountedBlock.class, decorateEntityName("mounted_block"), ENTITY_BLOCK_ID, OpenBlocks.instance, 64, 1, true);
EntityRegistry.registerModEntity(location("player_magnet"), EntityMagnet.PlayerBound.class, decorateEntityName("player_magnet"), ENTITY_MAGNET_PLAYER_ID, OpenBlocks.instance, 64, 1, true);
EntityRegistry.registerModEntity(location("cartographer"), EntityCartographer.class, decorateEntityName("cartographer"), ENTITY_CARTOGRAPHER_ID, OpenBlocks.instance, 64, 8, true);
EntityRegistry.registerModEntity(location("item_projectile"), EntityItemProjectile.class, decorateEntityName("item_projectile"), ENTITY_CANON_ITEM_ID, OpenBlocks.instance, 64, 1, true);
EntityRegistry.registerModEntity(location("golden_eye"), EntityGoldenEye.class, decorateEntityName("golden_eye"), ENTITY_GOLDEN_EYE_ID, OpenBlocks.instance, 64, 8, true);
EntityRegistry.registerModEntity(location("mini_me"), EntityMiniMe.class, decorateEntityName("mini_me"), ENTITY_MINIME_ID, OpenBlocks.instance, 64, 1, true);
EntityRegistry.registerModEntity(location("glyph"), EntityGlyph.class, decorateEntityName("glyph"), ENTITY_GLYPH_ID, OpenBlocks.instance, 160, Integer.MAX_VALUE, false);
final DataFixer dataFixer = FMLCommonHandler.instance().getDataFixer();
EntityLiving.registerFixesMob(dataFixer, EntityMiniMe.class);
EntityLuggage.registerFixes(dataFixer);
ItemLuggage.registerFixes(dataFixer);
EntityBlock.registerFixes(dataFixer, EntityMountedBlock.class);
EntityCartographer.registerFixes(dataFixer);
ItemCartographer.registerFixes(dataFixer);
EntityItemProjectile.registerFixes(dataFixer);
EntityGoldenEye.registerFixes(dataFixer);
ItemDevNull.registerFixes(dataFixer);
MagnetWhitelists.instance.initTesters();
MinecraftForge.EVENT_BUS.register(MapDataManager.instance);
// Integration.addModule(new ModuleAdapters());
// Integration.addModule(new ModuleTurtles());
if (!Config.soSerious) {
BrickManager.registerCapability();
MinecraftForge.EVENT_BUS.register(new BrickManager());
}
if (OpenBlocks.Blocks.elevator != null || OpenBlocks.Blocks.elevatorRotating != null) {
MinecraftForge.EVENT_BUS.register(ElevatorBlockRules.instance);
MinecraftForge.EVENT_BUS.register(new ElevatorActionHandler());
}
if (Config.radioVillagerEnabled) {
RadioVillagerTrades.registerUselessVillager();
}
if (Items.luggage != null) {
MinecraftForge.EVENT_BUS.register(new LuggageDropHandler());
}
if (Blocks.guide != null || Blocks.builderGuide != null) {
MinecraftForge.EVENT_BUS.register(new GuideActionHandler());
}
if (Items.xpBucket != null) {
if (Config.xpBucketDirectFill)
MinecraftForge.EVENT_BUS.register(new SingleFluidBucketFillHandler(new ItemStack(Items.xpBucket)));
}
if (Items.pedometer != null) {
PedometerHandler.registerCapability();
}
if (Items.sleepingBag != null)
MinecraftForge.EVENT_BUS.register(new ItemSleepingBag.IsSleepingHandler());
MinecraftForge.EVENT_BUS.register(CanvasReplaceBlacklist.instance);
MinecraftForge.EVENT_BUS.register(PlayerInventoryStore.instance);
MinecraftForge.EVENT_BUS.register(new EntityEventHandler());
MinecraftForge.EVENT_BUS.register(new GameRuleManager());
LootHandler.register();
proxy.preInit();
}
@EventHandler
public void init(FMLInitializationEvent evt) {
FluidXpUtils.initializeFromConfig();
MinecraftForge.EVENT_BUS.register(new ServerTickHandler());
proxy.init();
proxy.registerRenderInformation();
registerOreDictionary();
startupHelper.init();
if (Blocks.imaginary != null) {
// delayed to init, since sounds are not loaded in pre-init
Blocks.imaginary.setSoundType();
}
}
@EventHandler
public void postInit(FMLPostInitializationEvent evt) {
proxy.postInit();
if (Enchantments.flimFlam != null) {
FlimFlamRegistry.instance.registerFlimFlam("inventory-shuffle", -50, 100, new InventoryShuffleFlimFlam()).markSafe();
FlimFlamRegistry.instance.registerFlimFlam("useless-tool", -125, 50, new UselessToolFlimFlam()).markSafe();
FlimFlamRegistry.instance.registerFlimFlam("bane", -125, 100, new BaneFlimFlam()).markSafe();
FlimFlamRegistry.instance.registerFlimFlam("epic-lore", -10, 100, new LoreFlimFlam()).markSafe();
FlimFlamRegistry.instance.registerFlimFlam("living-rename", -10, 100, new RenameFlimFlam()).markSafe();
FlimFlamRegistry.instance.registerFlimFlam("squid", -75, 50, new SquidFilmFlam()).markSafe();
FlimFlamRegistry.instance.registerFlimFlam("sheep-dye", -5, 50, new SheepDyeFlimFlam()).markSafe();
FlimFlamRegistry.instance.registerFlimFlam("invisible-mobs", -25, 10, new InvisibleMobsFlimFlam()).markSafe();
FlimFlamRegistry.instance.registerFlimFlam("sound", -5, 150, new SoundFlimFlam()).markSilent().markSafe();
FlimFlamRegistry.instance.registerFlimFlam("snowballs", -50, 50, new SnowballsFlimFlam());
FlimFlamRegistry.instance.registerFlimFlam("teleport", -100, 30, new TeleportFlimFlam());
FlimFlamRegistry.instance.registerFlimFlam("mount", -150, 25, new MountFlimFlam());
FlimFlamRegistry.instance.registerFlimFlam("encase", -50, 50, new EncaseFlimFlam()).setRange(Integer.MIN_VALUE, -300);
FlimFlamRegistry.instance.registerFlimFlam("creepers", -60, 50, new DummyCreepersFlimFlam());
FlimFlamRegistry.instance.registerFlimFlam("disarm", -50, 50, new ItemDropFlimFlam());
FlimFlamRegistry.instance.registerFlimFlam("effect", -75, 75, new EffectFlimFlam());
FlimFlamRegistry.instance.registerFlimFlam("skyblock", -100, 150, new SkyblockFlimFlam()).setRange(Integer.MIN_VALUE, -400);
FlimFlamRegistry.BLACKLIST.init();
}
if (Blocks.tank != null) {
if (Config.allowBucketDrain) {
final ContainerBucketFillHandler tankFillHandler = new TileEntityTank.BucketFillHandler();
for (ItemStack bucket : filledBuckets)
tankFillHandler.addFilledBucket(bucket);
filledBuckets.clear();
for (String bucketId : Config.bucketItems) {
final ResourceLocation bucketLocation = new ResourceLocation(bucketId);
final Item item = Item.REGISTRY.getObject(bucketLocation);
if (item == null) {
Log.warn("Failed to find bucket item %s", item);
} else {
tankFillHandler.addFilledBucket(new ItemStack(item));
}
}
MinecraftForge.EVENT_BUS.register(tankFillHandler);
}
}
}
private final List<ItemStack> filledBuckets = Lists.newArrayList();
@EventHandler
public void processMessage(FMLInterModComms.IMCEvent event) {
for (FMLInterModComms.IMCMessage m : event.getMessages()) {
if (m.isStringMessage() && "donateUrl".equalsIgnoreCase(m.key)) {
DonationUrlManager.instance().addUrl(m.getSender(), m.getStringValue());
}
if (m.isItemStackMessage() && "bucket".equalsIgnoreCase(m.key)) {
filledBuckets.add(m.getItemStackValue());
}
}
}
@EventHandler
public void severStart(FMLServerStartingEvent evt) {
evt.registerServerCommand(new CommandFlimFlam());
evt.registerServerCommand(new CommandLuck());
evt.registerServerCommand(new CommandInventory());
}
public static String getModId() {
return OpenBlocks.class.getAnnotation(Mod.class).modid();
}
private static void registerOreDictionary() {
OreDictionary.registerOre("craftingTableWood", new ItemStack(net.minecraft.init.Blocks.CRAFTING_TABLE));
OreDictionary.registerOre("chestWood", new ItemStack(net.minecraft.init.Blocks.CHEST));
}
}