This commit is contained in:
chochem committed 2023-02-01 20:49:56 +00:00
1 parent 29b6a51d03
commit 32dc71f8b3
68 files changed
+5635 -5587

No files matched your search

@@ -1,27 +1,25 @@
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");
}
public class ItemCrystalDagger extends ItemSword implements IBloodlust, IRepairable {
@Override
public EnumRarity getRarity (ItemStack s)
{
return EnumRarity.uncommon;
}
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;
}
}
@@ -15,7 +15,6 @@ import net.minecraft.item.EnumAction;
import net.minecraft.item.EnumRarity;
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.server.MinecraftServer;
@@ -36,8 +35,8 @@ import taintedmagic.client.model.ModelKatana;
import taintedmagic.client.model.ModelSaya;
import taintedmagic.common.TaintedMagic;
import taintedmagic.common.entities.EntityTaintBubble;
import taintedmagic.common.network.PacketKatanaAttack;
import taintedmagic.common.network.PacketHandler;
import taintedmagic.common.network.PacketKatanaAttack;
import thaumcraft.api.IRepairable;
import thaumcraft.api.IWarpingGear;
import thaumcraft.common.config.Config;
@@ -46,420 +45,381 @@ 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 static boolean equipped = false;
public static float ticksEquipped = 0F;
public int ticksInUse = 0;
public ItemKatana ()
{
this.setCreativeTab(TaintedMagic.tabTaintedMagic);
this.setUnlocalizedName("ItemKatana");
this.setHasSubtypes(true);
this.setMaxStackSize(1);
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.moveSlowdown.getId(), 120, 2));
e.addPotionEffect(new PotionEffect(Config.potionBlurredID, 120));
}
}
catch (Exception ex)
{
}
if (hasAnyInscription(s))
{
switch (getInscription(s))
{
case 0 :
{
e.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) p).setFireDamage().setDamageBypassesArmor(), getAttackDamage(s));
e.setFire(5);
break;
}
case 1 :
{
e.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) p).setMagicDamage().setDamageBypassesArmor(), getAttackDamage(s));
try
{
e.addPotionEffect(new PotionEffect(Config.potionTaintPoisonID, 100));
}
catch (Exception ex)
{
}
break;
}
case 2 :
{
e.attackEntityFrom(DamageSource.wither.setMagicDamage().setDamageBypassesArmor(), getAttackDamage(s));
try
{
e.addPotionEffect(new PotionEffect(Potion.wither.id, 60));
}
catch (Exception ex)
{
}
break;
}
}
}
else e.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) p), getAttackDamage(s));
}
p.worldObj.playSoundAtEntity(p, "thaumcraft:swing", 0.5F + (float) Math.random(), 0.5F + (float) Math.random());
return super.hitEntity(s, e, p);
}
@Override
public boolean isFull3D ()
{
return true;
}
@Override
public boolean canHarvestBlock (Block b, ItemStack s)
{
return false;
}
@Override
public EnumAction getItemUseAction (ItemStack s)
{
return EnumAction.bow;
}
@SideOnly (Side.CLIENT)
public void getSubItems (Item i, CreativeTabs c, List l)
{
for (int a = 0; a < SUBTYPES; a++)
l.add(new ItemStack(this, 1, a));
}
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"));
if (s.hasTagCompound() && s.stackTagCompound.hasKey("inscription"))
{
l.add(EnumChatFormatting.GOLD + StatCollector.translateToLocal("text.katana.inscription." + s.stackTagCompound.getInteger("inscription")));
}
}
@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.55F;
case 2 :
return 20.75F;
}
return 0;
}
@Override
public int getMaxItemUseDuration (ItemStack s)
{
return 72000;
}
@Override
public ItemStack onItemRightClick (ItemStack s, World w, EntityPlayer p)
{
p.setItemInUse(s, getMaxItemUseDuration(s));
return s;
}
@Override
public void onUsingTick (ItemStack s, EntityPlayer p, int i)
{
super.onUsingTick(s, p, i);
this.ticksInUse = getMaxItemUseDuration(s) - i;
float j = 1.0F + ((float) Math.random() * 0.25F);
if (p.ticksExisted % 5 == 0) p.worldObj.playSoundAtEntity(p, "thaumcraft:wind", j * 0.1F, j);
}
@Override
public void onPlayerStoppedUsing (ItemStack s, World w, EntityPlayer p, int i)
{
super.onPlayerStoppedUsing(s, w, p, i);
Random r = new Random();
if (!hasAnyInscription(s) || !isFullyCharged(p) || p.isSneaking() || getInscription(s) == 2)
{
boolean leech = (getInscription(s) == 2 && isFullyCharged(p));
boolean b = false;
if (w.isRemote)
{
MovingObjectPosition mop = Minecraft.getMinecraft().objectMouseOver;
float mul = Math.min(1.0F + (float) this.ticksInUse / 40.0F, 2.0F);
if (mop.entityHit != null)
{
PacketHandler.INSTANCE.sendToServer(new PacketKatanaAttack(mop.entityHit, p, this.getAttackDamage(s) * mul, leech));
}
p.swingItem();
}
p.worldObj.playSoundAtEntity(p, "thaumcraft:swing", 0.5F + (float) Math.random(), 0.5F + (float) Math.random());
}
else if (hasAnyInscription(s) && isFullyCharged(p) && !p.isSneaking())
{
switch (getInscription(s))
{
case 0 :
{
EntityExplosiveOrb proj = new EntityExplosiveOrb(w, p);
proj.posX += proj.motionX;
proj.posY += proj.motionY;
proj.posZ += proj.motionZ;
if (!w.isRemote) w.spawnEntityInWorld(proj);
p.swingItem();
break;
}
case 1 :
{
for (int a = 0; a < 50; a++)
{
EntityTaintBubble proj = new EntityTaintBubble(w, p, 5.0F, false);
proj.posX += proj.motionX;
proj.posY += proj.motionY;
proj.posZ += proj.motionZ;
proj.damage = getAttackDamage(s) * 0.2F;
if (!w.isRemote) w.spawnEntityInWorld(proj);
p.swingItem();
}
break;
}
default :
break;
}
}
}
private boolean isFullyCharged (EntityPlayer p)
{
float f = Math.min((float) this.ticksInUse / 15.0F, 2.0F);
if (f == 2.0F) return true;
else return false;
}
@SideOnly (Side.CLIENT)
@SubscribeEvent
public void onPlayerRender (RenderPlayerEvent.Specials.Post event)
{
if (event.entityLiving.getActivePotionEffect(Potion.invisibility) != null) return;
EntityPlayer p = event.entityPlayer;
for (int i = 0; i < p.inventory.getSizeInventory(); i++)
{
if (p.inventory.getStackInSlot(i) != null && p.inventory.getStackInSlot(i).getItem() instanceof ItemKatana)
{
ItemStack s = p.inventory.getStackInSlot(i);
GL11.glPushMatrix();
int light = p.getBrightnessForRender(0);
int lightmapX = light % 65536;
int lightmapY = light / 65536;
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
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();
if (p.getHeldItem() == null || p.getHeldItem() != s)
{
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.glPopMatrix();
break;
}
}
}
@SideOnly (Side.CLIENT)
public static void renderHUD (ScaledResolution r, EntityPlayer p, float pt)
{
Minecraft mc = Minecraft.getMinecraft();
ItemStack s = mc.thePlayer.getCurrentEquippedItem();
Tessellator t = Tessellator.instance;
boolean b = false;
if (s != null && s.getItem() instanceof ItemKatana) b = true;
else b = false;
float time = 30F;
if (b) ticksEquipped = Math.min(time, ticksEquipped + pt);
else ticksEquipped = Math.max(0F, ticksEquipped - pt);
float defAlpha = 0F;
float fract = ticksEquipped / time;
float a = fract;
if (b || ticksEquipped != 0)
{
float tickFract = Math.min((float) p.getItemInUseDuration() / 30.0F, 1.0F);
int x = r.getScaledWidth() / 2 + 725;
int x2 = x + 16;
int y = r.getScaledHeight() / 2 + (p.capabilities.isCreativeMode ? 805 : 755);
int y2 = y + 16;
GL11.glPushMatrix();
GL11.glEnable(GL11.GL_BLEND);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
float sc = 0.315F;
GL11.glScalef(sc, sc, sc);
mc.renderEngine.bindTexture(new ResourceLocation("thaumcraft:textures/misc/script.png"));
for (int rune = 0; rune < 16; rune++)
{
float red = MathHelper.sin( (p.ticksExisted + rune * 5) / 5.0F) * 0.1F + 0.8F;
float green = MathHelper.sin( (p.ticksExisted + rune * 5) / 7.0F) * 0.1F + 0.7F;
float alpha = MathHelper.sin( (p.ticksExisted + rune * 5) / 10.0F) * 0.3F;
float f = 0.0625F * rune;
float f1 = f + 0.0625F;
float f2 = 0.0F;
float f3 = 1.0F;
t.startDrawingQuads();
t.setBrightness(240);
t.setColorRGBA_F(red, green, 0.4F, (alpha + 0.7F) * a);
t.addVertexWithUV(x + (rune * 16) - alpha, y2 + alpha, 0, f, f3);
t.addVertexWithUV(x2 + (rune * 16) + alpha, y2 + alpha, 0, f1, f3);
t.addVertexWithUV(x2 + (rune * 16) + alpha, y - alpha, 0, f1, f2);
t.addVertexWithUV(x + (rune * 16) - alpha, y - alpha, 0, f, f2);
t.draw();
if ((int) (16 * tickFract) > rune)
{
t.startDrawingQuads();
t.setBrightness(240);
t.setColorRGBA_F(1.0F - (0.0625F * rune), 0.0F + (0.0625F * rune), 0.0F, 0.9F + alpha);
t.addVertexWithUV(x + (rune * 16) - alpha, y2 + alpha, 0, f, f3);
t.addVertexWithUV(x2 + (rune * 16) + alpha, y2 + alpha, 0, f1, f3);
t.addVertexWithUV(x2 + (rune * 16) + alpha, y - alpha, 0, f1, f2);
t.addVertexWithUV(x + (rune * 16) - alpha, y - alpha, 0, f, f2);
t.draw();
}
}
GL11.glDisable(GL11.GL_BLEND);
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
GL11.glPopMatrix();
}
}
public static boolean hasAnyInscription (ItemStack s)
{
return s.hasTagCompound() && s.stackTagCompound.hasKey("inscription");
}
public static int getInscription (ItemStack s)
{
if (s.hasTagCompound() && s.stackTagCompound.hasKey("inscription")) return s.stackTagCompound.getInteger("inscription");
else return 0;
}
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;
}
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 static boolean equipped = false;
public static float ticksEquipped = 0F;
public int ticksInUse = 0;
public ItemKatana() {
this.setCreativeTab(TaintedMagic.tabTaintedMagic);
this.setUnlocalizedName("ItemKatana");
this.setHasSubtypes(true);
this.setMaxStackSize(1);
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.moveSlowdown.getId(), 120, 2));
e.addPotionEffect(new PotionEffect(Config.potionBlurredID, 120));
}
} catch (Exception ex) {}
if (hasAnyInscription(s)) {
switch (getInscription(s)) {
case 0: {
e.attackEntityFrom(
DamageSource.causePlayerDamage((EntityPlayer) p).setFireDamage()
.setDamageBypassesArmor(),
getAttackDamage(s));
e.setFire(5);
break;
}
case 1: {
e.attackEntityFrom(
DamageSource.causePlayerDamage((EntityPlayer) p).setMagicDamage()
.setDamageBypassesArmor(),
getAttackDamage(s));
try {
e.addPotionEffect(new PotionEffect(Config.potionTaintPoisonID, 100));
} catch (Exception ex) {}
break;
}
case 2: {
e.attackEntityFrom(
DamageSource.wither.setMagicDamage().setDamageBypassesArmor(),
getAttackDamage(s));
try {
e.addPotionEffect(new PotionEffect(Potion.wither.id, 60));
} catch (Exception ex) {}
break;
}
}
} else e.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) p), getAttackDamage(s));
}
p.worldObj.playSoundAtEntity(p, "thaumcraft:swing", 0.5F + (float) Math.random(), 0.5F + (float) Math.random());
return super.hitEntity(s, e, p);
}
@Override
public boolean isFull3D() {
return true;
}
@Override
public boolean canHarvestBlock(Block b, ItemStack s) {
return false;
}
@Override
public EnumAction getItemUseAction(ItemStack s) {
return EnumAction.bow;
}
@SideOnly(Side.CLIENT)
public void getSubItems(Item i, CreativeTabs c, List l) {
for (int a = 0; a < SUBTYPES; a++) l.add(new ItemStack(this, 1, a));
}
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"));
if (s.hasTagCompound() && s.stackTagCompound.hasKey("inscription")) {
l.add(
EnumChatFormatting.GOLD + StatCollector.translateToLocal(
"text.katana.inscription." + s.stackTagCompound.getInteger("inscription")));
}
}
@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.55F;
case 2:
return 20.75F;
}
return 0;
}
@Override
public int getMaxItemUseDuration(ItemStack s) {
return 72000;
}
@Override
public ItemStack onItemRightClick(ItemStack s, World w, EntityPlayer p) {
p.setItemInUse(s, getMaxItemUseDuration(s));
return s;
}
@Override
public void onUsingTick(ItemStack s, EntityPlayer p, int i) {
super.onUsingTick(s, p, i);
this.ticksInUse = getMaxItemUseDuration(s) - i;
float j = 1.0F + ((float) Math.random() * 0.25F);
if (p.ticksExisted % 5 == 0) p.worldObj.playSoundAtEntity(p, "thaumcraft:wind", j * 0.1F, j);
}
@Override
public void onPlayerStoppedUsing(ItemStack s, World w, EntityPlayer p, int i) {
super.onPlayerStoppedUsing(s, w, p, i);
Random r = new Random();
if (!hasAnyInscription(s) || !isFullyCharged(p) || p.isSneaking() || getInscription(s) == 2) {
boolean leech = (getInscription(s) == 2 && isFullyCharged(p));
boolean b = false;
if (w.isRemote) {
MovingObjectPosition mop = Minecraft.getMinecraft().objectMouseOver;
float mul = Math.min(1.0F + (float) this.ticksInUse / 40.0F, 2.0F);
if (mop.entityHit != null) {
PacketHandler.INSTANCE.sendToServer(
new PacketKatanaAttack(mop.entityHit, p, this.getAttackDamage(s) * mul, leech));
}
p.swingItem();
}
p.worldObj.playSoundAtEntity(
p,
"thaumcraft:swing",
0.5F + (float) Math.random(),
0.5F + (float) Math.random());
} else if (hasAnyInscription(s) && isFullyCharged(p) && !p.isSneaking()) {
switch (getInscription(s)) {
case 0: {
EntityExplosiveOrb proj = new EntityExplosiveOrb(w, p);
proj.posX += proj.motionX;
proj.posY += proj.motionY;
proj.posZ += proj.motionZ;
if (!w.isRemote) w.spawnEntityInWorld(proj);
p.swingItem();
break;
}
case 1: {
for (int a = 0; a < 50; a++) {
EntityTaintBubble proj = new EntityTaintBubble(w, p, 5.0F, false);
proj.posX += proj.motionX;
proj.posY += proj.motionY;
proj.posZ += proj.motionZ;
proj.damage = getAttackDamage(s) * 0.2F;
if (!w.isRemote) w.spawnEntityInWorld(proj);
p.swingItem();
}
break;
}
default:
break;
}
}
}
private boolean isFullyCharged(EntityPlayer p) {
float f = Math.min((float) this.ticksInUse / 15.0F, 2.0F);
if (f == 2.0F) return true;
else return false;
}
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onPlayerRender(RenderPlayerEvent.Specials.Post event) {
if (event.entityLiving.getActivePotionEffect(Potion.invisibility) != null) return;
EntityPlayer p = event.entityPlayer;
for (int i = 0; i < p.inventory.getSizeInventory(); i++) {
if (p.inventory.getStackInSlot(i) != null
&& p.inventory.getStackInSlot(i).getItem() instanceof ItemKatana) {
ItemStack s = p.inventory.getStackInSlot(i);
GL11.glPushMatrix();
int light = p.getBrightnessForRender(0);
int lightmapX = light % 65536;
int lightmapY = light / 65536;
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
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();
if (p.getHeldItem() == null || p.getHeldItem() != s) {
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.glPopMatrix();
break;
}
}
}
@SideOnly(Side.CLIENT)
public static void renderHUD(ScaledResolution r, EntityPlayer p, float pt) {
Minecraft mc = Minecraft.getMinecraft();
ItemStack s = mc.thePlayer.getCurrentEquippedItem();
Tessellator t = Tessellator.instance;
boolean b = false;
if (s != null && s.getItem() instanceof ItemKatana) b = true;
else b = false;
float time = 30F;
if (b) ticksEquipped = Math.min(time, ticksEquipped + pt);
else ticksEquipped = Math.max(0F, ticksEquipped - pt);
float defAlpha = 0F;
float fract = ticksEquipped / time;
float a = fract;
if (b || ticksEquipped != 0) {
float tickFract = Math.min((float) p.getItemInUseDuration() / 30.0F, 1.0F);
int x = r.getScaledWidth() / 2 + 725;
int x2 = x + 16;
int y = r.getScaledHeight() / 2 + (p.capabilities.isCreativeMode ? 805 : 755);
int y2 = y + 16;
GL11.glPushMatrix();
GL11.glEnable(GL11.GL_BLEND);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
float sc = 0.315F;
GL11.glScalef(sc, sc, sc);
mc.renderEngine.bindTexture(new ResourceLocation("thaumcraft:textures/misc/script.png"));
for (int rune = 0; rune < 16; rune++) {
float red = MathHelper.sin((p.ticksExisted + rune * 5) / 5.0F) * 0.1F + 0.8F;
float green = MathHelper.sin((p.ticksExisted + rune * 5) / 7.0F) * 0.1F + 0.7F;
float alpha = MathHelper.sin((p.ticksExisted + rune * 5) / 10.0F) * 0.3F;
float f = 0.0625F * rune;
float f1 = f + 0.0625F;
float f2 = 0.0F;
float f3 = 1.0F;
t.startDrawingQuads();
t.setBrightness(240);
t.setColorRGBA_F(red, green, 0.4F, (alpha + 0.7F) * a);
t.addVertexWithUV(x + (rune * 16) - alpha, y2 + alpha, 0, f, f3);
t.addVertexWithUV(x2 + (rune * 16) + alpha, y2 + alpha, 0, f1, f3);
t.addVertexWithUV(x2 + (rune * 16) + alpha, y - alpha, 0, f1, f2);
t.addVertexWithUV(x + (rune * 16) - alpha, y - alpha, 0, f, f2);
t.draw();
if ((int) (16 * tickFract) > rune) {
t.startDrawingQuads();
t.setBrightness(240);
t.setColorRGBA_F(1.0F - (0.0625F * rune), 0.0F + (0.0625F * rune), 0.0F, 0.9F + alpha);
t.addVertexWithUV(x + (rune * 16) - alpha, y2 + alpha, 0, f, f3);
t.addVertexWithUV(x2 + (rune * 16) + alpha, y2 + alpha, 0, f1, f3);
t.addVertexWithUV(x2 + (rune * 16) + alpha, y - alpha, 0, f1, f2);
t.addVertexWithUV(x + (rune * 16) - alpha, y - alpha, 0, f, f2);
t.draw();
}
}
GL11.glDisable(GL11.GL_BLEND);
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
GL11.glPopMatrix();
}
}
public static boolean hasAnyInscription(ItemStack s) {
return s.hasTagCompound() && s.stackTagCompound.hasKey("inscription");
}
public static int getInscription(ItemStack s) {
if (s.hasTagCompound() && s.stackTagCompound.hasKey("inscription"))
return s.stackTagCompound.getInteger("inscription");
else return 0;
}
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;
}
}
@@ -17,122 +17,106 @@ 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 class ItemPrimordialEdge extends ItemSword implements IWarpingGear, IRepairable {
public EnumAction getItemUseAction (ItemStack s)
{
return EnumAction.block;
}
public ItemPrimordialEdge(ToolMaterial m) {
super(m);
this.setTextureName("taintedmagic:ItemPrimordialEdge");
this.setUnlocalizedName("ItemPrimordialEdge");
this.setCreativeTab(TaintedMagic.tabTaintedMagic);
}
public EnumRarity getRarity (ItemStack s)
{
return TaintedMagic.rarityCreation;
}
public EnumAction getItemUseAction(ItemStack s) {
return EnumAction.block;
}
public boolean hitEntity (ItemStack s, EntityLivingBase e, EntityLivingBase p)
{
super.hitEntity(s, e, p);
public EnumRarity getRarity(ItemStack s) {
return TaintedMagic.rarityCreation;
}
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;
}
public boolean hitEntity(ItemStack s, EntityLivingBase e, EntityLivingBase p) {
super.hitEntity(s, e, p);
@Override
public ItemStack onItemRightClick (ItemStack s, World w, EntityPlayer p)
{
p.setItemInUse(s, this.getMaxItemUseDuration(s));
return s;
}
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 void onUsingTick (ItemStack s, EntityPlayer p, int count)
{
Iterator i$;
@Override
public ItemStack onItemRightClick(ItemStack s, World w, EntityPlayer p) {
p.setItemInUse(s, this.getMaxItemUseDuration(s));
return s;
}
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));
@Override
public void onUsingTick(ItemStack s, EntityPlayer p, int count) {
Iterator i$;
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;
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));
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);
}
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;
}
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 (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);
}
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;
}
}
}
}
}
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;
@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);
}
}
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;
}
}
}
}
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 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);
}
}
@Override
public void addInformation (ItemStack s, EntityPlayer p, List l, boolean b)
{
l.add(EnumChatFormatting.GOLD + StatCollector.translateToLocal("text.eldritchsapping"));
}
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 int getWarp (ItemStack s, EntityPlayer p)
{
return 5;
}
@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;
}
}
@@ -1,30 +1,29 @@
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");
}
import taintedmagic.common.TaintedMagic;
import taintedmagic.common.registry.ItemRegistry;
import thaumcraft.api.IRepairable;
public boolean getIsRepairable (ItemStack s, ItemStack s2)
{
return (s2.isItemEqual(new ItemStack(ItemRegistry.ItemMaterial)) && s2.getItemDamage() == 0) ? true : super.getIsRepairable(s, s2);
}
public class ItemShadowmetalAxe extends ItemAxe implements IRepairable {
@Override
public EnumRarity getRarity (ItemStack s)
{
return EnumRarity.uncommon;
}
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;
}
}
@@ -9,66 +9,73 @@ 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 class ItemShadowmetalHoe extends ItemHoe implements IRepairable {
public boolean getIsRepairable (ItemStack s, ItemStack s2)
{
return (s2.isItemEqual(new ItemStack(ItemRegistry.ItemMaterial)) && s2.getItemDamage() == 0) ? true : super.getIsRepairable(s, s2);
}
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);
}
@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;
public boolean getIsRepairable(ItemStack s, ItemStack s2) {
return (s2.isItemEqual(new ItemStack(ItemRegistry.ItemMaterial)) && s2.getItemDamage() == 0) ? true
: super.getIsRepairable(s, s2);
}
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;
}
@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;
@SubscribeEvent
public void useHoe (UseHoeEvent event)
{
if (event.current.getItem() == ItemRegistry.ItemShadowmetalHoe)
{
event.setCanceled(true);
}
}
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;
}
@Override
public EnumRarity getRarity (ItemStack s)
{
return EnumRarity.uncommon;
}
@SubscribeEvent
public void useHoe(UseHoeEvent event) {
if (event.current.getItem() == ItemRegistry.ItemShadowmetalHoe) {
event.setCanceled(true);
}
}
@Override
public EnumRarity getRarity(ItemStack s) {
return EnumRarity.uncommon;
}
}
@@ -3,28 +3,27 @@ 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 class ItemShadowmetalPick extends ItemPickaxe implements IRepairable {
public boolean getIsRepairable (ItemStack s, ItemStack s2)
{
return (s2.isItemEqual(new ItemStack(ItemRegistry.ItemMaterial)) && s2.getItemDamage() == 0) ? true : super.getIsRepairable(s, s2);
}
public ItemShadowmetalPick(ToolMaterial m) {
super(m);
this.setCreativeTab(TaintedMagic.tabTaintedMagic);
this.setTextureName("taintedmagic:ItemShadowmetalPick");
this.setUnlocalizedName("ItemShadowmetalPick");
}
@Override
public EnumRarity getRarity (ItemStack s)
{
return EnumRarity.uncommon;
}
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;
}
}
@@ -1,30 +1,29 @@
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");
}
import taintedmagic.common.TaintedMagic;
import taintedmagic.common.registry.ItemRegistry;
import thaumcraft.api.IRepairable;
public boolean getIsRepairable (ItemStack s, ItemStack s2)
{
return (s2.isItemEqual(new ItemStack(ItemRegistry.ItemMaterial)) && s2.getItemDamage() == 0) ? true : super.getIsRepairable(s, s2);
}
public class ItemShadowmetalSpade extends ItemSpade implements IRepairable {
@Override
public EnumRarity getRarity (ItemStack s)
{
return EnumRarity.uncommon;
}
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;
}
}
@@ -1,30 +1,29 @@
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");
}
import taintedmagic.common.TaintedMagic;
import taintedmagic.common.registry.ItemRegistry;
import thaumcraft.api.IRepairable;
public boolean getIsRepairable (ItemStack s, ItemStack s2)
{
return (s2.isItemEqual(new ItemStack(ItemRegistry.ItemMaterial)) && s2.getItemDamage() == 0) ? true : super.getIsRepairable(s, s2);
}
public class ItemShadowmetalSword extends ItemSword implements IRepairable {
@Override
public EnumRarity getRarity (ItemStack s)
{
return EnumRarity.uncommon;
}
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;
}
}
@@ -28,178 +28,171 @@ import thaumcraft.common.items.wands.WandManager;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemThaumicDisassembler extends Item
{
public static final String TAG_MODE = "mode";
public class ItemThaumicDisassembler extends Item {
public ItemThaumicDisassembler ()
{
this.setCreativeTab(TaintedMagic.tabTaintedMagic);
this.setMaxDamage(500);
this.setMaxStackSize(1);
this.setUnlocalizedName("ItemThaumicDisassembler");
this.setTextureName("taintedmagic:ItemThaumicDisassembler");
}
public static final String TAG_MODE = "mode";
@Override
public boolean canHarvestBlock (Block b, ItemStack s)
{
return b != Blocks.bedrock;
}
public ItemThaumicDisassembler() {
this.setCreativeTab(TaintedMagic.tabTaintedMagic);
this.setMaxDamage(500);
this.setMaxStackSize(1);
this.setUnlocalizedName("ItemThaumicDisassembler");
this.setTextureName("taintedmagic:ItemThaumicDisassembler");
}
@Override
public void addInformation (ItemStack s, EntityPlayer p, List l, boolean b)
{
super.addInformation(s, p, l, b);
@Override
public boolean canHarvestBlock(Block b, ItemStack s) {
return b != Blocks.bedrock;
}
l.add("\u00A78" + StatCollector.translateToLocal("text.mode") + ": " + getModeName(s));
l.add("\u00A78" + StatCollector.translateToLocal("text.efficiency") + ": " + (getMode(s) == 3 ? "\u00A7c" : "\u00A7a") + getEfficiency(s));
l.add(" ");
l.add("\u00A79" + "+20 " + StatCollector.translateToLocal("text.attackdamage"));
}
@Override
public void addInformation(ItemStack s, EntityPlayer p, List l, boolean b) {
super.addInformation(s, p, l, b);
@Override
public boolean hitEntity (ItemStack s, EntityLivingBase e, EntityLivingBase p)
{
e.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) p), 20);
s.damageItem(2, p);
return false;
}
l.add("\u00A78" + StatCollector.translateToLocal("text.mode") + ": " + getModeName(s));
l.add(
"\u00A78" + StatCollector.translateToLocal("text.efficiency")
+ ": "
+ (getMode(s) == 3 ? "\u00A7c" : "\u00A7a")
+ getEfficiency(s));
l.add(" ");
l.add("\u00A79" + "+20 " + StatCollector.translateToLocal("text.attackdamage"));
}
@Override
public float getDigSpeed (ItemStack s, Block b, int meta)
{
return getEfficiency(s);
}
@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 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 float getDigSpeed(ItemStack s, Block b, int meta) {
return getEfficiency(s);
}
@Override
public boolean onBlockStartBreak (ItemStack s, int x, int y, int z, EntityPlayer p)
{
super.onBlockStartBreak(s, x, y, z, p);
@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;
}
if (!p.worldObj.isRemote)
{
Block block = p.worldObj.getBlock(x, y, z);
int meta = p.worldObj.getBlockMetadata(x, y, z);
@Override
public boolean onBlockStartBreak(ItemStack s, int x, int y, int z, EntityPlayer p) {
super.onBlockStartBreak(s, x, y, z, p);
if (block == Blocks.lit_redstone_ore) block = Blocks.redstone_ore;
if (!p.worldObj.isRemote) {
Block block = p.worldObj.getBlock(x, y, z);
int meta = p.worldObj.getBlockMetadata(x, y, z);
ItemStack stack = new ItemStack(block, 1, meta);
}
return false;
}
if (block == Blocks.lit_redstone_ore) block = Blocks.redstone_ore;
@Override
public EnumRarity getRarity (ItemStack s)
{
return EnumRarity.uncommon;
}
ItemStack stack = new ItemStack(block, 1, meta);
}
return false;
}
@Override
public boolean isFull3D ()
{
return true;
}
@Override
public EnumRarity getRarity(ItemStack s) {
return EnumRarity.uncommon;
}
@Override
public ItemStack onItemRightClick (ItemStack s, World w, EntityPlayer p)
{
if (!w.isRemote && p.isSneaking()) toggleMode(s);
@Override
public boolean isFull3D() {
return true;
}
return s;
}
@Override
public ItemStack onItemRightClick(ItemStack s, World w, EntityPlayer p) {
if (!w.isRemote && p.isSneaking()) toggleMode(s);
public static 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;
}
return s;
}
public static int getMode (ItemStack s)
{
if (s.stackTagCompound == null) return 0;
return s.stackTagCompound.getInteger(TAG_MODE);
}
public static 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 static String getModeName (ItemStack s)
{
int mode = getMode(s);
public static int getMode(ItemStack s) {
if (s.stackTagCompound == null) return 0;
return s.stackTagCompound.getInteger(TAG_MODE);
}
switch (mode)
{
case 0 :
return "\u00A7a" + StatCollector.translateToLocal("text.disassembler.normal");
case 1 :
return "\u00A7a" + StatCollector.translateToLocal("text.disassembler.slow");
case 2 :
return "\u00A7a" + StatCollector.translateToLocal("text.disassembler.fast");
case 3 :
return "\u00A7c" + StatCollector.translateToLocal("text.disassembler.off");
}
return null;
}
public static String getModeName(ItemStack s) {
int mode = getMode(s);
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);
}
switch (mode) {
case 0:
return "\u00A7a" + StatCollector.translateToLocal("text.disassembler.normal");
case 1:
return "\u00A7a" + StatCollector.translateToLocal("text.disassembler.slow");
case 2:
return "\u00A7a" + StatCollector.translateToLocal("text.disassembler.fast");
case 3:
return "\u00A7c" + StatCollector.translateToLocal("text.disassembler.off");
}
return null;
}
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);
}
}
}
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);
}
@SideOnly (Side.CLIENT)
public static void renderHUD (ScaledResolution resolution, EntityPlayer player, float partialTicks)
{
Minecraft mc = Minecraft.getMinecraft();
EntityPlayer p = TaintedMagic.proxy.getClientPlayer();
ItemStack s = mc.thePlayer.getCurrentEquippedItem();
FontRenderer f = mc.fontRenderer;
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);
}
}
}
if (s != null && s.getItem() instanceof ItemThaumicDisassembler)
{
String str = "\u00A78" + StatCollector.translateToLocal("text.mode") + ": " + getModeName(s) + (getMode(s) == 3 ? "\u00A7c" : "\u00A7a") + " (" + getEfficiency(s) + ")";
@SideOnly(Side.CLIENT)
public static void renderHUD(ScaledResolution resolution, EntityPlayer player, float partialTicks) {
Minecraft mc = Minecraft.getMinecraft();
EntityPlayer p = TaintedMagic.proxy.getClientPlayer();
ItemStack s = mc.thePlayer.getCurrentEquippedItem();
FontRenderer f = mc.fontRenderer;
GL11.glPushMatrix();
GL11.glEnable(GL11.GL_BLEND);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glTranslated(0, -15, 0);
if (s != null && s.getItem() instanceof ItemThaumicDisassembler) {
String str = "\u00A78" + StatCollector.translateToLocal("text.mode")
+ ": "
+ getModeName(s)
+ (getMode(s) == 3 ? "\u00A7c" : "\u00A7a")
+ " ("
+ getEfficiency(s)
+ ")";
GL11.glScalef(0.8F, 0.8F, 0.8F);
GL11.glPushMatrix();
GL11.glEnable(GL11.GL_BLEND);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glTranslated(0, -15, 0);
f.drawStringWithShadow(str, resolution.getScaledWidth() / 2 + 100, resolution.getScaledHeight() / 2 + (p.capabilities.isCreativeMode ? 230 : 212), 0xFFFFFF);
GL11.glScalef(0.8F, 0.8F, 0.8F);
GL11.glDisable(GL11.GL_BLEND);
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
GL11.glPopMatrix();
}
}
f.drawStringWithShadow(
str,
resolution.getScaledWidth() / 2 + 100,
resolution.getScaledHeight() / 2 + (p.capabilities.isCreativeMode ? 230 : 212),
0xFFFFFF);
GL11.glDisable(GL11.GL_BLEND);
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
GL11.glPopMatrix();
}
}
}