diff --git a/common/mekanism/client/ClientConnectionHandler.java b/common/mekanism/client/ClientConnectionHandler.java index 7c6200541..88bf7f878 100644 --- a/common/mekanism/client/ClientConnectionHandler.java +++ b/common/mekanism/client/ClientConnectionHandler.java @@ -68,6 +68,7 @@ public class ClientConnectionHandler implements IConnectionHandler ClientTickHandler.tickingSet.clear(); Mekanism.jetpackOn.clear(); + Mekanism.gasmaskOn.clear(); Mekanism.proxy.unloadSoundHandler(); } diff --git a/common/mekanism/client/ClientPlayerTickHandler.java b/common/mekanism/client/ClientPlayerTickHandler.java index 49cb3632a..ef9d752bf 100644 --- a/common/mekanism/client/ClientPlayerTickHandler.java +++ b/common/mekanism/client/ClientPlayerTickHandler.java @@ -3,18 +3,23 @@ package mekanism.client; import java.util.EnumSet; import mekanism.api.EnumColor; +import mekanism.client.sound.GasMaskSound; +import mekanism.client.sound.JetpackSound; import mekanism.common.Mekanism; import mekanism.common.PacketHandler; import mekanism.common.PacketHandler.Transmission; import mekanism.common.item.ItemConfigurator; import mekanism.common.item.ItemElectricBow; +import mekanism.common.item.ItemGasMask; import mekanism.common.item.ItemJetpack; import mekanism.common.item.ItemJetpack.JetpackMode; +import mekanism.common.item.ItemScubaTank; import mekanism.common.item.ItemWalkieTalkie; import mekanism.common.network.PacketConfiguratorState; import mekanism.common.network.PacketElectricBowState; import mekanism.common.network.PacketJetpackData; import mekanism.common.network.PacketJetpackData.PacketType; +import mekanism.common.network.PacketScubaTankData; import mekanism.common.network.PacketWalkieTalkieState; import mekanism.common.util.StackUtils; import net.minecraft.client.Minecraft; @@ -139,7 +144,31 @@ public class ClientPlayerTickHandler implements ITickHandler for(EntityPlayer entry : Mekanism.jetpackOn) { - Mekanism.proxy.registerSound(entry); + if(MekanismClient.audioHandler.getFrom(entry) == null) + { + new JetpackSound(MekanismClient.audioHandler.getIdentifier(), entry); + } + } + + if(Mekanism.gasmaskOn.contains(entityPlayer) != isGasMaskOn(entityPlayer)) + { + if(isGasMaskOn(entityPlayer)) + { + Mekanism.gasmaskOn.add(entityPlayer); + } + else { + Mekanism.gasmaskOn.remove(entityPlayer); + } + + PacketHandler.sendPacket(Transmission.SERVER, new PacketScubaTankData().setParams(PacketType.UPDATE, entityPlayer, isGasMaskOn(entityPlayer))); + } + + for(EntityPlayer entry : Mekanism.gasmaskOn) + { + if(MekanismClient.audioHandler.getFrom(entry) == null) + { + new GasMaskSound(MekanismClient.audioHandler.getIdentifier(), entry); + } } if(entityPlayer.getCurrentItemOrArmor(3) != null && entityPlayer.getCurrentItemOrArmor(3).getItem() instanceof ItemJetpack) @@ -149,7 +178,7 @@ public class ClientPlayerTickHandler implements ITickHandler } if(isJetpackOn(entityPlayer)) - { + { ItemJetpack jetpack = (ItemJetpack)entityPlayer.getCurrentItemOrArmor(3).getItem(); if(jetpack.getMode(entityPlayer.getCurrentItemOrArmor(3)) == JetpackMode.NORMAL) @@ -186,14 +215,17 @@ public class ClientPlayerTickHandler implements ITickHandler jetpack.useGas(entityPlayer.getCurrentItemOrArmor(3)); } + + if(isGasMaskOn(entityPlayer)) + { + ItemScubaTank tank = (ItemScubaTank)entityPlayer.getCurrentItemOrArmor(3).getItem(); + + tank.useGas(entityPlayer.getCurrentItemOrArmor(3)); + entityPlayer.setAir(300); + } } } - private boolean cacheJetpackOn(EntityPlayer player) - { - return Mekanism.jetpackOn.contains(player); - } - public static boolean isJetpackOn(EntityPlayer player) { ItemStack stack = player.inventory.armorInventory[2]; @@ -221,6 +253,30 @@ public class ClientPlayerTickHandler implements ITickHandler return false; } + public static boolean isGasMaskOn(EntityPlayer player) + { + ItemStack tank = player.inventory.armorInventory[2]; + ItemStack mask = player.inventory.armorInventory[3]; + + if(tank != null && mask != null) + { + if(tank.getItem() instanceof ItemScubaTank && mask.getItem() instanceof ItemGasMask) + { + ItemScubaTank scubaTank = (ItemScubaTank)tank.getItem(); + + if(scubaTank.getGas(tank) != null) + { + if(scubaTank.getFlowing(tank)) + { + return true; + } + } + } + } + + return false; + } + @Override public EnumSet ticks() { diff --git a/common/mekanism/client/render/ModelCustomArmor.java b/common/mekanism/client/render/ModelCustomArmor.java index 1b614ad83..253a9acce 100644 --- a/common/mekanism/client/render/ModelCustomArmor.java +++ b/common/mekanism/client/render/ModelCustomArmor.java @@ -46,11 +46,6 @@ public class ModelCustomArmor extends ModelBiped bipedBody.isHidden = false; bipedBody.showModel = true; } - else if(modelType.armorSlot == 2) - { - bipedRightLeg.showModel = true; - bipedLeftLeg.showModel = true; - } setRotationAngles(f, f1, f2, f3, f4, size, entity); } @@ -109,9 +104,20 @@ public class ModelCustomArmor extends ModelBiped mc.renderEngine.bindTexture(modelType.resource); - if(ModelCustomArmor.this.modelType == ArmorModel.JETPACK && biped.bipedBody == partRender) + if(useModel(biped.modelType, partRender, biped)) { - ArmorModel.jetpackModel.render(0.0625F); + if(biped.modelType == ArmorModel.JETPACK) + { + ArmorModel.jetpackModel.render(0.0625F); + } + else if(biped.modelType == ArmorModel.SCUBATANK) + { + + } + else if(biped.modelType == ArmorModel.GASMASK) + { + + } } GL11.glPopMatrix(); @@ -125,10 +131,26 @@ public class ModelCustomArmor extends ModelBiped init(entity, par2, par3, par4, par5, par6, par7); super.render(entity, par2, par3, par4, par5, par6, par7); } + + public static boolean useModel(ArmorModel type, ModelRenderer partRender, ModelCustomArmor biped) + { + if(type.armorSlot == 0) + { + return partRender == biped.bipedHead; + } + else if(type.armorSlot == 1) + { + return partRender == biped.bipedBody; + } + + return false; + } public static enum ArmorModel { - JETPACK(1, MekanismUtils.getResource(ResourceType.RENDER, "Jetpack.png")); + JETPACK(1, MekanismUtils.getResource(ResourceType.RENDER, "Jetpack.png")), + SCUBATANK(1, MekanismUtils.getResource(ResourceType.RENDER, "ScubaTank.png")), + GASMASK(0, MekanismUtils.getResource(ResourceType.RENDER, "GasMask.png")); public int armorSlot; public ResourceLocation resource; diff --git a/common/mekanism/client/sound/GasMaskSound.java b/common/mekanism/client/sound/GasMaskSound.java new file mode 100644 index 000000000..92bbc9944 --- /dev/null +++ b/common/mekanism/client/sound/GasMaskSound.java @@ -0,0 +1,55 @@ +package mekanism.client.sound; + +import mekanism.client.ClientPlayerTickHandler; +import mekanism.common.item.ItemGasMask; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; + +public class GasMaskSound extends PlayerSound +{ + public GasMaskSound(String id, EntityPlayer entity) + { + super(id, "GasMask.ogg", entity); + } + + @Override + public boolean update(World world) + { + if(player.isDead) + { + return false; + } + else if(!world.loadedEntityList.contains(player)) + { + return false; + } + else if(!hasGasMask(player)) + { + return false; + } + else { + if(ClientPlayerTickHandler.isGasMaskOn(player) != isPlaying) + { + if(ClientPlayerTickHandler.isGasMaskOn(player)) + { + play(); + } + else { + stopLoop(); + } + } + } + + if(isPlaying) + { + ticksSincePlay++; + } + + return true; + } + + private boolean hasGasMask(EntityPlayer player) + { + return player.inventory.armorInventory[3] != null && player.inventory.armorInventory[3].getItem() instanceof ItemGasMask; + } +} diff --git a/common/mekanism/client/sound/JetpackSound.java b/common/mekanism/client/sound/JetpackSound.java index dd49774d2..d4dadf9d2 100644 --- a/common/mekanism/client/sound/JetpackSound.java +++ b/common/mekanism/client/sound/JetpackSound.java @@ -2,43 +2,15 @@ package mekanism.client.sound; import mekanism.client.ClientPlayerTickHandler; import mekanism.common.item.ItemJetpack; -import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; import universalelectricity.core.vector.Vector3; -public class JetpackSound extends Sound +public class JetpackSound extends PlayerSound { - /** The TileEntity this sound is associated with. */ - public EntityPlayer player; - - public int ticksSincePlay = 0; - - public JetpackSound(String id, String sound, EntityPlayer entity) + public JetpackSound(String id, EntityPlayer entity) { - super(id, sound, entity, new Vector3(entity)); - - player = entity; - } - - @Override - public float getMultiplier() - { - return Math.min(1, ((float)ticksSincePlay/20F))*0.3F; - } - - @Override - public Vector3 getLocation() - { - return new Vector3(player); - } - - @Override - public void play() - { - super.play(); - - ticksSincePlay = 0; + super(id, "Jetpack.ogg", entity); } @Override diff --git a/common/mekanism/client/sound/PlayerSound.java b/common/mekanism/client/sound/PlayerSound.java new file mode 100644 index 000000000..371cb53ad --- /dev/null +++ b/common/mekanism/client/sound/PlayerSound.java @@ -0,0 +1,45 @@ +package mekanism.client.sound; + +import mekanism.client.ClientPlayerTickHandler; +import mekanism.common.item.ItemJetpack; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; +import universalelectricity.core.vector.Vector3; + +public abstract class PlayerSound extends Sound +{ + /** The TileEntity this sound is associated with. */ + public EntityPlayer player; + + public int ticksSincePlay = 0; + + public PlayerSound(String id, String sound, EntityPlayer entity) + { + super(id, sound, entity, new Vector3(entity)); + + player = entity; + } + + @Override + public float getMultiplier() + { + return Math.min(1, ((float)ticksSincePlay/20F))*0.3F; + } + + @Override + public Vector3 getLocation() + { + return new Vector3(player); + } + + @Override + public void play() + { + super.play(); + + ticksSincePlay = 0; + } + + @Override + public abstract boolean update(World world); +} diff --git a/common/mekanism/client/sound/Sound.java b/common/mekanism/client/sound/Sound.java index a22dff342..f973a00a3 100644 --- a/common/mekanism/client/sound/Sound.java +++ b/common/mekanism/client/sound/Sound.java @@ -3,6 +3,7 @@ package mekanism.client.sound; import java.net.URL; import mekanism.client.MekanismClient; +import mekanism.common.Mekanism; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; @@ -29,6 +30,11 @@ public abstract class Sound */ public Sound(String id, String sound, Object obj, Vector3 loc) { + if(MekanismClient.audioHandler.getFrom(obj) != null) + { + return; + } + synchronized(MekanismClient.audioHandler.sounds) { soundPath = sound; diff --git a/common/mekanism/client/sound/SoundHandler.java b/common/mekanism/client/sound/SoundHandler.java index 5305c6204..da39e87f5 100644 --- a/common/mekanism/client/sound/SoundHandler.java +++ b/common/mekanism/client/sound/SoundHandler.java @@ -248,10 +248,6 @@ public class SoundHandler { new TileSound(getIdentifier(), ((IHasSound)obj).getSoundPath(), (TileEntity)obj); } - else if(obj instanceof EntityPlayer) - { - new JetpackSound(getIdentifier(), "Jetpack.ogg", (EntityPlayer)obj); - } } } } diff --git a/common/mekanism/common/Mekanism.java b/common/mekanism/common/Mekanism.java index 60dd70695..63a3e91de 100644 --- a/common/mekanism/common/Mekanism.java +++ b/common/mekanism/common/Mekanism.java @@ -52,6 +52,7 @@ import mekanism.common.item.ItemDirtyDust; import mekanism.common.item.ItemDust; import mekanism.common.item.ItemElectricBow; import mekanism.common.item.ItemEnergized; +import mekanism.common.item.ItemGasMask; import mekanism.common.item.ItemIngot; import mekanism.common.item.ItemJetpack; import mekanism.common.item.ItemMachineUpgrade; @@ -60,6 +61,7 @@ import mekanism.common.item.ItemNetworkReader; import mekanism.common.item.ItemPortableTeleporter; import mekanism.common.item.ItemProxy; import mekanism.common.item.ItemRobit; +import mekanism.common.item.ItemScubaTank; import mekanism.common.item.ItemWalkieTalkie; import mekanism.common.network.PacketConfigurationUpdate; import mekanism.common.network.PacketConfiguratorState; @@ -78,6 +80,7 @@ import mekanism.common.network.PacketPortalFX; import mekanism.common.network.PacketRedstoneControl; import mekanism.common.network.PacketRemoveUpgrade; import mekanism.common.network.PacketRobit; +import mekanism.common.network.PacketScubaTankData; import mekanism.common.network.PacketSimpleGui; import mekanism.common.network.PacketStatusUpdate; import mekanism.common.network.PacketTileEntity; @@ -182,6 +185,7 @@ public class Mekanism public static KeySync keyMap = new KeySync(); public static Set jetpackOn = new HashSet(); + public static Set gasmaskOn = new HashSet(); public static Set ic2Registered = new HashSet(); @@ -215,6 +219,8 @@ public class Mekanism public static Item WalkieTalkie; public static Item ItemProxy; public static ItemJetpack Jetpack; + public static ItemScubaTank ScubaTank; + public static ItemGasMask GasMask; //Blocks public static Block BasicBlock; @@ -1107,6 +1113,8 @@ public class Mekanism dynamicInventories.clear(); ic2Registered.clear(); jetpackOn.clear(); + gasmaskOn.clear(); + TransporterManager.flowingStacks.clear(); } @@ -1206,6 +1214,7 @@ public class Mekanism PacketHandler.registerPacket(PacketDigitalMinerGui.class); PacketHandler.registerPacket(PacketJetpackData.class); PacketHandler.registerPacket(PacketKey.class); + PacketHandler.registerPacket(PacketScubaTankData.class); //Donators donators.add("mrgreaper"); diff --git a/common/mekanism/common/item/ItemGasMask.java b/common/mekanism/common/item/ItemGasMask.java new file mode 100644 index 000000000..fa5e22e5c --- /dev/null +++ b/common/mekanism/common/item/ItemGasMask.java @@ -0,0 +1,43 @@ +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; +import net.minecraft.client.model.ModelBiped; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemArmor; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.EnumHelper; + +public class ItemGasMask extends ItemArmor +{ + public ItemGasMask(int id) + { + super(id, EnumHelper.addArmorMaterial("GASMASK", 0, new int[] {0, 0, 0, 0}, 0), 0, 0); + setCreativeTab(Mekanism.tabMekanism); + } + + @Override + public boolean isValidArmor(ItemStack stack, int armorType, Entity entity) + { + return armorType == 0; + } + + @Override + public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) + { + return "mekanism:render/NullArmor.png"; + } + + @Override + @SideOnly(Side.CLIENT) + public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) + { + ModelCustomArmor model = ModelCustomArmor.INSTANCE; + model.modelType = ArmorModel.GASMASK; + return model; + } +} diff --git a/common/mekanism/common/item/ItemScubaTank.java b/common/mekanism/common/item/ItemScubaTank.java new file mode 100644 index 000000000..70f0c2117 --- /dev/null +++ b/common/mekanism/common/item/ItemScubaTank.java @@ -0,0 +1,228 @@ +package mekanism.common.item; + +import java.util.List; + +import mekanism.api.EnumColor; +import mekanism.api.gas.Gas; +import mekanism.api.gas.GasRegistry; +import mekanism.api.gas.GasStack; +import mekanism.api.gas.IGasItem; +import mekanism.client.render.ModelCustomArmor; +import mekanism.client.render.ModelCustomArmor.ArmorModel; +import mekanism.common.Mekanism; +import mekanism.common.item.ItemJetpack.JetpackMode; +import net.minecraft.client.model.ModelBiped; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemArmor; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.EnumHelper; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class ItemScubaTank extends ItemArmor implements IGasItem +{ + public int MAX_GAS = 24000; + public int TRANSFER_RATE = 16; + + public ItemScubaTank(int id) + { + super(id, EnumHelper.addArmorMaterial("SCUBATANK", 0, new int[] {0, 0, 0, 0}, 0), 0, 1); + setCreativeTab(Mekanism.tabMekanism); + setMaxDamage(100); + setNoRepair(); + } + + @Override + public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) + { + GasStack gasStack = getGas(itemstack); + + if(gasStack == null) + { + list.add("No gas stored."); + } + else { + list.add("Stored " + gasStack.getGas().getLocalizedName() + ": " + gasStack.amount); + } + + list.add(EnumColor.GREY + "Flowing: " + (getFlowing(itemstack) ? EnumColor.DARK_GREEN : EnumColor.DARK_RED) + getFlowing(itemstack)); + } + + @Override + public boolean isValidArmor(ItemStack stack, int armorType, Entity entity) + { + return armorType == 1; + } + + @Override + public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) + { + return "mekanism:render/NullArmor.png"; + } + + @Override + @SideOnly(Side.CLIENT) + public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) + { + ModelCustomArmor model = ModelCustomArmor.INSTANCE; + model.modelType = ArmorModel.SCUBATANK; + return model; + } + + public void useGas(ItemStack stack) + { + setGas(new GasStack(getGas(stack).getGas(), getGas(stack).amount-1), stack); + } + + @Override + public int getMaxGas(Object... data) + { + if(data[0] instanceof ItemStack) + { + return MAX_GAS; + } + + return 0; + } + + @Override + public int getRate(ItemStack itemstack) + { + return TRANSFER_RATE; + } + + @Override + public int addGas(ItemStack itemstack, GasStack stack) + { + if(getGas(itemstack) != null && getGas(itemstack).getGas() != stack.getGas()) + { + return 0; + } + + if(stack.getGas() != GasRegistry.getGas("oxygen")) + { + return 0; + } + + int toUse = Math.min(getMaxGas(itemstack)-getStored(itemstack), Math.min(getRate(itemstack), stack.amount)); + setGas(new GasStack(stack.getGas(), getStored(itemstack)+toUse), itemstack); + + return toUse; + } + + @Override + public GasStack removeGas(ItemStack itemstack, int amount) + { + if(getGas(itemstack) == null) + { + return null; + } + + Gas type = getGas(itemstack).getGas(); + + int gasToUse = Math.min(getStored(itemstack), Math.min(getRate(itemstack), amount)); + setGas(new GasStack(type, getStored(itemstack)-gasToUse), itemstack); + + return new GasStack(type, gasToUse); + } + + public int getStored(ItemStack itemstack) + { + return getGas(itemstack) != null ? getGas(itemstack).amount : 0; + } + + public void toggleFlowing(ItemStack stack) + { + setFlowing(stack, !getFlowing(stack)); + } + + public boolean getFlowing(ItemStack stack) + { + if(stack.stackTagCompound == null) + { + return false; + } + + return stack.stackTagCompound.getBoolean("flowing"); + } + + public void setFlowing(ItemStack stack, boolean flowing) + { + if(stack.stackTagCompound == null) + { + stack.setTagCompound(new NBTTagCompound()); + } + + stack.stackTagCompound.setBoolean("flowing", flowing); + } + + @Override + public boolean canReceiveGas(ItemStack itemstack, Gas type) + { + return type == GasRegistry.getGas("oxygen"); + } + + @Override + public boolean canProvideGas(ItemStack itemstack, Gas type) + { + return getGas(itemstack) != null && (type == null || getGas(itemstack).getGas() == type); + } + + @Override + public GasStack getGas(Object... data) + { + if(data[0] instanceof ItemStack) + { + ItemStack itemstack = (ItemStack)data[0]; + + if(itemstack.stackTagCompound == null) + { + return null; + } + + GasStack stored = GasStack.readFromNBT(itemstack.stackTagCompound.getCompoundTag("stored")); + + if(stored == null) + { + itemstack.setItemDamage(100); + } + else { + itemstack.setItemDamage((int)Math.max(1, (Math.abs((((float)stored.amount/getMaxGas(itemstack))*100)-100)))); + } + + return stored; + } + + return null; + } + + @Override + public void setGas(GasStack stack, Object... data) + { + if(data[0] instanceof ItemStack) + { + ItemStack itemstack = (ItemStack)data[0]; + + if(itemstack.stackTagCompound == null) + { + itemstack.setTagCompound(new NBTTagCompound()); + } + + if(stack == null || stack.amount == 0) + { + itemstack.setItemDamage(100); + itemstack.stackTagCompound.removeTag("stored"); + } + else { + int amount = Math.max(0, Math.min(stack.amount, getMaxGas(itemstack))); + GasStack gasStack = new GasStack(stack.getGas(), amount); + + itemstack.setItemDamage((int)Math.max(1, (Math.abs((((float)amount/getMaxGas(itemstack))*100)-100)))); + itemstack.stackTagCompound.setCompoundTag("stored", gasStack.write(new NBTTagCompound())); + } + } + } +} diff --git a/common/mekanism/common/network/PacketScubaTankData.java b/common/mekanism/common/network/PacketScubaTankData.java new file mode 100644 index 000000000..84f2abc93 --- /dev/null +++ b/common/mekanism/common/network/PacketScubaTankData.java @@ -0,0 +1,98 @@ +package mekanism.common.network; + +import java.io.DataOutputStream; + +import mekanism.common.Mekanism; +import mekanism.common.PacketHandler; +import mekanism.common.PacketHandler.Transmission; +import mekanism.common.item.ItemScubaTank; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +import com.google.common.io.ByteArrayDataInput; + +public class PacketScubaTankData implements IMekanismPacket +{ + public PacketType packetType; + + public EntityPlayer updatePlayer; + public boolean value; + + @Override + public String getName() + { + return "ScubaTankData"; + } + + @Override + public IMekanismPacket setParams(Object... data) + { + packetType = (PacketType)data[0]; + + if(packetType == PacketType.UPDATE) + { + updatePlayer = (EntityPlayer)data[1]; + value = (Boolean)data[2]; + } + + return this; + } + + @Override + public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception + { + packetType = PacketType.values()[dataStream.readInt()]; + + if(packetType == PacketType.UPDATE) + { + String username = dataStream.readUTF(); + boolean value = dataStream.readBoolean(); + + EntityPlayer p = world.getPlayerEntityByName(username); + + if(p != null) + { + if(value) + { + Mekanism.gasmaskOn.add(p); + } + else { + Mekanism.gasmaskOn.remove(p); + } + + if(!world.isRemote) + { + PacketHandler.sendPacket(Transmission.CLIENTS_DIM, new PacketScubaTankData().setParams(PacketType.UPDATE, p, value), world.provider.dimensionId); + } + } + } + else if(packetType == PacketType.MODE) + { + ItemStack stack = player.getCurrentItemOrArmor(3); + + if(stack != null && stack.getItem() instanceof ItemScubaTank) + { + ((ItemScubaTank)stack.getItem()).toggleFlowing(stack); + } + } + } + + @Override + public void write(DataOutputStream dataStream) throws Exception + { + dataStream.writeInt(packetType.ordinal()); + + if(packetType == PacketType.UPDATE) + { + dataStream.writeUTF(updatePlayer.username); + dataStream.writeBoolean(value); + } + } + + public static enum PacketType + { + UPDATE, + MODE; + } +} diff --git a/resources/assets/mekanism/lang/en_US.lang b/resources/assets/mekanism/lang/en_US.lang index 12bda8d94..750ca13e9 100644 --- a/resources/assets/mekanism/lang/en_US.lang +++ b/resources/assets/mekanism/lang/en_US.lang @@ -23,6 +23,8 @@ item.Configurator.name=Configurator item.NetworkReader.name=Network Reader item.WalkieTalkie.name=Walkie-Talkie item.Jetpack.name=Jetpack +item.ScubaTank.name=Scuba Tank +item.GasMask.name=Gas Mask //Gas Tank tile.GasTank.GasTank.name=Gas Tank diff --git a/resources/assets/mekanism/sound/etc/GasMask.ogg b/resources/assets/mekanism/sound/etc/GasMask.ogg new file mode 100644 index 000000000..b0af86d2f Binary files /dev/null and b/resources/assets/mekanism/sound/etc/GasMask.ogg differ