mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-26 15:03:01 +00:00
1.6.2 test - Finished liquids, added connected textures on glass
This commit is contained in:
1 parent
40c6f445a2
commit
a80fcbce86
704 files changed
+60909
No files matched your search
@@ -0,0 +1,227 @@
|
||||
package tconstruct.items.tools;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.library.crafting.ToolBuilder;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class Arrow extends ToolCore
|
||||
{
|
||||
|
||||
public Arrow(int id)
|
||||
{
|
||||
super(id, 3);
|
||||
this.setUnlocalizedName("InfiTool.Arrow");
|
||||
this.setMaxStackSize(64);
|
||||
this.setMaxDamage(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIconSuffix (int partType)
|
||||
{
|
||||
switch (partType)
|
||||
{
|
||||
case 0:
|
||||
return "_arrow_head";
|
||||
case 1:
|
||||
return ""; //Doesn't break
|
||||
case 2:
|
||||
return "_arrow_shaft";
|
||||
case 3:
|
||||
return "_arrow_fletching";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEffectSuffix ()
|
||||
{
|
||||
return "_arrow_effect";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultFolder ()
|
||||
{
|
||||
return "arrow";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerPartPaths (int index, String[] location)
|
||||
{
|
||||
headStrings.put(index, location[0]);
|
||||
handleStrings.put(index, location[2]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerAlternatePartPaths (int index, String[] location)
|
||||
{
|
||||
accessoryStrings.put(index, location[3]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getHeadItem ()
|
||||
{
|
||||
return TContent.arrowhead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getAccessoryItem ()
|
||||
{
|
||||
return TContent.fletching;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] toolCategories ()
|
||||
{
|
||||
return new String[] { "ammo" };
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems (int id, CreativeTabs tab, List list)
|
||||
{
|
||||
//Vanilla style arrow
|
||||
Item accessory = getAccessoryItem();
|
||||
ItemStack accessoryStack = accessory != null ? new ItemStack(getAccessoryItem(), 1, 0) : null;
|
||||
Item extra = getExtraItem();
|
||||
ItemStack extraStack = extra != null ? new ItemStack(extra, 1, 0) : null;
|
||||
ItemStack tool = ToolBuilder.instance.buildTool(new ItemStack(getHeadItem(), 1, 3), new ItemStack(getHandleItem(), 1, 0), accessoryStack, extraStack, "");
|
||||
if (tool == null)
|
||||
{
|
||||
System.out.println("Creative builder failed tool for Vanilla style" + this.getToolName());
|
||||
System.out.println("Make sure you do not have item ID conflicts");
|
||||
}
|
||||
else
|
||||
{
|
||||
tool.stackSize = 1;
|
||||
tool.getTagCompound().getCompoundTag("InfiTool").setBoolean("Built", true);
|
||||
list.add(tool);
|
||||
}
|
||||
|
||||
//Random arrow
|
||||
accessory = getAccessoryItem();
|
||||
accessoryStack = accessory != null ? new ItemStack(getAccessoryItem(), 1, random.nextInt(4)) : null;
|
||||
extra = getExtraItem();
|
||||
extraStack = extra != null ? new ItemStack(extra, 1, 0) : null;
|
||||
tool = ToolBuilder.instance
|
||||
.buildTool(new ItemStack(getHeadItem(), 1, random.nextInt(18)), new ItemStack(getHandleItem(), 1, random.nextInt(18)), accessoryStack, extraStack, "Random Streamer");
|
||||
|
||||
if (tool == null)
|
||||
{
|
||||
System.out.println("Creative builder failed tool for Vanilla style" + this.getToolName());
|
||||
System.out.println("Make sure you do not have item ID conflicts");
|
||||
}
|
||||
else
|
||||
{
|
||||
tool.stackSize = 1;
|
||||
tool.getTagCompound().getCompoundTag("InfiTool").setBoolean("Built", true);
|
||||
list.add(tool);
|
||||
}
|
||||
super.getSubItems(id, tab, list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildTool (int id, String name, List list)
|
||||
{
|
||||
Item accessory = getAccessoryItem();
|
||||
ItemStack accessoryStack = accessory != null ? new ItemStack(getAccessoryItem(), 1, 0) : null;
|
||||
Item extra = getExtraItem();
|
||||
ItemStack extraStack = extra != null ? new ItemStack(getExtraItem(), 1, id) : null;
|
||||
ItemStack tool = ToolBuilder.instance.buildTool(new ItemStack(getHeadItem(), 1, id), new ItemStack(getHandleItem(), 1, id), accessoryStack, extraStack, name + getToolName());
|
||||
if (tool == null)
|
||||
{
|
||||
System.out.println("Creative builder failed tool for " + name + this.getToolName());
|
||||
System.out.println("Make sure you do not have item ID conflicts");
|
||||
}
|
||||
else
|
||||
{
|
||||
tool.stackSize = 1;
|
||||
tool.getTagCompound().getCompoundTag("InfiTool").setBoolean("Built", true);
|
||||
list.add(tool);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean onItemUse (ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float clickX, float clickY, float clickZ)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation (ItemStack stack, EntityPlayer player, List list, boolean par4)
|
||||
{
|
||||
if (!stack.hasTagCompound())
|
||||
return;
|
||||
|
||||
NBTTagCompound tags = stack.getTagCompound();
|
||||
if (tags.hasKey("charge"))
|
||||
{
|
||||
String color = "";
|
||||
//double joules = this.getJoules(stack);
|
||||
int power = tags.getInteger("charge");
|
||||
|
||||
if (power != 0)
|
||||
{
|
||||
if (power <= this.getMaxCharge(stack) / 3)
|
||||
color = "\u00a74";
|
||||
else if (power > this.getMaxCharge(stack) * 2 / 3)
|
||||
color = "\u00a72";
|
||||
else
|
||||
color = "\u00a76";
|
||||
}
|
||||
|
||||
String charge = new StringBuilder().append(color).append(tags.getInteger("charge")).append("/").append(getMaxCharge(stack)).append(" EU").toString();
|
||||
list.add(charge);
|
||||
}
|
||||
if (tags.hasKey("InfiTool"))
|
||||
{
|
||||
boolean broken = tags.getCompoundTag("InfiTool").getBoolean("Broken");
|
||||
if (broken)
|
||||
list.add("\u00A7oBroken");
|
||||
else
|
||||
{
|
||||
int head = tags.getCompoundTag("InfiTool").getInteger("Head");
|
||||
int handle = tags.getCompoundTag("InfiTool").getInteger("Handle");
|
||||
|
||||
String headName = getAbilityNameForType(head);
|
||||
if (!headName.equals(""))
|
||||
list.add(getStyleForType(head) + headName);
|
||||
|
||||
String handleName = getAbilityNameForType(handle);
|
||||
if (!handleName.equals("") && handle != head)
|
||||
list.add(getStyleForType(handle) + handleName);
|
||||
|
||||
int unbreaking = tags.getCompoundTag("InfiTool").getInteger("Unbreaking");
|
||||
String reinforced = getReinforcedName(head, handle, 0, 0, unbreaking);
|
||||
if (!reinforced.equals(""))
|
||||
list.add(reinforced);
|
||||
|
||||
boolean displayToolTips = true;
|
||||
int tipNum = 0;
|
||||
while (displayToolTips)
|
||||
{
|
||||
tipNum++;
|
||||
String tooltip = "Tooltip" + tipNum;
|
||||
if (tags.getCompoundTag("InfiTool").hasKey(tooltip))
|
||||
{
|
||||
String tipName = tags.getCompoundTag("InfiTool").getString(tooltip);
|
||||
if (!tipName.equals(""))
|
||||
list.add(tipName);
|
||||
}
|
||||
else
|
||||
displayToolTips = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
package tconstruct.items.tools;
|
||||
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.library.tools.Weapon;
|
||||
import net.minecraft.item.Item;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BattleSign extends Weapon
|
||||
{
|
||||
public BattleSign(int itemID)
|
||||
{
|
||||
super(itemID, 1);
|
||||
this.setUnlocalizedName("InfiTool.Battlesign");
|
||||
}
|
||||
|
||||
/*public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
if (!player.isSneaking())
|
||||
player.setItemInUse(stack, this.getMaxItemUseDuration(stack));
|
||||
return stack;
|
||||
}*/
|
||||
|
||||
public String getToolName ()
|
||||
{
|
||||
return "Battlesign";
|
||||
}
|
||||
|
||||
/*public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer player, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
|
||||
{
|
||||
if (par7 == 0 || !player.isSneaking())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (!par3World.getBlockMaterial(par4, par5, par6).isSolid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (par7 == 1)
|
||||
{
|
||||
++par5;
|
||||
}
|
||||
|
||||
if (par7 == 2)
|
||||
{
|
||||
--par6;
|
||||
}
|
||||
|
||||
if (par7 == 3)
|
||||
{
|
||||
++par6;
|
||||
}
|
||||
|
||||
if (par7 == 4)
|
||||
{
|
||||
--par4;
|
||||
}
|
||||
|
||||
if (par7 == 5)
|
||||
{
|
||||
++par4;
|
||||
}
|
||||
|
||||
if (!player.canPlayerEdit(par4, par5, par6, par7, par1ItemStack))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (!Block.signPost.canPlaceBlockAt(par3World, par4, par5, par6))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (par7 == 1)
|
||||
{
|
||||
int var11 = MathHelper.floor_double((double)((player.rotationYaw + 180.0F) * 16.0F / 360.0F) + 0.5D) & 15;
|
||||
par3World.setBlock(par4, par5, par6, Block.signPost.blockID, var11);
|
||||
}
|
||||
else
|
||||
{
|
||||
par3World.setBlock(par4, par5, par6, Block.signWall.blockID, par7);
|
||||
}
|
||||
|
||||
//--par1ItemStack.stackSize;
|
||||
TileEntitySign var12 = (TileEntitySign)par3World.getBlockTileEntity(par4, par5, par6);
|
||||
|
||||
if (var12 != null)
|
||||
{
|
||||
player.displayGUIEditSign(var12);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public Item getHeadItem ()
|
||||
{
|
||||
return TContent.signHead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getAccessoryItem ()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public int getRenderPasses (int metadata)
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPartAmount ()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerPartPaths (int index, String[] location)
|
||||
{
|
||||
headStrings.put(index, location[0]);
|
||||
brokenPartStrings.put(index, location[1]);
|
||||
handleStrings.put(index, location[2]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIconSuffix (int partType)
|
||||
{
|
||||
switch (partType)
|
||||
{
|
||||
case 0:
|
||||
return "_battlesign_head";
|
||||
case 1:
|
||||
return "_battlesign_head_broken";
|
||||
case 2:
|
||||
return "_battlesign_handle";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEffectSuffix ()
|
||||
{
|
||||
return "_battlesign_effect";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultFolder ()
|
||||
{
|
||||
return "battlesign";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,292 @@
|
||||
package tconstruct.items.tools;
|
||||
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.library.ActiveToolMod;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.tools.AbilityHelper;
|
||||
import tconstruct.library.tools.HarvestTool;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class Battleaxe extends HarvestTool
|
||||
{
|
||||
public Battleaxe(int itemID)
|
||||
{
|
||||
super(itemID, 4);
|
||||
this.setUnlocalizedName("InfiTool.Battleaxe");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Material[] getEffectiveMaterials ()
|
||||
{
|
||||
return materials;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getHarvestType ()
|
||||
{
|
||||
return "axe";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockDestroyed (ItemStack itemstack, World world, int bID, int x, int y, int z, EntityLivingBase player)
|
||||
{
|
||||
Block block = Block.blocksList[bID];
|
||||
if (block != null && block.blockMaterial == Material.leaves)
|
||||
return false;
|
||||
|
||||
return AbilityHelper.onBlockChanged(itemstack, world, bID, x, y, z, player, random);
|
||||
}
|
||||
|
||||
static Material[] materials = { Material.wood, Material.vine, Material.circuits, Material.cactus, Material.pumpkin };
|
||||
|
||||
@Override
|
||||
public Item getHeadItem ()
|
||||
{
|
||||
return TContent.broadAxeHead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getHandleItem ()
|
||||
{
|
||||
return TContent.toughRod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getAccessoryItem ()
|
||||
{
|
||||
return TContent.broadAxeHead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getExtraItem ()
|
||||
{
|
||||
return TContent.toughBinding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int durabilityTypeAccessory ()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int durabilityTypeExtra ()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getRepairCost ()
|
||||
{
|
||||
return 4.0f;
|
||||
}
|
||||
|
||||
public float getDurabilityModifier ()
|
||||
{
|
||||
return 2.5f;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public int getRenderPasses (int metadata)
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPartAmount ()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIconSuffix (int partType)
|
||||
{
|
||||
switch (partType)
|
||||
{
|
||||
case 0:
|
||||
return "_battleaxe_fronthead";
|
||||
case 1:
|
||||
return "_battleaxe_fronthead_broken";
|
||||
case 2:
|
||||
return "_battleaxe_handle";
|
||||
case 3:
|
||||
return "_battleaxe_backhead";
|
||||
case 4:
|
||||
return "_battleaxe_binding";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEffectSuffix ()
|
||||
{
|
||||
return "_battleaxe_effect";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultFolder ()
|
||||
{
|
||||
return "battleaxe";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] toolCategories ()
|
||||
{
|
||||
return new String[] { "weapon", "harvest", "melee", "slicing" };
|
||||
}
|
||||
|
||||
/* Battleaxe Specific */
|
||||
|
||||
@Override
|
||||
public boolean onItemUse (ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float clickX, float clickY, float clickZ)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumAction getItemUseAction (ItemStack par1ItemStack)
|
||||
{
|
||||
return EnumAction.bow;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick (ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
//player.rotationYaw += 1;
|
||||
//if (player.onGround)
|
||||
//{
|
||||
player.setItemInUse(stack, this.getMaxItemUseDuration(stack));
|
||||
//}
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerStoppedUsing (ItemStack stack, World world, EntityPlayer player, int useCount)
|
||||
{
|
||||
//if (player.onGround)
|
||||
{
|
||||
int time = this.getMaxItemUseDuration(stack) - useCount;
|
||||
int boost = time / 100;
|
||||
if (boost > 2)
|
||||
boost = 2;
|
||||
player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, time * 4, boost));
|
||||
player.addPotionEffect(new PotionEffect(Potion.jump.id, time * 4, boost));
|
||||
player.addPotionEffect(new PotionEffect(Potion.damageBoost.id, time * 4, 0));
|
||||
player.addPotionEffect(new PotionEffect(Potion.hunger.id, time * 2, 0));
|
||||
if (time > 5 && player.onGround)
|
||||
{
|
||||
player.addExhaustion(0.2F);
|
||||
player.setSprinting(true);
|
||||
|
||||
float speed = 0.025F * time;
|
||||
if (speed > 0.925f)
|
||||
speed = 0.925f;
|
||||
|
||||
float increase = (float) (0.02 * time + 0.2);
|
||||
if (increase > 0.56f)
|
||||
increase = 0.56f;
|
||||
player.motionY += increase;
|
||||
|
||||
player.motionX = (double) (-MathHelper.sin(player.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(player.rotationPitch / 180.0F * (float) Math.PI) * speed);
|
||||
player.motionZ = (double) (MathHelper.cos(player.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(player.rotationPitch / 180.0F * (float) Math.PI) * speed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getMaxItemUseDuration (ItemStack par1ItemStack)
|
||||
{
|
||||
return 72000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hitEntity (ItemStack stack, EntityLivingBase mob, EntityLivingBase player)
|
||||
{
|
||||
AbilityHelper.knockbackEntity(mob, 1.5f);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void onUpdate (ItemStack stack, World world, Entity entity, int par4, boolean par5)
|
||||
{
|
||||
super.onUpdate(stack, world, entity, par4, par5);
|
||||
if (entity instanceof EntityPlayerSP)
|
||||
{
|
||||
EntityPlayerSP player = (EntityPlayerSP) entity;
|
||||
ItemStack usingItem = player.getItemInUse();
|
||||
if (usingItem != null && usingItem.getItem() == this)
|
||||
{
|
||||
player.movementInput.moveForward *= 5.0F;
|
||||
player.movementInput.moveStrafe *= 5.0F;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockStartBreak (ItemStack stack, int x, int y, int z, EntityPlayer player)
|
||||
{
|
||||
World world = player.worldObj;
|
||||
final int woodID = world.getBlockId(x, y, z);
|
||||
final Block wood = Block.blocksList[woodID];
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
final int meta = world.getBlockMetadata(x, y, z);
|
||||
for (int yPos = y + 1; yPos < y + 9; yPos++)
|
||||
{
|
||||
int blockID = world.getBlockId(x, yPos, z);
|
||||
Block block = Block.blocksList[blockID];
|
||||
if (!(tags.getBoolean("Broken")) && block != null && block.blockMaterial == Material.wood)
|
||||
{
|
||||
int localblockID = world.getBlockId(x, yPos, z);
|
||||
int localMeta = world.getBlockMetadata(x, yPos, z);
|
||||
int hlvl = MinecraftForge.getBlockHarvestLevel(block, meta, getHarvestType());
|
||||
|
||||
if (hlvl <= tags.getInteger("HarvestLevel"))
|
||||
{
|
||||
boolean cancelHarvest = false;
|
||||
for (ActiveToolMod mod : TConstructRegistry.activeModifiers)
|
||||
{
|
||||
if (mod.beforeBlockBreak(this, stack, x, yPos, z, player))
|
||||
cancelHarvest = true;
|
||||
}
|
||||
|
||||
if (!cancelHarvest)
|
||||
{
|
||||
if (block != null && block.blockMaterial == Material.wood)
|
||||
{
|
||||
localMeta = world.getBlockMetadata(x, yPos, z);
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
{
|
||||
block.harvestBlock(world, player, x, yPos, z, localMeta);
|
||||
block.onBlockHarvested(world, x, y, z, localMeta, player);
|
||||
onBlockDestroyed(stack, world, localblockID, x, yPos, z, player);
|
||||
}
|
||||
world.setBlockToAir(x, yPos, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (!world.isRemote)
|
||||
world.playAuxSFX(2001, x, y, z, woodID + (meta << 12));
|
||||
return super.onBlockStartBreak(stack, x, y, z, player);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package tconstruct.items.tools;
|
||||
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.library.tools.Weapon;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
public class Broadsword extends Weapon
|
||||
{
|
||||
public Broadsword(int itemID)
|
||||
{
|
||||
super(itemID, 4);
|
||||
this.setUnlocalizedName("InfiTool.Broadsword");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getHeadItem ()
|
||||
{
|
||||
return TContent.swordBlade;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getAccessoryItem ()
|
||||
{
|
||||
return TContent.wideGuard;
|
||||
}
|
||||
|
||||
public float getDurabilityModifier ()
|
||||
{
|
||||
return 1.2f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIconSuffix (int partType)
|
||||
{
|
||||
switch (partType)
|
||||
{
|
||||
case 0:
|
||||
return "_sword_blade";
|
||||
case 1:
|
||||
return "_sword_blade_broken";
|
||||
case 2:
|
||||
return "_sword_handle";
|
||||
case 3:
|
||||
return "_sword_accessory";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEffectSuffix ()
|
||||
{
|
||||
return "_sword_effect";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultFolder ()
|
||||
{
|
||||
return "broadsword";
|
||||
}
|
||||
|
||||
/*@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void onUpdate (ItemStack stack, World world, Entity entity, int par4, boolean par5)
|
||||
{
|
||||
super.onUpdate(stack, world, entity, par4, par5);
|
||||
if (entity instanceof EntityPlayerSP)
|
||||
{
|
||||
EntityPlayerSP player = (EntityPlayerSP) entity;
|
||||
if (player.itemInUse != null && player.itemInUse.getItem() == this)
|
||||
{
|
||||
player.movementInput.moveForward *= 5.0F;
|
||||
player.movementInput.moveStrafe *= 5.0F;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
@@ -0,0 +1,228 @@
|
||||
package tconstruct.items.tools;
|
||||
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.library.crafting.Detailing.DetailInput;
|
||||
import tconstruct.library.tools.AbilityHelper;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumMovingObjectType;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class Chisel extends ToolCore
|
||||
{
|
||||
public Chisel(int id)
|
||||
{
|
||||
super(id, 0);
|
||||
this.setUnlocalizedName("InfiTool.Chisel");
|
||||
this.setContainerItem(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getContainerItemStack (ItemStack itemStack)
|
||||
{
|
||||
//AbilityHelper.damageTool(itemStack, 1, null, false);
|
||||
|
||||
int reinforced = 0;
|
||||
NBTTagCompound tags = itemStack.getTagCompound();
|
||||
|
||||
if (tags.getCompoundTag("InfiTool").hasKey("Unbreaking"))
|
||||
reinforced = tags.getCompoundTag("InfiTool").getInteger("Unbreaking");
|
||||
|
||||
if (random.nextInt(10) < 10 - reinforced)
|
||||
{
|
||||
AbilityHelper.damageTool(itemStack, 1, null, false);
|
||||
}
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesContainerItemLeaveCraftingGrid (ItemStack par1ItemStack)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean performDetailing (World world, int x, int y, int z, int blockID, int blockMeta)
|
||||
{
|
||||
boolean detailed = false;
|
||||
return detailed;
|
||||
}
|
||||
|
||||
public boolean onItemUse (ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float clickX, float clickY, float clickZ)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick (ItemStack stack, World world, EntityPlayer entityplayer)
|
||||
{
|
||||
if (entityplayer.capabilities.isCreativeMode)
|
||||
{
|
||||
onEaten(stack, world, entityplayer);
|
||||
}
|
||||
else
|
||||
{
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (!tags.getBoolean("Broken"))
|
||||
entityplayer.setItemInUse(stack, getMaxItemUseDuration(stack));
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onEaten (ItemStack itemstack, World world, EntityPlayer entityplayer)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
MovingObjectPosition movingobjectposition = getMovingObjectPositionFromPlayer(world, entityplayer, true);
|
||||
if (movingobjectposition == null)
|
||||
{
|
||||
return itemstack;
|
||||
}
|
||||
if (movingobjectposition.typeOfHit == EnumMovingObjectType.TILE)
|
||||
{
|
||||
int x = movingobjectposition.blockX;
|
||||
int y = movingobjectposition.blockY;
|
||||
int z = movingobjectposition.blockZ;
|
||||
int blockID = world.getBlockId(x, y, z);
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
|
||||
DetailInput details = TConstruct.chiselDetailing.getDetailing(blockID, meta);
|
||||
if (details != null && details.outputID < 4096)
|
||||
{
|
||||
world.setBlock(x, y, z, details.outputID, details.outputMeta, 3);
|
||||
if (!(entityplayer.capabilities.isCreativeMode))
|
||||
{
|
||||
int reinforced = 0;
|
||||
NBTTagCompound tags = itemstack.getTagCompound();
|
||||
|
||||
if (tags.getCompoundTag("InfiTool").hasKey("Unbreaking"))
|
||||
reinforced = tags.getCompoundTag("InfiTool").getInteger("Unbreaking");
|
||||
|
||||
if (random.nextInt(10) < 10 - reinforced)
|
||||
{
|
||||
AbilityHelper.damageTool(itemstack, 1, null, false);
|
||||
}
|
||||
}
|
||||
world.playAuxSFX(2001, x, y, z, blockID + (meta << 12));
|
||||
entityplayer.swingItem();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void onUpdate (ItemStack stack, World world, Entity entity, int par4, boolean par5)
|
||||
{
|
||||
super.onUpdate(stack, world, entity, par4, par5);
|
||||
if (entity instanceof EntityPlayerSP)
|
||||
{
|
||||
EntityPlayerSP player = (EntityPlayerSP) entity;
|
||||
ItemStack usingItem = player.getItemInUse();
|
||||
if (usingItem != null && usingItem.getItem() == this)
|
||||
{
|
||||
player.movementInput.moveForward *= 2.0;
|
||||
player.movementInput.moveStrafe *= 2.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxItemUseDuration (ItemStack itemstack)
|
||||
{
|
||||
if (!itemstack.hasTagCompound())
|
||||
return 20;
|
||||
|
||||
int speed = itemstack.getTagCompound().getCompoundTag("InfiTool").getInteger("MiningSpeed") / 100;
|
||||
int truespeed = 20 - speed;
|
||||
if (truespeed < 0)
|
||||
truespeed = 0;
|
||||
return truespeed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumAction getItemUseAction (ItemStack itemstack)
|
||||
{
|
||||
return EnumAction.eat;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public int getRenderPasses (int metadata)
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPartAmount ()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerPartPaths (int index, String[] location)
|
||||
{
|
||||
headStrings.put(index, location[0]);
|
||||
brokenPartStrings.put(index, location[1]);
|
||||
handleStrings.put(index, location[2]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIconSuffix (int partType)
|
||||
{
|
||||
switch (partType)
|
||||
{
|
||||
case 0:
|
||||
return "_chisel_head";
|
||||
case 1:
|
||||
return "_chisel_head_broken";
|
||||
case 2:
|
||||
return "_chisel_handle";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEffectSuffix ()
|
||||
{
|
||||
return "_chisel_effect";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultFolder ()
|
||||
{
|
||||
return "chisel";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getHeadItem ()
|
||||
{
|
||||
return TContent.chiselHead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getAccessoryItem ()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] toolCategories ()
|
||||
{
|
||||
return new String[] { "utility" };
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
package tconstruct.items.tools;
|
||||
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.library.tools.AbilityHelper;
|
||||
import tconstruct.library.tools.Weapon;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class Cleaver extends Weapon
|
||||
{
|
||||
public Cleaver(int itemID)
|
||||
{
|
||||
super(itemID, 4);
|
||||
this.setUnlocalizedName("InfiTool.Cleaver");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getHeadItem ()
|
||||
{
|
||||
return TContent.largeSwordBlade;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getHandleItem ()
|
||||
{
|
||||
return TContent.toughRod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getAccessoryItem ()
|
||||
{
|
||||
return TContent.heavyPlate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getExtraItem ()
|
||||
{
|
||||
return TContent.toughRod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int durabilityTypeAccessory ()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int durabilityTypeExtra ()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getRepairCost ()
|
||||
{
|
||||
return 4.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDurabilityModifier ()
|
||||
{
|
||||
return 2.5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDamageModifier ()
|
||||
{
|
||||
return 1.25f;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public int getRenderPasses (int metadata)
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPartAmount ()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIconSuffix (int partType)
|
||||
{
|
||||
switch (partType)
|
||||
{
|
||||
case 0:
|
||||
return "_cleaver_head";
|
||||
case 1:
|
||||
return "_cleaver_head_broken";
|
||||
case 2:
|
||||
return "_cleaver_handle";
|
||||
case 3:
|
||||
return "_cleaver_shield";
|
||||
case 4:
|
||||
return "_cleaver_guard";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEffectSuffix ()
|
||||
{
|
||||
return "_cleaver_effect";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultFolder ()
|
||||
{
|
||||
return "cleaver";
|
||||
}
|
||||
|
||||
/* Cleaver specific */
|
||||
@Override
|
||||
public boolean onLeftClickEntity (ItemStack stack, EntityPlayer player, Entity entity)
|
||||
{
|
||||
if (AbilityHelper.onLeftClickEntity(stack, player, entity, this))
|
||||
{
|
||||
entity.hurtResistantTime += 7;
|
||||
|
||||
/*if (entity instanceof EntityLiving)
|
||||
{
|
||||
EntityLiving living = (EntityLiving) entity;
|
||||
if (living.getHealth() <= 0)
|
||||
{
|
||||
|
||||
}
|
||||
}*/
|
||||
//if (entity.getHealth() <= 0)
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void onUpdate (ItemStack stack, World world, Entity entity, int par4, boolean par5)
|
||||
{
|
||||
super.onUpdate(stack, world, entity, par4, par5);
|
||||
if (entity instanceof EntityPlayer)
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer) entity;
|
||||
ItemStack equipped = player.getCurrentEquippedItem();
|
||||
if (equipped == stack)
|
||||
{
|
||||
player.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, 1, 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*@Override
|
||||
public boolean onEntitySwing (EntityLiving entity, ItemStack stack)
|
||||
{
|
||||
entity.swingProgressInt /= 2;
|
||||
return false;
|
||||
}*/
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package tconstruct.items.tools;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.library.tools.Weapon;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
public class Cutlass extends Weapon
|
||||
{
|
||||
public Cutlass(int itemID)
|
||||
{
|
||||
super(itemID, 4);
|
||||
this.setUnlocalizedName("InfiTool.Cutlass");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getHeadItem ()
|
||||
{
|
||||
return TContent.swordBlade;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getAccessoryItem ()
|
||||
{
|
||||
return TContent.fullGuard;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIconSuffix (int partType)
|
||||
{
|
||||
switch (partType)
|
||||
{
|
||||
case 0:
|
||||
return "_cutlass_blade";
|
||||
case 1:
|
||||
return "_cutlass_blade_broken";
|
||||
case 2:
|
||||
return "_cutlass_handle";
|
||||
case 3:
|
||||
return "_cutlass_guard";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEffectSuffix ()
|
||||
{
|
||||
return "_cutlass_effect";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultFolder ()
|
||||
{
|
||||
return "cutlass";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int durabilityTypeAccessory ()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public void getSubItems (int id, CreativeTabs tab, List list)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
package tconstruct.items.tools;
|
||||
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.entity.projectile.DaggerEntity;
|
||||
import tconstruct.library.tools.Weapon;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class Dagger extends Weapon
|
||||
{
|
||||
public Dagger(int id)
|
||||
{
|
||||
super(id, 1);
|
||||
this.setUnlocalizedName("InfiTool.Dagger");
|
||||
}
|
||||
|
||||
public ItemStack onItemRightClick (ItemStack itemstack, World world, EntityPlayer player)
|
||||
{
|
||||
ItemStack stack = itemstack.copy();
|
||||
if (!world.isRemote)
|
||||
{
|
||||
DaggerEntity dagger = new DaggerEntity(stack, world, player);
|
||||
world.spawnEntityInWorld(dagger);
|
||||
}
|
||||
itemstack.stackSize--;
|
||||
return itemstack;
|
||||
/*player.setItemInUse(itemstack, this.getMaxItemUseDuration(itemstack));
|
||||
return itemstack;*/
|
||||
}
|
||||
|
||||
public ItemStack onEaten (ItemStack itemstack, World world, EntityPlayer player)
|
||||
{
|
||||
ItemStack stack = itemstack.copy();
|
||||
if (!world.isRemote)
|
||||
{
|
||||
DaggerEntity dagger = new DaggerEntity(stack, world, player);
|
||||
world.spawnEntityInWorld(dagger);
|
||||
}
|
||||
itemstack.stackSize--;
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] toolCategories ()
|
||||
{
|
||||
return new String[] { "weapon", "melee", "throwing" };
|
||||
}
|
||||
|
||||
public EnumAction getItemUseAction (ItemStack par1ItemStack)
|
||||
{
|
||||
return EnumAction.bow;
|
||||
}
|
||||
|
||||
public int getMaxItemUseDuration (ItemStack stack)
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
|
||||
public boolean rangedTool ()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIconSuffix (int partType)
|
||||
{
|
||||
switch (partType)
|
||||
{
|
||||
case 0:
|
||||
return "_dagger_blade";
|
||||
case 1:
|
||||
return "_dagger_blade_broken";
|
||||
case 2:
|
||||
return "_dagger_handle";
|
||||
case 3:
|
||||
return "_dagger_accessory";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEffectSuffix ()
|
||||
{
|
||||
return "_dagger_effect";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultFolder ()
|
||||
{
|
||||
return "dagger";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getHeadItem ()
|
||||
{
|
||||
return TContent.knifeBlade;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getAccessoryItem ()
|
||||
{
|
||||
return TContent.crossbar;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,300 @@
|
||||
package tconstruct.items.tools;
|
||||
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.library.ActiveToolMod;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.tools.AbilityHelper;
|
||||
import tconstruct.library.tools.HarvestTool;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class Excavator extends HarvestTool
|
||||
{
|
||||
public Excavator(int itemID)
|
||||
{
|
||||
super(itemID, 2);
|
||||
this.setUnlocalizedName("InfiTool.Excavator");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Material[] getEffectiveMaterials ()
|
||||
{
|
||||
return materials;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getHarvestType ()
|
||||
{
|
||||
return "shovel";
|
||||
}
|
||||
|
||||
static Material[] materials = { Material.grass, Material.ground, Material.sand, Material.snow, Material.craftedSnow, Material.clay };
|
||||
|
||||
@Override
|
||||
public Item getHeadItem ()
|
||||
{
|
||||
return TContent.excavatorHead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getHandleItem ()
|
||||
{
|
||||
return TContent.toughRod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getAccessoryItem ()
|
||||
{
|
||||
return TContent.heavyPlate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getExtraItem ()
|
||||
{
|
||||
return TContent.toughBinding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getRepairCost ()
|
||||
{
|
||||
return 4.0f;
|
||||
}
|
||||
|
||||
public float getDurabilityModifier ()
|
||||
{
|
||||
return 2.75f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int durabilityTypeAccessory ()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int durabilityTypeExtra ()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public int getRenderPasses (int metadata)
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPartAmount ()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIconSuffix (int partType)
|
||||
{
|
||||
switch (partType)
|
||||
{
|
||||
case 0:
|
||||
return "_excavator_head";
|
||||
case 1:
|
||||
return "_excavator_head_broken";
|
||||
case 2:
|
||||
return "_excavator_handle";
|
||||
case 3:
|
||||
return "_excavator_binding";
|
||||
case 4:
|
||||
return "_excavator_grip";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEffectSuffix ()
|
||||
{
|
||||
return "_excavator_effect";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultFolder ()
|
||||
{
|
||||
return "excavator";
|
||||
}
|
||||
|
||||
/* Excavator Specific */
|
||||
|
||||
@Override
|
||||
public boolean onBlockStartBreak (ItemStack stack, int x, int y, int z, EntityPlayer player)
|
||||
{
|
||||
World world = player.worldObj;
|
||||
final int blockID = world.getBlockId(x, y, z);
|
||||
final int meta = world.getBlockMetadata(x, y, z);
|
||||
Block block = Block.blocksList[blockID];
|
||||
if (!stack.hasTagCompound())
|
||||
return false;
|
||||
|
||||
if (block == null)
|
||||
return super.onBlockStartBreak(stack, x, y, z, player);
|
||||
|
||||
float blockHardness = block.getBlockHardness(world, x, y, z);
|
||||
|
||||
boolean validStart = false;
|
||||
for (int iter = 0; iter < materials.length; iter++)
|
||||
{
|
||||
if (materials[iter] == block.blockMaterial)
|
||||
{
|
||||
validStart = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
MovingObjectPosition mop = AbilityHelper.raytraceFromEntity(world, player, true, 5.0D);
|
||||
if (mop == null || !validStart)
|
||||
return super.onBlockStartBreak(stack, x, y, z, player);
|
||||
|
||||
int xRange = 1;
|
||||
int yRange = 1;
|
||||
int zRange = 1;
|
||||
switch (mop.sideHit)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
yRange = 0;
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
zRange = 0;
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
xRange = 0;
|
||||
break;
|
||||
}
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
for (int xPos = x - xRange; xPos <= x + xRange; xPos++)
|
||||
{
|
||||
for (int yPos = y - yRange; yPos <= y + yRange; yPos++)
|
||||
{
|
||||
for (int zPos = z - zRange; zPos <= z + zRange; zPos++)
|
||||
{
|
||||
if (!(tags.getBoolean("Broken")))
|
||||
{
|
||||
int localblockID = world.getBlockId(xPos, yPos, zPos);
|
||||
block = Block.blocksList[localblockID];
|
||||
int localMeta = world.getBlockMetadata(xPos, yPos, zPos);
|
||||
int hlvl = MinecraftForge.getBlockHarvestLevel(block, meta, getHarvestType());
|
||||
float localHardness = block == null ? Float.MAX_VALUE : block.getBlockHardness(world, xPos, yPos, zPos);
|
||||
|
||||
if (hlvl <= tags.getInteger("HarvestLevel") && localHardness - 1.5 <= blockHardness)
|
||||
{
|
||||
boolean cancelHarvest = false;
|
||||
for (ActiveToolMod mod : TConstructRegistry.activeModifiers)
|
||||
{
|
||||
if (mod.beforeBlockBreak(this, stack, xPos, yPos, zPos, player))
|
||||
cancelHarvest = true;
|
||||
}
|
||||
|
||||
if (!cancelHarvest)
|
||||
{
|
||||
if (block != null && !(localHardness < 0))
|
||||
{
|
||||
for (int iter = 0; iter < materials.length; iter++)
|
||||
{
|
||||
if (materials[iter] == block.blockMaterial)
|
||||
{
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
{
|
||||
block.harvestBlock(world, player, xPos, yPos, zPos, localMeta);
|
||||
block.onBlockHarvested(world, x, y, z, localMeta, player);
|
||||
if (blockHardness > 0f)
|
||||
onBlockDestroyed(stack, world, localblockID, xPos, yPos, zPos, player);
|
||||
}
|
||||
world.setBlockToAir(xPos, yPos, zPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!world.isRemote)
|
||||
world.playAuxSFX(2001, x, y, z, blockID + (meta << 12));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getStrVsBlock (ItemStack stack, Block block, int meta)
|
||||
{
|
||||
if (!stack.hasTagCompound())
|
||||
return 1.0f;
|
||||
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (tags.getBoolean("Broken"))
|
||||
return 0.1f;
|
||||
|
||||
Material[] materials = getEffectiveMaterials();
|
||||
for (int i = 0; i < materials.length; i++)
|
||||
{
|
||||
if (materials[i] == block.blockMaterial)
|
||||
{
|
||||
float mineSpeed = tags.getInteger("MiningSpeed");
|
||||
int heads = 1;
|
||||
if (tags.hasKey("MiningSpeed2"))
|
||||
{
|
||||
mineSpeed += tags.getInteger("MiningSpeed2");
|
||||
heads++;
|
||||
}
|
||||
|
||||
if (tags.hasKey("MiningSpeedHandle"))
|
||||
{
|
||||
mineSpeed += tags.getInteger("MiningSpeedHandle");
|
||||
heads++;
|
||||
}
|
||||
|
||||
if (tags.hasKey("MiningSpeedExtra"))
|
||||
{
|
||||
mineSpeed += tags.getInteger("MiningSpeedExtra");
|
||||
heads++;
|
||||
}
|
||||
float trueSpeed = mineSpeed / (heads * 300f);
|
||||
int hlvl = MinecraftForge.getBlockHarvestLevel(block, meta, getHarvestType());
|
||||
int durability = tags.getInteger("Damage");
|
||||
|
||||
float stonebound = tags.getFloat("Shoddy");
|
||||
float bonusLog = (float) Math.log(durability / 72f + 1) * 2 * stonebound;
|
||||
trueSpeed += bonusLog;
|
||||
|
||||
if (hlvl <= tags.getInteger("HarvestLevel"))
|
||||
return trueSpeed;
|
||||
return 0.1f;
|
||||
}
|
||||
}
|
||||
return super.getStrVsBlock(stack, block, meta);
|
||||
}
|
||||
/*@Override
|
||||
public void onUpdate (ItemStack stack, World world, Entity entity, int par4, boolean par5)
|
||||
{
|
||||
super.onUpdate(stack, world, entity, par4, par5);
|
||||
if (entity instanceof EntityPlayer)
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer) entity;
|
||||
ItemStack equipped = player.getCurrentEquippedItem();
|
||||
if (equipped == stack)
|
||||
{
|
||||
player.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, 1, 1));
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
@@ -0,0 +1,202 @@
|
||||
package tconstruct.items.tools;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import tconstruct.blocks.logic.EquipLogic;
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.library.crafting.ToolBuilder;
|
||||
import tconstruct.library.tools.AbilityHelper;
|
||||
import tconstruct.library.tools.Weapon;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class FryingPan extends Weapon
|
||||
{
|
||||
public FryingPan(int itemID)
|
||||
{
|
||||
super(itemID, 2);
|
||||
this.setUnlocalizedName("InfiTool.FryingPan");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hitEntity (ItemStack stack, EntityLivingBase mob, EntityLivingBase player)
|
||||
{
|
||||
AbilityHelper.knockbackEntity(mob, 1.7f);
|
||||
mob.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 100, 0)); //5 seconds of stun
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLeftClickEntity (ItemStack stack, EntityPlayer player, Entity mob)
|
||||
{
|
||||
if (mob.canAttackWithItem() && !mob.func_85031_j(player) && mob.hurtResistantTime < 14)
|
||||
AbilityHelper.onLeftClickEntity(stack, player, mob, this);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityDamaged (World world, EntityLivingBase player, Entity entity)
|
||||
{
|
||||
world.playSoundEffect(entity.posX, entity.posY, entity.posZ, "sounds.frypan_hit", 1.0F, (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F);
|
||||
}
|
||||
|
||||
public String getToolName ()
|
||||
{
|
||||
return "Frying Pan";
|
||||
}
|
||||
|
||||
public void getSubItems (int id, CreativeTabs tab, List list)
|
||||
{
|
||||
super.getSubItems(id, tab, list);
|
||||
|
||||
Item accessory = getAccessoryItem();
|
||||
ItemStack tool = ToolBuilder.instance.buildTool(new ItemStack(getHeadItem(), 1, 2), new ItemStack(getHandleItem(), 1, 16), null, "Bane of Pigs");
|
||||
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
tags.setInteger("Modifiers", 0);
|
||||
tags.setInteger("Attack", Integer.MAX_VALUE / 100);
|
||||
tags.setInteger("TotalDurability", Integer.MAX_VALUE / 100);
|
||||
tags.setInteger("BaseDurability", Integer.MAX_VALUE / 100);
|
||||
tags.setInteger("MiningSpeed", Integer.MAX_VALUE / 100);
|
||||
|
||||
int[] keyPair = new int[] { Integer.MAX_VALUE / 100, 0, 0 };
|
||||
tags.setIntArray("Blaze", keyPair);
|
||||
tags.setInteger("Necrotic", Integer.MAX_VALUE / 100);
|
||||
tags.setInteger("Effect1", 7);
|
||||
|
||||
tags.setBoolean("Built", true);
|
||||
list.add(tool);
|
||||
}
|
||||
|
||||
public boolean onItemUse (ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float clickX, float clickY, float clickZ)
|
||||
{
|
||||
if (side == 0 || !player.isSneaking())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (!world.getBlockMaterial(x, y, z).isSolid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (side == 1)
|
||||
{
|
||||
++y;
|
||||
}
|
||||
|
||||
if (side == 2)
|
||||
{
|
||||
--z;
|
||||
}
|
||||
|
||||
if (side == 3)
|
||||
{
|
||||
++z;
|
||||
}
|
||||
|
||||
if (side == 4)
|
||||
{
|
||||
--x;
|
||||
}
|
||||
|
||||
if (side == 5)
|
||||
{
|
||||
++x;
|
||||
}
|
||||
|
||||
if (!player.canPlayerEdit(x, y, z, side, stack))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (!TContent.heldItemBlock.canPlaceBlockAt(world, x, y, z))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
world.setBlock(x, y, z, TContent.heldItemBlock.blockID, 0, 3);
|
||||
world.playSoundEffect(x, y, z, "sounds.frypan_hit", 1.0F, (random.nextFloat() - random.nextFloat()) * 0.2F + 0.65F);
|
||||
|
||||
EquipLogic logic = (EquipLogic) world.getBlockTileEntity(x, y, z);
|
||||
logic.setEquipmentItem(stack);
|
||||
--stack.stackSize;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getHeadItem ()
|
||||
{
|
||||
return TContent.frypanHead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getAccessoryItem ()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public int getRenderPasses (int metadata)
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPartAmount ()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerPartPaths (int index, String[] location)
|
||||
{
|
||||
headStrings.put(index, location[0]);
|
||||
brokenPartStrings.put(index, location[1]);
|
||||
handleStrings.put(index, location[2]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIconSuffix (int partType)
|
||||
{
|
||||
switch (partType)
|
||||
{
|
||||
case 0:
|
||||
return "_frypan_head";
|
||||
case 1:
|
||||
return "_frypan_head_broken";
|
||||
case 2:
|
||||
return "_frypan_handle";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEffectSuffix ()
|
||||
{
|
||||
return "_frypan_effect";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultFolder ()
|
||||
{
|
||||
return "frypan";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,379 @@
|
||||
package tconstruct.items.tools;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.library.ActiveToolMod;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.tools.AbilityHelper;
|
||||
import tconstruct.library.tools.HarvestTool;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class Hammer extends HarvestTool
|
||||
{
|
||||
public Hammer(int itemID)
|
||||
{
|
||||
super(itemID, 2);
|
||||
this.setUnlocalizedName("InfiTool.Hammer");
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public int getRenderPasses (int metadata)
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPartAmount ()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
public int durabilityTypeAccessory ()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
public int durabilityTypeExtra ()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getHarvestType ()
|
||||
{
|
||||
return "pickaxe";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Material[] getEffectiveMaterials ()
|
||||
{
|
||||
return materials;
|
||||
}
|
||||
|
||||
static Material[] materials = new Material[] { Material.rock, Material.iron, Material.ice, Material.glass, Material.piston, Material.anvil };
|
||||
|
||||
@Override
|
||||
public Item getHeadItem ()
|
||||
{
|
||||
return TContent.hammerHead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getHandleItem ()
|
||||
{
|
||||
return TContent.toughRod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getAccessoryItem ()
|
||||
{
|
||||
return TContent.heavyPlate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getExtraItem ()
|
||||
{
|
||||
return TContent.heavyPlate;
|
||||
}
|
||||
|
||||
public float getDurabilityModifier ()
|
||||
{
|
||||
return 4.5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIconSuffix (int partType)
|
||||
{
|
||||
switch (partType)
|
||||
{
|
||||
case 0:
|
||||
return "_hammer_head";
|
||||
case 1:
|
||||
return "_hammer_handle_broken";
|
||||
case 2:
|
||||
return "_hammer_handle";
|
||||
case 3:
|
||||
return "_hammer_front";
|
||||
case 4:
|
||||
return "_hammer_back";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEffectSuffix ()
|
||||
{
|
||||
return "_hammer_effect";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultFolder ()
|
||||
{
|
||||
return "hammer";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon (ItemStack stack, int renderPass)
|
||||
{
|
||||
NBTTagCompound tags = stack.getTagCompound();
|
||||
|
||||
if (tags != null)
|
||||
{
|
||||
tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (renderPass < getPartAmount())
|
||||
{
|
||||
if (renderPass == 0) // Handle
|
||||
{
|
||||
if (tags.getBoolean("Broken"))
|
||||
return (brokenIcons.get(tags.getInteger("RenderHandle")));
|
||||
return handleIcons.get(tags.getInteger("RenderHandle"));
|
||||
}
|
||||
|
||||
else if (renderPass == 1) // Head
|
||||
{
|
||||
return (headIcons.get(tags.getInteger("RenderHead")));
|
||||
}
|
||||
|
||||
else if (renderPass == 2) // Accessory
|
||||
{
|
||||
return (accessoryIcons.get(tags.getInteger("RenderAccessory")));
|
||||
}
|
||||
|
||||
else if (renderPass == 3) // Extra
|
||||
{
|
||||
return (extraIcons.get(tags.getInteger("RenderExtra")));
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (renderPass == getPartAmount())
|
||||
{
|
||||
if (tags.hasKey("Effect1"))
|
||||
return (effectIcons.get(tags.getInteger("Effect1")));
|
||||
}
|
||||
|
||||
else if (renderPass == getPartAmount() + 1)
|
||||
{
|
||||
if (tags.hasKey("Effect2"))
|
||||
return (effectIcons.get(tags.getInteger("Effect2")));
|
||||
}
|
||||
|
||||
else if (renderPass == getPartAmount() + 2)
|
||||
{
|
||||
if (tags.hasKey("Effect3"))
|
||||
return (effectIcons.get(tags.getInteger("Effect3")));
|
||||
}
|
||||
|
||||
else if (renderPass == getPartAmount() + 3)
|
||||
{
|
||||
if (tags.hasKey("Effect4"))
|
||||
return (effectIcons.get(tags.getInteger("Effect4")));
|
||||
}
|
||||
|
||||
else if (renderPass == getPartAmount() + 4)
|
||||
{
|
||||
if (tags.hasKey("Effect5"))
|
||||
return (effectIcons.get(tags.getInteger("Effect5")));
|
||||
}
|
||||
|
||||
else if (renderPass == getPartAmount() + 5)
|
||||
{
|
||||
if (tags.hasKey("Effect6"))
|
||||
return (effectIcons.get(tags.getInteger("Effect6")));
|
||||
}
|
||||
}
|
||||
return blankSprite;
|
||||
}
|
||||
return emptyIcon;
|
||||
}
|
||||
|
||||
ArrayList<int[]> coords = new ArrayList<int[]>();
|
||||
|
||||
@Override
|
||||
public boolean onBlockStartBreak (ItemStack stack, int x, int y, int z, EntityPlayer player)
|
||||
{
|
||||
World world = player.worldObj;
|
||||
final int blockID = world.getBlockId(x, y, z);
|
||||
final int meta = world.getBlockMetadata(x, y, z);
|
||||
Block block = Block.blocksList[blockID];
|
||||
if (!stack.hasTagCompound())
|
||||
return false;
|
||||
|
||||
if (block == null)
|
||||
return super.onBlockStartBreak(stack, x, y, z, player);
|
||||
|
||||
float blockHardness = block.getBlockHardness(world, x, y, z);
|
||||
|
||||
boolean validStart = false;
|
||||
for (int iter = 0; iter < materials.length; iter++)
|
||||
{
|
||||
if (materials[iter] == block.blockMaterial)
|
||||
{
|
||||
validStart = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
MovingObjectPosition mop = AbilityHelper.raytraceFromEntity(world, player, true, 5.0D);
|
||||
if (mop == null || !validStart)
|
||||
return super.onBlockStartBreak(stack, x, y, z, player);
|
||||
|
||||
int xRange = 1;
|
||||
int yRange = 1;
|
||||
int zRange = 1;
|
||||
switch (mop.sideHit)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
yRange = 0;
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
zRange = 0;
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
xRange = 0;
|
||||
break;
|
||||
}
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
for (int xPos = x - xRange; xPos <= x + xRange; xPos++)
|
||||
{
|
||||
for (int yPos = y - yRange; yPos <= y + yRange; yPos++)
|
||||
{
|
||||
for (int zPos = z - zRange; zPos <= z + zRange; zPos++)
|
||||
{
|
||||
if (!(tags.getBoolean("Broken")))
|
||||
{
|
||||
int localblockID = world.getBlockId(xPos, yPos, zPos);
|
||||
block = Block.blocksList[localblockID];
|
||||
int localMeta = world.getBlockMetadata(xPos, yPos, zPos);
|
||||
int hlvl = MinecraftForge.getBlockHarvestLevel(block, meta, getHarvestType());
|
||||
float localHardness = block == null ? Float.MAX_VALUE : block.getBlockHardness(world, xPos, yPos, zPos);
|
||||
|
||||
if (hlvl <= tags.getInteger("HarvestLevel") && localHardness - 1.5 <= blockHardness)
|
||||
{
|
||||
boolean cancelHarvest = false;
|
||||
for (ActiveToolMod mod : TConstructRegistry.activeModifiers)
|
||||
{
|
||||
if (mod.beforeBlockBreak(this, stack, xPos, yPos, zPos, player))
|
||||
cancelHarvest = true;
|
||||
}
|
||||
|
||||
if (!cancelHarvest)
|
||||
{
|
||||
if (block != null && !(localHardness < 0))
|
||||
{
|
||||
for (int iter = 0; iter < materials.length; iter++)
|
||||
{
|
||||
if (materials[iter] == block.blockMaterial)
|
||||
{
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
{
|
||||
block.harvestBlock(world, player, xPos, yPos, zPos, localMeta);
|
||||
block.onBlockHarvested(world, x, y, z, localMeta, player);
|
||||
if (blockHardness > 0f)
|
||||
onBlockDestroyed(stack, world, localblockID, xPos, yPos, zPos, player);
|
||||
}
|
||||
world.setBlockToAir(xPos, yPos, zPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!world.isRemote)
|
||||
world.playAuxSFX(2001, x, y, z, blockID + (meta << 12));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getStrVsBlock (ItemStack stack, Block block, int meta)
|
||||
{
|
||||
if (!stack.hasTagCompound())
|
||||
return 1.0f;
|
||||
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (tags.getBoolean("Broken"))
|
||||
return 0.1f;
|
||||
|
||||
Material[] materials = getEffectiveMaterials();
|
||||
for (int i = 0; i < materials.length; i++)
|
||||
{
|
||||
if (materials[i] == block.blockMaterial)
|
||||
{
|
||||
float mineSpeed = tags.getInteger("MiningSpeed");
|
||||
int heads = 1;
|
||||
if (tags.hasKey("MiningSpeed2"))
|
||||
{
|
||||
mineSpeed += tags.getInteger("MiningSpeed2");
|
||||
heads++;
|
||||
}
|
||||
|
||||
if (tags.hasKey("MiningSpeedHandle"))
|
||||
{
|
||||
mineSpeed += tags.getInteger("MiningSpeedHandle");
|
||||
heads++;
|
||||
}
|
||||
|
||||
if (tags.hasKey("MiningSpeedExtra"))
|
||||
{
|
||||
mineSpeed += tags.getInteger("MiningSpeedExtra");
|
||||
heads++;
|
||||
}
|
||||
float trueSpeed = mineSpeed / (heads * 300f);
|
||||
int hlvl = MinecraftForge.getBlockHarvestLevel(block, meta, getHarvestType());
|
||||
int durability = tags.getInteger("Damage");
|
||||
|
||||
float stonebound = tags.getFloat("Shoddy");
|
||||
float bonusLog = (float) Math.log(durability / 72f + 1) * 2 * stonebound;
|
||||
trueSpeed += bonusLog;
|
||||
|
||||
if (hlvl <= tags.getInteger("HarvestLevel"))
|
||||
return trueSpeed;
|
||||
return 0.1f;
|
||||
}
|
||||
}
|
||||
return super.getStrVsBlock(stack, block, meta);
|
||||
}
|
||||
|
||||
/*@Override
|
||||
public void onUpdate (ItemStack stack, World world, Entity entity, int par4, boolean par5)
|
||||
{
|
||||
super.onUpdate(stack, world, entity, par4, par5);
|
||||
if (entity instanceof EntityPlayer)
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer) entity;
|
||||
ItemStack equipped = player.getCurrentEquippedItem();
|
||||
if (equipped == stack)
|
||||
{
|
||||
player.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, 1, 1));
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public String[] toolCategories ()
|
||||
{
|
||||
return new String[] { "weapon", "harvest", "melee", "bludgeoning" };
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package tconstruct.items.tools;
|
||||
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.library.tools.AbilityHelper;
|
||||
import tconstruct.library.tools.HarvestTool;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class Hatchet extends HarvestTool
|
||||
{
|
||||
public Hatchet(int itemID)
|
||||
{
|
||||
super(itemID, 3);
|
||||
this.setUnlocalizedName("InfiTool.Axe");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Material[] getEffectiveMaterials ()
|
||||
{
|
||||
return materials;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getHarvestType ()
|
||||
{
|
||||
return "axe";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockDestroyed (ItemStack itemstack, World world, int bID, int x, int y, int z, EntityLivingBase player)
|
||||
{
|
||||
Block block = Block.blocksList[bID];
|
||||
if (block != null && block.blockMaterial == Material.leaves)
|
||||
return false;
|
||||
|
||||
return AbilityHelper.onBlockChanged(itemstack, world, bID, x, y, z, player, random);
|
||||
}
|
||||
|
||||
static Material[] materials = { Material.wood, Material.leaves, Material.vine, Material.circuits, Material.cactus, Material.pumpkin };
|
||||
|
||||
@Override
|
||||
public Item getHeadItem ()
|
||||
{
|
||||
return TContent.hatchetHead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getAccessoryItem ()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public int getRenderPasses (int metadata)
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPartAmount ()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerPartPaths (int index, String[] location)
|
||||
{
|
||||
headStrings.put(index, location[0]);
|
||||
brokenPartStrings.put(index, location[1]);
|
||||
handleStrings.put(index, location[2]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIconSuffix (int partType)
|
||||
{
|
||||
switch (partType)
|
||||
{
|
||||
case 0:
|
||||
return "_axe_head";
|
||||
case 1:
|
||||
return "_axe_head_broken";
|
||||
case 2:
|
||||
return "_axe_handle";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEffectSuffix ()
|
||||
{
|
||||
return "_axe_effect";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultFolder ()
|
||||
{
|
||||
return "axe";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
package tconstruct.items.tools;
|
||||
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.library.tools.Weapon;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class Longsword extends Weapon
|
||||
{
|
||||
public Longsword(int itemID)
|
||||
{
|
||||
super(itemID, 4);
|
||||
this.setUnlocalizedName("InfiTool.Longsword");
|
||||
}
|
||||
|
||||
public EnumAction getItemUseAction (ItemStack par1ItemStack)
|
||||
{
|
||||
return EnumAction.bow;
|
||||
}
|
||||
|
||||
public ItemStack onItemRightClick (ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
if (player.onGround)
|
||||
{
|
||||
player.setItemInUse(stack, this.getMaxItemUseDuration(stack));
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
public float chargeAttack ()
|
||||
{
|
||||
return 1.5f;
|
||||
}
|
||||
|
||||
public void onPlayerStoppedUsing (ItemStack stack, World world, EntityPlayer player, int useCount)
|
||||
{
|
||||
/*if (player.onGround)
|
||||
{
|
||||
int time = this.getMaxItemUseDuration(stack) - useCount;
|
||||
if (time > 5)
|
||||
{
|
||||
player.addExhaustion(0.2F);
|
||||
player.setSprinting(true);
|
||||
|
||||
float speed = 0.05F * time;
|
||||
if (speed > 0.925f)
|
||||
speed = 0.925f;
|
||||
|
||||
float increase = (float) (0.02 * time + 0.2);
|
||||
if (increase > 0.56f)
|
||||
increase = 0.56f;
|
||||
player.motionY += increase + speed/3;
|
||||
|
||||
player.motionX = (double) (-MathHelper.sin(player.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(player.rotationPitch / 180.0F * (float) Math.PI) * speed);
|
||||
player.motionZ = (double) (MathHelper.cos(player.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(player.rotationPitch / 180.0F * (float) Math.PI) * speed);
|
||||
}
|
||||
}*/
|
||||
int time = this.getMaxItemUseDuration(stack) - useCount;
|
||||
if (time > 5)
|
||||
{
|
||||
player.addExhaustion(0.2F);
|
||||
player.setSprinting(true);
|
||||
|
||||
float increase = (float) (0.02 * time + 0.2);
|
||||
if (increase > 0.56f)
|
||||
increase = 0.56f;
|
||||
player.motionY += increase;
|
||||
|
||||
float speed = 0.05F * time;
|
||||
if (speed > 0.925f)
|
||||
speed = 0.925f;
|
||||
player.motionX = (double) (-MathHelper.sin(player.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(player.rotationPitch / 180.0F * (float) Math.PI) * speed);
|
||||
player.motionZ = (double) (MathHelper.cos(player.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(player.rotationPitch / 180.0F * (float) Math.PI) * speed);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void onUpdate (ItemStack stack, World world, Entity entity, int par4, boolean par5)
|
||||
{
|
||||
super.onUpdate(stack, world, entity, par4, par5);
|
||||
if (entity instanceof EntityPlayerSP)
|
||||
{
|
||||
EntityPlayerSP player = (EntityPlayerSP) entity;
|
||||
ItemStack usingItem = player.getItemInUse();
|
||||
if (usingItem != null && usingItem.getItem() == this)
|
||||
{
|
||||
player.movementInput.moveForward *= 5.0F;
|
||||
player.movementInput.moveStrafe *= 5.0F;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getHeadItem ()
|
||||
{
|
||||
return TContent.swordBlade;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getAccessoryItem ()
|
||||
{
|
||||
return TContent.handGuard;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIconSuffix (int partType)
|
||||
{
|
||||
switch (partType)
|
||||
{
|
||||
case 0:
|
||||
return "_longsword_blade";
|
||||
case 1:
|
||||
return "_longsword_blade_broken";
|
||||
case 2:
|
||||
return "_longsword_handle";
|
||||
case 3:
|
||||
return "_longsword_accessory";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEffectSuffix ()
|
||||
{
|
||||
return "_longsword_effect";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultFolder ()
|
||||
{
|
||||
return "longsword";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,381 @@
|
||||
package tconstruct.items.tools;
|
||||
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.library.ActiveToolMod;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.tools.AbilityHelper;
|
||||
import tconstruct.library.tools.HarvestTool;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class LumberAxe extends HarvestTool
|
||||
{
|
||||
public LumberAxe(int itemID)
|
||||
{
|
||||
super(itemID, 0);
|
||||
this.setUnlocalizedName("InfiTool.LumberAxe");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Material[] getEffectiveMaterials ()
|
||||
{
|
||||
return materials;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getHarvestType ()
|
||||
{
|
||||
return "axe";
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getRepairCost ()
|
||||
{
|
||||
return 4.0f;
|
||||
}
|
||||
|
||||
public float getDurabilityModifier ()
|
||||
{
|
||||
return 2.5f;
|
||||
}
|
||||
|
||||
public String getToolName ()
|
||||
{
|
||||
return "Lumber Axe";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockDestroyed (ItemStack itemstack, World world, int bID, int x, int y, int z, EntityLivingBase player)
|
||||
{
|
||||
Block block = Block.blocksList[bID];
|
||||
if (block != null && block.blockMaterial == Material.leaves)
|
||||
return false;
|
||||
|
||||
return AbilityHelper.onBlockChanged(itemstack, world, bID, x, y, z, player, random);
|
||||
}
|
||||
|
||||
static Material[] materials = { Material.wood, Material.vine, Material.circuits, Material.cactus, Material.pumpkin };
|
||||
|
||||
/* Lumber axe specific */
|
||||
|
||||
/*@Override
|
||||
public void onUpdate (ItemStack stack, World world, Entity entity, int par4, boolean par5)
|
||||
{
|
||||
super.onUpdate(stack, world, entity, par4, par5);
|
||||
if (entity instanceof EntityPlayer)
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer) entity;
|
||||
ItemStack equipped = player.getCurrentEquippedItem();
|
||||
if (equipped == stack)
|
||||
{
|
||||
player.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, 1, 1));
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public float getStrVsBlock (ItemStack stack, Block block, int meta)
|
||||
{
|
||||
if (!stack.hasTagCompound())
|
||||
return 1.0f;
|
||||
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (tags.getBoolean("Broken"))
|
||||
return 0.1f;
|
||||
|
||||
Material[] materials = getEffectiveMaterials();
|
||||
for (int i = 0; i < materials.length; i++)
|
||||
{
|
||||
if (materials[i] == block.blockMaterial)
|
||||
{
|
||||
float mineSpeed = tags.getInteger("MiningSpeed");
|
||||
int heads = 1;
|
||||
if (tags.hasKey("MiningSpeed2"))
|
||||
{
|
||||
mineSpeed += tags.getInteger("MiningSpeed2");
|
||||
heads++;
|
||||
}
|
||||
|
||||
if (tags.hasKey("MiningSpeedHandle"))
|
||||
{
|
||||
mineSpeed += tags.getInteger("MiningSpeedHandle");
|
||||
heads++;
|
||||
}
|
||||
|
||||
if (tags.hasKey("MiningSpeedExtra"))
|
||||
{
|
||||
mineSpeed += tags.getInteger("MiningSpeedExtra");
|
||||
heads++;
|
||||
}
|
||||
float trueSpeed = mineSpeed / (heads * 300f);
|
||||
int hlvl = MinecraftForge.getBlockHarvestLevel(block, meta, getHarvestType());
|
||||
int durability = tags.getInteger("Damage");
|
||||
|
||||
float stonebound = tags.getFloat("Shoddy");
|
||||
float bonusLog = (float) Math.log(durability / 72f + 1) * 2 * stonebound;
|
||||
trueSpeed += bonusLog;
|
||||
|
||||
if (hlvl <= tags.getInteger("HarvestLevel"))
|
||||
return trueSpeed;
|
||||
return 0.1f;
|
||||
}
|
||||
}
|
||||
return super.getStrVsBlock(stack, block, meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockStartBreak (ItemStack stack, int x, int y, int z, EntityPlayer player)
|
||||
{
|
||||
World world = player.worldObj;
|
||||
final int woodID = world.getBlockId(x, y, z);
|
||||
final Block wood = Block.blocksList[woodID];
|
||||
if (wood.isWood(world, x, y, z))
|
||||
{
|
||||
int height = y;
|
||||
boolean foundTop = false;
|
||||
do
|
||||
{
|
||||
height++;
|
||||
int blockID = world.getBlockId(x, height, z);
|
||||
if (blockID != woodID)
|
||||
{
|
||||
height--;
|
||||
foundTop = true;
|
||||
}
|
||||
} while (!foundTop);
|
||||
|
||||
int numLeaves = 0;
|
||||
if (height - y < 30)
|
||||
{
|
||||
for (int xPos = x - 1; xPos <= x + 1; xPos++)
|
||||
{
|
||||
for (int yPos = height - 1; yPos <= height + 1; yPos++)
|
||||
{
|
||||
for (int zPos = z - 1; zPos <= z + 1; zPos++)
|
||||
{
|
||||
Block leaves = Block.blocksList[world.getBlockId(xPos, yPos, zPos)];
|
||||
if (leaves != null && leaves.isLeaves(world, xPos, yPos, zPos))
|
||||
numLeaves++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (numLeaves > 3)
|
||||
breakTree(world, x, y, z, stack, tags, woodID, meta, player);
|
||||
else
|
||||
destroyWood(world, x, y, z, stack, tags, player);
|
||||
|
||||
if (!world.isRemote)
|
||||
world.playAuxSFX(2001, x, y, z, woodID + (meta << 12));
|
||||
}
|
||||
return super.onBlockStartBreak(stack, x, y, z, player);
|
||||
}
|
||||
|
||||
void breakTree (World world, int x, int y, int z, ItemStack stack, NBTTagCompound tags, int bID, int meta, EntityPlayer player)
|
||||
{
|
||||
Block block;
|
||||
for (int xPos = x - 1; xPos <= x + 1; xPos++)
|
||||
{
|
||||
for (int yPos = y; yPos <= y + 1; yPos++)
|
||||
{
|
||||
for (int zPos = z - 1; zPos <= z + 1; zPos++)
|
||||
{
|
||||
if (!(tags.getBoolean("Broken")))
|
||||
{
|
||||
int localblockID = world.getBlockId(xPos, yPos, zPos);
|
||||
if (bID == localblockID)
|
||||
{
|
||||
block = Block.blocksList[localblockID];
|
||||
meta = world.getBlockMetadata(xPos, yPos, zPos);
|
||||
int hlvl = MinecraftForge.getBlockHarvestLevel(block, meta, getHarvestType());
|
||||
|
||||
if (hlvl <= tags.getInteger("HarvestLevel"))
|
||||
{
|
||||
boolean cancelHarvest = false;
|
||||
for (ActiveToolMod mod : TConstructRegistry.activeModifiers)
|
||||
{
|
||||
if (mod.beforeBlockBreak(this, stack, xPos, yPos, zPos, player))
|
||||
cancelHarvest = true;
|
||||
}
|
||||
|
||||
if (cancelHarvest)
|
||||
{
|
||||
breakTree(world, xPos, yPos, zPos, stack, tags, bID, meta, player);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (localblockID == bID && world.getBlockMetadata(xPos, yPos, zPos) % 4 == meta % 4)
|
||||
{
|
||||
/* world.setBlock(xPos, yPos, zPos, 0, 0, 3);
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
{
|
||||
Block.blocksList[bID].harvestBlock(world, player, xPos, yPos, zPos, meta);
|
||||
onBlockDestroyed(stack, world, bID, xPos, yPos, zPos, player);
|
||||
}*/
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
{
|
||||
block.harvestBlock(world, player, xPos, yPos, zPos, meta);
|
||||
block.onBlockHarvested(world, x, y, z, meta, player);
|
||||
onBlockDestroyed(stack, world, localblockID, xPos, yPos, zPos, player);
|
||||
}
|
||||
world.setBlockToAir(xPos, yPos, zPos);
|
||||
breakTree(world, xPos, yPos, zPos, stack, tags, bID, meta, player);
|
||||
}
|
||||
/*else
|
||||
{
|
||||
Block leaves = Block.blocksList[localID];
|
||||
if (leaves != null && leaves.isLeaves(world, xPos, yPos, zPos))
|
||||
{
|
||||
world.setBlockToAir(xPos, yPos, zPos);
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
{
|
||||
Block.blocksList[bID].harvestBlock(world, player, xPos, yPos, zPos, meta);
|
||||
onBlockDestroyed(stack, world, bID, xPos, yPos, zPos, player);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void destroyWood (World world, int x, int y, int z, ItemStack stack, NBTTagCompound tags, EntityPlayer player)
|
||||
{
|
||||
for (int xPos = x - 1; xPos <= x + 1; xPos++)
|
||||
{
|
||||
for (int yPos = y - 1; yPos <= y + 1; yPos++)
|
||||
{
|
||||
for (int zPos = z - 1; zPos <= z + 1; zPos++)
|
||||
{
|
||||
if (!(tags.getBoolean("Broken")))
|
||||
{
|
||||
int localblockID = world.getBlockId(xPos, yPos, zPos);
|
||||
Block block = Block.blocksList[localblockID];
|
||||
int meta = world.getBlockMetadata(xPos, yPos, zPos);
|
||||
int hlvl = MinecraftForge.getBlockHarvestLevel(block, meta, getHarvestType());
|
||||
|
||||
if (hlvl <= tags.getInteger("HarvestLevel"))
|
||||
{
|
||||
boolean cancelHarvest = false;
|
||||
for (ActiveToolMod mod : TConstructRegistry.activeModifiers)
|
||||
{
|
||||
if (mod.beforeBlockBreak(this, stack, xPos, yPos, zPos, player))
|
||||
cancelHarvest = true;
|
||||
}
|
||||
|
||||
if (!cancelHarvest)
|
||||
{
|
||||
if (block != null && block.blockMaterial == Material.wood)
|
||||
{
|
||||
world.setBlockToAir(xPos, yPos, zPos);
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
{
|
||||
block.harvestBlock(world, player, xPos, yPos, zPos, meta);
|
||||
onBlockDestroyed(stack, world, localblockID, xPos, yPos, zPos, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getHeadItem ()
|
||||
{
|
||||
return TContent.broadAxeHead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getHandleItem ()
|
||||
{
|
||||
return TContent.toughRod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getAccessoryItem ()
|
||||
{
|
||||
return TContent.heavyPlate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getExtraItem ()
|
||||
{
|
||||
return TContent.toughBinding;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public int getRenderPasses (int metadata)
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPartAmount ()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIconSuffix (int partType)
|
||||
{
|
||||
switch (partType)
|
||||
{
|
||||
case 0:
|
||||
return "_lumberaxe_head";
|
||||
case 1:
|
||||
return "_lumberaxe_head_broken";
|
||||
case 2:
|
||||
return "_lumberaxe_handle";
|
||||
case 3:
|
||||
return "_lumberaxe_shield";
|
||||
case 4:
|
||||
return "_lumberaxe_binding";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEffectSuffix ()
|
||||
{
|
||||
return "_lumberaxe_effect";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultFolder ()
|
||||
{
|
||||
return "lumberaxe";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int durabilityTypeAccessory ()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int durabilityTypeExtra ()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package tconstruct.items.tools;
|
||||
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.library.tools.AbilityHelper;
|
||||
import tconstruct.library.tools.DualHarvestTool;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class Mattock extends DualHarvestTool
|
||||
{
|
||||
public Mattock(int itemID)
|
||||
{
|
||||
super(itemID, 3);
|
||||
this.setUnlocalizedName("InfiTool.Mattock");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Material[] getEffectiveMaterials ()
|
||||
{
|
||||
return axeMaterials;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Material[] getEffectiveSecondaryMaterials ()
|
||||
{
|
||||
return shovelMaterials;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getHarvestType ()
|
||||
{
|
||||
return "axe";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getSecondHarvestType ()
|
||||
{
|
||||
return "shovel";
|
||||
}
|
||||
|
||||
static Material[] axeMaterials = { Material.wood, Material.cactus, Material.pumpkin, Material.plants, Material.vine };
|
||||
static Material[] shovelMaterials = { Material.grass, Material.ground, Material.clay };
|
||||
|
||||
@Override
|
||||
public Item getHeadItem ()
|
||||
{
|
||||
return TContent.hatchetHead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getAccessoryItem ()
|
||||
{
|
||||
return TContent.shovelHead;
|
||||
}
|
||||
|
||||
public int durabilityTypeAccessory ()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIconSuffix (int partType)
|
||||
{
|
||||
switch (partType)
|
||||
{
|
||||
case 0:
|
||||
return "_mattock_head";
|
||||
case 1:
|
||||
return "_mattock_head_broken";
|
||||
case 2:
|
||||
return "_mattock_handle";
|
||||
case 3:
|
||||
return "_mattock_back";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEffectSuffix ()
|
||||
{
|
||||
return "_mattock_effect";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultFolder ()
|
||||
{
|
||||
return "mattock";
|
||||
}
|
||||
|
||||
/* Mattock specific */
|
||||
|
||||
@Override
|
||||
public boolean onItemUse (ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float clickX, float clickY, float clickZ)
|
||||
{
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (tags.getBoolean("Broken"))
|
||||
return false;
|
||||
|
||||
return AbilityHelper.hoeGround(stack, player, world, x, y, z, side, random);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package tconstruct.items.tools;
|
||||
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.library.tools.HarvestTool;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
public class Pickaxe extends HarvestTool
|
||||
{
|
||||
public Pickaxe(int itemID)
|
||||
{
|
||||
super(itemID, 1);
|
||||
this.setUnlocalizedName("InfiTool.Pickaxe");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getHarvestType ()
|
||||
{
|
||||
return "pickaxe";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Material[] getEffectiveMaterials ()
|
||||
{
|
||||
return materials;
|
||||
}
|
||||
|
||||
static Material[] materials = new Material[] { Material.rock, Material.iron, Material.ice, Material.glass, Material.piston, Material.anvil, Material.circuits };
|
||||
|
||||
@Override
|
||||
public Item getHeadItem ()
|
||||
{
|
||||
return TContent.pickaxeHead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getAccessoryItem ()
|
||||
{
|
||||
return TContent.binding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIconSuffix (int partType)
|
||||
{
|
||||
switch (partType)
|
||||
{
|
||||
case 0:
|
||||
return "_pickaxe_head";
|
||||
case 1:
|
||||
return "_pickaxe_head_broken";
|
||||
case 2:
|
||||
return "_pickaxe_handle";
|
||||
case 3:
|
||||
return "_pickaxe_accessory";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEffectSuffix ()
|
||||
{
|
||||
return "_pickaxe_effect";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultFolder ()
|
||||
{
|
||||
return "pickaxe";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
package tconstruct.items.tools;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import tconstruct.entity.projectile.LaunchedPotion;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class PotionLauncher extends Item
|
||||
{
|
||||
@SideOnly(Side.CLIENT)
|
||||
private Icon[] icons;
|
||||
public static final String[] textureNames = new String[] { "potionlauncher" };
|
||||
|
||||
public PotionLauncher(int par1)
|
||||
{
|
||||
super(par1);
|
||||
this.maxStackSize = 1;
|
||||
this.setCreativeTab(CreativeTabs.tabCombat);
|
||||
this.setMaxDamage(3);
|
||||
}
|
||||
|
||||
public ItemStack onEaten (ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
boolean loaded = tags.getBoolean("Loaded");
|
||||
if (!loaded)
|
||||
{
|
||||
int slotID = getInventorySlotContainItem(Item.potion.itemID, player.inventory);
|
||||
ItemStack potion = player.inventory.getStackInSlot(slotID);
|
||||
|
||||
NBTTagCompound potionTag = new NBTTagCompound();
|
||||
potion.writeToNBT(potionTag);
|
||||
tags.setCompoundTag("LoadedPotion", potionTag);
|
||||
tags.setBoolean("Loaded", true);
|
||||
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
{
|
||||
potion.stackSize--;
|
||||
if (potion.stackSize < 1)
|
||||
player.inventory.setInventorySlotContents(slotID, null);
|
||||
}
|
||||
|
||||
world.playSoundEffect(player.posX, player.posY, player.posZ, "sounds.launcher_clank", 1.0F, (world.rand.nextFloat() - world.rand.nextFloat()) * 0.15F + 1.0F);
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
public void onPlayerStoppedUsing (ItemStack stack, World world, EntityPlayer player, int time)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ItemStack onItemRightClick (ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
int slotID = getInventorySlotContainItem(Item.potion.itemID, player.inventory);
|
||||
if (!tags.getBoolean("Loaded") && slotID >= 0)
|
||||
player.setItemInUse(stack, this.getMaxItemUseDuration(stack));
|
||||
return stack;
|
||||
}
|
||||
|
||||
/**
|
||||
* How long it takes to use or consume an item
|
||||
*/
|
||||
public int getMaxItemUseDuration (ItemStack stack)
|
||||
{
|
||||
return 30;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the action that specifies what animation to play when the items is being used
|
||||
*/
|
||||
public EnumAction getItemUseAction (ItemStack stack)
|
||||
{
|
||||
if (!stack.getTagCompound().getCompoundTag("InfiTool").getBoolean("Loaded"))
|
||||
return EnumAction.bow;
|
||||
else
|
||||
return EnumAction.none;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons (IconRegister par1IconRegister)
|
||||
{
|
||||
this.icons = new Icon[textureNames.length];
|
||||
|
||||
for (int i = 0; i < this.icons.length; ++i)
|
||||
{
|
||||
this.icons[i] = par1IconRegister.registerIcon("tinker:" + textureNames[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Icon getIconFromDamage (int meta)
|
||||
{
|
||||
return icons[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems (int id, CreativeTabs tabs, List list)
|
||||
{
|
||||
ItemStack stack = new ItemStack(id, 1, 0);
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
NBTTagCompound tags = new NBTTagCompound();
|
||||
compound.setCompoundTag("InfiTool", tags);
|
||||
|
||||
tags.setBoolean("Loaded", false);
|
||||
|
||||
stack.setTagCompound(compound);
|
||||
|
||||
list.add(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onEntitySwing (EntityLivingBase player, ItemStack stack)
|
||||
{
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (tags.getBoolean("Loaded"))
|
||||
{
|
||||
NBTTagCompound potionTag = tags.getCompoundTag("LoadedPotion");
|
||||
ItemStack potion = ItemStack.loadItemStackFromNBT(potionTag);//findPotion(player);InventoryLogic
|
||||
if (potion != null)
|
||||
{
|
||||
World world = player.worldObj;
|
||||
world.playSoundAtEntity(player, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
|
||||
|
||||
if (!world.isRemote)
|
||||
{
|
||||
world.spawnEntityInWorld(new LaunchedPotion(world, player, potion));
|
||||
}
|
||||
tags.removeTag("LoadedPotion");
|
||||
tags.setBoolean("Loaded", false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
ItemStack findPotion (EntityLivingBase living)
|
||||
{
|
||||
if (living instanceof EntityPlayer)
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer) living;
|
||||
int potionSlot = getInventorySlotContainItem(Item.potion.itemID, player.inventory);
|
||||
if (potionSlot >= 0)
|
||||
{
|
||||
return player.inventory.getStackInSlot(potionSlot);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
int getInventorySlotContainItem (int itemID, InventoryPlayer inventory)
|
||||
{
|
||||
for (int j = 0; j < inventory.mainInventory.length; ++j)
|
||||
{
|
||||
if (inventory.mainInventory[j] != null && inventory.mainInventory[j].itemID == itemID)
|
||||
{
|
||||
return j;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation (ItemStack stack, EntityPlayer player, List list, boolean par4)
|
||||
{
|
||||
list.add("Test Item");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
package tconstruct.items.tools;
|
||||
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.library.tools.Weapon;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class Rapier extends Weapon
|
||||
{
|
||||
public Rapier(int itemID)
|
||||
{
|
||||
super(itemID, 2);
|
||||
this.setUnlocalizedName("InfiTool.Rapier");
|
||||
}
|
||||
|
||||
public EnumAction getItemUseAction (ItemStack par1ItemStack)
|
||||
{
|
||||
return EnumAction.none;
|
||||
}
|
||||
|
||||
public ItemStack onItemRightClick (ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
if (player.onGround)
|
||||
{
|
||||
player.addExhaustion(0.1f);
|
||||
player.motionY += 0.32;
|
||||
float f = 0.5F;
|
||||
player.motionX = (double) (MathHelper.sin(player.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(player.rotationPitch / 180.0F * (float) Math.PI) * f);
|
||||
player.motionZ = (double) (-MathHelper.cos(player.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(player.rotationPitch / 180.0F * (float) Math.PI) * f);
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hitEntity (ItemStack stack, EntityLivingBase mob, EntityLivingBase player)
|
||||
{
|
||||
//AbilityHelper.hitEntity(stack, mob, player, damageVsEntity);
|
||||
//AbilityHelper.knockbackEntity(mob, 0.8f);
|
||||
mob.motionY *= 0.8;
|
||||
if (mob.hurtResistantTime > 18)
|
||||
mob.hurtResistantTime -= 5;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDurabilityModifier ()
|
||||
{
|
||||
return 0.7f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDamageModifier ()
|
||||
{
|
||||
return 0.8f;
|
||||
}
|
||||
|
||||
/*public float chargeAttack ()
|
||||
{
|
||||
return 1.0f;
|
||||
}*/
|
||||
|
||||
public boolean pierceArmor ()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getHeadItem ()
|
||||
{
|
||||
return TContent.swordBlade;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getAccessoryItem ()
|
||||
{
|
||||
return TContent.crossbar;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIconSuffix (int partType)
|
||||
{
|
||||
switch (partType)
|
||||
{
|
||||
case 0:
|
||||
return "_rapier_blade";
|
||||
case 1:
|
||||
return "_rapier_blade_broken";
|
||||
case 2:
|
||||
return "_rapier_handle";
|
||||
case 3:
|
||||
return "_rapier_accessory";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEffectSuffix ()
|
||||
{
|
||||
return "_rapier_effect";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultFolder ()
|
||||
{
|
||||
return "rapier";
|
||||
}
|
||||
|
||||
protected Material[] getEffectiveMaterials ()
|
||||
{
|
||||
return none;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,217 @@
|
||||
package tconstruct.items.tools;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.library.ActiveToolMod;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.tools.AbilityHelper;
|
||||
import tconstruct.library.tools.Weapon;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class Scythe extends Weapon
|
||||
{
|
||||
public Scythe(int itemID)
|
||||
{
|
||||
super(itemID, 4);
|
||||
this.setUnlocalizedName("InfiTool.Scythe");
|
||||
}
|
||||
|
||||
/*@Override
|
||||
protected String getHarvestType()
|
||||
{
|
||||
return "sword";
|
||||
}*/
|
||||
|
||||
@Override
|
||||
protected Material[] getEffectiveMaterials ()
|
||||
{
|
||||
return materials;
|
||||
}
|
||||
|
||||
static Material[] materials = new Material[] { Material.web, Material.cactus, Material.pumpkin, Material.plants, Material.vine, Material.leaves };
|
||||
|
||||
@Override
|
||||
public Item getHeadItem ()
|
||||
{
|
||||
return TContent.scytheBlade;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getHandleItem ()
|
||||
{
|
||||
return TContent.toughRod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getAccessoryItem ()
|
||||
{
|
||||
return TContent.toughBinding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getExtraItem ()
|
||||
{
|
||||
return TContent.toughRod;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public int getRenderPasses (int metadata)
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPartAmount ()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIconSuffix (int partType)
|
||||
{
|
||||
switch (partType)
|
||||
{
|
||||
case 0:
|
||||
return "_scythe_head";
|
||||
case 1:
|
||||
return "_scythe_head_broken";
|
||||
case 2:
|
||||
return "_scythe_handle";
|
||||
case 3:
|
||||
return "_scythe_binding";
|
||||
case 4:
|
||||
return "_scythe_accessory";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public float getDurabilityModifier ()
|
||||
{
|
||||
return 3.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getRepairCost ()
|
||||
{
|
||||
return 4.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEffectSuffix ()
|
||||
{
|
||||
return "_scythe_effect";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultFolder ()
|
||||
{
|
||||
return "scythe";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int durabilityTypeAccessory ()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int durabilityTypeExtra ()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDamageModifier ()
|
||||
{
|
||||
return 0.75f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] toolCategories ()
|
||||
{
|
||||
return new String[] { "weapon", "melee", "harvest" };
|
||||
}
|
||||
|
||||
/* Scythe Specific */
|
||||
|
||||
@Override
|
||||
public boolean onBlockStartBreak (ItemStack stack, int x, int y, int z, EntityPlayer player)
|
||||
{
|
||||
World world = player.worldObj;
|
||||
final int blockID = world.getBlockId(x, y, z);
|
||||
final int meta = world.getBlockMetadata(x, y, z);
|
||||
if (!stack.hasTagCompound())
|
||||
return false;
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
for (int xPos = x - 1; xPos <= x + 1; xPos++)
|
||||
{
|
||||
for (int yPos = y - 1; yPos <= y + 1; yPos++)
|
||||
{
|
||||
for (int zPos = z - 1; zPos <= z + 1; zPos++)
|
||||
{
|
||||
if (!(tags.getBoolean("Broken")))
|
||||
{
|
||||
boolean cancelHarvest = false;
|
||||
for (ActiveToolMod mod : TConstructRegistry.activeModifiers)
|
||||
{
|
||||
if (mod.beforeBlockBreak(this, stack, xPos, yPos, zPos, player))
|
||||
cancelHarvest = true;
|
||||
}
|
||||
|
||||
if (!cancelHarvest)
|
||||
{
|
||||
int localblockID = world.getBlockId(xPos, yPos, zPos);
|
||||
Block block = Block.blocksList[localblockID];
|
||||
if (block != null)// && (block.blockMaterial == Material.leaves || block.isLeaves(world, xPos, yPos, zPos)))
|
||||
{
|
||||
for (int iter = 0; iter < materials.length; iter++)
|
||||
{
|
||||
if (materials[iter] == block.blockMaterial)
|
||||
{
|
||||
int localMeta = world.getBlockMetadata(xPos, yPos, zPos);
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
{
|
||||
block.harvestBlock(world, player, xPos, yPos, zPos, localMeta);
|
||||
block.onBlockHarvested(world, x, y, z, localMeta, player);
|
||||
onBlockDestroyed(stack, world, localblockID, xPos, yPos, zPos, player);
|
||||
}
|
||||
world.setBlockToAir(xPos, yPos, zPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!world.isRemote)
|
||||
world.playAuxSFX(2001, x, y, z, blockID + (meta << 12));
|
||||
return super.onBlockStartBreak(stack, x, y, z, player);
|
||||
}
|
||||
|
||||
public boolean onLeftClickEntity (ItemStack stack, EntityPlayer player, Entity entity)
|
||||
{
|
||||
AxisAlignedBB box = AxisAlignedBB.getAABBPool().getAABB(entity.posX, entity.posY, entity.posZ, entity.posX + 1.0D, entity.posY + 1.0D, entity.posZ + 1.0D).expand(1.0D, 1.0D, 1.0D);
|
||||
List list = player.worldObj.getEntitiesWithinAABBExcludingEntity(player, box);
|
||||
for (Object o : list)
|
||||
{
|
||||
AbilityHelper.onLeftClickEntity(stack, player, (Entity) o, this);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
package tconstruct.items.tools;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.library.tools.BowBase;
|
||||
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class Shortbow extends BowBase
|
||||
{
|
||||
public Shortbow(int itemID)
|
||||
{
|
||||
super(itemID);
|
||||
this.setUnlocalizedName("InfiTool.Shortbow");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIconSuffix (int partType)
|
||||
{
|
||||
switch (partType)
|
||||
{
|
||||
case 0:
|
||||
return "_bow_top";
|
||||
case 1:
|
||||
return "_bowstring_broken";
|
||||
case 2:
|
||||
return "_bowstring";
|
||||
case 3:
|
||||
return "_bow_bottom";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEffectSuffix ()
|
||||
{
|
||||
return "_bow_effect";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultFolder ()
|
||||
{
|
||||
return "shortbow";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getHeadItem ()
|
||||
{
|
||||
return TContent.toolRod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getHandleItem ()
|
||||
{
|
||||
return TContent.bowstring;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getAccessoryItem ()
|
||||
{
|
||||
return TContent.toolRod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] toolCategories ()
|
||||
{
|
||||
return new String[] { "weapon", "ranged", "bow" };
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void onUpdate (ItemStack stack, World world, Entity entity, int par4, boolean par5)
|
||||
{
|
||||
super.onUpdate(stack, world, entity, par4, par5);
|
||||
if (entity instanceof EntityPlayerSP)
|
||||
{
|
||||
EntityPlayerSP player = (EntityPlayerSP) entity;
|
||||
ItemStack usingItem = player.getItemInUse();
|
||||
if (usingItem != null && usingItem.getItem() == this)
|
||||
{
|
||||
player.movementInput.moveForward *= 2.0F;
|
||||
player.movementInput.moveStrafe *= 2.0F;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation (ItemStack stack, EntityPlayer player, List list, boolean par4)
|
||||
{
|
||||
if (!stack.hasTagCompound())
|
||||
return;
|
||||
|
||||
NBTTagCompound tags = stack.getTagCompound();
|
||||
if (tags.hasKey("charge"))
|
||||
{
|
||||
String color = "";
|
||||
//double joules = this.getJoules(stack);
|
||||
int power = tags.getInteger("charge");
|
||||
|
||||
if (power != 0)
|
||||
{
|
||||
if (power <= this.getMaxCharge(stack) / 3)
|
||||
color = "\u00a74";
|
||||
else if (power > this.getMaxCharge(stack) * 2 / 3)
|
||||
color = "\u00a72";
|
||||
else
|
||||
color = "\u00a76";
|
||||
}
|
||||
|
||||
String charge = new StringBuilder().append(color).append(tags.getInteger("charge")).append("/").append(getMaxCharge(stack)).append(" EU").toString();
|
||||
list.add(charge);
|
||||
}
|
||||
if (tags.hasKey("InfiTool"))
|
||||
{
|
||||
boolean broken = tags.getCompoundTag("InfiTool").getBoolean("Broken");
|
||||
if (broken)
|
||||
list.add("\u00A7oBroken");
|
||||
else
|
||||
{
|
||||
int head = tags.getCompoundTag("InfiTool").getInteger("Head");
|
||||
int handle = tags.getCompoundTag("InfiTool").getInteger("Handle");
|
||||
int binding = tags.getCompoundTag("InfiTool").getInteger("Accessory");
|
||||
int extra = tags.getCompoundTag("InfiTool").getInteger("Extra");
|
||||
|
||||
String headName = getAbilityNameForType(head);
|
||||
if (!headName.equals(""))
|
||||
list.add(getStyleForType(head) + headName);
|
||||
|
||||
String handleName = getBowstringName(handle);
|
||||
if (!handleName.equals("") && handle != head)
|
||||
list.add(handleName);
|
||||
|
||||
if (getPartAmount() >= 3)
|
||||
{
|
||||
String bindingName = getAbilityNameForType(binding);
|
||||
if (!bindingName.equals("") && binding != head && binding != handle)
|
||||
list.add(getStyleForType(binding) + bindingName);
|
||||
}
|
||||
|
||||
if (getPartAmount() >= 4)
|
||||
{
|
||||
String extraName = getAbilityNameForType(extra);
|
||||
if (!extraName.equals("") && extra != head && extra != handle && extra != binding)
|
||||
list.add(getStyleForType(extra) + extraName);
|
||||
}
|
||||
|
||||
int unbreaking = tags.getCompoundTag("InfiTool").getInteger("Unbreaking");
|
||||
String reinforced = getReinforcedName(head, handle, binding, extra, unbreaking);
|
||||
if (!reinforced.equals(""))
|
||||
list.add(reinforced);
|
||||
|
||||
boolean displayToolTips = true;
|
||||
int tipNum = 0;
|
||||
while (displayToolTips)
|
||||
{
|
||||
tipNum++;
|
||||
String tooltip = "Tooltip" + tipNum;
|
||||
if (tags.getCompoundTag("InfiTool").hasKey(tooltip))
|
||||
{
|
||||
String tipName = tags.getCompoundTag("InfiTool").getString(tooltip);
|
||||
if (!tipName.equals(""))
|
||||
list.add(tipName);
|
||||
}
|
||||
else
|
||||
displayToolTips = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getBowstringName (int type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case 0:
|
||||
return "";
|
||||
case 1:
|
||||
return "\u00A7bEnchanted";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
//return TConstructRegistry.getMaterial(type).ability();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
package tconstruct.items.tools;
|
||||
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.library.tools.HarvestTool;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.item.Item;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class Shovel extends HarvestTool
|
||||
{
|
||||
public Shovel(int itemID)
|
||||
{
|
||||
super(itemID, 2);
|
||||
this.setUnlocalizedName("InfiTool.Shovel");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Material[] getEffectiveMaterials ()
|
||||
{
|
||||
return materials;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getHarvestType ()
|
||||
{
|
||||
return "shovel";
|
||||
}
|
||||
|
||||
static Material[] materials = { Material.grass, Material.ground, Material.sand, Material.snow, Material.craftedSnow, Material.clay };
|
||||
|
||||
@Override
|
||||
public Item getHeadItem ()
|
||||
{
|
||||
return TContent.shovelHead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getAccessoryItem ()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public int getRenderPasses (int metadata)
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPartAmount ()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerPartPaths (int index, String[] location)
|
||||
{
|
||||
headStrings.put(index, location[0]);
|
||||
brokenPartStrings.put(index, location[1]);
|
||||
handleStrings.put(index, location[2]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIconSuffix (int partType)
|
||||
{
|
||||
switch (partType)
|
||||
{
|
||||
case 0:
|
||||
return "_shovel_head";
|
||||
case 1:
|
||||
return "_shovel_head_broken";
|
||||
case 2:
|
||||
return "_shovel_handle";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEffectSuffix ()
|
||||
{
|
||||
return "_shovel_effect";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultFolder ()
|
||||
{
|
||||
return "shovel";
|
||||
}
|
||||
|
||||
/*@Override
|
||||
public Icon getIcon (ItemStack stack, int renderPass)
|
||||
{
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
|
||||
if (renderPass == 0) // Handle
|
||||
{
|
||||
return (handleIcons.get(tags.getInteger("RenderHandle")));
|
||||
}
|
||||
|
||||
if (renderPass == 1) // Head
|
||||
{
|
||||
if (tags.getBoolean("Broken"))
|
||||
return (brokenHeadIcons.get(tags.getInteger("RenderHead")));
|
||||
else
|
||||
return (headIcons.get(tags.getInteger("RenderHead")));
|
||||
}
|
||||
|
||||
if (renderPass == 2)
|
||||
{
|
||||
if (tags.hasKey("Effect1"))
|
||||
return (effectIcons.get(tags.getInteger("Effect1")));
|
||||
}
|
||||
|
||||
if (renderPass == 3)
|
||||
{
|
||||
if (tags.hasKey("Effect2"))
|
||||
return (effectIcons.get(tags.getInteger("Effect2")));
|
||||
}
|
||||
|
||||
if (renderPass == 4)
|
||||
{
|
||||
if (tags.hasKey("Effect3"))
|
||||
return (effectIcons.get(tags.getInteger("Effect3")));
|
||||
}
|
||||
|
||||
return TProxyClient.blankSprite;
|
||||
}*/
|
||||
}
|
||||
Reference in new issue
Block a user