mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-28 07:56:01 +00:00
First merging of weaponry into tinkers
This commit is contained in:
1 parent
6e1ea0e736
commit
73b25d19f0
191 files changed
+5325
-1
No files matched your search
@@ -0,0 +1,26 @@
|
||||
package boni.tinkersweaponry.items;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.tools.CustomMaterial;
|
||||
import tconstruct.library.tools.DynamicToolPart;
|
||||
|
||||
public class CustomToolPart extends WeaponryToolPart {
|
||||
private final Class<? extends CustomMaterial> customMat;
|
||||
|
||||
public CustomToolPart(String texture, String name, Class<? extends CustomMaterial> customMatClass) {
|
||||
super(texture, name);
|
||||
|
||||
this.customMat = customMatClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaterialID (ItemStack stack)
|
||||
{
|
||||
if(TConstructRegistry.getCustomMaterial(stack.getItemDamage(), customMat) != null)
|
||||
return stack.getItemDamage();
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
package boni.tinkersweaponry.items;
|
||||
|
||||
import boni.tinkersweaponry.TinkerWeaponry;
|
||||
import boni.tinkersweaponry.util.Reference;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.IIcon;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.tools.DynamicToolPart;
|
||||
import tconstruct.library.util.TextureHelper;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import tconstruct.util.config.PHConstruct;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class DualMaterialToolPart extends WeaponryToolPart {
|
||||
public IIcon defaultIcon2;
|
||||
public IIcon[] icons2;
|
||||
|
||||
public DualMaterialToolPart(String textureType, String name) {
|
||||
super(textureType, name);
|
||||
}
|
||||
|
||||
public static ItemStack createDualMaterial(Item item, int mat1, int mat2)
|
||||
{
|
||||
ItemStack stack = new ItemStack(item, 1, mat1);
|
||||
NBTTagCompound tags = new NBTTagCompound();
|
||||
NBTTagCompound subtag = new NBTTagCompound();
|
||||
subtag.setInteger("Material2", mat2);
|
||||
|
||||
tags.setTag("DualMat", subtag);
|
||||
stack.setTagCompound(tags);
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
public int getMaterialID2(ItemStack stack)
|
||||
{
|
||||
if(!stack.hasTagCompound())
|
||||
return -1;
|
||||
|
||||
int id = stack.getTagCompound().getCompoundTag("DualMat").getInteger("Material2");
|
||||
|
||||
if (TConstructRegistry.toolMaterials.keySet().contains(id))
|
||||
return id;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems (Item item, CreativeTabs tab, List list)
|
||||
{
|
||||
// material id == metadata
|
||||
for(Integer matID : TConstructRegistry.toolMaterials.keySet())
|
||||
list.add(createDualMaterial(item, matID, TinkerTools.MaterialID.Iron));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderPasses(int metadata) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresMultipleRenderPasses() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerIcons(IIconRegister iconRegister) {
|
||||
super.registerIcons(iconRegister);
|
||||
|
||||
// same as in super, secondary icon :I
|
||||
this.icons2 = new IIcon[icons.length];
|
||||
|
||||
// register icon for each material that has one
|
||||
if(!PHConstruct.minimalTextures)
|
||||
for(Map.Entry<Integer, tconstruct.library.tools.ToolMaterial> entry : TConstructRegistry.toolMaterials.entrySet())
|
||||
{
|
||||
String tex = modTexPrefix + ":" + folder + entry.getValue().materialName.toLowerCase() + texture + "_2";
|
||||
if(TextureHelper.itemTextureExists(tex))
|
||||
this.icons2[entry.getKey()] = iconRegister.registerIcon(tex);
|
||||
}
|
||||
|
||||
this.defaultIcon2 = iconRegister.registerIcon(modTexPrefix + ":" + folder + texture + "_2");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIconFromDamageForRenderPass(int meta, int pass) {
|
||||
// secondary item
|
||||
if(pass > 0) {
|
||||
if(meta > icons.length)
|
||||
return defaultIcon2;
|
||||
|
||||
if(icons2[meta] == null)
|
||||
return defaultIcon2;
|
||||
|
||||
return icons2[meta];
|
||||
}
|
||||
return super.getIconFromDamageForRenderPass(meta, pass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColorFromItemStack(ItemStack stack, int renderpass) {
|
||||
if(renderpass > 0)
|
||||
{
|
||||
int matId = getMaterialID2(stack);
|
||||
if(matId > icons2.length)
|
||||
return super.getColorFromItemStack(stack, renderpass);
|
||||
|
||||
if(icons[matId] == null)
|
||||
return TConstructRegistry.getMaterial(matId).primaryColor();
|
||||
|
||||
return super.getColorFromItemStack(stack, renderpass);
|
||||
}
|
||||
return super.getColorFromItemStack(stack, renderpass);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package boni.tinkersweaponry.items;
|
||||
|
||||
import boni.tinkersweaponry.util.Reference;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.crafting.PatternBuilder;
|
||||
import tconstruct.tools.items.Pattern;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class WeaponryPattern extends Pattern {
|
||||
private static final String[] patternName = new String[] { "shuriken", "crossbowlimb", "crossbowbody", "bowlimb" };
|
||||
|
||||
public WeaponryPattern(String patternType, String name) {
|
||||
super(patternName, getPatternNames(patternName, patternType), "patterns/");
|
||||
this.modTexPrefix = Reference.RESOURCE;
|
||||
|
||||
this.setUnlocalizedName(Reference.prefix(name));
|
||||
}
|
||||
|
||||
public static String[] getPatternNames (String[] patternName, String partType)
|
||||
{
|
||||
String[] names = new String[patternName.length];
|
||||
for (int i = 0; i < patternName.length; i++)
|
||||
names[i] = partType + patternName[i];
|
||||
return names;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems (Item b, CreativeTabs tab, List list)
|
||||
{
|
||||
for (int i = 0; i < patternName.length; i++)
|
||||
{
|
||||
// if (i != 23)
|
||||
list.add(new ItemStack(b, 1, i));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPatternCost(ItemStack pattern) {
|
||||
switch(pattern.getItemDamage())
|
||||
{
|
||||
case 0: return 1; // shuriken
|
||||
case 1: return 8; // crossbow limb
|
||||
case 2: return 10; // crossbow body
|
||||
case 3: return 3; // bowlimb
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package boni.tinkersweaponry.items;
|
||||
|
||||
import boni.tinkersweaponry.TinkerWeaponry;
|
||||
import boni.tinkersweaponry.util.Reference;
|
||||
import tconstruct.library.tools.DynamicToolPart;
|
||||
|
||||
public class WeaponryToolPart extends DynamicToolPart {
|
||||
public WeaponryToolPart(String textureType, String name) {
|
||||
super(textureType, name, Reference.RESOURCE);
|
||||
|
||||
this.setUnlocalizedName(Reference.prefix(name));
|
||||
this.setCreativeTab(TinkerWeaponry.creativeTab);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user