-
-
Save izzyaxel/a765c09f1402ccafebf1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package izzyaxel.arcaneartificing.main; | |
import izzyaxel.arcaneartificing.mana.Mana; | |
import izzyaxel.arcaneartificing.mana.ManaType; | |
import net.minecraft.entity.Entity; | |
import net.minecraft.entity.player.EntityPlayer; | |
import net.minecraft.nbt.NBTTagCompound; | |
import net.minecraft.world.World; | |
import net.minecraftforge.common.IExtendedEntityProperties; | |
public class AAExtendedPlayer implements IExtendedEntityProperties | |
{ | |
public static final String EEPName = "AAExtendedPlayer"; | |
EntityPlayer player; | |
//Mana storage | |
private int manaW; | |
private int manaU; | |
private int manaB; | |
private int manaG; | |
private int manaR; | |
private final String manaWName = "ManaW"; | |
private final String manaUName = "ManaU"; | |
private final String manaBName = "ManaB"; | |
private final String manaGName = "ManaG"; | |
private final String manaRName = "ManaR"; | |
private int maxManaW; | |
private int maxManaU; | |
private int maxManaB; | |
private int maxManaG; | |
private int maxManaR; | |
private final String maxManaWName = "MaxManaW"; | |
private final String maxManaUName = "MaxManaU"; | |
private final String maxManaBName = "MaxManaB"; | |
private final String maxManaGName = "MaxManaG"; | |
private final String maxManaRName = "MaxManaR"; | |
private boolean hasLearnedAboutMana = false; | |
private final String hasLearnedAboutManaName = "HasLearnedAboutMana"; | |
//Armor worn | |
private boolean hasCrown; | |
private boolean hasMantle; | |
private boolean hasGreaves; | |
private boolean hasCothurnus; | |
private float unzoomSensitivity; | |
private final String hasCrownName = "HasCrown"; | |
private final String hasMantleName = "HasMantle"; | |
private final String hasGreavesName = "HasGreaves"; | |
private final String hasCothurnusName = "HasCothurnus"; | |
private final String unzoomSensitivityName = "UnzoomSensitivity"; | |
//Keypresses | |
private boolean spaceDown; | |
private boolean shiftDown; | |
private boolean mmbDown; | |
private final String spaceDownName = "SpaceDown"; | |
private final String shiftDownName = "ShiftDown"; | |
private final String mmbDownName = "MMBDown"; | |
//Safeguard Talisman | |
private boolean inNether; | |
private boolean isBeingSaved; | |
private final String inNetherName = "InNether"; | |
private final String isBeingSavedName = "BeingSaved"; | |
//Iris | |
private boolean isHurt; | |
private int timeSinceHurt; | |
private final String isHurtName = "IsHurt"; | |
private final String timeSinceHurtName = "HurtTime"; | |
//Grapple beam | |
private boolean hasGrappled; | |
private int grappleHookID; | |
private final String hasGrappledName = "HasGrappled"; | |
private final String grappleHookIDName = "GrappleHookID"; | |
@Override | |
public void init(Entity entity, World world) | |
{ | |
if(entity instanceof EntityPlayer) | |
{ | |
this.player = (EntityPlayer)entity; | |
} | |
this.hasCrown = false; | |
this.hasMantle = false; | |
this.hasGreaves = false; | |
this.hasCothurnus = false; | |
this.spaceDown = false; | |
this.shiftDown = false; | |
this.inNether = false; | |
this.isBeingSaved = false; | |
this.isHurt = false; | |
this.timeSinceHurt = 0; | |
this.unzoomSensitivity = 0.5f; | |
this.mmbDown = false; | |
this.hasGrappled = false; | |
this.grappleHookID = -1; | |
this.manaW = 0; | |
this.manaU = 0; | |
this.manaB = 0; | |
this.manaG = 0; | |
this.manaR = 0; | |
this.maxManaW = AAReference.MAXSTARTINGMANA; | |
this.maxManaU = AAReference.MAXSTARTINGMANA; | |
this.maxManaB = AAReference.MAXSTARTINGMANA; | |
this.maxManaG = AAReference.MAXSTARTINGMANA; | |
this.maxManaR = AAReference.MAXSTARTINGMANA; | |
this.hasLearnedAboutMana = false; | |
} | |
@Override | |
public void saveNBTData(NBTTagCompound compound) | |
{ | |
NBTTagCompound properties = new NBTTagCompound(); | |
compound.setTag(EEPName, properties); | |
properties.setBoolean(this.hasCrownName, this.hasCrown); | |
properties.setBoolean(this.hasMantleName, this.hasMantle); | |
properties.setBoolean(this.hasGreavesName, this.hasGreaves); | |
properties.setBoolean(this.hasCothurnusName, this.hasCothurnus); | |
properties.setBoolean(this.spaceDownName, this.spaceDown); | |
properties.setBoolean(this.shiftDownName, this.shiftDown); | |
properties.setBoolean(this.inNetherName, this.inNether); | |
properties.setBoolean(this.isBeingSavedName, this.isBeingSaved); | |
properties.setBoolean(this.isHurtName, this.isHurt); | |
properties.setInteger(this.timeSinceHurtName, this.timeSinceHurt); | |
properties.setFloat(this.unzoomSensitivityName, this.unzoomSensitivity); | |
properties.setBoolean(this.mmbDownName, this.mmbDown); | |
properties.setBoolean(this.hasGrappledName, this.hasGrappled); | |
properties.setInteger(this.grappleHookIDName, this.grappleHookID); | |
properties.setInteger(this.manaWName, this.manaW); | |
properties.setInteger(this.manaUName, this.manaU); | |
properties.setInteger(this.manaBName, this.manaB); | |
properties.setInteger(this.manaGName, this.manaG); | |
properties.setInteger(this.manaRName, this.manaR); | |
properties.setInteger(this.maxManaWName, this.maxManaW); | |
properties.setInteger(this.maxManaUName, this.maxManaU); | |
properties.setInteger(this.maxManaBName, this.maxManaB); | |
properties.setInteger(this.maxManaGName, this.maxManaG); | |
properties.setInteger(this.maxManaRName, this.maxManaR); | |
properties.setBoolean(this.hasLearnedAboutManaName, this.hasLearnedAboutMana); | |
} | |
@Override | |
public void loadNBTData(NBTTagCompound compound) | |
{ | |
NBTTagCompound properties = (NBTTagCompound)compound.getTag(EEPName); | |
this.hasCrown = properties.getBoolean(this.hasCrownName); | |
this.hasMantle = properties.getBoolean(this.hasMantleName); | |
this.hasGreaves = properties.getBoolean(this.hasGreavesName); | |
this.hasCothurnus = properties.getBoolean(this.hasCothurnusName); | |
this.spaceDown = properties.getBoolean(this.spaceDownName); | |
this.shiftDown = properties.getBoolean(this.shiftDownName); | |
this.inNether = properties.getBoolean(this.inNetherName); | |
this.isBeingSaved = properties.getBoolean(this.isBeingSavedName); | |
this.isHurt = properties.getBoolean(this.isHurtName); | |
this.timeSinceHurt = properties.getInteger(this.timeSinceHurtName); | |
this.unzoomSensitivity = properties.getFloat(this.unzoomSensitivityName); | |
this.mmbDown = properties.getBoolean(this.mmbDownName); | |
this.hasGrappled = properties.getBoolean(this.hasGrappledName); | |
this.grappleHookID = properties.getInteger(this.grappleHookIDName); | |
this.manaW = properties.getInteger(this.manaWName); | |
this.manaU = properties.getInteger(this.manaUName); | |
this.manaB = properties.getInteger(this.manaBName); | |
this.manaG = properties.getInteger(this.manaGName); | |
this.manaR = properties.getInteger(this.manaRName); | |
this.maxManaW = properties.getInteger(this.maxManaWName); | |
this.maxManaU = properties.getInteger(this.maxManaUName); | |
this.maxManaB = properties.getInteger(this.maxManaBName); | |
this.maxManaG = properties.getInteger(this.maxManaGName); | |
this.maxManaR = properties.getInteger(this.maxManaRName); | |
this.hasLearnedAboutMana = properties.getBoolean(this.hasLearnedAboutManaName); | |
} | |
/**Mana************************************************************************************************************/ | |
//Progression | |
public boolean hasLearnedAboutmana() | |
{ | |
return this.hasLearnedAboutMana; | |
} | |
public void setHasLearnedAboutMana(boolean b) | |
{ | |
this.hasLearnedAboutMana = b; | |
} | |
//Mana manipulation and checking | |
//Get Current | |
public int getWhiteMana() | |
{ | |
return this.manaW; | |
} | |
public int getBlueMana() | |
{ | |
return this.manaU; | |
} | |
public int getBlackMana() | |
{ | |
return this.manaB; | |
} | |
public int getGreenMana() | |
{ | |
return this.manaG; | |
} | |
public int getRedMana() | |
{ | |
return this.manaR; | |
} | |
//Set Maxes | |
public void setMaxManaW(int mana) | |
{ | |
this.maxManaW = mana; | |
} | |
public void setMaxManaU(int mana) | |
{ | |
this.maxManaU = mana; | |
} | |
public void setMaxManaB(int mana) | |
{ | |
this.maxManaB = mana; | |
} | |
public void setMaxManaG(int mana) | |
{ | |
this.maxManaG = mana; | |
} | |
public void setMaxManaR(int mana) | |
{ | |
this.maxManaR = mana; | |
} | |
//Get Maxes | |
public int getMaxManaW() | |
{ | |
return this.maxManaW; | |
} | |
public int getMaxManaU() | |
{ | |
return this.maxManaU; | |
} | |
public int getMaxManaB() | |
{ | |
return this.maxManaB; | |
} | |
public int getMaxManaG() | |
{ | |
return this.maxManaG; | |
} | |
public int getMaxManaR() | |
{ | |
return this.maxManaR; | |
} | |
/** | |
* Can this player receive the full amount of mana being given to them? | |
* @param mana The mana packet to give the player | |
* @return Boolean | |
*/ | |
public boolean canReceiveFullAmountOfMana(Mana mana) | |
{ | |
switch(mana.type) | |
{ | |
case W: | |
return this.manaW + mana.amount <= this.maxManaW; | |
case U: | |
return this.manaU + mana.amount <= this.maxManaU; | |
case B: | |
return this.manaB + mana.amount <= this.maxManaB; | |
case G: | |
return this.manaG + mana.amount <= this.maxManaG; | |
case R: | |
return this.manaR + mana.amount <= this.maxManaR; | |
default: return false; | |
} | |
} | |
private void boundMin(ManaType type) | |
{ | |
switch(type) | |
{ | |
case W: | |
if(this.manaW < 0) | |
{ | |
this.manaW = 0; | |
} | |
break; | |
case U: | |
if(this.manaU < 0) | |
{ | |
this.manaU = 0; | |
} | |
break; | |
case B: | |
if(this.manaB < 0) | |
{ | |
this.manaB = 0; | |
} | |
break; | |
case G: | |
if(this.manaG < 0) | |
{ | |
this.manaG = 0; | |
} | |
break; | |
case R: | |
if(this.manaR < 0) | |
{ | |
this.manaR = 0; | |
} | |
break; | |
default: break; | |
} | |
} | |
private void boundMax(ManaType type) | |
{ | |
switch(type) | |
{ | |
case W: | |
if(this.manaW > this.maxManaW) | |
{ | |
this.manaW = this.maxManaW; | |
} | |
break; | |
case U: | |
if(this.manaU > this.maxManaU) | |
{ | |
this.manaU = this.maxManaU; | |
} | |
break; | |
case B: | |
if(this.manaB > this.maxManaB) | |
{ | |
this.manaB = this.maxManaB; | |
} | |
break; | |
case G: | |
if(this.manaG > this.maxManaG) | |
{ | |
this.manaG = this.maxManaG; | |
} | |
break; | |
case R: | |
if(this.manaR > this.maxManaR) | |
{ | |
this.manaR = this.maxManaR; | |
} | |
break; | |
default: break; | |
} | |
} | |
/** | |
* Give this player some mana; any excess over their max storage amount will be lost | |
* @param mana The mana packet to give the player | |
*/ | |
public void addMana(Mana mana) | |
{ | |
if(mana.amount < 0) | |
{ | |
return; | |
} | |
switch(mana.type) | |
{ | |
case W: | |
this.manaW += mana.amount; | |
this.boundMax(ManaType.W); | |
break; | |
case U: | |
this.manaU += mana.amount; | |
this.boundMax(ManaType.U); | |
break; | |
case B: | |
this.manaB += mana.amount; | |
this.boundMax(ManaType.B); | |
break; | |
case G: | |
this.manaG += mana.amount; | |
this.boundMax(ManaType.G); | |
break; | |
case R: | |
this.manaR += mana.amount; | |
this.boundMax(ManaType.R); | |
break; | |
default: break; | |
} | |
} | |
/** | |
* Can the player provide enough mana for the operation being performed? | |
* @param mana The mana packet to check with | |
* @return Boolean | |
*/ | |
public boolean canProvideMana(Mana mana) | |
{ | |
switch(mana.type) | |
{ | |
case W: | |
return this.manaW - mana.amount >= 0; | |
case U: | |
return this.manaU - mana.amount >= 0; | |
case B: | |
return this.manaB - mana.amount >= 0; | |
case G: | |
return this.manaG - mana.amount >= 0; | |
case R: | |
return this.manaR - mana.amount >= 0; | |
default: return false; | |
} | |
} | |
/** | |
* Provide the requested mana to perform an operation | |
* @param mana The mana packet being requested | |
*/ | |
public void provideMana(Mana mana) | |
{ | |
if(!this.canProvideMana(mana)) | |
{ | |
return; | |
} | |
switch(mana.type) | |
{ | |
case W: | |
this.manaW -= mana.amount; | |
break; | |
case U: | |
this.manaW -= mana.amount; | |
break; | |
case B: | |
this.manaW -= mana.amount; | |
break; | |
case G: | |
this.manaW -= mana.amount; | |
break; | |
case R: | |
this.manaW -= mana.amount; | |
break; | |
default: break; | |
} | |
} | |
/**********************************************************************************************************Mana****/ | |
public boolean isShiftDown() | |
{ | |
return this.shiftDown; | |
} | |
public void setShiftDown(boolean shiftDown) | |
{ | |
this.shiftDown = shiftDown; | |
} | |
public boolean isSpaceDown() | |
{ | |
return this.spaceDown; | |
} | |
public void setSpaceDown(boolean spaceDown) | |
{ | |
this.spaceDown = spaceDown; | |
} | |
public boolean isMMBDown() | |
{ | |
return this.mmbDown; | |
} | |
public void setMMBDown(boolean mmbDown) | |
{ | |
this.mmbDown = mmbDown; | |
} | |
public void setUnzoomSensitivity(float sensitivity) | |
{ | |
this.unzoomSensitivity = sensitivity; | |
} | |
public float getUnzoomSensitivity() | |
{ | |
return this.unzoomSensitivity; | |
} | |
public boolean isInNether() | |
{ | |
return this.inNether; | |
} | |
public void setInNether(boolean inNether) | |
{ | |
this.inNether = inNether; | |
} | |
public boolean isBeingSaved() | |
{ | |
return this.isBeingSaved; | |
} | |
public void setIsBeingSaved(boolean isBeingSaved) | |
{ | |
this.isBeingSaved = isBeingSaved; | |
} | |
//Crown of Iris | |
public boolean hasCrown() | |
{ | |
return this.hasCrown; | |
} | |
public void setHasCrown(boolean hasCrown) | |
{ | |
this.hasCrown = hasCrown; | |
} | |
//Mantle of Vulcan | |
public boolean hasMantle() | |
{ | |
return this.hasMantle; | |
} | |
public void setHasMantle(boolean hasMantle) | |
{ | |
this.hasMantle = hasMantle; | |
} | |
//Greaves of Gaia | |
public boolean hasGreaves() | |
{ | |
return this.hasGreaves; | |
} | |
public void setHasGreaves(boolean hasGreaves) | |
{ | |
this.hasGreaves = hasGreaves; | |
} | |
public boolean hasCothurnus() | |
{ | |
return this.hasCothurnus; | |
} | |
public void setHasCothurnus(boolean hasCothurnus) | |
{ | |
this.hasCothurnus = hasCothurnus; | |
} | |
public boolean isHurt() | |
{ | |
return this.isHurt; | |
} | |
public void setIsHurt(boolean hurt) | |
{ | |
this.isHurt = hurt; | |
} | |
public int getTimeSinceHurt() | |
{ | |
return this.timeSinceHurt; | |
} | |
public void setTimeSinceHurt(int timeSinceHurt) | |
{ | |
this.timeSinceHurt = timeSinceHurt; | |
} | |
public void incrementTimeSinceHurt() | |
{ | |
this.timeSinceHurt++; | |
} | |
public void setHasGrappled(boolean b) | |
{ | |
this.hasGrappled = b; | |
} | |
public boolean hasGrappled() | |
{ | |
return this.hasGrappled; | |
} | |
public void setGrappleHookID(int i) | |
{ | |
this.grappleHookID = i; | |
} | |
public int getGrappleHookID() | |
{ | |
return this.grappleHookID; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment