Skip to content

Commit

Permalink
just a quick fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
WanionCane committed Jul 22, 2016
1 parent 1aa7771 commit 101e8ea
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 14 deletions.
1 change: 1 addition & 0 deletions src/main/java/wanion/unidict/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ private Config() {}
public static final Set<String> keepOneEntryModBlackSet = Collections.unmodifiableSet(Sets.newLinkedHashSet(Arrays.asList(config.getStringList("keepOneEntryModBlackList", general, new String[]{}, "mods listed here will be blacklisted in keepOneEntry.\nmust be the exact modID."))));
public static boolean autoHideInJEI;
public static final Set<String> hideInJEIBlackSet = Collections.unmodifiableSet(Sets.newLinkedHashSet(Arrays.asList(config.getStringList("autoHideInJEIBlackList", general, new String[]{"ore"}, "put here things that you don't want to hide in JEI.\nonly works if keepOneEntry is false."))));
public static final boolean kindDebugMode = config.getBoolean("kindDebugMode", general, false, "Enable this to keep track of all the kinds.\nthe output will be in logs folder.");
// resource related stuff
private static final String resources = "resources";
public static final boolean enableSpecificKindSort = config.getBoolean("enableSpecificKindSort", resources, false, "enabling this allow you to specify the \"owner\" of each kind.\nalso will make \"S:ownerOfEveryThing\" be ignored.");
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/wanion/unidict/UniOreDictionary.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
*/

import gnu.trove.map.TIntObjectMap;
import gnu.trove.map.hash.THashMap;
import gnu.trove.map.hash.TIntObjectHashMap;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
Expand All @@ -25,7 +24,7 @@
@SuppressWarnings("unused")
public final class UniOreDictionary implements IDependence
{
private final Map<List<ItemStack>, String> entryToName = new THashMap<>();
private final Map<List<ItemStack>, String> entryToName = new IdentityHashMap<>();
private final TIntObjectMap<String> stackToName = new TIntObjectHashMap<>();

private static Map<String, Integer> nameToId = Util.getField(OreDictionary.class, "nameToId", null, Map.class);
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 = MOD_ID;
public static final String MOD_VERSION = "1.10.2-1.4b";
public static final String MOD_VERSION = "1.10.2-1.4c";
public static final char SLASH = separatorChar;
public static final String MC_VERSION = "[1.10.2]";

Expand Down
16 changes: 8 additions & 8 deletions src/main/java/wanion/unidict/resource/UniResourceContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import wanion.unidict.common.SpecificKindItemStackComparator;
import wanion.unidict.common.Util;

import javax.annotation.Nonnull;
import java.util.*;

import static wanion.unidict.Config.*;
Expand All @@ -34,14 +35,20 @@ public final class UniResourceContainer
private int mainEntryMeta;
private int[] hashes;

public UniResourceContainer(String name, long kind)
public UniResourceContainer(@Nonnull final String name, final long kind)
{
if ((entries = UniOreDictionary.get(this.id = UniOreDictionary.getId(this.name = name))) == null)
throw new RuntimeException("Something may have broken the Ore Dictionary!");
this.kind = kind;
initialSize = entries.size();
}

public UniResourceContainer(@Nonnull final String name, final long kind, boolean sort)
{
this(name, kind);
setSort(sort);
}

public ItemStack getMainEntry()
{
return new ItemStack(mainEntryItem, 1, mainEntryMeta);
Expand Down Expand Up @@ -108,13 +115,6 @@ public Comparator<ItemStack> getComparator()
return enableSpecificKindSort ? SpecificKindItemStackComparator.getComparatorFor(kind) : Util.itemStackComparatorByModName;
}

public UniResourceContainer setSortAndGet(final boolean sort)
{
if (this.sort = sort)
sort();
return this;
}

void setSort(final boolean sort)
{
if (this.sort = sort)
Expand Down
23 changes: 21 additions & 2 deletions src/main/java/wanion/unidict/resource/UniResourceHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@
import wanion.unidict.UniOreDictionary;
import wanion.unidict.api.UniDictAPI;
import wanion.unidict.common.Dependencies;
import wanion.unidict.common.Reference;

import javax.annotation.Nonnull;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.*;
import java.util.regex.Pattern;

Expand Down Expand Up @@ -85,7 +90,7 @@ private void createResources()
patternBuilder.append(allTheResourceNamesIterator.next()).append(allTheResourceNamesIterator.hasNext() ? "|" : ")$");
final Map<String, Set<String>> basicResourceMap = new HashMap<>();
final Set<String> allTheKinds = new LinkedHashSet<>();
final Set<String> allTheKindsBlackSet = Sets.newHashSet("stair", "bars", "fence", "trapdoor", "stairs", "bucketLiquid", "slab", "crystal", "stick", "orePoor", "oreChargedCertus", "slabNether", "bucketDust", "oreCoralium", "gem", "sapling", "pulp", "item", "stone", "wood", "crop", "bottleLiquid", "quartz", "log", "mana", "chest", "crafter", "material", "leaves", "oreCertus", "crystalSHard", "eternalLife", "blockPrismarine", "Door", "Bells", "Arrow");
final Set<String> allTheKindsBlackSet = Sets.newHashSet("stair", "bars", "fence", "trapdoor", "stairs", "bucketLiquid", "slab", "crystal", "stick", "orePoor", "oreChargedCertus", "slabNether", "bucketDust", "oreCoralium", "gem", "sapling", "pulp", "item", "stone", "wood", "crop", "bottleLiquid", "quartz", "log", "mana", "chest", "crafter", "material", "leaves", "oreCertus", "crystalSHard", "eternalLife", "blockPrismarine", "door", "bells", "arrow", "itemCompressed", "enlightenedFused", "darkFused", "crystalShard", "food", "hardened");
UniOreDictionary.getThoseThatMatches(Pattern.compile(patternBuilder.toString())).forEach(matcher -> {
final String kindName = matcher.replaceFirst("");
if (!allTheKindsBlackSet.contains(kindName)) {
Expand All @@ -97,6 +102,20 @@ private void createResources()
}
});
allTheKinds.forEach(Resource::register);
if (Config.kindDebugMode) {
try (final BufferedWriter bw = new BufferedWriter(new FileWriter(new File("." + Reference.SLASH + "logs" + Reference.SLASH + "kindDebugLog.txt")))) {
allTheKinds.forEach(kind -> {
try {
bw.write(kind);
bw.newLine();
} catch (IOException e) {
e.printStackTrace();
}
});
} catch (IOException e) {
e.printStackTrace();
}
}
basicResourceMap.forEach((resourceName, kinds) -> {
final TLongObjectMap<UniResourceContainer> kindMap = new TLongObjectHashMap<>();
kinds.forEach(kindName -> {
Expand All @@ -112,7 +131,7 @@ private void createResources()
kinds.forEach(kindName -> {
final String oreDictName = kindName + resourceName;
if (OreDictionary.doesOreNameExist(oreDictName))
customResource.addChild(new UniResourceContainer(oreDictName, Resource.registerAndGet(kindName)).setSortAndGet(true));
customResource.addChild(new UniResourceContainer(oreDictName, Resource.registerAndGet(kindName), true));
});
if (!resourceMap.containsKey(resourceName) && customResource.getChildren() != 0)
resourceMap.put(resourceName, customResource);
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.4b",
"version": "1.4c",
"mcversion": "${mcversion}",
"url": "http://minecraft.curseforge.com/projects/unidict",
"updateUrl": "",
Expand Down

0 comments on commit 101e8ea

Please sign in to comment.