-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathCommonProxy.java
More file actions
218 lines (183 loc) · 9.49 KB
/
CommonProxy.java
File metadata and controls
218 lines (183 loc) · 9.49 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
package gregtechfoodoption;
import crazypants.enderio.api.farm.IFarmerJoe;
import crazypants.enderio.base.farming.farmers.CustomSeedFarmer;
import gregtech.api.block.VariantItemBlock;
import gregtech.api.recipes.RecipeMaps;
import gregtech.api.unification.OreDictUnifier;
import gregtech.api.unification.material.Materials;
import gregtech.api.unification.ore.OrePrefix;
import gregtechfoodoption.block.GTFOBerryBush;
import gregtechfoodoption.block.GTFOCrop;
import gregtechfoodoption.block.GTFOMetaBlocks;
import gregtechfoodoption.block.GTFORootCrop;
import gregtechfoodoption.integration.enderio.GTFOBerryFarmer;
import gregtechfoodoption.integration.enderio.GTFORootCropFarmer;
import gregtechfoodoption.integration.nutrition.GTFONutritionCompatibility;
import gregtechfoodoption.item.GTFOMetaItem;
import gregtechfoodoption.item.GTFOMetaItems;
import gregtechfoodoption.item.GTFOSpecialVariantItemBlock;
import gregtechfoodoption.machines.multiblock.MetaTileEntityGreenhouse;
import gregtechfoodoption.potion.*;
import gregtechfoodoption.recipe.GTFOOreDictRegistration;
import gregtechfoodoption.recipe.GTFORecipeAddition;
import gregtechfoodoption.recipe.GTFORecipeHandler;
import gregtechfoodoption.recipe.GTFORecipeRemoval;
import gregtechfoodoption.utils.GTFOLog;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.potion.PotionEffect;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.config.Config;
import net.minecraftforge.common.config.ConfigManager;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.client.event.ConfigChangedEvent;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Optional;
import net.minecraftforge.fml.common.event.FMLInterModComms;
import net.minecraftforge.fml.common.event.FMLLoadCompleteEvent;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.registries.IForgeRegistry;
import javax.annotation.Nonnull;
import java.util.Objects;
import java.util.function.Function;
import static gregtech.api.unification.ore.OrePrefix.dust;
import static gregtechfoodoption.GTFOMaterialHandler.RecrystalizedLurdmanine;
import static gregtechfoodoption.block.GTFOCrop.CROP_BLOCKS;
@Mod.EventBusSubscriber(modid = GregTechFoodOption.MODID)
public class CommonProxy {
public void preLoad() {
GTFOPotions.initPotionInstances();
GTFOMetaItems.init();
GTFORecipeHandler.register();
RecipeMaps.BREWING_RECIPES.setMaxOutputs(1);
RecipeMaps.EXTRACTOR_RECIPES.setMaxInputs(2);
RecipeMaps.FERMENTING_RECIPES.setMaxInputs(1);
RecipeMaps.FERMENTING_RECIPES.setMaxOutputs(1);
RecipeMaps.COMPRESSOR_RECIPES.setMaxFluidInputs(1);
RecipeMaps.COMPRESSOR_RECIPES.setMaxFluidOutputs(1);
}
public void onLoad() {
}
public void onPostLoad() {
MinecraftForge.addGrassSeed(GTFOMetaItem.UNKNOWN_SEED.getStackForm(), 5);
LacingEntry.LACING_REGISTRY.register(0, "cyanide", new LacingEntry(GTFOMaterialHandler.SodiumCyanide.getItemStack(),
new PotionEffect(CyanidePoisoningPotion.INSTANCE, 1300, 0),
"5dkcap/2/4/"));
LacingEntry.LACING_REGISTRY.register(1, "antischizo", new LacingEntry(GTFOMaterialHandler.LithiumCarbonate.getItemStack(),
new PotionEffect(AntiSchizoPotion.INSTANCE, 1000, 0),
"14hez98zk7/2/3/5/9/10/"));
LacingEntry.LACING_REGISTRY.register(2, "lungcancer", new LacingEntry(OreDictUnifier.get(dust, Materials.Asbestos),
new PotionEffect(LungCancerPotion.INSTANCE, 99999999, 0),
"17aaqe0i1q/1/2/3/7/10/"));
LacingEntry.LACING_REGISTRY.register(3, "asphyxiation", new LacingEntry(OreDictUnifier.get(dust, RecrystalizedLurdmanine),
new PotionEffect(asphyxiationpotion.INSTANCE, 100, 0),
"fsdfdss/1/"));
if (Loader.isModLoaded(GTFOValues.MODID_NUGT) && GTFOConfig.gtfoOtherFoodModConfig.enableGTFONutrition) {
GTFONutritionCompatibility.init();
}
GTFOLog.logger.info("Removing recipes during post init (thanks Ender IO!)");
GTFORecipeRemoval.init();
}
@SubscribeEvent
public static void syncConfigValues(ConfigChangedEvent.OnConfigChangedEvent event) {
if (event.getModID().equals(GregTechFoodOption.MODID)) {
ConfigManager.sync(GregTechFoodOption.MODID, Config.Type.INSTANCE);
}
}
@SubscribeEvent
public static void registerBlocks(RegistryEvent.Register<Block> event) {
GTFOLog.logger.info("Registering blocks...");
IForgeRegistry<Block> registry = event.getRegistry();
registry.register(GTFOMetaBlocks.GTFO_CASING);
registry.register(GTFOMetaBlocks.GTFO_METAL_CASING);
registry.register(GTFOMetaBlocks.GTFO_GLASS_CASING);
CROP_BLOCKS.forEach(registry::register);
GTFOMetaBlocks.GTFO_LEAVES.forEach(registry::register);
GTFOMetaBlocks.GTFO_LOGS.forEach(registry::register);
GTFOMetaBlocks.GTFO_PLANKS.forEach(registry::register);
GTFOMetaBlocks.GTFO_SAPLINGS.forEach(registry::register);
MetaTileEntityGreenhouse.addGrasses();
}
@SubscribeEvent
public static void registerItems(RegistryEvent.Register<Item> event) {
GTFOLog.logger.info("Registering Items...");
IForgeRegistry<Item> registry = event.getRegistry();
registry.register(createItemBlock(GTFOMetaBlocks.GTFO_CASING, VariantItemBlock::new));
registry.register(createItemBlock(GTFOMetaBlocks.GTFO_METAL_CASING, VariantItemBlock::new));
registry.register(createItemBlock(GTFOMetaBlocks.GTFO_GLASS_CASING, VariantItemBlock::new));
GTFOMetaBlocks.GTFO_LEAVES.forEach(leaves -> registry.register(createItemBlock(leaves, GTFOSpecialVariantItemBlock::new)));
GTFOMetaBlocks.GTFO_LOGS.forEach(log -> registry.register(createItemBlock(log, GTFOSpecialVariantItemBlock::new)));
GTFOMetaBlocks.GTFO_SAPLINGS.forEach(sapling -> registry.register(createItemBlock(sapling, GTFOSpecialVariantItemBlock::new)));
GTFOMetaBlocks.GTFO_PLANKS.forEach(sapling -> registry.register(createItemBlock(sapling, GTFOSpecialVariantItemBlock::new)));
}
@SubscribeEvent(priority = EventPriority.NORMAL)
public static void registerRecipes(RegistryEvent.Register<IRecipe> event) {
GTFOLog.logger.info("Registering recipe normal...");
GTFORecipeAddition.init();
}
@SubscribeEvent(priority = EventPriority.LOW)
public static void registerLowRecipes(RegistryEvent.Register<IRecipe> event) {
GTFOLog.logger.info("Registering recipe low...");
GTFORecipeAddition.lowInit();
}
@SubscribeEvent(priority = EventPriority.LOW)
public static void registerOrePrefix(RegistryEvent.Register<IRecipe> event) {
GTFOLog.logger.info("Registering ore prefix...");
GTFOOreDictRegistration.init();
//GTFOMetaItems.registerOreDict();
GTFOMetaBlocks.registerOreDict();
//OrePrefix.runMaterialHandlers();
}
private static <T extends Block> ItemBlock createItemBlock(T block, Function<T, ItemBlock> producer) {
ItemBlock itemBlock = producer.apply(block);
itemBlock.setRegistryName(Objects.requireNonNull(block.getRegistryName()));
return itemBlock;
}
@SubscribeEvent(priority = EventPriority.LOWEST)
public static void registerRecipesLowest(RegistryEvent.Register<IRecipe> event) {
GTFOLog.logger.info("Registering recipe very low...");
GTFORecipeAddition.compatInit();
}
@SubscribeEvent
@Optional.Method(modid = "enderio")
public static void registerEIOFarmerJoes(@Nonnull RegistryEvent.Register<IFarmerJoe> event) {
for (GTFOCrop crop : CROP_BLOCKS) {
if (crop instanceof GTFORootCrop) {
event.getRegistry().register(new GTFORootCropFarmer(crop, crop.getSeedStack())
.setRegistryName(crop.getRegistryName()));
continue;
}
if (crop instanceof GTFOBerryBush) {
event.getRegistry().register(new GTFOBerryFarmer(crop, crop.getSeedStack())
.setRegistryName(crop.getRegistryName()));
continue;
}
event.getRegistry().register(new CustomSeedFarmer(crop, crop.getSeedStack())
.setRegistryName(crop.getRegistryName()));
}
}
// These recipes are generated at the beginning of the init() phase with the proper config set.
// This is not great practice, but ensures that they are run AFTER CraftTweaker,
// meaning they will follow the recipes in the map with CraftTweaker changes,
// being significantly easier for modpack authors.
/*
@SubscribeEvent(priority = EventPriority.HIGH)
public static void onLogin(PlayerEvent.PlayerLoggedInEvent event) {
if (!event.player.world.isRemote) {
}
}
@SubscribeEvent
public static void onSave(WorldEvent.Save event) {
MinecraftForge.addGrassSeed(GTFOMetaItem.UNKNOWN_SEED.getStackForm(), 5);
((MetaPrefixItem)OreDictUnifier.get("plateIron").getItem()).getItem(OreDictUnifier.get("plateIron"))
.addComponents(new GTFOFoodStats(0, 0, false, false, ItemStack.EMPTY));
}
@SubscribeEvent
public static void onUnload(WorldEvent.Unload event) {
}
*/
}