Added omnitool
This commit is contained in:
parent
2b0fd80def
commit
4a291087ad
4 changed files with 186 additions and 1 deletions
|
@ -13,6 +13,7 @@ import techreborn.items.ItemIngots;
|
|||
import techreborn.items.ItemParts;
|
||||
import techreborn.items.tools.ItemLapotronPack;
|
||||
import techreborn.items.tools.ItemLithiumBatpack;
|
||||
import techreborn.items.tools.ItemOmniTool;
|
||||
import techreborn.items.tools.ItemRockCutter;
|
||||
import techreborn.util.LogHelper;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
@ -26,6 +27,7 @@ public class ModItems {
|
|||
public static Item rockCutter;
|
||||
public static Item lithiumBatpack;
|
||||
public static Item lapotronpack;
|
||||
public static Item omniTool;
|
||||
|
||||
public static void init()
|
||||
{
|
||||
|
@ -43,6 +45,8 @@ public class ModItems {
|
|||
GameRegistry.registerItem(lithiumBatpack, "lithiumBatpack");
|
||||
lapotronpack = new ItemLapotronPack(ArmorMaterial.DIAMOND, 7, 1);
|
||||
GameRegistry.registerItem(lapotronpack, "lapotronPack");
|
||||
omniTool = new ItemOmniTool(ToolMaterial.EMERALD);
|
||||
GameRegistry.registerItem(omniTool, "omniTool");
|
||||
|
||||
LogHelper.info("TechReborns Items Loaded");
|
||||
|
||||
|
|
|
@ -218,7 +218,7 @@ public class ModRecipes {
|
|||
CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.ingots,9,14), "blockPlatinum");
|
||||
CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.ingots,9,15), "blockNickel");
|
||||
CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.ingots,9,16), "blockInvar");
|
||||
CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.rockCutter), Items.apple);
|
||||
CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.rockCutter,1,27), Items.apple);
|
||||
|
||||
|
||||
LogHelper.info("Shapless Recipes Added");
|
||||
|
|
180
src/main/java/techreborn/items/tools/ItemOmniTool.java
Normal file
180
src/main/java/techreborn/items/tools/ItemOmniTool.java
Normal file
|
@ -0,0 +1,180 @@
|
|||
package techreborn.items.tools;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import ic2.api.item.ElectricItem;
|
||||
import ic2.api.item.IElectricItem;
|
||||
import techreborn.client.TechRebornCreativeTab;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemPickaxe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
|
||||
public class ItemOmniTool extends ItemPickaxe implements IElectricItem{
|
||||
|
||||
public int maxCharge = 20000;
|
||||
public int cost = 100;
|
||||
public int hitCost = 125;
|
||||
|
||||
public ItemOmniTool(ToolMaterial toolMaterial)
|
||||
{
|
||||
super(toolMaterial);
|
||||
efficiencyOnProperMaterial = 13F;
|
||||
setCreativeTab(TechRebornCreativeTab.instance);
|
||||
setMaxStackSize(1);
|
||||
setMaxDamage(200);
|
||||
setUnlocalizedName("techreborn.omniTool");
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("techreborn:" + "omnitool");
|
||||
}
|
||||
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList)
|
||||
{
|
||||
ItemStack itemStack = new ItemStack(this, 1);
|
||||
if (getChargedItem(itemStack) == this)
|
||||
{
|
||||
ItemStack charged = new ItemStack(this, 1);
|
||||
ElectricItem.manager.charge(charged, 2147483647, 2147483647, true,false);
|
||||
itemList.add(charged);
|
||||
}
|
||||
if (getEmptyItem(itemStack) == this)
|
||||
{
|
||||
itemList.add(new ItemStack(this, 1, getMaxDamage()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int par4, int par5, int par6, EntityLivingBase entityLiving)
|
||||
{
|
||||
ElectricItem.manager.use(stack, cost, entityLiving);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHarvestBlock(Block block, ItemStack stack)
|
||||
{
|
||||
return Items.diamond_axe.canHarvestBlock(block, stack) || Items.diamond_sword.canHarvestBlock(block, stack) || Items.diamond_pickaxe.canHarvestBlock(block, stack) || Items.diamond_shovel.canHarvestBlock(block, stack) || Items.shears.canHarvestBlock(block, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDigSpeed(ItemStack stack, Block block, int meta)
|
||||
{
|
||||
if (!ElectricItem.manager.canUse(stack, cost))
|
||||
{
|
||||
return 5.0F;
|
||||
}
|
||||
|
||||
if (Items.wooden_axe.getDigSpeed(stack, block, meta) > 1.0F || Items.wooden_sword.getDigSpeed(stack, block, meta) > 1.0F || Items.wooden_pickaxe.getDigSpeed(stack, block, meta) > 1.0F || Items.wooden_shovel.getDigSpeed(stack, block, meta) > 1.0F || Items.shears.getDigSpeed(stack, block, meta) > 1.0F)
|
||||
{
|
||||
return efficiencyOnProperMaterial;
|
||||
} else {
|
||||
return super.getDigSpeed(stack, block, meta);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hitEntity(ItemStack itemstack, EntityLivingBase entityliving, EntityLivingBase attacker)
|
||||
{
|
||||
if (ElectricItem.manager.use(itemstack, hitCost, attacker))
|
||||
{
|
||||
entityliving.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) attacker), 8F);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float xOffset, float yOffset, float zOffset)
|
||||
{
|
||||
for (int i = 0; i < player.inventory.mainInventory.length; i++) {
|
||||
ItemStack torchStack = player.inventory.mainInventory[i];
|
||||
if (torchStack == null || !torchStack.getUnlocalizedName().toLowerCase().contains("torch"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Item item = torchStack.getItem();
|
||||
if (!(item instanceof ItemBlock))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
int oldMeta = torchStack.getItemDamage();
|
||||
int oldSize = torchStack.stackSize;
|
||||
boolean result = torchStack.tryPlaceItemIntoWorld(player, world, x, y, z, side, xOffset, yOffset, zOffset);
|
||||
if (player.capabilities.isCreativeMode)
|
||||
{
|
||||
torchStack.setItemDamage(oldMeta);
|
||||
torchStack.stackSize = oldSize;
|
||||
} else if (torchStack.stackSize <= 0)
|
||||
{
|
||||
ForgeEventFactory.onPlayerDestroyItem(player, torchStack);
|
||||
player.inventory.mainInventory[i] = null;
|
||||
}
|
||||
if (result)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return super.onItemUse(stack, player, world, x, y, z, side, xOffset, yOffset, zOffset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRepairable()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getChargedItem(ItemStack itemStack)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getEmptyItem(ItemStack itemStack)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(ItemStack itemStack)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxCharge(ItemStack itemStack)
|
||||
{
|
||||
return maxCharge;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTier(ItemStack itemStack)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTransferLimit(ItemStack itemStack)
|
||||
{
|
||||
return 200;
|
||||
}
|
||||
|
||||
}
|
|
@ -149,6 +149,7 @@ item.techreborn.part.BrassMachineHull.name=Brass Machine Hull
|
|||
item.techreborn.rockcutter.name=Rockcutter
|
||||
item.techreborn.lithiumbatpack.name=lithium Batpack
|
||||
item.techreborn.lapotronpack.name=Lapotron Pack
|
||||
item.techreborn.omniTool=Omni tool
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue