mirror of
https://github.com/GTNewHorizons/Tainted-Magic.git
synced 2026-11-27 23:33:20 +00:00
commit source
This commit is contained in:
commit
1381f5b9b4
171 files changed
+7742
No files matched your search
@@ -0,0 +1,27 @@
|
||||
package taintedmagic.common.items.tools;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemSword;
|
||||
import taintedmagic.api.IBloodlust;
|
||||
import taintedmagic.common.TaintedMagic;
|
||||
import thaumcraft.api.IRepairable;
|
||||
|
||||
public class ItemCrystalDagger extends ItemSword implements IBloodlust, IRepairable
|
||||
{
|
||||
public ItemCrystalDagger (ToolMaterial m)
|
||||
{
|
||||
super(m);
|
||||
this.setCreativeTab(TaintedMagic.tabTaintedMagic);
|
||||
this.setUnlocalizedName("ItemCrystalDagger");
|
||||
this.setMaxStackSize(1);
|
||||
this.setTextureName("taintedmagic:ItemCrystalDagger");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumRarity getRarity (ItemStack s)
|
||||
{
|
||||
return EnumRarity.uncommon;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
package taintedmagic.common.items.tools;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
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.EnumRarity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.RenderPlayerEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import taintedmagic.client.model.ModelKatana;
|
||||
import taintedmagic.client.model.ModelSaya;
|
||||
import taintedmagic.common.TaintedMagic;
|
||||
import thaumcraft.api.IRepairable;
|
||||
import thaumcraft.api.IWarpingGear;
|
||||
import thaumcraft.common.config.Config;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemKatana extends Item implements IWarpingGear, IRepairable
|
||||
{
|
||||
public static final int SUBTYPES = 3;
|
||||
|
||||
public static final ResourceLocation textureThaumium = new ResourceLocation("taintedmagic:textures/models/ModelKatanaThaumium.png");
|
||||
public static final ResourceLocation textureVoidmetal = new ResourceLocation("taintedmagic:textures/models/ModelKatanaVoidmetal.png");
|
||||
public static final ResourceLocation textureShadowmetal = new ResourceLocation("taintedmagic:textures/models/ModelKatanaShadowmetal.png");
|
||||
|
||||
public static final ModelKatana katana = new ModelKatana();
|
||||
public static final ModelSaya saya = new ModelSaya();
|
||||
|
||||
public ItemKatana ()
|
||||
{
|
||||
this.setCreativeTab(TaintedMagic.tabTaintedMagic);
|
||||
this.setUnlocalizedName("ItemKatana");
|
||||
this.setHasSubtypes(true);
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hitEntity (ItemStack s, EntityLivingBase e, EntityLivingBase p)
|
||||
{
|
||||
if (!e.worldObj.isRemote && (! (e instanceof EntityPlayer) || ! (p instanceof EntityPlayer) || MinecraftServer.getServer().isPVPEnabled()))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (s.getItemDamage() == 1)
|
||||
{
|
||||
e.addPotionEffect(new PotionEffect(Potion.weakness.getId(), 60));
|
||||
e.addPotionEffect(new PotionEffect(Potion.hunger.getId(), 120));
|
||||
}
|
||||
if (s.getItemDamage() == 2)
|
||||
{
|
||||
e.addPotionEffect(new PotionEffect(Potion.wither.getId(), 60));
|
||||
e.addPotionEffect(new PotionEffect(Config.potionBlurredID, 120));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
e.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) p), getAttackDamage(s));
|
||||
}
|
||||
p.worldObj.playSoundAtEntity(p, "thaumcraft:swing", 1.0F, 1.0F);
|
||||
|
||||
return super.hitEntity(s, e, p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFull3D ()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@SideOnly (Side.CLIENT)
|
||||
public void getSubItems (Item item, CreativeTabs c, List l)
|
||||
{
|
||||
for (int i = 0; i < SUBTYPES; i++)
|
||||
l.add(new ItemStack(this, 1, i));
|
||||
}
|
||||
|
||||
public String getUnlocalizedName (ItemStack s)
|
||||
{
|
||||
return super.getUnlocalizedName() + "." + s.getItemDamage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation (ItemStack s, EntityPlayer p, List l, boolean b)
|
||||
{
|
||||
if (s.getItemDamage() == 1) l.add(EnumChatFormatting.GOLD + StatCollector.translateToLocal("enchantment.special.sapgreat"));
|
||||
l.add(" ");
|
||||
l.add("\u00A79+" + getAttackDamage(s) + " " + StatCollector.translateToLocal("text.attackdamage"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumAction getItemUseAction (ItemStack s)
|
||||
{
|
||||
return EnumAction.block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumRarity getRarity (ItemStack s)
|
||||
{
|
||||
return EnumRarity.uncommon;
|
||||
}
|
||||
|
||||
public float getAttackDamage (ItemStack s)
|
||||
{
|
||||
switch (s.getItemDamage())
|
||||
{
|
||||
case 0 :
|
||||
return 14.25F;
|
||||
case 1 :
|
||||
return 17.75F;
|
||||
case 2 :
|
||||
return 20.5F;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPlayerRender (RenderPlayerEvent.Specials.Post event)
|
||||
{
|
||||
EntityPlayer p = event.entityPlayer;
|
||||
|
||||
if (event.entityLiving.getActivePotionEffect(Potion.invisibility) != null) return;
|
||||
|
||||
for (int i = 0; i < p.inventory.getSizeInventory(); i++)
|
||||
{
|
||||
if (p.inventory.getStackInSlot(i) != null && p.inventory.getStackInSlot(i).getItem() == this)
|
||||
{
|
||||
ItemStack s = p.inventory.getStackInSlot(i);
|
||||
|
||||
if (p.getHeldItem() == null || p.getHeldItem().getItem() != this)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
|
||||
GL11.glScalef(0.5F, 0.5F, 0.5F);
|
||||
GL11.glRotatef(55, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef(180, 0.0F, 1.0F, 0.0F);
|
||||
|
||||
GL11.glTranslatef(-0.6F, 2.25F, 1.25F);
|
||||
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(getTexture(s));
|
||||
katana.render(0.0625F);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
GL11.glPushMatrix();
|
||||
|
||||
GL11.glScalef(0.5F, 0.5F, 0.5F);
|
||||
GL11.glRotatef(55, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef(180, 0.0F, 1.0F, 0.0F);
|
||||
|
||||
GL11.glTranslatef(-0.6F, 2.25F, 1.25F);
|
||||
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(getTexture(s));
|
||||
saya.render(0.0625F);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static ResourceLocation getTexture (ItemStack s)
|
||||
{
|
||||
switch (s.getItemDamage())
|
||||
{
|
||||
case 0 :
|
||||
return textureThaumium;
|
||||
case 1 :
|
||||
return textureVoidmetal;
|
||||
case 2 :
|
||||
return textureShadowmetal;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWarp (ItemStack s, EntityPlayer p)
|
||||
{
|
||||
return s.getItemDamage() == 0 ? 0 : s.getItemDamage() == 1 ? 3 : 7;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
package taintedmagic.common.items.tools;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
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.EnumRarity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemSword;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import taintedmagic.api.IBloodlust;
|
||||
import taintedmagic.common.TaintedMagic;
|
||||
import thaumcraft.api.IRepairable;
|
||||
import thaumcraft.api.IWarpingGear;
|
||||
|
||||
public class ItemPrimordialEdge extends ItemSword implements IWarpingGear, IRepairable
|
||||
{
|
||||
public ItemPrimordialEdge (ToolMaterial m)
|
||||
{
|
||||
super(m);
|
||||
this.setTextureName("taintedmagic:ItemPrimordialEdge");
|
||||
this.setUnlocalizedName("ItemPrimordialEdge");
|
||||
this.setCreativeTab(TaintedMagic.tabTaintedMagic);
|
||||
}
|
||||
|
||||
public EnumAction getItemUseAction (ItemStack s)
|
||||
{
|
||||
return EnumAction.block;
|
||||
}
|
||||
|
||||
public EnumRarity getRarity (ItemStack s)
|
||||
{
|
||||
return EnumRarity.epic;
|
||||
}
|
||||
|
||||
public boolean hitEntity (ItemStack s, EntityLivingBase e, EntityLivingBase p)
|
||||
{
|
||||
super.hitEntity(s, e, p);
|
||||
|
||||
try
|
||||
{
|
||||
e.addPotionEffect(new PotionEffect(Potion.wither.id, 5, 1));
|
||||
e.addPotionEffect(new PotionEffect(Potion.weakness.id, 5, 1));
|
||||
p.worldObj.playSoundAtEntity(p, "thaumcraft:swing", 1.0F, 1.0F);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick (ItemStack s, World w, EntityPlayer p)
|
||||
{
|
||||
p.setItemInUse(s, this.getMaxItemUseDuration(s));
|
||||
return s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUsingTick (ItemStack s, EntityPlayer p, int count)
|
||||
{
|
||||
Iterator i$;
|
||||
|
||||
List ents = p.worldObj.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox(p.posX, p.posY, p.posZ, p.posX + 1, p.posY + 1, p.posZ + 1).expand(15.0D, 15.0D, 15.0D));
|
||||
|
||||
p.worldObj.playSoundAtEntity(p, "thaumcraft:brain", 0.05F, 0.5F);
|
||||
if ( (ents != null) && (ents.size() > 0)) for (i$ = ents.iterator(); i$.hasNext();)
|
||||
{
|
||||
Object ent = i$.next();
|
||||
Entity eo = (Entity) ent;
|
||||
|
||||
if (eo != p)
|
||||
{
|
||||
if ( (eo.isEntityAlive()) && (!eo.isEntityInvulnerable()))
|
||||
{
|
||||
double d = pointDistanceSpace(eo.posX, eo.posY, eo.posZ, p);
|
||||
if (d < 2.0D)
|
||||
{
|
||||
eo.attackEntityFrom(DamageSource.magic, 1.0F);
|
||||
}
|
||||
|
||||
}
|
||||
double var3 = (p.posX + 0.5D - eo.posX) / 20.0D;
|
||||
double var5 = (p.posY + 0.5D - eo.posY) / 20.0D;
|
||||
double var7 = (p.posZ + 0.5D - eo.posZ) / 20.0D;
|
||||
double var9 = Math.sqrt(var3 * var3 + var5 * var5 + var7 * var7);
|
||||
double var11 = 1.0D - var9;
|
||||
|
||||
if (var11 > 0.0D)
|
||||
{
|
||||
var11 *= var11;
|
||||
eo.motionX += var3 / var9 * var11 * 0.20D;
|
||||
eo.motionY += var5 / var9 * var11 * 0.30D;
|
||||
eo.motionZ += var7 / var9 * var11 * 0.20D;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate (ItemStack s, World w, Entity e, int i, boolean b)
|
||||
{
|
||||
if ( (!w.isRemote) && (s.isItemDamaged()) && (e.ticksExisted % 20 == 0))
|
||||
{
|
||||
s.damageItem(-1, (EntityLivingBase) e);
|
||||
}
|
||||
}
|
||||
|
||||
public double pointDistanceSpace (double x, double y, double z, EntityPlayer p)
|
||||
{
|
||||
double xvar = p.posX + 0.5D - x;
|
||||
double yvar = p.posY + 0.5D - y;
|
||||
double zvar = p.posZ + 0.5D - z;
|
||||
return xvar * xvar + yvar * yvar + zvar * zvar;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation (ItemStack s, EntityPlayer p, List l, boolean b)
|
||||
{
|
||||
l.add(EnumChatFormatting.GOLD + StatCollector.translateToLocal("text.eldritchsapping"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWarp (ItemStack s, EntityPlayer p)
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package taintedmagic.common.items.tools;
|
||||
|
||||
import taintedmagic.common.TaintedMagic;
|
||||
import taintedmagic.common.registry.ItemRegistry;
|
||||
import thaumcraft.api.IRepairable;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.ItemAxe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ItemShadowmetalAxe extends ItemAxe implements IRepairable
|
||||
{
|
||||
public ItemShadowmetalAxe (ToolMaterial m)
|
||||
{
|
||||
super(m);
|
||||
this.setCreativeTab(TaintedMagic.tabTaintedMagic);
|
||||
this.setTextureName("taintedmagic:ItemShadowmetalAxe");
|
||||
this.setUnlocalizedName("ItemShadowmetalAxe");
|
||||
}
|
||||
|
||||
public boolean getIsRepairable (ItemStack s, ItemStack s2)
|
||||
{
|
||||
return (s2.isItemEqual(new ItemStack(ItemRegistry.ItemMaterial)) && s2.getItemDamage() == 0) ? true : super.getIsRepairable(s, s2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumRarity getRarity (ItemStack s)
|
||||
{
|
||||
return EnumRarity.uncommon;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package taintedmagic.common.items.tools;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.ItemHoe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.player.UseHoeEvent;
|
||||
import taintedmagic.common.TaintedMagic;
|
||||
import taintedmagic.common.registry.ItemRegistry;
|
||||
import thaumcraft.api.IRepairable;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
public class ItemShadowmetalHoe extends ItemHoe implements IRepairable
|
||||
{
|
||||
public ItemShadowmetalHoe (ToolMaterial m)
|
||||
{
|
||||
super(m);
|
||||
this.setCreativeTab(TaintedMagic.tabTaintedMagic);
|
||||
this.setTextureName("taintedmagic:ItemShadowmetalHoe");
|
||||
this.setUnlocalizedName("ItemShadowmetalHoe");
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
FMLCommonHandler.instance().bus().register(this);
|
||||
}
|
||||
|
||||
public boolean getIsRepairable (ItemStack s, ItemStack s2)
|
||||
{
|
||||
return (s2.isItemEqual(new ItemStack(ItemRegistry.ItemMaterial)) && s2.getItemDamage() == 0) ? true : super.getIsRepairable(s, s2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse (ItemStack s, EntityPlayer p, World w, int x, int y, int z, int i, float a, float b, float c)
|
||||
{
|
||||
super.onItemUse(s, p, w, x, y, z, i, a, b, c);
|
||||
if (!p.worldObj.isRemote)
|
||||
{
|
||||
Block block = Blocks.dirt;
|
||||
|
||||
if (p.worldObj.getBlock(x, y, z) == Blocks.farmland)
|
||||
{
|
||||
p.worldObj.setBlock(x, y, z, Blocks.dirt);
|
||||
s.damageItem(1, p);
|
||||
w.playSoundEffect((double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F), block.stepSound.getStepResourcePath(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F);
|
||||
}
|
||||
else if (p.worldObj.getBlock(x, y, z) == Blocks.dirt || p.worldObj.getBlock(x, y, z) == Blocks.grass)
|
||||
{
|
||||
p.worldObj.setBlock(x, y, z, Blocks.farmland);
|
||||
s.damageItem(1, p);
|
||||
w.playSoundEffect((double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F), block.stepSound.getStepResourcePath(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F);
|
||||
}
|
||||
}
|
||||
if (p.worldObj.getBlock(x, y, z) == Blocks.dirt || p.worldObj.getBlock(x, y, z) == Blocks.grass || p.worldObj.getBlock(x, y, z) == Blocks.farmland) p.swingItem();
|
||||
return false;
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void useHoe (UseHoeEvent event)
|
||||
{
|
||||
if (event.current.getItem() == ItemRegistry.ItemShadowmetalHoe)
|
||||
{
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumRarity getRarity (ItemStack s)
|
||||
{
|
||||
return EnumRarity.uncommon;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package taintedmagic.common.items.tools;
|
||||
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.ItemPickaxe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import taintedmagic.common.TaintedMagic;
|
||||
import taintedmagic.common.registry.ItemRegistry;
|
||||
import thaumcraft.api.IRepairable;
|
||||
|
||||
public class ItemShadowmetalPick extends ItemPickaxe implements IRepairable
|
||||
{
|
||||
public ItemShadowmetalPick (ToolMaterial m)
|
||||
{
|
||||
super(m);
|
||||
this.setCreativeTab(TaintedMagic.tabTaintedMagic);
|
||||
this.setTextureName("taintedmagic:ItemShadowmetalPick");
|
||||
this.setUnlocalizedName("ItemShadowmetalPick");
|
||||
}
|
||||
|
||||
public boolean getIsRepairable (ItemStack s, ItemStack s2)
|
||||
{
|
||||
return (s2.isItemEqual(new ItemStack(ItemRegistry.ItemMaterial)) && s2.getItemDamage() == 0) ? true : super.getIsRepairable(s, s2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumRarity getRarity (ItemStack s)
|
||||
{
|
||||
return EnumRarity.uncommon;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package taintedmagic.common.items.tools;
|
||||
|
||||
import taintedmagic.common.TaintedMagic;
|
||||
import taintedmagic.common.registry.ItemRegistry;
|
||||
import thaumcraft.api.IRepairable;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.ItemSpade;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ItemShadowmetalSpade extends ItemSpade implements IRepairable
|
||||
{
|
||||
public ItemShadowmetalSpade (ToolMaterial m)
|
||||
{
|
||||
super(m);
|
||||
this.setCreativeTab(TaintedMagic.tabTaintedMagic);
|
||||
this.setTextureName("taintedmagic:ItemShadowmetalSpade");
|
||||
this.setUnlocalizedName("ItemShadowmetalSpade");
|
||||
}
|
||||
|
||||
public boolean getIsRepairable (ItemStack s, ItemStack s2)
|
||||
{
|
||||
return (s2.isItemEqual(new ItemStack(ItemRegistry.ItemMaterial)) && s2.getItemDamage() == 0) ? true : super.getIsRepairable(s, s2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumRarity getRarity (ItemStack s)
|
||||
{
|
||||
return EnumRarity.uncommon;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package taintedmagic.common.items.tools;
|
||||
|
||||
import taintedmagic.common.TaintedMagic;
|
||||
import taintedmagic.common.registry.ItemRegistry;
|
||||
import thaumcraft.api.IRepairable;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemSword;
|
||||
|
||||
public class ItemShadowmetalSword extends ItemSword implements IRepairable
|
||||
{
|
||||
public ItemShadowmetalSword (ToolMaterial m)
|
||||
{
|
||||
super(m);
|
||||
this.setCreativeTab(TaintedMagic.tabTaintedMagic);
|
||||
this.setTextureName("taintedmagic:ItemShadowmetalSword");
|
||||
this.setUnlocalizedName("ItemShadowmetalSword");
|
||||
}
|
||||
|
||||
public boolean getIsRepairable (ItemStack s, ItemStack s2)
|
||||
{
|
||||
return (s2.isItemEqual(new ItemStack(ItemRegistry.ItemMaterial)) && s2.getItemDamage() == 0) ? true : super.getIsRepairable(s, s2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumRarity getRarity (ItemStack s)
|
||||
{
|
||||
return EnumRarity.uncommon;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
package taintedmagic.common.items.tools;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import taintedmagic.common.TaintedMagic;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.aspects.AspectList;
|
||||
import thaumcraft.common.items.wands.WandManager;
|
||||
|
||||
public class ItemThaumicDisassembler extends Item
|
||||
{
|
||||
public static final String TAG_MODE = "mode";
|
||||
|
||||
public ItemThaumicDisassembler ()
|
||||
{
|
||||
this.setCreativeTab(TaintedMagic.tabTaintedMagic);
|
||||
this.setMaxDamage(500);
|
||||
this.setMaxStackSize(1);
|
||||
this.setUnlocalizedName("ItemThaumicDisassembler");
|
||||
this.setTextureName("taintedmagic:ItemThaumicDisassembler");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHarvestBlock (Block b, ItemStack s)
|
||||
{
|
||||
return b != Blocks.bedrock;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation (ItemStack s, EntityPlayer p, List l, boolean b)
|
||||
{
|
||||
super.addInformation(s, p, l, b);
|
||||
|
||||
l.add(StatCollector.translateToLocal("text.mode") + ": " + EnumChatFormatting.BLUE + getModeName(s));
|
||||
l.add(StatCollector.translateToLocal("text.efficiency") + ": " + EnumChatFormatting.BLUE + getEfficiency(s));
|
||||
l.add(" ");
|
||||
l.add(EnumChatFormatting.BLUE + "+20 " + StatCollector.translateToLocal("text.attackdamage"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hitEntity (ItemStack s, EntityLivingBase e, EntityLivingBase p)
|
||||
{
|
||||
e.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) p), 20);
|
||||
s.damageItem(2, p);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDigSpeed (ItemStack s, Block b, int meta)
|
||||
{
|
||||
return getEfficiency(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockDestroyed (ItemStack s, World w, Block b, int x, int y, int z, EntityLivingBase e)
|
||||
{
|
||||
if (b.getBlockHardness(w, x, y, z) != 0.0D) s.damageItem(1, e);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockStartBreak (ItemStack s, int x, int y, int z, EntityPlayer p)
|
||||
{
|
||||
super.onBlockStartBreak(s, x, y, z, p);
|
||||
|
||||
if (!p.worldObj.isRemote)
|
||||
{
|
||||
Block block = p.worldObj.getBlock(x, y, z);
|
||||
int meta = p.worldObj.getBlockMetadata(x, y, z);
|
||||
|
||||
if (block == Blocks.lit_redstone_ore)
|
||||
{
|
||||
block = Blocks.redstone_ore;
|
||||
}
|
||||
|
||||
ItemStack stack = new ItemStack(block, 1, meta);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumRarity getRarity (ItemStack s)
|
||||
{
|
||||
return EnumRarity.uncommon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFull3D ()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick (ItemStack s, World w, EntityPlayer p)
|
||||
{
|
||||
if (!w.isRemote && p.isSneaking()) toggleMode(s);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
public int getEfficiency (ItemStack s)
|
||||
{
|
||||
switch (getMode(s))
|
||||
{
|
||||
case 0 :
|
||||
return 20;
|
||||
case 1 :
|
||||
return 8;
|
||||
case 2 :
|
||||
return 128;
|
||||
case 3 :
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getMode (ItemStack s)
|
||||
{
|
||||
if (s.stackTagCompound == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return s.stackTagCompound.getInteger(TAG_MODE);
|
||||
}
|
||||
|
||||
public String getModeName (ItemStack s)
|
||||
{
|
||||
int mode = getMode(s);
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case 0 :
|
||||
return StatCollector.translateToLocal("text.disassembler.normal");
|
||||
case 1 :
|
||||
return StatCollector.translateToLocal("text.disassembler.slow");
|
||||
case 2 :
|
||||
return StatCollector.translateToLocal("text.disassembler.fast");
|
||||
case 3 :
|
||||
return StatCollector.translateToLocal("text.disassembler.off");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void toggleMode (ItemStack s)
|
||||
{
|
||||
if (s.stackTagCompound == null) s.setTagCompound(new NBTTagCompound());
|
||||
|
||||
s.stackTagCompound.setInteger(TAG_MODE, getMode(s) < 3 ? getMode(s) + 1 : 0);
|
||||
}
|
||||
|
||||
public void onUpdate (ItemStack s, World w, Entity e, int i, boolean b)
|
||||
{
|
||||
super.onUpdate(s, w, e, i, b);
|
||||
if (e instanceof EntityPlayer)
|
||||
{
|
||||
EntityPlayer p = (EntityPlayer) e;
|
||||
if ( (!w.isRemote) && (s.isItemDamaged()) && (e.ticksExisted % 20 == 0))
|
||||
{
|
||||
if (WandManager.consumeVisFromInventory(p, new AspectList().add(Aspect.ENTROPY, 5)))
|
||||
{
|
||||
s.damageItem(-1, (EntityLivingBase) e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user