Configurable machine output colors
This commit is contained in:
parent
799142198a
commit
289a2ee227
|
@ -4,6 +4,10 @@ public interface IEjector
|
|||
{
|
||||
public void onOutput();
|
||||
|
||||
public EnumColor getColor();
|
||||
|
||||
public void setColor(EnumColor color);
|
||||
|
||||
public boolean isEjecting();
|
||||
|
||||
public void setEjecting(boolean eject);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package mekanism.client.gui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -7,11 +8,13 @@ import mekanism.api.EnumColor;
|
|||
import mekanism.api.IConfigurable;
|
||||
import mekanism.api.Object3D;
|
||||
import mekanism.api.SideData;
|
||||
import mekanism.client.render.MekanismRenderer;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.PacketHandler.Transmission;
|
||||
import mekanism.common.block.BlockMachine.MachineType;
|
||||
import mekanism.common.inventory.container.ContainerNull;
|
||||
import mekanism.common.network.PacketConfigurationUpdate;
|
||||
import mekanism.common.network.PacketTileEntity;
|
||||
import mekanism.common.network.PacketConfigurationUpdate.ConfigurationPacket;
|
||||
import mekanism.common.network.PacketSimpleGui;
|
||||
import mekanism.common.tileentity.TileEntityContainerBlock;
|
||||
|
@ -21,6 +24,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import universalelectricity.core.electricity.ElectricityDisplay;
|
||||
import universalelectricity.core.electricity.ElectricityDisplay.ElectricUnit;
|
||||
|
@ -39,12 +43,12 @@ public class GuiConfiguration extends GuiMekanism
|
|||
|
||||
configurable = tile;
|
||||
|
||||
positions.put(0, new GuiPos(81, 63));
|
||||
positions.put(1, new GuiPos(81, 33));
|
||||
positions.put(2, new GuiPos(81, 48));
|
||||
positions.put(3, new GuiPos(66, 63));
|
||||
positions.put(4, new GuiPos(66, 48));
|
||||
positions.put(5, new GuiPos(96, 48));
|
||||
positions.put(0, new GuiPos(110, 63));
|
||||
positions.put(1, new GuiPos(110, 33));
|
||||
positions.put(2, new GuiPos(110, 48));
|
||||
positions.put(3, new GuiPos(95, 63));
|
||||
positions.put(4, new GuiPos(95, 48));
|
||||
positions.put(5, new GuiPos(125, 48));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -116,6 +120,22 @@ public class GuiConfiguration extends GuiMekanism
|
|||
fontRenderer.drawString("Configuration", 60, 5, 0x404040);
|
||||
fontRenderer.drawString("Eject: " + ejecting, 53, 17, 0x00CD00);
|
||||
|
||||
fontRenderer.drawString("Color:", 38, 37, 0x404040);
|
||||
|
||||
if(configurable.getEjector().getColor() != null)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glColor4f(1, 1, 1, 1);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
|
||||
mc.getTextureManager().bindTexture(MekanismRenderer.getColorResource(configurable.getEjector().getColor()));
|
||||
itemRenderer.renderIcon(44, 48, MekanismRenderer.getColorIcon(configurable.getEjector().getColor()), 16, 16);
|
||||
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
for(int i = 0; i < positions.size(); i++)
|
||||
{
|
||||
int x = positions.get(i).xPos;
|
||||
|
@ -128,6 +148,17 @@ public class GuiConfiguration extends GuiMekanism
|
|||
drawCreativeTabHoveringText(data.color != null ? data.color.getName() : "None", xAxis, yAxis);
|
||||
}
|
||||
}
|
||||
|
||||
if(xAxis >= 44 && xAxis <= 60 && yAxis >= 48 && yAxis <= 64)
|
||||
{
|
||||
if(configurable.getEjector().getColor() != null)
|
||||
{
|
||||
drawCreativeTabHoveringText(configurable.getEjector().getColor().getName(), xAxis, yAxis);
|
||||
}
|
||||
else {
|
||||
drawCreativeTabHoveringText("None", xAxis, yAxis);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -167,6 +198,12 @@ public class GuiConfiguration extends GuiMekanism
|
|||
PacketHandler.sendPacket(Transmission.SERVER, new PacketConfigurationUpdate().setParams(ConfigurationPacket.EJECT, Object3D.get(tile)));
|
||||
}
|
||||
|
||||
if(xAxis >= 44 && xAxis <= 60 && yAxis >= 48 && yAxis <= 64)
|
||||
{
|
||||
mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
|
||||
PacketHandler.sendPacket(Transmission.SERVER, new PacketConfigurationUpdate().setParams(ConfigurationPacket.EJECT_COLOR, Object3D.get((TileEntity)configurable)));
|
||||
}
|
||||
|
||||
for(int i = 0; i < positions.size(); i++)
|
||||
{
|
||||
int x = positions.get(i).xPos;
|
||||
|
|
|
@ -3,6 +3,7 @@ package mekanism.common;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.IConfigurable;
|
||||
import mekanism.api.IEjector;
|
||||
import mekanism.api.Object3D;
|
||||
|
@ -25,6 +26,8 @@ public class TileComponentEjector implements ITileComponent, IEjector
|
|||
|
||||
public boolean ejecting;
|
||||
|
||||
public EnumColor ejectColor;
|
||||
|
||||
public SideData sideData;
|
||||
|
||||
public int[] trackers;
|
||||
|
@ -99,7 +102,7 @@ public class TileComponentEjector implements ITileComponent, IEjector
|
|||
}
|
||||
else if(tile instanceof TileEntityLogisticalTransporter)
|
||||
{
|
||||
if(TransporterUtils.insert(tileEntity, (TileEntityLogisticalTransporter)tile, stack, null))
|
||||
if(TransporterUtils.insert(tileEntity, (TileEntityLogisticalTransporter)tile, stack, ejectColor))
|
||||
{
|
||||
stack = null;
|
||||
}
|
||||
|
@ -131,6 +134,18 @@ public class TileComponentEjector implements ITileComponent, IEjector
|
|||
{
|
||||
ejecting = eject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColor(EnumColor color)
|
||||
{
|
||||
ejectColor = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumColor getColor()
|
||||
{
|
||||
return ejectColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {}
|
||||
|
@ -140,6 +155,11 @@ public class TileComponentEjector implements ITileComponent, IEjector
|
|||
{
|
||||
ejecting = nbtTags.getBoolean("ejecting");
|
||||
|
||||
if(nbtTags.hasKey("ejectColor"))
|
||||
{
|
||||
ejectColor = TransporterUtils.colors.get(nbtTags.getInteger("ejectColor"));
|
||||
}
|
||||
|
||||
for(int i = 0; i < sideData.availableSlots.length; i++)
|
||||
{
|
||||
trackers[i] = nbtTags.getInteger("tracker" + i);
|
||||
|
@ -150,12 +170,23 @@ public class TileComponentEjector implements ITileComponent, IEjector
|
|||
public void read(ByteArrayDataInput dataStream)
|
||||
{
|
||||
ejecting = dataStream.readBoolean();
|
||||
|
||||
int c = dataStream.readInt();
|
||||
|
||||
if(c != -1)
|
||||
{
|
||||
ejectColor = TransporterUtils.colors.get(c);
|
||||
}
|
||||
else {
|
||||
ejectColor = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(NBTTagCompound nbtTags)
|
||||
{
|
||||
nbtTags.setBoolean("ejecting", ejecting);
|
||||
nbtTags.setInteger("ejectColor", TransporterUtils.colors.indexOf(ejectColor));
|
||||
|
||||
for(int i = 0; i < sideData.availableSlots.length; i++)
|
||||
{
|
||||
|
@ -167,5 +198,13 @@ public class TileComponentEjector implements ITileComponent, IEjector
|
|||
public void write(ArrayList data)
|
||||
{
|
||||
data.add(ejecting);
|
||||
|
||||
if(ejectColor != null)
|
||||
{
|
||||
data.add(TransporterUtils.colors.indexOf(ejectColor));
|
||||
}
|
||||
else {
|
||||
data.add(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import mekanism.common.ITileNetwork;
|
|||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.PacketHandler.Transmission;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.TransporterUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -59,7 +60,6 @@ public class PacketConfigurationUpdate implements IMekanismPacket
|
|||
{
|
||||
IConfigurable config = (IConfigurable)tile;
|
||||
config.getEjector().setEjecting(!config.getEjector().isEjecting());
|
||||
PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketTileEntity().setParams(object3D, ((ITileNetwork)tile).getNetworkedData(new ArrayList())), object3D, 50D);
|
||||
}
|
||||
}
|
||||
else if(packetType == ConfigurationPacket.SIDE_DATA)
|
||||
|
@ -74,6 +74,16 @@ public class PacketConfigurationUpdate implements IMekanismPacket
|
|||
PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketTileEntity().setParams(object3D, ((ITileNetwork)tile).getNetworkedData(new ArrayList())), object3D, 50D);
|
||||
}
|
||||
}
|
||||
else if(packetType == ConfigurationPacket.EJECT_COLOR)
|
||||
{
|
||||
TileEntity tile = object3D.getTileEntity(world);
|
||||
|
||||
if(tile instanceof IConfigurable)
|
||||
{
|
||||
IConfigurable config = (IConfigurable)tile;
|
||||
config.getEjector().setColor(TransporterUtils.increment(config.getEjector().getColor()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -95,6 +105,6 @@ public class PacketConfigurationUpdate implements IMekanismPacket
|
|||
|
||||
public static enum ConfigurationPacket
|
||||
{
|
||||
EJECT, SIDE_DATA
|
||||
EJECT, SIDE_DATA, EJECT_COLOR
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 4.7 KiB |
Binary file not shown.
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
Loading…
Reference in a new issue