Work on Solar Neutron Activator and its recipe system

This commit is contained in:
Aidan C. Brady 2015-02-26 17:23:53 -05:00
parent 74ba02e0bb
commit 5767bfb22e
12 changed files with 373 additions and 37 deletions

View file

@ -4,7 +4,6 @@ import java.lang.reflect.Method;
import mekanism.api.gas.GasStack;
import mekanism.api.infuse.InfuseType;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
@ -282,4 +281,36 @@ public final class RecipeHelper
System.err.println("Error while adding recipe: " + e.getMessage());
}
}
/**
* Add a Solar Evaporation Plant recipe.
* @param input - input GasStack
* @param output - output GasStack
*/
public static void addSolarEvaporationRecipe(FluidStack input, FluidStack output)
{
try {
Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler");
Method m = recipeClass.getMethod("addSolarEvaporationRecipe", FluidStack.class, FluidStack.class);
m.invoke(null, input, output);
} catch(Exception e) {
System.err.println("Error while adding recipe: " + e.getMessage());
}
}
/**
* Add a Solar Neutron Activator recipe.
* @param input - input GasStack
* @param output - output GasStack
*/
public static void addSolarNeutronRecipe(GasStack input, GasStack output)
{
try {
Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler");
Method m = recipeClass.getMethod("addSolarEvaporationRecipe", GasStack.class, GasStack.class);
m.invoke(null, input, output);
} catch(Exception e) {
System.err.println("Error while adding recipe: " + e.getMessage());
}
}
}

View file

@ -51,6 +51,7 @@ import mekanism.client.gui.GuiRotaryCondensentrator;
import mekanism.client.gui.GuiSeismicReader;
import mekanism.client.gui.GuiSeismicVibrator;
import mekanism.client.gui.GuiSolarEvaporationController;
import mekanism.client.gui.GuiSolarNeutronActivator;
import mekanism.client.gui.GuiTeleporter;
import mekanism.client.gui.GuiUpgradeManagement;
import mekanism.client.render.MekanismRenderer;
@ -484,6 +485,8 @@ public class ClientProxy extends CommonProxy
case 46:
return new GuiEntangledBlock(player.inventory, (TileEntityEntangledBlock)tileEntity);
case 47:
return new GuiSolarNeutronActivator(player.inventory, (TileEntitySolarNeutronActivator)tileEntity);
case 48:
return new GuiAmbientAccumulator(player, (TileEntityAmbientAccumulator)tileEntity);
}

View file

@ -55,7 +55,7 @@ public class GuiRotaryCondensentrator extends GuiMekanism
String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.BASE_ENERGY_USAGE*tileEntity.getUpgradedUsage());
return ListUtils.asList("Using: " + multiplier + "/t", "Needed: " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy()));
}
}, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalWasher.png")));
}, this, MekanismUtils.getResource(ResourceType.GUI, "GuiRotaryCondensentrator.png")));
guiElements.add(new GuiFluidGauge(new IFluidInfoHandler() {
@Override
public FluidTank getTank()
@ -99,7 +99,6 @@ public class GuiRotaryCondensentrator extends GuiMekanism
return tileEntity.mode == 1;
}
}, ProgressBar.LARGE_LEFT, this, MekanismUtils.getResource(ResourceType.GUI, "GuiRotaryCondensentrator.png"), 62, 38));
}
@Override

View file

@ -0,0 +1,91 @@
package mekanism.client.gui;
import mekanism.api.gas.GasTank;
import mekanism.client.gui.GuiGasGauge.IGasInfoHandler;
import mekanism.client.gui.GuiProgress.IProgressInfoHandler;
import mekanism.client.gui.GuiProgress.ProgressBar;
import mekanism.client.gui.GuiSlot.SlotOverlay;
import mekanism.client.gui.GuiSlot.SlotType;
import mekanism.common.inventory.container.ContainerSolarNeutronActivator;
import mekanism.common.tile.TileEntitySolarNeutronActivator;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import net.minecraft.entity.player.InventoryPlayer;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiSolarNeutronActivator extends GuiMekanism
{
public TileEntitySolarNeutronActivator tileEntity;
public GuiSolarNeutronActivator(InventoryPlayer inventory, TileEntitySolarNeutronActivator tentity)
{
super(new ContainerSolarNeutronActivator(inventory, tentity));
tileEntity = tentity;
guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiSolarNeutronActivator.png")));
guiElements.add(new GuiUpgradeTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiSolarNeutronActivator.png")));
guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiSolarNeutronActivator.png"), 4, 24).with(SlotOverlay.PLUS));
guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiSolarNeutronActivator.png"), 4, 55).with(SlotOverlay.MINUS));
guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiSolarNeutronActivator.png"), 154, 24));
guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiSolarNeutronActivator.png"), 154, 55));
guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiSolarNeutronActivator.png"), 154, 4).with(SlotOverlay.POWER));
guiElements.add(new GuiGasGauge(new IGasInfoHandler() {
@Override
public GasTank getTank()
{
return tileEntity.inputTank;
}
}, GuiGauge.Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiSolarNeutronActivator.png"), 25, 13));
guiElements.add(new GuiGasGauge(new IGasInfoHandler() {
@Override
public GasTank getTank()
{
return tileEntity.outputTank;
}
}, GuiGauge.Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiSolarNeutronActivator.png"), 133, 13));
guiElements.add(new GuiProgress(new IProgressInfoHandler()
{
@Override
public double getProgress()
{
return tileEntity.isActive ? 1 : 0;
}
}, ProgressBar.LARGE_RIGHT, this, MekanismUtils.getResource(ResourceType.GUI, "GuiSolarNeutronActivator.png"), 62, 38));
}
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
{
int xAxis = (mouseX - (width - xSize) / 2);
int yAxis = (mouseY - (height - ySize) / 2);
fontRendererObj.drawString(tileEntity.getInventoryName(), 26, 4, 0x404040);
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
}
@Override
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY)
{
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiSolarNeutronActivator.png"));
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
int guiWidth = (width - xSize) / 2;
int guiHeight = (height - ySize) / 2;
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
int displayInt;
int xAxis = (mouseX - (width - xSize) / 2);
int yAxis = (mouseY - (height - ySize) / 2);
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
}
}

View file

@ -42,6 +42,7 @@ import mekanism.common.inventory.container.ContainerRobitSmelting;
import mekanism.common.inventory.container.ContainerRotaryCondensentrator;
import mekanism.common.inventory.container.ContainerSeismicVibrator;
import mekanism.common.inventory.container.ContainerSolarEvaporationController;
import mekanism.common.inventory.container.ContainerSolarNeutronActivator;
import mekanism.common.inventory.container.ContainerTeleporter;
import mekanism.common.inventory.container.ContainerUpgradeManagement;
import mekanism.common.tile.TileEntityAdvancedElectricMachine;
@ -427,7 +428,10 @@ public class CommonProxy
case 45:
return new ContainerLaserTractorBeam(player.inventory, (TileEntityLaserTractorBeam)tileEntity);
case 46:
return new ContainerNull(player, (TileEntityContainerBlock)tileEntity);
case 47:
return new ContainerSolarNeutronActivator(player.inventory, (TileEntitySolarNeutronActivator)tileEntity);
case 48:
return new ContainerNull(player, (TileEntityContainerBlock)tileEntity);
}

View file

@ -1064,9 +1064,9 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer
LASER(MachineBlock.MACHINE_BLOCK_2, 13, "Laser", -1, TileEntityLaser.class, true, true, false),
LASER_AMPLIFIER(MachineBlock.MACHINE_BLOCK_2, 14, "LaserAmplifier", 44, TileEntityLaserAmplifier.class, false, true, false),
LASER_TRACTOR_BEAM(MachineBlock.MACHINE_BLOCK_2, 15, "LaserTractorBeam", 45, TileEntityLaserTractorBeam.class, false, true, false),
ENTANGLED_BLOCK(MachineBlock.MACHINE_BLOCK_3, 0, "EntangledBlock", 47, TileEntityEntangledBlock.class, true, false, false),
ENTANGLED_BLOCK(MachineBlock.MACHINE_BLOCK_3, 0, "EntangledBlock", 46, TileEntityEntangledBlock.class, true, false, false),
SOLAR_NEUTRON_ACTIVATOR(MachineBlock.MACHINE_BLOCK_3, 1, "SolarNeutronActivator", -1/*48*/, TileEntitySolarNeutronActivator.class, false, true, false),
AMBIENT_ACCUMULATOR(MachineBlock.MACHINE_BLOCK_3, 2, "AmbientAccumulator", 46, TileEntityAmbientAccumulator.class, true, false, false);
AMBIENT_ACCUMULATOR(MachineBlock.MACHINE_BLOCK_3, 2, "AmbientAccumulator", 48, TileEntityAmbientAccumulator.class, true, false, false);
public MachineBlock typeBlock;
public int meta;

View file

@ -0,0 +1,8 @@
package mekanism.common.inventory.container;
import net.minecraft.inventory.Container;
public class ContainerSolarNeutronActivator extends Container
{
}

View file

@ -26,7 +26,6 @@ import mekanism.common.recipe.machines.CrusherRecipe;
import mekanism.common.recipe.machines.CrystallizerRecipe;
import mekanism.common.recipe.machines.DissolutionRecipe;
import mekanism.common.recipe.machines.EnrichmentRecipe;
import mekanism.common.recipe.machines.GasCentrifugeRecipe;
import mekanism.common.recipe.machines.InjectionRecipe;
import mekanism.common.recipe.machines.MachineRecipe;
import mekanism.common.recipe.machines.MetallurgicInfuserRecipe;
@ -38,6 +37,7 @@ import mekanism.common.recipe.machines.SawmillRecipe;
import mekanism.common.recipe.machines.SeparatorRecipe;
import mekanism.common.recipe.machines.SmeltingRecipe;
import mekanism.common.recipe.machines.SolarEvaporationRecipe;
import mekanism.common.recipe.machines.SolarNeutronRecipe;
import mekanism.common.recipe.machines.WasherRecipe;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
@ -225,21 +225,21 @@ public final class RecipeHandler
{
addRecipe(Recipe.PRESSURIZED_REACTION_CHAMBER, new PressurizedRecipe(inputSolid, inputFluid, inputGas, outputSolid, outputGas, extraEnergy, ticks));
}
public static void addAmbientGas(int dimensionID, String ambientGasName)
{
addRecipe(Recipe.AMBIENT_ACCUMULATOR, new AmbientGasRecipe(dimensionID, ambientGasName));
}
public static void addCentrifugeRecipe(GasStack inputGas, GasStack outputGas)
{
addRecipe(Recipe.GAS_CENTRIFUGE, new GasCentrifugeRecipe(inputGas, outputGas));
}
public static void addSolarEvaporationRecipe(FluidStack inputFluid, FluidStack outputFluid)
{
addRecipe(Recipe.SOLAR_EVAPORATION_PLANT, new SolarEvaporationRecipe(inputFluid, outputFluid));
}
public static void addSolarNeutronRecipe(GasStack inputGas, GasStack outputGas)
{
addRecipe(Recipe.SOLAR_NEUTRON_ACTIVATOR, new SolarNeutronRecipe(inputGas, outputGas));
}
public static void addAmbientGas(int dimensionID, String ambientGasName)
{
addRecipe(Recipe.AMBIENT_ACCUMULATOR, new AmbientGasRecipe(dimensionID, ambientGasName));
}
/**
* Gets the Metallurgic Infuser Recipe for the InfusionInput in the parameters.
@ -349,19 +349,6 @@ public final class RecipeHandler
return null;
}
public static GasCentrifugeRecipe getCentrifugeRecipe(GasInput input)
{
if(input.isValid())
{
HashMap<GasInput, GasCentrifugeRecipe> recipes = Recipe.GAS_CENTRIFUGE.get();
GasCentrifugeRecipe recipe = recipes.get(input);
return recipe == null ? null : recipe.copy();
}
return null;
}
/**
* Gets the ChanceMachineRecipe of the ItemStackInput in the parameters, using the map in the parameters.
* @param input - ItemStackInput
@ -537,8 +524,8 @@ public final class RecipeHandler
CHEMICAL_CRYSTALLIZER(new HashMap<GasInput, CrystallizerRecipe>()),
PRESSURIZED_REACTION_CHAMBER(new HashMap<PressurizedInput, PressurizedRecipe>()),
AMBIENT_ACCUMULATOR(new HashMap<IntegerInput, AmbientGasRecipe>()),
GAS_CENTRIFUGE(new HashMap<GasInput, GasCentrifugeRecipe>()),
SOLAR_EVAPORATION_PLANT(new HashMap<FluidInput, SolarEvaporationRecipe>());
SOLAR_EVAPORATION_PLANT(new HashMap<FluidInput, SolarEvaporationRecipe>()),
SOLAR_NEUTRON_ACTIVATOR(new HashMap<GasInput, SolarNeutronRecipe>());
private HashMap recipes;

View file

@ -0,0 +1,38 @@
package mekanism.common.recipe.machines;
import mekanism.api.gas.GasStack;
import mekanism.api.gas.GasTank;
import mekanism.common.recipe.inputs.GasInput;
import mekanism.common.recipe.outputs.GasOutput;
public class SolarNeutronRecipe extends MachineRecipe<GasInput, GasOutput, SolarNeutronRecipe>
{
public SolarNeutronRecipe(GasStack input, GasStack output)
{
super(new GasInput(input), new GasOutput(output));
}
public SolarNeutronRecipe(GasInput input, GasOutput output)
{
super(input, output);
}
@Override
public SolarNeutronRecipe copy()
{
return new SolarNeutronRecipe(getInput(), getOutput());
}
public boolean canOperate(GasTank inputTank, GasTank outputTank)
{
return getInput().useGas(inputTank, false, 1) && getOutput().applyOutputs(outputTank, false, 1);
}
public void operate(GasTank inputTank, GasTank outputTank)
{
if(getInput().useGas(inputTank, true, 1))
{
getOutput().applyOutputs(outputTank, true, 1);
}
}
}

View file

@ -51,12 +51,12 @@ public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock imp
public static final int MAX_FLUID = 10000;
public int updateDelay;
/** 0: gas -> fluid; 1: fluid -> gas */
public int mode;
public int gasOutput = 256;
public int updateDelay;
public boolean isActive;

View file

@ -1,18 +1,46 @@
package mekanism.common.tile;
import io.netty.buffer.ByteBuf;
import java.util.ArrayList;
import mekanism.api.Coord4D;
import mekanism.api.Range4D;
import mekanism.api.gas.Gas;
import mekanism.api.gas.GasRegistry;
import mekanism.api.gas.GasStack;
import mekanism.api.gas.GasTank;
import mekanism.api.gas.IGasHandler;
import mekanism.api.gas.ITubeConnection;
import mekanism.common.Mekanism;
import mekanism.common.base.IActiveState;
import mekanism.common.base.IBoundingBlock;
import mekanism.common.base.IRedstoneControl;
import mekanism.common.base.ISustainedData;
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
import mekanism.common.util.MekanismUtils;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock implements IBoundingBlock, IGasHandler, ITubeConnection, ISustainedData
public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock implements IRedstoneControl, IBoundingBlock, IGasHandler, ITubeConnection, IActiveState, ISustainedData
{
public GasTank inputTank = new GasTank(MAX_GAS);
public GasTank outputTank = new GasTank(MAX_GAS);
public static final int MAX_GAS = 10000;
public int updateDelay;
public boolean isActive;
public boolean clientActive;
public int gasOutput = 256;
/** This machine's current RedstoneControl type. */
public RedstoneControl controlType = RedstoneControl.DISABLED;
public TileEntitySolarNeutronActivator()
{
super("SolarNeutronActivator");
@ -23,6 +51,90 @@ public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock im
{
}
@Override
public void handlePacketData(ByteBuf dataStream)
{
super.handlePacketData(dataStream);
controlType = RedstoneControl.values()[dataStream.readInt()];
if(dataStream.readBoolean())
{
inputTank.setGas(new GasStack(GasRegistry.getGas(dataStream.readInt()), dataStream.readInt()));
}
else {
inputTank.setGas(null);
}
if(dataStream.readBoolean())
{
outputTank.setGas(new GasStack(GasRegistry.getGas(dataStream.readInt()), dataStream.readInt()));
}
else {
outputTank.setGas(null);
}
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
}
@Override
public ArrayList getNetworkedData(ArrayList data)
{
super.getNetworkedData(data);
data.add(controlType.ordinal());
if(inputTank.getGas() != null)
{
data.add(true);
data.add(inputTank.getGas().getGas().getID());
data.add(inputTank.getStored());
}
else {
data.add(false);
}
if(outputTank.getGas() != null)
{
data.add(true);
data.add(outputTank.getGas().getGas().getID());
data.add(outputTank.getStored());
}
else {
data.add(false);
}
return data;
}
@Override
public void readFromNBT(NBTTagCompound nbtTags)
{
super.readFromNBT(nbtTags);
controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")];
inputTank.read(nbtTags.getCompoundTag("inputTank"));
outputTank.read(nbtTags.getCompoundTag("outputTank"));
}
@Override
public void writeToNBT(NBTTagCompound nbtTags)
{
super.writeToNBT(nbtTags);
nbtTags.setInteger("controlType", controlType.ordinal());
nbtTags.setTag("inputTank", inputTank.write(new NBTTagCompound()));
nbtTags.setTag("outputTank", outputTank.write(new NBTTagCompound()));
}
@Override
public boolean canSetFacing(int i)
{
return i != 0 && i != 1;
}
@Override
public void onPlace()
@ -68,14 +180,74 @@ public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock im
}
@Override
public void writeSustainedData(ItemStack itemStack)
public void writeSustainedData(ItemStack itemStack)
{
if(inputTank.getGas() != null)
{
itemStack.stackTagCompound.setTag("inputTank", inputTank.getGas().write(new NBTTagCompound()));
}
if(outputTank.getGas() != null)
{
itemStack.stackTagCompound.setTag("outputTank", outputTank.getGas().write(new NBTTagCompound()));
}
}
@Override
public void readSustainedData(ItemStack itemStack)
{
inputTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("inputTank")));
outputTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("outputTank")));
}
@Override
public void readSustainedData(ItemStack itemStack)
public RedstoneControl getControlType()
{
return controlType;
}
@Override
public void setControlType(RedstoneControl type)
{
controlType = type;
MekanismUtils.saveChunk(this);
}
@Override
public boolean canPulse()
{
return false;
}
@Override
public boolean getActive()
{
return isActive;
}
@Override
public void setActive(boolean active)
{
isActive = active;
if(clientActive != active && updateDelay == 0)
{
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this)));
updateDelay = 10;
clientActive = active;
}
}
@Override
public boolean renderUpdate()
{
return false;
}
@Override
public boolean lightUpdate()
{
return true;
}
}

View file

@ -121,6 +121,9 @@ tile.MachineBlock2.Laser.name=Laser
tile.MachineBlock2.LaserAmplifier.name=Laser Amplifier
tile.MachineBlock2.LaserTractorBeam.name=Laser Tractor Beam
//Machine Block 3 (third ID iteration)
tile.MachineBlock3.SolarNeutronActivator.name=Solar Neutron Activator
//Plastic
tile.PlasticBlock.name=Plastic Block
tile.SlickPlasticBlock.name=Slick Plastic Block