Mod ID filters :)
This commit is contained in:
parent
73135fbb87
commit
70abe40b1f
18 changed files with 1054 additions and 18 deletions
src/main
java/mekanism
client/gui
GuiDictionary.javaGuiMFilterSelect.javaGuiMModIDFilter.javaGuiMOreDictFilter.javaGuiTFilterSelect.javaGuiTModIDFilter.javaGuiTOreDictFilter.java
common
resources/assets/mekanism
|
@ -46,7 +46,7 @@ public class GuiDictionary extends GuiMekanism
|
||||||
|
|
||||||
for(String name : oreDictNames)
|
for(String name : oreDictNames)
|
||||||
{
|
{
|
||||||
fontRendererObj.drawString(MekanismUtils.localize("gui.dictionary.key") + ": " + name, 9, currentY, 0x00CD00);
|
fontRendererObj.drawString(MekanismUtils.localize("gui.key") + ": " + name, 9, currentY, 0x00CD00);
|
||||||
currentY += 9;
|
currentY += 9;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,9 +39,10 @@ public class GuiMFilterSelect extends GuiMekanism
|
||||||
int guiHeight = (height - ySize) / 2;
|
int guiHeight = (height - ySize) / 2;
|
||||||
|
|
||||||
buttonList.clear();
|
buttonList.clear();
|
||||||
buttonList.add(new GuiButton(0, guiWidth + 24, guiHeight + 32, 128, 20, "ItemStack"));
|
buttonList.add(new GuiButton(0, guiWidth + 24, guiHeight + 32, 128, 20, MekanismUtils.localize("gui.itemstack")));
|
||||||
buttonList.add(new GuiButton(1, guiWidth + 24, guiHeight + 52, 128, 20, "OreDict"));
|
buttonList.add(new GuiButton(1, guiWidth + 24, guiHeight + 52, 128, 20, MekanismUtils.localize("gui.oredict")));
|
||||||
buttonList.add(new GuiButton(2, guiWidth + 24, guiHeight + 72, 128, 20, "Material"));
|
buttonList.add(new GuiButton(2, guiWidth + 24, guiHeight + 72, 128, 20, MekanismUtils.localize("gui.material")));
|
||||||
|
buttonList.add(new GuiButton(3, guiWidth + 24, guiHeight + 92, 128, 20, MekanismUtils.localize("gui.modID")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -61,6 +62,10 @@ public class GuiMFilterSelect extends GuiMekanism
|
||||||
{
|
{
|
||||||
Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage(MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 3, 0, 0));
|
Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage(MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 3, 0, 0));
|
||||||
}
|
}
|
||||||
|
else if(guibutton.id == 3)
|
||||||
|
{
|
||||||
|
Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage(MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 6, 0, 0));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
350
src/main/java/mekanism/client/gui/GuiMModIDFilter.java
Normal file
350
src/main/java/mekanism/client/gui/GuiMModIDFilter.java
Normal file
|
@ -0,0 +1,350 @@
|
||||||
|
package mekanism.client.gui;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import mekanism.api.Coord4D;
|
||||||
|
import mekanism.api.EnumColor;
|
||||||
|
import mekanism.client.sound.SoundHandler;
|
||||||
|
import mekanism.common.Mekanism;
|
||||||
|
import mekanism.common.inventory.container.ContainerFilter;
|
||||||
|
import mekanism.common.miner.MModIDFilter;
|
||||||
|
import mekanism.common.network.PacketDigitalMinerGui.DigitalMinerGuiMessage;
|
||||||
|
import mekanism.common.network.PacketDigitalMinerGui.DigitalMinerGuiMessage.MinerGuiPacket;
|
||||||
|
import mekanism.common.network.PacketEditFilter.EditFilterMessage;
|
||||||
|
import mekanism.common.network.PacketNewFilter.NewFilterMessage;
|
||||||
|
import mekanism.common.tile.TileEntityDigitalMiner;
|
||||||
|
import mekanism.common.util.MekanismUtils;
|
||||||
|
import mekanism.common.util.MekanismUtils.ResourceType;
|
||||||
|
import net.minecraft.client.gui.GuiButton;
|
||||||
|
import net.minecraft.client.gui.GuiTextField;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemBlock;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraftforge.oredict.OreDictionary;
|
||||||
|
|
||||||
|
import org.lwjgl.input.Keyboard;
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public class GuiMModIDFilter extends GuiMekanism
|
||||||
|
{
|
||||||
|
public TileEntityDigitalMiner tileEntity;
|
||||||
|
|
||||||
|
public boolean isNew = false;
|
||||||
|
|
||||||
|
public MModIDFilter origFilter;
|
||||||
|
|
||||||
|
public MModIDFilter filter = new MModIDFilter();
|
||||||
|
|
||||||
|
private GuiTextField modIDText;
|
||||||
|
|
||||||
|
public ItemStack renderStack;
|
||||||
|
|
||||||
|
public int ticker = 0;
|
||||||
|
|
||||||
|
public int stackSwitch = 0;
|
||||||
|
|
||||||
|
public int stackIndex = 0;
|
||||||
|
|
||||||
|
public List<ItemStack> iterStacks;
|
||||||
|
|
||||||
|
public String status = EnumColor.DARK_GREEN + MekanismUtils.localize("gui.allOK");
|
||||||
|
|
||||||
|
public GuiMModIDFilter(EntityPlayer player, TileEntityDigitalMiner tentity, int index)
|
||||||
|
{
|
||||||
|
super(new ContainerFilter(player.inventory, tentity));
|
||||||
|
tileEntity = tentity;
|
||||||
|
|
||||||
|
origFilter = (MModIDFilter)tileEntity.filters.get(index);
|
||||||
|
filter = ((MModIDFilter)tentity.filters.get(index)).clone();
|
||||||
|
|
||||||
|
updateStackList(filter.modID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public GuiMModIDFilter(EntityPlayer player, TileEntityDigitalMiner tentity)
|
||||||
|
{
|
||||||
|
super(new ContainerFilter(player.inventory, tentity));
|
||||||
|
tileEntity = tentity;
|
||||||
|
|
||||||
|
isNew = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initGui()
|
||||||
|
{
|
||||||
|
super.initGui();
|
||||||
|
|
||||||
|
int guiWidth = (width - xSize) / 2;
|
||||||
|
int guiHeight = (height - ySize) / 2;
|
||||||
|
|
||||||
|
buttonList.clear();
|
||||||
|
buttonList.add(new GuiButton(0, guiWidth + 27, guiHeight + 62, 60, 20, MekanismUtils.localize("gui.save")));
|
||||||
|
buttonList.add(new GuiButton(1, guiWidth + 89, guiHeight + 62, 60, 20, MekanismUtils.localize("gui.delete")));
|
||||||
|
|
||||||
|
if(isNew)
|
||||||
|
{
|
||||||
|
((GuiButton)buttonList.get(1)).enabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
modIDText = new GuiTextField(fontRendererObj, guiWidth + 35, guiHeight + 47, 95, 12);
|
||||||
|
modIDText.setMaxStringLength(12);
|
||||||
|
modIDText.setFocused(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void keyTyped(char c, int i)
|
||||||
|
{
|
||||||
|
if(!modIDText.isFocused() || i == Keyboard.KEY_ESCAPE)
|
||||||
|
{
|
||||||
|
super.keyTyped(c, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(modIDText.isFocused() && i == Keyboard.KEY_RETURN)
|
||||||
|
{
|
||||||
|
setModID();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Character.isLetter(c) || Character.isDigit(c) || c == '*' || i == Keyboard.KEY_BACK || i == Keyboard.KEY_DELETE || i == Keyboard.KEY_LEFT || i == Keyboard.KEY_RIGHT)
|
||||||
|
{
|
||||||
|
modIDText.textboxKeyTyped(c, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void actionPerformed(GuiButton guibutton)
|
||||||
|
{
|
||||||
|
super.actionPerformed(guibutton);
|
||||||
|
|
||||||
|
if(guibutton.id == 0)
|
||||||
|
{
|
||||||
|
if(!modIDText.getText().isEmpty())
|
||||||
|
{
|
||||||
|
setModID();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(filter.modID != null && !filter.modID.isEmpty())
|
||||||
|
{
|
||||||
|
if(isNew)
|
||||||
|
{
|
||||||
|
Mekanism.packetHandler.sendToServer(new NewFilterMessage(Coord4D.get(tileEntity), filter));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Mekanism.packetHandler.sendToServer(new EditFilterMessage(Coord4D.get(tileEntity), false, origFilter, filter));
|
||||||
|
}
|
||||||
|
|
||||||
|
Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage(MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 0, 0, 0));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
status = EnumColor.DARK_RED + MekanismUtils.localize("gui.modIDFilter.noKey");
|
||||||
|
ticker = 20;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(guibutton.id == 1)
|
||||||
|
{
|
||||||
|
Mekanism.packetHandler.sendToServer(new EditFilterMessage(Coord4D.get(tileEntity), true, origFilter, null));
|
||||||
|
Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage(MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 0, 0, 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
|
||||||
|
{
|
||||||
|
int xAxis = (mouseX - (width - xSize) / 2);
|
||||||
|
int yAxis = (mouseY - (height - ySize) / 2);
|
||||||
|
|
||||||
|
fontRendererObj.drawString((isNew ? MekanismUtils.localize("gui.new") : MekanismUtils.localize("gui.edit")) + " " + MekanismUtils.localize("gui.modIDFilter"), 43, 6, 0x404040);
|
||||||
|
fontRendererObj.drawString(MekanismUtils.localize("gui.status") + ": " + status, 35, 20, 0x00CD00);
|
||||||
|
fontRendererObj.drawString(MekanismUtils.localize("gui.id") + ": " + filter.modID, 35, 32, 0x00CD00);
|
||||||
|
|
||||||
|
if(renderStack != null)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
GL11.glEnable(GL11.GL_LIGHTING);
|
||||||
|
itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), renderStack, 12, 19);
|
||||||
|
GL11.glDisable(GL11.GL_LIGHTING);
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
} catch(Exception e) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY)
|
||||||
|
{
|
||||||
|
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
|
||||||
|
|
||||||
|
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiMModIDFilter.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 xAxis = (mouseX - (width - xSize) / 2);
|
||||||
|
int yAxis = (mouseY - (height - ySize) / 2);
|
||||||
|
|
||||||
|
if(xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16)
|
||||||
|
{
|
||||||
|
drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 0, 11, 11);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 11, 11, 11);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(xAxis >= 131 && xAxis <= 143 && yAxis >= 47 && yAxis <= 59)
|
||||||
|
{
|
||||||
|
drawTexturedModalRect(guiWidth + 131, guiHeight + 47, 176 + 11, 0, 12, 12);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
drawTexturedModalRect(guiWidth + 131, guiHeight + 47, 176 + 11, 12, 12, 12);
|
||||||
|
}
|
||||||
|
|
||||||
|
modIDText.drawTextBox();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateScreen()
|
||||||
|
{
|
||||||
|
super.updateScreen();
|
||||||
|
|
||||||
|
modIDText.updateCursorCounter();
|
||||||
|
|
||||||
|
if(ticker > 0)
|
||||||
|
{
|
||||||
|
ticker--;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
status = EnumColor.DARK_GREEN + MekanismUtils.localize("gui.allOK");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(stackSwitch > 0)
|
||||||
|
{
|
||||||
|
stackSwitch--;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(stackSwitch == 0 && iterStacks != null && iterStacks.size() > 0)
|
||||||
|
{
|
||||||
|
stackSwitch = 20;
|
||||||
|
|
||||||
|
if(stackIndex == -1 || stackIndex == iterStacks.size()-1)
|
||||||
|
{
|
||||||
|
stackIndex = 0;
|
||||||
|
}
|
||||||
|
else if(stackIndex < iterStacks.size()-1)
|
||||||
|
{
|
||||||
|
stackIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
renderStack = iterStacks.get(stackIndex);
|
||||||
|
}
|
||||||
|
else if(iterStacks != null && iterStacks.size() == 0)
|
||||||
|
{
|
||||||
|
renderStack = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void mouseClicked(int mouseX, int mouseY, int button)
|
||||||
|
{
|
||||||
|
super.mouseClicked(mouseX, mouseY, button);
|
||||||
|
|
||||||
|
modIDText.mouseClicked(mouseX, mouseY, button);
|
||||||
|
|
||||||
|
if(button == 0)
|
||||||
|
{
|
||||||
|
int xAxis = (mouseX - (width - xSize) / 2);
|
||||||
|
int yAxis = (mouseY - (height - ySize) / 2);
|
||||||
|
|
||||||
|
if(xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16)
|
||||||
|
{
|
||||||
|
SoundHandler.playSound("gui.button.press");
|
||||||
|
Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage(MinerGuiPacket.SERVER, Coord4D.get(tileEntity), isNew ? 5 : 0, 0, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(xAxis >= 131 && xAxis <= 143 && yAxis >= 47 && yAxis <= 59)
|
||||||
|
{
|
||||||
|
SoundHandler.playSound("gui.button.press");
|
||||||
|
setModID();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateStackList(String modName)
|
||||||
|
{
|
||||||
|
if(iterStacks == null)
|
||||||
|
{
|
||||||
|
iterStacks = new ArrayList<ItemStack>();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
iterStacks.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
for(String key : OreDictionary.getOreNames())
|
||||||
|
{
|
||||||
|
for(ItemStack stack : OreDictionary.getOres(key))
|
||||||
|
{
|
||||||
|
ItemStack toAdd = stack.copy();
|
||||||
|
String s = MekanismUtils.getMod(toAdd);
|
||||||
|
|
||||||
|
if(!iterStacks.contains(stack) && toAdd.getItem() instanceof ItemBlock)
|
||||||
|
{
|
||||||
|
if(modName.equals(s) || modName.equals("*"))
|
||||||
|
{
|
||||||
|
iterStacks.add(stack.copy());
|
||||||
|
}
|
||||||
|
else if(modName.endsWith("*") && !modName.startsWith("*"))
|
||||||
|
{
|
||||||
|
if(s.startsWith(modName.substring(0, modName.length()-1)))
|
||||||
|
{
|
||||||
|
iterStacks.add(stack.copy());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(modName.startsWith("*") && !modName.endsWith("*"))
|
||||||
|
{
|
||||||
|
if(s.endsWith(modName.substring(1)))
|
||||||
|
{
|
||||||
|
iterStacks.add(stack.copy());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(modName.startsWith("*") && modName.endsWith("*"))
|
||||||
|
{
|
||||||
|
if(s.contains(modName.substring(1, modName.length()-1)))
|
||||||
|
{
|
||||||
|
iterStacks.add(stack.copy());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stackSwitch = 0;
|
||||||
|
stackIndex = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setModID()
|
||||||
|
{
|
||||||
|
String modName = modIDText.getText();
|
||||||
|
|
||||||
|
if(modName == null || modName.isEmpty())
|
||||||
|
{
|
||||||
|
status = EnumColor.DARK_RED + MekanismUtils.localize("gui.modIDFilter.noID");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if(modName.equals(filter.modID))
|
||||||
|
{
|
||||||
|
status = EnumColor.DARK_RED + MekanismUtils.localize("gui.modIDFilter.sameID");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
updateStackList(modName);
|
||||||
|
|
||||||
|
filter.modID = modName;
|
||||||
|
modIDText.setText("");
|
||||||
|
}
|
||||||
|
}
|
|
@ -52,7 +52,7 @@ public class GuiMOreDictFilter extends GuiMekanism
|
||||||
|
|
||||||
public List<ItemStack> iterStacks;
|
public List<ItemStack> iterStacks;
|
||||||
|
|
||||||
public String status = EnumColor.DARK_GREEN + "All OK";
|
public String status = EnumColor.DARK_GREEN + MekanismUtils.localize("gui.allOK");
|
||||||
|
|
||||||
public GuiMOreDictFilter(EntityPlayer player, TileEntityDigitalMiner tentity, int index)
|
public GuiMOreDictFilter(EntityPlayer player, TileEntityDigitalMiner tentity, int index)
|
||||||
{
|
{
|
||||||
|
@ -82,8 +82,8 @@ public class GuiMOreDictFilter extends GuiMekanism
|
||||||
int guiHeight = (height - ySize) / 2;
|
int guiHeight = (height - ySize) / 2;
|
||||||
|
|
||||||
buttonList.clear();
|
buttonList.clear();
|
||||||
buttonList.add(new GuiButton(0, guiWidth + 27, guiHeight + 62, 60, 20, "Save"));
|
buttonList.add(new GuiButton(0, guiWidth + 27, guiHeight + 62, 60, 20, MekanismUtils.localize("gui.save")));
|
||||||
buttonList.add(new GuiButton(1, guiWidth + 89, guiHeight + 62, 60, 20, "Delete"));
|
buttonList.add(new GuiButton(1, guiWidth + 89, guiHeight + 62, 60, 20, MekanismUtils.localize("gui.delete")));
|
||||||
|
|
||||||
if(isNew)
|
if(isNew)
|
||||||
{
|
{
|
||||||
|
@ -140,7 +140,7 @@ public class GuiMOreDictFilter extends GuiMekanism
|
||||||
Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage(MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 0, 0, 0));
|
Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage(MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 0, 0, 0));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
status = EnumColor.DARK_RED + "No key";
|
status = EnumColor.DARK_RED + MekanismUtils.localize("gui.oredictFilter.noKey");
|
||||||
ticker = 20;
|
ticker = 20;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -157,9 +157,9 @@ public class GuiMOreDictFilter extends GuiMekanism
|
||||||
int xAxis = (mouseX - (width - xSize) / 2);
|
int xAxis = (mouseX - (width - xSize) / 2);
|
||||||
int yAxis = (mouseY - (height - ySize) / 2);
|
int yAxis = (mouseY - (height - ySize) / 2);
|
||||||
|
|
||||||
fontRendererObj.drawString((isNew ? "New" : "Edit") + " OreDict Filter", 43, 6, 0x404040);
|
fontRendererObj.drawString((isNew ? MekanismUtils.localize("gui.new") : MekanismUtils.localize("gui.edit")) + " " + MekanismUtils.localize("gui.oredictFilter"), 43, 6, 0x404040);
|
||||||
fontRendererObj.drawString("Status: " + status, 35, 20, 0x00CD00);
|
fontRendererObj.drawString(MekanismUtils.localize("gui.status") + ": " + status, 35, 20, 0x00CD00);
|
||||||
fontRendererObj.drawString("Key: " + filter.oreDictName, 35, 32, 0x00CD00);
|
fontRendererObj.drawString(MekanismUtils.localize("gui.key") + ": " + filter.oreDictName, 35, 32, 0x00CD00);
|
||||||
|
|
||||||
if(renderStack != null)
|
if(renderStack != null)
|
||||||
{
|
{
|
||||||
|
@ -220,7 +220,7 @@ public class GuiMOreDictFilter extends GuiMekanism
|
||||||
ticker--;
|
ticker--;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
status = EnumColor.DARK_GREEN + "All OK";
|
status = EnumColor.DARK_GREEN + MekanismUtils.localize("gui.allOK");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(stackSwitch > 0)
|
if(stackSwitch > 0)
|
||||||
|
@ -339,12 +339,12 @@ public class GuiMOreDictFilter extends GuiMekanism
|
||||||
|
|
||||||
if(oreName == null || oreName.isEmpty())
|
if(oreName == null || oreName.isEmpty())
|
||||||
{
|
{
|
||||||
status = EnumColor.DARK_RED + "No key entered";
|
status = EnumColor.DARK_RED + MekanismUtils.localize("gui.oredictFilter.noKey");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if(oreName.equals(filter.oreDictName))
|
else if(oreName.equals(filter.oreDictName))
|
||||||
{
|
{
|
||||||
status = EnumColor.DARK_RED + "Same key";
|
status = EnumColor.DARK_RED + MekanismUtils.localize("gui.oredictFilter.sameKey");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@ public class GuiTFilterSelect extends GuiMekanism
|
||||||
buttonList.add(new GuiButton(0, guiWidth + 24, guiHeight + 32, 128, 20, MekanismUtils.localize("gui.itemstack")));
|
buttonList.add(new GuiButton(0, guiWidth + 24, guiHeight + 32, 128, 20, MekanismUtils.localize("gui.itemstack")));
|
||||||
buttonList.add(new GuiButton(1, guiWidth + 24, guiHeight + 52, 128, 20, MekanismUtils.localize("gui.oredict")));
|
buttonList.add(new GuiButton(1, guiWidth + 24, guiHeight + 52, 128, 20, MekanismUtils.localize("gui.oredict")));
|
||||||
buttonList.add(new GuiButton(2, guiWidth + 24, guiHeight + 72, 128, 20, MekanismUtils.localize("gui.material")));
|
buttonList.add(new GuiButton(2, guiWidth + 24, guiHeight + 72, 128, 20, MekanismUtils.localize("gui.material")));
|
||||||
|
buttonList.add(new GuiButton(3, guiWidth + 24, guiHeight + 92, 128, 20, MekanismUtils.localize("gui.modID")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -60,6 +61,10 @@ public class GuiTFilterSelect extends GuiMekanism
|
||||||
{
|
{
|
||||||
Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage(SorterGuiPacket.SERVER, Coord4D.get(tileEntity), 3, 0, 0));
|
Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage(SorterGuiPacket.SERVER, Coord4D.get(tileEntity), 3, 0, 0));
|
||||||
}
|
}
|
||||||
|
else if(guibutton.id == 3)
|
||||||
|
{
|
||||||
|
Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage(SorterGuiPacket.SERVER, Coord4D.get(tileEntity), 5, 0, 0));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
402
src/main/java/mekanism/client/gui/GuiTModIDFilter.java
Normal file
402
src/main/java/mekanism/client/gui/GuiTModIDFilter.java
Normal file
|
@ -0,0 +1,402 @@
|
||||||
|
package mekanism.client.gui;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import mekanism.api.Coord4D;
|
||||||
|
import mekanism.api.EnumColor;
|
||||||
|
import mekanism.client.render.MekanismRenderer;
|
||||||
|
import mekanism.client.sound.SoundHandler;
|
||||||
|
import mekanism.common.Mekanism;
|
||||||
|
import mekanism.common.inventory.container.ContainerFilter;
|
||||||
|
import mekanism.common.network.PacketEditFilter.EditFilterMessage;
|
||||||
|
import mekanism.common.network.PacketLogisticalSorterGui.LogisticalSorterGuiMessage;
|
||||||
|
import mekanism.common.network.PacketLogisticalSorterGui.LogisticalSorterGuiMessage.SorterGuiPacket;
|
||||||
|
import mekanism.common.network.PacketNewFilter.NewFilterMessage;
|
||||||
|
import mekanism.common.tile.TileEntityLogisticalSorter;
|
||||||
|
import mekanism.common.transporter.TModIDFilter;
|
||||||
|
import mekanism.common.util.MekanismUtils;
|
||||||
|
import mekanism.common.util.TransporterUtils;
|
||||||
|
import mekanism.common.util.MekanismUtils.ResourceType;
|
||||||
|
import net.minecraft.client.gui.GuiButton;
|
||||||
|
import net.minecraft.client.gui.GuiTextField;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemBlock;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraftforge.oredict.OreDictionary;
|
||||||
|
|
||||||
|
import org.lwjgl.input.Keyboard;
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
import org.lwjgl.opengl.GL12;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.registry.GameData;
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public class GuiTModIDFilter extends GuiMekanism
|
||||||
|
{
|
||||||
|
public TileEntityLogisticalSorter tileEntity;
|
||||||
|
|
||||||
|
public boolean isNew = false;
|
||||||
|
|
||||||
|
public TModIDFilter origFilter;
|
||||||
|
|
||||||
|
public TModIDFilter filter = new TModIDFilter();
|
||||||
|
|
||||||
|
private GuiTextField modIDText;
|
||||||
|
|
||||||
|
public ItemStack renderStack;
|
||||||
|
|
||||||
|
public int ticker = 0;
|
||||||
|
|
||||||
|
public int stackSwitch = 0;
|
||||||
|
|
||||||
|
public int stackIndex = 0;
|
||||||
|
|
||||||
|
public List<ItemStack> iterStacks;
|
||||||
|
|
||||||
|
public String status = EnumColor.DARK_GREEN + MekanismUtils.localize("gui.allOK");
|
||||||
|
|
||||||
|
public GuiTModIDFilter(EntityPlayer player, TileEntityLogisticalSorter tentity, int index)
|
||||||
|
{
|
||||||
|
super(new ContainerFilter(player.inventory, tentity));
|
||||||
|
tileEntity = tentity;
|
||||||
|
|
||||||
|
origFilter = (TModIDFilter)tileEntity.filters.get(index);
|
||||||
|
filter = ((TModIDFilter)tentity.filters.get(index)).clone();
|
||||||
|
|
||||||
|
updateStackList(filter.modID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public GuiTModIDFilter(EntityPlayer player, TileEntityLogisticalSorter tentity)
|
||||||
|
{
|
||||||
|
super(new ContainerFilter(player.inventory, tentity));
|
||||||
|
tileEntity = tentity;
|
||||||
|
|
||||||
|
isNew = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initGui()
|
||||||
|
{
|
||||||
|
super.initGui();
|
||||||
|
|
||||||
|
int guiWidth = (width - xSize) / 2;
|
||||||
|
int guiHeight = (height - ySize) / 2;
|
||||||
|
|
||||||
|
buttonList.clear();
|
||||||
|
buttonList.add(new GuiButton(0, guiWidth + 27, guiHeight + 62, 60, 20, MekanismUtils.localize("gui.save")));
|
||||||
|
buttonList.add(new GuiButton(1, guiWidth + 89, guiHeight + 62, 60, 20, MekanismUtils.localize("gui.delete")));
|
||||||
|
|
||||||
|
if(isNew)
|
||||||
|
{
|
||||||
|
((GuiButton)buttonList.get(1)).enabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
modIDText = new GuiTextField(fontRendererObj, guiWidth + 35, guiHeight + 47, 95, 12);
|
||||||
|
modIDText.setMaxStringLength(12);
|
||||||
|
modIDText.setFocused(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void keyTyped(char c, int i)
|
||||||
|
{
|
||||||
|
if(!modIDText.isFocused() || i == Keyboard.KEY_ESCAPE)
|
||||||
|
{
|
||||||
|
super.keyTyped(c, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(modIDText.isFocused() && i == Keyboard.KEY_RETURN)
|
||||||
|
{
|
||||||
|
setModID();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Character.isLetter(c) || Character.isDigit(c) || c == '*' || i == Keyboard.KEY_BACK || i == Keyboard.KEY_DELETE || i == Keyboard.KEY_LEFT || i == Keyboard.KEY_RIGHT)
|
||||||
|
{
|
||||||
|
modIDText.textboxKeyTyped(c, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void actionPerformed(GuiButton guibutton)
|
||||||
|
{
|
||||||
|
super.actionPerformed(guibutton);
|
||||||
|
|
||||||
|
if(guibutton.id == 0)
|
||||||
|
{
|
||||||
|
if(!modIDText.getText().isEmpty())
|
||||||
|
{
|
||||||
|
setModID();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(filter.modID != null && !filter.modID.isEmpty())
|
||||||
|
{
|
||||||
|
if(isNew)
|
||||||
|
{
|
||||||
|
Mekanism.packetHandler.sendToServer(new NewFilterMessage(Coord4D.get(tileEntity), filter));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Mekanism.packetHandler.sendToServer(new EditFilterMessage(Coord4D.get(tileEntity), false, origFilter, filter));
|
||||||
|
}
|
||||||
|
|
||||||
|
Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage(SorterGuiPacket.SERVER, Coord4D.get(tileEntity), 0, 0, 0));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
status = EnumColor.DARK_RED + MekanismUtils.localize("gui.modIDFilter.noKey");
|
||||||
|
ticker = 20;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(guibutton.id == 1)
|
||||||
|
{
|
||||||
|
Mekanism.packetHandler.sendToServer(new EditFilterMessage(Coord4D.get(tileEntity), true, origFilter, null));
|
||||||
|
Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage(SorterGuiPacket.SERVER, Coord4D.get(tileEntity), 0, 0, 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
|
||||||
|
{
|
||||||
|
int xAxis = (mouseX - (width - xSize) / 2);
|
||||||
|
int yAxis = (mouseY - (height - ySize) / 2);
|
||||||
|
|
||||||
|
fontRendererObj.drawString((isNew ? MekanismUtils.localize("gui.new") : MekanismUtils.localize("gui.edit")) + " " + MekanismUtils.localize("gui.modIDFilter"), 43, 6, 0x404040);
|
||||||
|
fontRendererObj.drawString(MekanismUtils.localize("gui.status") + ": " + status, 35, 20, 0x00CD00);
|
||||||
|
fontRendererObj.drawString(MekanismUtils.localize("gui.id") + ": " + filter.modID, 35, 32, 0x00CD00);
|
||||||
|
|
||||||
|
if(renderStack != null)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
GL11.glEnable(GL11.GL_LIGHTING);
|
||||||
|
itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), renderStack, 12, 19);
|
||||||
|
GL11.glDisable(GL11.GL_LIGHTING);
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
} catch(Exception e) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(filter.color != null)
|
||||||
|
{
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
GL11.glColor4f(1, 1, 1, 1);
|
||||||
|
GL11.glEnable(GL11.GL_LIGHTING);
|
||||||
|
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||||
|
|
||||||
|
mc.getTextureManager().bindTexture(MekanismRenderer.getBlocksTexture());
|
||||||
|
itemRender.renderIcon(12, 44, MekanismRenderer.getColorIcon(filter.color), 16, 16);
|
||||||
|
|
||||||
|
GL11.glDisable(GL11.GL_LIGHTING);
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(xAxis >= 12 && xAxis <= 28 && yAxis >= 44 && yAxis <= 60)
|
||||||
|
{
|
||||||
|
if(filter.color != null)
|
||||||
|
{
|
||||||
|
drawCreativeTabHoveringText(filter.color.getName(), xAxis, yAxis);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
drawCreativeTabHoveringText(MekanismUtils.localize("gui.none"), xAxis, yAxis);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY)
|
||||||
|
{
|
||||||
|
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
|
||||||
|
|
||||||
|
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiTModIDFilter.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 xAxis = (mouseX - (width - xSize) / 2);
|
||||||
|
int yAxis = (mouseY - (height - ySize) / 2);
|
||||||
|
|
||||||
|
if(xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16)
|
||||||
|
{
|
||||||
|
drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 0, 11, 11);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 11, 11, 11);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(xAxis >= 131 && xAxis <= 143 && yAxis >= 47 && yAxis <= 59)
|
||||||
|
{
|
||||||
|
drawTexturedModalRect(guiWidth + 131, guiHeight + 47, 176 + 11, 0, 12, 12);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
drawTexturedModalRect(guiWidth + 131, guiHeight + 47, 176 + 11, 12, 12, 12);
|
||||||
|
}
|
||||||
|
|
||||||
|
modIDText.drawTextBox();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateScreen()
|
||||||
|
{
|
||||||
|
super.updateScreen();
|
||||||
|
|
||||||
|
modIDText.updateCursorCounter();
|
||||||
|
|
||||||
|
if(ticker > 0)
|
||||||
|
{
|
||||||
|
ticker--;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
status = EnumColor.DARK_GREEN + MekanismUtils.localize("gui.allOK");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(stackSwitch > 0)
|
||||||
|
{
|
||||||
|
stackSwitch--;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(stackSwitch == 0 && iterStacks != null && iterStacks.size() > 0)
|
||||||
|
{
|
||||||
|
stackSwitch = 20;
|
||||||
|
|
||||||
|
if(stackIndex == -1 || stackIndex == iterStacks.size()-1)
|
||||||
|
{
|
||||||
|
stackIndex = 0;
|
||||||
|
}
|
||||||
|
else if(stackIndex < iterStacks.size()-1)
|
||||||
|
{
|
||||||
|
stackIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
renderStack = iterStacks.get(stackIndex);
|
||||||
|
}
|
||||||
|
else if(iterStacks != null && iterStacks.size() == 0)
|
||||||
|
{
|
||||||
|
renderStack = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void mouseClicked(int mouseX, int mouseY, int button)
|
||||||
|
{
|
||||||
|
super.mouseClicked(mouseX, mouseY, button);
|
||||||
|
|
||||||
|
modIDText.mouseClicked(mouseX, mouseY, button);
|
||||||
|
|
||||||
|
int xAxis = (mouseX - (width - xSize) / 2);
|
||||||
|
int yAxis = (mouseY - (height - ySize) / 2);
|
||||||
|
|
||||||
|
if(button == 0)
|
||||||
|
{
|
||||||
|
if(xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16)
|
||||||
|
{
|
||||||
|
SoundHandler.playSound("gui.button.press");
|
||||||
|
Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage(SorterGuiPacket.SERVER, Coord4D.get(tileEntity), isNew ? 4 : 0, 0, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(xAxis >= 131 && xAxis <= 143 && yAxis >= 47 && yAxis <= 59)
|
||||||
|
{
|
||||||
|
SoundHandler.playSound("gui.button.press");
|
||||||
|
setModID();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && button == 0)
|
||||||
|
{
|
||||||
|
button = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(xAxis >= 12 && xAxis <= 28 && yAxis >= 44 && yAxis <= 60)
|
||||||
|
{
|
||||||
|
SoundHandler.playSound("mekanism:etc.Ding");
|
||||||
|
|
||||||
|
if(button == 0)
|
||||||
|
{
|
||||||
|
filter.color = TransporterUtils.increment(filter.color);
|
||||||
|
}
|
||||||
|
else if(button == 1)
|
||||||
|
{
|
||||||
|
filter.color = TransporterUtils.decrement(filter.color);
|
||||||
|
}
|
||||||
|
else if(button == 2)
|
||||||
|
{
|
||||||
|
filter.color = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateStackList(String modName)
|
||||||
|
{
|
||||||
|
if(iterStacks == null)
|
||||||
|
{
|
||||||
|
iterStacks = new ArrayList<ItemStack>();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
iterStacks.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
for(String key : OreDictionary.getOreNames())
|
||||||
|
{
|
||||||
|
for(ItemStack stack : OreDictionary.getOres(key))
|
||||||
|
{
|
||||||
|
ItemStack toAdd = stack.copy();
|
||||||
|
String s = MekanismUtils.getMod(toAdd);
|
||||||
|
|
||||||
|
if(!iterStacks.contains(stack) && toAdd.getItem() instanceof ItemBlock)
|
||||||
|
{
|
||||||
|
if(modName.equals(s) || modName.equals("*"))
|
||||||
|
{
|
||||||
|
iterStacks.add(stack.copy());
|
||||||
|
}
|
||||||
|
else if(modName.endsWith("*") && !modName.startsWith("*"))
|
||||||
|
{
|
||||||
|
if(s.startsWith(modName.substring(0, modName.length()-1)))
|
||||||
|
{
|
||||||
|
iterStacks.add(stack.copy());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(modName.startsWith("*") && !modName.endsWith("*"))
|
||||||
|
{
|
||||||
|
if(s.endsWith(modName.substring(1)))
|
||||||
|
{
|
||||||
|
iterStacks.add(stack.copy());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(modName.startsWith("*") && modName.endsWith("*"))
|
||||||
|
{
|
||||||
|
if(s.contains(modName.substring(1, modName.length()-1)))
|
||||||
|
{
|
||||||
|
iterStacks.add(stack.copy());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stackSwitch = 0;
|
||||||
|
stackIndex = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setModID()
|
||||||
|
{
|
||||||
|
String modName = modIDText.getText();
|
||||||
|
|
||||||
|
if(modName == null || modName.isEmpty())
|
||||||
|
{
|
||||||
|
status = EnumColor.DARK_RED + MekanismUtils.localize("gui.modIDFilter.noID");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if(modName.equals(filter.modID))
|
||||||
|
{
|
||||||
|
status = EnumColor.DARK_RED + MekanismUtils.localize("gui.modIDFilter.sameID");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
updateStackList(modName);
|
||||||
|
|
||||||
|
filter.modID = modName;
|
||||||
|
modIDText.setText("");
|
||||||
|
}
|
||||||
|
}
|
|
@ -161,7 +161,7 @@ public class GuiTOreDictFilter extends GuiMekanism
|
||||||
|
|
||||||
fontRendererObj.drawString((isNew ? MekanismUtils.localize("gui.new") : MekanismUtils.localize("gui.edit")) + " " + MekanismUtils.localize("gui.oredictFilter"), 43, 6, 0x404040);
|
fontRendererObj.drawString((isNew ? MekanismUtils.localize("gui.new") : MekanismUtils.localize("gui.edit")) + " " + MekanismUtils.localize("gui.oredictFilter"), 43, 6, 0x404040);
|
||||||
fontRendererObj.drawString(MekanismUtils.localize("gui.status") + ": " + status, 35, 20, 0x00CD00);
|
fontRendererObj.drawString(MekanismUtils.localize("gui.status") + ": " + status, 35, 20, 0x00CD00);
|
||||||
fontRendererObj.drawString("Key: " + filter.oreDictName, 35, 32, 0x00CD00);
|
fontRendererObj.drawString(MekanismUtils.localize("gui.key") + ": " + filter.oreDictName, 35, 32, 0x00CD00);
|
||||||
|
|
||||||
if(renderStack != null)
|
if(renderStack != null)
|
||||||
{
|
{
|
||||||
|
|
78
src/main/java/mekanism/common/miner/MModIDFilter.java
Normal file
78
src/main/java/mekanism/common/miner/MModIDFilter.java
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
package mekanism.common.miner;
|
||||||
|
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import mekanism.common.PacketHandler;
|
||||||
|
import mekanism.common.transporter.Finder.ModIDFinder;
|
||||||
|
import net.minecraft.item.ItemBlock;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
|
||||||
|
public class MModIDFilter extends MinerFilter
|
||||||
|
{
|
||||||
|
public String modID;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canFilter(ItemStack itemStack)
|
||||||
|
{
|
||||||
|
if(itemStack == null || !(itemStack.getItem() instanceof ItemBlock))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ModIDFinder(modID).modifies(itemStack);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NBTTagCompound write(NBTTagCompound nbtTags)
|
||||||
|
{
|
||||||
|
nbtTags.setInteger("type", 3);
|
||||||
|
nbtTags.setString("modID", modID);
|
||||||
|
|
||||||
|
return nbtTags;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void read(NBTTagCompound nbtTags)
|
||||||
|
{
|
||||||
|
modID = nbtTags.getString("modID");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(ArrayList data)
|
||||||
|
{
|
||||||
|
data.add(3);
|
||||||
|
data.add(modID);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void read(ByteBuf dataStream)
|
||||||
|
{
|
||||||
|
modID = PacketHandler.readString(dataStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode()
|
||||||
|
{
|
||||||
|
int code = 1;
|
||||||
|
code = 31 * code + modID.hashCode();
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object filter)
|
||||||
|
{
|
||||||
|
return super.equals(filter) && filter instanceof MModIDFilter && ((MModIDFilter)filter).modID.equals(modID);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MModIDFilter clone()
|
||||||
|
{
|
||||||
|
MModIDFilter filter = new MModIDFilter();
|
||||||
|
filter.modID = modID;
|
||||||
|
|
||||||
|
return filter;
|
||||||
|
}
|
||||||
|
}
|
|
@ -37,6 +37,10 @@ public abstract class MinerFilter
|
||||||
{
|
{
|
||||||
filter = new MMaterialFilter();
|
filter = new MMaterialFilter();
|
||||||
}
|
}
|
||||||
|
else if(type == 3)
|
||||||
|
{
|
||||||
|
filter = new MModIDFilter();
|
||||||
|
}
|
||||||
|
|
||||||
filter.read(nbtTags);
|
filter.read(nbtTags);
|
||||||
|
|
||||||
|
@ -61,6 +65,10 @@ public abstract class MinerFilter
|
||||||
{
|
{
|
||||||
filter = new MMaterialFilter();
|
filter = new MMaterialFilter();
|
||||||
}
|
}
|
||||||
|
else if(type == 3)
|
||||||
|
{
|
||||||
|
filter = new MModIDFilter();
|
||||||
|
}
|
||||||
|
|
||||||
filter.read(dataStream);
|
filter.read(dataStream);
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ import mekanism.client.gui.GuiDigitalMinerConfig;
|
||||||
import mekanism.client.gui.GuiMFilterSelect;
|
import mekanism.client.gui.GuiMFilterSelect;
|
||||||
import mekanism.client.gui.GuiMItemStackFilter;
|
import mekanism.client.gui.GuiMItemStackFilter;
|
||||||
import mekanism.client.gui.GuiMMaterialFilter;
|
import mekanism.client.gui.GuiMMaterialFilter;
|
||||||
|
import mekanism.client.gui.GuiMModIDFilter;
|
||||||
import mekanism.client.gui.GuiMOreDictFilter;
|
import mekanism.client.gui.GuiMOreDictFilter;
|
||||||
import mekanism.common.Mekanism;
|
import mekanism.common.Mekanism;
|
||||||
import mekanism.common.PacketHandler;
|
import mekanism.common.PacketHandler;
|
||||||
|
@ -126,7 +127,7 @@ public class PacketDigitalMinerGui implements IMessageHandler<DigitalMinerGuiMes
|
||||||
{
|
{
|
||||||
container = new ContainerNull(playerMP, (TileEntityContainerBlock)obj.getTileEntity(world));
|
container = new ContainerNull(playerMP, (TileEntityContainerBlock)obj.getTileEntity(world));
|
||||||
}
|
}
|
||||||
else if(guiType == 1 || guiType == 2 || guiType == 3)
|
else if(guiType == 1 || guiType == 2 || guiType == 3 || guiType == 6)
|
||||||
{
|
{
|
||||||
container = new ContainerFilter(playerMP.inventory, (TileEntityContainerBlock)obj.getTileEntity(world));
|
container = new ContainerFilter(playerMP.inventory, (TileEntityContainerBlock)obj.getTileEntity(world));
|
||||||
}
|
}
|
||||||
|
@ -188,6 +189,10 @@ public class PacketDigitalMinerGui implements IMessageHandler<DigitalMinerGuiMes
|
||||||
{
|
{
|
||||||
return new GuiMMaterialFilter(player, (TileEntityDigitalMiner)world.getTileEntity(x, y, z));
|
return new GuiMMaterialFilter(player, (TileEntityDigitalMiner)world.getTileEntity(x, y, z));
|
||||||
}
|
}
|
||||||
|
else if(type == 6)
|
||||||
|
{
|
||||||
|
return new GuiMModIDFilter(player, (TileEntityDigitalMiner)world.getTileEntity(x, y, z));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if(packetType == MinerGuiPacket.CLIENT_INDEX)
|
else if(packetType == MinerGuiPacket.CLIENT_INDEX)
|
||||||
{
|
{
|
||||||
|
@ -203,6 +208,10 @@ public class PacketDigitalMinerGui implements IMessageHandler<DigitalMinerGuiMes
|
||||||
{
|
{
|
||||||
return new GuiMMaterialFilter(player, (TileEntityDigitalMiner)world.getTileEntity(x, y, z), index);
|
return new GuiMMaterialFilter(player, (TileEntityDigitalMiner)world.getTileEntity(x, y, z), index);
|
||||||
}
|
}
|
||||||
|
else if(type == 6)
|
||||||
|
{
|
||||||
|
return new GuiMModIDFilter(player, (TileEntityDigitalMiner)world.getTileEntity(x, y, z), index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import mekanism.client.gui.GuiLogisticalSorter;
|
||||||
import mekanism.client.gui.GuiTFilterSelect;
|
import mekanism.client.gui.GuiTFilterSelect;
|
||||||
import mekanism.client.gui.GuiTItemStackFilter;
|
import mekanism.client.gui.GuiTItemStackFilter;
|
||||||
import mekanism.client.gui.GuiTMaterialFilter;
|
import mekanism.client.gui.GuiTMaterialFilter;
|
||||||
|
import mekanism.client.gui.GuiTModIDFilter;
|
||||||
import mekanism.client.gui.GuiTOreDictFilter;
|
import mekanism.client.gui.GuiTOreDictFilter;
|
||||||
import mekanism.common.Mekanism;
|
import mekanism.common.Mekanism;
|
||||||
import mekanism.common.PacketHandler;
|
import mekanism.common.PacketHandler;
|
||||||
|
@ -116,7 +117,7 @@ public class PacketLogisticalSorterGui implements IMessageHandler<LogisticalSort
|
||||||
{
|
{
|
||||||
container = new ContainerNull(playerMP, (TileEntityContainerBlock)obj.getTileEntity(world));
|
container = new ContainerNull(playerMP, (TileEntityContainerBlock)obj.getTileEntity(world));
|
||||||
}
|
}
|
||||||
else if(guiType == 1 || guiType == 2 || guiType == 3)
|
else if(guiType == 1 || guiType == 2 || guiType == 3 || guiType == 5)
|
||||||
{
|
{
|
||||||
container = new ContainerFilter(playerMP.inventory, (TileEntityContainerBlock)obj.getTileEntity(world));
|
container = new ContainerFilter(playerMP.inventory, (TileEntityContainerBlock)obj.getTileEntity(world));
|
||||||
}
|
}
|
||||||
|
@ -164,6 +165,10 @@ public class PacketLogisticalSorterGui implements IMessageHandler<LogisticalSort
|
||||||
{
|
{
|
||||||
return new GuiTMaterialFilter(player, (TileEntityLogisticalSorter)world.getTileEntity(x, y, z));
|
return new GuiTMaterialFilter(player, (TileEntityLogisticalSorter)world.getTileEntity(x, y, z));
|
||||||
}
|
}
|
||||||
|
else if(type == 5)
|
||||||
|
{
|
||||||
|
return new GuiTModIDFilter(player, (TileEntityLogisticalSorter)world.getTileEntity(x, y, z));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if(packetType == SorterGuiPacket.CLIENT_INDEX)
|
else if(packetType == SorterGuiPacket.CLIENT_INDEX)
|
||||||
{
|
{
|
||||||
|
@ -179,6 +184,10 @@ public class PacketLogisticalSorterGui implements IMessageHandler<LogisticalSort
|
||||||
{
|
{
|
||||||
return new GuiTMaterialFilter(player, (TileEntityLogisticalSorter)world.getTileEntity(x, y, z), index);
|
return new GuiTMaterialFilter(player, (TileEntityLogisticalSorter)world.getTileEntity(x, y, z), index);
|
||||||
}
|
}
|
||||||
|
else if(type == 5)
|
||||||
|
{
|
||||||
|
return new GuiTModIDFilter(player, (TileEntityLogisticalSorter)world.getTileEntity(x, y, z));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -110,4 +110,53 @@ public abstract class Finder
|
||||||
return Block.getBlockFromItem(stack.getItem()).getMaterial() == materialType;
|
return Block.getBlockFromItem(stack.getItem()).getMaterial() == materialType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class ModIDFinder extends Finder
|
||||||
|
{
|
||||||
|
public String modID;
|
||||||
|
|
||||||
|
public ModIDFinder(String mod)
|
||||||
|
{
|
||||||
|
modID = mod;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean modifies(ItemStack stack)
|
||||||
|
{
|
||||||
|
if(stack == null || !(stack.getItem() instanceof ItemBlock))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
String id = MekanismUtils.getMod(stack);
|
||||||
|
|
||||||
|
if(modID.equals(id) || modID.equals("*"))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if(modID.endsWith("*") && !modID.startsWith("*"))
|
||||||
|
{
|
||||||
|
if(id.startsWith(modID.substring(0, modID.length()-1)))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(modID.startsWith("*") && !modID.endsWith("*"))
|
||||||
|
{
|
||||||
|
if(id.endsWith(modID.substring(1)))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(modID.startsWith("*") && modID.endsWith("*"))
|
||||||
|
{
|
||||||
|
if(id.contains(modID.substring(1, modID.length()-1)))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
95
src/main/java/mekanism/common/transporter/TModIDFilter.java
Normal file
95
src/main/java/mekanism/common/transporter/TModIDFilter.java
Normal file
|
@ -0,0 +1,95 @@
|
||||||
|
package mekanism.common.transporter;
|
||||||
|
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import mekanism.common.PacketHandler;
|
||||||
|
import mekanism.common.transporter.Finder.ModIDFinder;
|
||||||
|
import mekanism.common.util.InventoryUtils;
|
||||||
|
import net.minecraft.inventory.IInventory;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
|
public class TModIDFilter extends TransporterFilter
|
||||||
|
{
|
||||||
|
public String modID;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canFilter(ItemStack itemStack)
|
||||||
|
{
|
||||||
|
if(itemStack == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ModIDFinder(modID).modifies(itemStack);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InvStack getStackFromInventory(IInventory inv, ForgeDirection side)
|
||||||
|
{
|
||||||
|
return InventoryUtils.takeTopStack(inv, side.ordinal(), new ModIDFinder(modID));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(NBTTagCompound nbtTags)
|
||||||
|
{
|
||||||
|
super.write(nbtTags);
|
||||||
|
|
||||||
|
nbtTags.setInteger("type", 3);
|
||||||
|
nbtTags.setString("modID", modID);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void read(NBTTagCompound nbtTags)
|
||||||
|
{
|
||||||
|
super.read(nbtTags);
|
||||||
|
|
||||||
|
modID = nbtTags.getString("modID");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(ArrayList data)
|
||||||
|
{
|
||||||
|
data.add(3);
|
||||||
|
|
||||||
|
super.write(data);
|
||||||
|
|
||||||
|
data.add(modID);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void read(ByteBuf dataStream)
|
||||||
|
{
|
||||||
|
super.read(dataStream);
|
||||||
|
|
||||||
|
modID = PacketHandler.readString(dataStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode()
|
||||||
|
{
|
||||||
|
int code = 1;
|
||||||
|
code = 31 * code + super.hashCode();
|
||||||
|
code = 31 * code + modID.hashCode();
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object filter)
|
||||||
|
{
|
||||||
|
return super.equals(filter) && filter instanceof TModIDFilter && ((TModIDFilter)filter).modID.equals(modID);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TModIDFilter clone()
|
||||||
|
{
|
||||||
|
TModIDFilter filter = new TModIDFilter();
|
||||||
|
filter.color = color;
|
||||||
|
filter.modID = modID;
|
||||||
|
|
||||||
|
return filter;
|
||||||
|
}
|
||||||
|
}
|
|
@ -77,6 +77,10 @@ public abstract class TransporterFilter
|
||||||
{
|
{
|
||||||
filter = new TMaterialFilter();
|
filter = new TMaterialFilter();
|
||||||
}
|
}
|
||||||
|
else if(type == 3)
|
||||||
|
{
|
||||||
|
filter = new TModIDFilter();
|
||||||
|
}
|
||||||
|
|
||||||
filter.read(nbtTags);
|
filter.read(nbtTags);
|
||||||
|
|
||||||
|
@ -101,6 +105,10 @@ public abstract class TransporterFilter
|
||||||
{
|
{
|
||||||
filter = new TMaterialFilter();
|
filter = new TMaterialFilter();
|
||||||
}
|
}
|
||||||
|
else if(type == 3)
|
||||||
|
{
|
||||||
|
filter = new TModIDFilter();
|
||||||
|
}
|
||||||
|
|
||||||
filter.read(dataStream);
|
filter.read(dataStream);
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,8 @@ import net.minecraftforge.fluids.FluidStack;
|
||||||
import net.minecraftforge.fluids.IFluidBlock;
|
import net.minecraftforge.fluids.IFluidBlock;
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
import net.minecraftforge.oredict.OreDictionary;
|
||||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||||
|
import cpw.mods.fml.common.ModContainer;
|
||||||
|
import cpw.mods.fml.common.registry.GameData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utilities used by Mekanism. All miscellaneous methods are located here.
|
* Utilities used by Mekanism. All miscellaneous methods are located here.
|
||||||
|
@ -1262,6 +1264,16 @@ public final class MekanismUtils
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getMod(ItemStack stack)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
ModContainer mod = GameData.findModOwner(GameData.getItemRegistry().getNameForObject(stack.getItem()));
|
||||||
|
return mod == null ? "Minecraft" : mod.getName();
|
||||||
|
} catch(Exception e) {
|
||||||
|
return "null";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static int getID(ItemStack itemStack)
|
public static int getID(ItemStack itemStack)
|
||||||
{
|
{
|
||||||
if(itemStack == null)
|
if(itemStack == null)
|
||||||
|
|
BIN
src/main/resources/assets/mekanism/gui/GuiMModIDFilter.png
Normal file
BIN
src/main/resources/assets/mekanism/gui/GuiMModIDFilter.png
Normal file
Binary file not shown.
After (image error) Size: 4.1 KiB |
BIN
src/main/resources/assets/mekanism/gui/GuiTModIDFilter.png
Normal file
BIN
src/main/resources/assets/mekanism/gui/GuiTModIDFilter.png
Normal file
Binary file not shown.
After (image error) Size: 4.2 KiB |
|
@ -316,12 +316,14 @@ gui.newFilter=New Filter
|
||||||
gui.energy=Energy
|
gui.energy=Energy
|
||||||
gui.gas=Gas
|
gui.gas=Gas
|
||||||
gui.dumping=Dumping
|
gui.dumping=Dumping
|
||||||
|
gui.modID=Mod ID
|
||||||
|
gui.key=Key
|
||||||
|
gui.id=ID
|
||||||
|
|
||||||
gui.chemicalInfuser.short=C. Infuser
|
gui.chemicalInfuser.short=C. Infuser
|
||||||
gui.chemicalDissolutionChamber.short=C. Dissolution Chamber
|
gui.chemicalDissolutionChamber.short=C. Dissolution Chamber
|
||||||
|
|
||||||
gui.dictionary.noKey=No key.
|
gui.dictionary.noKey=No key.
|
||||||
gui.dictionary.key=Key
|
|
||||||
|
|
||||||
gui.configuration=Configuration
|
gui.configuration=Configuration
|
||||||
gui.configuration.strictInput=Strict Input
|
gui.configuration.strictInput=Strict Input
|
||||||
|
@ -349,6 +351,10 @@ gui.oredictFilter=OreDict Filter
|
||||||
gui.oredictFilter.noKey=No key entered
|
gui.oredictFilter.noKey=No key entered
|
||||||
gui.oredictFilter.sameKey=Same key
|
gui.oredictFilter.sameKey=Same key
|
||||||
|
|
||||||
|
gui.modIDFilter=Mod ID Filter
|
||||||
|
gui.modIDFilter.noID=No ID entered
|
||||||
|
gui.modIDFilter.sameID=Same ID
|
||||||
|
|
||||||
gui.itemFilter=Item Filter
|
gui.itemFilter=Item Filter
|
||||||
gui.itemFilter.noItem=No item
|
gui.itemFilter.noItem=No item
|
||||||
gui.itemFilter.details=ItemStack Details
|
gui.itemFilter.details=ItemStack Details
|
||||||
|
|
Loading…
Add table
Reference in a new issue