Posted July 3, 201411 yr Hi everyone ! In my mod, I created a new flower, the cotton. You can use it to make an "armor" that you can dye later. When I created the mod with MCP, it was very easy, I used the func_150297_b. But now I use forge, It doesn't work. So, here is my forge class, the func_150297_b are in red: package com.hamsterfurtif.elisancecraft.armors; import com.hamsterfurtif.elisancecraft.ElisanceCraftMOD; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @SuppressWarnings("unused") public class ArmorCoton extends ItemArmor { private static final String[] Armor_Type = new String[] {"coton_helmet", "coton_chestplate", "coton_leggings", "coton_boots"}; public ArmorCoton(ArmorMaterial armorMaterial, int renderIndex, int armourType) { super(armorMaterial, renderIndex, armourType); } public String getArmorTexture(ItemStack stack, Entity entity, int slot, String layer) { if (stack.getItem().equals(ElisanceCraftMOD.coton_helmet) || stack.getItem().equals(ElisanceCraftMOD.coton_chestplate) || stack.getItem().equals(ElisanceCraftMOD.coton_boots)) { return "elisancecraft:textures/armors/coton_1.png"; } if (stack.getItem().equals(ElisanceCraftMOD.coton_leggings)) { return "elisancecraft:textures/armors/coton_2.png"; } else { return null; } } @Override public void registerIcons(IIconRegister reg) { if (this == ElisanceCraftMOD.coton_helmet) { this.itemIcon = reg.registerIcon("elisancecraft:coton_helmet"); } if (this == ElisanceCraftMOD.coton_chestplate) { this.itemIcon = reg.registerIcon("elisancecraft:coton_chestplate"); } if (this == ElisanceCraftMOD.coton_leggings) { this.itemIcon = reg.registerIcon("elisancecraft:coton_leggings"); } if (this == ElisanceCraftMOD.coton_boots) { this.itemIcon = reg.registerIcon("elisancecraft:coton_boots"); } } public int getColor(ItemStack par1ItemStack) { if (this.getArmorMaterial() != ElisanceCraftMOD.enumArmorMaterialCoton ) { return -1; } else { if (this.getArmorMaterial() == ElisanceCraftMOD.enumArmorMaterialCoton) { NBTTagCompound var2 = par1ItemStack.getTagCompound(); if (var2 == null) { return 16777215; } else { NBTTagCompound var3 = var2.getCompoundTag("display"); return var3 == null ? 10511680 : (var3.[color=red]func_150297_b[/color]("color", 3) ? var3.getInteger("color") : 16777215); } } } } public void func_82813_b(ItemStack par1ItemStack, int par2) { if (this.getArmorMaterial() != ItemArmor.ArmorMaterial.CLOTH && this.getArmorMaterial() != ElisanceCraftMOD.enumArmorMaterialCoton) { throw new UnsupportedOperationException("Can\'t dye non-leather!"); } else { NBTTagCompound var3 = par1ItemStack.getTagCompound(); if (var3 == null) { var3 = new NBTTagCompound(); par1ItemStack.setTagCompound(var3); } NBTTagCompound var4 = var3.getCompoundTag("display"); if (!var3.[color=red]func_150297_b[/color]("display", 10)) { var3.setTag("display", var4); } var4.setInteger("color", par2); } } } My second question is about flower Generation. It's about the cotton flower. I would like it to spawn in savanna biomes only, and I searched a lot but found nothing, so, if someone could explain me how to do, it would be great .
July 3, 201411 yr func_150297_b is hasKey if that helps _ ___ ___| |__ _ __ / __/ __| '_ \| '_ \ \__ \__ \ | | | | | | |___/___/_| |_|_| |_|
July 3, 201411 yr Author Well, I used hasKey, but the function didn't work. It asked for a(nother) return statement at the end. What I a supposed to do ? About the generation, here's all I've done: package com.hamsterfurtif.elisancecraft.gen; import java.util.Random; import com.hamsterfurtif.elisancecraft.ElisanceCraftMOD; import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenerator; public class WorldGenCoton extends WorldGenerator { private static final String __OBFID = "CL_00000189"; public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) { for (int var6 = 0; var6 < 10; ++var6) { int var7 = par3 + par2Random.nextInt( - par2Random.nextInt(; int var8 = par4 + par2Random.nextInt(4) - par2Random.nextInt(4); int var9 = par5 + par2Random.nextInt( - par2Random.nextInt(; if (ElisanceCraftMOD.coton_sauvage.canPlaceBlockAt(par1World, var7, var8, var9)) { par1World.setBlock(var7, var8, var9, ElisanceCraftMOD.coton_sauvage, 0, 2); } } return true; } } All the generation tutorials are about ores...
July 3, 201411 yr Author Well, I understood this : If the armor is not made of cotton, then the function will return -1, If the armor is made of cotton : var2 equals the Armor's TagCoumpound (And to be honest, I don't really know what it means. I think it's if the armor is colored or not, and if it is, what color.) If this Armor's TagCoumpound is null, th function will return the color 16777215. Else, var3 = var2.getCompoundTag("display"); and the function returns : if var3 is null the function returns 10511680 if var3 isn't null AND var3.hasKey("color", 3) is true, the function returns var3.getInteger("color") if var3 isn't null AND var3.hasKey("color", 3) if false, the function returns 16777215 Is all this right ?
July 3, 201411 yr Author Well, I suppose the method does not always return an int ? And I guess It's because var3 isn't null, so the issue is in this part : (var3.hasKey("color", 3) ? var3.getInteger("color") : 16777215) or in this one : NBTTagCompound var3 = var2.getCompoundTag("display"); If it is in the first part, it's because var3.hasKey("color", 3) is not true, and then the function returns var3.getInteger("color") which is not an int. So, the problem here is var3 ?
July 3, 201411 yr Author All the previous message was made to answer your question : <<Do you actually know what the error message means ?>> At the beginning of mine : <<I suppose the method does not always return an int>> Because I think that it want me to add a return statement to be sure the method will always return an Int. And if it want to be sure that the method always return an int, it's because it currently doesn't. This is the point of my previous message. If you're talking about the override thing, I just left it when I was doing a few test, that's all. I just suppressed it. About var3 : I did not created all this, I copied it from the original code : package net.minecraft.item; import java.util.List; import net.minecraft.block.BlockDispenser; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.command.IEntitySelector; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.dispenser.BehaviorDefaultDispenseItem; import net.minecraft.dispenser.IBehaviorDispenseItem; import net.minecraft.dispenser.IBlockSource; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.EnumFacing; import net.minecraft.util.IIcon; import net.minecraft.world.World; public class ItemArmor extends Item { /** Holds the 'base' maxDamage that each armorType have. */ private static final int[] maxDamageArray = new int[] {11, 16, 15, 13}; private static final String[] CLOTH_OVERLAY_NAMES = new String[] {"leather_helmet_overlay", "leather_chestplate_overlay", "leather_leggings_overlay", "leather_boots_overlay"}; public static final String[] EMPTY_SLOT_NAMES = new String[] {"empty_armor_slot_helmet", "empty_armor_slot_chestplate", "empty_armor_slot_leggings", "empty_armor_slot_boots"}; private static final IBehaviorDispenseItem dispenserBehavior = new BehaviorDefaultDispenseItem() { private static final String __OBFID = "CL_00001767"; protected ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) { EnumFacing var3 = BlockDispenser.func_149937_b(par1IBlockSource.getBlockMetadata()); int var4 = par1IBlockSource.getXInt() + var3.getFrontOffsetX(); int var5 = par1IBlockSource.getYInt() + var3.getFrontOffsetY(); int var6 = par1IBlockSource.getZInt() + var3.getFrontOffsetZ(); AxisAlignedBB var7 = AxisAlignedBB.getAABBPool().getAABB((double)var4, (double)var5, (double)var6, (double)(var4 + 1), (double)(var5 + 1), (double)(var6 + 1)); List var8 = par1IBlockSource.getWorld().selectEntitiesWithinAABB(EntityLivingBase.class, var7, new IEntitySelector.ArmoredMob(par2ItemStack)); if (var8.size() > 0) { EntityLivingBase var9 = (EntityLivingBase)var8.get(0); int var10 = var9 instanceof EntityPlayer ? 1 : 0; int var11 = EntityLiving.getArmorPosition(par2ItemStack); ItemStack var12 = par2ItemStack.copy(); var12.stackSize = 1; var9.setCurrentItemOrArmor(var11 - var10, var12); if (var9 instanceof EntityLiving) { ((EntityLiving)var9).setEquipmentDropChance(var11, 2.0F); } --par2ItemStack.stackSize; return par2ItemStack; } else { return super.dispenseStack(par1IBlockSource, par2ItemStack); } } }; /** * Stores the armor type: 0 is helmet, 1 is plate, 2 is legs and 3 is boots */ public final int armorType; /** Holds the amount of damage that the armor reduces at full durability. */ public final int damageReduceAmount; /** * Used on RenderPlayer to select the correspondent armor to be rendered on the player: 0 is cloth, 1 is chain, 2 is * iron, 3 is diamond and 4 is gold. */ public final int renderIndex; /** The EnumArmorMaterial used for this ItemArmor */ private final ItemArmor.ArmorMaterial material; private IIcon overlayIcon; private IIcon emptySlotIcon; private static final String __OBFID = "CL_00001766"; public ItemArmor(ItemArmor.ArmorMaterial p_i45325_1_, int p_i45325_2_, int p_i45325_3_) { this.material = p_i45325_1_; this.armorType = p_i45325_3_; this.renderIndex = p_i45325_2_; this.damageReduceAmount = p_i45325_1_.getDamageReductionAmount(p_i45325_3_); this.setMaxDamage(p_i45325_1_.getDurability(p_i45325_3_)); this.maxStackSize = 1; this.setCreativeTab(CreativeTabs.tabCombat); BlockDispenser.dispenseBehaviorRegistry.putObject(this, dispenserBehavior); } public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { if (par2 > 0) { return 16777215; } else { int var3 = this.getColor(par1ItemStack); if (var3 < 0) { var3 = 16777215; } return var3; } } public boolean requiresMultipleRenderPasses() { return this.material == ItemArmor.ArmorMaterial.CLOTH; } /** * Return the enchantability factor of the item, most of the time is based on material. */ public int getItemEnchantability() { return this.material.getEnchantability(); } /** * Return the armor material for this armor item. */ public ItemArmor.ArmorMaterial getArmorMaterial() { return this.material; } /** * Return whether the specified armor ItemStack has a color. */ public boolean hasColor(ItemStack par1ItemStack) { return this.material != ItemArmor.ArmorMaterial.CLOTH ? false : (!par1ItemStack.hasTagCompound() ? false : (!par1ItemStack.getTagCompound().func_150297_b("display", 10) ? false : par1ItemStack.getTagCompound().getCompoundTag("display").func_150297_b("color", 3))); } /** * Return the color for the specified armor ItemStack. */ //Permet de rendre le cuir marron par défaut, mais permet aussi la coloration public int getColor(ItemStack par1ItemStack) { if (this.material != ItemArmor.ArmorMaterial.COTON && this.material != ItemArmor.ArmorMaterial.CLOTH) { return -1; } else { if (this.material == ItemArmor.ArmorMaterial.COTON) { NBTTagCompound var2 = par1ItemStack.getTagCompound(); if (var2 == null) { return 16777215; } else { NBTTagCompound var3 = var2.getCompoundTag("display"); return var3 == null ? 10511680 : (var3.func_150297_b("color", 3) ? var3.getInteger("color") : 16777215); } } else { NBTTagCompound var2 = par1ItemStack.getTagCompound(); if (var2 == null) { return 10511680; } else { NBTTagCompound var3 = var2.getCompoundTag("display"); return var3 == null ? 10511680 : (var3.func_150297_b("color", 3) ? var3.getInteger("color") : 10511680); } } } } /** * Gets an icon index based on an item's damage value and the given render pass */ public IIcon getIconFromDamageForRenderPass(int par1, int par2) { return par2 == 1 ? this.overlayIcon : super.getIconFromDamageForRenderPass(par1, par2); } /** * Remove the color from the specified armor ItemStack. */ public void removeColor(ItemStack par1ItemStack) { if ( this.material == ItemArmor.ArmorMaterial.CLOTH ) { NBTTagCompound var2 = par1ItemStack.getTagCompound(); if (var2 != null) { NBTTagCompound var3 = var2.getCompoundTag("display"); if (var3.hasKey("color")) { var3.removeTag("color"); } } } } public void func_82813_b(ItemStack par1ItemStack, int par2) { if (this.material != ItemArmor.ArmorMaterial.CLOTH && this.material != ItemArmor.ArmorMaterial.COTON) { throw new UnsupportedOperationException("Can\'t dye non-leather!"); } else { NBTTagCompound var3 = par1ItemStack.getTagCompound(); if (var3 == null) { var3 = new NBTTagCompound(); par1ItemStack.setTagCompound(var3); } NBTTagCompound var4 = var3.getCompoundTag("display"); if (!var3.func_150297_b("display", 10)) { var3.setTag("display", var4); } var4.setInteger("color", par2); } } /** * Return whether this item is repairable in an anvil. */ public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { return this.material.func_151685_b() == par2ItemStack.getItem() ? true : super.getIsRepairable(par1ItemStack, par2ItemStack); } //Permet d'ajouter les Overlays (ne pas appliquer au coton) public void registerIcons(IIconRegister par1IconRegister) { super.registerIcons(par1IconRegister); if (this.material == ItemArmor.ArmorMaterial.CLOTH) { this.overlayIcon = par1IconRegister.registerIcon(CLOTH_OVERLAY_NAMES[this.armorType]); } this.emptySlotIcon = par1IconRegister.registerIcon(EMPTY_SLOT_NAMES[this.armorType]); } /** * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer */ public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { int var4 = EntityLiving.getArmorPosition(par1ItemStack) - 1; ItemStack var5 = par3EntityPlayer.getCurrentArmor(var4); if (var5 == null) { par3EntityPlayer.setCurrentItemOrArmor(var4, par1ItemStack.copy()); par1ItemStack.stackSize = 0; } return par1ItemStack; } public static IIcon func_94602_b(int par0) { switch (par0) { case 0: return Items.diamond_helmet.emptySlotIcon; case 1: return Items.diamond_chestplate.emptySlotIcon; case 2: return Items.diamond_leggings.emptySlotIcon; case 3: return Items.diamond_boots.emptySlotIcon; default: return null; } } public static enum ArmorMaterial { CLOTH("CLOTH", 0, 5, new int[]{1, 3, 2, 1}, 15), CHAIN("CHAIN", 1, 15, new int[]{2, 5, 4, 1}, 12), IRON("IRON", 2, 15, new int[]{2, 6, 5, 2}, 9), GOLD("GOLD", 3, 7, new int[]{2, 5, 3, 1}, 25), DIAMOND("DIAMOND", 4, 33, new int[]{3, 8, 6, 3}, 10), COTON("COTON",5, 5, new int[]{1, 3, 2, 1}, 15); private int maxDamageFactor; private int[] damageReductionAmountArray; private int enchantability; private static final ItemArmor.ArmorMaterial[] $VALUES = new ItemArmor.ArmorMaterial[]{CLOTH, CHAIN, IRON, GOLD, DIAMOND, COTON}; private static final String __OBFID = "CL_00001768"; private ArmorMaterial(String par1Str, int par2, int par3, int[] par4ArrayOfInteger, int par5) { this.maxDamageFactor = par3; this.damageReductionAmountArray = par4ArrayOfInteger; this.enchantability = par5; } public int getDurability(int par1) { return ItemArmor.maxDamageArray[par1] * this.maxDamageFactor; } public int getDamageReductionAmount(int par1) { return this.damageReductionAmountArray[par1]; } public int getEnchantability() { return this.enchantability; } public Item func_151685_b() { return this == CLOTH ? Items.leather : (this == CHAIN ? Items.iron_ingot : (this == GOLD ? Items.gold_ingot : (this == IRON ? Items.iron_ingot : (this == DIAMOND ? Items.diamond : (this == COTON ? Items.coton_fleur : null))))); } } } The vanilla version works very fine btw, so I don't know why I doesn't with Forge. And this is where var3 comes from. NBTTagCompound var3 = var2.getCompoundTag("display");
July 3, 201411 yr Author I checked what @Override does, but what does it have to do with this method ? Should I override or not ? And, what is wrong with my reasoning ?
July 3, 201411 yr Author Well, I think yes. I want to redefine superclass's method for my new class, so I have to Override. Isn't it the right thing to do ?
July 3, 201411 yr Author I want it to work not only with Leather but also with Cotton ! But it doesn't work, and I don't know why.
July 7, 201411 yr Author Oh ! My mistake. So here's the exact code I used in vanilla, and it's working : public int getColor(ItemStack par1ItemStack) { if (this.getArmorMaterial() != ElisanceCraftMOD.enumArmorMaterialCoton && this.getArmorMaterial() != ItemArmor.ArmorMaterial.CLOTH) { return -1; } else { if (this.getArmorMaterial() == ElisanceCraftMOD.enumArmorMaterialCoton) { NBTTagCompound var2 = par1ItemStack.getTagCompound(); if (var2 == null) { return 16777215; } else { NBTTagCompound var3 = var2.getCompoundTag("display"); return var3 == null ? 10511680 : (var3.hasKey("color", 3) ? var3.getInteger("color") : 16777215); } } else { NBTTagCompound var2 = par1ItemStack.getTagCompound(); if (var2 == null) { return 16777215; } else { NBTTagCompound var3 = var2.getCompoundTag("display"); return var3 == null ? 10511680 : (var3.hasKey("color", 3) ? var3.getInteger("color") : 16777215); } } } } But the cotton is still not dyeable. So I looked in vanilla codes and saw this : package net.minecraft.item.crafting; import java.util.ArrayList; import net.minecraft.block.BlockColored; import net.minecraft.entity.passive.EntitySheep; import net.minecraft.init.Items; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import net.minecraft.world.World; public class RecipesArmorDyes implements IRecipe { private static final String __OBFID = "CL_00000079"; /** * Used to check if a recipe matches current crafting inventory */ public boolean matches(InventoryCrafting par1InventoryCrafting, World par2World) { ItemStack var3 = null; ArrayList var4 = new ArrayList(); for (int var5 = 0; var5 < par1InventoryCrafting.getSizeInventory(); ++var5) { ItemStack var6 = par1InventoryCrafting.getStackInSlot(var5); if (var6 != null) { if (var6.getItem() instanceof ItemArmor) { ItemArmor var7 = (ItemArmor)var6.getItem(); if (var7.getArmorMaterial() != ItemArmor.ArmorMaterial.CLOTH && var7.getArmorMaterial() != ItemArmor.ArmorMaterial.COTON|| var3 != null) { return false; } var3 = var6; } else { if (var6.getItem() != Items.dye) { return false; } var4.add(var6); } } } return var3 != null && !var4.isEmpty(); } /** * Returns an Item that is the result of this recipe */ public ItemStack getCraftingResult(InventoryCrafting par1InventoryCrafting) { ItemStack var2 = null; int[] var3 = new int[3]; int var4 = 0; int var5 = 0; ItemArmor var6 = null; int var7; int var9; float var10; float var11; int var17; for (var7 = 0; var7 < par1InventoryCrafting.getSizeInventory(); ++var7) { ItemStack var8 = par1InventoryCrafting.getStackInSlot(var7); if (var8 != null) { if (var8.getItem() instanceof ItemArmor) { var6 = (ItemArmor)var8.getItem(); if (var6.getArmorMaterial() != ItemArmor.ArmorMaterial.CLOTH && var6.getArmorMaterial() != ItemArmor.ArmorMaterial.COTON|| var2 != null) { return null; } var2 = var8.copy(); var2.stackSize = 1; if (var6.getArmorMaterial() == ItemArmor.ArmorMaterial.CLOTH || var6.getArmorMaterial() == ItemArmor.ArmorMaterial.COTON) { if (var6.hasColor(var8)) { var9 = var6.getColor(var2); var10 = (float)(var9 >> 16 & 255) / 255.0F; var11 = (float)(var9 >> 8 & 255) / 255.0F; float var12 = (float)(var9 & 255) / 255.0F; var4 = (int)((float)var4 + Math.max(var10, Math.max(var11, var12)) * 255.0F); var3[0] = (int)((float)var3[0] + var10 * 255.0F); var3[1] = (int)((float)var3[1] + var11 * 255.0F); var3[2] = (int)((float)var3[2] + var12 * 255.0F); ++var5; } } } else { if (var8.getItem() != Items.dye) { return null; } float[] var14 = EntitySheep.fleeceColorTable[blockColored.func_150032_b(var8.getItemDamage())]; int var15 = (int)(var14[0] * 255.0F); int var16 = (int)(var14[1] * 255.0F); var17 = (int)(var14[2] * 255.0F); var4 += Math.max(var15, Math.max(var16, var17)); var3[0] += var15; var3[1] += var16; var3[2] += var17; ++var5; } } } if (var6 == null) { return null; } else { var7 = var3[0] / var5; int var13 = var3[1] / var5; var9 = var3[2] / var5; var10 = (float)var4 / (float)var5; var11 = (float)Math.max(var7, Math.max(var13, var9)); var7 = (int)((float)var7 * var10 / var11); var13 = (int)((float)var13 * var10 / var11); var9 = (int)((float)var9 * var10 / var11); var17 = (var7 << + var13; var17 = (var17 << + var9; var6.func_82813_b(var2, var17); return var2; } } /** * Returns the size of the recipe area */ public int getRecipeSize() { return 10; } public ItemStack getRecipeOutput() { return null; } } So, what should I do ? Should I create a new class that extends RecipesArmorDyes ? Or should I create a new class that implements IRecipie, and with the same content ?
July 7, 201411 yr Author So, here's what I've done : package com.hamsterfurtif.elisancecraft.armors; import java.util.ArrayList; import com.hamsterfurtif.elisancecraft.ElisanceCraftMOD; import net.minecraft.block.BlockColored; import net.minecraft.entity.passive.EntitySheep; import net.minecraft.init.Items; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.RecipesArmorDyes; import net.minecraft.world.World; public class ArmorDye extends RecipesArmorDyes { /** * Used to check if a recipe matches current crafting inventory */ @Override public boolean matches(InventoryCrafting par1InventoryCrafting, World par2World) { ItemStack var3 = null; ArrayList<ItemStack> var4 = new ArrayList<ItemStack>(); for (int var5 = 0; var5 < par1InventoryCrafting.getSizeInventory(); ++var5) { ItemStack var6 = par1InventoryCrafting.getStackInSlot(var5); if (var6 != null) { if (var6.getItem() instanceof ItemArmor) { ItemArmor var7 = (ItemArmor)var6.getItem(); if (var7.getArmorMaterial() != ElisanceCraftMOD.enumArmorMaterialCoton || var3 != null) { return false; } var3 = var6; } else { if (var6.getItem() != Items.dye) { return false; } var4.add(var6); } } } return var3 != null && !var4.isEmpty(); } /** * Returns an Item that is the result of this recipe */ @Override public ItemStack getCraftingResult(InventoryCrafting par1InventoryCrafting) { ItemStack var2 = null; int[] var3 = new int[3]; int var4 = 0; int var5 = 0; ItemArmor var6 = null; int var7; int var9; float var10; float var11; int var17; for (var7 = 0; var7 < par1InventoryCrafting.getSizeInventory(); ++var7) { ItemStack var8 = par1InventoryCrafting.getStackInSlot(var7); if (var8 != null) { if (var8.getItem() instanceof ItemArmor) { var6 = (ItemArmor)var8.getItem(); if ( var6.getArmorMaterial() != ElisanceCraftMOD.enumArmorMaterialCoton || var2 != null) { return null; } var2 = var8.copy(); var2.stackSize = 1; if (var6.getArmorMaterial() == ElisanceCraftMOD.enumArmorMaterialCoton ) { if (var6.hasColor(var8)) { var9 = var6.getColor(var2); var10 = (float)(var9 >> 16 & 255) / 255.0F; var11 = (float)(var9 >> 8 & 255) / 255.0F; float var12 = (float)(var9 & 255) / 255.0F; var4 = (int)((float)var4 + Math.max(var10, Math.max(var11, var12)) * 255.0F); var3[0] = (int)((float)var3[0] + var10 * 255.0F); var3[1] = (int)((float)var3[1] + var11 * 255.0F); var3[2] = (int)((float)var3[2] + var12 * 255.0F); ++var5; } } } else { if (var8.getItem() != Items.dye) { return null; } float[] var14 = EntitySheep.fleeceColorTable[blockColored.func_150032_b(var8.getItemDamage())]; int var15 = (int)(var14[0] * 255.0F); int var16 = (int)(var14[1] * 255.0F); var17 = (int)(var14[2] * 255.0F); var4 += Math.max(var15, Math.max(var16, var17)); var3[0] += var15; var3[1] += var16; var3[2] += var17; ++var5; } } } if (var6 == null) { return null; } else { var7 = var3[0] / var5; int var13 = var3[1] / var5; var9 = var3[2] / var5; var10 = (float)var4 / (float)var5; var11 = (float)Math.max(var7, Math.max(var13, var9)); var7 = (int)((float)var7 * var10 / var11); var13 = (int)((float)var13 * var10 / var11); var9 = (int)((float)var9 * var10 / var11); var17 = (var7 << + var13; var17 = (var17 << + var9; var6.func_82813_b(var2, var17); return var2; } } /** * Returns the size of the recipe area */ @Override public int getRecipeSize() { return 10; } @Override public ItemStack getRecipeOutput() { return null; } } But it's not working. It's more or like the same as the vanilla obe : package net.minecraft.item.crafting; import java.util.ArrayList; import net.minecraft.block.BlockColored; import net.minecraft.entity.passive.EntitySheep; import net.minecraft.init.Items; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import net.minecraft.world.World; public class RecipesArmorDyes implements IRecipe { private static final String __OBFID = "CL_00000079"; /** * Used to check if a recipe matches current crafting inventory */ public boolean matches(InventoryCrafting par1InventoryCrafting, World par2World) { ItemStack var3 = null; ArrayList var4 = new ArrayList(); for (int var5 = 0; var5 < par1InventoryCrafting.getSizeInventory(); ++var5) { ItemStack var6 = par1InventoryCrafting.getStackInSlot(var5); if (var6 != null) { if (var6.getItem() instanceof ItemArmor) { ItemArmor var7 = (ItemArmor)var6.getItem(); if (var7.getArmorMaterial() != ItemArmor.ArmorMaterial.CLOTH && var7.getArmorMaterial() != ItemArmor.ArmorMaterial.COTON|| var3 != null) { return false; } var3 = var6; } else { if (var6.getItem() != Items.dye) { return false; } var4.add(var6); } } } return var3 != null && !var4.isEmpty(); } /** * Returns an Item that is the result of this recipe */ public ItemStack getCraftingResult(InventoryCrafting par1InventoryCrafting) { ItemStack var2 = null; int[] var3 = new int[3]; int var4 = 0; int var5 = 0; ItemArmor var6 = null; int var7; int var9; float var10; float var11; int var17; for (var7 = 0; var7 < par1InventoryCrafting.getSizeInventory(); ++var7) { ItemStack var8 = par1InventoryCrafting.getStackInSlot(var7); if (var8 != null) { if (var8.getItem() instanceof ItemArmor) { var6 = (ItemArmor)var8.getItem(); if (var6.getArmorMaterial() != ItemArmor.ArmorMaterial.CLOTH && var6.getArmorMaterial() != ItemArmor.ArmorMaterial.COTON|| var2 != null) { return null; } var2 = var8.copy(); var2.stackSize = 1; if (var6.getArmorMaterial() == ItemArmor.ArmorMaterial.CLOTH || var6.getArmorMaterial() == ItemArmor.ArmorMaterial.COTON) { if (var6.hasColor(var8)) { var9 = var6.getColor(var2); var10 = (float)(var9 >> 16 & 255) / 255.0F; var11 = (float)(var9 >> 8 & 255) / 255.0F; float var12 = (float)(var9 & 255) / 255.0F; var4 = (int)((float)var4 + Math.max(var10, Math.max(var11, var12)) * 255.0F); var3[0] = (int)((float)var3[0] + var10 * 255.0F); var3[1] = (int)((float)var3[1] + var11 * 255.0F); var3[2] = (int)((float)var3[2] + var12 * 255.0F); ++var5; } } } else { if (var8.getItem() != Items.dye) { return null; } float[] var14 = EntitySheep.fleeceColorTable[blockColored.func_150032_b(var8.getItemDamage())]; int var15 = (int)(var14[0] * 255.0F); int var16 = (int)(var14[1] * 255.0F); var17 = (int)(var14[2] * 255.0F); var4 += Math.max(var15, Math.max(var16, var17)); var3[0] += var15; var3[1] += var16; var3[2] += var17; ++var5; } } } if (var6 == null) { return null; } else { var7 = var3[0] / var5; int var13 = var3[1] / var5; var9 = var3[2] / var5; var10 = (float)var4 / (float)var5; var11 = (float)Math.max(var7, Math.max(var13, var9)); var7 = (int)((float)var7 * var10 / var11); var13 = (int)((float)var13 * var10 / var11); var9 = (int)((float)var9 * var10 / var11); var17 = (var7 << + var13; var17 = (var17 << + var9; var6.func_82813_b(var2, var17); return var2; } } /** * Returns the size of the recipe area */ public int getRecipeSize() { return 10; } public ItemStack getRecipeOutput() { return null; } }
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.