Skip to content

Commit

Permalink
1.12.2-1.3: New Integrations: Advanced Rocketry (All Machines), Base …
Browse files Browse the repository at this point in the history
…Metals (Crack Hammer), Forestry (Centrifuge), Industrial Foregoing (Laser),
  • Loading branch information
WanionCane committed Nov 25, 2017
1 parent 4a928e7 commit bec1fa1
Show file tree
Hide file tree
Showing 18 changed files with 229 additions and 10 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ apply plugin: 'net.minecraftforge.gradle.forge'
//Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.


version = "1.12.2-1.2"
version = "1.12.2-1.3"
group = "wanion.unidict" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "UniDict"

Expand Down
Binary file added libs/AdvancedRocketry-1.12.2-1.2.5a-23.jar
Binary file not shown.
Binary file added libs/BaseMetals-1.12-2.5.0-beta3.51.jar
Binary file not shown.
Binary file added libs/Forgelin-1.5.1.jar
Binary file not shown.
Binary file added libs/LibVulpes-1.12.2-0.2.6-16-universal.jar
Binary file not shown.
Binary file added libs/OreSpawn-1.12-3.2.0.95.jar
Binary file not shown.
Binary file not shown.
Binary file added libs/forestry_1.12.2-5.7.0.212.jar
Binary file not shown.
Binary file added libs/industrialforegoing-1.12.2-1.5.9-96.jar
Binary file not shown.
Binary file added libs/tesla-core-lib-1.12-1.0.11.jar
Binary file not shown.
7 changes: 0 additions & 7 deletions src/main/java/wanion/unidict/UniOreDictionary.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,6 @@ public static ItemStack getLastEntry(final String oreDictName)
return (oreList != null && !oreDictName.isEmpty()) ? oreList.get(oreList.size() - 1).copy() : null;
}

public static Set<ItemStack> get(final Collection<String> oreDictNames)
{
final Set<ItemStack> itemStacks = new HashSet<>();
oreDictNames.forEach(name -> idToStack.get(nameToId.get(name)));
return itemStacks;
}

public static List<ItemStack> get(final ItemStack thing)
{
final int thingId = MetaItem.get(thing);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/wanion/unidict/common/Reference.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public final class Reference
{
public static final String MOD_ID = "unidict";
public static final String MOD_NAME = "UniDict";
public static final String MOD_VERSION = "1.12.2-1.2";
public static final String MOD_VERSION = "1.12.2-1.3";
public static final String DEPENDENCIES = "required-after:wanionlib@[1.12.2-1.2,);after:*";
public static final char SLASH = separatorChar;
public static final String MC_VERSION = "[1.12,]";
Expand Down
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();
}
}));
}
}
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 src/main/java/wanion/unidict/integration/ForestryIntegration.java
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;
}
}
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.";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,14 @@ private enum Integration
CRAFTING(CraftingIntegration.class),
FURNACE(FurnaceIntegration.class),
ABYSSAL_CRAFT("abyssalcraft", AbyssalCraftIntegration.class),
ADVANCED_ROCKETRY("advancedrocketry", AdvancedRocketryIntegration.class),
APPLIED_ENERGISTICS_2("appliedenergistics2", AE2Integration.class),
BASE_METALS("basemetals", BaseMetalsIntegration.class),
EMBERS("embers", EmbersIntegration.class),
FORESTRY("forestry", ForestryIntegration.class),
IMMERSIVE_ENGINEERING("immersiveengineering", IEIntegration.class),
INDUSTRIAL_CRAFT_2("ic2", IC2Integration.class),
IDUSTRIAL_FOREGOIN("industrialforegoing", IndustrialForegoingIntegration.class),
MEKANISM("mekanism", MekanismIntegration.class),
//REFINED_STORAGE("refinedstorage", RefinedStorageIntegration.class, false),
TECH_REBORN("techreborn", TechRebornIntegration.class),
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/mcmod.info
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"modId": "unidict",
"name": "UniDict",
"description": "a mod about unifying all the things.",
"version": "1.12.2-1.2",
"version": "1.12.2-1.3",
"mcversion": "${mcversion}",
"url": "http://minecraft.curseforge.com/projects/unidict",
"updateUrl": "",
Expand Down

0 comments on commit bec1fa1

Please sign in to comment.