Fix rolling machine CT
This commit is contained in:
parent
610c2e479e
commit
23ccd878bd
2 changed files with 26 additions and 4 deletions
|
@ -26,6 +26,8 @@ package techreborn.compat.crafttweaker;
|
||||||
|
|
||||||
import crafttweaker.api.item.IIngredient;
|
import crafttweaker.api.item.IIngredient;
|
||||||
import crafttweaker.api.item.IItemStack;
|
import crafttweaker.api.item.IItemStack;
|
||||||
|
import gnu.trove.set.TCharSet;
|
||||||
|
import gnu.trove.set.hash.TCharHashSet;
|
||||||
import net.minecraft.item.crafting.IRecipe;
|
import net.minecraft.item.crafting.IRecipe;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import reborncore.common.util.ItemUtils;
|
import reborncore.common.util.ItemUtils;
|
||||||
|
@ -64,11 +66,15 @@ public class CTRollingMachine {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Stolen from https://github.com/jaredlll08/MTLib/blob/1.12/src/main/java/com/blamejared/mtlib/helpers/InputHelper.java#L170-L213
|
||||||
|
//License as seen here: https://github.com/jaredlll08/MTLib/blob/1.12/LICENSE.md (MIT at time of writing)
|
||||||
public static Object[] toShapedObjects(IIngredient[][] ingredients) {
|
public static Object[] toShapedObjects(IIngredient[][] ingredients) {
|
||||||
if (ingredients == null)
|
if (ingredients == null)
|
||||||
return null;
|
return null;
|
||||||
else {
|
else {
|
||||||
ArrayList<Object> prep = new ArrayList<Object>();
|
ArrayList<Object> prep = new ArrayList<>();
|
||||||
|
TCharSet usedCharSet = new TCharHashSet();
|
||||||
|
|
||||||
prep.add("abc");
|
prep.add("abc");
|
||||||
prep.add("def");
|
prep.add("def");
|
||||||
prep.add("ghi");
|
prep.add("ghi");
|
||||||
|
@ -78,11 +84,27 @@ public class CTRollingMachine {
|
||||||
for (int y = 0; y < ingredients[x].length; y++) {
|
for (int y = 0; y < ingredients[x].length; y++) {
|
||||||
if (ingredients[x][y] != null && x < map.length && y < map[x].length) {
|
if (ingredients[x][y] != null && x < map.length && y < map[x].length) {
|
||||||
prep.add(map[x][y]);
|
prep.add(map[x][y]);
|
||||||
|
usedCharSet.add(map[x][y]);
|
||||||
prep.add(CraftTweakerCompat.toObject(ingredients[x][y]));
|
prep.add(CraftTweakerCompat.toObject(ingredients[x][y]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
if (prep.get(i) instanceof String) {
|
||||||
|
String s = (String) prep.get(i);
|
||||||
|
for (int j = 0; j < 3; j++) {
|
||||||
|
char c = s.charAt(j);
|
||||||
|
if (usedCharSet.contains(c)) {
|
||||||
|
sb.append(c);
|
||||||
|
} else {
|
||||||
|
sb.append(" ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
prep.set(i, sb.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
return prep.toArray();
|
return prep.toArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,14 +45,14 @@ import static crafttweaker.api.minecraft.CraftTweakerMC.getLiquidStack;
|
||||||
public class CraftTweakerCompat implements ICompatModule {
|
public class CraftTweakerCompat implements ICompatModule {
|
||||||
public static ItemStack toStack(IItemStack iStack) {
|
public static ItemStack toStack(IItemStack iStack) {
|
||||||
if (iStack == null){
|
if (iStack == null){
|
||||||
return null;
|
return ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
return getItemStack(iStack);
|
return getItemStack(iStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object toObject(IIngredient iStack) {
|
public static Object toObject(IIngredient iStack) {
|
||||||
if (iStack == null)
|
if (iStack == null)
|
||||||
return null;
|
return ItemStack.EMPTY;
|
||||||
else {
|
else {
|
||||||
if (iStack instanceof IOreDictEntry)
|
if (iStack instanceof IOreDictEntry)
|
||||||
return ((IOreDictEntry) iStack).getName();
|
return ((IOreDictEntry) iStack).getName();
|
||||||
|
@ -62,7 +62,7 @@ public class CraftTweakerCompat implements ICompatModule {
|
||||||
IIngredient ingr = ReflectionHelper.getPrivateValue(IngredientStack.class, (IngredientStack) iStack, "ingredient");
|
IIngredient ingr = ReflectionHelper.getPrivateValue(IngredientStack.class, (IngredientStack) iStack, "ingredient");
|
||||||
return toObject(ingr);
|
return toObject(ingr);
|
||||||
} else
|
} else
|
||||||
return null;
|
return ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue