33
44import crazypants .enderio .base .fluid .Fluids ;
55import crazypants .enderio .base .init .ModObject ;
6+ import gregtech .api .recipes .RecipeBuilder ;
7+ import gregtech .api .recipes .builders .SimpleRecipeBuilder ;
68import gregtech .api .recipes .ingredients .GTRecipeItemInput ;
79import gregtech .api .recipes .ingredients .nbtmatch .NBTCondition ;
810import gregtech .api .recipes .ingredients .nbtmatch .NBTMatcher ;
1416import net .minecraft .item .ItemStack ;
1517import net .minecraft .nbt .NBTTagCompound ;
1618import net .minecraft .util .ResourceLocation ;
17- import net .minecraftforge .fluids .Fluid ;
1819import net .minecraftforge .fluids .FluidStack ;
1920import net .minecraftforge .fml .common .Loader ;
2021
2122import java .util .ArrayList ;
23+ import java .util .Arrays ;
2224import java .util .List ;
25+ import java .util .function .Consumer ;
2326
2427import static gregtech .api .GTValues .*;
2528import static gregtech .api .unification .material .Materials .*;
@@ -29,23 +32,14 @@ public class EIOSoulRecipeLoader {
2932
3033 // This code was created under the advice of miozune.
3134 public static void init (){
32- recipeAll ();
33- recipeBlaze ();
34- recipeCreeper ();
35- recipeEnderman ();
36- recipeSkeleton ();
37- recipeSlime ();
38- recipeSpider ();
39- recipePigman ();
35+ soulBinderRecipes ();
36+ vialExtractorRecipes ();
4037 recipeVillager ();
4138 recipeWitch ();
42- recipeWitherSkeleton ();
4339 recipeZombie ();
44- recipeGuardian ();
45- recipeSquid ();
4640 }
4741
48- private static void recipeAll () {
42+ private static void soulBinderRecipes () {
4943 for (ResourceLocation name : EntityList .getEntityNameList ()) {
5044 if (!EntityList .ENTITY_EGGS .containsKey (name )) {
5145 continue ;
@@ -92,140 +86,28 @@ private static void recipeAll() {
9286 }
9387 }
9488
95- private static void recipeBlaze () {
96- ItemStack stack = new ItemStack (ModObject .itemSoulVial .getItemNN (), 1 , 1 );
97- NBTTagCompound tag = new NBTTagCompound ();
98- tag .setString ("entityId" , "minecraft:blaze" );
99- stack .setTagCompound (tag );
100-
101- // Vial Extractor
102- GTERecipeMaps .VIAL_EXTRACTOR_RECIPES .recipeBuilder ()
103- .input (GTRecipeItemInput .getOrCreate (stack )
104- .setNBTMatchingCondition (NBTMatcher .RECURSIVE_EQUAL_TO ,
105- NBTCondition .create (NBTTagType .STRING , "entityId" , "minecraft:blaze" )))
106- .output (ModObject .itemSoulVial .getItemNN ())
107- .output (Items .BLAZE_ROD , 10 )
108- .output (Items .ROTTEN_FLESH , 10 )
109- .fluidOutputs (new FluidStack (Fluids .XP_JUICE .getFluid (), 1000 ))
110- .duration (600 ).EUt (30 ).buildAndRegister ();
111- }
112-
113- private static void recipeCreeper () {
114- ItemStack stack = new ItemStack (ModObject .itemSoulVial .getItemNN (), 1 , 1 );
115- NBTTagCompound tag = new NBTTagCompound ();
116- tag .setString ("entityId" , "minecraft:creeper" );
117- stack .setTagCompound (tag );
118-
119- // Vial Extractor
120- GTERecipeMaps .VIAL_EXTRACTOR_RECIPES .recipeBuilder ()
121- .input (GTRecipeItemInput .getOrCreate (stack )
122- .setNBTMatchingCondition (NBTMatcher .RECURSIVE_EQUAL_TO ,
123- NBTCondition .create (NBTTagType .STRING , "entityId" , "minecraft:creeper" )))
124- .output (ModObject .itemSoulVial .getItemNN ())
125- .output (Items .SKULL , 10 , 4 )
126- .output (Items .GUNPOWDER , 10 )
127- .fluidOutputs (new FluidStack (Fluids .XP_JUICE .getFluid (), 1000 ))
128- .duration (600 ).EUt (30 ).buildAndRegister ();
129- }
130-
131- private static void recipeEnderman () {
132- ItemStack stack = new ItemStack (ModObject .itemSoulVial .getItemNN (), 1 , 1 );
133- NBTTagCompound tag = new NBTTagCompound ();
134- tag .setString ("entityId" , "minecraft:enderman" );
135- stack .setTagCompound (tag );
136-
137- // Vial Extractor
138- GTERecipeMaps .VIAL_EXTRACTOR_RECIPES .recipeBuilder ()
139- .input (GTRecipeItemInput .getOrCreate (stack )
140- .setNBTMatchingCondition (NBTMatcher .RECURSIVE_EQUAL_TO ,
141- NBTCondition .create (NBTTagType .STRING , "entityId" , "minecraft:enderman" )))
142- .output (ModObject .itemSoulVial .getItemNN ())
143- .output (ModObject .blockEndermanSkull .getItemNN (), 10 , 0 )
144- .output (Items .ENDER_PEARL , 10 )
145- .fluidOutputs (new FluidStack (Fluids .XP_JUICE .getFluid (), 1000 ))
146- .duration (600 ).EUt (30 ).buildAndRegister ();
147- }
148-
149- private static void recipeSkeleton () {
150- ItemStack stack = new ItemStack (ModObject .itemSoulVial .getItemNN (), 1 , 1 );
151- NBTTagCompound tag = new NBTTagCompound ();
152- tag .setString ("entityId" , "minecraft:skeleton" );
153- stack .setTagCompound (tag );
154-
155- // Vial Extractor
156- GTERecipeMaps .VIAL_EXTRACTOR_RECIPES .recipeBuilder ()
157- .input (GTRecipeItemInput .getOrCreate (stack )
158- .setNBTMatchingCondition (NBTMatcher .RECURSIVE_EQUAL_TO ,
159- NBTCondition .create (NBTTagType .STRING , "entityId" , "minecraft:skeleton" )))
160- .output (ModObject .itemSoulVial .getItemNN ())
161- .output (Items .SKULL , 10 , 0 )
162- .output (Items .BONE , 10 )
163- .fluidOutputs (new FluidStack (Fluids .XP_JUICE .getFluid (), 1000 ))
164- .duration (600 ).EUt (30 ).buildAndRegister ();
165- }
166-
167- private static void recipeSlime () {
168- List <String > slime = new ArrayList <>();
169- slime .add ("minecraft:slime" );
170- slime .add ("minecraft:magma_cube" );
171- for (String Slime : slime ) {
172- ItemStack stack = new ItemStack (ModObject .itemSoulVial .getItemNN (), 1 , 1 );
173- NBTTagCompound tag = new NBTTagCompound ();
174- tag .setString ("entityId" , Slime );
175- stack .setTagCompound (tag );
176-
177- // Vial Extractor
178- GTERecipeMaps .VIAL_EXTRACTOR_RECIPES .recipeBuilder ()
179- .input (GTRecipeItemInput .getOrCreate (stack )
180- .setNBTMatchingCondition (NBTMatcher .RECURSIVE_EQUAL_TO ,
181- NBTCondition .create (NBTTagType .STRING , "entityId" , Slime )))
182- .output (ModObject .itemSoulVial .getItemNN ())
183- .output (Items .SLIME_BALL , 10 )
184- .output (Items .ROTTEN_FLESH , 10 )
185- .fluidOutputs (new FluidStack (Fluids .XP_JUICE .getFluid (), 2000 ))
186- .duration (600 ).EUt (30 ).buildAndRegister ();
187- }
188- }
189-
190- private static void recipeSpider () {
191- List <String > spider = new ArrayList <>();
192- spider .add ("minecraft:spider" );
193- //spider.add("minecraft:cave_spider");
194- for (String Spider : spider ) {
195- ItemStack stack = new ItemStack (ModObject .itemSoulVial .getItemNN (), 1 , 1 );
196- NBTTagCompound tag = new NBTTagCompound ();
197- tag .setString ("entityId" , Spider );
198- stack .setTagCompound (tag );
199-
200- // Vial Extractor
201- GTERecipeMaps .VIAL_EXTRACTOR_RECIPES .recipeBuilder ()
202- .input (GTRecipeItemInput .getOrCreate (stack )
203- .setNBTMatchingCondition (NBTMatcher .RECURSIVE_EQUAL_TO ,
204- NBTCondition .create (NBTTagType .STRING , "entityId" , Spider )))
205- .output (ModObject .itemSoulVial .getItemNN ())
206- .output (Items .SPIDER_EYE , 10 )
207- .output (Items .STRING , 10 )
208- .fluidOutputs (new FluidStack (Fluids .XP_JUICE .getFluid (), 1000 ))
209- .duration (600 ).EUt (30 ).buildAndRegister ();
210- }
211- }
212-
213- private static void recipePigman () {
214- ItemStack stack = new ItemStack (ModObject .itemSoulVial .getItemNN (), 1 , 1 );
215- NBTTagCompound tag = new NBTTagCompound ();
216- tag .setString ("entityId" , "minecraft:zombie_pigman" );
217- stack .setTagCompound (tag );
218-
219- // Vial Extractor
220- GTERecipeMaps .VIAL_EXTRACTOR_RECIPES .recipeBuilder ()
221- .input (GTRecipeItemInput .getOrCreate (stack )
222- .setNBTMatchingCondition (NBTMatcher .RECURSIVE_EQUAL_TO ,
223- NBTCondition .create (NBTTagType .STRING , "entityId" , "minecraft:zombie_pigman" )))
224- .output (ModObject .itemSoulVial .getItemNN ())
225- .output (Items .ROTTEN_FLESH , 10 )
226- .chancedOutput (ingot , Gold , 250 , 250 )
227- .fluidOutputs (new FluidStack (Fluids .XP_JUICE .getFluid (), 1000 ))
228- .duration (600 ).EUt (30 ).buildAndRegister ();
89+ private static void vialExtractorRecipes () {
90+ registerVialExtractorRecipe ("minecraft:blaze" , new ItemStack (Items .BLAZE_ROD , 10 ), new ItemStack (Items .ROTTEN_FLESH , 10 ));
91+ registerVialExtractorRecipe ("minecraft:creeper" , new ItemStack (Items .SKULL , 10 , 4 ), new ItemStack (Items .GUNPOWDER , 10 ));
92+ registerVialExtractorRecipe ("minecraft:enderman" , new ItemStack (ModObject .blockEndermanSkull .getItemNN (), 10 , 0 ), new ItemStack (Items .ENDER_PEARL , 10 ));
93+ registerVialExtractorRecipe ("minecraft:skeleton" , new ItemStack (Items .SKULL , 10 , 0 ), new ItemStack (Items .BONE , 10 ));
94+ for (String slime : Arrays .asList ("minecraft:slime" , "minecraft:magma_cube" )) {
95+ registerVialExtractorRecipe (slime , 2000 , new ItemStack (Items .SLIME_BALL , 10 ), new ItemStack (Items .ROTTEN_FLESH , 10 ));
96+ }
97+ registerVialExtractorRecipe ("minecraft:spider" , new ItemStack (Items .SPIDER_EYE , 10 ), new ItemStack (Items .STRING , 10 ));
98+ registerVialExtractorRecipe ("minecraft:zombie_pigman" , 1000 , builder ->
99+ builder .output (Items .ROTTEN_FLESH , 10 ).chancedOutput (ingot , Gold , 250 , 250 ));
100+ registerVialExtractorRecipe ("minecraft:wither_skeleton" , new ItemStack (Items .SKULL , 5 , 1 ), new ItemStack (Items .BONE , 5 ));
101+ for (String zombie : Arrays .asList ("minecraft:zombie" , "minecraft:husk" , "minecraft:zombie_villager" )) {
102+ registerVialExtractorRecipe (zombie , 1000 , builder ->
103+ builder .output (Items .SKULL , 10 , 2 )
104+ .output (Items .ROTTEN_FLESH , 10 )
105+ .chancedOutput (ingot , Iron , 100 , 0 ));
106+ }
107+ for (String guardian : Arrays .asList ("minecraft:guardian" , "minecraft:elder_guardian" )) {
108+ registerVialExtractorRecipe (guardian , new ItemStack (Items .PRISMARINE_SHARD , 5 ), new ItemStack (Blocks .SPONGE , 1 , 1 ));
109+ }
110+ registerVialExtractorRecipe ("minecraft:squid" , new ItemStack (Items .DYE , 10 , 0 ));
229111 }
230112
231113 private static void recipeVillager () {
@@ -247,121 +129,88 @@ private static void recipeVillager() {
247129 }
248130
249131 private static void recipeWitch () {
250- List <String > witch = new ArrayList <>();
251- witch .add ("minecraft:witch" );
252- if (Loader .isModLoaded ("enderzoo" )) {witch .add ("enderzoo:witherwitch" );}
253- if (Loader .isModLoaded ("enderiozoo" )) {witch .add ("enderiozoo:witherwitch" );}
254- for (String Witch : witch ) {
255- ItemStack stack = new ItemStack (ModObject .itemSoulVial .getItemNN (), 1 , 1 );
256- NBTTagCompound tag = new NBTTagCompound ();
257- tag .setString ("entityId" , Witch );
258- stack .setTagCompound (tag );
259-
260- // Soul Binder - Sentient Ender
261- GTERecipeMaps .SOUL_BINDER_RECIPES .recipeBuilder ()
262- .input (GTRecipeItemInput .getOrCreate (stack )
263- .setNBTMatchingCondition (NBTMatcher .RECURSIVE_EQUAL_TO ,
264- NBTCondition .create (NBTTagType .STRING , "entityId" , Witch )))
265- .input (ModObject .itemMaterial .getItemNN (), 1 , 43 )
266- .fluidInputs (new FluidStack (Fluids .XP_JUICE .getFluid (), 8640 ))
267- .output (ModObject .itemSoulVial .getItemNN ())
268- .output (ModObject .itemMaterial .getItemNN (), 1 , 44 )
269- .duration (1000 ).EUt (VA [LV ]).buildAndRegister ();
270- }
271- }
272-
273- private static void recipeWitherSkeleton () {
274- ItemStack stack = new ItemStack (ModObject .itemSoulVial .getItemNN (), 1 , 1 );
275- NBTTagCompound tag = new NBTTagCompound ();
276- tag .setString ("entityId" , "minecraft:wither_skeleton" );
277- stack .setTagCompound (tag );
278-
279- // Vial Extractor
280- GTERecipeMaps .VIAL_EXTRACTOR_RECIPES .recipeBuilder ()
281- .input (GTRecipeItemInput .getOrCreate (stack )
282- .setNBTMatchingCondition (NBTMatcher .RECURSIVE_EQUAL_TO ,
283- NBTCondition .create (NBTTagType .STRING , "entityId" , "minecraft:wither_skeleton" )))
284- .output (ModObject .itemSoulVial .getItemNN ())
285- .output (Items .SKULL , 5 , 1 )
286- .output (Items .BONE , 5 )
287- .chancedOutput (new ItemStack (Items .COAL ), 250 , 250 )
288- .fluidOutputs (new FluidStack (Fluids .XP_JUICE .getFluid (), 1000 ))
289- .duration (600 ).EUt (30 ).buildAndRegister ();
290- }
291-
292- private static void recipeZombie () {
293- List <String > zombie = new ArrayList <>();
294- zombie .add ("minecraft:zombie" );
295- zombie .add ("minecraft:husk" );
296- zombie .add ("minecraft:zombie_villager" );
297- for (String Zombie : zombie ) {
132+ List <String > witch = new ArrayList <>();
133+ witch .add ("minecraft:witch" );
134+ if (Loader .isModLoaded ("enderzoo" )) {witch .add ("enderzoo:witherwitch" );}
135+ if (Loader .isModLoaded ("enderiozoo" )) {witch .add ("enderiozoo:witherwitch" );}
136+ for (String Witch : witch ) {
298137 ItemStack stack = new ItemStack (ModObject .itemSoulVial .getItemNN (), 1 , 1 );
299138 NBTTagCompound tag = new NBTTagCompound ();
300- tag .setString ("entityId" , Zombie );
139+ tag .setString ("entityId" , Witch );
301140 stack .setTagCompound (tag );
302141
303- // Soul Binder - Frank'N'Zombie
142+ // Soul Binder - Sentient Ender
304143 GTERecipeMaps .SOUL_BINDER_RECIPES .recipeBuilder ()
305144 .input (GTRecipeItemInput .getOrCreate (stack )
306145 .setNBTMatchingCondition (NBTMatcher .RECURSIVE_EQUAL_TO ,
307- NBTCondition .create (NBTTagType .STRING , "entityId" , Zombie )))
308- .input (ModObject .itemMaterial .getItemNN (), 1 , 41 )
146+ NBTCondition .create (NBTTagType .STRING , "entityId" , Witch )))
147+ .input (ModObject .itemMaterial .getItemNN (), 1 , 43 )
309148 .fluidInputs (new FluidStack (Fluids .XP_JUICE .getFluid (), 8640 ))
310149 .output (ModObject .itemSoulVial .getItemNN ())
311- .output (ModObject .itemMaterial .getItemNN (), 1 , 42 )
150+ .output (ModObject .itemMaterial .getItemNN (), 1 , 44 )
312151 .duration (1000 ).EUt (VA [LV ]).buildAndRegister ();
313-
314- // Vial Extractor
315- GTERecipeMaps .VIAL_EXTRACTOR_RECIPES .recipeBuilder ()
316- .input (GTRecipeItemInput .getOrCreate (stack )
317- .setNBTMatchingCondition (NBTMatcher .RECURSIVE_EQUAL_TO ,
318- NBTCondition .create (NBTTagType .STRING , "entityId" , Zombie )))
319- .output (ModObject .itemSoulVial .getItemNN ())
320- .output (Items .SKULL , 10 , 2 )
321- .output (Items .ROTTEN_FLESH , 10 )
322- .chancedOutput (ingot , Iron , 100 , 0 )
323- .fluidOutputs (new FluidStack (Fluids .XP_JUICE .getFluid (), 1000 ))
324- .duration (600 ).EUt (30 ).buildAndRegister ();
325152 }
326153 }
327154
328- private static void recipeGuardian () {
329- List <String > guardian = new ArrayList <>();
330- guardian .add ("minecraft:guardian" );
331- guardian .add ("minecraft:elder_guardian" );
332- for (String Guardian : guardian ) {
155+ private static void recipeZombie () {
156+ for (String Zombie : Arrays .asList ("minecraft:zombie" , "minecraft:husk" , "minecraft:zombie_villager" )) {
333157 ItemStack stack = new ItemStack (ModObject .itemSoulVial .getItemNN (), 1 , 1 );
334158 NBTTagCompound tag = new NBTTagCompound ();
335- tag .setString ("entityId" , Guardian );
159+ tag .setString ("entityId" , Zombie );
336160 stack .setTagCompound (tag );
337161
338- // Vial Extractor
339- GTERecipeMaps .VIAL_EXTRACTOR_RECIPES .recipeBuilder ()
162+ // Soul Binder - Frank'N'Zombie
163+ GTERecipeMaps .SOUL_BINDER_RECIPES .recipeBuilder ()
340164 .input (GTRecipeItemInput .getOrCreate (stack )
341165 .setNBTMatchingCondition (NBTMatcher .RECURSIVE_EQUAL_TO ,
342- NBTCondition .create (NBTTagType .STRING , "entityId" , Guardian )))
166+ NBTCondition .create (NBTTagType .STRING , "entityId" , Zombie )))
167+ .input (ModObject .itemMaterial .getItemNN (), 1 , 41 )
168+ .fluidInputs (new FluidStack (Fluids .XP_JUICE .getFluid (), 8640 ))
343169 .output (ModObject .itemSoulVial .getItemNN ())
344- .output (Items .PRISMARINE_SHARD , 5 )
345- .outputs (new ItemStack (Blocks .SPONGE , 1 , 1 ))
346- .fluidOutputs (new FluidStack (Fluids .XP_JUICE .getFluid (), 1000 ))
347- .duration (600 ).EUt (30 ).buildAndRegister ();
170+ .output (ModObject .itemMaterial .getItemNN (), 1 , 42 )
171+ .duration (1000 ).EUt (VA [LV ]).buildAndRegister ();
348172 }
349173 }
350174
351- private static void recipeSquid () {
175+ /**
176+ * @param entityName Name of entity, `modID:entityName`
177+ * @param xpAmount Amount of Liquid XP to output
178+ * @param applyForRecipeBuilder Methods to call for recipe builder
179+ */
180+ private static void registerVialExtractorRecipe (String entityName , int xpAmount , Consumer <RecipeBuilder <SimpleRecipeBuilder >> applyForRecipeBuilder ) {
352181 ItemStack stack = new ItemStack (ModObject .itemSoulVial .getItemNN (), 1 , 1 );
353182 NBTTagCompound tag = new NBTTagCompound ();
354- tag .setString ("entityId" , "minecraft:squid" );
183+ tag .setString ("entityId" , entityName );
355184 stack .setTagCompound (tag );
356185
357- // Vial Extractor
358- GTERecipeMaps .VIAL_EXTRACTOR_RECIPES .recipeBuilder ()
186+ RecipeBuilder <SimpleRecipeBuilder > recipeBuilder = GTERecipeMaps .VIAL_EXTRACTOR_RECIPES .recipeBuilder ();
187+
188+ recipeBuilder
359189 .input (GTRecipeItemInput .getOrCreate (stack )
360- .setNBTMatchingCondition (NBTMatcher .RECURSIVE_EQUAL_TO ,
361- NBTCondition .create (NBTTagType .STRING , "entityId" , "minecraft:squid" )))
190+ .setNBTMatchingCondition (NBTMatcher .RECURSIVE_EQUAL_TO ,
191+ NBTCondition .create (NBTTagType .STRING , "entityId" , entityName )))
362192 .output (ModObject .itemSoulVial .getItemNN ())
363- .outputs (new ItemStack (Items .DYE , 10 , 0 ))
364- .fluidOutputs (new FluidStack (Fluids .XP_JUICE .getFluid (), 1000 ))
365- .duration (600 ).EUt (30 ).buildAndRegister ();
193+ .fluidOutputs (new FluidStack (Fluids .XP_JUICE .getFluid (), xpAmount ));
194+
195+ applyForRecipeBuilder .accept (recipeBuilder );
196+
197+ recipeBuilder .duration (600 ).EUt (VA [LV ]).buildAndRegister ();
198+ }
199+
200+ /**
201+ * @param entityName Name of entity, `modID:entityName`
202+ * @param xpAmount Amount of Liquid XP to output
203+ * @param outputs Item outputs, except for empty vial
204+ */
205+ private static void registerVialExtractorRecipe (String entityName , int xpAmount , ItemStack ... outputs ) {
206+ registerVialExtractorRecipe (entityName , xpAmount , builder -> builder .outputs (outputs ));
207+ }
208+
209+ /**
210+ * @param entityName Name of entity, `modID:entityName`
211+ * @param outputs Item outputs, except for empty vial
212+ */
213+ private static void registerVialExtractorRecipe (String entityName , ItemStack ... outputs ) {
214+ registerVialExtractorRecipe (entityName , 1000 , outputs );
366215 }
367216}
0 commit comments