mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-28 15:56:07 +00:00
Merge branch '1.7' of https://github.com/CrazyPants/EnderIO into CrazyPants-1.7
Conflicts: src/main/java/crazypants/enderio/conduit/gui/ItemSettings.java src/main/java/crazypants/enderio/conduit/packet/PacketItemConduitFilter.java
This commit is contained in:
commit
d7c3f9283c
34 files changed
+1304
-360
No files matched your search
@@ -28,6 +28,8 @@ import crazypants.enderio.conduit.ConduitRecipes;
|
||||
import crazypants.enderio.conduit.facade.BlockConduitFacade;
|
||||
import crazypants.enderio.conduit.facade.ItemConduitFacade;
|
||||
import crazypants.enderio.conduit.geom.ConduitGeometryUtil;
|
||||
import crazypants.enderio.conduit.item.ItemBasicItemFilter;
|
||||
import crazypants.enderio.conduit.item.ItemExtractSpeedUpgrade;
|
||||
import crazypants.enderio.conduit.item.ItemItemConduit;
|
||||
import crazypants.enderio.conduit.liquid.ItemLiquidConduit;
|
||||
import crazypants.enderio.conduit.power.ItemPowerConduit;
|
||||
@@ -139,6 +141,8 @@ public class EnderIO {
|
||||
public static ItemPowerConduit itemPowerConduit;
|
||||
public static ItemLiquidConduit itemLiquidConduit;
|
||||
public static ItemItemConduit itemItemConduit;
|
||||
public static ItemBasicItemFilter itemBasicFilterUpgrade;
|
||||
public static ItemExtractSpeedUpgrade itemExtractSpeedUpgrade;
|
||||
|
||||
// Machines
|
||||
public static BlockStirlingGenerator blockStirlingGenerator;
|
||||
@@ -248,6 +252,9 @@ public class EnderIO {
|
||||
itemPowerConduit = ItemPowerConduit.create();
|
||||
itemLiquidConduit = ItemLiquidConduit.create();
|
||||
itemItemConduit = ItemItemConduit.create();
|
||||
|
||||
itemBasicFilterUpgrade = itemBasicFilterUpgrade.create();
|
||||
itemExtractSpeedUpgrade = ItemExtractSpeedUpgrade.create();
|
||||
|
||||
Fluid f = new Fluid(Fluids.NUTRIENT_DISTILLATION_NAME).setDensity(1500).setViscosity(3000);
|
||||
FluidRegistry.registerFluid(f);
|
||||
|
||||
@@ -12,6 +12,8 @@ public enum ModObject {
|
||||
itemRedstoneConduit,
|
||||
itemItemConduit,
|
||||
itemMeConduit,
|
||||
itemBasicFilterUpgrade,
|
||||
itemExtractSpeedUpgrade,
|
||||
|
||||
// Power
|
||||
itemPowerConduit,
|
||||
|
||||
@@ -11,6 +11,7 @@ import java.util.Set;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
@@ -70,6 +71,11 @@ public abstract class AbstractConduit implements IConduit {
|
||||
return ConnectionMode.IN_OUT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops() {
|
||||
return Collections.singletonList(createItem());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConnectionMode(ForgeDirection dir, ConnectionMode mode) {
|
||||
ConnectionMode oldVal = conectionModes.get(dir);
|
||||
|
||||
@@ -378,7 +378,7 @@ public class BlockConduitBundle extends BlockEio implements IGuiHandler {
|
||||
if(con.getConduitConnections().isEmpty() &&
|
||||
con.getExternalConnections().isEmpty() && ConduitUtil.renderConduit(player, con)) {
|
||||
te.removeConduit(con);
|
||||
drop.add(con.createItem());
|
||||
drop.addAll(con.getDrops());
|
||||
droppedUnconected = true;
|
||||
}
|
||||
}
|
||||
@@ -387,7 +387,7 @@ public class BlockConduitBundle extends BlockEio implements IGuiHandler {
|
||||
for (IConduit con : cons) {
|
||||
if(ConduitUtil.renderConduit(player, con)) {
|
||||
te.removeConduit(con);
|
||||
drop.add(con.createItem());
|
||||
drop.addAll(con.getDrops());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -395,7 +395,7 @@ public class BlockConduitBundle extends BlockEio implements IGuiHandler {
|
||||
IConduit con = te.getConduit(type);
|
||||
if(con != null) {
|
||||
te.removeConduit(con);
|
||||
drop.add(con.createItem());
|
||||
drop.addAll(con.getDrops());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package crazypants.enderio.conduit;
|
||||
|
||||
import static crazypants.enderio.ModObject.blockPainter;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import crazypants.enderio.Config;
|
||||
@@ -49,11 +50,22 @@ public class ConduitRecipes {
|
||||
ItemStack itemConduit = new ItemStack(EnderIO.itemItemConduit, numConduits, 0);
|
||||
GameRegistry.addShapedRecipe(itemConduit, "bbb", "###", "bbb", 'b', conduitBinder, '#', phasedIronNugget);
|
||||
|
||||
ItemStack itemConduitAdvanced = new ItemStack(EnderIO.itemItemConduit, numConduits, 1);
|
||||
GameRegistry.addShapedRecipe(itemConduitAdvanced, "bbb", "###", "bbb", 'b', conduitBinder, '#', phasedIron);
|
||||
// ItemStack itemConduitAdvanced = new ItemStack(EnderIO.itemItemConduit, numConduits, 1);
|
||||
// GameRegistry.addShapedRecipe(itemConduitAdvanced, "bbb", "###", "bbb", 'b', conduitBinder, '#', phasedIron);
|
||||
|
||||
MachineRecipeRegistry.instance.registerRecipe(blockPainter.unlocalisedName, new FacadePainterRecipe());
|
||||
|
||||
//Filter Recipes
|
||||
ItemStack basicFilter = new ItemStack(EnderIO.itemBasicFilterUpgrade, 1, 0);
|
||||
GameRegistry.addShapedRecipe(basicFilter, " p ","php"," p ", 'p', Items.paper, 'h', Blocks.hopper);
|
||||
|
||||
ItemStack advFilter = new ItemStack(EnderIO.itemBasicFilterUpgrade, 1, 1);
|
||||
GameRegistry.addShapedRecipe(advFilter, "rpr","php","rpr", 'p', Items.paper, 'h', new ItemStack(Items.skull, 1, 0), 'r', Items.redstone);
|
||||
GameRegistry.addShapedRecipe(advFilter, "rpr","php","rpr", 'p', Items.paper, 'h', new ItemStack(Items.skull, 1, 2), 'r', Items.redstone);
|
||||
GameRegistry.addShapedRecipe(advFilter, "rpr","php","rpr", 'p', Items.paper, 'h', new ItemStack(Items.skull, 1, 4), 'r', Items.redstone);
|
||||
|
||||
ItemStack speedUpgrade = new ItemStack(EnderIO.itemExtractSpeedUpgrade, 1, 0);
|
||||
GameRegistry.addShapedRecipe(speedUpgrade, "iii","epe","ere", 'p', Blocks.piston, 'e', electricalSteel, 'r', Blocks.redstone_torch, 'i', Items.iron_ingot);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,6 +21,8 @@ public interface IConduit {
|
||||
Class<? extends IConduit> getBaseConduitType();
|
||||
|
||||
ItemStack createItem();
|
||||
|
||||
List<ItemStack> getDrops();
|
||||
|
||||
int getLightValue();
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ public class BaseSettingsPanel implements ISettingsPanel {
|
||||
|
||||
FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
|
||||
int x = gap * 3 + fr.getStringWidth(modeLabel);
|
||||
int y = gap * 3 + fr.FONT_HEIGHT;
|
||||
int y = 8;// + fr.FONT_HEIGHT;
|
||||
|
||||
leftArrow = new IconButtonEIO(gui, PREV_MODE_B, x, y, IconEIO.LEFT_ARROW);
|
||||
leftArrow.setSize(8, 16);
|
||||
@@ -60,6 +60,8 @@ public class BaseSettingsPanel implements ISettingsPanel {
|
||||
rightArrow.setSize(8, 16);
|
||||
|
||||
customTop = top + gap * 5 + fr.FONT_HEIGHT * 2;
|
||||
customTop -= 16;
|
||||
//customTop = top;
|
||||
|
||||
}
|
||||
|
||||
@@ -115,10 +117,10 @@ public class BaseSettingsPanel implements ISettingsPanel {
|
||||
int rgb = ColorUtil.getRGB(Color.darkGray);
|
||||
int x = left + (width - fr.getStringWidth(getTypeName())) / 2;
|
||||
|
||||
fr.drawString(getTypeName(), x, top, rgb);
|
||||
//fr.drawString(getTypeName(), x, top, rgb);
|
||||
|
||||
x = left;
|
||||
int y = top + gap + fr.FONT_HEIGHT + gap;
|
||||
int y = customTop + 8;//gap + fr.FONT_HEIGHT + gap;
|
||||
gui.getFontRenderer().drawString(modeLabel, x, y, rgb);
|
||||
|
||||
String modeString = con.getConectionMode(gui.dir).getLocalisedName();
|
||||
@@ -134,6 +136,7 @@ public class BaseSettingsPanel implements ISettingsPanel {
|
||||
gui.getFontRenderer().drawString(modeString, x, y, rgb);
|
||||
|
||||
renderCustomOptions(y + gap + fr.FONT_HEIGHT + gap, par1, par2, par3);
|
||||
//renderCustomOptions(y + gap, par1, par2, par3);
|
||||
}
|
||||
|
||||
protected void renderCustomOptions(int top, float par1, int par2, int par3) {
|
||||
|
||||
@@ -0,0 +1,163 @@
|
||||
package crazypants.enderio.conduit.gui;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.conduit.ConnectionMode;
|
||||
import crazypants.enderio.conduit.IConduit;
|
||||
import crazypants.enderio.conduit.item.IItemConduit;
|
||||
import crazypants.enderio.conduit.item.IItemFilter;
|
||||
import crazypants.enderio.conduit.item.ItemFilter;
|
||||
import crazypants.enderio.conduit.packet.PacketItemConduitFilter;
|
||||
import crazypants.enderio.gui.ColorButton;
|
||||
import crazypants.enderio.gui.IconButtonEIO;
|
||||
import crazypants.enderio.gui.IconEIO;
|
||||
import crazypants.enderio.gui.ToggleButtonEIO;
|
||||
import crazypants.render.RenderUtil;
|
||||
import crazypants.util.DyeColor;
|
||||
import crazypants.util.Lang;
|
||||
|
||||
public class BasicItemFilterGui {
|
||||
|
||||
private static final int ID_WHITELIST = 17;
|
||||
private static final int ID_NBT = 18;
|
||||
private static final int ID_META = 19;
|
||||
private static final int ID_ORE_DICT = 20;
|
||||
private static final int ID_STICKY = 21;
|
||||
|
||||
private IItemConduit itemConduit;
|
||||
private GuiExternalConnection gui;
|
||||
|
||||
private ToggleButtonEIO useMetaB;
|
||||
private ToggleButtonEIO useNbtB;
|
||||
private IconButtonEIO whiteListB;
|
||||
private ToggleButtonEIO useOreDictB;
|
||||
private ToggleButtonEIO stickyB;
|
||||
|
||||
boolean isAdvanced;
|
||||
boolean isInput;
|
||||
|
||||
private ItemFilter filter;
|
||||
|
||||
public BasicItemFilterGui(GuiExternalConnection gui, IItemConduit itemConduit, boolean isInput) {
|
||||
this.gui = gui;
|
||||
this.itemConduit = itemConduit;
|
||||
this.isInput = isInput;
|
||||
|
||||
if(isInput) {
|
||||
filter = (ItemFilter) itemConduit.getInputFilter(gui.dir);
|
||||
} else {
|
||||
filter = (ItemFilter) itemConduit.getOutputFilter(gui.dir);
|
||||
}
|
||||
isAdvanced = filter.isAdvanced();
|
||||
|
||||
int butLeft = 124;
|
||||
int x = butLeft ;
|
||||
int y = 68;
|
||||
whiteListB = new IconButtonEIO(gui, ID_WHITELIST, x, y, IconEIO.FILTER_WHITELIST);
|
||||
whiteListB.setToolTip(Lang.localize("gui.conduit.item.whitelist"));
|
||||
|
||||
x += 20;
|
||||
useMetaB = new ToggleButtonEIO(gui, ID_META, x, y, IconEIO.FILTER_META_OFF, IconEIO.FILTER_META);
|
||||
useMetaB.setSelectedToolTip(Lang.localize("gui.conduit.item.matchMetaData"));
|
||||
useMetaB.setUnselectedToolTip(Lang.localize("gui.conduit.item.ignoreMetaData"));
|
||||
useMetaB.setPaintSelectedBorder(false);
|
||||
|
||||
x += 20;
|
||||
stickyB = new ToggleButtonEIO(gui, ID_STICKY, x, y, IconEIO.FILTER_STICKY_OFF, IconEIO.FILTER_STICKY);
|
||||
String[] lines = Lang.localizeList("gui.conduit.item.stickyEnabled");
|
||||
stickyB.setSelectedToolTip(lines);
|
||||
stickyB.setUnselectedToolTip(Lang.localize("gui.conduit.item.stickyDisbaled"));
|
||||
stickyB.setPaintSelectedBorder(false);
|
||||
|
||||
y += 20;
|
||||
x = butLeft;
|
||||
|
||||
x += 20;
|
||||
useNbtB = new ToggleButtonEIO(gui, ID_NBT, x, y, IconEIO.FILTER_NBT_OFF, IconEIO.FILTER_NBT);
|
||||
useNbtB.setSelectedToolTip(Lang.localize("gui.conduit.item.matchNBT"));
|
||||
useNbtB.setUnselectedToolTip(Lang.localize("gui.conduit.item.ignoreNBT"));
|
||||
useNbtB.setPaintSelectedBorder(false);
|
||||
|
||||
x = butLeft;
|
||||
useOreDictB = new ToggleButtonEIO(gui, ID_ORE_DICT, x, y, IconEIO.FILTER_ORE_DICT_OFF, IconEIO.FILTER_ORE_DICT);
|
||||
useOreDictB.setSelectedToolTip(Lang.localize("gui.conduit.item.oreDicEnabled"));
|
||||
useOreDictB.setUnselectedToolTip(Lang.localize("gui.conduit.item.oreDicDisabled"));
|
||||
useOreDictB.setPaintSelectedBorder(false);
|
||||
}
|
||||
|
||||
public void updateButtons() {
|
||||
|
||||
ItemFilter activeFilter = (ItemFilter)filter;
|
||||
|
||||
if(isAdvanced) {
|
||||
useNbtB.onGuiInit();
|
||||
useNbtB.setSelected(activeFilter.isMatchNBT());
|
||||
|
||||
useOreDictB.onGuiInit();
|
||||
useOreDictB.setSelected(activeFilter.isUseOreDict());
|
||||
|
||||
if(!isInput) {
|
||||
stickyB.onGuiInit();
|
||||
stickyB.setSelected(activeFilter.isSticky());
|
||||
}
|
||||
}
|
||||
|
||||
useMetaB.onGuiInit();
|
||||
useMetaB.setSelected(activeFilter.isMatchMeta());
|
||||
|
||||
whiteListB.onGuiInit();
|
||||
if(activeFilter.isBlacklist()) {
|
||||
whiteListB.setIcon(IconEIO.FILTER_BLACKLIST);
|
||||
whiteListB.setToolTip(Lang.localize("gui.conduit.item.blacklist"));
|
||||
} else {
|
||||
whiteListB.setIcon(IconEIO.FILTER_WHITELIST);
|
||||
whiteListB.setToolTip(Lang.localize("gui.conduit.item.whitelist"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void actionPerformed(GuiButton guiButton) {
|
||||
|
||||
if(guiButton.id == ID_META) {
|
||||
filter.setMatchMeta(useMetaB.isSelected());
|
||||
sendFilterChange();
|
||||
} else if(guiButton.id == ID_NBT) {
|
||||
filter.setMatchNBT(useNbtB.isSelected());
|
||||
sendFilterChange();
|
||||
} else if(guiButton.id == ID_STICKY) {
|
||||
filter.setSticky(stickyB.isSelected());
|
||||
sendFilterChange();
|
||||
} else if(guiButton.id == ID_ORE_DICT) {
|
||||
filter.setUseOreDict(useOreDictB.isSelected());
|
||||
sendFilterChange();
|
||||
} else if(guiButton.id == ID_WHITELIST) {
|
||||
filter.setBlacklist(!filter.isBlacklist());
|
||||
sendFilterChange();
|
||||
}
|
||||
}
|
||||
|
||||
private void sendFilterChange() {
|
||||
updateButtons();
|
||||
EnderIO.packetPipeline.sendToServer(new PacketItemConduitFilter(itemConduit, gui.dir));
|
||||
}
|
||||
|
||||
public void deactivate() {
|
||||
useNbtB.detach();
|
||||
useMetaB.detach();
|
||||
useOreDictB.detach();
|
||||
whiteListB.detach();
|
||||
stickyB.detach();
|
||||
}
|
||||
|
||||
public void renderCustomOptions(int top, float par1, int par2, int par3) {
|
||||
GL11.glColor3f(1, 1, 1);
|
||||
RenderUtil.bindTexture("enderio:textures/gui/itemFilter.png");
|
||||
gui.drawTexturedModalRect(gui.getGuiLeft() + 32, gui.getGuiTop() + 68, 0, 238, 18 * 5, 18);
|
||||
if(filter.isAdvanced()) {
|
||||
gui.drawTexturedModalRect(gui.getGuiLeft() + 32, gui.getGuiTop() + 86, 0, 238, 18 * 5, 18);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,11 +7,15 @@ import java.util.List;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.conduit.IConduitBundle;
|
||||
import crazypants.enderio.conduit.item.FilterRegister;
|
||||
import crazypants.enderio.conduit.item.IItemConduit;
|
||||
import crazypants.enderio.conduit.item.IItemFilter;
|
||||
import crazypants.enderio.conduit.item.ItemFilter;
|
||||
import crazypants.gui.TemplateSlot;
|
||||
|
||||
@@ -21,111 +25,143 @@ public class ExternalConnectionContainer extends Container {
|
||||
private IConduitBundle bundle;
|
||||
private ForgeDirection dir;
|
||||
private IItemConduit itemConduit;
|
||||
private ItemFilter inputFilter;
|
||||
private ItemFilter outputFilter;
|
||||
|
||||
private IItemFilter inputFilter;
|
||||
private IItemFilter outputFilter;
|
||||
|
||||
private int outputFilterUpgradeSlot = 36;
|
||||
private int inputFilterUpgradeSlot = 37;
|
||||
private int speedUpgradeSlot = 38;
|
||||
private int startFilterSlot = 39;
|
||||
|
||||
private List<Point> slotLocations = new ArrayList<Point>();
|
||||
|
||||
List<FilterChangeListener> filterListeners = new ArrayList<FilterChangeListener>();
|
||||
|
||||
public ExternalConnectionContainer(InventoryPlayer playerInv, IConduitBundle bundle, ForgeDirection dir) {
|
||||
this.playerInv = playerInv;
|
||||
this.bundle = bundle;
|
||||
this.dir = dir;
|
||||
|
||||
itemConduit = bundle.getConduit(IItemConduit.class);
|
||||
if(itemConduit != null) {
|
||||
addFilterSlots(dir);
|
||||
}
|
||||
int x;
|
||||
int y;
|
||||
|
||||
int topY = 113;
|
||||
// add players inventory
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
for (int j = 0; j < 9; ++j) {
|
||||
int x = 23 + j * 18;
|
||||
int y = topY + i * 18;
|
||||
x = 23 + j * 18;
|
||||
y = topY + i * 18;
|
||||
addSlotToContainer(new Slot(playerInv, j + i * 9 + 9, x, y));
|
||||
slotLocations.add(new Point(x, y));
|
||||
}
|
||||
}
|
||||
|
||||
int y = 171;
|
||||
y = 171;
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
int x = 23 + i * 18;
|
||||
x = 23 + i * 18;
|
||||
addSlotToContainer(new Slot(playerInv, i, x, y));
|
||||
slotLocations.add(new Point(x, y));
|
||||
}
|
||||
|
||||
itemConduit = bundle.getConduit(IItemConduit.class);
|
||||
if(itemConduit != null) {
|
||||
|
||||
x = 10;
|
||||
y = 47;
|
||||
InventoryFilterUpgrade fi = new InventoryFilterUpgrade(itemConduit, dir, false);
|
||||
addSlotToContainer(new FilterSlot(fi, 0, x, y, false));
|
||||
slotLocations.add(new Point(x, y));
|
||||
|
||||
x = 10;
|
||||
y = 47;
|
||||
fi = new InventoryFilterUpgrade(itemConduit, dir, true);
|
||||
addSlotToContainer(new FilterSlot(fi, 0, x, y, true));
|
||||
slotLocations.add(new Point(x, y));
|
||||
|
||||
x = 28;
|
||||
y = 47;
|
||||
final InventorySpeedUpgrades si = new InventorySpeedUpgrades(itemConduit, dir);
|
||||
addSlotToContainer(new Slot(si, 0, x, y) {
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack par1ItemStack) {
|
||||
return si.isItemValidForSlot(0, par1ItemStack);
|
||||
}
|
||||
|
||||
});
|
||||
slotLocations.add(new Point(x, y));
|
||||
|
||||
addFilterSlots(dir);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void addFilterSlots(ForgeDirection dir) {
|
||||
boolean isAdvanced = itemConduit.getMetaData() == 1;
|
||||
|
||||
List<Slot> slots;
|
||||
inputFilter = itemConduit.getInputFilter(dir);
|
||||
|
||||
int topY = 67;
|
||||
int leftX = 23;
|
||||
int index = 0;
|
||||
|
||||
for (int row = 0; row < 2; ++row) {
|
||||
|
||||
for (int col = 0; col < 5; ++col) {
|
||||
int x = leftX + col * 18;
|
||||
int y = topY + row * 18;
|
||||
if(!isAdvanced && row == 1) {
|
||||
x = -30000;
|
||||
y = -30000;
|
||||
}
|
||||
addSlotToContainer(new TemplateSlot(inputFilter, index, x, y));
|
||||
slotLocations.add(new Point(x, y));
|
||||
index++;
|
||||
if(inputFilter != null) {
|
||||
slots = inputFilter.getSlots();
|
||||
for (Slot slot : slots) {
|
||||
addSlotToContainer(slot);
|
||||
slotLocations.add(new Point(slot.xDisplayPosition, slot.yDisplayPosition));
|
||||
}
|
||||
}
|
||||
|
||||
outputFilter = itemConduit.getOutputFilter(dir);
|
||||
|
||||
leftX = 23;
|
||||
index = 0;
|
||||
for (int row = 0; row < 2; ++row) {
|
||||
|
||||
for (int col = 0; col < 5; ++col) {
|
||||
int x = leftX + col * 18;
|
||||
int y = topY + row * 18;
|
||||
if(!isAdvanced && row == 1) {
|
||||
x = -30000;
|
||||
y = -30000;
|
||||
}
|
||||
addSlotToContainer(new TemplateSlot(outputFilter, index, x, y));
|
||||
slotLocations.add(new Point(x, y));
|
||||
index++;
|
||||
if(outputFilter != null) {
|
||||
slots = outputFilter.getSlots();
|
||||
for (Slot slot : slots) {
|
||||
addSlotToContainer(slot);
|
||||
slotLocations.add(new Point(slot.xDisplayPosition, slot.yDisplayPosition));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void filterChanged() {
|
||||
int slotsToRemove = inventorySlots.size() - startFilterSlot;
|
||||
for (int i = 0; i < slotsToRemove; i++) {
|
||||
int removeIndex = inventorySlots.size() - 1;
|
||||
inventorySlots.remove(removeIndex);
|
||||
inventoryItemStacks.remove(removeIndex);
|
||||
slotLocations.remove(removeIndex);
|
||||
}
|
||||
addFilterSlots(dir);
|
||||
|
||||
for (FilterChangeListener list : filterListeners) {
|
||||
list.onFilterChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public void setInputSlotsVisible(boolean visible) {
|
||||
setSlotsVisible(visible, inputFilterUpgradeSlot, inputFilterUpgradeSlot + 1);
|
||||
setSlotsVisible(visible, speedUpgradeSlot, speedUpgradeSlot + 1);
|
||||
|
||||
if(inputFilter == null) {
|
||||
return;
|
||||
}
|
||||
int startIndex = 0;
|
||||
int endIndex = inputFilter.getSizeInventory();
|
||||
int startIndex = startFilterSlot;
|
||||
int endIndex = inputFilter.getSlotCount() + startIndex;
|
||||
setSlotsVisible(visible, startIndex, endIndex);
|
||||
|
||||
}
|
||||
|
||||
public void setOutputSlotsVisible(boolean visible) {
|
||||
|
||||
setSlotsVisible(visible, outputFilterUpgradeSlot, outputFilterUpgradeSlot + 1);
|
||||
|
||||
if(outputFilter == null) {
|
||||
return;
|
||||
}
|
||||
int startIndex = inputFilter.getSizeInventory();
|
||||
int endIndex = startIndex + outputFilter.getSizeInventory();
|
||||
int startIndex = startFilterSlot + (inputFilter == null ? 0 : inputFilter.getSlotCount());
|
||||
int endIndex = startIndex + outputFilter.getSlotCount();
|
||||
setSlotsVisible(visible, startIndex, endIndex);
|
||||
|
||||
}
|
||||
|
||||
public void setInventorySlotsVisible(boolean visible) {
|
||||
int startIndex;
|
||||
if(inputFilter == null || outputFilter == null) {
|
||||
startIndex = 0;
|
||||
} else {
|
||||
startIndex = inputFilter.getSizeInventory() + outputFilter.getSizeInventory();
|
||||
}
|
||||
int endIndex = inventorySlots.size();
|
||||
setSlotsVisible(visible, startIndex, endIndex);
|
||||
setSlotsVisible(visible, 0, 36);
|
||||
}
|
||||
|
||||
private void setSlotsVisible(boolean visible, int startIndex, int endIndex) {
|
||||
@@ -149,13 +185,10 @@ public class ExternalConnectionContainer extends Container {
|
||||
@Override
|
||||
public ItemStack slotClick(int par1, int par2, int par3, EntityPlayer par4EntityPlayer) {
|
||||
if(par4EntityPlayer.worldObj != null) {
|
||||
if(itemConduit != null && par1 < 20) {
|
||||
if(par1 >= startFilterSlot && itemConduit != null) {
|
||||
itemConduit.setInputFilter(dir, inputFilter);
|
||||
itemConduit.setOutputFilter(dir, outputFilter);
|
||||
if(par4EntityPlayer.worldObj.isRemote) {
|
||||
par4EntityPlayer.worldObj.markBlockForUpdate(bundle.getEntity().xCoord, bundle.getEntity().xCoord, bundle.getEntity().xCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
return super.slotClick(par1, par2, par3, par4EntityPlayer);
|
||||
@@ -171,4 +204,25 @@ public class ExternalConnectionContainer extends Container {
|
||||
return null;
|
||||
}
|
||||
|
||||
private class FilterSlot extends Slot {
|
||||
|
||||
boolean isInput;
|
||||
|
||||
public FilterSlot(IInventory par1iInventory, int par2, int par3, int par4, boolean isInput) {
|
||||
super(par1iInventory, par2, par3, par4);
|
||||
this.isInput = isInput;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlotChanged() {
|
||||
filterChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack par1ItemStack) {
|
||||
return inventory.isItemValidForSlot(0, par1ItemStack);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package crazypants.enderio.conduit.gui;
|
||||
|
||||
public interface FilterChangeListener {
|
||||
|
||||
void onFilterChanged();
|
||||
|
||||
}
|
||||
@@ -64,7 +64,7 @@ public class GuiExternalConnection extends GuiContainerBase {
|
||||
buttonList.clear();
|
||||
for (int i = 0; i < tabs.size(); i++) {
|
||||
if(i == activeTab) {
|
||||
tabs.get(i).onGuiInit(guiLeft + 10, guiTop + 10, xSize - 20, ySize - 20);
|
||||
tabs.get(i).onGuiInit(guiLeft + 10, guiTop, xSize - 20, ySize - 20);
|
||||
} else {
|
||||
tabs.get(i).deactivate();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package crazypants.enderio.conduit.gui;
|
||||
|
||||
public interface IItemFilterGui {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
package crazypants.enderio.conduit.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import crazypants.enderio.conduit.item.IItemConduit;
|
||||
import crazypants.enderio.conduit.item.IItemFilterUpgrade;
|
||||
|
||||
public class InventoryFilterUpgrade implements IInventory {
|
||||
|
||||
final IItemConduit itemConduit;
|
||||
final ForgeDirection dir;
|
||||
final boolean isInput;
|
||||
|
||||
InventoryFilterUpgrade(IItemConduit itemConduit, ForgeDirection dir, boolean isInput) {
|
||||
this.itemConduit = itemConduit;
|
||||
this.dir = dir;
|
||||
this.isInput = isInput;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slot) {
|
||||
if(slot == 0) {
|
||||
if(isInput) {
|
||||
return itemConduit.getInputFilterUpgrade(dir);
|
||||
} else {
|
||||
return itemConduit.getOutputFilterUpgrade(dir);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slot, int num) {
|
||||
if(slot == 0) {
|
||||
ItemStack current = getStackInSlot(0);
|
||||
if(current == null) {
|
||||
return current;
|
||||
}
|
||||
ItemStack result;
|
||||
ItemStack remaining;
|
||||
if(num >= current.stackSize) {
|
||||
result = current.copy();
|
||||
remaining = null;
|
||||
} else {
|
||||
result = current.copy();
|
||||
result.stackSize = num;
|
||||
remaining = current.copy();
|
||||
remaining.stackSize -= num;
|
||||
}
|
||||
if(isInput) {
|
||||
itemConduit.setInputFilterUpgrade(dir, remaining);
|
||||
} else {
|
||||
itemConduit.setOutputFilterUpgrade(dir, remaining);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int var1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slot, ItemStack var2) {
|
||||
if(slot == 0) {
|
||||
if(isInput) {
|
||||
itemConduit.setInputFilterUpgrade(dir, var2);
|
||||
} else {
|
||||
itemConduit.setOutputFilterUpgrade(dir, var2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "FilterUpgrade";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer var1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int var1, ItemStack item) {
|
||||
if(item == null) {
|
||||
return false;
|
||||
}
|
||||
return item.getItem() instanceof IItemFilterUpgrade;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package crazypants.enderio.conduit.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.conduit.item.IItemConduit;
|
||||
|
||||
class InventorySpeedUpgrades implements IInventory {
|
||||
|
||||
IItemConduit itemConduit;
|
||||
ForgeDirection dir;
|
||||
|
||||
InventorySpeedUpgrades(IItemConduit itemConduit, ForgeDirection dir) {
|
||||
this.itemConduit = itemConduit;
|
||||
this.dir = dir;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slot) {
|
||||
if(slot == 0) {
|
||||
return itemConduit.getSpeedUpgrade(dir);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slot, int num) {
|
||||
if(slot == 0) {
|
||||
ItemStack current = itemConduit.getSpeedUpgrade(dir);
|
||||
if(current == null) {
|
||||
return current;
|
||||
}
|
||||
ItemStack result;
|
||||
ItemStack remaining;
|
||||
if(num >= current.stackSize) {
|
||||
result = current.copy();
|
||||
remaining = null;
|
||||
} else {
|
||||
result = current.copy();
|
||||
result.stackSize = num;
|
||||
remaining = current.copy();
|
||||
remaining.stackSize -= num;
|
||||
}
|
||||
itemConduit.setSpeedUpgrade(dir, remaining);
|
||||
return result;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int var1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slot, ItemStack var2) {
|
||||
if(slot == 0) {
|
||||
itemConduit.setSpeedUpgrade(dir, var2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "SpeedUpgrade";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer var1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int var1, ItemStack item) {
|
||||
if(item == null) {
|
||||
return false;
|
||||
}
|
||||
return item.getItem() == EnderIO.itemExtractSpeedUpgrade;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import org.lwjgl.opengl.GL11;
|
||||
import crazypants.enderio.conduit.ConnectionMode;
|
||||
import crazypants.enderio.conduit.IConduit;
|
||||
import crazypants.enderio.conduit.item.IItemConduit;
|
||||
import crazypants.enderio.conduit.item.IItemFilter;
|
||||
import crazypants.enderio.conduit.item.ItemFilter;
|
||||
import crazypants.enderio.conduit.packet.PacketExtractMode;
|
||||
import crazypants.enderio.conduit.packet.PacketItemConduitFilter;
|
||||
@@ -36,16 +37,11 @@ public class ItemSettings extends BaseSettingsPanel {
|
||||
|
||||
private static final int ID_COLOR_BUTTON = 179816;
|
||||
|
||||
private static final int ID_WHITELIST = 17;
|
||||
private static final int ID_NBT = 18;
|
||||
private static final int ID_META = 19;
|
||||
private static final int ID_ORE_DICT = 20;
|
||||
private static final int ID_STICKY = 21;
|
||||
private static final int ID_LOOP = 22;
|
||||
private static final int ID_CHANNEL = 23;
|
||||
private static final int ID_ROUND_ROBIN = 24;
|
||||
private static final int ID_PRIORITY_UP = 25;
|
||||
private static final int ID_PRIORITY_DOWN = 26;
|
||||
private static final int ID_CHANNEL = 23;
|
||||
|
||||
private IItemConduit itemConduit;
|
||||
|
||||
@@ -54,13 +50,6 @@ public class ItemSettings extends BaseSettingsPanel {
|
||||
|
||||
private IconButtonEIO nextFilterB;
|
||||
|
||||
private ToggleButtonEIO useMetaB;
|
||||
private ToggleButtonEIO useNbtB;
|
||||
private IconButtonEIO whiteListB;
|
||||
private ToggleButtonEIO useOreDictB;
|
||||
private ToggleButtonEIO stickyB;
|
||||
private ColorButton channelB;
|
||||
|
||||
private ToggleButtonEIO loopB;
|
||||
private ToggleButtonEIO roundRobinB;
|
||||
|
||||
@@ -69,33 +58,41 @@ public class ItemSettings extends BaseSettingsPanel {
|
||||
|
||||
private RedstoneModeButton rsB;
|
||||
private ColorButton colorB;
|
||||
|
||||
private ColorButton channelB;
|
||||
|
||||
boolean inOutShowIn = false;
|
||||
|
||||
boolean isAdvanced;
|
||||
private IItemFilter activeFilter;
|
||||
|
||||
private ItemFilter activeFilter;
|
||||
|
||||
private int priLeft = 120;
|
||||
private int priLeft;
|
||||
private int priWidth = 32;
|
||||
|
||||
private GuiToolTip priorityTooltip;
|
||||
|
||||
private BasicItemFilterGui filterGui;
|
||||
|
||||
protected ItemSettings(final GuiExternalConnection gui, IConduit con) {
|
||||
super(IconEIO.WRENCH_OVERLAY_ITEM, Lang.localize("itemItemConduit.name"), gui, con);
|
||||
itemConduit = (IItemConduit) con;
|
||||
isAdvanced = itemConduit.getMetaData() == 1;
|
||||
|
||||
inputHeading = Lang.localize("gui.conduit.item.extractionFilter");
|
||||
outputHeading = Lang.localize("gui.conduit.item.insertionFilter");
|
||||
|
||||
int x = 98;
|
||||
int x = 52;
|
||||
int y = customTop;
|
||||
|
||||
nextFilterB = new IconButtonEIO(gui, NEXT_FILTER_ID, x, y, IconEIO.RIGHT_ARROW);
|
||||
nextFilterB.setSize(8, 16);
|
||||
|
||||
x = 115;
|
||||
x = 66;
|
||||
channelB = new ColorButton(gui, ID_CHANNEL, x, y);
|
||||
channelB.setColorIndex(0);
|
||||
channelB.setToolTipHeading(Lang.localize("gui.conduit.item.channel"));
|
||||
|
||||
x += channelB.getWidth() + 4;
|
||||
priLeft = x - 8;
|
||||
|
||||
rsB = new RedstoneModeButton(gui, ID_REDSTONE_BUTTON, x, y, new IRedstoneModeControlable() {
|
||||
|
||||
@Override
|
||||
@@ -131,52 +128,24 @@ public class ItemSettings extends BaseSettingsPanel {
|
||||
loopB.setUnselectedToolTip(Lang.localize("gui.conduit.item.selfFeedDisabled"));
|
||||
loopB.setPaintSelectedBorder(false);
|
||||
|
||||
x = priLeft + priWidth + 9;
|
||||
x = priLeft + priWidth + 9;
|
||||
priUpB = new IconButtonEIO(gui, ID_PRIORITY_UP, x, y, IconEIO.ADD_BUT);
|
||||
priUpB.setSize(10, 10);
|
||||
priUpB.setSize(8, 8);
|
||||
|
||||
y += 10;
|
||||
y += 8;
|
||||
priDownB = new IconButtonEIO(gui, ID_PRIORITY_DOWN, x, y, IconEIO.MINUS_BUT);
|
||||
priDownB.setSize(10, 10);
|
||||
priDownB.setSize(8, 8);
|
||||
|
||||
priorityTooltip = new GuiToolTip(new Rectangle(priLeft + 9, y, priWidth, 20), Lang.localize("gui.conduit.item.priority"));
|
||||
|
||||
x = 115;
|
||||
y = 66;
|
||||
whiteListB = new IconButtonEIO(gui, ID_WHITELIST, x, y, IconEIO.FILTER_WHITELIST);
|
||||
whiteListB.setToolTip(Lang.localize("gui.conduit.item.whitelist"));
|
||||
priorityTooltip = new GuiToolTip(new Rectangle(priLeft + 9, y, priWidth, 20), Lang.localize("gui.conduit.item.priority"));
|
||||
|
||||
x += 20;
|
||||
useMetaB = new ToggleButtonEIO(gui, ID_META, x, y, IconEIO.FILTER_META_OFF, IconEIO.FILTER_META);
|
||||
useMetaB.setSelectedToolTip(Lang.localize("gui.conduit.item.matchMetaData"));
|
||||
useMetaB.setUnselectedToolTip(Lang.localize("gui.conduit.item.ignoreMetaData"));
|
||||
useMetaB.setPaintSelectedBorder(false);
|
||||
gui.container.filterListeners.add(new FilterChangeListener() {
|
||||
|
||||
x += 20;
|
||||
stickyB = new ToggleButtonEIO(gui, ID_STICKY, x, y, IconEIO.FILTER_STICKY_OFF, IconEIO.FILTER_STICKY);
|
||||
String[] lines = Lang.localizeList("gui.conduit.item.stickyEnabled");
|
||||
stickyB.setSelectedToolTip(lines);
|
||||
stickyB.setUnselectedToolTip(Lang.localize("gui.conduit.item.stickyDisbaled"));
|
||||
stickyB.setPaintSelectedBorder(false);
|
||||
@Override
|
||||
public void onFilterChanged() {
|
||||
filtersChanged();
|
||||
}
|
||||
|
||||
y += 20;
|
||||
x = 115;
|
||||
|
||||
channelB = new ColorButton(gui, ID_CHANNEL, x, y);
|
||||
channelB.setColorIndex(0);
|
||||
channelB.setToolTipHeading(Lang.localize("gui.conduit.item.channel"));
|
||||
|
||||
x += 20;
|
||||
useNbtB = new ToggleButtonEIO(gui, ID_NBT, x, y, IconEIO.FILTER_NBT_OFF, IconEIO.FILTER_NBT);
|
||||
useNbtB.setSelectedToolTip(Lang.localize("gui.conduit.item.matchNBT"));
|
||||
useNbtB.setUnselectedToolTip(Lang.localize("gui.conduit.item.ignoreNBT"));
|
||||
useNbtB.setPaintSelectedBorder(false);
|
||||
|
||||
x += 20;
|
||||
useOreDictB = new ToggleButtonEIO(gui, ID_ORE_DICT, x, y, IconEIO.FILTER_ORE_DICT_OFF, IconEIO.FILTER_ORE_DICT);
|
||||
useOreDictB.setSelectedToolTip(Lang.localize("gui.conduit.item.oreDicEnabled"));
|
||||
useOreDictB.setUnselectedToolTip(Lang.localize("gui.conduit.item.oreDicDisabled"));
|
||||
useOreDictB.setPaintSelectedBorder(false);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@@ -208,15 +177,10 @@ public class ItemSettings extends BaseSettingsPanel {
|
||||
|
||||
ConnectionMode mode = con.getConectionMode(gui.dir);
|
||||
if(mode == ConnectionMode.INPUT) {
|
||||
showInput = true;
|
||||
gui.container.setInputSlotsVisible(true);
|
||||
gui.container.setOutputSlotsVisible(false);
|
||||
gui.container.setInventorySlotsVisible(true);
|
||||
showInput = true;
|
||||
} else if(mode == ConnectionMode.OUTPUT) {
|
||||
showOutput = true;
|
||||
gui.container.setInputSlotsVisible(false);
|
||||
gui.container.setOutputSlotsVisible(true);
|
||||
gui.container.setInventorySlotsVisible(true);
|
||||
|
||||
} else if(mode == ConnectionMode.IN_OUT) {
|
||||
|
||||
if(nextFilterB != null) {
|
||||
@@ -228,17 +192,24 @@ public class ItemSettings extends BaseSettingsPanel {
|
||||
}
|
||||
|
||||
if(!showInput && !showOutput) {
|
||||
filterGui = null;
|
||||
activeFilter = null;
|
||||
} else {
|
||||
} else if(showInput) {
|
||||
activeFilter = itemConduit.getInputFilter(gui.dir);
|
||||
gui.container.setInventorySlotsVisible(true);
|
||||
if(showInput) {
|
||||
activeFilter = itemConduit.getInputFilter(gui.dir);
|
||||
gui.container.setInputSlotsVisible(true);
|
||||
gui.container.setOutputSlotsVisible(false);
|
||||
} else {
|
||||
activeFilter = itemConduit.getOutputFilter(gui.dir);
|
||||
gui.container.setInputSlotsVisible(false);
|
||||
gui.container.setOutputSlotsVisible(true);
|
||||
gui.container.setInputSlotsVisible(true);
|
||||
gui.container.setOutputSlotsVisible(false);
|
||||
if(activeFilter != null) {
|
||||
filterGui = new BasicItemFilterGui(gui, itemConduit, true);
|
||||
|
||||
}
|
||||
} else if(showOutput) {
|
||||
activeFilter = itemConduit.getOutputFilter(gui.dir);
|
||||
gui.container.setInputSlotsVisible(false);
|
||||
gui.container.setOutputSlotsVisible(true);
|
||||
gui.container.setInventorySlotsVisible(true);
|
||||
if(activeFilter != null) {
|
||||
filterGui = new BasicItemFilterGui(gui, itemConduit, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,54 +217,59 @@ public class ItemSettings extends BaseSettingsPanel {
|
||||
|
||||
}
|
||||
|
||||
private void updateButtons() {
|
||||
if(activeFilter == null || useNbtB == null) {
|
||||
return;
|
||||
private void filtersChanged() {
|
||||
if(filterGui != null) {
|
||||
filterGui.deactivate();
|
||||
filterGui = null;
|
||||
}
|
||||
|
||||
ConnectionMode mode = con.getConectionMode(gui.dir);
|
||||
if(mode == ConnectionMode.DISABLED) {
|
||||
return;
|
||||
}
|
||||
boolean outputActive = (mode == ConnectionMode.IN_OUT && !inOutShowIn) || (mode == ConnectionMode.OUTPUT);
|
||||
int chanCol;
|
||||
if(outputActive) {
|
||||
stickyB.onGuiInit();
|
||||
stickyB.setSelected(activeFilter.isSticky());
|
||||
|
||||
chanCol = itemConduit.getOutputColor(gui.dir).ordinal();
|
||||
boolean showInput = mode == ConnectionMode.INPUT || (mode == ConnectionMode.IN_OUT && inOutShowIn);
|
||||
if(showInput) {
|
||||
gui.container.setInventorySlotsVisible(true);
|
||||
gui.container.setInputSlotsVisible(true);
|
||||
gui.container.setOutputSlotsVisible(false);
|
||||
|
||||
activeFilter = itemConduit.getInputFilter(gui.dir);
|
||||
if(activeFilter != null) {
|
||||
filterGui = new BasicItemFilterGui(gui, itemConduit, true);
|
||||
}
|
||||
} else {
|
||||
gui.container.setInventorySlotsVisible(true);
|
||||
gui.container.setInputSlotsVisible(false);
|
||||
gui.container.setOutputSlotsVisible(true);
|
||||
|
||||
activeFilter = itemConduit.getOutputFilter(gui.dir);
|
||||
if(activeFilter != null) {
|
||||
filterGui = new BasicItemFilterGui(gui, itemConduit, false);
|
||||
}
|
||||
|
||||
}
|
||||
if(filterGui != null) {
|
||||
filterGui.updateButtons();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void updateButtons() {
|
||||
|
||||
ConnectionMode mode = con.getConectionMode(gui.dir);
|
||||
if(mode == ConnectionMode.DISABLED) {
|
||||
return;
|
||||
}
|
||||
boolean outputActive = (mode == ConnectionMode.IN_OUT && !inOutShowIn) || (mode == ConnectionMode.OUTPUT);
|
||||
|
||||
if(!outputActive) {
|
||||
|
||||
rsB.onGuiInit();
|
||||
rsB.setMode(itemConduit.getExtractionRedstoneMode(gui.dir));
|
||||
|
||||
colorB.onGuiInit();
|
||||
colorB.setColorIndex(itemConduit.getExtractionSignalColor(gui.dir).ordinal());
|
||||
|
||||
chanCol = itemConduit.getInputColor(gui.dir).ordinal();
|
||||
}
|
||||
|
||||
channelB.onGuiInit();
|
||||
channelB.setColorIndex(chanCol);
|
||||
|
||||
if(isAdvanced) {
|
||||
useNbtB.onGuiInit();
|
||||
useNbtB.setSelected(activeFilter.isMatchNBT());
|
||||
|
||||
useOreDictB.onGuiInit();
|
||||
useOreDictB.setSelected(activeFilter.isUseOreDict());
|
||||
}
|
||||
|
||||
useMetaB.onGuiInit();
|
||||
useMetaB.setSelected(activeFilter.isMatchMeta());
|
||||
|
||||
whiteListB.onGuiInit();
|
||||
if(activeFilter.isBlacklist()) {
|
||||
whiteListB.setIcon(IconEIO.FILTER_BLACKLIST);
|
||||
whiteListB.setToolTip(Lang.localize("gui.conduit.item.blacklist"));
|
||||
} else {
|
||||
whiteListB.setIcon(IconEIO.FILTER_WHITELIST);
|
||||
whiteListB.setToolTip(Lang.localize("gui.conduit.item.whitelist"));
|
||||
}
|
||||
|
||||
if(mode == ConnectionMode.IN_OUT && !outputActive) {
|
||||
@@ -311,6 +287,19 @@ public class ItemSettings extends BaseSettingsPanel {
|
||||
priDownB.onGuiInit();
|
||||
gui.addToolTip(priorityTooltip);
|
||||
}
|
||||
|
||||
int chanCol;
|
||||
if(!outputActive) {
|
||||
chanCol = itemConduit.getInputColor(gui.dir).ordinal();
|
||||
} else {
|
||||
chanCol = itemConduit.getOutputColor(gui.dir).ordinal();
|
||||
}
|
||||
channelB.onGuiInit();
|
||||
channelB.setColorIndex(chanCol);
|
||||
|
||||
if(filterGui != null) {
|
||||
filterGui.updateButtons();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -320,78 +309,44 @@ public class ItemSettings extends BaseSettingsPanel {
|
||||
if(guiButton.id == NEXT_FILTER_ID) {
|
||||
inOutShowIn = !inOutShowIn;
|
||||
updateGuiVisibility();
|
||||
}
|
||||
|
||||
if(activeFilter == null) {
|
||||
return;
|
||||
}
|
||||
if(guiButton.id == ID_META) {
|
||||
activeFilter.setMatchMeta(useMetaB.isSelected());
|
||||
sendFilterChange();
|
||||
} else if(guiButton.id == ID_NBT) {
|
||||
activeFilter.setMatchNBT(useNbtB.isSelected());
|
||||
sendFilterChange();
|
||||
} else if(guiButton.id == ID_STICKY) {
|
||||
activeFilter.setSticky(stickyB.isSelected());
|
||||
sendFilterChange();
|
||||
} else if(guiButton.id == ID_ORE_DICT) {
|
||||
activeFilter.setUseOreDict(useOreDictB.isSelected());
|
||||
sendFilterChange();
|
||||
} else if(guiButton.id == ID_WHITELIST) {
|
||||
activeFilter.setBlacklist(!activeFilter.isBlacklist());
|
||||
sendFilterChange();
|
||||
} else if(guiButton.id == ID_COLOR_BUTTON) {
|
||||
|
||||
itemConduit.setExtractionSignalColor(gui.dir, DyeColor.values()[colorB.getColorIndex()]);
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketExtractMode(itemConduit, gui.dir));
|
||||
|
||||
} else if(guiButton.id == ID_LOOP) {
|
||||
itemConduit.setSelfFeedEnabled(gui.dir, !itemConduit.isSelfFeedEnabled(gui.dir));
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketItemConduitFilter(itemConduit, gui.dir));
|
||||
|
||||
} else if(guiButton.id == ID_ROUND_ROBIN) {
|
||||
itemConduit.setRoundRobinEnabled(gui.dir, !itemConduit.isRoundRobinEnabled(gui.dir));
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketItemConduitFilter(itemConduit, gui.dir));
|
||||
|
||||
} else if(guiButton.id == ID_PRIORITY_UP) {
|
||||
itemConduit.setOutputPriority(gui.dir, itemConduit.getOutputPriority(gui.dir) + 1);
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketItemConduitFilter(itemConduit, gui.dir));
|
||||
|
||||
} else if(guiButton.id == ID_PRIORITY_DOWN) {
|
||||
itemConduit.setOutputPriority(gui.dir, itemConduit.getOutputPriority(gui.dir) - 1);
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketItemConduitFilter(itemConduit, gui.dir));
|
||||
|
||||
} else if(guiButton.id == ID_CHANNEL) {
|
||||
|
||||
ConnectionMode mode = con.getConectionMode(gui.dir);
|
||||
if(mode == ConnectionMode.IN_OUT) {
|
||||
mode = inOutShowIn ? ConnectionMode.INPUT : ConnectionMode.OUTPUT;
|
||||
}
|
||||
|
||||
DyeColor col = DyeColor.values()[channelB.getColorIndex()];
|
||||
DyeColor col = DyeColor.values()[channelB.getColorIndex()];
|
||||
boolean input;
|
||||
if(mode == ConnectionMode.INPUT) {
|
||||
if(isInputVisible()) {
|
||||
col = DyeColor.values()[channelB.getColorIndex()];
|
||||
itemConduit.setInputColor(gui.dir, col);
|
||||
input = true;
|
||||
} else if(mode == ConnectionMode.OUTPUT) {
|
||||
} else {
|
||||
itemConduit.setOutputColor(gui.dir, DyeColor.values()[channelB.getColorIndex()]);
|
||||
input = false;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketItemConduitFilter(itemConduit, gui.dir));
|
||||
}
|
||||
|
||||
if(filterGui != null) {
|
||||
filterGui.actionPerformed(guiButton);
|
||||
}
|
||||
}
|
||||
|
||||
private void sendFilterChange() {
|
||||
updateButtons();
|
||||
|
||||
if(activeFilter != null) {
|
||||
ConnectionMode mode = con.getConectionMode(gui.dir);
|
||||
boolean inputActive = (mode == ConnectionMode.IN_OUT && inOutShowIn) || (mode == ConnectionMode.INPUT);
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketItemConduitFilter(itemConduit, gui.dir));
|
||||
}
|
||||
private boolean isInputVisible() {
|
||||
ConnectionMode mode = con.getConectionMode(gui.dir);
|
||||
return (mode == ConnectionMode.IN_OUT && inOutShowIn) || (mode == ConnectionMode.INPUT);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -403,29 +358,42 @@ public class ItemSettings extends BaseSettingsPanel {
|
||||
@Override
|
||||
protected void renderCustomOptions(int top, float par1, int par2, int par3) {
|
||||
ConnectionMode mode = con.getConectionMode(gui.dir);
|
||||
if(mode != ConnectionMode.DISABLED) {
|
||||
if(itemConduit.getMetaData() == 0) {
|
||||
RenderUtil.bindTexture("enderio:textures/gui/itemFilter.png");
|
||||
} else {
|
||||
RenderUtil.bindTexture("enderio:textures/gui/itemFilterAdvanced.png");
|
||||
}
|
||||
gui.drawTexturedModalRect(gui.getGuiLeft(), gui.getGuiTop() + 55, 0, 55, gui.getXSize(), 145);
|
||||
if(mode == ConnectionMode.DISABLED) {
|
||||
return;
|
||||
}
|
||||
|
||||
FontRenderer fr = gui.getFontRenderer();
|
||||
String heading = getHeading();
|
||||
int headingWidth = fr.getStringWidth(heading);
|
||||
int x = 0;
|
||||
int rgb = ColorUtil.getRGB(Color.darkGray);
|
||||
fr.drawString(heading, left + x, top, rgb);
|
||||
|
||||
boolean outputActive = (mode == ConnectionMode.IN_OUT && !inOutShowIn) || (mode == ConnectionMode.OUTPUT);
|
||||
if(outputActive) {
|
||||
GL11.glColor3f(1, 1, 1);
|
||||
IconEIO.BUTTON_DOWN.renderIcon(left + priLeft, top - 5, priWidth, 20, 0, true);
|
||||
String str = itemConduit.getOutputPriority(gui.dir) + "";
|
||||
int sw = fr.getStringWidth(str);
|
||||
fr.drawString(str, left + priLeft + priWidth - sw - gap, top, ColorUtil.getRGB(Color.black));
|
||||
}
|
||||
RenderUtil.bindTexture("enderio:textures/gui/itemFilter.png");
|
||||
gui.drawTexturedModalRect(gui.getGuiLeft(), gui.getGuiTop() + 55, 0, 55, gui.getXSize(), 145);
|
||||
|
||||
FontRenderer fr = gui.getFontRenderer();
|
||||
String heading = getHeading();
|
||||
int headingWidth = fr.getStringWidth(heading);
|
||||
int x = 0;
|
||||
int rgb = ColorUtil.getRGB(Color.darkGray);
|
||||
fr.drawString(heading, left + x, top, rgb);
|
||||
|
||||
boolean outputActive = (mode == ConnectionMode.IN_OUT && !inOutShowIn) || (mode == ConnectionMode.OUTPUT);
|
||||
if(outputActive) {
|
||||
GL11.glColor3f(1, 1, 1);
|
||||
IconEIO.BUTTON_DOWN.renderIcon(left + priLeft, top - 5, priWidth, 16, 0, true);
|
||||
String str = itemConduit.getOutputPriority(gui.dir) + "";
|
||||
int sw = fr.getStringWidth(str);
|
||||
fr.drawString(str, left + priLeft + priWidth - sw - gap, top, ColorUtil.getRGB(Color.black));
|
||||
|
||||
} else {
|
||||
//draw speed upgrade slot
|
||||
GL11.glColor3f(1, 1, 1);
|
||||
RenderUtil.bindTexture("enderio:textures/gui/itemFilter.png");
|
||||
gui.drawTexturedModalRect(gui.getGuiLeft() + 9 + 18, gui.getGuiTop() + 46, 94, 238, 18, 18);
|
||||
}
|
||||
|
||||
//filter upgrade slot
|
||||
GL11.glColor3f(1, 1, 1);
|
||||
RenderUtil.bindTexture("enderio:textures/gui/itemFilter.png");
|
||||
gui.drawTexturedModalRect(gui.getGuiLeft() + 9, gui.getGuiTop() + 46, 94, 220, 18, 18);
|
||||
|
||||
if(filterGui != null) {
|
||||
filterGui.renderCustomOptions(top, par1, par2, par3);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -437,18 +405,18 @@ public class ItemSettings extends BaseSettingsPanel {
|
||||
gui.container.setOutputSlotsVisible(false);
|
||||
rsB.detach();
|
||||
colorB.detach();
|
||||
channelB.detach();
|
||||
useNbtB.detach();
|
||||
useMetaB.detach();
|
||||
useOreDictB.detach();
|
||||
whiteListB.detach();
|
||||
stickyB.detach();
|
||||
roundRobinB.detach();
|
||||
loopB.detach();
|
||||
nextFilterB.detach();
|
||||
priUpB.detach();
|
||||
priDownB.detach();
|
||||
gui.removeToolTip(priorityTooltip);
|
||||
gui.removeToolTip(priorityTooltip);
|
||||
channelB.detach();
|
||||
|
||||
if(filterGui != null) {
|
||||
filterGui.deactivate();
|
||||
filterGui = null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package crazypants.enderio.conduit.item;
|
||||
|
||||
import cpw.mods.fml.common.network.ByteBufUtils;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import crazypants.enderio.Log;
|
||||
import crazypants.enderio.network.NetworkUtil;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public class FilterRegister {
|
||||
|
||||
public static void writeFilter(ByteBuf buf, IItemFilter filter) {
|
||||
if(filter == null) {
|
||||
ByteBufUtils.writeUTF8String(buf, "nullFilter");
|
||||
return;
|
||||
}
|
||||
String name = filter.getClass().getName();
|
||||
ByteBufUtils.writeUTF8String(buf, name);
|
||||
|
||||
NBTTagCompound root = new NBTTagCompound();
|
||||
filter.writeToNBT(root);
|
||||
NetworkUtil.writeNBTTagCompound(root, buf);
|
||||
}
|
||||
|
||||
public static IItemFilter readFilter(ByteBuf buf) {
|
||||
String className = ByteBufUtils.readUTF8String(buf);
|
||||
if(className.equals("nullFilter")) {
|
||||
return null;
|
||||
}
|
||||
NBTTagCompound tag = NetworkUtil.readNBTTagCompound(buf);
|
||||
try {
|
||||
Class<?> clz = Class.forName(className);
|
||||
IItemFilter filter = (IItemFilter) clz.newInstance();
|
||||
filter.readFromNBT(tag);
|
||||
return filter;
|
||||
} catch (Exception e) {
|
||||
Log.error("Could not read item filter: " + e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static IItemFilter getFilterForUpgrade(ItemStack stack) {
|
||||
if(stack == null) {
|
||||
return null;
|
||||
}
|
||||
if( ! (stack.getItem() instanceof IItemFilterUpgrade) ) {
|
||||
return null;
|
||||
}
|
||||
IItemFilterUpgrade upgrade = (IItemFilterUpgrade)stack.getItem();
|
||||
IItemFilter res = upgrade.createFilterFromStack(stack);
|
||||
return res;
|
||||
}
|
||||
|
||||
public static void loadFilterFromStack(IItemFilter filter, ItemStack stack) {
|
||||
if(stack != null && stack.stackTagCompound != null && stack.stackTagCompound.hasKey("filter")) {
|
||||
filter.readFromNBT(stack.stackTagCompound.getCompoundTag("filter"));
|
||||
}
|
||||
}
|
||||
|
||||
public static void writeFilterToStack(IItemFilter filter, ItemStack stack) {
|
||||
if(stack == null || filter == null) {
|
||||
return;
|
||||
}
|
||||
NBTTagCompound filterRoot = new NBTTagCompound();
|
||||
filter.writeToNBT(filterRoot);
|
||||
if(stack.stackTagCompound == null) {
|
||||
stack.stackTagCompound = new NBTTagCompound();
|
||||
}
|
||||
stack.stackTagCompound.setTag("filter", filterRoot);
|
||||
}
|
||||
|
||||
public static boolean isFilterSet(ItemStack stack) {
|
||||
return stack != null && stack.stackTagCompound != null && stack.stackTagCompound.hasKey("filter");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package crazypants.enderio.conduit.item;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import cofh.api.transport.IItemDuct;
|
||||
@@ -22,19 +23,31 @@ public interface IItemConduit extends IConduit, IItemDuct, IExtractor {
|
||||
|
||||
IInventory getExternalInventory(ForgeDirection direction);
|
||||
|
||||
int getMaximumExtracted();
|
||||
int getMaximumExtracted(ForgeDirection direction);
|
||||
|
||||
float getTickTimePerItem();
|
||||
float getTickTimePerItem(ForgeDirection direction);
|
||||
|
||||
void itemsExtracted(int numInserted, int slot);
|
||||
|
||||
void setInputFilterUpgrade(ForgeDirection dir, ItemStack stack);
|
||||
|
||||
void setInputFilter(ForgeDirection dir, ItemFilter filter);
|
||||
void setOutputFilterUpgrade(ForgeDirection dir, ItemStack stack);
|
||||
|
||||
void setOutputFilter(ForgeDirection dir, ItemFilter filter);
|
||||
ItemStack getInputFilterUpgrade(ForgeDirection dir);
|
||||
|
||||
ItemFilter getInputFilter(ForgeDirection dir);
|
||||
ItemStack getOutputFilterUpgrade(ForgeDirection dir);
|
||||
|
||||
ItemFilter getOutputFilter(ForgeDirection dir);
|
||||
void setInputFilter(ForgeDirection dir, IItemFilter filter);
|
||||
|
||||
void setOutputFilter(ForgeDirection dir, IItemFilter filter);
|
||||
|
||||
IItemFilter getInputFilter(ForgeDirection dir);
|
||||
|
||||
IItemFilter getOutputFilter(ForgeDirection dir);
|
||||
|
||||
void setSpeedUpgrade(ForgeDirection dir, ItemStack upgrade);
|
||||
|
||||
ItemStack getSpeedUpgrade(ForgeDirection dir);
|
||||
|
||||
int getOutputPriority(ForgeDirection dir);
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package crazypants.enderio.conduit.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public interface IItemFilter {
|
||||
|
||||
void readFromNBT(NBTTagCompound nbtRoot);
|
||||
|
||||
void writeToNBT(NBTTagCompound nbtRoot);
|
||||
|
||||
boolean doesItemPassFilter(ItemStack item);
|
||||
|
||||
boolean doesFilterCaptureStack(ItemStack item);
|
||||
|
||||
boolean isValid();
|
||||
|
||||
boolean isSticky();
|
||||
|
||||
List<Slot> getSlots();
|
||||
|
||||
int getSlotCount();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package crazypants.enderio.conduit.item;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IItemFilterUpgrade {
|
||||
|
||||
IItemFilter createFilterFromStack(ItemStack stack);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package crazypants.enderio.conduit.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.EnderIOTab;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.util.Lang;
|
||||
|
||||
public class ItemBasicItemFilter extends Item implements IItemFilterUpgrade {
|
||||
|
||||
public static ItemBasicItemFilter create() {
|
||||
ItemBasicItemFilter result = new ItemBasicItemFilter();
|
||||
result.init();
|
||||
return result;
|
||||
}
|
||||
|
||||
private final IIcon[] icons;
|
||||
|
||||
protected ItemBasicItemFilter() {
|
||||
setCreativeTab(EnderIOTab.tabEnderIO);
|
||||
setUnlocalizedName(ModObject.itemBasicFilterUpgrade.unlocalisedName);
|
||||
setHasSubtypes(true);
|
||||
setMaxDamage(0);
|
||||
setMaxStackSize(64);
|
||||
|
||||
icons = new IIcon[2];
|
||||
}
|
||||
|
||||
protected void init() {
|
||||
GameRegistry.registerItem(this, ModObject.itemBasicFilterUpgrade.unlocalisedName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemFilter createFilterFromStack(ItemStack stack) {
|
||||
int damage = MathHelper.clamp_int(stack.getItemDamage(), 0, 1);
|
||||
ItemFilter filter;
|
||||
if(damage == 0) {
|
||||
filter = new ItemFilter(false);
|
||||
} else {
|
||||
filter = new ItemFilter(true);
|
||||
}
|
||||
FilterRegister.loadFilterFromStack(filter, stack);
|
||||
return filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIconFromDamage(int damage) {
|
||||
damage = MathHelper.clamp_int(damage, 0, 1);
|
||||
return icons[damage];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IIconRegister IIconRegister) {
|
||||
|
||||
icons[0] = IIconRegister.registerIcon("enderio:filterUpgradeBasic");
|
||||
icons[1] = IIconRegister.registerIcon("enderio:filterUpgradeAdvanced");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack par1ItemStack) {
|
||||
int i = MathHelper.clamp_int(par1ItemStack.getItemDamage(), 0, 1);
|
||||
return i == 0 ? "enderio.filterUpgradeBasic" : "enderio.filterUpgradeAdvanced";
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
|
||||
for (int j = 0; j < 2; ++j) {
|
||||
par3List.add(new ItemStack(this, 1, j));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {
|
||||
par3List.add(Lang.localize("itemConduitFilterUpgrade"));
|
||||
if(FilterRegister.isFilterSet(par1ItemStack)) {
|
||||
par3List.add(EnumChatFormatting.ITALIC + Lang.localize("itemConduitFilterUpgrade.configured"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package crazypants.enderio.conduit.item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -81,14 +83,17 @@ public class ItemConduit extends AbstractConduit implements IItemConduit {
|
||||
|
||||
ItemConduitNetwork network;
|
||||
|
||||
int maxExtractedOnTick = 2;
|
||||
float extractRatePerTick = maxExtractedOnTick / 20f;
|
||||
// int maxExtractedOnTick = 2;
|
||||
// float extractRatePerTick = maxExtractedOnTick / 20f;
|
||||
|
||||
protected final EnumMap<ForgeDirection, RedstoneControlMode> extractionModes = new EnumMap<ForgeDirection, RedstoneControlMode>(ForgeDirection.class);
|
||||
protected final EnumMap<ForgeDirection, DyeColor> extractionColors = new EnumMap<ForgeDirection, DyeColor>(ForgeDirection.class);
|
||||
|
||||
protected final EnumMap<ForgeDirection, ItemFilter> outputFilters = new EnumMap<ForgeDirection, ItemFilter>(ForgeDirection.class);
|
||||
protected final EnumMap<ForgeDirection, ItemFilter> inputFilters = new EnumMap<ForgeDirection, ItemFilter>(ForgeDirection.class);
|
||||
protected final EnumMap<ForgeDirection, IItemFilter> outputFilters = new EnumMap<ForgeDirection, IItemFilter>(ForgeDirection.class);
|
||||
protected final EnumMap<ForgeDirection, IItemFilter> inputFilters = new EnumMap<ForgeDirection, IItemFilter>(ForgeDirection.class);
|
||||
protected final EnumMap<ForgeDirection, ItemStack> outputFilterUpgrades = new EnumMap<ForgeDirection, ItemStack>(ForgeDirection.class);
|
||||
protected final EnumMap<ForgeDirection, ItemStack> inputFilterUpgrades = new EnumMap<ForgeDirection, ItemStack>(ForgeDirection.class);
|
||||
protected final EnumMap<ForgeDirection, ItemStack> speedUpgrades = new EnumMap<ForgeDirection, ItemStack>(ForgeDirection.class);
|
||||
|
||||
protected final EnumMap<ForgeDirection, Boolean> selfFeed = new EnumMap<ForgeDirection, Boolean>(ForgeDirection.class);
|
||||
|
||||
@@ -112,12 +117,50 @@ public class ItemConduit extends AbstractConduit implements IItemConduit {
|
||||
|
||||
private void updateFromMetadata() {
|
||||
if(metaData == 1) {
|
||||
maxExtractedOnTick = 64;
|
||||
extractRatePerTick = (4 * 64) / 20f; //4 stacks a second
|
||||
|
||||
for (Entry<ForgeDirection, IItemFilter> entry : inputFilters.entrySet()) {
|
||||
if(entry.getValue() != null) {
|
||||
IItemFilter f = entry.getValue();
|
||||
if(!isDefault(f)) {
|
||||
setSpeedUpgrade(entry.getKey(), new ItemStack(EnderIO.itemExtractSpeedUpgrade, 4, 0));
|
||||
setInputFilterUpgrade(entry.getKey(), new ItemStack(EnderIO.itemBasicFilterUpgrade, 1, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (Entry<ForgeDirection, IItemFilter> entry : inputFilters.entrySet()) {
|
||||
if(entry.getValue() != null) {
|
||||
IItemFilter f = entry.getValue();
|
||||
if(!isDefault(f)) {
|
||||
setOutputFilterUpgrade(entry.getKey(), new ItemStack(EnderIO.itemBasicFilterUpgrade, 1, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
metaData = 0;
|
||||
|
||||
//maxExtractedOnTick = 64;
|
||||
//extractRatePerTick = (4 * 64) / 20f; //4 stacks a second
|
||||
} else {
|
||||
maxExtractedOnTick = 1;
|
||||
extractRatePerTick = 0.2f; //four items a second
|
||||
//maxExtractedOnTick = 1;
|
||||
//extractRatePerTick = 0.2f; //four items a second
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops() {
|
||||
List<ItemStack> res = new ArrayList<ItemStack>();
|
||||
res.add(createItem());
|
||||
for(ItemStack stack : speedUpgrades.values()) {
|
||||
res.add(stack);
|
||||
}
|
||||
for(ItemStack stack : inputFilterUpgrades.values()) {
|
||||
res.add(stack);
|
||||
}
|
||||
for(ItemStack stack : outputFilterUpgrades.values()) {
|
||||
res.add(stack);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -178,27 +221,70 @@ public class ItemConduit extends AbstractConduit implements IItemConduit {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInputFilter(ForgeDirection dir, ItemFilter filter) {
|
||||
public void setInputFilter(ForgeDirection dir, IItemFilter filter) {
|
||||
inputFilters.put(dir, filter);
|
||||
if(network != null) {
|
||||
network.routesChanged();
|
||||
}
|
||||
setClientStateDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOutputFilter(ForgeDirection dir, ItemFilter filter) {
|
||||
public void setOutputFilter(ForgeDirection dir, IItemFilter filter) {
|
||||
outputFilters.put(dir, filter);
|
||||
if(network != null) {
|
||||
network.routesChanged();
|
||||
}
|
||||
|
||||
setClientStateDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemFilter getInputFilter(ForgeDirection dir) {
|
||||
ItemFilter res = inputFilters.get(dir);
|
||||
if(res == null) {
|
||||
res = new ItemFilter();
|
||||
inputFilters.put(dir, res);
|
||||
public IItemFilter getInputFilter(ForgeDirection dir) {
|
||||
return inputFilters.get(dir);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemFilter getOutputFilter(ForgeDirection dir) {
|
||||
return outputFilters.get(dir);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInputFilterUpgrade(ForgeDirection dir, ItemStack stack) {
|
||||
inputFilterUpgrades.put(dir, stack);
|
||||
setInputFilter(dir, FilterRegister.getFilterForUpgrade(stack));
|
||||
setClientStateDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOutputFilterUpgrade(ForgeDirection dir, ItemStack stack) {
|
||||
outputFilterUpgrades.put(dir, stack);
|
||||
setOutputFilter(dir, FilterRegister.getFilterForUpgrade(stack));
|
||||
setClientStateDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getInputFilterUpgrade(ForgeDirection dir) {
|
||||
return inputFilterUpgrades.get(dir);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getOutputFilterUpgrade(ForgeDirection dir) {
|
||||
return outputFilterUpgrades.get(dir);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSpeedUpgrade(ForgeDirection dir, ItemStack upgrade) {
|
||||
if(upgrade != null) {
|
||||
speedUpgrades.put(dir, upgrade);
|
||||
} else {
|
||||
speedUpgrades.remove(dir);
|
||||
}
|
||||
return res;
|
||||
setClientStateDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getSpeedUpgrade(ForgeDirection dir) {
|
||||
return speedUpgrades.get(dir);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -206,16 +292,6 @@ public class ItemConduit extends AbstractConduit implements IItemConduit {
|
||||
return metaData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemFilter getOutputFilter(ForgeDirection dir) {
|
||||
ItemFilter res = outputFilters.get(dir);
|
||||
if(res == null) {
|
||||
res = new ItemFilter();
|
||||
outputFilters.put(dir, res);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExtractionRedstoneMode(RedstoneControlMode mode, ForgeDirection dir) {
|
||||
extractionModes.put(dir, mode);
|
||||
@@ -292,13 +368,26 @@ public class ItemConduit extends AbstractConduit implements IItemConduit {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumExtracted() {
|
||||
return maxExtractedOnTick;
|
||||
public int getMaximumExtracted(ForgeDirection dir) {
|
||||
int numUpgrades = getNumSpeedUpgrades(dir);
|
||||
int res = (int)Math.pow(4, numUpgrades);
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTickTimePerItem() {
|
||||
return 1f / extractRatePerTick;
|
||||
public float getTickTimePerItem(ForgeDirection dir) {
|
||||
int numUpgrades = getNumSpeedUpgrades(dir);
|
||||
float maxExtract = 10f / getMaximumExtracted(dir);
|
||||
return maxExtract;
|
||||
|
||||
}
|
||||
|
||||
private int getNumSpeedUpgrades(ForgeDirection dir) {
|
||||
ItemStack stack = speedUpgrades.get(dir);
|
||||
if(stack == null) {
|
||||
return 0;
|
||||
}
|
||||
return stack.stackSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -361,7 +450,11 @@ public class ItemConduit extends AbstractConduit implements IItemConduit {
|
||||
|
||||
@Override
|
||||
public void setSelfFeedEnabled(ForgeDirection dir, boolean enabled) {
|
||||
selfFeed.put(dir, enabled);
|
||||
if(!enabled) {
|
||||
selfFeed.remove(dir);
|
||||
} else {
|
||||
selfFeed.put(dir, enabled);
|
||||
}
|
||||
if(network != null) {
|
||||
network.routesChanged();
|
||||
}
|
||||
@@ -378,7 +471,11 @@ public class ItemConduit extends AbstractConduit implements IItemConduit {
|
||||
|
||||
@Override
|
||||
public void setRoundRobinEnabled(ForgeDirection dir, boolean enabled) {
|
||||
roundRobin.put(dir, enabled);
|
||||
if(!enabled) {
|
||||
roundRobin.remove(dir);
|
||||
} else {
|
||||
roundRobin.put(dir, enabled);
|
||||
}
|
||||
if(network != null) {
|
||||
network.routesChanged();
|
||||
}
|
||||
@@ -395,7 +492,11 @@ public class ItemConduit extends AbstractConduit implements IItemConduit {
|
||||
|
||||
@Override
|
||||
public void setOutputPriority(ForgeDirection dir, int priority) {
|
||||
this.priority.put(dir, priority);
|
||||
if(priority == 0) {
|
||||
this.priority.remove(dir);
|
||||
} else {
|
||||
this.priority.put(dir, priority);
|
||||
}
|
||||
if(network != null) {
|
||||
network.routesChanged();
|
||||
}
|
||||
@@ -491,27 +592,60 @@ public class ItemConduit extends AbstractConduit implements IItemConduit {
|
||||
|
||||
nbtRoot.setShort("metaData", (short) metaData);
|
||||
|
||||
for (Entry<ForgeDirection, ItemFilter> entry : inputFilters.entrySet()) {
|
||||
for (Entry<ForgeDirection, IItemFilter> entry : inputFilters.entrySet()) {
|
||||
if(entry.getValue() != null) {
|
||||
ItemFilter f = entry.getValue();
|
||||
if(!f.isDefault()) {
|
||||
IItemFilter f = entry.getValue();
|
||||
if(!isDefault(f)) {
|
||||
NBTTagCompound itemRoot = new NBTTagCompound();
|
||||
f.writeToNBT(itemRoot);
|
||||
nbtRoot.setTag("inFilts." + entry.getKey().name(), itemRoot);
|
||||
nbtRoot.setTag("inFilts." + entry.getKey().name(), itemRoot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (Entry<ForgeDirection, ItemFilter> entry : outputFilters.entrySet()) {
|
||||
for (Entry<ForgeDirection, ItemStack> entry : speedUpgrades.entrySet()) {
|
||||
if(entry.getValue() != null) {
|
||||
ItemFilter f = entry.getValue();
|
||||
if(!f.isDefault()) {
|
||||
ItemStack up = entry.getValue();
|
||||
NBTTagCompound itemRoot = new NBTTagCompound();
|
||||
up.writeToNBT(itemRoot);
|
||||
nbtRoot.setTag("speedUpgrades." + entry.getKey().name(), itemRoot);
|
||||
}
|
||||
}
|
||||
|
||||
for (Entry<ForgeDirection, IItemFilter> entry : outputFilters.entrySet()) {
|
||||
if(entry.getValue() != null) {
|
||||
IItemFilter f = entry.getValue();
|
||||
if(!isDefault(f)) {
|
||||
NBTTagCompound itemRoot = new NBTTagCompound();
|
||||
f.writeToNBT(itemRoot);
|
||||
nbtRoot.setTag("outFilts." + entry.getKey().name(), itemRoot);
|
||||
nbtRoot.setTag("outFilts." + entry.getKey().name(), itemRoot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (Entry<ForgeDirection, ItemStack> entry : inputFilterUpgrades.entrySet()) {
|
||||
if(entry.getValue() != null) {
|
||||
ItemStack up = entry.getValue();
|
||||
IItemFilter filter = getInputFilter(entry.getKey());
|
||||
FilterRegister.writeFilterToStack(filter, up);
|
||||
|
||||
NBTTagCompound itemRoot = new NBTTagCompound();
|
||||
up.writeToNBT(itemRoot);
|
||||
nbtRoot.setTag("inputFilterUpgrades." + entry.getKey().name(), itemRoot);
|
||||
}
|
||||
}
|
||||
|
||||
for (Entry<ForgeDirection, ItemStack> entry : outputFilterUpgrades.entrySet()) {
|
||||
if(entry.getValue() != null) {
|
||||
ItemStack up = entry.getValue();
|
||||
IItemFilter filter = getOutputFilter(entry.getKey());
|
||||
FilterRegister.writeFilterToStack(filter, up);
|
||||
|
||||
NBTTagCompound itemRoot = new NBTTagCompound();
|
||||
up.writeToNBT(itemRoot);
|
||||
nbtRoot.setTag("outputFilterUpgrades." + entry.getKey().name(), itemRoot);
|
||||
}
|
||||
}
|
||||
|
||||
for (Entry<ForgeDirection, RedstoneControlMode> entry : extractionModes.entrySet()) {
|
||||
if(entry.getValue() != null) {
|
||||
@@ -538,7 +672,7 @@ public class ItemConduit extends AbstractConduit implements IItemConduit {
|
||||
nbtRoot.setBoolean("roundRobin." + entry.getKey().name(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (Entry<ForgeDirection, Integer> entry : priority.entrySet()) {
|
||||
if(entry.getValue() != null) {
|
||||
nbtRoot.setInteger("priority." + entry.getKey().name(), entry.getValue());
|
||||
@@ -561,6 +695,13 @@ public class ItemConduit extends AbstractConduit implements IItemConduit {
|
||||
|
||||
}
|
||||
|
||||
private boolean isDefault(IItemFilter f) {
|
||||
if(f instanceof ItemFilter) {
|
||||
return ((ItemFilter)f).isDefault();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbtRoot, short nbtVersion) {
|
||||
super.readFromNBT(nbtRoot, nbtVersion);
|
||||
@@ -568,19 +709,42 @@ public class ItemConduit extends AbstractConduit implements IItemConduit {
|
||||
metaData = nbtRoot.getShort("metaData");
|
||||
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
|
||||
String key = "inFilts." + dir.name();
|
||||
if(nbtRoot.hasKey(key)) {
|
||||
NBTTagCompound filterTag = (NBTTagCompound) nbtRoot.getTag(key);
|
||||
ItemFilter filter = new ItemFilter();
|
||||
filter.readFromNBT(filterTag);
|
||||
inputFilters.put(dir, filter);
|
||||
inputFilters.put(dir, filter);
|
||||
}
|
||||
|
||||
key = "speedUpgrades." + dir.name();
|
||||
if(nbtRoot.hasKey(key)) {
|
||||
NBTTagCompound upTag = (NBTTagCompound) nbtRoot.getTag(key);
|
||||
ItemStack ups = ItemStack.loadItemStackFromNBT(upTag);
|
||||
speedUpgrades.put(dir, ups);
|
||||
}
|
||||
|
||||
key = "inputFilterUpgrades." + dir.name();
|
||||
if(nbtRoot.hasKey(key)) {
|
||||
NBTTagCompound upTag = (NBTTagCompound) nbtRoot.getTag(key);
|
||||
ItemStack ups = ItemStack.loadItemStackFromNBT(upTag);
|
||||
inputFilterUpgrades.put(dir, ups);
|
||||
}
|
||||
|
||||
key = "outputFilterUpgrades." + dir.name();
|
||||
if(nbtRoot.hasKey(key)) {
|
||||
NBTTagCompound upTag = (NBTTagCompound) nbtRoot.getTag(key);
|
||||
ItemStack ups = ItemStack.loadItemStackFromNBT(upTag);
|
||||
outputFilterUpgrades.put(dir, ups);
|
||||
}
|
||||
|
||||
key = "outFilts." + dir.name();
|
||||
if(nbtRoot.hasKey(key)) {
|
||||
NBTTagCompound filterTag = (NBTTagCompound) nbtRoot.getTag(key);
|
||||
ItemFilter filter = new ItemFilter();
|
||||
filter.readFromNBT(filterTag);
|
||||
outputFilters.put(dir, filter);
|
||||
outputFilters.put(dir, filter);
|
||||
}
|
||||
|
||||
key = "extRM." + dir.name();
|
||||
@@ -608,7 +772,7 @@ public class ItemConduit extends AbstractConduit implements IItemConduit {
|
||||
boolean val = nbtRoot.getBoolean(key);
|
||||
roundRobin.put(dir, val);
|
||||
}
|
||||
|
||||
|
||||
key = "priority." + dir.name();
|
||||
if(nbtRoot.hasKey(key)) {
|
||||
int val = nbtRoot.getInteger(key);
|
||||
|
||||
@@ -138,7 +138,7 @@ public class ItemConduitNetwork extends AbstractConduitNetwork<IItemConduit, IIt
|
||||
if(source.con.getLocation().equals(con.getLocation())) {
|
||||
if(source != null && source.sendPriority != null) {
|
||||
for (Target t : source.sendPriority) {
|
||||
ItemFilter f = t.inv.con.getOutputFilter(t.inv.conDir);
|
||||
IItemFilter f = t.inv.con.getOutputFilter(t.inv.conDir);
|
||||
if(input == null || f == null || f.doesItemPassFilter(input)) {
|
||||
String s = Lang.localize(t.inv.inv.getInventoryName(), false) + " " + t.inv.location + " Distance [" + t.distance + "] ";
|
||||
result.add(s);
|
||||
@@ -155,7 +155,7 @@ public class ItemConduitNetwork extends AbstractConduitNetwork<IItemConduit, IIt
|
||||
List<String> result = new ArrayList<String>();
|
||||
for (NetworkedInventory inv : inventories) {
|
||||
if(inv.hasTarget(con, dir)) {
|
||||
ItemFilter f = inv.con.getInputFilter(inv.conDir);
|
||||
IItemFilter f = inv.con.getInputFilter(inv.conDir);
|
||||
if(input == null || f == null || f.doesItemPassFilter(input)) {
|
||||
result.add(Lang.localize(inv.inv.getInventoryName(), false) + " " + inv.location);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package crazypants.enderio.conduit.item;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.item.Item;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.EnderIOTab;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.machine.monitor.ItemConduitProbe;
|
||||
import crazypants.enderio.machine.monitor.PacketConduitProbe;
|
||||
|
||||
public class ItemExtractSpeedUpgrade extends Item {
|
||||
|
||||
public static ItemExtractSpeedUpgrade create() {
|
||||
|
||||
EnderIO.packetPipeline.registerPacket(PacketConduitProbe.class);
|
||||
|
||||
ItemExtractSpeedUpgrade result = new ItemExtractSpeedUpgrade();
|
||||
result.init();
|
||||
return result;
|
||||
}
|
||||
|
||||
protected ItemExtractSpeedUpgrade() {
|
||||
setCreativeTab(EnderIOTab.tabEnderIO);
|
||||
setUnlocalizedName(ModObject.itemExtractSpeedUpgrade.unlocalisedName);
|
||||
setMaxStackSize(64);
|
||||
}
|
||||
|
||||
protected void init() {
|
||||
GameRegistry.registerItem(this, ModObject.itemExtractSpeedUpgrade.unlocalisedName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister IIconRegister) {
|
||||
itemIcon = IIconRegister.registerIcon("enderio:extractSpeedUpgrade");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,15 +1,23 @@
|
||||
package crazypants.enderio.conduit.item;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.text.html.HTMLDocument.HTMLReader.IsindexAction;
|
||||
|
||||
import crazypants.gui.TemplateSlot;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public class ItemFilter implements IInventory {
|
||||
public class ItemFilter implements IInventory, IItemFilter {
|
||||
|
||||
private static final boolean DEFAULT_BLACKLIST = false;
|
||||
|
||||
@@ -31,20 +39,31 @@ public class ItemFilter implements IInventory {
|
||||
|
||||
int[] oreIds;
|
||||
|
||||
private boolean isAdvanced;
|
||||
|
||||
private IItemConduit con;
|
||||
|
||||
public ItemFilter() {
|
||||
this(10);
|
||||
this(5, false);
|
||||
}
|
||||
|
||||
public ItemFilter(boolean advanced) {
|
||||
this(advanced ? 10 : 5, advanced);
|
||||
}
|
||||
|
||||
private ItemFilter(int numItems) {
|
||||
private ItemFilter(int numItems, boolean isAdvanced) {
|
||||
this.isAdvanced = isAdvanced;
|
||||
items = new ItemStack[numItems];
|
||||
oreIds = new int[numItems];
|
||||
Arrays.fill(oreIds, -99);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesFilterCaptureStack(ItemStack item) {
|
||||
return isSticky() && itemMatched(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesItemPassFilter(ItemStack item) {
|
||||
if(!isValid()) {
|
||||
return true;
|
||||
@@ -96,6 +115,7 @@ public class ItemFilter implements IInventory {
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
for (ItemStack item : items) {
|
||||
if(item != null) {
|
||||
@@ -137,6 +157,7 @@ public class ItemFilter implements IInventory {
|
||||
this.useOreDict = useOreDict;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSticky() {
|
||||
return sticky;
|
||||
}
|
||||
@@ -145,12 +166,14 @@ public class ItemFilter implements IInventory {
|
||||
this.sticky = sticky;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbtRoot) {
|
||||
nbtRoot.setBoolean("isBlacklist", isBlacklist);
|
||||
nbtRoot.setBoolean("matchMeta", matchMeta);
|
||||
nbtRoot.setBoolean("matchNBT", matchNBT);
|
||||
nbtRoot.setBoolean("useOreDict", useOreDict);
|
||||
nbtRoot.setBoolean("sticky", sticky);
|
||||
nbtRoot.setBoolean("isAdvanced", isAdvanced);
|
||||
|
||||
int i = 0;
|
||||
for (ItemStack item : items) {
|
||||
@@ -164,14 +187,16 @@ public class ItemFilter implements IInventory {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbtRoot) {
|
||||
isBlacklist = nbtRoot.getBoolean("isBlacklist");
|
||||
matchMeta = nbtRoot.getBoolean("matchMeta");
|
||||
matchNBT = nbtRoot.getBoolean("matchNBT");
|
||||
useOreDict = nbtRoot.getBoolean("useOreDict");
|
||||
sticky = nbtRoot.getBoolean("sticky");
|
||||
isAdvanced = nbtRoot.getBoolean("isAdvanced");
|
||||
|
||||
int numItems = 10;
|
||||
int numItems = isAdvanced ? 10 : 5;
|
||||
items = new ItemStack[numItems];
|
||||
oreIds = new int[numItems];
|
||||
for (int i = 0; i < numItems; i++) {
|
||||
@@ -242,7 +267,7 @@ public class ItemFilter implements IInventory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
public void markDirty() {
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -263,11 +288,49 @@ public class ItemFilter implements IInventory {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Slot> getSlots() {
|
||||
List<Slot> result = new ArrayList<Slot>();
|
||||
|
||||
int topY = 69;
|
||||
int leftX = 33;
|
||||
int index = 0;
|
||||
int numRows = isAdvanced ? 2 : 1;
|
||||
for (int row = 0; row < numRows; ++row) {
|
||||
for (int col = 0; col < 5; ++col) {
|
||||
int x = leftX + col * 18;
|
||||
int y = topY + row * 18;
|
||||
result.add(new TemplateSlot(this, index, x, y));
|
||||
index++;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlotCount() {
|
||||
return getSizeInventory();
|
||||
}
|
||||
|
||||
public boolean isAdvanced() {
|
||||
return isAdvanced;
|
||||
}
|
||||
|
||||
public boolean isDefault() {
|
||||
return !isValid() && isBlacklist == DEFAULT_BLACKLIST &&
|
||||
return !isAdvanced && !isValid() && isBlacklist == DEFAULT_BLACKLIST &&
|
||||
matchMeta == DEFAULT_META &&
|
||||
matchNBT == DEFAULT_MBT &&
|
||||
useOreDict == DEFAULT_ORE_DICT &&
|
||||
sticky == DEFAULT_STICKY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
// return "ItemFilter [isBlacklist=" + isBlacklist + ", matchMeta=" + matchMeta + ", matchNBT=" + matchNBT + ", useOreDict=" + useOreDict + ", sticky="
|
||||
// + sticky + ", items=" + Arrays.toString(items) + ", oreIds=" + Arrays.toString(oreIds) + ", isAdvanced=" + isAdvanced + "]";
|
||||
return "ItemFilter [isAdvanced=" + isAdvanced + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -8,9 +8,12 @@ import crazypants.enderio.conduit.ItemConduitSubtype;
|
||||
|
||||
public class ItemItemConduit extends AbstractItemConduit {
|
||||
|
||||
// private static ItemConduitSubtype[] subtypes = new ItemConduitSubtype[] {
|
||||
// new ItemConduitSubtype(ModObject.itemItemConduit.name(), "enderio:itemItemConduit"),
|
||||
// new ItemConduitSubtype(ModObject.itemItemConduit.name() + "Empowered", "enderio:itemItemConduitAdvanced")
|
||||
// };
|
||||
private static ItemConduitSubtype[] subtypes = new ItemConduitSubtype[] {
|
||||
new ItemConduitSubtype(ModObject.itemItemConduit.name(), "enderio:itemItemConduit"),
|
||||
new ItemConduitSubtype(ModObject.itemItemConduit.name() + "Empowered", "enderio:itemItemConduitAdvanced")
|
||||
new ItemConduitSubtype(ModObject.itemItemConduit.name(), "enderio:itemItemConduit")
|
||||
};
|
||||
|
||||
public static ItemItemConduit create() {
|
||||
|
||||
@@ -78,7 +78,7 @@ class NetworkedInventory {
|
||||
}
|
||||
|
||||
boolean isSticky() {
|
||||
return con.getOutputFilter(conDir).isValid() && con.getOutputFilter(conDir).isSticky();
|
||||
return con.getOutputFilter(conDir) != null && con.getOutputFilter(conDir).isValid() && con.getOutputFilter(conDir).isSticky();
|
||||
}
|
||||
|
||||
int getPriority() {
|
||||
@@ -132,7 +132,7 @@ class NetworkedInventory {
|
||||
}
|
||||
int numSlots = slotIndices.length;
|
||||
ItemStack extractItem = null;
|
||||
int maxExtracted = con.getMaximumExtracted();
|
||||
int maxExtracted = con.getMaximumExtracted(conDir);
|
||||
|
||||
int slot = -1;
|
||||
int slotChecksPerTick = Math.min(numSlots, ItemConduitNetwork.MAX_SLOT_CHECK_PER_TICK);
|
||||
@@ -157,7 +157,7 @@ class NetworkedInventory {
|
||||
if(itemStack == null) {
|
||||
return false;
|
||||
}
|
||||
ItemFilter filter = con.getInputFilter(conDir);
|
||||
IItemFilter filter = con.getInputFilter(conDir);
|
||||
if(filter == null) {
|
||||
return true;
|
||||
}
|
||||
@@ -188,7 +188,7 @@ class NetworkedInventory {
|
||||
}
|
||||
}
|
||||
con.itemsExtracted(numInserted, slot);
|
||||
tickDeficit = Math.round(numInserted * con.getTickTimePerItem());
|
||||
tickDeficit = Math.round(numInserted * con.getTickTimePerItem(conDir));
|
||||
return true;
|
||||
|
||||
}
|
||||
@@ -207,8 +207,8 @@ class NetworkedInventory {
|
||||
//for (Target target : sendPriority) {
|
||||
for (Target target : targets) {
|
||||
if(target.stickyInput && !matchedStickyInput) {
|
||||
ItemFilter of = target.inv.con.getOutputFilter(target.inv.conDir);
|
||||
matchedStickyInput = of.isValid() && of.doesItemPassFilter(toExtract);
|
||||
IItemFilter of = target.inv.con.getOutputFilter(target.inv.conDir);
|
||||
matchedStickyInput = of != null && of.isValid() && of.doesItemPassFilter(toExtract);
|
||||
}
|
||||
if(target.stickyInput || !matchedStickyInput) {
|
||||
if(target.inv.recheckInv) {
|
||||
@@ -248,7 +248,7 @@ class NetworkedInventory {
|
||||
if(!canInsert() || item == null) {
|
||||
return 0;
|
||||
}
|
||||
ItemFilter filter = con.getOutputFilter(conDir);
|
||||
IItemFilter filter = con.getOutputFilter(conDir);
|
||||
if(filter != null) {
|
||||
if(!filter.doesItemPassFilter(item)) {
|
||||
return 0;
|
||||
|
||||
@@ -5,8 +5,9 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
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 crazypants.enderio.conduit.item.FilterRegister;
|
||||
import crazypants.enderio.conduit.item.IItemConduit;
|
||||
import crazypants.enderio.conduit.item.ItemFilter;
|
||||
import crazypants.enderio.conduit.item.IItemFilter;
|
||||
import crazypants.util.DyeColor;
|
||||
|
||||
public class PacketItemConduitFilter extends AbstractConduitPacket<IItemConduit> implements IMessageHandler<PacketItemConduitFilter, IMessage> {
|
||||
@@ -18,8 +19,8 @@ public class PacketItemConduitFilter extends AbstractConduitPacket<IItemConduit>
|
||||
private DyeColor colOut;
|
||||
private int priority;
|
||||
|
||||
private ItemFilter inputFilter;
|
||||
private ItemFilter outputFilter;
|
||||
private IItemFilter inputFilter;
|
||||
private IItemFilter outputFilter;
|
||||
|
||||
public PacketItemConduitFilter() {
|
||||
}
|
||||
@@ -45,16 +46,8 @@ public class PacketItemConduitFilter extends AbstractConduitPacket<IItemConduit>
|
||||
buf.writeInt(priority);
|
||||
buf.writeShort(colIn.ordinal());
|
||||
buf.writeShort(colOut.ordinal());
|
||||
writeFilter(buf, inputFilter);
|
||||
writeFilter(buf, outputFilter);
|
||||
}
|
||||
|
||||
private void writeFilter(ByteBuf buf, ItemFilter filter) {
|
||||
buf.writeBoolean(filter.isBlacklist());
|
||||
buf.writeBoolean(filter.isMatchMeta());
|
||||
buf.writeBoolean(filter.isMatchNBT());
|
||||
buf.writeBoolean(filter.isUseOreDict());
|
||||
buf.writeBoolean(filter.isSticky());
|
||||
FilterRegister.writeFilter(buf, inputFilter);
|
||||
FilterRegister.writeFilter(buf, outputFilter);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -65,19 +58,8 @@ public class PacketItemConduitFilter extends AbstractConduitPacket<IItemConduit>
|
||||
priority = buf.readInt();
|
||||
colIn = DyeColor.values()[buf.readShort()];
|
||||
colOut = DyeColor.values()[buf.readShort()];
|
||||
inputFilter = readFilter(buf);
|
||||
outputFilter = readFilter(buf);
|
||||
}
|
||||
|
||||
private ItemFilter readFilter(ByteBuf data) {
|
||||
|
||||
ItemFilter itemFilter = new ItemFilter();
|
||||
itemFilter.setBlacklist(data.readBoolean());
|
||||
itemFilter.setMatchMeta(data.readBoolean());
|
||||
itemFilter.setMatchNBT(data.readBoolean());
|
||||
itemFilter.setUseOreDict(data.readBoolean());
|
||||
itemFilter.setSticky(data.readBoolean());
|
||||
return itemFilter;
|
||||
inputFilter = FilterRegister.readFilter(buf);
|
||||
outputFilter = FilterRegister.readFilter(buf);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -95,22 +77,22 @@ public class PacketItemConduitFilter extends AbstractConduitPacket<IItemConduit>
|
||||
return null;
|
||||
}
|
||||
|
||||
private void applyFilter(ForgeDirection dir, IItemConduit conduit, ItemFilter filter, boolean isInput) {
|
||||
if(filter == null) {
|
||||
private void applyFilter(ForgeDirection dir, IItemConduit conduit, IItemFilter filter, boolean isInput) {
|
||||
// if(filter == null) {
|
||||
if(isInput) {
|
||||
conduit.setInputFilter(dir, filter);
|
||||
} else {
|
||||
conduit.setOutputFilter(dir, filter);
|
||||
}
|
||||
return;
|
||||
}
|
||||
// }
|
||||
|
||||
ItemFilter itemFilter = isInput ? conduit.getInputFilter(dir) : conduit.getOutputFilter(dir);
|
||||
itemFilter.setBlacklist(filter.isBlacklist());
|
||||
itemFilter.setMatchMeta(filter.isMatchMeta());
|
||||
itemFilter.setMatchNBT(filter.isMatchNBT());
|
||||
itemFilter.setUseOreDict(filter.isUseOreDict());
|
||||
itemFilter.setSticky(filter.isSticky());
|
||||
// ItemFilter itemFilter = isInput ? conduit.getInputFilter(dir) : conduit.getOutputFilter(dir);
|
||||
// itemFilter.setBlacklist(filter.isBlacklist());
|
||||
// itemFilter.setMatchMeta(filter.isMatchMeta());
|
||||
// itemFilter.setMatchNBT(filter.isMatchNBT());
|
||||
// itemFilter.setUseOreDict(filter.isUseOreDict());
|
||||
// itemFilter.setSticky(filter.isSticky());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ import crazypants.enderio.conduit.RaytraceResult;
|
||||
import crazypants.enderio.conduit.geom.CollidableCache.CacheKey;
|
||||
import crazypants.enderio.conduit.geom.CollidableComponent;
|
||||
import crazypants.enderio.conduit.geom.ConduitGeometryUtil;
|
||||
import crazypants.enderio.machine.AbstractMachineEntity;
|
||||
import crazypants.render.BoundingBox;
|
||||
import crazypants.render.IconUtil;
|
||||
import crazypants.util.BlockCoord;
|
||||
@@ -269,7 +270,7 @@ public class InsulatedRedstoneConduit extends RedstoneConduit implements IInsula
|
||||
|
||||
World world = getBundle().getEntity().getWorldObj();
|
||||
TileEntity te = world.getTileEntity(loc.x, loc.y, loc.z);
|
||||
if(te instanceof IPowerEmitter || te instanceof IRedstoneControl) {
|
||||
if(te instanceof IPowerEmitter || te instanceof IRedstoneControl || te instanceof AbstractMachineEntity) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ public class IconButtonEIO extends GuiButton {
|
||||
public void setToolTip(String... tooltipText) {
|
||||
if(toolTip == null) {
|
||||
toolTip = new GuiToolTip(new Rectangle(xOrigin, yOrigin, width, height), tooltipText);
|
||||
gui.addToolTip(toolTip);
|
||||
//gui.addToolTip(toolTip);
|
||||
toolTip.setBounds(new Rectangle(xPosition, yPosition, width, height));
|
||||
} else {
|
||||
toolTip.setToolTipText(tooltipText);
|
||||
|
||||
Reference in new issue
Block a user