Actually add chainsaws (last commit was a lie)

This commit is contained in:
TheDoctorSoda 2016-02-25 17:42:45 -08:00
parent 4efb322ccd
commit 6978e14652
3 changed files with 430 additions and 0 deletions

View file

@ -0,0 +1,143 @@
package techreborn.items.tools;
import me.modmuss50.jsonDestroyer.api.ITexturedItem;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
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.ItemPickaxe;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import reborncore.RebornCore;
import reborncore.api.power.IEnergyItemInfo;
import reborncore.common.powerSystem.PoweredItem;
import reborncore.common.util.TorchHelper;
import techreborn.client.TechRebornCreativeTab;
import techreborn.config.ConfigTechReborn;
import java.util.List;
public class ItemAdvancedChainsaw extends ItemPickaxe implements IEnergyItemInfo, ITexturedItem {
public int maxCharge = ConfigTechReborn.AdvancedChainsawCharge;
public int cost = 250;
public static final int tier = ConfigTechReborn.AdvancedChainsawTier;
public double transferLimit = 100;
public ItemAdvancedChainsaw() {
super(ToolMaterial.EMERALD);
efficiencyOnProperMaterial = 20F;
setCreativeTab(TechRebornCreativeTab.instance);
setMaxStackSize(1);
setMaxDamage(240);
setUnlocalizedName("techreborn.advancedChainsaw");
RebornCore.jsonDestroyer.registerObject(this);
}
@Override
public boolean onBlockDestroyed(ItemStack stack, World worldIn, Block blockIn, BlockPos pos, EntityLivingBase playerIn) {
PoweredItem.useEnergy(cost, stack);
return true;
}
@Override
public boolean canHarvestBlock(Block block, ItemStack stack) {
return Items.diamond_axe.canHarvestBlock(block, stack);
}
@Override
public float getDigSpeed(ItemStack stack, IBlockState state) {
if(!PoweredItem.canUseEnergy(cost, stack)){
return 4.0F;
}
if (Items.wooden_axe.getDigSpeed(stack, state) > 1.0F) {
return efficiencyOnProperMaterial;
} else {
return super.getDigSpeed(stack, state);
}
}
@Override
public boolean hitEntity(ItemStack itemstack, EntityLivingBase entityliving, EntityLivingBase entityliving1) {
return true;
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) {
return TorchHelper.placeTorch(stack, playerIn, worldIn, pos.getX(), pos.getY(), pos.getZ(), side.getIndex(), hitX, hitY, hitZ);
}
@Override
public boolean isRepairable() {
return false;
}
@Override
public double getMaxPower(ItemStack stack) {
return maxCharge;
}
@Override
public boolean canAcceptEnergy(ItemStack stack) {
return true;
}
@Override
public boolean canProvideEnergy(ItemStack stack) {
return false;
}
@Override
public double getMaxTransfer(ItemStack stack) {
return transferLimit;
}
@Override
public int getStackTeir(ItemStack stack) {
return tier;
}
@SuppressWarnings(
{"rawtypes", "unchecked"})
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) {
ItemStack itemStack = new ItemStack(this, 1);
itemList.add(itemStack);
ItemStack charged = new ItemStack(this, 1);
PoweredItem.setEnergy(getMaxPower(charged), charged);
itemList.add(charged);
}
@Override
public double getDurabilityForDisplay(ItemStack stack) {
double charge = (PoweredItem.getEnergy(stack) / getMaxPower(stack));
return 1 - charge;
}
@Override
public boolean showDurabilityBar(ItemStack stack) {
return true;
}
@Override
public String getTextureName(int damage) {
return "techreborn:items/tool/advancedChainsaw";
}
@Override
public int getMaxMeta() {
return 1;
}
}

View file

@ -0,0 +1,144 @@
package techreborn.items.tools;
import java.util.List;
import me.modmuss50.jsonDestroyer.api.ITexturedItem;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
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.Item.ToolMaterial;
import net.minecraft.item.ItemAxe;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import reborncore.RebornCore;
import reborncore.api.power.IEnergyItemInfo;
import reborncore.common.powerSystem.PoweredItem;
import reborncore.common.util.TorchHelper;
import techreborn.client.TechRebornCreativeTab;
import techreborn.config.ConfigTechReborn;
public class ItemChainsaw extends ItemAxe implements IEnergyItemInfo, ITexturedItem {
public int maxCharge = ConfigTechReborn.IronChainsawCharge;
public int cost = 250;
public static final int tier = ConfigTechReborn.IronChainsawTier;
public double transferLimit = 100;
public ItemChainsaw() {
super(ToolMaterial.IRON);
efficiencyOnProperMaterial = 20F;
setCreativeTab(TechRebornCreativeTab.instance);
setMaxStackSize(1);
setMaxDamage(240);
setUnlocalizedName("techreborn.ironChainsaw");
RebornCore.jsonDestroyer.registerObject(this);
}
@Override
public boolean onBlockDestroyed(ItemStack stack, World worldIn, Block blockIn, BlockPos pos, EntityLivingBase playerIn) {
PoweredItem.useEnergy(cost, stack);
return true;
}
@Override
public boolean canHarvestBlock(Block block, ItemStack stack) {
return Items.iron_axe.canHarvestBlock(block, stack);
}
@Override
public float getDigSpeed(ItemStack stack, IBlockState state) {
if(!PoweredItem.canUseEnergy(cost, stack)){
return 2.0F;
}
if (Items.wooden_axe.getDigSpeed(stack, state) > 1.0F) {
return efficiencyOnProperMaterial;
} else {
return super.getDigSpeed(stack, state);
}
}
@Override
public boolean hitEntity(ItemStack itemstack, EntityLivingBase entityliving, EntityLivingBase entityliving1) {
return true;
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) {
return TorchHelper.placeTorch(stack, playerIn, worldIn, pos.getX(), pos.getY(), pos.getZ(), side.getIndex(), hitX, hitY, hitZ);
}
@Override
public boolean isRepairable() {
return false;
}
@Override
public double getMaxPower(ItemStack stack) {
return maxCharge;
}
@Override
public boolean canAcceptEnergy(ItemStack stack) {
return true;
}
@Override
public boolean canProvideEnergy(ItemStack stack) {
return false;
}
@Override
public double getMaxTransfer(ItemStack stack) {
return transferLimit;
}
@Override
public int getStackTeir(ItemStack stack) {
return tier;
}
@SuppressWarnings(
{"rawtypes", "unchecked"})
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) {
ItemStack itemStack = new ItemStack(this, 1);
itemList.add(itemStack);
ItemStack charged = new ItemStack(this, 1);
PoweredItem.setEnergy(getMaxPower(charged), charged);
itemList.add(charged);
}
@Override
public double getDurabilityForDisplay(ItemStack stack) {
double charge = (PoweredItem.getEnergy(stack) / getMaxPower(stack));
return 1 - charge;
}
@Override
public boolean showDurabilityBar(ItemStack stack) {
return true;
}
@Override
public String getTextureName(int damage) {
return "techreborn:items/tool/ironChainsaw";
}
@Override
public int getMaxMeta() {
return 1;
}
}

View file

@ -0,0 +1,143 @@
package techreborn.items.tools;
import me.modmuss50.jsonDestroyer.api.ITexturedItem;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
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.ItemPickaxe;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import reborncore.RebornCore;
import reborncore.api.power.IEnergyItemInfo;
import reborncore.common.powerSystem.PoweredItem;
import reborncore.common.util.TorchHelper;
import techreborn.client.TechRebornCreativeTab;
import techreborn.config.ConfigTechReborn;
import java.util.List;
public class ItemDiamondChainsaw extends ItemPickaxe implements IEnergyItemInfo, ITexturedItem {
public int maxCharge = ConfigTechReborn.DiamondChainsawCharge;
public int cost = 250;
public static final int tier = ConfigTechReborn.DiamondChainsawTier;
public double transferLimit = 100;
public ItemDiamondChainsaw() {
super(ToolMaterial.EMERALD);
efficiencyOnProperMaterial = 20F;
setCreativeTab(TechRebornCreativeTab.instance);
setMaxStackSize(1);
setMaxDamage(240);
setUnlocalizedName("techreborn.diamondChainsaw");
RebornCore.jsonDestroyer.registerObject(this);
}
@Override
public boolean onBlockDestroyed(ItemStack stack, World worldIn, Block blockIn, BlockPos pos, EntityLivingBase playerIn) {
PoweredItem.useEnergy(cost, stack);
return true;
}
@Override
public boolean canHarvestBlock(Block block, ItemStack stack) {
return Items.diamond_axe.canHarvestBlock(block, stack);
}
@Override
public float getDigSpeed(ItemStack stack, IBlockState state) {
if(!PoweredItem.canUseEnergy(cost, stack)){
return 2.5F;
}
if (Items.wooden_axe.getDigSpeed(stack, state) > 1.0F) {
return efficiencyOnProperMaterial;
} else {
return super.getDigSpeed(stack, state);
}
}
@Override
public boolean hitEntity(ItemStack itemstack, EntityLivingBase entityliving, EntityLivingBase entityliving1) {
return true;
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) {
return TorchHelper.placeTorch(stack, playerIn, worldIn, pos.getX(), pos.getY(), pos.getZ(), side.getIndex(), hitX, hitY, hitZ);
}
@Override
public boolean isRepairable() {
return false;
}
@Override
public double getMaxPower(ItemStack stack) {
return maxCharge;
}
@Override
public boolean canAcceptEnergy(ItemStack stack) {
return true;
}
@Override
public boolean canProvideEnergy(ItemStack stack) {
return false;
}
@Override
public double getMaxTransfer(ItemStack stack) {
return transferLimit;
}
@Override
public int getStackTeir(ItemStack stack) {
return tier;
}
@SuppressWarnings(
{"rawtypes", "unchecked"})
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) {
ItemStack itemStack = new ItemStack(this, 1);
itemList.add(itemStack);
ItemStack charged = new ItemStack(this, 1);
PoweredItem.setEnergy(getMaxPower(charged), charged);
itemList.add(charged);
}
@Override
public double getDurabilityForDisplay(ItemStack stack) {
double charge = (PoweredItem.getEnergy(stack) / getMaxPower(stack));
return 1 - charge;
}
@Override
public boolean showDurabilityBar(ItemStack stack) {
return true;
}
@Override
public String getTextureName(int damage) {
return "techreborn:items/tool/diamondChainsaw";
}
@Override
public int getMaxMeta() {
return 1;
}
}