Oredictionificator work
This commit is contained in:
parent
6870b211c5
commit
9f20e0bce0
7 changed files with 687 additions and 3 deletions
|
@ -1,12 +1,19 @@
|
||||||
package mekanism.client.gui;
|
package mekanism.client.gui;
|
||||||
|
|
||||||
|
import mekanism.api.Coord4D;
|
||||||
|
import mekanism.api.EnumColor;
|
||||||
import mekanism.client.gui.element.GuiProgress;
|
import mekanism.client.gui.element.GuiProgress;
|
||||||
import mekanism.client.gui.element.GuiProgress.IProgressInfoHandler;
|
import mekanism.client.gui.element.GuiProgress.IProgressInfoHandler;
|
||||||
import mekanism.client.gui.element.GuiProgress.ProgressBar;
|
import mekanism.client.gui.element.GuiProgress.ProgressBar;
|
||||||
import mekanism.client.gui.element.GuiSlot;
|
import mekanism.client.gui.element.GuiSlot;
|
||||||
import mekanism.client.gui.element.GuiSlot.SlotType;
|
import mekanism.client.gui.element.GuiSlot.SlotType;
|
||||||
|
import mekanism.client.render.MekanismRenderer;
|
||||||
|
import mekanism.common.Mekanism;
|
||||||
import mekanism.common.inventory.container.ContainerOredictionificator;
|
import mekanism.common.inventory.container.ContainerOredictionificator;
|
||||||
|
import mekanism.common.network.PacketOredictionificatorGui.OredictionificatorGuiMessage;
|
||||||
|
import mekanism.common.network.PacketOredictionificatorGui.OredictionificatorGuiPacket;
|
||||||
import mekanism.common.tile.TileEntityOredictionificator;
|
import mekanism.common.tile.TileEntityOredictionificator;
|
||||||
|
import mekanism.common.tile.TileEntityOredictionificator.OredictionificatorFilter;
|
||||||
import mekanism.common.util.MekanismUtils;
|
import mekanism.common.util.MekanismUtils;
|
||||||
import mekanism.common.util.MekanismUtils.ResourceType;
|
import mekanism.common.util.MekanismUtils.ResourceType;
|
||||||
import net.minecraft.client.gui.GuiButton;
|
import net.minecraft.client.gui.GuiButton;
|
||||||
|
@ -52,6 +59,16 @@ public class GuiOredictionificator extends GuiMekanism
|
||||||
return Math.max(Math.min((int)(scroll*88), 88), 0);
|
return Math.max(Math.min((int)(scroll*88), 88), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getFilterIndex()
|
||||||
|
{
|
||||||
|
if(tileEntity.filters.size() <= 4)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (int)((tileEntity.filters.size()*scroll) - ((4F/(float)tileEntity.filters.size()))*scroll);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initGui()
|
public void initGui()
|
||||||
{
|
{
|
||||||
|
@ -71,7 +88,7 @@ public class GuiOredictionificator extends GuiMekanism
|
||||||
|
|
||||||
if(guibutton.id == 0)
|
if(guibutton.id == 0)
|
||||||
{
|
{
|
||||||
|
Mekanism.packetHandler.sendToServer(new OredictionificatorGuiMessage(OredictionificatorGuiPacket.SERVER, Coord4D.get(tileEntity), 1, 0, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,6 +101,27 @@ public class GuiOredictionificator extends GuiMekanism
|
||||||
fontRendererObj.drawString(tileEntity.getInventoryName(), (xSize/2)-(fontRendererObj.getStringWidth(tileEntity.getInventoryName())/2), 6, 0x404040);
|
fontRendererObj.drawString(tileEntity.getInventoryName(), (xSize/2)-(fontRendererObj.getStringWidth(tileEntity.getInventoryName())/2), 6, 0x404040);
|
||||||
fontRendererObj.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040);
|
fontRendererObj.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040);
|
||||||
|
|
||||||
|
for(int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
if(tileEntity.filters.get(getFilterIndex()+i) != null)
|
||||||
|
{
|
||||||
|
OredictionificatorFilter filter = tileEntity.filters.get(getFilterIndex()+i);
|
||||||
|
int yStart = i*22 + 18;
|
||||||
|
|
||||||
|
/*
|
||||||
|
if(itemFilter.itemType != null)
|
||||||
|
{
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
GL11.glEnable(GL11.GL_LIGHTING);
|
||||||
|
itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), itemFilter.itemType, 59, yStart + 3);
|
||||||
|
GL11.glDisable(GL11.GL_LIGHTING);
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
}*/
|
||||||
|
|
||||||
|
fontRendererObj.drawString(MekanismUtils.localize("gui.filter"), 78, yStart + 2, 0x404040);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,5 +140,49 @@ public class GuiOredictionificator extends GuiMekanism
|
||||||
drawTexturedModalRect(guiWidth + 154, guiHeight + 18 + getScroll(), 232, 0, 12, 15);
|
drawTexturedModalRect(guiWidth + 154, guiHeight + 18 + getScroll(), 232, 0, 12, 15);
|
||||||
|
|
||||||
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
|
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
|
||||||
|
|
||||||
|
for(int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
if(tileEntity.filters.get(getFilterIndex()+i) != null)
|
||||||
|
{
|
||||||
|
int yStart = i*22 + 18;
|
||||||
|
boolean mouseOver = xAxis >= 56 && xAxis <= 152 && yAxis >= yStart && yAxis <= yStart+22;
|
||||||
|
|
||||||
|
if(mouseOver)
|
||||||
|
{
|
||||||
|
MekanismRenderer.color(EnumColor.GREY, 3.0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
drawTexturedModalRect(guiWidth + 56, guiHeight + yStart, 0, 166, 142, 22);
|
||||||
|
|
||||||
|
MekanismRenderer.resetColor();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void mouseClickMove(int mouseX, int mouseY, int button, long ticks)
|
||||||
|
{
|
||||||
|
super.mouseClickMove(mouseX, mouseY, button, ticks);
|
||||||
|
|
||||||
|
int xAxis = (mouseX - (width - xSize) / 2);
|
||||||
|
int yAxis = (mouseY - (height - ySize) / 2);
|
||||||
|
|
||||||
|
if(isDragging)
|
||||||
|
{
|
||||||
|
scroll = Math.min(Math.max((float)(yAxis-18-dragOffset)/88F, 0), 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void mouseMovedOrUp(int x, int y, int type)
|
||||||
|
{
|
||||||
|
super.mouseMovedOrUp(x, y, type);
|
||||||
|
|
||||||
|
if(type == 0 && isDragging)
|
||||||
|
{
|
||||||
|
dragOffset = 0;
|
||||||
|
isDragging = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,360 @@
|
||||||
|
package mekanism.client.gui;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import mekanism.api.Coord4D;
|
||||||
|
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.PacketNewFilter.NewFilterMessage;
|
||||||
|
import mekanism.common.network.PacketSimpleGui.SimpleGuiMessage;
|
||||||
|
import mekanism.common.tile.TileEntityOredictionificator;
|
||||||
|
import mekanism.common.tile.TileEntityOredictionificator.OredictionificatorFilter;
|
||||||
|
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.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 GuiOredictionificatorFilter extends GuiMekanism
|
||||||
|
{
|
||||||
|
public static List<String> possibleFilters = Arrays.asList("ingot", "ore", "dust");
|
||||||
|
|
||||||
|
public TileEntityOredictionificator tileEntity;
|
||||||
|
|
||||||
|
public OredictionificatorFilter origFilter;
|
||||||
|
|
||||||
|
public OredictionificatorFilter filter = new OredictionificatorFilter();
|
||||||
|
|
||||||
|
public GuiTextField filterText;
|
||||||
|
|
||||||
|
public boolean isNew;
|
||||||
|
|
||||||
|
public ItemStack renderStack;
|
||||||
|
|
||||||
|
public GuiOredictionificatorFilter(EntityPlayer player, TileEntityOredictionificator tentity, int index)
|
||||||
|
{
|
||||||
|
super(tentity, new ContainerFilter(player.inventory, tentity));
|
||||||
|
tileEntity = tentity;
|
||||||
|
|
||||||
|
origFilter = tileEntity.filters.get(index);
|
||||||
|
filter = ((OredictionificatorFilter)tentity.filters.get(index)).clone();
|
||||||
|
}
|
||||||
|
|
||||||
|
public GuiOredictionificatorFilter(EntityPlayer player, TileEntityOredictionificator tentity)
|
||||||
|
{
|
||||||
|
super(tentity, new ContainerFilter(player.inventory, tentity));
|
||||||
|
tileEntity = tentity;
|
||||||
|
|
||||||
|
isNew = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFilter()
|
||||||
|
{
|
||||||
|
String newFilter = filterText.getText();
|
||||||
|
boolean has = true;
|
||||||
|
|
||||||
|
for(String s : possibleFilters)
|
||||||
|
{
|
||||||
|
if(newFilter.startsWith(s))
|
||||||
|
{
|
||||||
|
has = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(has)
|
||||||
|
{
|
||||||
|
filter.filter = newFilter;
|
||||||
|
filter.index = 0;
|
||||||
|
filterText.setText("");
|
||||||
|
|
||||||
|
updateRenderStack();
|
||||||
|
}
|
||||||
|
|
||||||
|
updateButtons();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateButtons()
|
||||||
|
{
|
||||||
|
if(filter.filter != null && !filter.filter.isEmpty())
|
||||||
|
{
|
||||||
|
((GuiButton)buttonList.get(0)).enabled = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
((GuiButton)buttonList.get(0)).enabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!isNew)
|
||||||
|
{
|
||||||
|
((GuiButton)buttonList.get(1)).enabled = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
((GuiButton)buttonList.get(1)).enabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initGui()
|
||||||
|
{
|
||||||
|
super.initGui();
|
||||||
|
|
||||||
|
int guiWidth = (width - xSize) / 2;
|
||||||
|
int guiHeight = (height - ySize) / 2;
|
||||||
|
|
||||||
|
buttonList.clear();
|
||||||
|
buttonList.add(new GuiButton(0, guiWidth + 31, guiHeight + 62, 54, 20, MekanismUtils.localize("gui.save")));
|
||||||
|
buttonList.add(new GuiButton(1, guiWidth + 89, guiHeight + 62, 54, 20, MekanismUtils.localize("gui.delete")));
|
||||||
|
|
||||||
|
if(isNew)
|
||||||
|
{
|
||||||
|
((GuiButton)buttonList.get(1)).enabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
filterText = new GuiTextField(fontRendererObj, guiWidth + 33, guiHeight + 48, 96, 12);
|
||||||
|
filterText.setMaxStringLength(TileEntityOredictionificator.MAX_LENGTH);
|
||||||
|
filterText.setFocused(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
|
||||||
|
{
|
||||||
|
int xAxis = (mouseX - (width - xSize) / 2);
|
||||||
|
int yAxis = (mouseY - (height - ySize) / 2);
|
||||||
|
|
||||||
|
String text = (isNew ? MekanismUtils.localize("gui.new") : MekanismUtils.localize("gui.edit")) + " " + MekanismUtils.localize("gui.filter");
|
||||||
|
fontRendererObj.drawString(text, (xSize/2)-(fontRendererObj.getStringWidth(text)/2), 6, 0x404040);
|
||||||
|
|
||||||
|
fontRendererObj.drawString(MekanismUtils.localize("gui.index") + ": " + filter.index, 79, 23, 0x404040);
|
||||||
|
|
||||||
|
if(filter.filter != null)
|
||||||
|
{
|
||||||
|
renderScaledText(filter.filter, 32, 38, 0x404040, 111);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(renderStack != null)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
GL11.glEnable(GL11.GL_LIGHTING);
|
||||||
|
itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), renderStack, 45, 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, "GuiOredictionificatorFilter.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 + 36, 0, 11, 11);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176 + 36, 11, 11, 11);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(xAxis >= 31 && xAxis <= 43 && yAxis >= 21 && yAxis <= 33)
|
||||||
|
{
|
||||||
|
drawTexturedModalRect(guiWidth + 31, guiHeight + 21, 176 + 24, 0, 12, 12);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
drawTexturedModalRect(guiWidth + 31, guiHeight + 21, 176 + 24, 12, 12, 12);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(xAxis >= 63 && xAxis <= 75 && yAxis >= 21 && yAxis <= 33)
|
||||||
|
{
|
||||||
|
drawTexturedModalRect(guiWidth + 63, guiHeight + 21, 176 + 12, 0, 12, 12);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
drawTexturedModalRect(guiWidth + 63, guiHeight + 21, 176 + 12, 12, 12, 12);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(xAxis >= 130 && xAxis <= 142 && yAxis >= 48 && yAxis <= 60)
|
||||||
|
{
|
||||||
|
drawTexturedModalRect(guiWidth + 130, guiHeight + 48, 176, 0, 12, 12);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
drawTexturedModalRect(guiWidth + 130, guiHeight + 48, 176, 12, 12, 12);
|
||||||
|
}
|
||||||
|
|
||||||
|
filterText.drawTextBox();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void keyTyped(char c, int i)
|
||||||
|
{
|
||||||
|
if(!filterText.isFocused() || i == Keyboard.KEY_ESCAPE)
|
||||||
|
{
|
||||||
|
super.keyTyped(c, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(filterText.isFocused() && i == Keyboard.KEY_RETURN)
|
||||||
|
{
|
||||||
|
setFilter();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Character.isLetter(c) || Character.isDigit(c) || i == Keyboard.KEY_BACK || i == Keyboard.KEY_DELETE || i == Keyboard.KEY_LEFT || i == Keyboard.KEY_RIGHT)
|
||||||
|
{
|
||||||
|
filterText.textboxKeyTyped(c, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void actionPerformed(GuiButton guibutton)
|
||||||
|
{
|
||||||
|
super.actionPerformed(guibutton);
|
||||||
|
|
||||||
|
if(guibutton.id == 0)
|
||||||
|
{
|
||||||
|
if(!filterText.getText().isEmpty())
|
||||||
|
{
|
||||||
|
setFilter();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(filter.filter != null && !filter.filter.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 SimpleGuiMessage(Coord4D.get(tileEntity), 52));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(guibutton.id == 1)
|
||||||
|
{
|
||||||
|
Mekanism.packetHandler.sendToServer(new EditFilterMessage(Coord4D.get(tileEntity), true, origFilter, null));
|
||||||
|
Mekanism.packetHandler.sendToServer(new SimpleGuiMessage(Coord4D.get(tileEntity), 52));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateScreen()
|
||||||
|
{
|
||||||
|
super.updateScreen();
|
||||||
|
|
||||||
|
filterText.updateCursorCounter();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void mouseClicked(int mouseX, int mouseY, int button)
|
||||||
|
{
|
||||||
|
super.mouseClicked(mouseX, mouseY, button);
|
||||||
|
|
||||||
|
filterText.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 SimpleGuiMessage(Coord4D.get(tileEntity), 52));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(xAxis >= 130 && xAxis <= 142 && yAxis >= 48 && yAxis <= 60)
|
||||||
|
{
|
||||||
|
SoundHandler.playSound("gui.button.press");
|
||||||
|
setFilter();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(xAxis >= 31 && xAxis <= 43 && yAxis >= 21 && yAxis <= 33)
|
||||||
|
{
|
||||||
|
SoundHandler.playSound("gui.button.press");
|
||||||
|
|
||||||
|
if(filter.filter != null)
|
||||||
|
{
|
||||||
|
List<ItemStack> ores = OreDictionary.getOres(filter.filter);
|
||||||
|
|
||||||
|
if(filter.index > 0)
|
||||||
|
{
|
||||||
|
filter.index--;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
filter.index = ores.size()-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
updateRenderStack();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(xAxis >= 63 && xAxis <= 75 && yAxis >= 21 && yAxis <= 33)
|
||||||
|
{
|
||||||
|
SoundHandler.playSound("gui.button.press");
|
||||||
|
|
||||||
|
if(filter.filter != null)
|
||||||
|
{
|
||||||
|
List<ItemStack> ores = OreDictionary.getOres(filter.filter);
|
||||||
|
|
||||||
|
if(filter.index < ores.size()-1)
|
||||||
|
{
|
||||||
|
filter.index++;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
filter.index = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
updateRenderStack();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateRenderStack()
|
||||||
|
{
|
||||||
|
if(filter.filter == null || filter.filter.isEmpty())
|
||||||
|
{
|
||||||
|
renderStack = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<ItemStack> stacks = OreDictionary.getOres(filter.filter);
|
||||||
|
|
||||||
|
if(stacks.isEmpty())
|
||||||
|
{
|
||||||
|
renderStack = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(stacks.size()-1 >= filter.index)
|
||||||
|
{
|
||||||
|
renderStack = stacks.get(filter.index).copy();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
renderStack = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -38,6 +38,8 @@ import mekanism.common.network.PacketLogisticalSorterGui;
|
||||||
import mekanism.common.network.PacketLogisticalSorterGui.LogisticalSorterGuiMessage;
|
import mekanism.common.network.PacketLogisticalSorterGui.LogisticalSorterGuiMessage;
|
||||||
import mekanism.common.network.PacketNewFilter;
|
import mekanism.common.network.PacketNewFilter;
|
||||||
import mekanism.common.network.PacketNewFilter.NewFilterMessage;
|
import mekanism.common.network.PacketNewFilter.NewFilterMessage;
|
||||||
|
import mekanism.common.network.PacketOredictionificatorGui;
|
||||||
|
import mekanism.common.network.PacketOredictionificatorGui.OredictionificatorGuiMessage;
|
||||||
import mekanism.common.network.PacketPortableTankState;
|
import mekanism.common.network.PacketPortableTankState;
|
||||||
import mekanism.common.network.PacketPortableTankState.PortableTankStateMessage;
|
import mekanism.common.network.PacketPortableTankState.PortableTankStateMessage;
|
||||||
import mekanism.common.network.PacketPortableTeleporter;
|
import mekanism.common.network.PacketPortableTeleporter;
|
||||||
|
@ -97,7 +99,9 @@ public class PacketHandler
|
||||||
netHandler.registerMessage(PacketTileEntity.class, TileEntityMessage.class, 5, Side.SERVER);
|
netHandler.registerMessage(PacketTileEntity.class, TileEntityMessage.class, 5, Side.SERVER);
|
||||||
netHandler.registerMessage(PacketPortalFX.class, PortalFXMessage.class, 6, Side.CLIENT);
|
netHandler.registerMessage(PacketPortalFX.class, PortalFXMessage.class, 6, Side.CLIENT);
|
||||||
netHandler.registerMessage(PacketDataRequest.class, DataRequestMessage.class, 7, Side.SERVER);
|
netHandler.registerMessage(PacketDataRequest.class, DataRequestMessage.class, 7, Side.SERVER);
|
||||||
//EMPTY SLOTS 8 & 9
|
netHandler.registerMessage(PacketOredictionificatorGui.class, OredictionificatorGuiMessage.class, 8, Side.CLIENT);
|
||||||
|
netHandler.registerMessage(PacketOredictionificatorGui.class, OredictionificatorGuiMessage.class, 8, Side.SERVER);
|
||||||
|
//EMPTY SLOT 9
|
||||||
netHandler.registerMessage(PacketPortableTeleporter.class, PortableTeleporterMessage.class, 10, Side.CLIENT);
|
netHandler.registerMessage(PacketPortableTeleporter.class, PortableTeleporterMessage.class, 10, Side.CLIENT);
|
||||||
netHandler.registerMessage(PacketPortableTeleporter.class, PortableTeleporterMessage.class, 10, Side.SERVER);
|
netHandler.registerMessage(PacketPortableTeleporter.class, PortableTeleporterMessage.class, 10, Side.SERVER);
|
||||||
netHandler.registerMessage(PacketRemoveUpgrade.class, RemoveUpgradeMessage.class, 11, Side.SERVER);
|
netHandler.registerMessage(PacketRemoveUpgrade.class, RemoveUpgradeMessage.class, 11, Side.SERVER);
|
||||||
|
|
|
@ -0,0 +1,223 @@
|
||||||
|
package mekanism.common.network;
|
||||||
|
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import mekanism.api.Coord4D;
|
||||||
|
import mekanism.client.gui.GuiOredictionificator;
|
||||||
|
import mekanism.client.gui.GuiOredictionificatorFilter;
|
||||||
|
import mekanism.common.Mekanism;
|
||||||
|
import mekanism.common.PacketHandler;
|
||||||
|
import mekanism.common.inventory.container.ContainerFilter;
|
||||||
|
import mekanism.common.inventory.container.ContainerOredictionificator;
|
||||||
|
import mekanism.common.network.PacketOredictionificatorGui.OredictionificatorGuiMessage;
|
||||||
|
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||||
|
import mekanism.common.tile.TileEntityContainerBlock;
|
||||||
|
import mekanism.common.tile.TileEntityOredictionificator;
|
||||||
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
|
import net.minecraft.inventory.Container;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import cpw.mods.fml.common.FMLCommonHandler;
|
||||||
|
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||||
|
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||||
|
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
|
public class PacketOredictionificatorGui implements IMessageHandler<OredictionificatorGuiMessage, IMessage>
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public IMessage onMessage(OredictionificatorGuiMessage message, MessageContext context)
|
||||||
|
{
|
||||||
|
EntityPlayer player = PacketHandler.getPlayer(context);
|
||||||
|
|
||||||
|
if(!player.worldObj.isRemote)
|
||||||
|
{
|
||||||
|
World worldServer = FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(message.coord4D.dimensionId);
|
||||||
|
|
||||||
|
if(worldServer != null && message.coord4D.getTileEntity(worldServer) instanceof TileEntityOredictionificator)
|
||||||
|
{
|
||||||
|
OredictionificatorGuiMessage.openServerGui(message.packetType, message.guiType, worldServer, (EntityPlayerMP)player, message.coord4D, message.index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(message.coord4D.getTileEntity(player.worldObj) instanceof TileEntityOredictionificator)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
if(message.packetType == OredictionificatorGuiPacket.CLIENT)
|
||||||
|
{
|
||||||
|
FMLCommonHandler.instance().showGuiScreen(OredictionificatorGuiMessage.getGui(message.packetType, message.guiType, player, player.worldObj, message.coord4D.xCoord, message.coord4D.yCoord, message.coord4D.zCoord, -1));
|
||||||
|
}
|
||||||
|
else if(message.packetType == OredictionificatorGuiPacket.CLIENT_INDEX)
|
||||||
|
{
|
||||||
|
FMLCommonHandler.instance().showGuiScreen(OredictionificatorGuiMessage.getGui(message.packetType, message.guiType, player, player.worldObj, message.coord4D.xCoord, message.coord4D.yCoord, message.coord4D.zCoord, message.index));
|
||||||
|
}
|
||||||
|
|
||||||
|
player.openContainer.windowId = message.windowId;
|
||||||
|
} catch(Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class OredictionificatorGuiMessage implements IMessage
|
||||||
|
{
|
||||||
|
public Coord4D coord4D;
|
||||||
|
|
||||||
|
public OredictionificatorGuiPacket packetType;
|
||||||
|
|
||||||
|
public int guiType;
|
||||||
|
|
||||||
|
public int windowId = -1;
|
||||||
|
|
||||||
|
public int index = -1;
|
||||||
|
|
||||||
|
public OredictionificatorGuiMessage() {}
|
||||||
|
|
||||||
|
public OredictionificatorGuiMessage(OredictionificatorGuiPacket type, Coord4D coord, int guiID, int extra, int extra2)
|
||||||
|
{
|
||||||
|
packetType = type;
|
||||||
|
|
||||||
|
coord4D = coord;
|
||||||
|
guiType = guiID;
|
||||||
|
|
||||||
|
if(packetType == OredictionificatorGuiPacket.CLIENT)
|
||||||
|
{
|
||||||
|
windowId = extra;
|
||||||
|
}
|
||||||
|
else if(packetType == OredictionificatorGuiPacket.SERVER_INDEX)
|
||||||
|
{
|
||||||
|
index = extra;
|
||||||
|
}
|
||||||
|
else if(packetType == OredictionificatorGuiPacket.CLIENT_INDEX)
|
||||||
|
{
|
||||||
|
windowId = extra;
|
||||||
|
index = extra2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void openServerGui(OredictionificatorGuiPacket t, int guiType, World world, EntityPlayerMP playerMP, Coord4D obj, int i)
|
||||||
|
{
|
||||||
|
Container container = null;
|
||||||
|
|
||||||
|
playerMP.closeContainer();
|
||||||
|
|
||||||
|
if(guiType == 0)
|
||||||
|
{
|
||||||
|
container = new ContainerOredictionificator(playerMP.inventory, (TileEntityOredictionificator)obj.getTileEntity(world));
|
||||||
|
}
|
||||||
|
else if(guiType == 1)
|
||||||
|
{
|
||||||
|
container = new ContainerFilter(playerMP.inventory, (TileEntityContainerBlock)obj.getTileEntity(world));
|
||||||
|
}
|
||||||
|
|
||||||
|
playerMP.getNextWindowId();
|
||||||
|
int window = playerMP.currentWindowId;
|
||||||
|
|
||||||
|
if(t == OredictionificatorGuiPacket.SERVER)
|
||||||
|
{
|
||||||
|
Mekanism.packetHandler.sendTo(new OredictionificatorGuiMessage(OredictionificatorGuiPacket.CLIENT, obj, guiType, window, 0), playerMP);
|
||||||
|
}
|
||||||
|
else if(t == OredictionificatorGuiPacket.SERVER_INDEX)
|
||||||
|
{
|
||||||
|
Mekanism.packetHandler.sendTo(new OredictionificatorGuiMessage(OredictionificatorGuiPacket.CLIENT_INDEX, obj, guiType, window, i), playerMP);
|
||||||
|
}
|
||||||
|
|
||||||
|
playerMP.openContainer = container;
|
||||||
|
playerMP.openContainer.windowId = window;
|
||||||
|
playerMP.openContainer.addCraftingToCrafters(playerMP);
|
||||||
|
|
||||||
|
if(guiType == 0)
|
||||||
|
{
|
||||||
|
TileEntityOredictionificator tile = (TileEntityOredictionificator)obj.getTileEntity(world);
|
||||||
|
|
||||||
|
for(EntityPlayer player : tile.playersUsing)
|
||||||
|
{
|
||||||
|
Mekanism.packetHandler.sendTo(new TileEntityMessage(obj, tile.getFilterPacket(new ArrayList())), (EntityPlayerMP)player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public static GuiScreen getGui(OredictionificatorGuiPacket packetType, int type, EntityPlayer player, World world, int x, int y, int z, int index)
|
||||||
|
{
|
||||||
|
if(type == 0)
|
||||||
|
{
|
||||||
|
return new GuiOredictionificator(player.inventory, (TileEntityOredictionificator)world.getTileEntity(x, y, z));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(packetType == OredictionificatorGuiPacket.CLIENT)
|
||||||
|
{
|
||||||
|
if(type == 1)
|
||||||
|
{
|
||||||
|
return new GuiOredictionificatorFilter(player, (TileEntityOredictionificator)world.getTileEntity(x, y, z));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(packetType == OredictionificatorGuiPacket.CLIENT_INDEX)
|
||||||
|
{
|
||||||
|
if(type == 1)
|
||||||
|
{
|
||||||
|
return new GuiOredictionificatorFilter(player, (TileEntityOredictionificator)world.getTileEntity(x, y, z), index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toBytes(ByteBuf dataStream)
|
||||||
|
{
|
||||||
|
dataStream.writeInt(packetType.ordinal());
|
||||||
|
|
||||||
|
dataStream.writeInt(coord4D.xCoord);
|
||||||
|
dataStream.writeInt(coord4D.yCoord);
|
||||||
|
dataStream.writeInt(coord4D.zCoord);
|
||||||
|
|
||||||
|
dataStream.writeInt(coord4D.dimensionId);
|
||||||
|
|
||||||
|
dataStream.writeInt(guiType);
|
||||||
|
|
||||||
|
if(packetType == OredictionificatorGuiPacket.CLIENT || packetType == OredictionificatorGuiPacket.CLIENT_INDEX)
|
||||||
|
{
|
||||||
|
dataStream.writeInt(windowId);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(packetType == OredictionificatorGuiPacket.SERVER_INDEX || packetType == OredictionificatorGuiPacket.CLIENT_INDEX)
|
||||||
|
{
|
||||||
|
dataStream.writeInt(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fromBytes(ByteBuf dataStream)
|
||||||
|
{
|
||||||
|
packetType = OredictionificatorGuiPacket.values()[dataStream.readInt()];
|
||||||
|
|
||||||
|
coord4D = new Coord4D(dataStream.readInt(), dataStream.readInt(), dataStream.readInt(), dataStream.readInt());
|
||||||
|
|
||||||
|
guiType = dataStream.readInt();
|
||||||
|
|
||||||
|
if(packetType == OredictionificatorGuiPacket.CLIENT || packetType == OredictionificatorGuiPacket.CLIENT_INDEX)
|
||||||
|
{
|
||||||
|
windowId = dataStream.readInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(packetType == OredictionificatorGuiPacket.SERVER_INDEX || packetType == OredictionificatorGuiPacket.CLIENT_INDEX)
|
||||||
|
{
|
||||||
|
index = dataStream.readInt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static enum OredictionificatorGuiPacket
|
||||||
|
{
|
||||||
|
SERVER, CLIENT, SERVER_INDEX, CLIENT_INDEX
|
||||||
|
}
|
||||||
|
}
|
|
@ -331,6 +331,16 @@ public class TileEntityOredictionificator extends TileEntityContainerBlock imple
|
||||||
return filter;
|
return filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OredictionificatorFilter clone()
|
||||||
|
{
|
||||||
|
OredictionificatorFilter newFilter = new OredictionificatorFilter();
|
||||||
|
newFilter.filter = filter;
|
||||||
|
newFilter.index = index;
|
||||||
|
|
||||||
|
return newFilter;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode()
|
public int hashCode()
|
||||||
{
|
{
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.4 KiB |
|
@ -399,6 +399,7 @@ gui.state=State
|
||||||
gui.on=On
|
gui.on=On
|
||||||
gui.off=Off
|
gui.off=Off
|
||||||
gui.filters=Filters
|
gui.filters=Filters
|
||||||
|
gui.filter=Filter
|
||||||
gui.idle=Idle
|
gui.idle=Idle
|
||||||
gui.data=Data
|
gui.data=Data
|
||||||
gui.newFilter=New Filter
|
gui.newFilter=New Filter
|
||||||
|
@ -441,6 +442,7 @@ gui.add=Add
|
||||||
gui.set=Set
|
gui.set=Set
|
||||||
gui.freq=Freq
|
gui.freq=Freq
|
||||||
gui.security=Security
|
gui.security=Security
|
||||||
|
gui.index=Index
|
||||||
|
|
||||||
gui.reactor.injectionRate=Injection Rate
|
gui.reactor.injectionRate=Injection Rate
|
||||||
|
|
||||||
|
@ -490,6 +492,8 @@ gui.modIDFilter=Mod ID Filter
|
||||||
gui.modIDFilter.noID=No ID
|
gui.modIDFilter.noID=No ID
|
||||||
gui.modIDFilter.sameID=Same ID
|
gui.modIDFilter.sameID=Same ID
|
||||||
|
|
||||||
|
gui.oredictionificatorFilter=Oredictionificator Filter
|
||||||
|
|
||||||
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
|
||||||
|
@ -673,6 +677,7 @@ tooltip.Laser=An advanced form of linear energy!ntransfer that utilizes an extre
|
||||||
tooltip.LaserAmplifier=A block that can be used to merge,!nredirect and amplify laser beams,!nwith fine controls over when to fire
|
tooltip.LaserAmplifier=A block that can be used to merge,!nredirect and amplify laser beams,!nwith fine controls over when to fire
|
||||||
tooltip.LaserTractorBeam=A block used to merge and!nredirect laser beams. Collects!ndrops from blocks it has broken.
|
tooltip.LaserTractorBeam=A block used to merge and!nredirect laser beams. Collects!ndrops from blocks it has broken.
|
||||||
tooltip.SolarNeutronActivator=A machine that directs the neutron radiation !nof the sun into its internal reservoir, allowing !nfor the slow creation of various isotopes.
|
tooltip.SolarNeutronActivator=A machine that directs the neutron radiation !nof the sun into its internal reservoir, allowing !nfor the slow creation of various isotopes.
|
||||||
|
tooltip.Oredictionificator=A machine used to unify and translate between various items !nand blocks using the Ore Dictionary.
|
||||||
|
|
||||||
tooltip.HeatGenerator=A generator that uses the heat of lava or !nother burnable resources to produce energy.
|
tooltip.HeatGenerator=A generator that uses the heat of lava or !nother burnable resources to produce energy.
|
||||||
tooltip.SolarGenerator=A generator that uses the power !nof the sun to produce energy.
|
tooltip.SolarGenerator=A generator that uses the power !nof the sun to produce energy.
|
||||||
|
|
Loading…
Reference in a new issue