mirror of
https://github.com/GTNewHorizons/Electro-Magic-Tools.git
synced 2026-11-17 19:05:07 +00:00
one ring rewrite
This commit is contained in:
1 parent
0f669ce9fd
commit
5dedb54b26
2 files changed
+69
-49
No files matched your search
@@ -25,7 +25,6 @@ import java.util.Random;
|
||||
public class ItemOneRing extends ItemBase implements IBauble {
|
||||
|
||||
public IIcon[] icon = new IIcon[16];
|
||||
public static int wornTick;
|
||||
public Random random = new Random();
|
||||
|
||||
public ItemOneRing() {
|
||||
@@ -33,8 +32,6 @@ public class ItemOneRing extends ItemBase implements IBauble {
|
||||
this.setHasSubtypes(true);
|
||||
this.setMaxDamage(0);
|
||||
this.setMaxStackSize(1);
|
||||
|
||||
wornTick = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -62,7 +59,6 @@ public class ItemOneRing extends ItemBase implements IBauble {
|
||||
return this.icon[meta];
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List list) {
|
||||
list.add(new ItemStack(this, 1, 0));
|
||||
@@ -81,58 +77,75 @@ public class ItemOneRing extends ItemBase implements IBauble {
|
||||
@Override
|
||||
public void onWornTick(ItemStack stack, EntityLivingBase player) {
|
||||
if (!player.worldObj.isRemote) {
|
||||
if (stack != null && stack.getItemDamage() == 0) {
|
||||
if (player instanceof EntityPlayer) {
|
||||
((EntityPlayer) player).capabilities.disableDamage = true;
|
||||
|
||||
wornTick++;
|
||||
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tag.setInteger("MindCorruption", wornTick);
|
||||
((EntityPlayer) player).writeToNBT(tag);
|
||||
int corruption = tag.getInteger("MindCorruption");
|
||||
if (tag != null && corruption != wornTick) {
|
||||
wornTick = corruption;
|
||||
}
|
||||
|
||||
if (corruption <= 0)
|
||||
((EntityPlayer) player).addChatMessage(new ChatComponentText(TextHelper.PURPLE + "You have worn the Ring. Your soul has now been forever " + TextHelper.PURPLE + "tainted. " + TextHelper.RED + TextHelper.ITALIC + "Beware of wearing the ring. The tainting will only " + TextHelper.RED + TextHelper.ITALIC + "increase, and strange things will start happening."));
|
||||
|
||||
if (corruption > 6000 && corruption < 24000 && random.nextInt(2000) == 0)
|
||||
player.addPotionEffect(new PotionEffect(Potion.blindness.id, 500, 2, false));
|
||||
|
||||
if (corruption >= 6000 && corruption < 24000 && random.nextInt(2000) == 0)
|
||||
player.addPotionEffect(new PotionEffect(Potion.confusion.id, 500, 2, false));
|
||||
|
||||
if (corruption >= 24000 && corruption < 72000 && random.nextInt(2000) == 0) {
|
||||
for (int i = 0; i <= 5; i++)
|
||||
((EntityPlayer) player).capabilities.disableDamage = false;
|
||||
|
||||
player.attackEntityFrom(DamageSource.magic, 5);
|
||||
}
|
||||
|
||||
if (corruption >= 72000 && corruption < 120000 && random.nextInt(4000) == 0) {
|
||||
for (int i = 0; i <= 100; i++)
|
||||
((EntityPlayer) player).capabilities.disableDamage = false;
|
||||
|
||||
player.motionY = 2;
|
||||
}
|
||||
|
||||
if (corruption >= 120000 && random.nextInt(10000) == 0) {
|
||||
for (int i = 0; i <= 510; i++)
|
||||
((EntityPlayer) player).capabilities.disableDamage = false;
|
||||
|
||||
player.addPotionEffect(new PotionEffect(Potion.wither.id, 5000, 4, false));
|
||||
}
|
||||
if (stack != null && player instanceof EntityPlayer && stack.getItemDamage() == 0) {
|
||||
if (!player.isInvisible()) {
|
||||
player.setInvisible(true);
|
||||
}
|
||||
((EntityPlayer) player).capabilities.disableDamage = true;
|
||||
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
((EntityPlayer) player).writeToNBT(tag);
|
||||
|
||||
NBTTagCompound forgeTag;
|
||||
|
||||
forgeTag = tag.getCompoundTag("ForgeData");
|
||||
|
||||
int corruption = 0;
|
||||
if (forgeTag.hasKey("MindCorruption")) {
|
||||
corruption = forgeTag.getInteger("MindCorruption");
|
||||
System.out.println(corruption);
|
||||
}
|
||||
else {
|
||||
forgeTag.setInteger("MindCorruption", 0);
|
||||
}
|
||||
|
||||
if (corruption <= 0) {
|
||||
((EntityPlayer) player).addChatMessage(new ChatComponentText(TextHelper.PURPLE + "You have worn the Ring. Your soul has now been forever " + TextHelper.PURPLE + "tainted. " + TextHelper.RED + TextHelper.ITALIC + "Beware of wearing the ring. The tainting will only " + TextHelper.RED + TextHelper.ITALIC + "increase, and strange things will start happening."));
|
||||
}
|
||||
else if (corruption > 6000 && corruption < 24000 && random.nextInt(2000) == 0) {
|
||||
player.addPotionEffect(new PotionEffect(Potion.blindness.id, 500, 2, false));
|
||||
}
|
||||
else if (corruption >= 6000 && corruption < 24000 && random.nextInt(2000) == 0) {
|
||||
player.addPotionEffect(new PotionEffect(Potion.confusion.id, 500, 2, false));
|
||||
}
|
||||
else if (corruption >= 24000 && corruption < 72000 && random.nextInt(2000) == 0) {
|
||||
for (int i = 0; i <= 5; i++)
|
||||
((EntityPlayer) player).capabilities.disableDamage = false;
|
||||
|
||||
player.attackEntityFrom(DamageSource.magic, 5);
|
||||
}
|
||||
else if (corruption >= 72000 && corruption < 120000 && random.nextInt(4000) == 0) {
|
||||
for (int i = 0; i <= 100; i++)
|
||||
((EntityPlayer) player).capabilities.disableDamage = false;
|
||||
|
||||
player.motionY = 2;
|
||||
}
|
||||
else if (corruption >= 120000 && random.nextInt(10000) == 0) {
|
||||
for (int i = 0; i <= 510; i++)
|
||||
((EntityPlayer) player).capabilities.disableDamage = false;
|
||||
|
||||
player.addPotionEffect(new PotionEffect(Potion.wither.id, 5000, 4, false));
|
||||
}
|
||||
else if (corruption + 100 >= Integer.MAX_VALUE) { // =3333333
|
||||
player.isDead = true;
|
||||
}
|
||||
|
||||
forgeTag.setInteger("MindCorruption", ++corruption);
|
||||
tag.setTag("ForgeData", forgeTag);
|
||||
((EntityPlayer) player).readFromNBT(tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEquipped(ItemStack stack, EntityLivingBase player) {
|
||||
if (stack != null && stack.getItemDamage() == 0) {
|
||||
if (stack != null && player instanceof EntityPlayer && stack.getItemDamage() == 0) {
|
||||
player.setInvisible(true);
|
||||
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
((EntityPlayer) player).writeToNBT(tag);
|
||||
tag.getCompoundTag("ForgeData").setInteger("MindCorruption", 0);
|
||||
((EntityPlayer) player).readFromNBT(tag);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,6 +155,13 @@ public class ItemOneRing extends ItemBase implements IBauble {
|
||||
player.setInvisible(false);
|
||||
if (player instanceof EntityPlayer && !((EntityPlayer) player).capabilities.isCreativeMode)
|
||||
((EntityPlayer) player).capabilities.disableDamage = false;
|
||||
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
((EntityPlayer) player).writeToNBT(tag);
|
||||
tag.removeTag("ForgeData");
|
||||
((EntityPlayer) player).readFromNBT(tag);
|
||||
|
||||
player.addPotionEffect(new PotionEffect(Potion.confusion.id, 500, 2, false));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user