Finished Reactor Logic Adapter

This commit is contained in:
Aidan C. Brady 2015-03-29 16:02:57 -04:00
parent 7d521ea841
commit 6ce51b0b8d
5 changed files with 93 additions and 30 deletions

View file

@ -40,9 +40,12 @@ public class GuiReactorLogicAdapter extends GuiMekanism
int xAxis = (mouseX - (width - xSize) / 2);
int yAxis = (mouseY - (height - ySize) / 2);
fontRendererObj.drawString(tileEntity.getInventoryName(), 46, 6, 0x404040);
fontRendererObj.drawString(MekanismUtils.localize("gui.coolingMeasurements") + ": " + LangUtils.transOnOff(tileEntity.activeCooled), 36, 20, 0x404040);
fontRendererObj.drawString(MekanismUtils.localize("gui.redstoneOutputMode") + ": " + EnumColor.RED + tileEntity.logicType.getLocalizedName(), 23, 123, 0x404040);
fontRendererObj.drawString(tileEntity.getInventoryName(), (xSize/2)-(fontRendererObj.getStringWidth(tileEntity.getInventoryName())/2), 6, 0x404040);
renderScaledText(MekanismUtils.localize("gui.coolingMeasurements") + ": " + EnumColor.RED + LangUtils.transOnOff(tileEntity.activeCooled), 36, 20, 0x404040, 117);
renderScaledText(MekanismUtils.localize("gui.redstoneOutputMode") + ": " + EnumColor.RED + tileEntity.logicType.getLocalizedName(), 23, 123, 0x404040, 130);
String text = MekanismUtils.localize("gui.status") + ": " + EnumColor.RED + MekanismUtils.localize("gui." + (tileEntity.checkMode() ? "outputting" : "idle"));
fontRendererObj.drawString(text, (xSize/2)-(fontRendererObj.getStringWidth(text)/2), 136, 0x404040);
for(ReactorLogic type : ReactorLogic.values())
{
@ -52,7 +55,7 @@ public class GuiReactorLogicAdapter extends GuiMekanism
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glPopMatrix();
fontRendererObj.drawString(type.getLocalizedName(), 46, 34+(22*type.ordinal()), 0x404040);
fontRendererObj.drawString(EnumColor.WHITE + type.getLocalizedName(), 46, 34+(22*type.ordinal()), 0x404040);
if(xAxis >= 24 && xAxis <= 152 && yAxis >= 32+(22*type.ordinal()) && yAxis <= 32+22+(22*type.ordinal()))
{
@ -84,17 +87,17 @@ public class GuiReactorLogicAdapter extends GuiMekanism
{
MekanismRenderer.color(EnumColor.RED);
drawTexturedModalRect(24, 32+(22*type.ordinal()), 0, 166+(type == tileEntity.logicType ? 22 : 0), 128, 22);
drawTexturedModalRect(guiWidth + 24, guiHeight + 32+(22*type.ordinal()), 0, 166+(type == tileEntity.logicType ? 22 : 0), 128, 22);
MekanismRenderer.resetColor();
}
if(xAxis >= 23 && xAxis <= 34 && yAxis >= 19 && yAxis <= 30)
{
drawTexturedModalRect(guiWidth + 23, guiHeight + 19, 176, 0, 12, 12);
drawTexturedModalRect(guiWidth + 23, guiHeight + 19, 176, 0, 11, 11);
}
else {
drawTexturedModalRect(guiWidth + 23, guiHeight + 19, 176, 12, 12, 12);
drawTexturedModalRect(guiWidth + 23, guiHeight + 19, 176, 11, 11, 11);
}
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);

View file

@ -147,7 +147,7 @@ public class MekanismGenerators implements IModule
" I ", "ILI", " I ", Character.valueOf('I'), new ItemStack(GeneratorsBlocks.ReactorGlass, 1, 0), Character.valueOf('L'), "blockRedstone"
}));
CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(GeneratorsBlocks.Reactor, 1, 4), new Object[] {
" R ", "RFR", " R ", Character.valueOf('R'), "dustRedstone", Character.valueOf('R'), new ItemStack(GeneratorsBlocks.Reactor, 1, 1)
" R ", "RFR", " R ", Character.valueOf('R'), "dustRedstone", Character.valueOf('F'), new ItemStack(GeneratorsBlocks.Reactor, 1, 1)
}));
FuelHandler.addGas(GasRegistry.getGas("ethene"), general.ETHENE_BURN_TIME, general.FROM_H2 + generators.bioGeneration * 2 * general.ETHENE_BURN_TIME); //1mB hydrogen + 2*bioFuel/tick*200ticks/100mB * 20x efficiency bonus

View file

@ -346,6 +346,19 @@ public class BlockReactor extends BlockContainer implements IBlockCTM
return super.shouldSideBeRendered(world, x, y, z, side);
}
}
@Override
public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side)
{
TileEntity tile = world.getTileEntity(x, y, z);
if(tile instanceof TileEntityReactorLogicAdapter)
{
return ((TileEntityReactorLogicAdapter)tile).checkMode() ? 15 : 0;
}
return 0;
}
public static enum ReactorBlockType
{

View file

@ -3,44 +3,71 @@ package mekanism.generators.common.tile.reactor;
import io.netty.buffer.ByteBuf;
import java.util.ArrayList;
import java.util.List;
import mekanism.common.Mekanism;
import mekanism.common.util.MekanismUtils;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import cpw.mods.fml.common.Optional.Interface;
import cpw.mods.fml.common.Optional.Method;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.api.peripheral.IPeripheral;
@Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "ComputerCraft")
public class TileEntityReactorLogicAdapter extends TileEntityReactorBlock implements IPeripheral
{
public ReactorLogic logicType = ReactorLogic.DISABLED;
public boolean activeCooled;
public boolean prevOutputting;
public TileEntityReactorLogicAdapter()
{
super();
fullName = "ReactorLogicAdapter";
}
@Override
public void onUpdate()
{
super.onUpdate();
if(!worldObj.isRemote)
{
boolean outputting = checkMode();
if(outputting != prevOutputting)
{
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockType());
}
prevOutputting = outputting;
}
}
@Override
public boolean isFrame()
{
return false;
}
public boolean checkMode(ReactorLogic type)
public boolean checkMode()
{
if(worldObj.isRemote)
{
return prevOutputting;
}
if(getReactor() == null || !getReactor().isFormed())
{
return false;
}
switch(type)
switch(logicType)
{
case DISABLED:
return false;
@ -97,6 +124,7 @@ public class TileEntityReactorLogicAdapter extends TileEntityReactorBlock implem
logicType = ReactorLogic.values()[dataStream.readInt()];
activeCooled = dataStream.readBoolean();
prevOutputting = dataStream.readBoolean();
}
@Override
@ -106,6 +134,7 @@ public class TileEntityReactorLogicAdapter extends TileEntityReactorBlock implem
data.add(logicType.ordinal());
data.add(activeCooled);
data.add(prevOutputting);
return data;
}
@ -136,31 +165,49 @@ public class TileEntityReactorLogicAdapter extends TileEntityReactorBlock implem
@Method(modid = "ComputerCraft")
public String[] getMethodNames()
{
List<String> ret = new ArrayList<String>();
for(ReactorLogic type : ReactorLogic.values())
{
if(type != ReactorLogic.DISABLED)
{
ret.add(type.name);
}
}
return (String[])ret.toArray();
return new String[] {"isIgnited", "canIgnite", "getPlasmaHeat", "getMaxPlasmaHeat", "getCaseHeat", "getMaxCaseHeat", "getInjectionRate", "setInjectionRate", "hasFuel"};
}
@Override
@Method(modid = "ComputerCraft")
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException
{
if(method >= 0 && method < ReactorLogic.values().length-1)
if(getReactor() == null || !getReactor().isFormed())
{
ReactorLogic type = ReactorLogic.values()[method+1];
return new Object[] {checkMode(type)};
return new Object[] {"Unformed."};
}
else {
return new Object[] {"Unknown command."};
switch(method)
{
case 0:
return new Object[] {getReactor().isBurning()};
case 1:
return new Object[] {getReactor().getPlasmaTemp() >= getReactor().getIgnitionTemperature(activeCooled)};
case 2:
return new Object[] {getReactor().getPlasmaTemp()};
case 3:
return new Object[] {getReactor().getMaxPlasmaTemperature(activeCooled)};
case 4:
return new Object[] {getReactor().getCaseTemp()};
case 5:
return new Object[] {getReactor().getMaxCasingTemperature(activeCooled)};
case 6:
return new Object[] {getReactor().getInjectionRate()};
case 7:
if(arguments[0] instanceof Integer)
{
getReactor().setInjectionRate((Integer)arguments[0]);
return new Object[] {"Injection rate set."};
}
else {
return new Object[] {"Invalid parameters."};
}
case 8:
return new Object[] {(getReactor().getDeuteriumTank().getStored() >= getReactor().getInjectionRate()/2) &&
(getReactor().getTritiumTank().getStored() >= getReactor().getInjectionRate()/2)};
default:
Mekanism.logger.error("Attempted to call unknown method with computer ID " + computer.getID());
return new Object[] {"Unknown command."};
}
}

View file

@ -466,8 +466,8 @@ gui.nextItem=Next Item
gui.lastItem=Last Item
gui.oreDictCompat=Compatible OreDict Key
gui.toggleCooling=Toggle Cooling Measurements
gui.coolingMeasurements=Active cooling measurements
gui.redstoneOutputMode=Redstone output mode
gui.coolingMeasurements=Active cooling
gui.redstoneOutputMode=Redstone mode
gui.reactor.injectionRate=Injection Rate