mirror of
https://github.com/GTNewHorizons/Electro-Magic-Tools.git
synced 2026-11-19 19:49:55 +00:00
Refractored Code
+added Solar Factory -removed unnessecary solar and essentia generator classes +started gtnh researches +added tooltip clearance on solars (maximal output) Signed-off-by: bartimaeusnek <[email protected]>
This commit is contained in:
1 parent
980df8516a
commit
0fecf28b65
397 files changed
+8693
-9288
No files matched your search
@@ -23,113 +23,104 @@ import thaumcraft.api.IWarpingGear;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class ItemOneRing extends ItemBase implements IBauble, IWarpingGear, IRunicArmor
|
||||
{
|
||||
private static final String NBT_TAG_FORGE_DATA = "EMT";
|
||||
private static final String NBT_TAG_MIND_CORRUPTION = "MindCorruption";
|
||||
private static final String NBT_TAG_WARP = "warp";
|
||||
public IIcon[] icon = new IIcon[16];
|
||||
public Random random = new Random();
|
||||
public class ItemOneRing extends ItemBase implements IBauble, IWarpingGear, IRunicArmor {
|
||||
private static final String NBT_TAG_FORGE_DATA = "EMT";
|
||||
private static final String NBT_TAG_MIND_CORRUPTION = "MindCorruption";
|
||||
private static final String NBT_TAG_WARP = "warp";
|
||||
public IIcon[] icon = new IIcon[16];
|
||||
public Random random = new Random();
|
||||
|
||||
public int getWarp(ItemStack itemstack, EntityPlayer player)
|
||||
{
|
||||
return getItemWarpLevel(itemstack, false);
|
||||
}
|
||||
|
||||
public ItemOneRing() {
|
||||
super("bauble");
|
||||
this.setHasSubtypes(true);
|
||||
this.setMaxDamage(0);
|
||||
this.setMaxStackSize(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack itemstack) {
|
||||
String name = "";
|
||||
switch (itemstack.getItemDamage()) {
|
||||
case 0: {
|
||||
name = "oneRing";
|
||||
break;
|
||||
}
|
||||
default:
|
||||
name = "nothing";
|
||||
break;
|
||||
}
|
||||
return "item." + EMT.MOD_ID + ".bauble." + name;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister ri) {
|
||||
this.icon[0] = ri.registerIcon(EMT.TEXTURE_PATH + ":onering");
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIconFromDamage(int meta) {
|
||||
return this.icon[meta];
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List list) {
|
||||
list.add(new ItemStack(this, 1, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaubleType getBaubleType(ItemStack stack) {
|
||||
if (stack.getItemDamage() <= 0) {
|
||||
return BaubleType.RING;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private NBTTagCompound getOrSetForgeTag(EntityPlayer pPlayer)
|
||||
{
|
||||
NBTTagCompound tPlayerNBT = pPlayer.getEntityData();
|
||||
NBTTagCompound forgeTag = new NBTTagCompound();
|
||||
|
||||
// getCompoundTag already returns the contents of "ForgeData" TagCompound. Changed this to
|
||||
// save our value in EMT Sub-Tag
|
||||
if (tPlayerNBT.hasKey( NBT_TAG_FORGE_DATA ))
|
||||
forgeTag = tPlayerNBT.getCompoundTag( NBT_TAG_FORGE_DATA );
|
||||
else
|
||||
tPlayerNBT.setTag( NBT_TAG_FORGE_DATA, forgeTag );
|
||||
|
||||
return forgeTag;
|
||||
}
|
||||
|
||||
private int getItemWarpLevel(ItemStack stack, boolean increment)
|
||||
{
|
||||
NBTTagCompound tWarpTag = new NBTTagCompound();
|
||||
int tWarpLevel = 0;
|
||||
if (stack.hasTagCompound())
|
||||
{
|
||||
if (stack.getTagCompound().hasKey( NBT_TAG_WARP ))
|
||||
{
|
||||
tWarpLevel = stack.getTagCompound().getInteger( NBT_TAG_WARP );
|
||||
if (increment)
|
||||
stack.getTagCompound().setInteger( NBT_TAG_WARP , ++tWarpLevel);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tWarpTag.setInteger( NBT_TAG_WARP, 0 );
|
||||
stack.setTagCompound( tWarpTag );
|
||||
public ItemOneRing() {
|
||||
super("bauble");
|
||||
this.setHasSubtypes(true);
|
||||
this.setMaxDamage(0);
|
||||
this.setMaxStackSize(1);
|
||||
}
|
||||
|
||||
return tWarpLevel;
|
||||
}
|
||||
public int getWarp(ItemStack itemstack, EntityPlayer player) {
|
||||
return getItemWarpLevel(itemstack, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWornTick(ItemStack stack, EntityLivingBase player) {
|
||||
if (!player.isInvisible()) {
|
||||
player.setInvisible(true);
|
||||
((EntityPlayer) player).capabilities.disableDamage = true;
|
||||
}
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack itemstack) {
|
||||
String name = "";
|
||||
switch (itemstack.getItemDamage()) {
|
||||
case 0: {
|
||||
name = "oneRing";
|
||||
break;
|
||||
}
|
||||
default:
|
||||
name = "nothing";
|
||||
break;
|
||||
}
|
||||
return "item." + EMT.MOD_ID + ".bauble." + name;
|
||||
}
|
||||
|
||||
// Stop doing this 20 times per second...
|
||||
if ( random.nextInt(20) > 0)
|
||||
return;
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister ri) {
|
||||
this.icon[0] = ri.registerIcon(EMT.TEXTURE_PATH + ":onering");
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIconFromDamage(int meta) {
|
||||
return this.icon[meta];
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List list) {
|
||||
list.add(new ItemStack(this, 1, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaubleType getBaubleType(ItemStack stack) {
|
||||
if (stack.getItemDamage() <= 0) {
|
||||
return BaubleType.RING;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private NBTTagCompound getOrSetForgeTag(EntityPlayer pPlayer) {
|
||||
NBTTagCompound tPlayerNBT = pPlayer.getEntityData();
|
||||
NBTTagCompound forgeTag = new NBTTagCompound();
|
||||
|
||||
// getCompoundTag already returns the contents of "ForgeData" TagCompound. Changed this to
|
||||
// save our value in EMT Sub-Tag
|
||||
if (tPlayerNBT.hasKey(NBT_TAG_FORGE_DATA))
|
||||
forgeTag = tPlayerNBT.getCompoundTag(NBT_TAG_FORGE_DATA);
|
||||
else
|
||||
tPlayerNBT.setTag(NBT_TAG_FORGE_DATA, forgeTag);
|
||||
|
||||
return forgeTag;
|
||||
}
|
||||
|
||||
private int getItemWarpLevel(ItemStack stack, boolean increment) {
|
||||
NBTTagCompound tWarpTag = new NBTTagCompound();
|
||||
int tWarpLevel = 0;
|
||||
if (stack.hasTagCompound()) {
|
||||
if (stack.getTagCompound().hasKey(NBT_TAG_WARP)) {
|
||||
tWarpLevel = stack.getTagCompound().getInteger(NBT_TAG_WARP);
|
||||
if (increment)
|
||||
stack.getTagCompound().setInteger(NBT_TAG_WARP, ++tWarpLevel);
|
||||
}
|
||||
} else {
|
||||
tWarpTag.setInteger(NBT_TAG_WARP, 0);
|
||||
stack.setTagCompound(tWarpTag);
|
||||
}
|
||||
|
||||
return tWarpLevel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWornTick(ItemStack stack, EntityLivingBase player) {
|
||||
if (!player.isInvisible()) {
|
||||
player.setInvisible(true);
|
||||
((EntityPlayer) player).capabilities.disableDamage = true;
|
||||
}
|
||||
|
||||
// Stop doing this 20 times per second...
|
||||
if (random.nextInt(20) > 0)
|
||||
return;
|
||||
|
||||
/* Why dump to a new tag when you can just grab the tag and work with it?
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
@@ -137,111 +128,104 @@ public class ItemOneRing extends ItemBase implements IBauble, IWarpingGear, IRun
|
||||
NBTTagCompound forgeTag = tag.getCompoundTag("ForgeData");
|
||||
*/
|
||||
|
||||
// Retrieve Players NBT Data
|
||||
// Retrieve Players NBT Data
|
||||
|
||||
NBTTagCompound forgeTag = getOrSetForgeTag((EntityPlayer)player);
|
||||
NBTTagCompound forgeTag = getOrSetForgeTag((EntityPlayer) player);
|
||||
|
||||
int corruption = 0;
|
||||
int corruption = 0;
|
||||
|
||||
// get corruption levels, init to 0 if not existing yet
|
||||
if (forgeTag.hasKey( NBT_TAG_MIND_CORRUPTION ))
|
||||
corruption = forgeTag.getInteger( NBT_TAG_MIND_CORRUPTION );
|
||||
else
|
||||
forgeTag.setInteger( NBT_TAG_MIND_CORRUPTION, 0);
|
||||
// get corruption levels, init to 0 if not existing yet
|
||||
if (forgeTag.hasKey(NBT_TAG_MIND_CORRUPTION))
|
||||
corruption = forgeTag.getInteger(NBT_TAG_MIND_CORRUPTION);
|
||||
else
|
||||
forgeTag.setInteger(NBT_TAG_MIND_CORRUPTION, 0);
|
||||
|
||||
if (!player.worldObj.isRemote) {
|
||||
//EMT.LOGGER.info( String.format( "Total Corruption: %d ItemWarpLevel: %d", corruption, getItemWarpLevel( stack, false ) ));
|
||||
if (!player.worldObj.isRemote) {
|
||||
//EMT.LOGGER.info( String.format( "Total Corruption: %d ItemWarpLevel: %d", corruption, getItemWarpLevel( stack, false ) ));
|
||||
|
||||
if (corruption == 0) {
|
||||
((EntityPlayer) player).addChatMessage(new ChatComponentText(EMTTextHelper.PURPLE + "You have worn the Ring. Your soul has now been forever " + EMTTextHelper.PURPLE + "tainted. " + EMTTextHelper.RED + EMTTextHelper.ITALIC + "Beware of wearing the ring. The tainting will only " + EMTTextHelper.RED + EMTTextHelper.ITALIC + "increase, and strange things will start happening."));
|
||||
}
|
||||
// First effect should become active after ~5 Minutes
|
||||
else if (corruption > 300 && corruption < 1400 && random.nextInt(100) == 0) {
|
||||
((EntityPlayer) player).addChatMessage(new ChatComponentText(EMTTextHelper.PURPLE + "The Ring somehow feels heavy"));
|
||||
if (random.nextBoolean())
|
||||
player.addPotionEffect(new PotionEffect(Potion.blindness.id, 500, 2, false));
|
||||
else
|
||||
player.addPotionEffect(new PotionEffect(Potion.confusion.id, 500, 2, false));
|
||||
}
|
||||
else if (corruption >= 1400 && corruption < 3800 && random.nextInt(100) == 0) {
|
||||
((EntityPlayer) player).capabilities.disableDamage = false;
|
||||
player.addPotionEffect(new PotionEffect(Potion.poison.id, 500, 2, false));
|
||||
}
|
||||
else if (corruption >= 3800 && corruption < 6500 && random.nextInt(100) == 0) {
|
||||
((EntityPlayer) player).capabilities.disableDamage = false;
|
||||
player.motionY += 2d;
|
||||
}
|
||||
else if (corruption >= 6500 && random.nextInt(10000) == 0) {
|
||||
((EntityPlayer) player).capabilities.disableDamage = false;
|
||||
player.addPotionEffect(new PotionEffect(Potion.wither.id, 100, 4, false));
|
||||
}
|
||||
if (corruption == 0) {
|
||||
((EntityPlayer) player).addChatMessage(new ChatComponentText(EMTTextHelper.PURPLE + "You have worn the Ring. Your soul has now been forever " + EMTTextHelper.PURPLE + "tainted. " + EMTTextHelper.RED + EMTTextHelper.ITALIC + "Beware of wearing the ring. The tainting will only " + EMTTextHelper.RED + EMTTextHelper.ITALIC + "increase, and strange things will start happening."));
|
||||
}
|
||||
// First effect should become active after ~5 Minutes
|
||||
else if (corruption > 300 && corruption < 1400 && random.nextInt(100) == 0) {
|
||||
((EntityPlayer) player).addChatMessage(new ChatComponentText(EMTTextHelper.PURPLE + "The Ring somehow feels heavy"));
|
||||
if (random.nextBoolean())
|
||||
player.addPotionEffect(new PotionEffect(Potion.blindness.id, 500, 2, false));
|
||||
else
|
||||
player.addPotionEffect(new PotionEffect(Potion.confusion.id, 500, 2, false));
|
||||
} else if (corruption >= 1400 && corruption < 3800 && random.nextInt(100) == 0) {
|
||||
((EntityPlayer) player).capabilities.disableDamage = false;
|
||||
player.addPotionEffect(new PotionEffect(Potion.poison.id, 500, 2, false));
|
||||
} else if (corruption >= 3800 && corruption < 6500 && random.nextInt(100) == 0) {
|
||||
((EntityPlayer) player).capabilities.disableDamage = false;
|
||||
player.motionY += 2d;
|
||||
} else if (corruption >= 6500 && random.nextInt(10000) == 0) {
|
||||
((EntityPlayer) player).capabilities.disableDamage = false;
|
||||
player.addPotionEffect(new PotionEffect(Potion.wither.id, 100, 4, false));
|
||||
}
|
||||
|
||||
if (corruption >= 300)
|
||||
{
|
||||
if ( random.nextInt( 100 ) == 0)
|
||||
{
|
||||
getItemWarpLevel( stack, true );
|
||||
((EntityPlayer) player).addChatMessage(new ChatComponentText(EMTTextHelper.PURPLE + "The Ring suddenly starts to glow purple"));
|
||||
if (corruption >= 300) {
|
||||
if (random.nextInt(100) == 0) {
|
||||
getItemWarpLevel(stack, true);
|
||||
((EntityPlayer) player).addChatMessage(new ChatComponentText(EMTTextHelper.PURPLE + "The Ring suddenly starts to glow purple"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
forgeTag.setInteger( NBT_TAG_MIND_CORRUPTION, ++corruption);
|
||||
//tag.setTag( NBT_TAG_FORGE_DATA, forgeTag);
|
||||
//((EntityPlayer) player).readFromNBT(tag);
|
||||
}
|
||||
forgeTag.setInteger(NBT_TAG_MIND_CORRUPTION, ++corruption);
|
||||
//tag.setTag( NBT_TAG_FORGE_DATA, forgeTag);
|
||||
//((EntityPlayer) player).readFromNBT(tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEquipped(ItemStack stack, EntityLivingBase player) {
|
||||
// This purges all corruption once the ring is put on / a second ring is equipped?
|
||||
@Override
|
||||
public void onEquipped(ItemStack stack, EntityLivingBase player) {
|
||||
// This purges all corruption once the ring is put on / a second ring is equipped?
|
||||
/*
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
((EntityPlayer) player).writeToNBT(tag);
|
||||
tag.getCompoundTag( NBT_TAG_FORGE_DATA ).setInteger( NBT_TAG_MIND_CORRUPTION, 0);
|
||||
((EntityPlayer) player).readFromNBT(tag);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnequipped(ItemStack stack, EntityLivingBase player) {
|
||||
player.setInvisible(false);
|
||||
if (!((EntityPlayer) player).capabilities.isCreativeMode)
|
||||
((EntityPlayer) player).capabilities.disableDamage = false;
|
||||
@Override
|
||||
public void onUnequipped(ItemStack stack, EntityLivingBase player) {
|
||||
player.setInvisible(false);
|
||||
if (!((EntityPlayer) player).capabilities.isCreativeMode)
|
||||
((EntityPlayer) player).capabilities.disableDamage = false;
|
||||
|
||||
/* Wtf? Remove ForgeData tag? There are more mods using this tag than just emt!
|
||||
((EntityPlayer) player).writeToNBT(tag);
|
||||
tag.removeTag( NBT_TAG_FORGE_DATA );
|
||||
((EntityPlayer) player).readFromNBT(tag);
|
||||
*/
|
||||
player.addPotionEffect(new PotionEffect(Potion.confusion.id, 200, 1, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canEquip(ItemStack stack, EntityLivingBase player) {
|
||||
return stack.getItemDamage() == 0 && player instanceof EntityPlayer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUnequip(ItemStack stack, EntityLivingBase player) {
|
||||
// So, how this was written, you basically could not unequip the ring for 600 ticks after you equipped it, but afterwards you could?
|
||||
// Let's make it a random chance to remove it instead...
|
||||
|
||||
// NBTTagCompound tag = getOrSetForgeTag((EntityPlayer) player);
|
||||
// return (tag.getCompoundTag( NBT_TAG_FORGE_DATA ).getInteger( NBT_TAG_MIND_CORRUPTION ) > 600);
|
||||
boolean tRet = false;
|
||||
if (random.nextInt( 5 ) == 0)
|
||||
{
|
||||
tRet = true;
|
||||
((EntityPlayer) player).addChatMessage(new ChatComponentText(EMTTextHelper.GREEN + "You removed the Ring. Maybe you should think twice before using it next time?"));
|
||||
player.addPotionEffect(new PotionEffect(Potion.confusion.id, 200, 1, false));
|
||||
}
|
||||
else
|
||||
( (EntityPlayer) player ).addChatMessage( new ChatComponentText( EMTTextHelper.PURPLE + "Nooo, don't remove me! I give you great power!" ) );
|
||||
|
||||
return tRet;
|
||||
}
|
||||
@Override
|
||||
public boolean canEquip(ItemStack stack, EntityLivingBase player) {
|
||||
return stack.getItemDamage() == 0 && player instanceof EntityPlayer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRunicCharge(ItemStack itemStack) {
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public boolean canUnequip(ItemStack stack, EntityLivingBase player) {
|
||||
// So, how this was written, you basically could not unequip the ring for 600 ticks after you equipped it, but afterwards you could?
|
||||
// Let's make it a random chance to remove it instead...
|
||||
|
||||
// NBTTagCompound tag = getOrSetForgeTag((EntityPlayer) player);
|
||||
// return (tag.getCompoundTag( NBT_TAG_FORGE_DATA ).getInteger( NBT_TAG_MIND_CORRUPTION ) > 600);
|
||||
boolean tRet = false;
|
||||
if (random.nextInt(5) == 0) {
|
||||
tRet = true;
|
||||
((EntityPlayer) player).addChatMessage(new ChatComponentText(EMTTextHelper.GREEN + "You removed the Ring. Maybe you should think twice before using it next time?"));
|
||||
} else
|
||||
((EntityPlayer) player).addChatMessage(new ChatComponentText(EMTTextHelper.PURPLE + "Nooo, don't remove me! I give you great power!"));
|
||||
|
||||
return tRet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRunicCharge(ItemStack itemStack) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user