Browse Source

add Construct Armory support, add JEI item hiding, add some other fixes

master
Adrian Siekierka 1 year ago
parent
commit
3766d57eeb

+ 10
- 6
build.gradle View File

@@ -13,7 +13,7 @@ buildscript {
apply plugin: 'net.minecraftforge.gradle.forge'
apply plugin: 'net.minecrell.licenser'
version = "0.1.1"
version = "0.2.0"
group = "pl.asie.tinkeredhegemony"
archivesBaseName = "TinkeredHegemony"
@@ -34,10 +34,10 @@ dependencies {
}
minecraft {
version = "1.12.2-14.23.3.2669"
version = "1.12.2-14.23.4.2712"
runDir = "run"
mappings = "snapshot_20180420"
mappings = "snapshot_20180624"
replace "\${version}", project.version
replace "\${mcversion}", version
@@ -51,6 +51,9 @@ repositories {
maven {
url "http://maven.blamejared.com/"
}
ivy {
artifactPattern "http://asie.pl/javadeps/[module]-[revision](-[classifier]).[ext]"
}
}
sourceSets {
@@ -71,10 +74,11 @@ license {
}
dependencies {
deobfCompile "CraftTweaker2:CraftTweaker2-MC1120-Main:1.12-4.1.6.457"
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.9.1.70"
deobfCompile "mezz.jei:jei_1.12.2:4.8.6.161"
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"
}
processResources {

+ 42
- 9
src/main/java/pl/asie/tinkeredhegemony/MaterialMatcher.java View File

@@ -40,26 +40,39 @@ public class MaterialMatcher {
materialMap.put(i, ImmutableSet.copyOf(materials));
}

private static Material get(Configuration config, String key, String name) {
name = config.getString(key, "materialMap", name, "");
private static Material find(String name) {
for (Material m : TinkerMaterials.materials) {
if (m.identifier.equals(name)) {
return m;
}
}

TinkeredHegemony.logger.warn("Could not find material '"+name+"'!");
return null;
}

public static void init(Configuration config) {
private static Material[] get(Configuration config, String key, String name) {
String[] names = config.getStringList(key, "materialMap", new String[] { name }, "Will match any material on this list for the head, or all materials if empty.");
Material[] materials = Arrays.stream(names).map(MaterialMatcher::find).filter(Objects::nonNull).toArray(Material[]::new);

if (config.hasChanged() && TinkeredHegemony.lastSave) {
config.save();
}

if (materials.length == 0) {
TinkeredHegemony.logger.warn("Could not find material '" + name + "'!");
}
return materials;
}

static void init(Configuration config) {
materialMap.clear();

Material woodLike = get(config, "wood", "wood");
Material stoneLike = get(config, "stone", "stone");
Material ironLike = get(config, "iron", "iron");
Material goldLike = get(config, "gold", "cobalt");
Material diamondLike = get(config, "diamond", "manyullyn");
Material[] woodLike = get(config, "wood", "wood");
Material[] stoneLike = get(config, "stone", "stone");
Material[] ironLike = get(config, "iron", "iron");
Material[] goldLike = get(config, "gold", "cobalt");
Material[] diamondLike = get(config, "diamond", "manyullyn");
Material[] leatherLike = get(config, "leather", "paper");

add(Items.WOODEN_AXE, woodLike);
add(Items.WOODEN_HOE, woodLike);
@@ -91,6 +104,26 @@ public class MaterialMatcher {
add(Items.DIAMOND_PICKAXE, diamondLike);
add(Items.DIAMOND_SHOVEL, diamondLike);
add(Items.DIAMOND_SWORD, diamondLike);

add(Items.LEATHER_HELMET, leatherLike);
add(Items.LEATHER_CHESTPLATE, leatherLike);
add(Items.LEATHER_LEGGINGS, leatherLike);
add(Items.LEATHER_BOOTS, leatherLike);

add(Items.IRON_HELMET, ironLike);
add(Items.IRON_CHESTPLATE, ironLike);
add(Items.IRON_LEGGINGS, ironLike);
add(Items.IRON_BOOTS, ironLike);

add(Items.GOLDEN_HELMET, goldLike);
add(Items.GOLDEN_CHESTPLATE, goldLike);
add(Items.GOLDEN_LEGGINGS, goldLike);
add(Items.GOLDEN_BOOTS, goldLike);

add(Items.DIAMOND_HELMET, goldLike);
add(Items.DIAMOND_CHESTPLATE, goldLike);
add(Items.DIAMOND_LEGGINGS, goldLike);
add(Items.DIAMOND_BOOTS, goldLike);
}

@Nullable

+ 1
- 0
src/main/java/pl/asie/tinkeredhegemony/RecipeDummy.java View File

@@ -39,6 +39,7 @@ public class RecipeDummy extends IForgeRegistryEntry.Impl<IRecipe> implements IR

@Override
public boolean isDynamic() {
// This also hides it from the recipe book!
return true;
}


+ 37
- 1
src/main/java/pl/asie/tinkeredhegemony/TinkeredHegemony.java View File

@@ -19,15 +19,23 @@

package pl.asie.tinkeredhegemony;

import c4.conarm.common.ConstructsRegistry;
import c4.conarm.common.items.armor.Boots;
import c4.conarm.common.items.armor.Chestplate;
import c4.conarm.common.items.armor.Helmet;
import c4.conarm.common.items.armor.Leggings;
import c4.conarm.lib.armor.ArmorCore;
import com.google.common.collect.Sets;
import gnu.trove.map.TObjectIntMap;
import gnu.trove.map.hash.TObjectIntHashMap;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.*;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
@@ -36,9 +44,11 @@ import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
import org.apache.logging.log4j.Logger;
import slimeknights.tconstruct.library.tinkering.ITinkerable;
import slimeknights.tconstruct.tools.TinkerTools;
import slimeknights.tconstruct.tools.harvest.TinkerHarvestTools;
import slimeknights.tconstruct.tools.melee.TinkerMeleeWeapons;
import slimeknights.tconstruct.tools.melee.item.BattleSign;
import slimeknights.tconstruct.tools.melee.item.BroadSword;
import slimeknights.tconstruct.tools.ranged.TinkerRangedWeapons;
import slimeknights.tconstruct.tools.ranged.item.ShortBow;
@@ -58,18 +68,29 @@ public class TinkeredHegemony {
protected static final Set<DisabledItemClass> classMap = new HashSet<>();
protected static final Set<Item> itemSet = new HashSet<>();

static boolean lastSave;

private boolean performRecipeReplacement, performRecipePatchwork, performItemDisabling, performItemNeutralizing;

private void addIfConfigured(DisabledItemClass disabledItemClass, boolean def) {
if (config.getBoolean("disable", disabledItemClass.getName(), def, "")) {
if (config.getBoolean(disabledItemClass.getName(), "disabledTypes", def, "")) {
classMap.add(disabledItemClass);
}
}

public static Configuration getConfig() {
return config;
}

public static Set<Item> getDisabledItems() {
return itemSet;
}

@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event) {
logger = event.getModLog();
config = new Configuration(event.getSuggestedConfigurationFile());
lastSave = false;

performItemDisabling = config.getBoolean("performItemDisabling", "general", true, "Should vanilla item recipes be removed?");
performItemNeutralizing = config.getBoolean("performItemNeutralizing", "general", true, "Should vanilla tool items be effectively nullified (maximum damage set to 1)?");
@@ -98,6 +119,11 @@ public class TinkeredHegemony {
addIfConfigured(new DisabledItemClass("hoe", (i) -> i instanceof ItemHoe, TinkerHarvestTools.mattock, Mattock.class, TinkerTools.axeHead, TinkerTools.shovelHead), true);
addIfConfigured(new DisabledItemClass("shovel", (i) -> i instanceof ItemSpade, TinkerHarvestTools.shovel, Shovel.class, TinkerTools.shovelHead), true);
addIfConfigured(new DisabledItemClass("bow", (i) -> i instanceof ItemBow, TinkerRangedWeapons.shortBow, ShortBow.class, TinkerTools.bowLimb), true);
addIfConfigured(new DisabledItemClass("shield", (i) -> i instanceof ItemShield, TinkerMeleeWeapons.battleSign, BattleSign.class, TinkerTools.signHead), false);

if (Loader.isModLoaded("conarm")) {
supportConarm();
}

MaterialMatcher.init(config);

@@ -106,6 +132,14 @@ public class TinkeredHegemony {
}
}

@net.minecraftforge.fml.common.Optional.Method(modid = "conarm")
private void supportConarm() {
addIfConfigured(new DisabledItemClass("helmet", (i) -> i instanceof ItemArmor && !(i instanceof ITinkerable) && ((ItemArmor) i).armorType == EntityEquipmentSlot.HEAD, ConstructsRegistry.helmet, Helmet.class, ConstructsRegistry.helmetCore), true);
addIfConfigured(new DisabledItemClass("chestplate", (i) -> i instanceof ItemArmor && !(i instanceof ITinkerable) && ((ItemArmor) i).armorType == EntityEquipmentSlot.CHEST, ConstructsRegistry.chestplate, Chestplate.class, ConstructsRegistry.chestCore), true);
addIfConfigured(new DisabledItemClass("leggings", (i) -> i instanceof ItemArmor && !(i instanceof ITinkerable) && ((ItemArmor) i).armorType == EntityEquipmentSlot.LEGS, ConstructsRegistry.leggings, Leggings.class, ConstructsRegistry.leggingsCore), true);
addIfConfigured(new DisabledItemClass("boots", (i) -> i instanceof ItemArmor && !(i instanceof ITinkerable) && ((ItemArmor) i).armorType == EntityEquipmentSlot.FEET, ConstructsRegistry.boots, Boots.class, ConstructsRegistry.bootsCore), true);
}

@Mod.EventHandler
public void postInit(FMLPostInitializationEvent event) {
itemSet.clear();
@@ -156,5 +190,7 @@ public class TinkeredHegemony {
if (config.hasChanged()) {
config.save();
}

lastSave = true;
}
}

+ 31
- 0
src/main/java/pl/asie/tinkeredhegemony/compat/TinkeredHegemonyJEIPlugin.java View File

@@ -0,0 +1,31 @@
package pl.asie.tinkeredhegemony.compat;

import mezz.jei.api.IModPlugin;
import mezz.jei.api.IModRegistry;
import mezz.jei.api.JEIPlugin;
import mezz.jei.api.ingredients.IIngredientBlacklist;
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;

@JEIPlugin
public class TinkeredHegemonyJEIPlugin implements IModPlugin {
@Override
public void register(IModRegistry registry) {
Configuration config = TinkeredHegemony.getConfig();

if (config.getBoolean("hideDisabledItems", "jei", true, "Should disabled items be hidden in JEI?")) {
IIngredientBlacklist blacklist = registry.getJeiHelpers().getIngredientBlacklist();

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

if (config.hasChanged()) {
config.save();
}
}
}

Loading…
Cancel
Save