Give ToolShards the DynamicToolPart treatment

This commit is contained in:
Bernhard Bonigl committed 2014-10-18 17:02:43 +02:00
1 parent 5a5b05d1c7
commit 9672f95efc
4 files changed
+53 -55

No files matched your search

@@ -220,6 +220,7 @@ public class TConstructRegistry
public static HashMap<Integer, ToolMaterial> toolMaterials = new HashMap<Integer, ToolMaterial>(40);
public static HashMap<String, ToolMaterial> toolMaterialStrings = new HashMap<String, ToolMaterial>(40);
public static List<Integer> defaultToolPartMaterials = new LinkedList<Integer>();
public static List<Integer> defaultShardMaterials = new LinkedList<Integer>();
public static void addDefaultToolPartMaterial(int materialID)
{
@@ -229,6 +230,14 @@ public class TConstructRegistry
defaultToolPartMaterials.add(materialID);
}
public static void addDefaultShardMaterial(int materialID)
{
if(!toolMaterials.containsKey(materialID))
logger.error("[TCon API] Can't add default shard: Material ID " + materialID + " is unknown.");
else
defaultShardMaterials.add(materialID);
}
/**
* Adds a tool material to the registry
*
@@ -171,7 +171,7 @@ public class TinkerTools
TinkerTools.materials = new MaterialItem().setUnlocalizedName("tconstruct.Materials");
TinkerTools.toolRod = new DynamicToolPart("_rod", "ToolRod");
TinkerTools.toolShard = new ToolShard("_chunk").setUnlocalizedName("tconstruct.ToolShard");
TinkerTools.toolShard = new ToolShard("_chunk", "ToolShard");
TinkerTools.woodPattern = new Pattern("pattern_", "materials/").setUnlocalizedName("tconstruct.Pattern");
GameRegistry.registerItem(TinkerTools.materials, "materials");
GameRegistry.registerItem(TinkerTools.woodPattern, "woodPattern");
@@ -698,6 +698,9 @@ public class TinkerTools
TConstructRegistry.addBowstringMaterial(1, 2, new ItemStack((Item) obj, 1, 7), new ItemStack(TinkerTools.bowstring, 1, 1), 1F, 1F, 0.9f, 0x63bcd9);
TConstructRegistry.addBowMaterial(31, 576, 40, 1.2f);
TConstructRegistry.addArrowMaterial(31, 1.8F, 0.5F, 100F);
TConstructRegistry.addDefaultToolPartMaterial(MaterialID.Thaumium);
TConstructRegistry.addDefaultShardMaterial(MaterialID.Thaumium);
}
else
{
@@ -809,6 +812,31 @@ public class TinkerTools
TConstructRegistry.addDefaultToolPartMaterial(MaterialID.BlueSlime );
TConstructRegistry.addDefaultToolPartMaterial(MaterialID.PigIron);
// Register all the materials for default toolparts
//TConstructRegistry.addDefaultShardMaterial(MaterialID.Wood);
TConstructRegistry.addDefaultShardMaterial(MaterialID.Stone);
TConstructRegistry.addDefaultShardMaterial(MaterialID.Flint);
TConstructRegistry.addDefaultShardMaterial(MaterialID.Cactus);
//TConstructRegistry.addDefaultShardMaterial(MaterialID.Bone);
TConstructRegistry.addDefaultShardMaterial(MaterialID.Obsidian);
TConstructRegistry.addDefaultShardMaterial(MaterialID.Netherrack);
TConstructRegistry.addDefaultShardMaterial(MaterialID.Slime);
//TConstructRegistry.addDefaultShardMaterial(MaterialID.Paper);
TConstructRegistry.addDefaultShardMaterial(MaterialID.BlueSlime );
if(PHConstruct.craftMetalTools)
{
TConstructRegistry.addDefaultShardMaterial(MaterialID.Iron);
TConstructRegistry.addDefaultShardMaterial(MaterialID.Cobalt);
TConstructRegistry.addDefaultShardMaterial(MaterialID.Ardite);
TConstructRegistry.addDefaultShardMaterial(MaterialID.Manyullyn);
TConstructRegistry.addDefaultShardMaterial(MaterialID.Copper);
TConstructRegistry.addDefaultShardMaterial(MaterialID.Bronze);
TConstructRegistry.addDefaultShardMaterial(MaterialID.Alumite);
TConstructRegistry.addDefaultShardMaterial(MaterialID.Steel);
TConstructRegistry.addDefaultShardMaterial(MaterialID.PigIron);
}
PatternBuilder pb = PatternBuilder.instance;
if (PHConstruct.enableTWood)
pb.registerFullMaterial(Blocks.planks, 2, "Wood", new ItemStack(Items.stick), new ItemStack(Items.stick), 0);
@@ -1,68 +1,29 @@
package tconstruct.tools.items;
import cpw.mods.fml.relauncher.*;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.*;
import net.minecraft.util.IIcon;
import tconstruct.tools.TinkerTools;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.tools.DynamicToolPart;
public class ToolShard extends ToolPart
import java.util.List;
public class ToolShard extends DynamicToolPart
{
public ToolShard(String tex)
public ToolShard(String tex, String name)
{
super(tex, "ToolShard");
this.setHasSubtypes(true);
this.setMaxDamage(0);
}
private static String[] buildTextureNames (String textureType)
{
String[] names = new String[toolMaterialNames.length];
for (int i = 0; i < toolMaterialNames.length; i++)
{
if (!toolTextureNames[i].equals(""))
names[i] = toolTextureNames[i] + textureType;
}
return names;
super(tex, name);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons (IIconRegister iconRegister)
public void getSubItems (Item item, CreativeTabs tab, List list)
{
this.icons = new IIcon[textureNames.length];
for (int i = 0; i < 5; ++i)
{
this.icons[i] = iconRegister.registerIcon("tinker:" + folder + textureNames[i]);
// material id == metadata
for(Integer matID : TConstructRegistry.defaultShardMaterials) {
ItemStack stack = new ItemStack(item, 1, matID);
if (this.getMaterialID(stack) != -1)
list.add(stack);
}
icons[5] = icons[4];
for (int i = 6; i < 9; ++i)
{
this.icons[i] = iconRegister.registerIcon("tinker:" + folder + textureNames[i]);
}
icons[9] = icons[8];
for (int i = 10; i < icons.length; ++i)
{
if (!toolTextureNames[i].equals(""))
this.icons[i] = iconRegister.registerIcon("tinker:" + folder + textureNames[i]);
}
}
@Override
public void getSubItems (Item b, CreativeTabs tab, List list)
{
for (int i = 1; i < 5; i++)
list.add(new ItemStack(b, 1, i));
for (int i = 6; i < 9; i++)
list.add(new ItemStack(b, 1, i));
for (int i = 10; i < 19; i++)
list.add(new ItemStack(b, 1, i));
if (TinkerTools.thaumcraftAvailable)
list.add(new ItemStack(b, 1, 31));
}
}