-
Notifications
You must be signed in to change notification settings - Fork 10
/
IronShulkerBoxes.java
89 lines (76 loc) · 4.61 KB
/
IronShulkerBoxes.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
package com.progwml6.ironshulkerbox;
import com.progwml6.ironshulkerbox.client.screen.IronShulkerBoxScreen;
import com.progwml6.ironshulkerbox.client.tileentity.IronShulkerBoxTileEntityRenderer;
import com.progwml6.ironshulkerbox.common.block.ShulkerBoxesBlocks;
import com.progwml6.ironshulkerbox.common.block.tileentity.IronShulkerBoxesTileEntityTypes;
import com.progwml6.ironshulkerbox.common.data.IronShulkerBoxesRecipeProvider;
import com.progwml6.ironshulkerbox.common.inventory.IronShulkerBoxesContainerTypes;
import com.progwml6.ironshulkerbox.common.items.IronShulkerBoxesItems;
import com.progwml6.ironshulkerbox.common.network.PacketHandler;
import net.minecraft.client.gui.ScreenManager;
import net.minecraft.data.DataGenerator;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.event.lifecycle.GatherDataEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
@Mod(IronShulkerBoxes.MOD_ID)
public class IronShulkerBoxes {
public static final String MOD_ID = "ironshulkerbox";
public static final ItemGroup IRONSHULKERBOX_ITEM_GROUP = (new ItemGroup("ironshulkerbox") {
@Override
@OnlyIn(Dist.CLIENT)
public ItemStack createIcon() {
return new ItemStack(ShulkerBoxesBlocks.BLACK_IRON_SHULKER_BOX.get());
}
});
public IronShulkerBoxes() {
IEventBus modBus = FMLJavaModLoadingContext.get().getModEventBus();
// General mod setup
modBus.addListener(this::setup);
modBus.addListener(this::gatherData);
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> {
// Client setup
modBus.addListener(this::setupClient);
});
// Registry objects
ShulkerBoxesBlocks.BLOCKS.register(modBus);
IronShulkerBoxesItems.ITEMS.register(modBus);
IronShulkerBoxesTileEntityTypes.TILE_ENTITIES.register(modBus);
IronShulkerBoxesContainerTypes.CONTAINERS.register(modBus);
}
@OnlyIn(Dist.CLIENT)
private void setupClient(final FMLClientSetupEvent event) {
ScreenManager.registerFactory(IronShulkerBoxesContainerTypes.IRON_SHULKER_BOX.get(), IronShulkerBoxScreen::new);
ScreenManager.registerFactory(IronShulkerBoxesContainerTypes.GOLD_SHULKER_BOX.get(), IronShulkerBoxScreen::new);
ScreenManager.registerFactory(IronShulkerBoxesContainerTypes.DIAMOND_SHULKER_BOX.get(), IronShulkerBoxScreen::new);
ScreenManager.registerFactory(IronShulkerBoxesContainerTypes.CRYSTAL_SHULKER_BOX.get(), IronShulkerBoxScreen::new);
ScreenManager.registerFactory(IronShulkerBoxesContainerTypes.COPPER_SHULKER_BOX.get(), IronShulkerBoxScreen::new);
ScreenManager.registerFactory(IronShulkerBoxesContainerTypes.SILVER_SHULKER_BOX.get(), IronShulkerBoxScreen::new);
ScreenManager.registerFactory(IronShulkerBoxesContainerTypes.OBSIDIAN_SHULKER_BOX.get(), IronShulkerBoxScreen::new);
ClientRegistry.bindTileEntityRenderer(IronShulkerBoxesTileEntityTypes.IRON_SHULKER_BOX.get(), IronShulkerBoxTileEntityRenderer::new);
ClientRegistry.bindTileEntityRenderer(IronShulkerBoxesTileEntityTypes.GOLD_SHULKER_BOX.get(), IronShulkerBoxTileEntityRenderer::new);
ClientRegistry.bindTileEntityRenderer(IronShulkerBoxesTileEntityTypes.GOLD_SHULKER_BOX.get(), IronShulkerBoxTileEntityRenderer::new);
ClientRegistry.bindTileEntityRenderer(IronShulkerBoxesTileEntityTypes.DIAMOND_SHULKER_BOX.get(), IronShulkerBoxTileEntityRenderer::new);
ClientRegistry.bindTileEntityRenderer(IronShulkerBoxesTileEntityTypes.COPPER_SHULKER_BOX.get(), IronShulkerBoxTileEntityRenderer::new);
ClientRegistry.bindTileEntityRenderer(IronShulkerBoxesTileEntityTypes.SILVER_SHULKER_BOX.get(), IronShulkerBoxTileEntityRenderer::new);
ClientRegistry.bindTileEntityRenderer(IronShulkerBoxesTileEntityTypes.CRYSTAL_SHULKER_BOX.get(), IronShulkerBoxTileEntityRenderer::new);
ClientRegistry.bindTileEntityRenderer(IronShulkerBoxesTileEntityTypes.OBSIDIAN_SHULKER_BOX.get(), IronShulkerBoxTileEntityRenderer::new);
}
private void setup(final FMLCommonSetupEvent event) {
PacketHandler.register();
}
private void gatherData(GatherDataEvent event) {
DataGenerator datagenerator = event.getGenerator();
if (event.includeServer()) {
datagenerator.addProvider(new IronShulkerBoxesRecipeProvider(datagenerator));
}
}
}