Skip to content

Commit

Permalink
some improvements, added dustSmall to be Unified by default.
Browse files Browse the repository at this point in the history
  • Loading branch information
WanionCane committed Jul 26, 2016
1 parent 101e8ea commit 76f9cd1
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/main/java/wanion/unidict/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private Config() {}
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.");
public static final TObjectLongMap<String> ownerOfEveryThing = new TUnmodifiableObjectLongMap<>((!enableSpecificKindSort) ? getOwnerOfEveryThingMap() : new TObjectLongHashMap<>());
public static final Set<String> metalsToUnify = Collections.unmodifiableSet(Sets.newLinkedHashSet(Arrays.asList(config.getStringList("metalsToUnify", resources, new String[]{"Iron", "Gold", "Copper", "Tin", "Silver", "Lead", "Nickel", "Platinum", "Zinc", "Aluminium", "Aluminum", "Alumina", "Chrome", "Chromium", "Iridium", "Osmium", "Titanium", "Tungsten", "Bronze", "Steel", "Brass", "Invar", "Electrum", "Signalum", "Cupronickel"}, "list of things to do unifying things.\n"))));
public static final Set<String> childrenOfMetals = Collections.unmodifiableSet(Sets.newLinkedHashSet(Arrays.asList(config.getStringList("childrenOfMetals", resources, new String[]{"ore", "dustTiny", "chunk", "dust", "nugget", "ingot", "block", "plate", "gear", "rod"}, "what kind of child do you want to make a standard?\n"))));
public static final Set<String> childrenOfMetals = Collections.unmodifiableSet(Sets.newLinkedHashSet(Arrays.asList(config.getStringList("childrenOfMetals", resources, new String[]{"ore", "dustTiny", "dustSmall", "chunk", "dust", "nugget", "ingot", "block", "plate", "gear", "rod"}, "what kind of child do you want to make a standard?\n"))));
public static final List<String> resourceBlackList = Arrays.asList(config.getStringList("resourceBlackList", resources, new String[]{"Aluminium"}, "resources to be black-listed.\nthis exists to avoid duplicates.\nthis affect the API."));
public static final Map<String, Set<String>> customUnifiedResources = Collections.unmodifiableMap(getCustomUnifiedResourcesMap());
// modules
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/wanion/unidict/recipe/ForgeRecipeResearcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public List<Class<? extends ShapedOreRecipe>> getShapedRecipeClasses()
{
Class<? extends ShapedOreRecipe> shapedCustomRecipe = null;
try {
if (Loader.isModLoaded("forestry"))
if (Loader.isModLoaded("Forestry"))
shapedCustomRecipe = (Class<? extends ShapedOreRecipe>) Class.forName("forestry.core.recipes.ShapedRecipeCustom");
} catch (ClassNotFoundException e) { UniDict.getLogger().error(e); }
return shapedCustomRecipe == null ? Collections.singletonList(ShapedOreRecipe.class) : Arrays.asList(ShapedOreRecipe.class, shapedCustomRecipe);
Expand All @@ -68,7 +68,7 @@ public ShapedOreRecipe getNewShapedRecipe(@Nonnull final IRecipe recipe, @Nonnul
final Object[] newRecipeInputs = new Object[9];
for (int i = 0; i < 9; i++) {
final Object input = i < recipeInputs.length ? recipeInputs[i] : null;
final String bufferOreName = input != null ? uniOreDictionary.getName(input) : null;
final String bufferOreName = input != null ? input instanceof List ? uniOreDictionary.getName(input) : input instanceof ItemStack ? resourceHandler.getContainerName((ItemStack) input) : null : null;
newRecipeInputs[i] = input != null ? bufferOreName != null ? bufferOreName : input : null;
}
return new ShapedOreRecipe(resourceHandler.getMainItemStack(recipe.getRecipeOutput()), RecipeHelper.rawShapeToShape(newRecipeInputs));
Expand All @@ -83,7 +83,7 @@ public ShapedOreRecipe getNewShapedFromShapelessRecipe(@Nonnull final IRecipe re
final Object[] newRecipeInputs = new Object[recipeInputs.length];
for (int i = 0; i < recipeInputs.length; i++) {
final Object input = i < recipeInputs.length ? recipeInputs[i] : null;
final String bufferOreName = input != null ? uniOreDictionary.getName(input) : null;
final String bufferOreName = input != null ? input instanceof List ? uniOreDictionary.getName(input) : input instanceof ItemStack ? resourceHandler.getContainerName((ItemStack) input) : null : null;
newRecipeInputs[i] = input != null ? bufferOreName != null ? bufferOreName : input : null;
}
return new ShapedOreRecipe(resourceHandler.getMainItemStack(recipe.getRecipeOutput()), RecipeHelper.rawShapeToShape(newRecipeInputs));
Expand All @@ -97,7 +97,7 @@ public ShapelessOreRecipe getNewShapelessRecipe(@Nonnull final IRecipe recipe, @
final List<Object> inputs = new ArrayList<>();
((ShapelessOreRecipe) recipe).getInput().forEach(object -> {
if (object != null) {
final String bufferOreName = uniOreDictionary.getName(object);
final String bufferOreName = object instanceof List ? uniOreDictionary.getName(object) : object instanceof ItemStack ? resourceHandler.getContainerName((ItemStack) object) : null;
if (bufferOreName != null)
inputs.add(bufferOreName);
else if (object instanceof ItemStack)
Expand All @@ -115,7 +115,7 @@ public ShapelessOreRecipe getNewShapelessFromShapedRecipe(@Nonnull final IRecipe
final List<Object> inputs = new ArrayList<>();
for (Object object : ((ShapedOreRecipe) recipe).getInput()) {
if (object != null) {
final String bufferOreName = uniOreDictionary.getName(object);
final String bufferOreName = object instanceof List ? uniOreDictionary.getName(object) : object instanceof ItemStack ? resourceHandler.getContainerName((ItemStack) object) : null;
if (bufferOreName != null)
inputs.add(bufferOreName);
else if (object instanceof ItemStack)
Expand Down
11 changes: 7 additions & 4 deletions src/main/java/wanion/unidict/recipe/VanillaRecipeResearcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,13 @@ public ShapedOreRecipe getNewShapedRecipe(@Nonnull final IRecipe recipe, @Nonnul
{
final Object[] newRecipeInputs = new Object[9];
final ItemStack[] recipeInputs = ((ShapedRecipes) recipe).recipeItems;
for (int i = 0; i < 9; i++) {
final ItemStack input = i < recipeInputs.length ? recipeInputs[i] : null;
final String bufferOreName = resourceHandler.getContainerName(input);
newRecipeInputs[i] = input != null ? bufferOreName != null ? bufferOreName : input : null;
int i = 0;
for (int x = 0; x < ((ShapedRecipes) recipe).recipeWidth; x++) {
for (int y = 0; y < ((ShapedRecipes) recipe).recipeHeight; y++) {
final ItemStack input = recipeInputs[i++];
final String bufferOreName = resourceHandler.getContainerName(input);
newRecipeInputs[x * 3 + y] = bufferOreName != null ? bufferOreName : input;
}
}
return new ShapedOreRecipe(resourceHandler.getMainItemStack(recipe.getRecipeOutput()), RecipeHelper.rawShapeToShape(newRecipeInputs));
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/wanion/unidict/resource/ResourceHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,34 +92,34 @@ public ItemStack getMainItemStack(final ItemStack thing)
return (attributesOfThing != null) ? attributesOfThing.uniResourceContainer.getMainEntry(thing.stackSize) : thing;
}

public List<ItemStack> getMainItemStackList(final Collection<ItemStack> things)
public List<ItemStack> getMainItemStackList(@Nonnull final Collection<ItemStack> things)
{
return things.stream().map(this::getMainItemStack).collect(Collectors.toList());
}

public void setMainItemStacks(final List<ItemStack> thingList)
public void setMainItemStacks(@Nonnull final List<ItemStack> thingList)
{
final List<ItemStack> newThings = new ArrayList<>();
for (Iterator<ItemStack> thingListIterator = thingList.iterator(); thingListIterator.hasNext(); thingListIterator.remove())
newThings.add(getMainItemStack(thingListIterator.next()));
thingList.addAll(newThings);
}

public ItemStack[] getMainItemStacks(final ItemStack[] things)
public ItemStack[] getMainItemStacks(@Nonnull final ItemStack[] things)
{
for (int i = 0; i < things.length; i++)
things[i] = getMainItemStack(things[i]);
return things;
}

public void setMainItemStacks(final Object[] things)
public void setMainItemStacks(@Nonnull final Object[] things)
{
for (int i = 0; i < things.length; i++)
if (things[i] instanceof ItemStack)
things[i] = getMainItemStack((ItemStack) things[i]);
}

public boolean containerExists(final String name)
public boolean containerExists(@Nonnull final String name)
{
return containerMap.containsKey(name);
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/wanion/unidict/resource/UniAttributes.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

import javax.annotation.Nonnull;

class UniAttributes
{
final Resource resource;
final UniResourceContainer uniResourceContainer;

UniAttributes(Resource resource, UniResourceContainer uniResourceContainer)
UniAttributes(@Nonnull final Resource resource, @Nonnull final UniResourceContainer uniResourceContainer)
{
this.resource = resource;
this.uniResourceContainer = uniResourceContainer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public UniResourceContainer(@Nonnull final String name, final long kind)
initialSize = entries.size();
}

public UniResourceContainer(@Nonnull final String name, final long kind, boolean sort)
public UniResourceContainer(@Nonnull final String name, final long kind, final boolean sort)
{
this(name, kind);
setSort(sort);
Expand All @@ -54,7 +54,7 @@ public ItemStack getMainEntry()
return new ItemStack(mainEntryItem, 1, mainEntryMeta);
}

public ItemStack getMainEntry(int size)
public ItemStack getMainEntry(final int size)
{
return new ItemStack(mainEntryItem, size, mainEntryMeta);
}
Expand All @@ -72,7 +72,7 @@ boolean updateEntries()
return true;
if (sort && initialSize != entries.size())
sort();
ItemStack mainEntry = entries.get(0);
final ItemStack mainEntry = entries.get(0);
mainEntryMeta = (mainEntryItem = mainEntry.getItem()).getDamage(mainEntry);
if (sort) {
hashes = MetaItem.getArray(entries);
Expand Down

0 comments on commit 76f9cd1

Please sign in to comment.