Add potion resistance to gas mask

This commit is contained in:
Aidan Brady 2013-12-07 00:55:35 -05:00
parent 916859c21d
commit 5e50e920a6
4 changed files with 37 additions and 10 deletions

View file

@ -234,6 +234,7 @@ public class ClientPlayerTickHandler implements ITickHandler
tank.useGas(entityPlayer.getCurrentItemOrArmor(3));
entityPlayer.setAir(300);
entityPlayer.clearActivePotions();
}
}
}

View file

@ -132,6 +132,7 @@ public class CommonPlayerTickHandler implements ITickHandler
tank.useGas(player.getCurrentItemOrArmor(3));
player.setAir(300);
player.clearActivePotions();
}
}
}

View file

@ -247,23 +247,23 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds
if(side == 4)
{
world.spawnParticle("smoke", (double)(xRandom - iRandom), (double)yRandom, (double)(zRandom + jRandom), 0.0D, 0.0D, 0.0D);
world.spawnParticle("reddust", (double)(xRandom - iRandom), (double)yRandom, (double)(zRandom + jRandom), 0.0D, 0.0D, 0.0D);
world.spawnParticle("smoke", (xRandom - iRandom), yRandom, (zRandom + jRandom), 0.0D, 0.0D, 0.0D);
world.spawnParticle("reddust", (xRandom - iRandom), yRandom, (zRandom + jRandom), 0.0D, 0.0D, 0.0D);
}
else if(side == 5)
{
world.spawnParticle("smoke", (double)(xRandom + iRandom), (double)yRandom, (double)(zRandom + jRandom), 0.0D, 0.0D, 0.0D);
world.spawnParticle("reddust", (double)(xRandom + iRandom), (double)yRandom, (double)(zRandom + jRandom), 0.0D, 0.0D, 0.0D);
world.spawnParticle("smoke", (xRandom + iRandom), yRandom, (zRandom + jRandom), 0.0D, 0.0D, 0.0D);
world.spawnParticle("reddust", (xRandom + iRandom), yRandom, (zRandom + jRandom), 0.0D, 0.0D, 0.0D);
}
else if(side == 2)
{
world.spawnParticle("smoke", (double)(xRandom + jRandom), (double)yRandom, (double)(zRandom - iRandom), 0.0D, 0.0D, 0.0D);
world.spawnParticle("reddust", (double)(xRandom + jRandom), (double)yRandom, (double)(zRandom - iRandom), 0.0D, 0.0D, 0.0D);
world.spawnParticle("smoke", (xRandom + jRandom), yRandom, (zRandom - iRandom), 0.0D, 0.0D, 0.0D);
world.spawnParticle("reddust", (xRandom + jRandom), yRandom, (zRandom - iRandom), 0.0D, 0.0D, 0.0D);
}
else if(side == 3)
{
world.spawnParticle("smoke", (double)(xRandom + jRandom), (double)yRandom, (double)(zRandom + iRandom), 0.0D, 0.0D, 0.0D);
world.spawnParticle("reddust", (double)(xRandom + jRandom), (double)yRandom, (double)(zRandom + iRandom), 0.0D, 0.0D, 0.0D);
world.spawnParticle("smoke", (xRandom + jRandom), yRandom, (zRandom + iRandom), 0.0D, 0.0D, 0.0D);
world.spawnParticle("reddust", (xRandom + jRandom), yRandom, (zRandom + iRandom), 0.0D, 0.0D, 0.0D);
}
}
}

View file

@ -1,7 +1,5 @@
package mekanism.common.item;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import mekanism.client.render.ModelCustomArmor;
import mekanism.client.render.ModelCustomArmor.ArmorModel;
import mekanism.common.Mekanism;
@ -11,6 +9,11 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.EnumHelper;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.entity.living.LivingAttackEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemGasMask extends ItemArmor
{
@ -18,6 +21,7 @@ public class ItemGasMask extends ItemArmor
{
super(id, EnumHelper.addArmorMaterial("GASMASK", 0, new int[] {0, 0, 0, 0}, 0), 0, 0);
setCreativeTab(Mekanism.tabMekanism);
MinecraftForge.EVENT_BUS.register(this);
}
@Override
@ -40,4 +44,25 @@ public class ItemGasMask extends ItemArmor
model.modelType = ArmorModel.GASMASK;
return model;
}
@ForgeSubscribe
public void onEntityAttacked(LivingAttackEvent event)
{
EntityLivingBase base = event.entityLiving;
if(base.getCurrentItemOrArmor(4) != null && base.getCurrentItemOrArmor(4).getItem() instanceof ItemGasMask)
{
ItemGasMask mask = (ItemGasMask)base.getCurrentItemOrArmor(4).getItem();
if(base.getCurrentItemOrArmor(3) != null && base.getCurrentItemOrArmor(3).getItem() instanceof ItemScubaTank)
{
ItemScubaTank tank = (ItemScubaTank)base.getCurrentItemOrArmor(3).getItem();
if(tank.getFlowing(base.getCurrentItemOrArmor(3)) && tank.getGas(base.getCurrentItemOrArmor(3)) != null)
{
event.setCanceled(true);
}
}
}
}
}