Removed craft-only mode for the Exporter and Fixed Exporter with Stack Upgrade not working correctly in Regulator Mode
This commit is contained in:
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
### 1.5.24
|
### 1.5.24
|
||||||
- The Grid now displays last modified information (player name and date) and size on tooltips of stacks (raoulvdberge)
|
- The Grid now displays last modified information (player name and date) and size on tooltips of stacks (raoulvdberge)
|
||||||
|
- Removed craft-only mode for the Exporter (raoulvdberge)
|
||||||
|
- Fixed Exporter with Stack Upgrade not working correctly in Regulator Mode (raoulvdberge)
|
||||||
|
|
||||||
### 1.5.23
|
### 1.5.23
|
||||||
- Fixed duplication bug with autocrafting (raoulvdberge)
|
- Fixed duplication bug with autocrafting (raoulvdberge)
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package com.raoulvdberge.refinedstorage.apiimpl.network.node;
|
|||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.RS;
|
import com.raoulvdberge.refinedstorage.RS;
|
||||||
import com.raoulvdberge.refinedstorage.RSItems;
|
import com.raoulvdberge.refinedstorage.RSItems;
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingTask;
|
|
||||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBase;
|
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBase;
|
||||||
@@ -33,7 +32,6 @@ public class NetworkNodeExporter extends NetworkNode implements IComparable, ITy
|
|||||||
private static final String NBT_COMPARE = "Compare";
|
private static final String NBT_COMPARE = "Compare";
|
||||||
private static final String NBT_TYPE = "Type";
|
private static final String NBT_TYPE = "Type";
|
||||||
private static final String NBT_REGULATOR = "Regulator";
|
private static final String NBT_REGULATOR = "Regulator";
|
||||||
private static final String NBT_CRAFT_ONLY = "CraftOnly";
|
|
||||||
|
|
||||||
private ItemHandlerBase itemFilters = new ItemHandlerBase(9, new ItemHandlerListenerNetworkNode(this));
|
private ItemHandlerBase itemFilters = new ItemHandlerBase(9, new ItemHandlerListenerNetworkNode(this));
|
||||||
private ItemHandlerFluid fluidFilters = new ItemHandlerFluid(9, new ItemHandlerListenerNetworkNode(this));
|
private ItemHandlerFluid fluidFilters = new ItemHandlerFluid(9, new ItemHandlerListenerNetworkNode(this));
|
||||||
@@ -43,9 +41,6 @@ public class NetworkNodeExporter extends NetworkNode implements IComparable, ITy
|
|||||||
private int compare = IComparer.COMPARE_NBT | IComparer.COMPARE_DAMAGE;
|
private int compare = IComparer.COMPARE_NBT | IComparer.COMPARE_DAMAGE;
|
||||||
private int type = IType.ITEMS;
|
private int type = IType.ITEMS;
|
||||||
private boolean regulator = false;
|
private boolean regulator = false;
|
||||||
private boolean craftOnly = false;
|
|
||||||
private ICraftingTask[] craftOnlyTask = new ICraftingTask[9];
|
|
||||||
private Integer[] craftOnlyToExtract = new Integer[9];
|
|
||||||
|
|
||||||
public NetworkNodeExporter(World world, BlockPos pos) {
|
public NetworkNodeExporter(World world, BlockPos pos) {
|
||||||
super(world, pos);
|
super(world, pos);
|
||||||
@@ -72,11 +67,11 @@ public class NetworkNodeExporter extends NetworkNode implements IComparable, ITy
|
|||||||
if (slot.getItem() == RSItems.FILTER) {
|
if (slot.getItem() == RSItems.FILTER) {
|
||||||
for (ItemStack slotInFilter : ItemFilter.getFilterItemsFromCache(slot)) {
|
for (ItemStack slotInFilter : ItemFilter.getFilterItemsFromCache(slot)) {
|
||||||
if (!slotInFilter.isEmpty()) {
|
if (!slotInFilter.isEmpty()) {
|
||||||
doExport(handler, -1, slotInFilter);
|
doExport(handler, slotInFilter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
doExport(handler, i, slot);
|
doExport(handler, slot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -136,63 +131,40 @@ public class NetworkNodeExporter extends NetworkNode implements IComparable, ITy
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doExport(IItemHandler handler, int i, ItemStack slot) {
|
private void doExport(IItemHandler handler, ItemStack slot) {
|
||||||
if (craftOnly && i >= 0) {
|
int stackSize = upgrades.getItemInteractCount();
|
||||||
if (craftOnlyTask[i] == null) {
|
|
||||||
craftOnlyTask[i] = network.getCraftingManager().schedule(slot, 1, compare);
|
|
||||||
|
|
||||||
if (craftOnlyTask[i] != null) {
|
if (regulator) {
|
||||||
craftOnlyToExtract[i] = craftOnlyTask[i].getPattern().getQuantityPerRequest(slot, compare);
|
int found = 0;
|
||||||
}
|
|
||||||
} else if (craftOnlyTask[i].isFinished() && craftOnlyTask[i].getMissing().isEmpty()) {
|
|
||||||
ItemStack took = network.extractItem(slot, 1, compare, true);
|
|
||||||
|
|
||||||
if (took != null && ItemHandlerHelper.insertItem(handler, took, true).isEmpty()) {
|
for (int index = 0; index < handler.getSlots(); index++) {
|
||||||
took = network.extractItem(slot, 1, compare, false);
|
ItemStack handlerStack = handler.getStackInSlot(index);
|
||||||
|
|
||||||
if (took != null) {
|
if (API.instance().getComparer().isEqual(slot, handlerStack, compare)) {
|
||||||
ItemHandlerHelper.insertItem(handler, took, false);
|
found += handlerStack.getCount();
|
||||||
|
|
||||||
craftOnlyToExtract[i]--;
|
|
||||||
|
|
||||||
if (craftOnlyToExtract[i] <= 0) {
|
|
||||||
craftOnlyToExtract[i] = null;
|
|
||||||
craftOnlyTask[i] = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (!network.getCraftingManager().getTasks().contains(craftOnlyTask[i])) {
|
|
||||||
craftOnlyTask[i] = null;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
int stackSize = upgrades.getItemInteractCount();
|
|
||||||
|
|
||||||
if (regulator) {
|
|
||||||
for (int index = 0; index < handler.getSlots(); index++) {
|
|
||||||
ItemStack exporterStack = handler.getStackInSlot(index);
|
|
||||||
|
|
||||||
if (API.instance().getComparer().isEqual(slot, exporterStack, compare)) {
|
|
||||||
if (exporterStack.getCount() >= slot.getCount()) {
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
stackSize = upgrades.hasUpgrade(ItemUpgrade.TYPE_STACK) ? slot.getCount() - exporterStack.getCount() : 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack took = network.extractItem(slot, Math.min(slot.getMaxStackSize(), stackSize), compare, true);
|
stackSize = slot.getCount() - found;
|
||||||
|
|
||||||
if (took == null) {
|
if (stackSize <= 0) {
|
||||||
if (upgrades.hasUpgrade(ItemUpgrade.TYPE_CRAFTING)) {
|
return;
|
||||||
network.getCraftingManager().schedule(slot, 1, compare);
|
} else if (!upgrades.hasUpgrade(ItemUpgrade.TYPE_STACK)) {
|
||||||
}
|
stackSize = 1;
|
||||||
} else if (ItemHandlerHelper.insertItem(handler, took, true).isEmpty()) {
|
}
|
||||||
took = network.extractItem(slot, upgrades.getItemInteractCount(), compare, false);
|
}
|
||||||
|
|
||||||
if (took != null) {
|
ItemStack took = network.extractItem(slot, Math.min(slot.getMaxStackSize(), stackSize), compare, true);
|
||||||
ItemHandlerHelper.insertItem(handler, took, false);
|
|
||||||
}
|
if (took == null) {
|
||||||
|
if (upgrades.hasUpgrade(ItemUpgrade.TYPE_CRAFTING)) {
|
||||||
|
network.getCraftingManager().schedule(slot, 1, compare);
|
||||||
|
}
|
||||||
|
} else if (ItemHandlerHelper.insertItem(handler, took, true).isEmpty()) {
|
||||||
|
took = network.extractItem(slot, Math.min(slot.getMaxStackSize(), stackSize), compare, false);
|
||||||
|
|
||||||
|
if (took != null) {
|
||||||
|
ItemHandlerHelper.insertItem(handler, took, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -237,7 +209,6 @@ public class NetworkNodeExporter extends NetworkNode implements IComparable, ITy
|
|||||||
tag.setInteger(NBT_COMPARE, compare);
|
tag.setInteger(NBT_COMPARE, compare);
|
||||||
tag.setInteger(NBT_TYPE, type);
|
tag.setInteger(NBT_TYPE, type);
|
||||||
tag.setBoolean(NBT_REGULATOR, regulator);
|
tag.setBoolean(NBT_REGULATOR, regulator);
|
||||||
tag.setBoolean(NBT_CRAFT_ONLY, craftOnly);
|
|
||||||
|
|
||||||
StackUtils.writeItems(itemFilters, 0, tag);
|
StackUtils.writeItems(itemFilters, 0, tag);
|
||||||
StackUtils.writeItems(fluidFilters, 2, tag);
|
StackUtils.writeItems(fluidFilters, 2, tag);
|
||||||
@@ -261,10 +232,6 @@ public class NetworkNodeExporter extends NetworkNode implements IComparable, ITy
|
|||||||
regulator = tag.getBoolean(NBT_REGULATOR);
|
regulator = tag.getBoolean(NBT_REGULATOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tag.hasKey(NBT_CRAFT_ONLY)) {
|
|
||||||
craftOnly = tag.getBoolean(NBT_CRAFT_ONLY);
|
|
||||||
}
|
|
||||||
|
|
||||||
StackUtils.readItems(itemFilters, 0, tag);
|
StackUtils.readItems(itemFilters, 0, tag);
|
||||||
StackUtils.readItems(fluidFilters, 2, tag);
|
StackUtils.readItems(fluidFilters, 2, tag);
|
||||||
}
|
}
|
||||||
@@ -310,12 +277,4 @@ public class NetworkNodeExporter extends NetworkNode implements IComparable, ITy
|
|||||||
public IItemHandler getFilterInventory() {
|
public IItemHandler getFilterInventory() {
|
||||||
return getType() == IType.ITEMS ? itemFilters : fluidFilters;
|
return getType() == IType.ITEMS ? itemFilters : fluidFilters;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCraftOnly() {
|
|
||||||
return craftOnly;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCraftOnly(boolean craftOnly) {
|
|
||||||
this.craftOnly = craftOnly;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,10 @@ package com.raoulvdberge.refinedstorage.gui;
|
|||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||||
import com.raoulvdberge.refinedstorage.container.ContainerExporter;
|
import com.raoulvdberge.refinedstorage.container.ContainerExporter;
|
||||||
import com.raoulvdberge.refinedstorage.gui.sidebutton.*;
|
import com.raoulvdberge.refinedstorage.gui.sidebutton.SideButtonCompare;
|
||||||
|
import com.raoulvdberge.refinedstorage.gui.sidebutton.SideButtonExporterRegulator;
|
||||||
|
import com.raoulvdberge.refinedstorage.gui.sidebutton.SideButtonRedstoneMode;
|
||||||
|
import com.raoulvdberge.refinedstorage.gui.sidebutton.SideButtonType;
|
||||||
import com.raoulvdberge.refinedstorage.tile.TileExporter;
|
import com.raoulvdberge.refinedstorage.tile.TileExporter;
|
||||||
|
|
||||||
public class GuiExporter extends GuiBase {
|
public class GuiExporter extends GuiBase {
|
||||||
@@ -21,7 +24,6 @@ public class GuiExporter extends GuiBase {
|
|||||||
addSideButton(new SideButtonCompare(this, TileExporter.COMPARE, IComparer.COMPARE_OREDICT));
|
addSideButton(new SideButtonCompare(this, TileExporter.COMPARE, IComparer.COMPARE_OREDICT));
|
||||||
|
|
||||||
addSideButton(new SideButtonExporterRegulator(this));
|
addSideButton(new SideButtonExporterRegulator(this));
|
||||||
addSideButton(new SideButtonExporterCraftOnly(this));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
package com.raoulvdberge.refinedstorage.gui.sidebutton;
|
|
||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
|
||||||
import com.raoulvdberge.refinedstorage.tile.TileExporter;
|
|
||||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataManager;
|
|
||||||
import net.minecraft.util.text.TextFormatting;
|
|
||||||
|
|
||||||
public class SideButtonExporterCraftOnly extends SideButton {
|
|
||||||
public SideButtonExporterCraftOnly(GuiBase gui) {
|
|
||||||
super(gui);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void drawButtonIcon(int x, int y) {
|
|
||||||
gui.drawTexture(x, y, 64 + (TileExporter.CRAFT_ONLY.getValue() ? 16 : 0), 32, 16, 16);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getTooltip() {
|
|
||||||
return GuiBase.t("sidebutton.refinedstorage:exporter.craft_only") + "\n" + TextFormatting.GRAY + GuiBase.t(TileExporter.CRAFT_ONLY.getValue() ? "gui.yes" : "gui.no");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void actionPerformed() {
|
|
||||||
TileDataManager.setParameter(TileExporter.CRAFT_ONLY, !TileExporter.CRAFT_ONLY.getValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -14,7 +14,8 @@ import net.minecraft.world.World;
|
|||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class TileExporter extends TileNode<NetworkNodeExporter> {
|
public class
|
||||||
|
TileExporter extends TileNode<NetworkNodeExporter> {
|
||||||
public static final TileDataParameter<Integer, TileExporter> COMPARE = IComparable.createParameter();
|
public static final TileDataParameter<Integer, TileExporter> COMPARE = IComparable.createParameter();
|
||||||
public static final TileDataParameter<Integer, TileExporter> TYPE = IType.createParameter();
|
public static final TileDataParameter<Integer, TileExporter> TYPE = IType.createParameter();
|
||||||
public static final TileDataParameter<Boolean, TileExporter> REGULATOR = new TileDataParameter<>(DataSerializers.BOOLEAN, false, t -> t.getNode().isRegulator(), (t, v) -> {
|
public static final TileDataParameter<Boolean, TileExporter> REGULATOR = new TileDataParameter<>(DataSerializers.BOOLEAN, false, t -> t.getNode().isRegulator(), (t, v) -> {
|
||||||
@@ -43,16 +44,11 @@ public class TileExporter extends TileNode<NetworkNodeExporter> {
|
|||||||
((ContainerExporter) ((GuiExporter) Minecraft.getMinecraft().currentScreen).inventorySlots).initSlots();
|
((ContainerExporter) ((GuiExporter) Minecraft.getMinecraft().currentScreen).inventorySlots).initSlots();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
public static final TileDataParameter<Boolean, TileExporter> CRAFT_ONLY = new TileDataParameter<>(DataSerializers.BOOLEAN, false, t -> t.getNode().isCraftOnly(), (t, v) -> {
|
|
||||||
t.getNode().setCraftOnly(v);
|
|
||||||
t.getNode().markDirty();
|
|
||||||
});
|
|
||||||
|
|
||||||
public TileExporter() {
|
public TileExporter() {
|
||||||
dataManager.addWatchedParameter(COMPARE);
|
dataManager.addWatchedParameter(COMPARE);
|
||||||
dataManager.addWatchedParameter(TYPE);
|
dataManager.addWatchedParameter(TYPE);
|
||||||
dataManager.addWatchedParameter(REGULATOR);
|
dataManager.addWatchedParameter(REGULATOR);
|
||||||
dataManager.addWatchedParameter(CRAFT_ONLY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ public final class TimeUtils {
|
|||||||
public static String getAgo(long ago, String by) {
|
public static String getAgo(long ago, String by) {
|
||||||
long diff = System.currentTimeMillis() - ago;
|
long diff = System.currentTimeMillis() - ago;
|
||||||
|
|
||||||
if (diff < SECOND * 5) {
|
if (diff < SECOND * 10) {
|
||||||
return I18n.format("misc.refinedstorage:last_modified.just_now", by);
|
return I18n.format("misc.refinedstorage:last_modified.just_now", by);
|
||||||
} else if (diff < MINUTE) {
|
} else if (diff < MINUTE) {
|
||||||
return I18n.format("misc.refinedstorage:last_modified.second" + ((diff / SECOND) > 1 ? "s" : ""), diff / SECOND, by);
|
return I18n.format("misc.refinedstorage:last_modified.second" + ((diff / SECOND) > 1 ? "s" : ""), diff / SECOND, by);
|
||||||
|
|||||||
Reference in New Issue
Block a user