-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1.12.2-1.3: New Integrations: Advanced Rocketry (All Machines), Base …
…Metals (Crack Hammer), Forestry (Centrifuge), Industrial Foregoing (Laser),
- Loading branch information
1 parent
4a928e7
commit bec1fa1
Showing
18 changed files
with
229 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file renamed
BIN
+63.1 KB
libs/WanionLib-1.12.2-1.2-dev.jar → libs/WanionLib-1.12.2-1.2c-dev.jar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/main/java/wanion/unidict/integration/AdvancedRocketryIntegration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package wanion.unidict.integration; | ||
|
||
/* | ||
* Created by WanionCane(https://github.com/WanionCane). | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
import net.minecraft.item.ItemStack; | ||
import wanion.unidict.UniDict; | ||
import zmaster587.libVulpes.recipe.RecipesMachine; | ||
|
||
import java.lang.reflect.Field; | ||
import java.util.List; | ||
|
||
final class AdvancedRocketryIntegration extends AbstractIntegrationThread | ||
{ | ||
private final Field outputField; | ||
AdvancedRocketryIntegration() | ||
{ | ||
super("Advanced Rocketry"); | ||
try { | ||
(outputField = RecipesMachine.Recipe.class.getDeclaredField("output")).setAccessible(true); | ||
} catch (NoSuchFieldException e) { | ||
throw new RuntimeException("Couldn't find the fields!"); | ||
} | ||
} | ||
|
||
@Override | ||
public String call() | ||
{ | ||
try { | ||
fixRecipes(); | ||
} catch (Exception e) { | ||
UniDict.getLogger().error(threadName + e); | ||
} | ||
return threadName + "10. 9...3 2 1... BOOOOM!!"; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
private void fixRecipes() | ||
{ | ||
RecipesMachine.getInstance().recipeList.values().forEach(iRecipes -> iRecipes.forEach(iRecipe -> { | ||
if (iRecipe instanceof RecipesMachine.Recipe) | ||
try { | ||
resourceHandler.setMainItemStacks((List<ItemStack>) outputField.get(iRecipe)); | ||
} catch (IllegalAccessException e) { | ||
e.printStackTrace(); | ||
} | ||
})); | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
src/main/java/wanion/unidict/integration/BaseMetalsIntegration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package wanion.unidict.integration; | ||
|
||
/* | ||
* Created by WanionCane(https://github.com/WanionCane). | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
import com.mcmoddev.lib.registry.CrusherRecipeRegistry; | ||
import com.mcmoddev.lib.registry.recipe.ArbitraryCrusherRecipe; | ||
import com.mcmoddev.lib.registry.recipe.ICrusherRecipe; | ||
import com.mcmoddev.lib.registry.recipe.OreDictionaryCrusherRecipe; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.util.ResourceLocation; | ||
import net.minecraftforge.registries.IForgeRegistryModifiable; | ||
import wanion.lib.common.Util; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
final class BaseMetalsIntegration extends AbstractIntegrationThread | ||
{ | ||
BaseMetalsIntegration() | ||
{ | ||
super("Base Metals"); | ||
} | ||
|
||
@Override | ||
public String call() | ||
{ | ||
fixCrushingRecipes(); | ||
return threadName + "Fixing Everything!"; | ||
} | ||
|
||
private void fixCrushingRecipes() | ||
{ | ||
final CrusherRecipeRegistry crusherRecipeRegistry = Util.getField(CrusherRecipeRegistry.class, "instance", null, CrusherRecipeRegistry.class); | ||
final IForgeRegistryModifiable<ICrusherRecipe> registry = Util.getField(CrusherRecipeRegistry.class, "registry", crusherRecipeRegistry, IForgeRegistryModifiable.class); | ||
final List<ResourceLocation> recipesToRemove = new ArrayList<>(); | ||
final List<ICrusherRecipe> newRecipes = new ArrayList<>(); | ||
registry.getEntries().forEach(recipe -> { | ||
final ICrusherRecipe crusherRecipe = recipe.getValue(); | ||
final ItemStack output = crusherRecipe.getOutput(); | ||
final ItemStack newOutput = resourceHandler.getMainItemStack(crusherRecipe.getOutput()); | ||
if (output != newOutput) { | ||
recipesToRemove.add(recipe.getKey()); | ||
if (crusherRecipe instanceof ArbitraryCrusherRecipe) | ||
newRecipes.add(new ArbitraryCrusherRecipe(crusherRecipe.getInputs().get(0), newOutput)); | ||
else if (crusherRecipe instanceof OreDictionaryCrusherRecipe) | ||
newRecipes.add(new OreDictionaryCrusherRecipe(Util.getField(OreDictionaryCrusherRecipe.class, "oreDictSource", crusherRecipe, String .class), newOutput)); | ||
} | ||
}); | ||
recipesToRemove.forEach(registry::remove); | ||
newRecipes.forEach(registry::register); | ||
} | ||
} |
82 changes: 82 additions & 0 deletions
82
src/main/java/wanion/unidict/integration/ForestryIntegration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package wanion.unidict.integration; | ||
|
||
import forestry.api.recipes.ICarpenterRecipe; | ||
import forestry.api.recipes.ICentrifugeRecipe; | ||
import forestry.core.recipes.ShapedRecipeCustom; | ||
import forestry.factory.recipes.CarpenterRecipe; | ||
import forestry.factory.recipes.CarpenterRecipeManager; | ||
import forestry.factory.recipes.CentrifugeRecipe; | ||
import forestry.factory.recipes.CentrifugeRecipeManager; | ||
import net.minecraft.item.Item; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.util.ResourceLocation; | ||
import net.minecraft.util.registry.RegistryNamespaced; | ||
import wanion.lib.common.MetaItem; | ||
import wanion.lib.common.Util; | ||
import wanion.unidict.UniDict; | ||
import wanion.unidict.resource.UniResourceContainer; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.util.*; | ||
|
||
final class ForestryIntegration extends AbstractIntegrationThread | ||
{ | ||
private Set<ICarpenterRecipe> carpenterRecipes = Util.getField(CarpenterRecipeManager.class, "recipes", null, Set.class); | ||
private static final RegistryNamespaced<ResourceLocation, Item> itemRegistry = Item.REGISTRY; | ||
|
||
ForestryIntegration() | ||
{ | ||
super("Forestry"); | ||
} | ||
|
||
@Override | ||
public String call() | ||
{ | ||
try { | ||
removeBadCarpenterOutputs(carpenterRecipes); | ||
if (resourceHandler.containerExists("ingotBronze")) | ||
bronzeThings(); | ||
fixCentrifugeRecipes(); | ||
} catch (Exception e) { UniDict.getLogger().error(threadName + e); } | ||
return threadName + "All these bees... they can hurt, you know?"; | ||
} | ||
|
||
private void removeBadCarpenterOutputs(@Nonnull final Set<ICarpenterRecipe> carpenterRecipes) | ||
{ | ||
carpenterRecipes.removeIf(carpenterRecipe -> carpenterRecipe != null && resourceHandler.exists(MetaItem.get(carpenterRecipe.getCraftingGridRecipe().getOutput()))); | ||
} | ||
|
||
private void bronzeThings() | ||
{ | ||
UniResourceContainer ingotBronze = resourceHandler.getContainer("ingotBronze"); | ||
final Item brokenBronzePickaxe = itemRegistry.getObject(new ResourceLocation("forestry", "brokenBronzePickaxe")); | ||
final Item brokenBronzeShovel = itemRegistry.getObject(new ResourceLocation("forestry", "brokenBronzeShovel")); | ||
if (brokenBronzePickaxe != null) | ||
carpenterRecipes.add(new CarpenterRecipe(5, null, ItemStack.EMPTY, new ShapedRecipeCustom(ingotBronze.getMainEntry(2), "X ", " ", " ", 'X', new ItemStack(brokenBronzePickaxe)))); | ||
if (brokenBronzeShovel != null) | ||
carpenterRecipes.add(new CarpenterRecipe(5, null, ItemStack.EMPTY, new ShapedRecipeCustom(ingotBronze.getMainEntry(1), "X ", " ", " ", 'X', new ItemStack(brokenBronzeShovel)))); | ||
} | ||
|
||
private void fixCentrifugeRecipes() | ||
{ | ||
final Set<ICentrifugeRecipe> centrifugeRecipes = Util.getField(CentrifugeRecipeManager.class, "recipes", null, Set.class); | ||
if (centrifugeRecipes == null) | ||
return; | ||
final List<ICentrifugeRecipe> newRecipes = new ArrayList<>(); | ||
for (final Iterator<ICentrifugeRecipe> centrifugeRecipeIterator = centrifugeRecipes.iterator(); centrifugeRecipeIterator.hasNext(); centrifugeRecipeIterator.remove()) | ||
{ | ||
final ICentrifugeRecipe centrifugeRecipe = centrifugeRecipeIterator.next(); | ||
newRecipes.add(new CentrifugeRecipe(centrifugeRecipe.getProcessingTime(), centrifugeRecipe.getInput(), correctCentrifugeOutput(centrifugeRecipe.getAllProducts()))); | ||
|
||
} | ||
centrifugeRecipes.addAll(newRecipes); | ||
} | ||
|
||
@Nonnull | ||
private Map<ItemStack, Float> correctCentrifugeOutput(@Nonnull final Map<ItemStack, Float> outputMap) | ||
{ | ||
final Map<ItemStack, Float> newOutputMap = new HashMap<>(); | ||
outputMap.forEach((output, chance) -> newOutputMap.put(resourceHandler.getMainItemStack(output), chance)); | ||
return newOutputMap; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/wanion/unidict/integration/IndustrialForegoingIntegration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package wanion.unidict.integration; | ||
|
||
/* | ||
* Created by WanionCane(https://github.com/WanionCane). | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
import com.buuz135.industrial.api.recipe.LaserDrillEntry; | ||
import net.minecraft.item.ItemStack; | ||
import wanion.lib.common.Util; | ||
|
||
final class IndustrialForegoingIntegration extends AbstractIntegrationThread | ||
{ | ||
IndustrialForegoingIntegration() | ||
{ | ||
super("Industrial Foregoing"); | ||
} | ||
|
||
@Override | ||
public String call() | ||
{ | ||
LaserDrillEntry.LASER_DRILL_ENTRIES.forEach(laserDrillEntry -> Util.setField(LaserDrillEntry.class, "stack", laserDrillEntry, resourceHandler.getMainItemStack(Util.getField(LaserDrillEntry.class, "stack", laserDrillEntry, ItemStack.class)))); | ||
return threadName + "enhanced Laser Drill focus."; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters