mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-12-22 19:39:24 +01:00
Made the Chest have Air instead of the Helm
This commit is contained in:
parent
ac46458220
commit
824a86b816
1 changed files with 24 additions and 16 deletions
|
@ -9,14 +9,16 @@ import net.minecraft.entity.Entity;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemScubaArmor extends ItemArmorAA{
|
||||
|
||||
private static final int helmetTime = 500;
|
||||
private static final int helmetTimeDecreaseInAir = 3;
|
||||
private static final int chestAirTime = 500;
|
||||
private static final int chestAirIncreasePerTick = 3;
|
||||
|
||||
public ItemScubaArmor(String name, int type){
|
||||
super(name, InitArmorMaterials.armorMaterialScuba, type, null, "armorScuba");
|
||||
|
@ -25,29 +27,35 @@ public class ItemScubaArmor extends ItemArmorAA{
|
|||
@Override
|
||||
public void onArmorTick(World world, EntityPlayer player, ItemStack armor){
|
||||
if(!world.isRemote){
|
||||
if(armor.getItem() == InitItems.itemScubaHelm){
|
||||
if(this.hasFullArmor(player)){
|
||||
NBTTagCompound compound = armor.getTagCompound();
|
||||
if(compound == null) compound = new NBTTagCompound();
|
||||
|
||||
if(player.isInsideOfMaterial(Material.water)){
|
||||
int time = compound.getInteger("waitTime");
|
||||
if(time < helmetTime){
|
||||
compound.setInteger("waitTime", time+1);
|
||||
player.setAir(300);
|
||||
if(armor.getItem() == InitItems.itemScubaChest){
|
||||
if(player.isInsideOfMaterial(Material.water)){
|
||||
int time = compound.getInteger("waitTime");
|
||||
if(time < chestAirTime){
|
||||
compound.setInteger("waitTime", time+1);
|
||||
player.addPotionEffect(new PotionEffect(Potion.waterBreathing.getId(), 1, 0));
|
||||
}
|
||||
}
|
||||
else{
|
||||
this.addAirToChest(compound);
|
||||
}
|
||||
}
|
||||
else{
|
||||
this.addAir(compound);
|
||||
}
|
||||
armor.setTagCompound(compound);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addAir(NBTTagCompound compound){
|
||||
private boolean hasFullArmor(EntityPlayer player){
|
||||
return player.inventory.getStackInSlot(36) != null && player.inventory.getStackInSlot(37) != null && player.inventory.getStackInSlot(38) != null && player.inventory.getStackInSlot(39) != null && player.inventory.getStackInSlot(36).getItem() == InitItems.itemScubaBoots && player.inventory.getStackInSlot(37).getItem() == InitItems.itemScubaPants && player.inventory.getStackInSlot(38).getItem() == InitItems.itemScubaChest && player.inventory.getStackInSlot(39).getItem() == InitItems.itemScubaHelm;
|
||||
}
|
||||
|
||||
private void addAirToChest(NBTTagCompound compound){
|
||||
int time = compound.getInteger("waitTime");
|
||||
if(time > 0){
|
||||
compound.setInteger("waitTime", time < helmetTimeDecreaseInAir ? 0 : time-helmetTimeDecreaseInAir);
|
||||
compound.setInteger("waitTime", time < chestAirIncreasePerTick ? 0 : time-chestAirIncreasePerTick);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,7 +64,7 @@ public class ItemScubaArmor extends ItemArmorAA{
|
|||
if(!entity.isInsideOfMaterial(Material.water)){
|
||||
NBTTagCompound compound = stack.getTagCompound();
|
||||
if(compound != null){
|
||||
this.addAir(compound);
|
||||
this.addAirToChest(compound);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -66,10 +74,10 @@ public class ItemScubaArmor extends ItemArmorAA{
|
|||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld){
|
||||
super.addInformation(stack, player, list, isHeld);
|
||||
if(KeyUtil.isShiftPressed() && stack.getItem() == InitItems.itemScubaHelm){
|
||||
if(KeyUtil.isShiftPressed() && stack.getItem() == InitItems.itemScubaChest){
|
||||
NBTTagCompound compound = stack.getTagCompound();
|
||||
//TODO Localize
|
||||
list.add("Air: "+(compound == null ? helmetTime : helmetTime-compound.getInteger("waitTime"))+"/"+helmetTime);
|
||||
list.add("Air: "+(compound == null ? chestAirTime : chestAirTime-compound.getInteger("waitTime"))+"/"+chestAirTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue