Change how leaf fletchlings are handled to be more general. Basically ALL leaves can be used for leaf fletchlings now.

This commit is contained in:
Bernhard Bonigl committed 2014-08-23 11:28:56 +02:00
1 parent 1dd13c5a5f
commit 175352108e
5 files changed
+47 -38

No files matched your search

@@ -217,7 +217,7 @@ public class TConstructRegistry
* multiple times the parts are added to the recipe's input list Valid part
* amounts are 2, 3, and 4.
*
* @see ToolBuidler
* @see ToolBuilder
* @param output
* The ToolCore to craft
* @param parts
@@ -241,8 +241,6 @@ public class TConstructRegistry
*
* @param materialID
* Unique ID, stored for each part
* @exception materialID
* must be unique
* @param materialName
* Unique name for data lookup purposes
* @param harvestLevel
@@ -283,8 +281,6 @@ public class TConstructRegistry
*
* @param materialID
* Unique ID, stored for each part
* @exception materialID
* must be unique
* @param materialName
* Unique name for data lookup purposes
* @param displayName
@@ -327,8 +323,6 @@ public class TConstructRegistry
*
* @param materialID
* Unique ID, stored for each part
* @exception materialID
* must be unique
* @param material
* Complete tool material to add. Uses the name in the material
* for lookup purposes.
@@ -456,7 +450,7 @@ public class TConstructRegistry
{
for (CustomMaterial mat : customMaterials)
{
if (mat.getClass().equals(clazz) && input.isItemEqual(mat.input))
if (mat.getClass().equals(clazz) && mat.matches(input))
return mat;
}
return null;
@@ -15,4 +15,12 @@ public class FletchingMaterial extends CustomMaterial
this.breakChance = breakChance;
this.mass = mass;
}
public FletchingMaterial(int materialID, int value, String oredict, ItemStack craftingItem, float accuracy, float breakChance, float mass)
{
super(materialID, value, oredict, craftingItem);
this.accuracy = accuracy;
this.breakChance = breakChance;
this.mass = mass;
}
}
@@ -1,4 +1,34 @@
package tconstruct.library.tools;
public class FletchlingLeafMaterial {
import mantle.blocks.BlockUtils;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import tconstruct.tools.TinkerToolEvents;
public class FletchlingLeafMaterial extends FletchingMaterial {
public FletchlingLeafMaterial(int materialID, int value, String oredict, ItemStack craftingItem, float accuracy, float breakChance, float mass) {
super(materialID, value, oredict, craftingItem, accuracy, breakChance, mass);
}
@Override
public boolean matches(ItemStack stack) {
if(matchesLeaves(stack))
return true;
return super.matches(stack);
}
public static boolean matchesLeaves (ItemStack stack)
{
if (stack != null)
{
Block block = BlockUtils.getBlockFromItemStack(stack);
if (block != null)
{
if (block.isLeaves(null, 0, 0, 0))
return true;
}
}
return false;
}
}
@@ -25,12 +25,7 @@ import tconstruct.TConstruct;
import tconstruct.armor.player.TPlayerStats;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.event.*;
import tconstruct.library.tools.AbilityHelper;
import tconstruct.library.tools.ArrowMaterial;
import tconstruct.library.tools.BowMaterial;
import tconstruct.library.tools.BowstringMaterial;
import tconstruct.library.tools.FletchingMaterial;
import tconstruct.library.tools.ToolCore;
import tconstruct.library.tools.*;
import tconstruct.util.ItemHelper;
import tconstruct.util.config.PHConstruct;
import cpw.mods.fml.common.eventhandler.Event.Result;
@@ -222,33 +217,15 @@ public class TinkerToolEvents
public static ItemStack craftFletching (ItemStack stack)
{
if (matchesLeaves(stack))
{
FletchingMaterial leaves = (FletchingMaterial) TConstructRegistry.getCustomMaterial(new ItemStack(Blocks.leaves), FletchingMaterial.class);
return leaves.craftingItem.copy();
}
FletchingMaterial mat = (FletchingMaterial) TConstructRegistry.getCustomMaterial(stack, FletchingMaterial.class);
// maybe it's a leaf fletchling
if(mat == null)
mat = (FletchingMaterial) TConstructRegistry.getCustomMaterial(stack, FletchlingLeafMaterial.class);
if (mat != null)
return mat.craftingItem.copy();
return null;
}
public static boolean matchesLeaves (ItemStack stack)
{
if (stack != null)
{
Block block = BlockUtils.getBlockFromItemStack(stack);
if (block != null)
{
if (block.isLeaves(null, 0, 0, 0))
return true;
}
}
return false;
}
@SubscribeEvent
public void onAttack (LivingAttackEvent event)
@@ -44,6 +44,7 @@ import tconstruct.items.tools.Shovel;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.client.TConstructClientRegistry;
import tconstruct.library.crafting.*;
import tconstruct.library.tools.FletchlingLeafMaterial;
import tconstruct.library.tools.ToolCore;
import tconstruct.library.util.IPattern;
import tconstruct.modifiers.tools.ModAntiSpider;
@@ -877,8 +878,7 @@ public class TinkerTools
TConstructRegistry.addBowstringMaterial(0, 2, new ItemStack(Items.string), new ItemStack(TinkerTools.bowstring, 1, 0), 1F, 1F, 1f); // String
TConstructRegistry.addFletchingMaterial(0, 2, new ItemStack(Items.feather), new ItemStack(TinkerTools.fletching, 1, 0), 100F, 0F, 0.05F); // Feather
for (int i = 0; i < 4; i++)
TConstructRegistry.addFletchingMaterial(1, 2, new ItemStack(Blocks.leaves, 1, i), new ItemStack(TinkerTools.fletching, 1, 1), 75F, 0F, 0.2F); // All four vanialla Leaves
TConstructRegistry.addCustomMaterial(new FletchlingLeafMaterial(1, 2, "treeLeaves", new ItemStack(TinkerTools.fletching, 1, 1), 75F, 0F, 0.2F)); // all vanilla and oredicted leaves. and all leaves in general.
TConstructRegistry.addFletchingMaterial(2, 2, new ItemStack(TinkerTools.materials, 1, 1), new ItemStack(TinkerTools.fletching, 1, 2), 100F, 0F, 0.12F); // Slime
TConstructRegistry.addFletchingMaterial(3, 2, new ItemStack(TinkerTools.materials, 1, 17), new ItemStack(TinkerTools.fletching, 1, 3), 100F, 0F, 0.12F); // BlueSlime