Lay down framework for gas-based advanced machines
This commit is contained in:
parent
1de691be1d
commit
4fb335b7d3
12 changed files with 102 additions and 14 deletions
|
@ -21,6 +21,8 @@ public class Gas
|
|||
|
||||
private Icon icon;
|
||||
|
||||
private boolean visible = true;
|
||||
|
||||
/**
|
||||
* Creates a new Gas object with a defined name or key value.
|
||||
* @param s - name or key to associate this Gas with
|
||||
|
@ -39,6 +41,27 @@ public class Gas
|
|||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not this is a visible gas.
|
||||
* @return if this gas is visible
|
||||
*/
|
||||
public boolean isVisible()
|
||||
{
|
||||
return visible;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets this gas's "visible" state to a new value. Setting it to 'false' will treat this gas as an internal gas, and it will not be displayed or accessed by other mods.
|
||||
* @param v - new visible state
|
||||
* @return this Gas object
|
||||
*/
|
||||
public Gas setVisible(boolean v)
|
||||
{
|
||||
visible = v;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the unlocalized name of this Gas.
|
||||
* @return this Gas's unlocalized name
|
||||
|
|
|
@ -74,6 +74,8 @@ public class MekanismRenderer
|
|||
GasRegistry.getGas("sulfurTrioxideGas").setIcon(event.map.registerIcon("mekanism:LiquidSulfurTrioxide"));
|
||||
GasRegistry.getGas("sulfuricAcid").setIcon(event.map.registerIcon("mekanism:LiquidSulfuricAcid"));
|
||||
GasRegistry.getGas("hydrogenChloride").setIcon(event.map.registerIcon("mekanism:LiquidHydrogenChloride"));
|
||||
GasRegistry.getGas("liquidOsmium").setIcon(event.map.registerIcon("mekanism:LiquidOsmium"));
|
||||
GasRegistry.getGas("liquidStone").setIcon(event.map.registerIcon("mekanism:LiquidStone"));
|
||||
|
||||
FluidRegistry.getFluid("brine").setIcons(event.map.registerIcon("mekanism:LiquidBrine"));
|
||||
}
|
||||
|
|
|
@ -121,14 +121,6 @@ public interface IFactory
|
|||
|
||||
public int getMaxSecondaryEnergy()
|
||||
{
|
||||
if(usesFuel)
|
||||
{
|
||||
MachineType type = MachineType.get(getStack().itemID, getStack().getItemDamage());
|
||||
TileEntityAdvancedElectricMachine machine = (TileEntityAdvancedElectricMachine)type.create();
|
||||
|
||||
return machine.MAX_SECONDARY_ENERGY;
|
||||
}
|
||||
|
||||
return 200;
|
||||
}
|
||||
|
||||
|
|
|
@ -116,7 +116,6 @@ import mekanism.common.util.MekanismUtils.ResourceType;
|
|||
import mekanism.common.voice.VoiceServerManager;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBucket;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||
|
@ -1067,6 +1066,8 @@ public class Mekanism
|
|||
GasRegistry.register(new Gas("sulfurTrioxideGas")).registerFluid();
|
||||
GasRegistry.register(new Gas("sulfuricAcid")).registerFluid();
|
||||
GasRegistry.register(new Gas("hydrogenChloride")).registerFluid();
|
||||
GasRegistry.register(new Gas("liquidOsmium").setVisible(false));
|
||||
GasRegistry.register(new Gas("liquidStone").setVisible(false));
|
||||
|
||||
FluidRegistry.registerFluid(new Fluid("brine"));
|
||||
|
||||
|
|
|
@ -166,9 +166,12 @@ public class ItemBlockGasTank extends ItemBlock implements IGasItem, ISustainedI
|
|||
|
||||
for(Gas type : GasRegistry.getRegisteredGasses())
|
||||
{
|
||||
ItemStack filled = new ItemStack(this);
|
||||
setGas(filled, new GasStack(type, ((IGasItem)filled.getItem()).getMaxGas(filled)));
|
||||
list.add(filled);
|
||||
if(type.isVisible())
|
||||
{
|
||||
ItemStack filled = new ItemStack(this);
|
||||
setGas(filled, new GasStack(type, ((IGasItem)filled.getItem()).getMaxGas(filled)));
|
||||
list.add(filled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@ package mekanism.common.tile;
|
|||
import java.util.ArrayList;
|
||||
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.api.gas.GasTank;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.SideData;
|
||||
import mekanism.common.recipe.RecipeHandler;
|
||||
|
@ -31,6 +33,8 @@ public abstract class TileEntityAdvancedElectricMachine extends TileEntityBasicM
|
|||
/** How much secondary energy (fuel) is stored in this machine. */
|
||||
public int secondaryEnergyStored = 0;
|
||||
|
||||
public GasTank gasTank;
|
||||
|
||||
/**
|
||||
* Advanced Electric Machine -- a machine like this has a total of 4 slots. Input slot (0), fuel slot (1), output slot (2),
|
||||
* energy slot (3), and the upgrade slot (4). The machine will not run if it does not have enough electricity, or if it doesn't have enough
|
||||
|
@ -58,6 +62,8 @@ public abstract class TileEntityAdvancedElectricMachine extends TileEntityBasicM
|
|||
|
||||
sideConfig = new byte[] {2, 1, 0, 4, 5, 3};
|
||||
|
||||
gasTank = new GasTank(maxSecondaryEnergy);
|
||||
|
||||
inventory = new ItemStack[5];
|
||||
|
||||
SECONDARY_ENERGY_PER_TICK = secondaryPerTick;
|
||||
|
@ -94,7 +100,7 @@ public abstract class TileEntityAdvancedElectricMachine extends TileEntityBasicM
|
|||
secondaryEnergyStored -= SECONDARY_ENERGY_PER_TICK;
|
||||
electricityStored -= MekanismUtils.getEnergyPerTick(getSpeedMultiplier(), getEnergyMultiplier(), ENERGY_PER_TICK);
|
||||
|
||||
if((operatingTicks) >= MekanismUtils.getTicks(getSpeedMultiplier(), TICKS_REQUIRED))
|
||||
if(operatingTicks >= MekanismUtils.getTicks(getSpeedMultiplier(), TICKS_REQUIRED))
|
||||
{
|
||||
operate();
|
||||
|
||||
|
@ -228,13 +234,33 @@ public abstract class TileEntityAdvancedElectricMachine extends TileEntityBasicM
|
|||
{
|
||||
super.handlePacketData(dataStream);
|
||||
secondaryEnergyStored = dataStream.readInt();
|
||||
|
||||
if(dataStream.readBoolean())
|
||||
{
|
||||
gasTank.setGas(new GasStack(dataStream.readInt(), dataStream.readInt()));
|
||||
}
|
||||
else {
|
||||
gasTank.setGas(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList getNetworkedData(ArrayList data)
|
||||
{
|
||||
super.getNetworkedData(data);
|
||||
|
||||
data.add(secondaryEnergyStored);
|
||||
|
||||
if(gasTank.getGas() != null)
|
||||
{
|
||||
data.add(true);
|
||||
data.add(gasTank.getGas().getGas().getID());
|
||||
data.add(gasTank.getStored());
|
||||
}
|
||||
else {
|
||||
data.add(false);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
@ -244,6 +270,7 @@ public abstract class TileEntityAdvancedElectricMachine extends TileEntityBasicM
|
|||
super.readFromNBT(nbtTags);
|
||||
|
||||
secondaryEnergyStored = nbtTags.getInteger("secondaryEnergyStored");
|
||||
gasTank.read(nbtTags.getCompoundTag("gasTank"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -252,6 +279,7 @@ public abstract class TileEntityAdvancedElectricMachine extends TileEntityBasicM
|
|||
super.writeToNBT(nbtTags);
|
||||
|
||||
nbtTags.setInteger("secondaryEnergyStored", secondaryEnergyStored);
|
||||
nbtTags.setCompoundTag("gasTank", gasTank.write(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -3,11 +3,12 @@ package mekanism.common.tile;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.gas.Gas;
|
||||
import mekanism.api.gas.GasRegistry;
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.api.gas.GasTank;
|
||||
import mekanism.api.gas.GasTransmission;
|
||||
import mekanism.api.gas.IGasHandler;
|
||||
import mekanism.api.gas.IGasItem;
|
||||
|
@ -83,6 +84,8 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip
|
|||
/** This machine's previous amount of energy. */
|
||||
public double prevEnergy;
|
||||
|
||||
public GasTank gasTank;
|
||||
|
||||
public boolean sorting;
|
||||
|
||||
public int secondaryEnergyStored;
|
||||
|
@ -115,6 +118,8 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip
|
|||
inventory = new ItemStack[5+type.processes*2];
|
||||
progress = new int[type.processes];
|
||||
isActive = false;
|
||||
|
||||
gasTank = new GasTank(getMaxSecondaryEnergy());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -591,6 +596,14 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip
|
|||
sideConfig[i] = dataStream.readByte();
|
||||
}
|
||||
|
||||
if(dataStream.readBoolean())
|
||||
{
|
||||
gasTank.setGas(new GasStack(dataStream.readInt(), dataStream.readInt()));
|
||||
}
|
||||
else {
|
||||
gasTank.setGas(null);
|
||||
}
|
||||
|
||||
if(updateDelay == 0 && clientActive != isActive)
|
||||
{
|
||||
updateDelay = Mekanism.UPDATE_DELAY;
|
||||
|
@ -623,6 +636,8 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip
|
|||
sideConfig[i] = nbtTags.getByte("config"+i);
|
||||
}
|
||||
}
|
||||
|
||||
gasTank.read(nbtTags.getCompoundTag("gasTank"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -648,6 +663,8 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip
|
|||
{
|
||||
nbtTags.setByte("config"+i, sideConfig[i]);
|
||||
}
|
||||
|
||||
nbtTags.setCompoundTag("gasTank", gasTank.write(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -664,6 +681,16 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip
|
|||
data.add(progress);
|
||||
data.add(sideConfig);
|
||||
|
||||
if(gasTank.getGas() != null)
|
||||
{
|
||||
data.add(true);
|
||||
data.add(gasTank.getGas().getGas().getID());
|
||||
data.add(gasTank.getStored());
|
||||
}
|
||||
else {
|
||||
data.add(false);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
|
|
@ -175,6 +175,8 @@ fluid.sulfurTrioxideGas=Liquid Sulfur Trioxide
|
|||
fluid.sulfuricAcid=Liquid Sulfuric Acid
|
||||
fluid.hydrogenChloride=Liquid Hydrogen Chloride
|
||||
fluid.brine=Brine
|
||||
fluid.liquidOsmium=Liquid Osmium
|
||||
fluid.liquidStone=Liquid Stone
|
||||
|
||||
//Gui text
|
||||
gui.removeSpeedUpgrade=Remove speed upgrade
|
||||
|
|
BIN
resources/assets/mekanism/textures/blocks/LiquidOsmium.png
Normal file
BIN
resources/assets/mekanism/textures/blocks/LiquidOsmium.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"animation": {
|
||||
"frametime": 2
|
||||
}
|
||||
}
|
BIN
resources/assets/mekanism/textures/blocks/LiquidStone.png
Normal file
BIN
resources/assets/mekanism/textures/blocks/LiquidStone.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.6 KiB |
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"animation": {
|
||||
"frametime": 2
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue