diff --git a/src/main/java/mekanism/client/ClientTickHandler.java b/src/main/java/mekanism/client/ClientTickHandler.java index cb9ee9f72..ceb7ce012 100644 --- a/src/main/java/mekanism/client/ClientTickHandler.java +++ b/src/main/java/mekanism/client/ClientTickHandler.java @@ -9,6 +9,7 @@ import java.util.Set; import mekanism.api.EnumColor; import mekanism.api.IClientTicker; +import mekanism.api.gas.GasStack; import mekanism.client.sound.GasMaskSound; import mekanism.client.sound.JetpackSound; import mekanism.client.sound.SoundHandler; @@ -455,9 +456,20 @@ public class ClientTickHandler { ItemScubaTank tank = (ItemScubaTank)mc.thePlayer.getEquipmentInSlot(3).getItem(); + final int max = 300; + tank.useGas(mc.thePlayer.getEquipmentInSlot(3)); - mc.thePlayer.setAir(300); - mc.thePlayer.clearActivePotions(); + GasStack received = tank.removeGas(mc.thePlayer.getEquipmentInSlot(3), max-mc.thePlayer.getAir()); + + if(received != null) + { + mc.thePlayer.setAir(mc.thePlayer.getAir()+received.amount); + + if(mc.thePlayer.getAir() == max) + { + mc.thePlayer.clearActivePotions(); + } + } } } } diff --git a/src/main/java/mekanism/common/CommonPlayerTickHandler.java b/src/main/java/mekanism/common/CommonPlayerTickHandler.java index 423aa8b20..bdb51c4f4 100644 --- a/src/main/java/mekanism/common/CommonPlayerTickHandler.java +++ b/src/main/java/mekanism/common/CommonPlayerTickHandler.java @@ -1,5 +1,6 @@ package mekanism.common; +import mekanism.api.gas.GasStack; import mekanism.common.item.ItemFreeRunners; import mekanism.common.item.ItemGasMask; import mekanism.common.item.ItemJetpack; @@ -15,13 +16,14 @@ import net.minecraft.network.NetHandlerPlayServer; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent.Phase; import cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent; +import cpw.mods.fml.relauncher.Side; public class CommonPlayerTickHandler { @SubscribeEvent public void onTick(PlayerTickEvent event) { - if(event.phase == Phase.END) + if(event.phase == Phase.END && event.side == Side.SERVER) { tickEnd(event.player); } @@ -29,7 +31,7 @@ public class CommonPlayerTickHandler public void tickEnd(EntityPlayer player) { - if(!player.worldObj.isRemote && player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemPortableTeleporter) + if(player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemPortableTeleporter) { ItemPortableTeleporter item = (ItemPortableTeleporter)player.getCurrentEquippedItem().getItem(); ItemStack itemstack = player.getCurrentEquippedItem(); @@ -141,9 +143,20 @@ public class CommonPlayerTickHandler { ItemScubaTank tank = (ItemScubaTank)player.getEquipmentInSlot(3).getItem(); + final int max = 300; + tank.useGas(player.getEquipmentInSlot(3)); - player.setAir(300); - player.clearActivePotions(); + GasStack received = tank.removeGas(player.getEquipmentInSlot(3), max-player.getAir()); + + if(received != null) + { + player.setAir(player.getAir()+received.amount); + + if(player.getAir() == max) + { + player.clearActivePotions(); + } + } } } diff --git a/src/main/java/mekanism/common/CommonProxy.java b/src/main/java/mekanism/common/CommonProxy.java index d8232099f..e023b54d5 100644 --- a/src/main/java/mekanism/common/CommonProxy.java +++ b/src/main/java/mekanism/common/CommonProxy.java @@ -189,6 +189,7 @@ public class CommonProxy Mekanism.voiceServerEnabled = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "VoiceServerEnabled", true).getBoolean(true); Mekanism.cardboardSpawners = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "AllowSpawnerBoxPickup", true).getBoolean(true); Mekanism.enableWorldRegeneration = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EnableWorldRegeneration", false).getBoolean(false); + Mekanism.creativeOverrideElectricChest = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "CreativeOverrideElectricChest", true).getBoolean(true); Mekanism.obsidianTNTDelay = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ObsidianTNTDelay", 100).getInt(); Mekanism.obsidianTNTBlastRadius = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ObsidianTNTBlastRadius", 12).getInt(); Mekanism.UPDATE_DELAY = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ClientUpdateDelay", 10).getInt(); diff --git a/src/main/java/mekanism/common/Mekanism.java b/src/main/java/mekanism/common/Mekanism.java index 40a7fe8c7..78c92ea46 100644 --- a/src/main/java/mekanism/common/Mekanism.java +++ b/src/main/java/mekanism/common/Mekanism.java @@ -309,6 +309,7 @@ public class Mekanism public static boolean cardboardSpawners = true; public static boolean machineEffects = true; public static boolean enableWorldRegeneration = true; + public static boolean creativeOverrideElectricChest = true; public static int obsidianTNTBlastRadius = 12; public static int osmiumPerChunk = 12; public static int copperPerChunk = 16; diff --git a/src/main/java/mekanism/common/block/BlockMachine.java b/src/main/java/mekanism/common/block/BlockMachine.java index 0317bd4aa..f565a5a14 100644 --- a/src/main/java/mekanism/common/block/BlockMachine.java +++ b/src/main/java/mekanism/common/block/BlockMachine.java @@ -68,12 +68,12 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.init.Items; import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; +import net.minecraft.server.MinecraftServer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.IIcon; diff --git a/src/main/java/mekanism/common/inventory/InventoryElectricChest.java b/src/main/java/mekanism/common/inventory/InventoryElectricChest.java index b0e261cda..545ec4600 100644 --- a/src/main/java/mekanism/common/inventory/InventoryElectricChest.java +++ b/src/main/java/mekanism/common/inventory/InventoryElectricChest.java @@ -71,7 +71,10 @@ public class InventoryElectricChest extends InventoryBasic } } - ((ISustainedInventory)getStack().getItem()).setInventory(tagList, getStack()); + if(getStack() != null) + { + ((ISustainedInventory)getStack().getItem()).setInventory(tagList, getStack()); + } } public void read() diff --git a/src/main/java/mekanism/common/network/PacketConfigSync.java b/src/main/java/mekanism/common/network/PacketConfigSync.java index c29a957da..958e400e1 100644 --- a/src/main/java/mekanism/common/network/PacketConfigSync.java +++ b/src/main/java/mekanism/common/network/PacketConfigSync.java @@ -30,6 +30,7 @@ public class PacketConfigSync implements IMessageHandler