Logic adapter work

This commit is contained in:
Aidan C. Brady 2015-03-29 15:23:13 -04:00
parent 0f54c21cf2
commit 7d521ea841
4 changed files with 127 additions and 8 deletions

View file

@ -1,10 +1,20 @@
package mekanism.generators.client.gui;
import java.util.ArrayList;
import mekanism.api.Coord4D;
import mekanism.api.EnumColor;
import mekanism.client.gui.GuiMekanism;
import mekanism.client.render.MekanismRenderer;
import mekanism.client.sound.SoundHandler;
import mekanism.common.Mekanism;
import mekanism.common.inventory.container.ContainerNull;
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
import mekanism.common.util.LangUtils;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import mekanism.generators.common.tile.reactor.TileEntityReactorLogicAdapter;
import mekanism.generators.common.tile.reactor.TileEntityReactorLogicAdapter.ReactorLogic;
import net.minecraft.entity.player.InventoryPlayer;
import org.lwjgl.opengl.GL11;
@ -27,7 +37,33 @@ public class GuiReactorLogicAdapter extends GuiMekanism
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
{
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);
for(ReactorLogic type : ReactorLogic.values())
{
GL11.glPushMatrix();
GL11.glEnable(GL11.GL_LIGHTING);
itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), type.getRenderStack(), 27, 35 + (22*type.ordinal()));
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glPopMatrix();
fontRendererObj.drawString(type.getLocalizedName(), 46, 34+(22*type.ordinal()), 0x404040);
if(xAxis >= 24 && xAxis <= 152 && yAxis >= 32+(22*type.ordinal()) && yAxis <= 32+22+(22*type.ordinal()))
{
drawCreativeTabHoveringText(type.getDescription(), xAxis, yAxis);
}
}
if(xAxis >= 23 && xAxis <= 34 && yAxis >= 19 && yAxis <= 30)
{
drawCreativeTabHoveringText(MekanismUtils.localize("gui.toggleCooling"), xAxis, yAxis);
}
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
}
@ -41,6 +77,69 @@ public class GuiReactorLogicAdapter extends GuiMekanism
int guiHeight = (height - ySize) / 2;
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
int xAxis = (mouseX - (width - xSize) / 2);
int yAxis = (mouseY - (height - ySize) / 2);
for(ReactorLogic type : ReactorLogic.values())
{
MekanismRenderer.color(EnumColor.RED);
drawTexturedModalRect(24, 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);
}
else {
drawTexturedModalRect(guiWidth + 23, guiHeight + 19, 176, 12, 12, 12);
}
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
}
@Override
protected void mouseClicked(int mouseX, int mouseY, int button)
{
super.mouseClicked(mouseX, mouseY, button);
if(button == 0)
{
int xAxis = (mouseX - (width - xSize) / 2);
int yAxis = (mouseY - (height - ySize) / 2);
if(xAxis >= 23 && xAxis <= 34 && yAxis >= 19 && yAxis <= 30)
{
SoundHandler.playSound("gui.button.press");
ArrayList data = new ArrayList();
data.add(0);
Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data));
return;
}
for(ReactorLogic type : ReactorLogic.values())
{
if(xAxis >= 24 && xAxis <= 152 && yAxis >= 32+(22*type.ordinal()) && yAxis <= 32+22+(22*type.ordinal()))
{
if(type != tileEntity.logicType)
{
SoundHandler.playSound("gui.button.press");
ArrayList data = new ArrayList();
data.add(1);
data.add(type.ordinal());
Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data));
return;
}
}
}
}
}
}

View file

@ -213,9 +213,17 @@ public class BlockReactor extends BlockContainer implements IBlockCTM
if(!entityplayer.isSneaking())
{
entityplayer.openGui(MekanismGenerators.instance, ReactorBlockType.get(this, metadata).guiId, world, x, y, z);
return true;
}
}
return true;
if(tileEntity instanceof TileEntityReactorLogicAdapter)
{
if(!entityplayer.isSneaking())
{
entityplayer.openGui(MekanismGenerators.instance, ReactorBlockType.get(this, metadata).guiId, world, x, y, z);
return true;
}
}
return false;

View file

@ -6,6 +6,8 @@ import java.util.ArrayList;
import java.util.List;
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.Method;
import dan200.computercraft.api.lua.ILuaContext;
@ -15,7 +17,7 @@ import dan200.computercraft.api.peripheral.IPeripheral;
public class TileEntityReactorLogicAdapter extends TileEntityReactorBlock implements IPeripheral
{
public ReactorLogic logicType;
public ReactorLogic logicType = ReactorLogic.DISABLED;
public boolean activeCooled;
@ -164,16 +166,23 @@ public class TileEntityReactorLogicAdapter extends TileEntityReactorBlock implem
public static enum ReactorLogic
{
DISABLED("disabled"),
READY("ready"),
CAPACITY("capacity"),
DEPLETED("depleted");
DISABLED("disabled", new ItemStack(Items.gunpowder)),
READY("ready", new ItemStack(Items.redstone)),
CAPACITY("capacity", new ItemStack(Items.redstone)),
DEPLETED("depleted", new ItemStack(Items.redstone));
private String name;
private ItemStack renderStack;
private ReactorLogic(String s)
private ReactorLogic(String s, ItemStack stack)
{
name = s;
renderStack = stack;
}
public ItemStack getRenderStack()
{
return renderStack;
}
public String getLocalizedName()

View file

@ -465,6 +465,9 @@ gui.abundancy=Abundancy
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.reactor.injectionRate=Injection Rate