Pouches can be recolored with persistent inventories

You're welcome. That was a lot of thinking o_o

OreDict friendly as always.
This commit is contained in:
oitsjustjose 2015-12-15 00:11:38 -06:00
commit a6ad223c14
10 changed files with 159 additions and 17 deletions

View file

@ -13,7 +13,7 @@ buildscript{
apply plugin: 'net.minecraftforge.gradle.forge'
version = "1.3a"
version = "1.31"
group= "com.oitsjustjose.criss_cross"
archivesBaseName = "CrissCross-1.8.8"
@ -24,7 +24,7 @@ minecraft{
replaceIn "lib/Lib.java"
replace "@VERSION@", project.version
mappings = "snapshot_20151122"
mappings = "snapshot_20151214"
}
dependencies{

View file

@ -50,8 +50,7 @@ public class BlockScribe extends BlockMachineBase
if (!worldIn.isAirBlock(pos.add(i / 2, 0, j / 2)))
break;
worldIn.spawnParticle(EnumParticleTypes.ENCHANTMENT_TABLE, (double) pos.getX() + 0.5D, (double) pos.getY() + 2.0D, (double) pos.getZ() + 0.5D, (double) ((float) i + rand
.nextFloat()) - 0.5D, (double) ((float) k - rand.nextFloat() - 1.0F), (double) ((float) j + rand.nextFloat()) - 0.5D, new int[0]);
worldIn.spawnParticle(EnumParticleTypes.ENCHANTMENT_TABLE, (double) pos.getX() + 0.5D, (double) pos.getY() + 2.0D, (double) pos.getZ() + 0.5D, (double) ((float) i + rand.nextFloat()) - 0.5D, (double) ((float) k - rand.nextFloat() - 1.0F), (double) ((float) j + rand.nextFloat()) - 0.5D, new int[0]);
}
}
}

View file

@ -1,6 +1,5 @@
package com.oitsjustjose.criss_cross.container;
import com.oitsjustjose.criss_cross.tileentity.TileScribe;
import net.minecraft.entity.player.EntityPlayer;

View file

@ -72,7 +72,7 @@ public class GUIHandler implements IGuiHandler
return new ContainerScribe(player, TE);
}
if (player.getHeldItem() != null && player.getHeldItem().getItem() instanceof ItemPouch)
{
return new ContainerPouch(player, player.inventory.currentItem);

View file

@ -16,8 +16,7 @@ public class ConfigHandler
public static String cropomatorRecipeItem;
public static String[] cropomatorInputs;
public static String[] cropomatorCatalysts;
public static String[] defaultCropomatorInputs = new String[] { "minecraft:apple", "minecraft:reeds", "minecraft:nether_wart", "minecraft:carrot", "minecraft:cactus", "minecraft:potato", "minecraft:sapling:0", "minecraft:sapling:1", "minecraft:sapling:2", "minecraft:sapling:3", "minecraft:sapling:4", "minecraft:sapling:5", "minecraft:melon", "minecraft:brown_mushroom",
"minecraft:red_mushroom", "minecraft:dye:3", "minecraft:pumpkin", "minecraft:wheat", "minecraft:wheat_seeds" };
public static String[] defaultCropomatorInputs = new String[] { "minecraft:apple", "minecraft:reeds", "minecraft:nether_wart", "minecraft:carrot", "minecraft:cactus", "minecraft:potato", "minecraft:sapling:0", "minecraft:sapling:1", "minecraft:sapling:2", "minecraft:sapling:3", "minecraft:sapling:4", "minecraft:sapling:5", "minecraft:melon", "minecraft:brown_mushroom", "minecraft:red_mushroom", "minecraft:dye:3", "minecraft:pumpkin", "minecraft:wheat", "minecraft:wheat_seeds" };
public static String[] defaultCropomatorCatalystItems = new String[] { "minecraft:dye:15" };
public static int electroextractorProcessTime;
@ -68,8 +67,7 @@ public class ConfigHandler
electroextractorRecipeItem = config.getString("Electroextractor Crafting Item.", config.CATEGORY_GENERAL, "minecraft:diamond_block", "This is the item located in the center of the crafting recipe for the Electroextractor. Formatted as: <modid>:<item>:<meta> or <modid>:<item>.");
electroextractorOreDictInputs = config.get(config.CATEGORY_GENERAL, "Electroextractor OreDictionary Entries.", defaultElectroextractorOreDictInputs, "Formatted as <OreDictName>:<DecimalColorYouWant>." + "\n" + " Remove the 'ore' part of the oredict name (i.e. 'oreIron' should be entered as 'Iron')" + "\n"
+ "Use http://www.colorpicker.com/ to find a color and http://bit.ly/1RhPhcX to convert it from Hex to Decimal.").getStringList();
electroextractorOreDictInputs = config.get(config.CATEGORY_GENERAL, "Electroextractor OreDictionary Entries.", defaultElectroextractorOreDictInputs, "Formatted as <OreDictName>:<DecimalColorYouWant>." + "\n" + " Remove the 'ore' part of the oredict name (i.e. 'oreIron' should be entered as 'Iron')" + "\n" + "Use http://www.colorpicker.com/ to find a color and http://bit.ly/1RhPhcX to convert it from Hex to Decimal.").getStringList();
// Woodchipper's Configs
woodchipperFuels = config.get(config.CATEGORY_GENERAL, "Woodchipper Fuel Items", defaultWoodchipperFuels, "A list of items to be added as the Woodchipper's 'fuels'. Formatted as: <modid>:<item>:<meta> or <modid>:<item>.").getStringList();

View file

@ -14,7 +14,6 @@ public class Lib
public static final String clientProxy = "com.oitsjustjose.criss_cross.util.ClientProxy";
public static final String commonProxy = "com.oitsjustjose.criss_cross.util.CommonProxy";
private static final ArrayList<Item> allItems = new ArrayList<Item>();
private static final ArrayList<Block> allBlocks = new ArrayList<Block>();

View file

@ -27,7 +27,7 @@ public class LibItems
public static void init()
{
mkI = EnumHelper.addToolMaterial("mkI", 7, 6244, 8.0F, 1.0F, 10);
mkI.setRepairItem(new ItemStack(Blocks.emerald_block));
mkII = EnumHelper.addToolMaterial("mkII", 10, 1, 12.0F, 1.0F, 10);

View file

@ -45,7 +45,7 @@ public class CCMachineRecipes
TileStonegen.addFuel(new ItemStack(LibItems.buckets));
TileCobblegen.addFuel(new ItemStack(Items.water_bucket));
TileCobblegen.addFuel(new ItemStack(LibItems.buckets));
ElectroextractorRecipes.getInstance().addRecipe(new ItemStack(Blocks.diamond_ore), new ItemStack(Items.diamond, electroQTY));
ElectroextractorRecipes.getInstance().addRecipe(new ItemStack(Blocks.emerald_ore), new ItemStack(Items.emerald, electroQTY));
ElectroextractorRecipes.getInstance().addRecipe(new ItemStack(Blocks.coal_ore), new ItemStack(Items.coal, electroQTY));
@ -93,7 +93,7 @@ public class CCMachineRecipes
ScribeRecipes.getInstance().addRecipe(new ItemStack(Blocks.vine, 64), getEnchantedBook(Enchantment.thorns));
ScribeRecipes.getInstance().addRecipe(new ItemStack(Items.iron_ingot, 24), getEnchantedBook(Enchantment.unbreaking));
}
public static void initCropomatorRecipes()
{
for (int i = 0; i < ConfigHandler.cropomatorInputs.length; i++)
@ -348,10 +348,10 @@ public class CCMachineRecipes
{
ItemStack retBook = new ItemStack(Items.enchanted_book);
Items.enchanted_book.addEnchantment(retBook, new EnchantmentData(enchantment, 1));
return retBook;
}
static boolean doesOreNameExist(String oreName)
{
List<ItemStack> ores = OreDictionary.getOres(oreName);

View file

@ -0,0 +1,146 @@
package com.oitsjustjose.criss_cross.recipes;
import com.oitsjustjose.criss_cross.items.ItemPouch;
import net.minecraft.init.Items;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import net.minecraftforge.oredict.OreDictionary;
public class PouchColorRecipes implements IRecipe
{
@Override
public boolean matches(InventoryCrafting invCraft, World world)
{
boolean dyeItem = false;
boolean pouchItem = false;
for (int i = 0; i < invCraft.getSizeInventory(); i++)
{
ItemStack stack = invCraft.getStackInSlot(i);
if (stack != null)
if (stack.getItem() instanceof ItemPouch && !pouchItem)
pouchItem = true;
else if (isOreDictDye(stack) && !dyeItem)
dyeItem = true;
else
return false;
}
return pouchItem && dyeItem;
}
@Override
public ItemStack getCraftingResult(InventoryCrafting invCraft)
{
ItemStack pouch = null;
ItemStack dye = null;
ItemStack newPouch = null;
for (int i = 0; i < invCraft.getSizeInventory(); i++)
{
if (invCraft.getStackInSlot(i) != null)
{
if (invCraft.getStackInSlot(i).getItem() instanceof ItemPouch)
pouch = invCraft.getStackInSlot(i);
else if (isOreDictDye(invCraft.getStackInSlot(i)))
dye = invCraft.getStackInSlot(i);
}
}
if (pouch == null || dye == null)
return null;
newPouch = pouch.copy();
newPouch.setItemDamage(getDyeMetaFromString(getOreDictNameForDye(dye)));
return newPouch;
}
@Override
public int getRecipeSize()
{
return 10;
}
@Override
public ItemStack getRecipeOutput()
{
return null;
}
@Override
public ItemStack[] getRemainingItems(InventoryCrafting invCraft)
{
ItemStack[] ret = new ItemStack[9];
ItemStack stackToClear = null;
for (int i = 0; i < invCraft.getSizeInventory(); i++)
if (invCraft.getStackInSlot(i) != null)
if (!isOreDictDye(invCraft.getStackInSlot(i)) && !(invCraft.getStackInSlot(i).getItem() instanceof ItemPouch))
ret[i] = invCraft.getStackInSlot(i);
return ret;
}
boolean isOreDictDye(ItemStack itemstack)
{
int[] oreID = OreDictionary.getOreIDs(itemstack);
for (int x : oreID)
if (OreDictionary.getOreName(x).toLowerCase().contains("dye"))
return true;
return false;
}
String getOreDictNameForDye(ItemStack itemstack)
{
int[] oreID = OreDictionary.getOreIDs(itemstack);
for (int x : oreID)
if (OreDictionary.getOreName(x).toLowerCase().contains("dye"))
return OreDictionary.getOreName(x);
return "";
}
int getDyeMetaFromString(String string)
{
String s = string.toLowerCase();
if (s.contains("dyeblack"))
return 0;
else if (s.contains("dyered"))
return 1;
else if (s.contains("dyegreen"))
return 2;
else if (s.contains("dyebrown"))
return 3;
else if (s.contains("dyeblue"))
return 4;
else if (s.contains("dyepurple"))
return 5;
else if (s.contains("dyecyan"))
return 6;
else if (s.contains("dyelightgray"))
return 7;
else if (s.contains("dyegray"))
return 8;
else if (s.contains("dyepink"))
return 9;
else if (s.contains("dyelime"))
return 10;
else if (s.contains("dyeyellow"))
return 11;
else if (s.contains("dyelightblue"))
return 12;
else if (s.contains("dyemagenta"))
return 13;
else if (s.contains("dyeorange"))
return 14;
else if (s.contains("dyewhite"))
return 15;
else
return 0;
}
}

View file

@ -9,6 +9,7 @@ import com.oitsjustjose.criss_cross.util.ColorUtils;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.oredict.ShapedOreRecipe;
@ -20,9 +21,9 @@ public class VanillaRecipes
electroextractorRecipe();
woodChipperRecipe();
initOthers();
CraftingManager.getInstance().getRecipeList().add(new PouchColorRecipes());
}
static void initOthers()
{