Skip to content

Instantly share code, notes, and snippets.

@EliteForges
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EliteForges/e5067c9fceccdc039712 to your computer and use it in GitHub Desktop.
Save EliteForges/e5067c9fceccdc039712 to your computer and use it in GitHub Desktop.
package com.eliteforges.gpm.items.slycooper;
import java.util.List;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumToolMaterial;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import com.eliteforges.gpm.Main;
import cpw.mods.fml.common.registry.LanguageRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class CaneGold
extends CaneSword
{
public CaneGold(int id, EnumToolMaterial par2EnumToolMaterial)
{
super(id, par2EnumToolMaterial);
setMaxStackSize(1);
setMaxDamage(-1);
setCreativeTab(Main.tabGPMElite);
setUnlocalizedName("caneGold");
}
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister)
{
this.itemIcon = iconRegister.registerIcon("gpm2:caneGold");
LanguageRegistry.addName(Main.canegold, "Cane");
}
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{
par3List.add("Uses Left: Infinite");
}
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player)
{
ItemStack cane = new ItemStack(Main.canePower);
return cane;
}
}
package com.eliteforges.gpm.items.slycooper;
import java.util.List;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumToolMaterial;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import com.eliteforges.gpm.Main;
import cpw.mods.fml.common.network.Player;
import cpw.mods.fml.common.registry.LanguageRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class CanePower
extends CaneSword
{
public CanePower(int id, EnumToolMaterial par2EnumToolMaterial)
{
super(id, par2EnumToolMaterial);
setMaxStackSize(1);
setMaxDamage(3);
setCreativeTab(Main.tabGPMElite);
setUnlocalizedName("canePower");
}
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister)
{
this.itemIcon = iconRegister.registerIcon("gpm2:canePower");
LanguageRegistry.addName(Main.canePower, "Cane");
}
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{
par3List.add("Uses Left: Infinite");
}
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player)
{
ItemStack cane = new ItemStack(Main.canegold);
return cane;
}
//This is where I need it to turn into a "canegold" when durability runs out
public ItemStack onLeftClickEntity(ItemStack itemStack, World world, EntityPlayer player)
{
ItemStack cane = new ItemStack(Main.canegold);
if (this.getDamage(itemStack) == 3);
return cane;
}
}
package com.eliteforges.gpm.items.slycooper;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.item.EnumAction;
import net.minecraft.item.EnumToolMaterial;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import com.eliteforges.gpm.Main;
import com.google.common.collect.Multimap;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class CaneSword
extends Item
{
private float weaponDamage;
private final EnumToolMaterial toolMaterial;
public CaneSword(int par1, EnumToolMaterial par2EnumToolMaterial)
{
super(par1);
this.toolMaterial = par2EnumToolMaterial;
this.maxStackSize = 1;
setMaxDamage(par2EnumToolMaterial.getMaxUses());
setCreativeTab(CreativeTabs.tabCombat);
this.weaponDamage = (4.0F + par2EnumToolMaterial.getDamageVsEntity());
}
public float func_82803_g()
{
return this.toolMaterial.getDamageVsEntity();
}
public float getStrVsBlock(ItemStack par1ItemStack, Block par2Block)
{
if (par2Block.blockID == Block.web.blockID) {
return 15.0F;
}
Material material = par2Block.blockMaterial;
return (material != Material.plants) && (material != Material.vine) && (material != Material.coral) && (material != Material.leaves) && (material != Material.pumpkin) ? 1.0F : 1.5F;
}
public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase)
{
par1ItemStack.damageItem(1, par3EntityLivingBase);
return true;
}
public boolean onBlockDestroyed(ItemStack par1ItemStack, World par2World, int par3, int par4, int par5, int par6, EntityLivingBase par7EntityLivingBase)
{
if (Block.blocksList[par3].getBlockHardness(par2World, par4, par5, par6) != 0.0D) {
par1ItemStack.damageItem(2, par7EntityLivingBase);
}
return true;
}
@SideOnly(Side.CLIENT)
public boolean isFull3D()
{
return true;
}
public EnumAction getItemUseAction(ItemStack par1ItemStack)
{
return EnumAction.block;
}
public int getMaxItemUseDuration(ItemStack par1ItemStack)
{
return 72000;
}
public boolean canHarvestBlock(Block par1Block)
{
return par1Block.blockID == Block.web.blockID;
}
public int getItemEnchantability()
{
return this.toolMaterial.getEnchantability();
}
public String getToolMaterialName()
{
return this.toolMaterial.toString();
}
public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack)
{
return this.toolMaterial.getToolCraftingMaterial() == par2ItemStack.itemID ? true : super.getIsRepairable(par1ItemStack, par2ItemStack);
}
public Multimap getItemAttributeModifiers()
{
Multimap multimap = super.getItemAttributeModifiers();
multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(field_111210_e, "Weapon modifier", this.weaponDamage, 0));
return multimap;
}
}
package com.eliteforges.gpm.items.slycooper;
import java.util.List;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumToolMaterial;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import com.eliteforges.gpm.Main;
import cpw.mods.fml.common.registry.LanguageRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class CaneGold
extends CaneSword
{
public CaneGold(int id, EnumToolMaterial par2EnumToolMaterial)
{
super(id, par2EnumToolMaterial);
setMaxStackSize(1);
setMaxDamage(-1);
setCreativeTab(Main.tabGPMElite);
setUnlocalizedName("caneGold");
}
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister)
{
this.itemIcon = iconRegister.registerIcon("gpm2:caneGold");
LanguageRegistry.addName(Main.canegold, "Cane");
}
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{
par3List.add("Uses Left: Infinite");
}
//@Override
// public boolean onItemUse(ItemStack item, EntityPlayer player, World par3world, int X, int Y, int Z, int side, float xOffset, float yOffset, float zOffSet) {
//if (!par3world.isRemote)
// {
// if(CaneCooldown.use==0)
// {
// CaneCooldown.givePoweredCane();
// }
// }
//return true;
//}
public static int ticks = 10;
public static int use = 0;
public static void givePoweredCane() {
ItemStack Poweredcane = new ItemStack(Main.canePower);
use=1;
}
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) {
if((use == 1) && (ticks > 0)){
ticks--;
ItemStack cane = new ItemStack(Main.caneCool);
}
else if(ticks <= 0){
use = 0;
ticks = 10;
ItemStack cane = new ItemStack(Main.canegold);
}
}
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player, Entity entity)
{
if(use==0)
givePoweredCane();
CaneCooldown.givePoweredCane();
return itemStack;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment