Fixed Gas Mask OP-ness, added config option to let creative mode override the Electric Chest, fixed Gas Generator crash

This commit is contained in:
Aidan C. Brady 2014-07-16 23:53:00 -04:00
parent de1e264c68
commit cfeb08a8ee
8 changed files with 44 additions and 9 deletions

View file

@ -9,6 +9,7 @@ import java.util.Set;
import mekanism.api.EnumColor; import mekanism.api.EnumColor;
import mekanism.api.IClientTicker; import mekanism.api.IClientTicker;
import mekanism.api.gas.GasStack;
import mekanism.client.sound.GasMaskSound; import mekanism.client.sound.GasMaskSound;
import mekanism.client.sound.JetpackSound; import mekanism.client.sound.JetpackSound;
import mekanism.client.sound.SoundHandler; import mekanism.client.sound.SoundHandler;
@ -455,9 +456,20 @@ public class ClientTickHandler
{ {
ItemScubaTank tank = (ItemScubaTank)mc.thePlayer.getEquipmentInSlot(3).getItem(); ItemScubaTank tank = (ItemScubaTank)mc.thePlayer.getEquipmentInSlot(3).getItem();
final int max = 300;
tank.useGas(mc.thePlayer.getEquipmentInSlot(3)); tank.useGas(mc.thePlayer.getEquipmentInSlot(3));
mc.thePlayer.setAir(300); GasStack received = tank.removeGas(mc.thePlayer.getEquipmentInSlot(3), max-mc.thePlayer.getAir());
mc.thePlayer.clearActivePotions();
if(received != null)
{
mc.thePlayer.setAir(mc.thePlayer.getAir()+received.amount);
if(mc.thePlayer.getAir() == max)
{
mc.thePlayer.clearActivePotions();
}
}
} }
} }
} }

View file

@ -1,5 +1,6 @@
package mekanism.common; package mekanism.common;
import mekanism.api.gas.GasStack;
import mekanism.common.item.ItemFreeRunners; import mekanism.common.item.ItemFreeRunners;
import mekanism.common.item.ItemGasMask; import mekanism.common.item.ItemGasMask;
import mekanism.common.item.ItemJetpack; 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.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent.Phase; import cpw.mods.fml.common.gameevent.TickEvent.Phase;
import cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent; import cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent;
import cpw.mods.fml.relauncher.Side;
public class CommonPlayerTickHandler public class CommonPlayerTickHandler
{ {
@SubscribeEvent @SubscribeEvent
public void onTick(PlayerTickEvent event) public void onTick(PlayerTickEvent event)
{ {
if(event.phase == Phase.END) if(event.phase == Phase.END && event.side == Side.SERVER)
{ {
tickEnd(event.player); tickEnd(event.player);
} }
@ -29,7 +31,7 @@ public class CommonPlayerTickHandler
public void tickEnd(EntityPlayer player) 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(); ItemPortableTeleporter item = (ItemPortableTeleporter)player.getCurrentEquippedItem().getItem();
ItemStack itemstack = player.getCurrentEquippedItem(); ItemStack itemstack = player.getCurrentEquippedItem();
@ -141,9 +143,20 @@ public class CommonPlayerTickHandler
{ {
ItemScubaTank tank = (ItemScubaTank)player.getEquipmentInSlot(3).getItem(); ItemScubaTank tank = (ItemScubaTank)player.getEquipmentInSlot(3).getItem();
final int max = 300;
tank.useGas(player.getEquipmentInSlot(3)); tank.useGas(player.getEquipmentInSlot(3));
player.setAir(300); GasStack received = tank.removeGas(player.getEquipmentInSlot(3), max-player.getAir());
player.clearActivePotions();
if(received != null)
{
player.setAir(player.getAir()+received.amount);
if(player.getAir() == max)
{
player.clearActivePotions();
}
}
} }
} }

View file

@ -189,6 +189,7 @@ public class CommonProxy
Mekanism.voiceServerEnabled = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "VoiceServerEnabled", true).getBoolean(true); 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.cardboardSpawners = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "AllowSpawnerBoxPickup", true).getBoolean(true);
Mekanism.enableWorldRegeneration = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EnableWorldRegeneration", false).getBoolean(false); 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.obsidianTNTDelay = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ObsidianTNTDelay", 100).getInt();
Mekanism.obsidianTNTBlastRadius = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ObsidianTNTBlastRadius", 12).getInt(); Mekanism.obsidianTNTBlastRadius = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ObsidianTNTBlastRadius", 12).getInt();
Mekanism.UPDATE_DELAY = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ClientUpdateDelay", 10).getInt(); Mekanism.UPDATE_DELAY = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ClientUpdateDelay", 10).getInt();

View file

@ -309,6 +309,7 @@ public class Mekanism
public static boolean cardboardSpawners = true; public static boolean cardboardSpawners = true;
public static boolean machineEffects = true; public static boolean machineEffects = true;
public static boolean enableWorldRegeneration = true; public static boolean enableWorldRegeneration = true;
public static boolean creativeOverrideElectricChest = true;
public static int obsidianTNTBlastRadius = 12; public static int obsidianTNTBlastRadius = 12;
public static int osmiumPerChunk = 12; public static int osmiumPerChunk = 12;
public static int copperPerChunk = 16; public static int copperPerChunk = 16;

View file

@ -68,12 +68,12 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Items;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagList;
import net.minecraft.server.MinecraftServer;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;

View file

@ -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() public void read()

View file

@ -30,6 +30,7 @@ public class PacketConfigSync implements IMessageHandler<ConfigSyncMessage, IMes
dataStream.writeBoolean(Mekanism.dynamicTankEasterEgg); dataStream.writeBoolean(Mekanism.dynamicTankEasterEgg);
dataStream.writeBoolean(Mekanism.voiceServerEnabled); dataStream.writeBoolean(Mekanism.voiceServerEnabled);
dataStream.writeBoolean(Mekanism.cardboardSpawners); dataStream.writeBoolean(Mekanism.cardboardSpawners);
dataStream.writeBoolean(Mekanism.creativeOverrideElectricChest);
dataStream.writeInt(Mekanism.obsidianTNTDelay); dataStream.writeInt(Mekanism.obsidianTNTDelay);
dataStream.writeInt(Mekanism.obsidianTNTBlastRadius); dataStream.writeInt(Mekanism.obsidianTNTBlastRadius);
dataStream.writeInt(Mekanism.UPDATE_DELAY); dataStream.writeInt(Mekanism.UPDATE_DELAY);
@ -83,6 +84,7 @@ public class PacketConfigSync implements IMessageHandler<ConfigSyncMessage, IMes
Mekanism.dynamicTankEasterEgg = dataStream.readBoolean(); Mekanism.dynamicTankEasterEgg = dataStream.readBoolean();
Mekanism.voiceServerEnabled = dataStream.readBoolean(); Mekanism.voiceServerEnabled = dataStream.readBoolean();
Mekanism.cardboardSpawners = dataStream.readBoolean(); Mekanism.cardboardSpawners = dataStream.readBoolean();
Mekanism.creativeOverrideElectricChest = dataStream.readBoolean();
Mekanism.obsidianTNTDelay = dataStream.readInt(); Mekanism.obsidianTNTDelay = dataStream.readInt();
Mekanism.obsidianTNTBlastRadius = dataStream.readInt(); Mekanism.obsidianTNTBlastRadius = dataStream.readInt();
Mekanism.UPDATE_DELAY = dataStream.readInt(); Mekanism.UPDATE_DELAY = dataStream.readInt();

View file

@ -62,7 +62,10 @@ public class TileEntityGasGenerator extends TileEntityGenerator implements IGasH
} }
else if(inventory[0] != null && inventory[0].getItem() instanceof IGasItem) else if(inventory[0] != null && inventory[0].getItem() instanceof IGasItem)
{ {
gasType = ((IGasItem)inventory[0].getItem()).getGas(inventory[0]).getGas(); if(((IGasItem)inventory[0].getItem()).getGas(inventory[0]) != null)
{
gasType = ((IGasItem)inventory[0].getItem()).getGas(inventory[0]).getGas();
}
} }
if(gasType != null && FuelHandler.getFuel(gasType) != null) if(gasType != null && FuelHandler.getFuel(gasType) != null)