Browse Source

0.2.1

master
Adrian Siekierka 1 year ago
parent
commit
f6270e3505

+ 4
- 4
build.gradle View File

@@ -13,7 +13,7 @@ buildscript {
apply plugin: 'net.minecraftforge.gradle.forge'
apply plugin: 'net.minecrell.licenser'
version = "0.2.0"
version = "0.2.1"
group = "pl.asie.tinkeredhegemony"
archivesBaseName = "TinkeredHegemony"
@@ -34,7 +34,7 @@ dependencies {
}
minecraft {
version = "1.12.2-14.23.4.2712"
version = "1.12.2-14.23.5.2768"
runDir = "run"
mappings = "snapshot_20180624"
@@ -77,8 +77,8 @@ dependencies {
deobfCompile "CraftTweaker2:CraftTweaker2-MC1120-Main:1.12-4.1.6.467"
deobfCompile "slimeknights.mantle:Mantle:1.12-1.3.2.25"
deobfCompile "slimeknights:TConstruct:1.12.2-2.10.1.91"
deobfCompile "mezz.jei:jei_1.12.2:4.10.0.200"
deobfCompile name: "conarm", version: "1.12.2-1.0.0"
deobfCompile "mezz.jei:jei_1.12.2:4.13.1.220"
deobfCompile name: "conarm", version: "1.12.2-1.1.2"
}
processResources {

+ 1
- 0
docs/changelog/0.1.0.txt View File

@@ -0,0 +1 @@
Oh joy! A first release!

+ 3
- 0
docs/changelog/0.1.1.txt View File

@@ -0,0 +1,3 @@
* Add mod metadata (mcmod.info)
* Minor optimizations
* Add finer-grained configuration of the tweaks the mod performs

+ 6
- 0
docs/changelog/0.2.0.txt View File

@@ -0,0 +1,6 @@
PLEASE NOTE: YOU *MUST* REGENERATE tinkeredhegemony.cfg AFTER THIS UPDATE!

* Allowed setting multiple matching materials for each vanilla material type.
* Added replacing shields with battlesigns.
* Added Construct's Armory support (helmet, chestplate, leggings, boots).
* Added support for hiding disabled items in JEI.

+ 11
- 0
docs/changelog/0.2.1.txt View File

@@ -0,0 +1,11 @@
Additions:

* Hide all JEI recipes which output a disabled vanilla tool.
* Recipes which only take one in as input are not disabled by default.
They are often responsible for smelting, etc. You can force disabling
these with an additional configuration option.

Bugs fixed:

* Fix being able to create disabled vanilla tools from Tinkers' recipes.
* Fix crash with Construct's Armory armor recipe replacements.

+ 2
- 2
src/main/java/pl/asie/tinkeredhegemony/DisabledItemClass.java View File

@@ -83,8 +83,8 @@ public class DisabledItemClass {

public IngredientTinkerTool createIngredient(Collection<Material> materials) {
ImmutableSet.Builder<Pair<Material, IToolPart>> data = new ImmutableSet.Builder<>();
for (Material m : materials) {
for (IToolPart p : partsMaterialMatch) {
for (IToolPart p : partsMaterialMatch) {
for (Material m : materials) {
data.add(Pair.of(m, p));
}
}

+ 5
- 2
src/main/java/pl/asie/tinkeredhegemony/IngredientTinkerTool.java View File

@@ -58,9 +58,12 @@ public class IngredientTinkerTool extends Ingredient {
return false;
}

if (stack.getItem() instanceof TinkersItem && itemClass.isAssignableFrom(stack.getItem().getClass()) && stack.hasTagCompound()) {
if (itemClass.isAssignableFrom(stack.getItem().getClass()) && stack.hasTagCompound()) {
List<Material> materials = TinkerUtil.getMaterialsFromTagList(TagUtil.getBaseMaterialsTagList(stack));
List<PartMaterialType> components = ((TinkersItem) stack.getItem()).getRequiredComponents();
List<PartMaterialType> components = TinkerReflectionWrapper.getRequiredComponents(stack.getItem());
if (components.isEmpty()) {
return false;
}

Set<IToolPart> partsSeen = new HashSet<>();
Set<IToolPart> partsFound = new HashSet<>();

+ 14
- 2
src/main/java/pl/asie/tinkeredhegemony/RecipeTAPatchwork.java View File

@@ -67,7 +67,7 @@ public class RecipeTAPatchwork extends IForgeRegistryEntry.Impl<IRecipe> impleme

{
List<Material> materials = TinkerUtil.getMaterialsFromTagList(TagUtil.getBaseMaterialsTagList(s));
List<PartMaterialType> components = ((TinkersItem) s.getItem()).getRequiredComponents();
List<PartMaterialType> components = TinkerReflectionWrapper.getRequiredComponents(s.getItem());

if (components.size() <= materials.size()) {
for (int j = 0; j < components.size(); j++) {
@@ -115,7 +115,19 @@ public class RecipeTAPatchwork extends IForgeRegistryEntry.Impl<IRecipe> impleme
if (!(inv instanceof InventoryCraftingPatched)) {
InventoryCrafting invPatched = getInvPatched(inv);
if (invPatched != null) {
return CraftingManager.findMatchingRecipe(invPatched, worldIn) != null;
IRecipe recipe = CraftingManager.findMatchingRecipe(invPatched, worldIn);
if (recipe != null) {
ItemStack output = recipe.getCraftingResult(invPatched);
if (!output.isEmpty()) {
for (DisabledItemClass c : TinkeredHegemony.classMap) {
if (c.getItemPredicate().test(output.getItem())) {
return false;
}
}
}

return true;
}
}
}
return false;

+ 63
- 0
src/main/java/pl/asie/tinkeredhegemony/TinkerReflectionWrapper.java View File

@@ -0,0 +1,63 @@
/*
* Copyright (c) 2015, 2016, 2017, 2018 Adrian Siekierka
*
* This file is part of Tinkered Hegemony.
*
* Tinkered Hegemony is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Tinkered Hegemony is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Tinkered Hegemony. If not, see <http://www.gnu.org/licenses/>.
*/

package pl.asie.tinkeredhegemony;

import net.minecraft.item.Item;
import net.minecraftforge.fml.relauncher.ReflectionHelper;
import slimeknights.tconstruct.library.tinkering.PartMaterialType;
import slimeknights.tconstruct.library.tinkering.TinkersItem;

import java.lang.reflect.Method;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class TinkerReflectionWrapper {
private static final Map<Class, Method> rcMap = new HashMap<>();

public static List<PartMaterialType> getRequiredComponents(Item i) {
if (i instanceof TinkersItem) {
return ((TinkersItem) i).getRequiredComponents();
} else {
Method m = rcMap.computeIfAbsent(i.getClass(), (c) -> {
try {
//noinspection unchecked
return c.getMethod("getRequiredComponents");
} catch (NoSuchMethodException e) {
TinkeredHegemony.logger.warn("Could not find getRequiredComponents method for class " + i.getClass() + "! This is a bug!");
return null;
}
});

if (m != null) {
try {
//noinspection unchecked
return (List<PartMaterialType>) m.invoke(i);
} catch (Exception e) {
e.printStackTrace();
return Collections.emptyList();
}
} else {
return Collections.emptyList();
}
}
}
}

+ 62
- 1
src/main/java/pl/asie/tinkeredhegemony/compat/TinkeredHegemonyJEIPlugin.java View File

@@ -19,27 +19,52 @@

package pl.asie.tinkeredhegemony.compat;

import com.google.common.collect.Lists;
import mezz.jei.api.IJeiRuntime;
import mezz.jei.api.IModPlugin;
import mezz.jei.api.IModRegistry;
import mezz.jei.api.JEIPlugin;
import mezz.jei.api.ingredients.IIngredientBlacklist;
import mezz.jei.api.ingredients.IIngredientRegistry;
import mezz.jei.api.ingredients.VanillaTypes;
import mezz.jei.api.recipe.*;
import mezz.jei.plugins.vanilla.anvil.AnvilRecipeWrapper;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.oredict.OreDictionary;
import pl.asie.tinkeredhegemony.TinkeredHegemony;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;

@JEIPlugin
public class TinkeredHegemonyJEIPlugin implements IModPlugin {
private IIngredientRegistry ingredientRegistry;
private ArrayList<ItemStack> stacksToRemove;
private boolean disableInputRecipes, disableOutputRecipes;

@Override
public void register(IModRegistry registry) {
Configuration config = TinkeredHegemony.getConfig();

disableInputRecipes = config.getBoolean("hideInputRecipes", "jei", false,
"If hideDisabledItems is enabled, should recipes which take in the disabled tool as input also be disabled? (f.e. smelting)");

disableOutputRecipes = config.getBoolean("hideOutputRecipes", "jei", true,
"If hideDisabledItems is enabled, should recipes which take in the disabled tool as output also be disabled? (f.e. anvil)");

if (config.getBoolean("hideDisabledItems", "jei", true, "Should disabled items be hidden in JEI?")) {
IIngredientBlacklist blacklist = registry.getJeiHelpers().getIngredientBlacklist();
ingredientRegistry = registry.getIngredientRegistry();
stacksToRemove = new ArrayList<>();

for (Item i : TinkeredHegemony.getDisabledItems()) {
blacklist.addIngredientToBlacklist(new ItemStack(i, 1, OreDictionary.WILDCARD_VALUE));
ItemStack wildcard = new ItemStack(i, 1, OreDictionary.WILDCARD_VALUE);
blacklist.addIngredientToBlacklist(wildcard);
stacksToRemove.add(wildcard);
}
}

@@ -47,4 +72,40 @@ public class TinkeredHegemonyJEIPlugin implements IModPlugin {
config.save();
}
}

@Override
public void onRuntimeAvailable(IJeiRuntime jeiRuntime) {
if (ingredientRegistry != null && stacksToRemove != null && !stacksToRemove.isEmpty() && (disableInputRecipes || disableOutputRecipes)) {
for (IRecipeCategory category : Lists.newArrayList(jeiRuntime.getRecipeRegistry().getRecipeCategories())) {
for (ItemStack stack : stacksToRemove) {
if (disableOutputRecipes) {
IFocus<ItemStack> focusOutput = jeiRuntime.getRecipeRegistry().createFocus(IFocus.Mode.OUTPUT, stack);

try {
for (Object wrapperObj : jeiRuntime.getRecipeRegistry().getRecipeWrappers(category, focusOutput)) {
jeiRuntime.getRecipeRegistry().hideRecipe((IRecipeWrapper) wrapperObj, category.getUid());
}
} catch (Exception e) {
e.printStackTrace();
}
}

if (disableInputRecipes) {
IFocus<ItemStack> focusInput = jeiRuntime.getRecipeRegistry().createFocus(IFocus.Mode.INPUT, stack);

try {
for (Object wrapperObj : jeiRuntime.getRecipeRegistry().getRecipeWrappers(category, focusInput)) {
jeiRuntime.getRecipeRegistry().hideRecipe((IRecipeWrapper) wrapperObj, category.getUid());
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
}

ingredientRegistry = null;
stacksToRemove = null;
}
}

Loading…
Cancel
Save