Added a GUI for editing panel components
Currently only available for buttons
This commit is contained in:
parent
8cabaa9844
commit
1d83fa7579
|
@ -20,29 +20,49 @@ package malte0811.industrialWires;
|
|||
import malte0811.industrialWires.blocks.TileEntityJacobsLadder;
|
||||
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanelCreator;
|
||||
import malte0811.industrialWires.blocks.controlpanel.TileEntityRSPanelConn;
|
||||
import malte0811.industrialWires.containers.ContainerPanelComponent;
|
||||
import malte0811.industrialWires.containers.ContainerPanelCreator;
|
||||
import malte0811.industrialWires.containers.ContainerRSPanelConn;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.network.IGuiHandler;
|
||||
|
||||
public class CommonProxy implements IGuiHandler {
|
||||
public void preInit() {}
|
||||
public void postInit() {}
|
||||
public World getClientWorld() {return null;}
|
||||
public void playJacobsLadderSound(TileEntityJacobsLadder te, int phase, Vec3d soundPos) {}
|
||||
public void preInit() {
|
||||
}
|
||||
|
||||
public void postInit() {
|
||||
}
|
||||
|
||||
public World getClientWorld() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void playJacobsLadderSound(TileEntityJacobsLadder te, int phase, Vec3d soundPos) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
TileEntity te = world.getTileEntity(new BlockPos(x, y, z));
|
||||
if (te instanceof TileEntityPanelCreator) {
|
||||
return new ContainerPanelCreator(player.inventory, (TileEntityPanelCreator)te);
|
||||
}
|
||||
if (te instanceof TileEntityRSPanelConn) {
|
||||
return new ContainerRSPanelConn((TileEntityRSPanelConn)te);
|
||||
public Container getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
if (ID == 0) {//TILE GUI
|
||||
TileEntity te = world.getTileEntity(new BlockPos(x, y, z));
|
||||
if (te instanceof TileEntityPanelCreator) {
|
||||
return new ContainerPanelCreator(player.inventory, (TileEntityPanelCreator) te);
|
||||
}
|
||||
if (te instanceof TileEntityRSPanelConn) {
|
||||
return new ContainerRSPanelConn((TileEntityRSPanelConn) te);
|
||||
}
|
||||
} else if (ID == 1) {//ITEM GUI
|
||||
EnumHand h = z == 1 ? EnumHand.MAIN_HAND : EnumHand.OFF_HAND;
|
||||
ItemStack held = player.getHeldItem(h);
|
||||
if (held != null && held.getItem() == IndustrialWires.panelComponent) {
|
||||
return new ContainerPanelComponent(h);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ import malte0811.industrialWires.blocks.wire.*;
|
|||
import malte0811.industrialWires.crafting.RecipeCoilLength;
|
||||
import malte0811.industrialWires.items.ItemIC2Coil;
|
||||
import malte0811.industrialWires.items.ItemPanelComponent;
|
||||
import malte0811.industrialWires.network.MessageComponentSync;
|
||||
import malte0811.industrialWires.network.MessageGUIInteract;
|
||||
import malte0811.industrialWires.network.MessagePanelInteract;
|
||||
import malte0811.industrialWires.network.MessageTileSyncIW;
|
||||
|
@ -173,6 +174,7 @@ public class IndustrialWires {
|
|||
packetHandler.registerMessage(MessageTileSyncIW.HandlerClient.class, MessageTileSyncIW.class, 0, Side.CLIENT);
|
||||
packetHandler.registerMessage(MessagePanelInteract.HandlerServer.class, MessagePanelInteract.class, 1, Side.SERVER);
|
||||
packetHandler.registerMessage(MessageGUIInteract.HandlerServer.class, MessageGUIInteract.class, 2, Side.SERVER);
|
||||
packetHandler.registerMessage(MessageComponentSync.HandlerServer.class, MessageComponentSync.class, 3, Side.SERVER);
|
||||
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(instance, proxy);
|
||||
}
|
||||
|
|
|
@ -175,7 +175,7 @@ public class BlockPanel extends BlockIWBase implements IMetaEnum {
|
|||
}
|
||||
if (te instanceof TileEntityPanelCreator) {
|
||||
if (!world.isRemote) {
|
||||
player.openGui(IndustrialWires.instance, 1, te.getWorld(), te.getPos().getX(), te.getPos().getY(), te.getPos().getZ());
|
||||
player.openGui(IndustrialWires.instance, 0, te.getWorld(), te.getPos().getX(), te.getPos().getY(), te.getPos().getZ());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -300,6 +300,9 @@ public class TileEntityPanel extends TileEntityIWBase implements IDirectionalTil
|
|||
@Override
|
||||
public void onChunkUnload() {
|
||||
super.onChunkUnload();
|
||||
for (PanelComponent pc:components) {
|
||||
pc.invalidate(this);
|
||||
}
|
||||
for (TileEntityRSPanelConn rs : rsPorts) {
|
||||
rs.unregisterPanel(this, true);
|
||||
}
|
||||
|
@ -308,6 +311,9 @@ public class TileEntityPanel extends TileEntityIWBase implements IDirectionalTil
|
|||
@Override
|
||||
public void invalidate() {
|
||||
super.invalidate();
|
||||
for (PanelComponent pc:components) {
|
||||
pc.invalidate(this);
|
||||
}
|
||||
for (TileEntityRSPanelConn rs : rsPorts) {
|
||||
rs.unregisterPanel(this, true);
|
||||
}
|
||||
|
|
|
@ -136,6 +136,7 @@ public class TileEntityPanelCreator extends TileEntityIWBase implements IIEInven
|
|||
ItemStack panel = new ItemStack(IndustrialWires.panel, 1, BlockTypes_Panel.TOP.ordinal());
|
||||
panel.setTagCompound(panelNBT);
|
||||
inv[0] = panel;
|
||||
components.clear();
|
||||
}
|
||||
break;
|
||||
case REMOVE_ALL:
|
||||
|
|
|
@ -33,6 +33,7 @@ import malte0811.industrialWires.blocks.IMetaEnum;
|
|||
import malte0811.industrialWires.blocks.TileEntityJacobsLadder;
|
||||
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanelCreator;
|
||||
import malte0811.industrialWires.blocks.controlpanel.TileEntityRSPanelConn;
|
||||
import malte0811.industrialWires.client.gui.GuiPanelComponent;
|
||||
import malte0811.industrialWires.client.gui.GuiPanelCreator;
|
||||
import malte0811.industrialWires.client.gui.GuiRSPanelConn;
|
||||
import malte0811.industrialWires.client.panelmodel.PanelModelLoader;
|
||||
|
@ -49,6 +50,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
@ -223,13 +225,21 @@ public class ClientProxy extends CommonProxy {
|
|||
|
||||
@Override
|
||||
public Gui getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
TileEntity te = world.getTileEntity(new BlockPos(x, y, z));
|
||||
if (te instanceof TileEntityRSPanelConn) {
|
||||
return new GuiRSPanelConn((TileEntityRSPanelConn)te);
|
||||
}
|
||||
if (te instanceof TileEntityPanelCreator) {
|
||||
return new GuiPanelCreator(player.inventory, (TileEntityPanelCreator) te);
|
||||
if (ID==0) {
|
||||
TileEntity te = world.getTileEntity(new BlockPos(x, y, z));
|
||||
if (te instanceof TileEntityRSPanelConn) {
|
||||
return new GuiRSPanelConn((TileEntityRSPanelConn) te);
|
||||
}
|
||||
if (te instanceof TileEntityPanelCreator) {
|
||||
return new GuiPanelCreator(player.inventory, (TileEntityPanelCreator) te);
|
||||
}
|
||||
} else if (ID==1) {
|
||||
EnumHand h = z == 1 ? EnumHand.MAIN_HAND : EnumHand.OFF_HAND;
|
||||
ItemStack held = player.getHeldItem(h);
|
||||
if (held != null && held.getItem() == IndustrialWires.panelComponent) {
|
||||
return new GuiPanelComponent(h, IndustrialWires.panelComponent.componentFromStack(held));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,291 @@
|
|||
package malte0811.industrialWires.client.gui;
|
||||
|
||||
import blusunrize.immersiveengineering.client.ClientUtils;
|
||||
import blusunrize.immersiveengineering.client.gui.elements.GuiButtonCheckbox;
|
||||
import blusunrize.immersiveengineering.client.gui.elements.GuiSliderIE;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.client.gui.elements.GuiChannelPicker;
|
||||
import malte0811.industrialWires.client.gui.elements.GuiIntChooser;
|
||||
import malte0811.industrialWires.containers.ContainerPanelComponent;
|
||||
import malte0811.industrialWires.controlpanel.PanelComponent;
|
||||
import malte0811.industrialWires.controlpanel.properties.IConfigurableComponent;
|
||||
import malte0811.industrialWires.network.MessageComponentSync;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GuiPanelComponent extends GuiContainer {
|
||||
private PanelComponent component;
|
||||
private IConfigurableComponent confComp;
|
||||
private ContainerPanelComponent container;
|
||||
private List<GuiButtonCheckbox> boolButtons = new ArrayList<>();
|
||||
private List<GuiTextField> stringTexts = new ArrayList<>();
|
||||
private List<GuiChannelPicker> rsChannelChoosers = new ArrayList<>();
|
||||
private List<GuiIntChooser> intChoosers = new ArrayList<>();
|
||||
private List<GuiSliderIE> floatSliders = new ArrayList<>();
|
||||
|
||||
//TODO int, float
|
||||
public GuiPanelComponent(EnumHand h, PanelComponent pc) {
|
||||
super(new ContainerPanelComponent(h));
|
||||
container = (ContainerPanelComponent) inventorySlots;
|
||||
component = pc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
Keyboard.enableRepeatEvents(true);
|
||||
if (component instanceof IConfigurableComponent) {
|
||||
confComp = (IConfigurableComponent) component;
|
||||
IConfigurableComponent.BoolConfig[] bools = confComp.getBooleanOptions();
|
||||
boolButtons.clear();
|
||||
for (int i = 0;i<bools.length;i++) {
|
||||
IConfigurableComponent.BoolConfig bc = bools[i];
|
||||
//TODO check whether ID==0 is a bad thing when using custom button lists
|
||||
boolButtons.add(new GuiButtonCheckbox(0, guiLeft + bc.x, guiTop + bc.y, confComp.fomatConfigName(IConfigurableComponent.ConfigType.BOOL, i), bc.value));
|
||||
}
|
||||
IConfigurableComponent.StringConfig[] strings = confComp.getStringOptions();
|
||||
stringTexts.clear();
|
||||
for (IConfigurableComponent.StringConfig sc : strings) {
|
||||
stringTexts.add(new GuiTextField(0, mc.fontRendererObj, guiLeft + sc.x, guiTop + sc.y, 58, 12));
|
||||
}
|
||||
IConfigurableComponent.RSChannelConfig[] rs = confComp.getRSChannelOptions();
|
||||
rsChannelChoosers.clear();
|
||||
for (IConfigurableComponent.RSChannelConfig rc : rs) {
|
||||
rsChannelChoosers.add(new GuiChannelPicker(0, guiLeft + rc.x, guiTop + rc.y, 40, rc.value));
|
||||
}
|
||||
intChoosers.clear();
|
||||
IConfigurableComponent.IntConfig[] is = confComp.getIntegerOptions();
|
||||
for (IConfigurableComponent.IntConfig ic : is) {
|
||||
intChoosers.add(new GuiIntChooser(guiLeft+ic.x, guiTop+ic.y, ic.allowNegative, ic.value, ic.digits));
|
||||
}
|
||||
floatSliders.clear();
|
||||
IConfigurableComponent.FloatConfig[] fs = confComp.getFloatOptions();
|
||||
for (int i = 0;i<fs.length;i++) {
|
||||
IConfigurableComponent.FloatConfig fc = fs[i];
|
||||
floatSliders.add(new GuiSliderIE(0, guiLeft+fc.x, guiTop+fc.y, fc.width,
|
||||
confComp.fomatConfigName(IConfigurableComponent.ConfigType.FLOAT, i), fc.value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
|
||||
//TODO background
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
super.onGuiClosed();
|
||||
Keyboard.enableRepeatEvents(false);
|
||||
syncAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char typedChar, int keyCode) throws IOException {
|
||||
boolean superCall = true;
|
||||
for (int i = 0;i<stringTexts.size();i++) {
|
||||
GuiTextField field = stringTexts.get(i);
|
||||
if (field.isFocused() && keyCode == 28) {
|
||||
sync(i, field.getText());
|
||||
superCall = false;
|
||||
} else if (field.textboxKeyTyped(typedChar, keyCode)) {
|
||||
superCall = false;
|
||||
}
|
||||
}
|
||||
if (superCall) {
|
||||
super.keyTyped(typedChar, keyCode);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
for (int i = 0;i<stringTexts.size();i++) {
|
||||
GuiTextField field = stringTexts.get(i);
|
||||
boolean focus = field.isFocused();
|
||||
field.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
if (focus&&!field.isFocused()) {
|
||||
sync(i, field.getText());
|
||||
}
|
||||
}
|
||||
for (int i = 0;i<rsChannelChoosers.size();i++) {
|
||||
GuiChannelPicker picker = rsChannelChoosers.get(i);
|
||||
int mXRel = mouseX-picker.xPosition;
|
||||
int mYRel = mouseY-picker.yPosition;
|
||||
if (mXRel>=0&&mXRel<picker.width&&mYRel>=0&&mYRel<picker.height) {
|
||||
int old = picker.getSelected();
|
||||
picker.select();
|
||||
if (old != picker.getSelected()) {
|
||||
sync(i, picker.getSelected());
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0;i<boolButtons.size();i++) {
|
||||
GuiButtonCheckbox box = boolButtons.get(i);
|
||||
boolean on = box.state;
|
||||
box.mousePressed(mc, mouseX, mouseY);
|
||||
if (on!=box.state) {
|
||||
sync(i, box.state);
|
||||
}
|
||||
}
|
||||
for (int i = 0;i<intChoosers.size();i++) {
|
||||
GuiIntChooser chooser = intChoosers.get(i);
|
||||
int oldV = chooser.getValue();
|
||||
chooser.click(mouseX, mouseY);
|
||||
if (oldV!=chooser.getValue()) {
|
||||
sync(i, chooser.getValue());
|
||||
}
|
||||
}
|
||||
for (int i = 0;i<floatSliders.size();i++) {
|
||||
GuiSliderIE slider = floatSliders.get(i);
|
||||
double oldV = slider.getValue();
|
||||
slider.mousePressed(mc, mouseX, mouseY);
|
||||
slider.mouseReleased(mouseX, mouseY);
|
||||
if (oldV!=slider.getValue()) {
|
||||
sync(i, (float) slider.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
GlStateManager.color(1, 1, 1, 1);
|
||||
for (int i = 0;i<rsChannelChoosers.size();i++) {
|
||||
GuiChannelPicker pick = rsChannelChoosers.get(i);
|
||||
pick.drawButton(mc, mouseX, mouseY);
|
||||
String tooltip = confComp.fomatConfigDescription(IConfigurableComponent.ConfigType.RS_CHANNEL, i);
|
||||
if (tooltip!=null&&pick.isHovered()) {
|
||||
ClientUtils.drawHoveringText(ImmutableList.of(tooltip), mouseX, mouseY, mc.fontRendererObj);
|
||||
}
|
||||
}
|
||||
for (int i = 0;i<boolButtons.size();i++) {
|
||||
GuiButtonCheckbox box = boolButtons.get(i);
|
||||
box.drawButton(mc, mouseX, mouseY);
|
||||
String tooltip = confComp.fomatConfigDescription(IConfigurableComponent.ConfigType.BOOL, i);
|
||||
if (tooltip!=null&&box.isMouseOver()) {
|
||||
ClientUtils.drawHoveringText(ImmutableList.of(tooltip), mouseX, mouseY, mc.fontRendererObj);
|
||||
}
|
||||
}
|
||||
for (int i = 0;i<stringTexts.size();i++) {
|
||||
GuiTextField field = stringTexts.get(i);
|
||||
field.drawTextBox();
|
||||
String tooltip = confComp.fomatConfigDescription(IConfigurableComponent.ConfigType.STRING, i);
|
||||
if (tooltip!=null&&mouseX>=field.xPosition&&mouseX<field.xPosition+field.width&&
|
||||
mouseY>=field.yPosition&&mouseY<field.yPosition+field.height) {
|
||||
ClientUtils.drawHoveringText(ImmutableList.of(tooltip), mouseX, mouseY, mc.fontRendererObj);
|
||||
}
|
||||
}
|
||||
for (int i = 0;i<intChoosers.size();i++) {
|
||||
GuiIntChooser choose = intChoosers.get(i);
|
||||
choose.drawChooser();
|
||||
String tooltip = confComp.fomatConfigDescription(IConfigurableComponent.ConfigType.INT, i);
|
||||
if (tooltip!=null&&choose.isMouseOver(mouseX, mouseY)) {
|
||||
ClientUtils.drawHoveringText(ImmutableList.of(tooltip), mouseX, mouseY, mc.fontRendererObj);
|
||||
}
|
||||
}
|
||||
for (int i = 0;i<floatSliders.size();i++) {
|
||||
GuiSliderIE choose = floatSliders.get(i);
|
||||
choose.drawButton(mc, mouseX, mouseY);
|
||||
String tooltip = confComp.fomatConfigDescription(IConfigurableComponent.ConfigType.INT, i);
|
||||
if (tooltip!=null&&choose.isMouseOver()) {
|
||||
ClientUtils.drawHoveringText(ImmutableList.of(tooltip), mouseX, mouseY, mc.fontRendererObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void sync(int id, String value) {
|
||||
NBTTagCompound update = new NBTTagCompound();
|
||||
update.setInteger(MessageComponentSync.TYPE, IConfigurableComponent.ConfigType.STRING.ordinal());
|
||||
update.setInteger(MessageComponentSync.ID, id);
|
||||
update.setString(MessageComponentSync.VALUE, value);
|
||||
syncSingle(update);
|
||||
}
|
||||
private void sync(int id, boolean value) {
|
||||
NBTTagCompound update = new NBTTagCompound();
|
||||
update.setInteger(MessageComponentSync.TYPE, IConfigurableComponent.ConfigType.BOOL.ordinal());
|
||||
update.setInteger(MessageComponentSync.ID, id);
|
||||
update.setBoolean(MessageComponentSync.VALUE, value);
|
||||
syncSingle(update);
|
||||
}
|
||||
private void sync(int id, byte value) {
|
||||
NBTTagCompound update = new NBTTagCompound();
|
||||
update.setInteger(MessageComponentSync.TYPE, IConfigurableComponent.ConfigType.RS_CHANNEL.ordinal());
|
||||
update.setInteger(MessageComponentSync.ID, id);
|
||||
update.setByte(MessageComponentSync.VALUE, value);
|
||||
syncSingle(update);
|
||||
}
|
||||
private void sync(int id, int value) {
|
||||
NBTTagCompound update = new NBTTagCompound();
|
||||
update.setInteger(MessageComponentSync.TYPE, IConfigurableComponent.ConfigType.INT.ordinal());
|
||||
update.setInteger(MessageComponentSync.ID, id);
|
||||
update.setInteger(MessageComponentSync.VALUE, value);
|
||||
syncSingle(update);
|
||||
}
|
||||
private void sync(int id, float value) {
|
||||
NBTTagCompound update = new NBTTagCompound();
|
||||
update.setInteger(MessageComponentSync.TYPE, IConfigurableComponent.ConfigType.FLOAT.ordinal());
|
||||
update.setInteger(MessageComponentSync.ID, id);
|
||||
update.setFloat(MessageComponentSync.VALUE, value);
|
||||
syncSingle(update);
|
||||
}
|
||||
private void syncAll() {
|
||||
NBTTagList list = new NBTTagList();
|
||||
for (int i = 0;i<stringTexts.size();i++) {
|
||||
NBTTagCompound update = new NBTTagCompound();
|
||||
update.setInteger(MessageComponentSync.TYPE, IConfigurableComponent.ConfigType.STRING.ordinal());
|
||||
update.setInteger(MessageComponentSync.ID, i);
|
||||
update.setString(MessageComponentSync.VALUE, stringTexts.get(i).getText());
|
||||
list.appendTag(update);
|
||||
}
|
||||
for (int i = 0;i<boolButtons.size();i++) {
|
||||
NBTTagCompound update = new NBTTagCompound();
|
||||
update.setInteger(MessageComponentSync.TYPE, IConfigurableComponent.ConfigType.BOOL.ordinal());
|
||||
update.setInteger(MessageComponentSync.ID, i);
|
||||
update.setBoolean(MessageComponentSync.VALUE, boolButtons.get(i).state);
|
||||
list.appendTag(update);
|
||||
}
|
||||
for (int i = 0;i<rsChannelChoosers.size();i++) {
|
||||
NBTTagCompound update = new NBTTagCompound();
|
||||
update.setInteger(MessageComponentSync.TYPE, IConfigurableComponent.ConfigType.RS_CHANNEL.ordinal());
|
||||
update.setInteger(MessageComponentSync.ID, i);
|
||||
update.setByte(MessageComponentSync.VALUE, rsChannelChoosers.get(i).getSelected());
|
||||
list.appendTag(update);
|
||||
}
|
||||
for (int i = 0;i<intChoosers.size();i++) {
|
||||
NBTTagCompound update = new NBTTagCompound();
|
||||
update.setInteger(MessageComponentSync.TYPE, IConfigurableComponent.ConfigType.INT.ordinal());
|
||||
update.setInteger(MessageComponentSync.ID, i);
|
||||
update.setInteger(MessageComponentSync.VALUE, intChoosers.get(i).getValue());
|
||||
list.appendTag(update);
|
||||
}
|
||||
for (int i = 0;i<floatSliders.size();i++) {
|
||||
NBTTagCompound update = new NBTTagCompound();
|
||||
update.setInteger(MessageComponentSync.TYPE, IConfigurableComponent.ConfigType.FLOAT.ordinal());
|
||||
update.setInteger(MessageComponentSync.ID, i);
|
||||
update.setFloat(MessageComponentSync.VALUE, (float) floatSliders.get(i).getValue());
|
||||
list.appendTag(update);
|
||||
}
|
||||
sync(list);
|
||||
}
|
||||
private void syncSingle(NBTTagCompound nbt) {
|
||||
NBTTagList list = new NBTTagList();
|
||||
list.appendTag(nbt);
|
||||
sync(list);
|
||||
}
|
||||
private void sync(NBTTagList list) {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.setTag("data", list);
|
||||
IndustrialWires.packetHandler.sendToServer(new MessageComponentSync(container.hand, nbt));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package malte0811.industrialWires.client.gui.elements;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.item.EnumDyeColor;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class GuiChannelPicker extends GuiButton {
|
||||
private byte selected;
|
||||
private byte currHovered;
|
||||
public GuiChannelPicker(int id, int x, int y, int size, byte selectedChannel) {
|
||||
super(id, x, y, size, size, "");
|
||||
selected = selectedChannel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton(@Nonnull Minecraft mc, int mouseX, int mouseY) {
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
||||
GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
|
||||
mouseX-=xPosition;
|
||||
mouseY-=yPosition;
|
||||
currHovered = -1;
|
||||
for (byte i = 0;i<16;i++) {
|
||||
int xMin = width/4*(i%4);
|
||||
int yMin = height/4*(i/4);
|
||||
int xMax = xMin+width/4;
|
||||
int yMax = yMin+height/4;
|
||||
EnumDyeColor color = EnumDyeColor.byMetadata(i);
|
||||
int colorVal = color.getMapColor().colorValue|0xff000000;
|
||||
if (mouseX>=xMin&&mouseX<xMax&&mouseY>=yMin&&mouseY<yMax) {
|
||||
currHovered = i;
|
||||
}
|
||||
if (selected==i) {
|
||||
drawRect(xMin+xPosition, yMin+yPosition, xMax+xPosition, yMax+yPosition, 0xff000000|~colorVal);
|
||||
}
|
||||
if (currHovered==i) {
|
||||
drawRect(xMin+xPosition, yMin+yPosition, xMax+xPosition, yMax+yPosition, colorVal);
|
||||
} else {
|
||||
final int offset = width/20;
|
||||
drawRect(xMin+offset+xPosition, yMin+offset+yPosition, xMax-offset+xPosition, yMax-offset+yPosition, colorVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void select() {
|
||||
if (currHovered>=0) {
|
||||
selected = currHovered;
|
||||
}
|
||||
}
|
||||
public byte getSelected() {
|
||||
return selected;
|
||||
}
|
||||
public boolean isHovered() {
|
||||
return currHovered>=0;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package malte0811.industrialWires.client.gui.elements;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
|
||||
public class GuiIntChooser extends Gui {
|
||||
private boolean allowNegative;
|
||||
private int value;
|
||||
private int xPos, yPos;
|
||||
private int xBtn;
|
||||
private int max;
|
||||
private Minecraft mc = Minecraft.getMinecraft();
|
||||
public GuiIntChooser(int x, int y, boolean neg, int initialValue, int digits) {
|
||||
allowNegative = neg;
|
||||
value = initialValue;
|
||||
xPos = x;
|
||||
yPos = y;
|
||||
max = (int) Math.pow(10, digits)-1;
|
||||
xBtn = x+mc.fontRendererObj.getCharWidth('0')*(digits+1);
|
||||
}
|
||||
public void drawChooser() {
|
||||
int color = 0xE0E0E0;
|
||||
mc.fontRendererObj.drawStringWithShadow(Integer.toString(value), xPos, yPos, color);
|
||||
//TODO nicer buttons
|
||||
mc.fontRendererObj.drawStringWithShadow("^", xBtn, yPos, color);
|
||||
mc.fontRendererObj.drawStringWithShadow("V", xBtn, yPos+mc.fontRendererObj.FONT_HEIGHT/2, color);
|
||||
}
|
||||
|
||||
public void click(int x, int y) {
|
||||
int height = mc.fontRendererObj.FONT_HEIGHT;
|
||||
if (x>=xBtn&&x<xBtn+mc.fontRendererObj.getCharWidth('V')) {
|
||||
if (y>=yPos&&y<yPos+height/2) {
|
||||
if (value<max) {
|
||||
value++;
|
||||
}
|
||||
} else if (y<yPos+height&&y>=yPos+height/2) {
|
||||
if (allowNegative||value>0) {
|
||||
value--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public boolean isMouseOver(int mX, int mY) {
|
||||
return mX>=xPos&&mX<xBtn+mc.fontRendererObj.getCharWidth('V')&&mY>=yPos&&mY<yPos+mc.fontRendererObj.FONT_HEIGHT;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialWires.containers;
|
||||
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumHand;
|
||||
|
||||
public class ContainerPanelComponent extends Container {
|
||||
public EnumHand hand;
|
||||
public ContainerPanelComponent(EnumHand h) {
|
||||
hand = h;
|
||||
}
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer playerIn) {
|
||||
ItemStack held = playerIn.getHeldItem(hand);
|
||||
return held!=null&&held.getItem()== IndustrialWires.panelComponent;
|
||||
}
|
||||
}
|
|
@ -21,7 +21,8 @@ package malte0811.industrialWires.controlpanel;
|
|||
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanel;
|
||||
import malte0811.industrialWires.client.RawQuad;
|
||||
import malte0811.industrialWires.client.gui.GuiPanelCreator;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import malte0811.industrialWires.controlpanel.properties.IConfigurableComponent;
|
||||
import net.minecraft.nbt.*;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import org.lwjgl.util.vector.Vector3f;
|
||||
|
@ -33,7 +34,7 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
public class LightedButton extends PanelComponent {
|
||||
public class LightedButton extends PanelComponent implements IConfigurableComponent {
|
||||
public int color = 0xFF0000;
|
||||
public boolean active;
|
||||
public boolean latching;
|
||||
|
@ -77,16 +78,14 @@ public class LightedButton extends PanelComponent {
|
|||
private final static float size = .0625F;
|
||||
@Override
|
||||
public List<RawQuad> getQuads() {
|
||||
float[] color = new float[4];
|
||||
color[3] = 1;
|
||||
for (int i = 0;i<3;i++) {
|
||||
color[i] = ((this.color>>(8*(2-i)))&255)/255F*(active?1:.5F);
|
||||
}
|
||||
float[] color = getFloatColor(active);
|
||||
List<RawQuad> ret = new ArrayList<>(5);
|
||||
PanelUtils.addColoredBox(color, GRAY, null, new Vector3f(0, 0, 0), new Vector3f(size, size/2, size), ret, false);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public PanelComponent copyOf() {
|
||||
|
@ -156,6 +155,11 @@ public class LightedButton extends PanelComponent {
|
|||
renderInGUIDefault(gui, 0xff000000|color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate(TileEntityPanel te) {
|
||||
setOut(false, te);
|
||||
}
|
||||
|
||||
private void setOut(boolean on, TileEntityPanel tile) {
|
||||
active = on;
|
||||
tile.markDirty();
|
||||
|
@ -186,4 +190,95 @@ public class LightedButton extends PanelComponent {
|
|||
result = 31 * result + (latching ? 1 : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyConfigOption(ConfigType type, int id, NBTBase value) {
|
||||
switch (type) {
|
||||
case BOOL:
|
||||
if (id==0) {
|
||||
latching = ((NBTTagByte)value).getByte()!=0;
|
||||
}
|
||||
break;
|
||||
case RS_CHANNEL:
|
||||
if (id==0) {
|
||||
rsOutputChannel = ((NBTTagByte)value).getByte();
|
||||
}
|
||||
break;
|
||||
case INT:
|
||||
if (id==0) {
|
||||
rsOutputId = ((NBTTagInt)value).getInt();
|
||||
}
|
||||
break;
|
||||
case FLOAT:
|
||||
color &= ~(0xff<<(8*id));
|
||||
color |= (int)(255*(((NBTTagFloat)value).getFloat()))<<(8*id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String fomatConfigName(ConfigType type, int id) {
|
||||
switch (type) {
|
||||
case BOOL:
|
||||
return "Latching";
|
||||
case RS_CHANNEL:
|
||||
case INT:
|
||||
return null;
|
||||
case FLOAT:
|
||||
return id==0?"Red":(id==1?"Green":"Blue");
|
||||
default:
|
||||
return "INVALID";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String fomatConfigDescription(ConfigType type, int id) {
|
||||
//TODO localize
|
||||
switch (type) {
|
||||
case BOOL:
|
||||
return "Does this button stay on indefinitely?";
|
||||
case RS_CHANNEL:
|
||||
return "The RS channel to output on";
|
||||
case INT:
|
||||
return "The RS connector output ID";
|
||||
case FLOAT:
|
||||
return null;
|
||||
default:
|
||||
return "INVALID?";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public RSChannelConfig[] getRSChannelOptions() {
|
||||
return new RSChannelConfig[]{new RSChannelConfig("channel", 0, 0, (byte)rsOutputChannel)};
|
||||
}
|
||||
|
||||
@Override
|
||||
public IntConfig[] getIntegerOptions() {
|
||||
return new IntConfig[]{new IntConfig("rsId", 0, 70, rsOutputId, 2, false)};
|
||||
}
|
||||
|
||||
@Override
|
||||
public BoolConfig[] getBooleanOptions() {
|
||||
return new BoolConfig[]{new BoolConfig("latching", 0, 50, latching)};
|
||||
}
|
||||
|
||||
@Override
|
||||
public FloatConfig[] getFloatOptions() {
|
||||
float[] color = getFloatColor(true);
|
||||
return new FloatConfig[]{
|
||||
new FloatConfig("red", 0, 100, color[0], 60),
|
||||
new FloatConfig("green", 0, 120, color[1], 60),
|
||||
new FloatConfig("blue", 0, 140, color[2], 60)
|
||||
};
|
||||
}
|
||||
|
||||
public float[] getFloatColor(boolean active) {
|
||||
float[] ret = new float[4];
|
||||
ret[3] = 1;
|
||||
for (int i = 0;i<3;i++) {
|
||||
ret[i] = ((color>>(8*(2-i)))&255)/255F*(active?1:.5F);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -89,6 +89,8 @@ public abstract class PanelComponent {
|
|||
|
||||
public void unregisterRSOutput(int id, @Nonnull BiConsumer<Integer, Byte> out) {}
|
||||
|
||||
public void invalidate(TileEntityPanel te) {}
|
||||
|
||||
public float getX() {
|
||||
return x;
|
||||
}
|
||||
|
|
|
@ -174,6 +174,13 @@ public class Slider extends PanelComponent {
|
|||
Gui.drawRect(left, top, right, bottom, 0xff000000|color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate(TileEntityPanel te) {
|
||||
for (BiConsumer<Integer, Byte> out:outputs) {
|
||||
out.accept((int)rsChannel, (byte) 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
|
|
@ -0,0 +1,100 @@
|
|||
package malte0811.industrialWires.controlpanel.properties;
|
||||
|
||||
import blusunrize.immersiveengineering.api.tool.IConfigurableTool.ToolConfig;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
//Based on IConfigurableTool in the IE API
|
||||
public interface IConfigurableComponent {
|
||||
/**
|
||||
* Apply and store the config option on the given stack
|
||||
*/
|
||||
void applyConfigOption(ConfigType type, int id, NBTBase value);
|
||||
|
||||
/**
|
||||
* @return a TRANSLATED name for the config option. Try to keep this short.
|
||||
*/
|
||||
@Nullable
|
||||
String fomatConfigName(ConfigType type, int id);
|
||||
|
||||
/**
|
||||
* @return a TRANSLATED name for the config option, displayed when hovering over it
|
||||
*/
|
||||
@Nullable
|
||||
String fomatConfigDescription(ConfigType type, int id);
|
||||
|
||||
default StringConfig[] getStringOptions() {
|
||||
return new StringConfig[0];
|
||||
}
|
||||
|
||||
default RSChannelConfig[] getRSChannelOptions() {
|
||||
return new RSChannelConfig[0];
|
||||
}
|
||||
|
||||
default IntConfig[] getIntegerOptions() {
|
||||
return new IntConfig[0];
|
||||
}
|
||||
|
||||
default BoolConfig[] getBooleanOptions() {
|
||||
return new BoolConfig[0];
|
||||
}
|
||||
|
||||
default FloatConfig[] getFloatOptions() {
|
||||
return new FloatConfig[0];
|
||||
}
|
||||
|
||||
class UniversalConfig<T> extends ToolConfig {
|
||||
public T value;
|
||||
|
||||
protected UniversalConfig(String name, int x, int y, T value) {
|
||||
super(name, x, y);
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
class BoolConfig extends UniversalConfig<Boolean> {
|
||||
public BoolConfig(String name, int x, int y, Boolean value) {
|
||||
super(name, x, y, value);
|
||||
}
|
||||
}
|
||||
|
||||
class StringConfig extends UniversalConfig<String> {
|
||||
public StringConfig(String name, int x, int y, String value) {
|
||||
super(name, x, y, value);
|
||||
}
|
||||
}
|
||||
|
||||
class RSChannelConfig extends UniversalConfig<Byte> {
|
||||
public RSChannelConfig(String name, int x, int y, Byte value) {
|
||||
super(name, x, y, value);
|
||||
}
|
||||
}
|
||||
|
||||
class IntConfig extends UniversalConfig<Integer> {
|
||||
public int digits;
|
||||
public boolean allowNegative;
|
||||
|
||||
public IntConfig(String name, int x, int y, Integer value, int digits, boolean allowNegative) {
|
||||
super(name, x, y, value);
|
||||
this.digits = digits;
|
||||
this.allowNegative = allowNegative;
|
||||
}
|
||||
}
|
||||
|
||||
class FloatConfig extends UniversalConfig<Float> {
|
||||
public int width;
|
||||
|
||||
public FloatConfig(String name, int x, int y, Float value, int width) {
|
||||
super(name, x, y, value);
|
||||
this.width = width;
|
||||
}
|
||||
}
|
||||
enum ConfigType {
|
||||
BOOL,
|
||||
STRING,
|
||||
RS_CHANNEL,
|
||||
INT,
|
||||
FLOAT;
|
||||
}
|
||||
}
|
|
@ -30,7 +30,11 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
@ -135,4 +139,13 @@ public class ItemPanelComponent extends Item {
|
|||
}
|
||||
return nbt;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) {
|
||||
if(!worldIn.isRemote) {
|
||||
playerIn.openGui(IndustrialWires.MODID, 1, worldIn, 0, 0, hand==EnumHand.MAIN_HAND?1:0);
|
||||
}
|
||||
return new ActionResult<>(EnumActionResult.SUCCESS, itemStackIn);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,89 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialWires.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.controlpanel.PanelComponent;
|
||||
import malte0811.industrialWires.controlpanel.properties.IConfigurableComponent;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraftforge.fml.common.network.ByteBufUtils;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||
|
||||
public class MessageComponentSync implements IMessage {
|
||||
public static final String TYPE = "type";
|
||||
public static final String ID = "cfgId";
|
||||
public static final String VALUE = "value";
|
||||
private EnumHand hand;
|
||||
private NBTTagCompound data;
|
||||
|
||||
public MessageComponentSync(EnumHand h, NBTTagCompound data) {
|
||||
hand = h;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public MessageComponentSync() {}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
hand = EnumHand.values()[buf.readInt()];
|
||||
data = ByteBufUtils.readTag(buf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeInt(hand.ordinal());
|
||||
ByteBufUtils.writeTag(buf, data);
|
||||
}
|
||||
|
||||
public static class HandlerServer implements IMessageHandler<MessageComponentSync, IMessage> {
|
||||
@Override
|
||||
public IMessage onMessage(MessageComponentSync message, MessageContext ctx) {
|
||||
ctx.getServerHandler().playerEntity.getServerWorld().addScheduledTask(()->handle(message, ctx.getServerHandler().playerEntity));
|
||||
return null;
|
||||
}
|
||||
private void handle(MessageComponentSync msg, EntityPlayerMP player) {
|
||||
ItemStack held = player.getHeldItem(msg.hand);
|
||||
if (held!=null&&held.getItem()== IndustrialWires.panelComponent) {
|
||||
PanelComponent old = IndustrialWires.panelComponent.componentFromStack(held);
|
||||
if (old instanceof IConfigurableComponent) {
|
||||
NBTTagList changes = msg.data.getTagList("data", 10);
|
||||
IConfigurableComponent cmp = (IConfigurableComponent) old;
|
||||
for (int i = 0; i < changes.tagCount(); i++) {
|
||||
NBTTagCompound curr = changes.getCompoundTagAt(i);
|
||||
IConfigurableComponent.ConfigType type = IConfigurableComponent.ConfigType.values()[curr.getInteger(TYPE)];
|
||||
try {
|
||||
cmp.applyConfigOption(type, curr.getInteger(ID), curr.getTag(VALUE));
|
||||
} catch (Exception x) {
|
||||
x.printStackTrace();
|
||||
}
|
||||
}
|
||||
ItemStack newCmp = IndustrialWires.panelComponent.stackFromComponent(old);
|
||||
player.setHeldItem(msg.hand, newCmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue