mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 23:28:35 +01:00
Made the Scuba Helmet recharge when not in Armor Slot
This commit is contained in:
parent
d4962ddb66
commit
ac46458220
2 changed files with 23 additions and 8 deletions
|
@ -42,7 +42,7 @@ public class ItemArmorAA extends ItemArmor implements INameableItem{
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) {
|
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld){
|
||||||
ItemUtil.addInformation(this, list, 1, "");
|
ItemUtil.addInformation(this, list, 1, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,9 @@ package ellpeck.actuallyadditions.items;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
import ellpeck.actuallyadditions.material.InitArmorMaterials;
|
import ellpeck.actuallyadditions.material.InitArmorMaterials;
|
||||||
import ellpeck.actuallyadditions.util.ItemUtil;
|
|
||||||
import ellpeck.actuallyadditions.util.KeyUtil;
|
import ellpeck.actuallyadditions.util.KeyUtil;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
@ -29,28 +29,43 @@ public class ItemScubaArmor extends ItemArmorAA{
|
||||||
NBTTagCompound compound = armor.getTagCompound();
|
NBTTagCompound compound = armor.getTagCompound();
|
||||||
if(compound == null) compound = new NBTTagCompound();
|
if(compound == null) compound = new NBTTagCompound();
|
||||||
|
|
||||||
int time = compound.getInteger("waitTime");
|
|
||||||
if(player.isInsideOfMaterial(Material.water)){
|
if(player.isInsideOfMaterial(Material.water)){
|
||||||
|
int time = compound.getInteger("waitTime");
|
||||||
if(time < helmetTime){
|
if(time < helmetTime){
|
||||||
compound.setInteger("waitTime", time+1);
|
compound.setInteger("waitTime", time+1);
|
||||||
player.setAir(300);
|
player.setAir(300);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if(time > 0){
|
this.addAir(compound);
|
||||||
compound.setInteger("waitTime", time < helmetTimeDecreaseInAir ? 0 : time-helmetTimeDecreaseInAir);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
armor.setTagCompound(compound);
|
armor.setTagCompound(compound);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addAir(NBTTagCompound compound){
|
||||||
|
int time = compound.getInteger("waitTime");
|
||||||
|
if(time > 0){
|
||||||
|
compound.setInteger("waitTime", time < helmetTimeDecreaseInAir ? 0 : time-helmetTimeDecreaseInAir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5){
|
||||||
|
if(!entity.isInsideOfMaterial(Material.water)){
|
||||||
|
NBTTagCompound compound = stack.getTagCompound();
|
||||||
|
if(compound != null){
|
||||||
|
this.addAir(compound);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) {
|
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld){
|
||||||
ItemUtil.addInformation(this, list, 1, "");
|
super.addInformation(stack, player, list, isHeld);
|
||||||
if(KeyUtil.isShiftPressed() && stack.getItem() == InitItems.itemScubaHelm){
|
if(KeyUtil.isShiftPressed() && stack.getItem() == InitItems.itemScubaHelm){
|
||||||
NBTTagCompound compound = stack.getTagCompound();
|
NBTTagCompound compound = stack.getTagCompound();
|
||||||
//TODO Localize
|
//TODO Localize
|
||||||
|
|
Loading…
Reference in a new issue