Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ff1091d252 | |||
| dd2f1c6dc7 | |||
| f14407b87a | |||
| 04f006695e | |||
| 4f36ccf64d | |||
| d9b4410c94 | |||
| 9bbd0ad61b | |||
| 662a7805dd | |||
| c46eadec08 | |||
| 148207f5c3 | |||
| 3ae251f098 | |||
| 82a906886f | |||
| 5b2c6658c0 |
@@ -66,6 +66,8 @@ archivesBaseName = aebasename
|
||||
jar {
|
||||
manifest {
|
||||
attributes 'FMLAT': 'appeng_at.cfg'
|
||||
attributes "FMLCorePlugin": "appeng.core.AE2ELCore"
|
||||
attributes "FMLCorePluginContainsFMLMod": "true"
|
||||
}
|
||||
|
||||
from sourceSets.api.output
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ aebuild=7
|
||||
aegroup=appeng
|
||||
aebasename=appliedenergistics2
|
||||
extended=extended_life
|
||||
extendedversion=v0.54.16
|
||||
extendedversion=v0.54.20
|
||||
#########################################################
|
||||
# Versions #
|
||||
#########################################################
|
||||
|
||||
@@ -83,9 +83,7 @@ configurations {
|
||||
dependencies {
|
||||
// deobfCompile "gregtechce:gregtech:1.12.2:1.15.1.735"
|
||||
// installable runtime dependencies
|
||||
//deobfCompile "curse.maven:gregtechceu-557242:3949406"
|
||||
|
||||
compileOnly(files("etc/gregtech-1.12.2-2.4.4-beta.jar"))
|
||||
deobfCompile "curse.maven:gregtechceu-557242:3949406"
|
||||
|
||||
compileOnly "curse.maven:chisel-235279:2915375"
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ import appeng.api.storage.IStorageChannel;
|
||||
* - For fluids: AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class).createList()
|
||||
* - Replace with the corresponding {@link IStorageChannel} type for non native channels
|
||||
*/
|
||||
public interface IItemList<T extends IAEStack<T>> extends IItemContainer<T>, Iterable<T>, Cloneable
|
||||
public interface IItemList<T extends IAEStack<T>> extends IItemContainer<T>, Iterable<T>
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -85,9 +85,4 @@ public interface IItemList<T extends IAEStack<T>> extends IItemContainer<T>, Ite
|
||||
* resets stack sizes to 0.
|
||||
*/
|
||||
void resetStatus();
|
||||
|
||||
/**
|
||||
* create a copy of this list.
|
||||
*/
|
||||
IItemList<T> clone();
|
||||
}
|
||||
}
|
||||
+2
-5
@@ -61,6 +61,7 @@ import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
import static appeng.client.render.BlockPosHighlighter.hilightBlock;
|
||||
import static appeng.helpers.ItemStackHelper.stackFromNBT;
|
||||
|
||||
|
||||
public class GuiInterfaceConfigurationTerminal extends AEBaseGui implements IJEIGhostIngredients {
|
||||
@@ -299,11 +300,7 @@ public class GuiInterfaceConfigurationTerminal extends AEBaseGui implements IJEI
|
||||
for (int x = 0; x < current.getInventory().getSlots(); x++) {
|
||||
final String which = Integer.toString(x);
|
||||
if (invData.hasKey(which)) {
|
||||
NBTTagCompound tag = invData.getCompoundTag(which);
|
||||
current.getInventory().setStackInSlot(x, new ItemStack(tag));
|
||||
if (tag.hasKey("stackSize")) {
|
||||
current.getInventory().getStackInSlot(x).setCount(tag.getInteger("stackSize"));
|
||||
}
|
||||
current.getInventory().setStackInSlot(x, stackFromNBT(invData.getCompoundTag(which)));
|
||||
}
|
||||
}
|
||||
} catch (final NumberFormatException ignored) {
|
||||
|
||||
@@ -52,6 +52,7 @@ import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
import static appeng.client.render.BlockPosHighlighter.hilightBlock;
|
||||
import static appeng.helpers.ItemStackHelper.stackFromNBT;
|
||||
|
||||
|
||||
public class GuiInterfaceTerminal extends AEBaseGui {
|
||||
@@ -321,7 +322,7 @@ public class GuiInterfaceTerminal extends AEBaseGui {
|
||||
for (int x = 0; x < current.getInventory().getSlots(); x++) {
|
||||
final String which = Integer.toString(x);
|
||||
if (invData.hasKey(which)) {
|
||||
current.getInventory().setStackInSlot(x, new ItemStack(invData.getCompoundTag(which)));
|
||||
current.getInventory().setStackInSlot(x, stackFromNBT(invData.getCompoundTag(which)));
|
||||
}
|
||||
}
|
||||
} catch (final NumberFormatException ignored) {
|
||||
|
||||
@@ -103,7 +103,6 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
|
||||
private int currentMouseY = 0;
|
||||
private boolean delayedUpdate;
|
||||
|
||||
private boolean updateView = true;
|
||||
protected int jeiOffset = Loader.isModLoaded("jei") ? 24 : 0;
|
||||
|
||||
public GuiMEMonitorable(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
|
||||
@@ -162,7 +161,8 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
|
||||
}
|
||||
|
||||
if (!this.delayedUpdate) {
|
||||
this.updateView = true;
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -319,7 +319,8 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
|
||||
this.searchField.setText(memoryText);
|
||||
this.searchField.selectAll();
|
||||
this.repo.setSearchString(memoryText);
|
||||
this.updateView = true;
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
}
|
||||
|
||||
craftingGridOffsetX = Integer.MAX_VALUE;
|
||||
@@ -380,7 +381,8 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
|
||||
if (btn == 1 && this.searchField.isMouseIn(xCoord, yCoord)) {
|
||||
this.searchField.setText("");
|
||||
this.repo.setSearchString("");
|
||||
this.updateView = true;
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
}
|
||||
|
||||
super.mouseClicked(xCoord, yCoord, btn);
|
||||
@@ -474,7 +476,8 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
|
||||
|
||||
if (this.searchField.textboxKeyTyped(character, key)) {
|
||||
this.repo.setSearchString(this.searchField.getText());
|
||||
this.updateView = true;
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
// tell forge the key event is handled and should not be sent out
|
||||
this.keyHandled = mouseInGui;
|
||||
} else {
|
||||
@@ -501,7 +504,7 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
|
||||
this.delayedUpdate = false;
|
||||
}
|
||||
}
|
||||
if (!this.delayedUpdate && updateView) {
|
||||
if (!this.delayedUpdate) {
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
}
|
||||
@@ -537,7 +540,7 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
|
||||
this.ViewBox.set(this.configSrc.getSetting(Settings.VIEW_MODE));
|
||||
}
|
||||
|
||||
this.updateView = true;
|
||||
this.repo.updateView();
|
||||
}
|
||||
|
||||
int getReservedSpace() {
|
||||
|
||||
@@ -55,8 +55,6 @@ public class GuiNetworkStatus extends AEBaseGui implements ISortSource {
|
||||
private GuiImgButton units;
|
||||
private int tooltip = -1;
|
||||
|
||||
private boolean updateView = true;
|
||||
|
||||
public GuiNetworkStatus(final InventoryPlayer inventoryPlayer, final INetworkTool te) {
|
||||
super(new ContainerNetworkStatus(inventoryPlayer, te));
|
||||
final GuiScrollbar scrollbar = new GuiScrollbar();
|
||||
@@ -208,17 +206,9 @@ public class GuiNetworkStatus extends AEBaseGui implements ISortSource {
|
||||
for (final IAEItemStack is : list) {
|
||||
this.repo.postUpdate(is);
|
||||
}
|
||||
this.updateView = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen() {
|
||||
if (updateView) {
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
updateView = false;
|
||||
}
|
||||
super.updateScreen();
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
}
|
||||
|
||||
private void setScrollBar() {
|
||||
|
||||
@@ -39,22 +39,19 @@ import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
||||
public class ItemRepo {
|
||||
|
||||
private final IItemList<IAEItemStack> list = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
|
||||
private final List<IAEItemStack> view;
|
||||
private List<IAEItemStack> asyncUpdatedView;
|
||||
private boolean updated;
|
||||
private final ArrayList<IAEItemStack> view = new ArrayList<>();
|
||||
private final IScrollSource src;
|
||||
private final ISortSource sortSrc;
|
||||
|
||||
private int rowSize = 9;
|
||||
|
||||
private volatile String searchString = "";
|
||||
private String searchString = "";
|
||||
private IPartitionList<IAEItemStack> myPartitionList;
|
||||
private String innerSearch = "";
|
||||
private boolean hasPower;
|
||||
@@ -62,14 +59,11 @@ public class ItemRepo {
|
||||
public ItemRepo(final IScrollSource src, final ISortSource sortSrc) {
|
||||
this.src = src;
|
||||
this.sortSrc = sortSrc;
|
||||
|
||||
this.view = Collections.synchronizedList(new ArrayList<>());
|
||||
this.asyncUpdatedView = Collections.synchronizedList(new ArrayList<>());
|
||||
list.forEach(this.view::add);
|
||||
}
|
||||
|
||||
public IAEItemStack getReferenceItem(int idx) {
|
||||
idx += this.src.getCurrentScroll() * this.rowSize;
|
||||
|
||||
if (idx >= this.view.size()) {
|
||||
return null;
|
||||
}
|
||||
@@ -101,128 +95,111 @@ public class ItemRepo {
|
||||
this.updateView();
|
||||
}
|
||||
|
||||
private CompletableFuture<Void> searchTask = null;
|
||||
|
||||
public void updateView() {
|
||||
if (searchTask != null) {
|
||||
return;
|
||||
this.view.clear();
|
||||
|
||||
this.view.ensureCapacity(this.list.size());
|
||||
|
||||
final Enum viewMode = this.sortSrc.getSortDisplay();
|
||||
final Enum searchMode = AEConfig.instance().getConfigManager().getSetting(Settings.SEARCH_MODE);
|
||||
final boolean needsZeroCopy = viewMode == ViewItems.CRAFTABLE;
|
||||
|
||||
if (searchMode == SearchBoxMode.JEI_AUTOSEARCH || searchMode == SearchBoxMode.JEI_MANUAL_SEARCH || searchMode == SearchBoxMode.JEI_AUTOSEARCH_KEEP || searchMode == SearchBoxMode.JEI_MANUAL_SEARCH_KEEP) {
|
||||
this.updateJEI(this.searchString);
|
||||
}
|
||||
|
||||
if (updated) {
|
||||
this.view.clear();
|
||||
this.view.addAll(asyncUpdatedView);
|
||||
this.asyncUpdatedView.clear();
|
||||
this.updated = false;
|
||||
final boolean terminalSearchToolTips = AEConfig.instance().getConfigManager().getSetting(Settings.SEARCH_TOOLTIPS) != YesNo.NO;
|
||||
|
||||
boolean searchMod = false;
|
||||
|
||||
this.innerSearch = searchString.toLowerCase();
|
||||
if (this.innerSearch.startsWith("@")) {
|
||||
searchMod = true;
|
||||
this.innerSearch = this.innerSearch.substring(1);
|
||||
}
|
||||
|
||||
// Since sortSrc is final, so we can safely call it inside lambda
|
||||
searchTask = CompletableFuture.supplyAsync(() -> {
|
||||
IItemList<IAEItemStack> list = this.list.clone();
|
||||
List<IAEItemStack> view = new ArrayList<>(list.size());
|
||||
Enum viewMode = this.sortSrc.getSortDisplay();
|
||||
|
||||
boolean needsZeroCopy = viewMode == ViewItems.CRAFTABLE;
|
||||
|
||||
boolean terminalSearchToolTips = AEConfig.instance().getConfigManager().getSetting(Settings.SEARCH_TOOLTIPS) != YesNo.NO;
|
||||
|
||||
boolean searchMod = false;
|
||||
|
||||
String innerSearch = searchString.toLowerCase();
|
||||
if (innerSearch.startsWith("@")) {
|
||||
searchMod = true;
|
||||
innerSearch = innerSearch.substring(1);
|
||||
}
|
||||
|
||||
Pattern m = null;
|
||||
Pattern m = null;
|
||||
try {
|
||||
m = Pattern.compile(this.innerSearch, Pattern.CASE_INSENSITIVE);
|
||||
} catch (final Throwable ignore) {
|
||||
try {
|
||||
m = Pattern.compile(innerSearch, Pattern.CASE_INSENSITIVE);
|
||||
} catch (final Throwable ignore) {
|
||||
try {
|
||||
m = Pattern.compile(Pattern.quote(innerSearch), Pattern.CASE_INSENSITIVE);
|
||||
} catch (final Throwable __) {
|
||||
return Collections.<IAEItemStack>emptyList();
|
||||
m = Pattern.compile(Pattern.quote(this.innerSearch), Pattern.CASE_INSENSITIVE);
|
||||
} catch (final Throwable __) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
boolean notDone = false;
|
||||
for (IAEItemStack is : this.list) {
|
||||
if (this.myPartitionList != null) {
|
||||
if (!this.myPartitionList.isListed(is)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (viewMode == ViewItems.CRAFTABLE && !is.isCraftable()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (IAEItemStack is : list) {
|
||||
if (this.myPartitionList != null) {
|
||||
if (!this.myPartitionList.isListed(is)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (viewMode == ViewItems.STORED && is.getStackSize() == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (viewMode == ViewItems.CRAFTABLE && !is.isCraftable()) {
|
||||
continue;
|
||||
}
|
||||
final String dspName = (searchMod ? Platform.getModId(is) : Platform.getItemDisplayName(is)).toLowerCase();
|
||||
boolean foundMatchingItemStack = true;
|
||||
|
||||
if (viewMode == ViewItems.STORED && is.getStackSize() == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final String dspName = (searchMod ? Platform.getModId(is) : Platform.getItemDisplayName(is)).toLowerCase();
|
||||
boolean foundMatchingItemStack = true;
|
||||
|
||||
for (String term : innerSearch.split(" ")) {
|
||||
if (term.length() > 1 && (term.startsWith("-") || term.startsWith("!"))) {
|
||||
term = term.substring(1);
|
||||
if (dspName.contains(term)) {
|
||||
foundMatchingItemStack = false;
|
||||
break;
|
||||
}
|
||||
} else if (!dspName.contains(term)) {
|
||||
for (String term : innerSearch.split(" ")) {
|
||||
if (term.length() > 1 && (term.startsWith("-") || term.startsWith("!"))) {
|
||||
term = term.substring(1);
|
||||
if (dspName.contains(term)) {
|
||||
foundMatchingItemStack = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (terminalSearchToolTips && !foundMatchingItemStack) {
|
||||
final List<String> tooltip = Platform.getTooltip(is);
|
||||
for (final String line : tooltip) {
|
||||
if (m.matcher(line).find()) {
|
||||
foundMatchingItemStack = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (foundMatchingItemStack) {
|
||||
if (needsZeroCopy) {
|
||||
is = is.copy();
|
||||
is.setStackSize(0);
|
||||
}
|
||||
|
||||
view.add(is);
|
||||
} else if (!dspName.contains(term)) {
|
||||
foundMatchingItemStack = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
final Enum SortBy = this.sortSrc.getSortBy();
|
||||
final Enum SortDir = this.sortSrc.getSortDir();
|
||||
|
||||
ItemSorters.setDirection((appeng.api.config.SortDir) SortDir);
|
||||
ItemSorters.init();
|
||||
|
||||
if (SortBy == SortOrder.MOD) {
|
||||
view.sort(ItemSorters.CONFIG_BASED_SORT_BY_MOD);
|
||||
} else if (SortBy == SortOrder.AMOUNT) {
|
||||
view.sort(ItemSorters.CONFIG_BASED_SORT_BY_SIZE);
|
||||
} else if (SortBy == SortOrder.INVTWEAKS) {
|
||||
if (InventoryBogoSortModule.isLoaded()) {
|
||||
view.sort(InventoryBogoSortModule.COMPARATOR);
|
||||
} else {
|
||||
view.sort(ItemSorters.CONFIG_BASED_SORT_BY_INV_TWEAKS);
|
||||
if (terminalSearchToolTips && !foundMatchingItemStack) {
|
||||
final List<String> tooltip = Platform.getTooltip(is);
|
||||
for (final String line : tooltip) {
|
||||
if (m.matcher(line).find()) {
|
||||
foundMatchingItemStack = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (foundMatchingItemStack) {
|
||||
if (needsZeroCopy) {
|
||||
is = is.copy();
|
||||
is.setStackSize(0);
|
||||
}
|
||||
|
||||
this.view.add(is);
|
||||
}
|
||||
}
|
||||
|
||||
final Enum SortBy = this.sortSrc.getSortBy();
|
||||
final Enum SortDir = this.sortSrc.getSortDir();
|
||||
|
||||
ItemSorters.setDirection((appeng.api.config.SortDir) SortDir);
|
||||
ItemSorters.init();
|
||||
|
||||
if (SortBy == SortOrder.MOD) {
|
||||
Collections.sort(this.view, ItemSorters.CONFIG_BASED_SORT_BY_MOD);
|
||||
} else if (SortBy == SortOrder.AMOUNT) {
|
||||
Collections.sort(this.view, ItemSorters.CONFIG_BASED_SORT_BY_SIZE);
|
||||
} else if (SortBy == SortOrder.INVTWEAKS) {
|
||||
if (InventoryBogoSortModule.isLoaded()) {
|
||||
Collections.sort(this.view, InventoryBogoSortModule.COMPARATOR);
|
||||
} else {
|
||||
view.sort(ItemSorters.CONFIG_BASED_SORT_BY_NAME);
|
||||
Collections.sort(this.view, ItemSorters.CONFIG_BASED_SORT_BY_INV_TWEAKS);
|
||||
}
|
||||
|
||||
return view;
|
||||
}).thenAcceptAsync(view -> {
|
||||
this.updated = true;
|
||||
this.asyncUpdatedView.addAll(view);
|
||||
}).thenRunAsync(() -> {
|
||||
this.searchTask = null; // Prevent redundant cancellation
|
||||
});
|
||||
} else {
|
||||
Collections.sort(this.view, ItemSorters.CONFIG_BASED_SORT_BY_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateJEI(String filter) {
|
||||
@@ -234,10 +211,6 @@ public class ItemRepo {
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
if (searchTask != null) {
|
||||
searchTask.cancel(true);
|
||||
searchTask = null;
|
||||
}
|
||||
this.list.resetStatus();
|
||||
}
|
||||
|
||||
@@ -263,17 +236,6 @@ public class ItemRepo {
|
||||
|
||||
public void setSearchString(@Nonnull final String searchString) {
|
||||
this.searchString = searchString;
|
||||
|
||||
if (searchTask != null) {
|
||||
searchTask.cancel(true);
|
||||
searchTask = null;
|
||||
}
|
||||
|
||||
// Passive JEI auto search
|
||||
final Enum<?> searchMode = AEConfig.instance().getConfigManager().getSetting(Settings.SEARCH_MODE);
|
||||
if (searchMode == SearchBoxMode.JEI_AUTOSEARCH || searchMode == SearchBoxMode.JEI_MANUAL_SEARCH || searchMode == SearchBoxMode.JEI_AUTOSEARCH_KEEP || searchMode == SearchBoxMode.JEI_MANUAL_SEARCH_KEEP) {
|
||||
this.updateJEI(this.searchString);
|
||||
}
|
||||
}
|
||||
|
||||
public IItemList<IAEItemStack> getList() {
|
||||
|
||||
@@ -388,7 +388,10 @@ public abstract class AEBaseContainer extends Container {
|
||||
|
||||
if (Platform.itemComparisons().isSameItem(tis, t)) // t.isItemEqual(tis))
|
||||
{
|
||||
int maxSize = d.getSlotStackLimit();
|
||||
int maxSize = t.getMaxStackSize();
|
||||
if (maxSize > d.getSlotStackLimit()) {
|
||||
maxSize = d.getSlotStackLimit();
|
||||
}
|
||||
|
||||
int placeAble = maxSize - t.getCount();
|
||||
|
||||
|
||||
+3
-4
@@ -50,6 +50,8 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import static appeng.helpers.ItemStackHelper.stackWriteToNBT;
|
||||
|
||||
|
||||
public final class ContainerInterfaceConfigurationTerminal extends AEBaseContainer {
|
||||
|
||||
@@ -310,10 +312,7 @@ public final class ContainerInterfaceConfigurationTerminal extends AEBaseContain
|
||||
ItemHandlerUtil.setStackInSlot(inv.client, x + offset, is.isEmpty() ? ItemStack.EMPTY : is.copy());
|
||||
|
||||
if (!is.isEmpty()) {
|
||||
is.writeToNBT(itemNBT);
|
||||
if (is.getCount() > Byte.MAX_VALUE) {
|
||||
itemNBT.setInteger("stackSize", is.getCount());
|
||||
}
|
||||
stackWriteToNBT(is, itemNBT);
|
||||
}
|
||||
|
||||
tag.setTag(Integer.toString(x + offset), itemNBT);
|
||||
|
||||
@@ -57,6 +57,8 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import static appeng.helpers.ItemStackHelper.stackWriteToNBT;
|
||||
|
||||
|
||||
public final class ContainerInterfaceTerminal extends AEBaseContainer {
|
||||
|
||||
@@ -345,7 +347,7 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer {
|
||||
ItemHandlerUtil.setStackInSlot(inv.client, x + offset, is.isEmpty() ? ItemStack.EMPTY : is.copy());
|
||||
|
||||
if (!is.isEmpty()) {
|
||||
is.writeToNBT(itemNBT);
|
||||
stackWriteToNBT(is, itemNBT);
|
||||
}
|
||||
|
||||
tag.setTag(Integer.toString(x + offset), itemNBT);
|
||||
|
||||
@@ -38,6 +38,8 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static appeng.helpers.ItemStackHelper.stackWriteToNBT;
|
||||
|
||||
public abstract class ContainerPatternEncoder extends ContainerMEMonitorable implements IAEAppEngInventory, IOptionalSlotHost, IContainerCraftingPacket {
|
||||
|
||||
private final AbstractPartEncoder patternTerminal;
|
||||
@@ -526,10 +528,7 @@ public abstract class ContainerPatternEncoder extends ContainerMEMonitorable imp
|
||||
final NBTTagCompound c = new NBTTagCompound();
|
||||
|
||||
if (!i.isEmpty()) {
|
||||
i.writeToNBT(c);
|
||||
if (i.getCount() > Byte.MAX_VALUE) {
|
||||
c.setInteger("stackSize", i.getCount());
|
||||
}
|
||||
stackWriteToNBT(i, c);
|
||||
}
|
||||
|
||||
return c;
|
||||
|
||||
@@ -40,7 +40,6 @@ import appeng.util.inv.AdaptorItemHandler;
|
||||
import appeng.util.inv.WrapperCursorItemHandler;
|
||||
import appeng.util.inv.WrapperInvItemHandler;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import com.blamejared.recipestages.RecipeStages;
|
||||
import com.blamejared.recipestages.recipes.RecipeStage;
|
||||
import net.darkhax.gamestages.GameStageHelper;
|
||||
import net.darkhax.itemstages.ItemStages;
|
||||
@@ -55,9 +54,10 @@ import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -101,16 +101,21 @@ public class SlotCraftingTerm extends AppEngCraftingSlot {
|
||||
@Override
|
||||
public ItemStack getStack() {
|
||||
if (Platform.isClient() && Loader.isModLoaded("itemstages")) {
|
||||
final ItemStack item = super.getStack();
|
||||
final String itemsStage = ItemStages.getStage(item);
|
||||
final String enchantStage = ItemStages.getEnchantStage(item);
|
||||
final EntityPlayer player = Minecraft.getMinecraft().player;
|
||||
|
||||
if ((itemsStage != null && !GameStageHelper.hasStage(player, itemsStage))
|
||||
|| (enchantStage != null && !GameStageHelper.hasStage(player, enchantStage)))
|
||||
return ItemStack.EMPTY;
|
||||
return itemstageStack();
|
||||
}
|
||||
return super.getStack();
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
ItemStack itemstageStack() {
|
||||
final ItemStack item = super.getStack();
|
||||
final String itemsStage = ItemStages.getStage(item);
|
||||
final String enchantStage = ItemStages.getEnchantStage(item);
|
||||
final EntityPlayer player = Minecraft.getMinecraft().player;
|
||||
|
||||
if ((itemsStage != null && !GameStageHelper.hasStage(player, itemsStage))
|
||||
|| (enchantStage != null && !GameStageHelper.hasStage(player, enchantStage)))
|
||||
return ItemStack.EMPTY;
|
||||
return super.getStack();
|
||||
}
|
||||
|
||||
@@ -196,7 +201,7 @@ public class SlotCraftingTerm extends AppEngCraftingSlot {
|
||||
final String enchantStage = ItemStages.getEnchantStage(recipe.getRecipeOutput());
|
||||
|
||||
if ((itemsStage != null && !GameStageHelper.hasStage(player, itemsStage))
|
||||
|| (enchantStage != null && !GameStageHelper.hasStage(player, enchantStage)))
|
||||
|| (enchantStage != null && !GameStageHelper.hasStage(player, enchantStage)))
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2020 Adrian Siekierka
|
||||
*
|
||||
* This file is part of StackUp.
|
||||
*
|
||||
* StackUp is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* StackUp is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with StackUp. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package appeng.core;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Map;
|
||||
|
||||
@IFMLLoadingPlugin.Name("AE2ELCore")
|
||||
@IFMLLoadingPlugin.MCVersion("1.12.2")
|
||||
@IFMLLoadingPlugin.SortingIndex(1001)
|
||||
@IFMLLoadingPlugin.TransformerExclusions("appeng.core.transformer")
|
||||
public class AE2ELCore implements IFMLLoadingPlugin {
|
||||
@Override
|
||||
public String[] getASMTransformerClass() {
|
||||
return new String[]{
|
||||
"appeng.core.transformer.AE2ELTransformer"
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModContainerClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getSetupClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectData(Map<String, Object> data) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAccessTransformerClass() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -4,10 +4,25 @@ package appeng.core.api;
|
||||
import appeng.api.config.IncludeExclude;
|
||||
import appeng.api.storage.ICellInventory;
|
||||
import appeng.api.storage.ICellInventoryHandler;
|
||||
import appeng.api.storage.channels.IFluidStorageChannel;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.api.util.IClientHelper;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.fluids.items.FluidDummyItem;
|
||||
import appeng.fluids.util.AEFluidStack;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -27,16 +42,72 @@ public class ApiClientHelper implements IClientHelper {
|
||||
.getLocal());
|
||||
}
|
||||
|
||||
IItemList<?> itemList = cellInventory.getChannel().createList();
|
||||
|
||||
if (handler.isPreformatted()) {
|
||||
final String list = (handler.getIncludeExcludeMode() == IncludeExclude.WHITELIST ? GuiText.Included : GuiText.Excluded).getLocal();
|
||||
|
||||
if (handler.isFuzzy()) {
|
||||
lines.add(GuiText.Partitioned.getLocal() + " - " + list + ' ' + GuiText.Fuzzy.getLocal());
|
||||
lines.add("[" + GuiText.Partitioned.getLocal() + "]" + " - " + list + ' ' + GuiText.Fuzzy.getLocal());
|
||||
} else {
|
||||
lines.add(GuiText.Partitioned.getLocal() + " - " + list + ' ' + GuiText.Precise.getLocal());
|
||||
lines.add("[" + GuiText.Partitioned.getLocal() + "]" + " - " + list + ' ' + GuiText.Precise.getLocal());
|
||||
}
|
||||
|
||||
if (Minecraft.getMinecraft().gameSettings.advancedItemTooltips || Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
|
||||
IItemHandler inv = cellInventory.getConfigInventory();
|
||||
cellInventory.getAvailableItems((IItemList) itemList);
|
||||
for (int i = 0; i < inv.getSlots(); i++) {
|
||||
final ItemStack is = inv.getStackInSlot(i);
|
||||
if (!is.isEmpty()) {
|
||||
if (cellInventory.getChannel() instanceof IItemStorageChannel) {
|
||||
if (!handler.isFuzzy()) {
|
||||
final IAEItemStack ais = AEItemStack.fromItemStack(is);
|
||||
IAEItemStack stocked = ((IItemList<IAEItemStack>) itemList).findPrecise(ais);
|
||||
lines.add("[" + is.getDisplayName() + "]" + ": " + (stocked == null ? "0" : String.valueOf(stocked.getStackSize())));
|
||||
} else {
|
||||
final IAEItemStack ais = AEItemStack.fromItemStack(is);
|
||||
Collection<IAEItemStack> stocked = ((IItemList<IAEItemStack>) itemList).findFuzzy(ais, handler.getCellInv().getFuzzyMode());
|
||||
|
||||
int[] ids = OreDictionary.getOreIDs(is);
|
||||
long size = 0;
|
||||
for (IAEItemStack ist : stocked) {
|
||||
size += ist.getStackSize();
|
||||
}
|
||||
|
||||
if (is.getItem().isDamageable()) {
|
||||
lines.add("[" + is.getDisplayName() + "]" + ": " + size);
|
||||
} else if (ids.length > 0) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int j : ids) {
|
||||
sb.append(OreDictionary.getOreName(j)).append(", ");
|
||||
}
|
||||
lines.add("[{" + sb.substring(0, sb.length() - 2) + "}]" + ": " + size);
|
||||
}
|
||||
}
|
||||
} else if (cellInventory.getChannel() instanceof IFluidStorageChannel) {
|
||||
final AEFluidStack ais;
|
||||
if (is.getItem() instanceof FluidDummyItem) {
|
||||
ais = AEFluidStack.fromFluidStack(((FluidDummyItem) is.getItem()).getFluidStack(is));
|
||||
} else {
|
||||
ais = AEFluidStack.fromFluidStack(FluidUtil.getFluidContained(is));
|
||||
}
|
||||
IAEFluidStack stocked = ((IItemList<IAEFluidStack>) itemList).findPrecise(ais);
|
||||
lines.add("[" + is.getDisplayName() + "]" + ": " + (stocked == null ? "0" : String.valueOf(stocked.getStackSize())));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (Minecraft.getMinecraft().gameSettings.advancedItemTooltips || Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
|
||||
cellInventory.getAvailableItems((IItemList) itemList);
|
||||
for (IAEStack<?> s : itemList) {
|
||||
if (s instanceof IAEItemStack) {
|
||||
lines.add(((IAEItemStack) s).getDefinition().getDisplayName() + ": " + s.getStackSize());
|
||||
} else if (s instanceof IAEFluidStack) {
|
||||
lines.add(((IAEFluidStack) s).getFluidStack().getLocalizedName() + ": " + s.getStackSize() + "mB");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ package appeng.core.api.imc;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.api.IIMCProcessor;
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
import net.minecraftforge.fml.common.event.FMLInterModComms.IMCMessage;
|
||||
|
||||
|
||||
@@ -37,7 +38,7 @@ public class IMCSpatial implements IIMCProcessor {
|
||||
public void process(final IMCMessage m) {
|
||||
|
||||
try {
|
||||
final Class classInstance = Class.forName(m.getStringValue());
|
||||
final Class classInstance = Class.forName(m.getStringValue(), false, Launch.classLoader);
|
||||
AEApi.instance().registries().movable().whiteListTileEntity(classInstance);
|
||||
} catch (final ClassNotFoundException e) {
|
||||
AELog.info("Bad Class Registered: " + m.getStringValue() + " by " + m.getSender());
|
||||
|
||||
@@ -63,6 +63,8 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static appeng.helpers.ItemStackHelper.stackFromNBT;
|
||||
|
||||
|
||||
public class PacketJEIRecipe extends AppEngPacket {
|
||||
|
||||
@@ -85,7 +87,7 @@ public class PacketJEIRecipe extends AppEngPacket {
|
||||
if (list.tagCount() > 0) {
|
||||
this.recipe.add(new ItemStack[list.tagCount()]);
|
||||
for (int y = 0; y < list.tagCount(); y++) {
|
||||
this.recipe.get(x)[y] = new ItemStack(list.getCompoundTagAt(y));
|
||||
this.recipe.get(x)[y] = stackFromNBT(list.getCompoundTagAt(y));
|
||||
}
|
||||
} else {
|
||||
this.recipe.add(emptyArray);
|
||||
@@ -97,7 +99,7 @@ public class PacketJEIRecipe extends AppEngPacket {
|
||||
final NBTTagList outputList = comp.getTagList("outputs", 10);
|
||||
this.output = new ArrayList<>();
|
||||
for (int z = 0; z < outputList.tagCount(); z++) {
|
||||
this.output.add(new ItemStack(outputList.getCompoundTagAt(z)));
|
||||
this.output.add(stackFromNBT(outputList.getCompoundTagAt(z)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2020 Adrian Siekierka
|
||||
*
|
||||
* This file is part of StackUp.
|
||||
*
|
||||
* StackUp is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* StackUp is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with StackUp. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package appeng.core.transformer;
|
||||
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class AE2ELTransformer implements IClassTransformer {
|
||||
|
||||
@Override
|
||||
public byte[] transform(String name, String transformedName, byte[] basicClass) {
|
||||
transformedName = transformedName.replace('/', '.');
|
||||
|
||||
byte[] data = basicClass;
|
||||
Consumer<ClassNode> consumer = (n) -> {
|
||||
};
|
||||
Consumer<ClassNode> emptyConsumer = consumer;
|
||||
|
||||
if ("net.minecraft.item.ItemStack".equals(transformedName)) {
|
||||
consumer = consumer.andThen(ItemStackPatch::patchCountGetSet);
|
||||
}
|
||||
|
||||
if (consumer != emptyConsumer) {
|
||||
return processNode(basicClass, consumer);
|
||||
} else {
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] processNode(byte[] data, Consumer<ClassNode> classNodeConsumer) {
|
||||
ClassReader reader = new ClassReader(data);
|
||||
ClassNode nodeOrig = new ClassNode();
|
||||
reader.accept(nodeOrig, 0);
|
||||
classNodeConsumer.accept(nodeOrig);
|
||||
ClassWriter writer = new ClassWriter(0);
|
||||
nodeOrig.accept(writer);
|
||||
return writer.toByteArray();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2020 Adrian Siekierka
|
||||
*
|
||||
* This file is part of StackUp.
|
||||
*
|
||||
* StackUp is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* StackUp is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with StackUp. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package appeng.core.transformer;
|
||||
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.tree.AbstractInsnNode;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.objectweb.asm.tree.LdcInsnNode;
|
||||
import org.objectweb.asm.tree.MethodInsnNode;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
|
||||
import java.util.ListIterator;
|
||||
|
||||
public final class ItemStackPatch {
|
||||
private ItemStackPatch() {
|
||||
}
|
||||
|
||||
public static void patchCountGetSet(ClassNode node) {
|
||||
for (MethodNode mn : node.methods) {
|
||||
if ("<init>".equals(mn.name)) {
|
||||
ListIterator<AbstractInsnNode> it = mn.instructions.iterator();
|
||||
while (it.hasNext()) {
|
||||
AbstractInsnNode in = it.next();
|
||||
if (in instanceof LdcInsnNode && "Count".equals(((LdcInsnNode) in).cst)) {
|
||||
AbstractInsnNode in2 = it.next();
|
||||
if (in2.getOpcode() == Opcodes.INVOKEVIRTUAL) {
|
||||
// :thinking:
|
||||
boolean patched = false;
|
||||
MethodInsnNode min2 = (MethodInsnNode) in2;
|
||||
if (min2.name.equals("getByte")) {
|
||||
min2.name = "getInteger";
|
||||
patched = true;
|
||||
} else if (min2.name.equals("func_74771_c")) {
|
||||
min2.name = "func_74762_e";
|
||||
patched = true;
|
||||
}
|
||||
|
||||
if (patched) {
|
||||
min2.desc = "(Ljava/lang/String;)I";
|
||||
System.out.println("Patched ItemStack Count getter!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if ("func_77955_b".equals(mn.name) || "writeToNBT".equals(mn.name)) {
|
||||
ListIterator<AbstractInsnNode> it = mn.instructions.iterator();
|
||||
while (it.hasNext()) {
|
||||
AbstractInsnNode in = it.next();
|
||||
if (in instanceof LdcInsnNode && "Count".equals(((LdcInsnNode) in).cst)) {
|
||||
it.next();
|
||||
it.next();
|
||||
it.next();
|
||||
AbstractInsnNode in2 = it.next();
|
||||
if (in2.getOpcode() == Opcodes.INVOKEVIRTUAL) {
|
||||
// :thinking:
|
||||
boolean patched = false;
|
||||
MethodInsnNode min2 = (MethodInsnNode) in2;
|
||||
if (min2.name.equals("setByte")) {
|
||||
min2.name = "setInteger";
|
||||
patched = true;
|
||||
} else if (min2.name.equals("func_74774_a")) {
|
||||
min2.name = "func_74768_a";
|
||||
patched = true;
|
||||
}
|
||||
|
||||
if (patched) {
|
||||
min2.desc = "(Ljava/lang/String;I)V";
|
||||
System.out.println("Patched ItemStack Count setter!");
|
||||
|
||||
// Remove I2B cast
|
||||
it.previous();
|
||||
it.previous();
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -161,13 +161,6 @@ public final class FluidList implements IItemList<IAEFluidStack> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidList clone() {
|
||||
FluidList list = new FluidList();
|
||||
list.records.putAll(records);
|
||||
return list;
|
||||
}
|
||||
|
||||
private IAEFluidStack getFluidRecord(final IAEFluidStack fluid) {
|
||||
return this.records.get(fluid);
|
||||
}
|
||||
|
||||
@@ -101,6 +101,8 @@ import net.minecraftforge.items.wrapper.RangedWrapper;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
|
||||
import static appeng.helpers.ItemStackHelper.*;
|
||||
|
||||
|
||||
public class DualityInterface implements IGridTickable, IStorageMonitorable, IInventoryDestination, IAEAppEngInventory, IConfigManagerHost, ICraftingProvider, IUpgradeableHost {
|
||||
public static final int NUMBER_OF_STORAGE_SLOTS = 9;
|
||||
@@ -208,12 +210,8 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
final NBTTagList waitingToSend = new NBTTagList();
|
||||
if (this.waitingToSend != null) {
|
||||
for (final ItemStack is : this.waitingToSend) {
|
||||
final NBTTagCompound item = new NBTTagCompound();
|
||||
is.writeToNBT(item);
|
||||
if (is.getCount() > Byte.MAX_VALUE) {
|
||||
item.setInteger("stackSize", is.getCount());
|
||||
}
|
||||
waitingToSend.appendTag(item);
|
||||
final NBTTagCompound itemNBT = stackToNBT(is);
|
||||
waitingToSend.appendTag(itemNBT);
|
||||
}
|
||||
}
|
||||
data.setTag("waitingToSend", waitingToSend);
|
||||
@@ -225,12 +223,8 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
NBTTagList waitingListSided = new NBTTagList();
|
||||
if (this.waitingToSendFacing.containsKey(s)) {
|
||||
for (final ItemStack is : this.waitingToSendFacing.get(s)) {
|
||||
final NBTTagCompound item = new NBTTagCompound();
|
||||
is.writeToNBT(item);
|
||||
if (is.getCount() > Byte.MAX_VALUE) {
|
||||
item.setInteger("stackSize", is.getCount());
|
||||
}
|
||||
waitingListSided.appendTag(item);
|
||||
final NBTTagCompound itemNBT = stackToNBT(is);
|
||||
waitingListSided.appendTag(itemNBT);
|
||||
}
|
||||
sidedWaitList.setTag(s.name(), waitingListSided);
|
||||
}
|
||||
@@ -246,10 +240,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
for (int x = 0; x < waitingList.tagCount(); x++) {
|
||||
final NBTTagCompound c = waitingList.getCompoundTagAt(x);
|
||||
if (c != null) {
|
||||
final ItemStack is = new ItemStack(c);
|
||||
if (c.hasKey("stackSize")) {
|
||||
is.setCount(c.getInteger("stackSize"));
|
||||
}
|
||||
final ItemStack is = stackFromNBT(c);
|
||||
this.addToSendList(is);
|
||||
}
|
||||
}
|
||||
@@ -264,10 +255,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
for (int x = 0; x < w.tagCount(); x++) {
|
||||
final NBTTagCompound c = w.getCompoundTagAt(x);
|
||||
if (c != null) {
|
||||
final ItemStack is = new ItemStack(c);
|
||||
if (c.hasKey("stackSize")) {
|
||||
is.setCount(c.getInteger("stackSize"));
|
||||
}
|
||||
final ItemStack is = stackFromNBT(c);
|
||||
this.addToSendListFacing(is, EnumFacing.getFront(s.getIndex()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@ import net.minecraft.util.text.TextFormatting;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static appeng.helpers.ItemStackHelper.stackFromNBT;
|
||||
|
||||
|
||||
public class InvalidPatternHelper {
|
||||
|
||||
@@ -89,11 +91,14 @@ public class InvalidPatternHelper {
|
||||
private final ItemStack stack;
|
||||
|
||||
public PatternIngredient(NBTTagCompound tag) {
|
||||
this.stack = new ItemStack(tag);
|
||||
this.stack = stackFromNBT(tag);
|
||||
|
||||
if (this.stack.isEmpty()) {
|
||||
this.id = tag.getString("id");
|
||||
this.count = tag.getByte("Count");
|
||||
if (tag.hasKey("stackSize")) {
|
||||
this.count = tag.getInteger("stackSize");
|
||||
}
|
||||
this.damage = Math.max(0, tag.getShort("Damage"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package appeng.helpers;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
/**
|
||||
* Methods to help with the added "stackSize" NBT tag to get around "Count" being written and read as a byte.
|
||||
*/
|
||||
public class ItemStackHelper {
|
||||
public static ItemStack stackFromNBT(NBTTagCompound itemNBT) {
|
||||
ItemStack is = new ItemStack(itemNBT);
|
||||
if (itemNBT.hasKey("stackSize")) {
|
||||
is.setCount(itemNBT.getInteger("stackSize"));
|
||||
}
|
||||
return is;
|
||||
}
|
||||
|
||||
public static void stackWriteToNBT(ItemStack is, NBTTagCompound itemNBT) {
|
||||
is.writeToNBT(itemNBT);
|
||||
if (is.getCount() > Byte.MAX_VALUE) {
|
||||
itemNBT.setInteger("stackSize", is.getCount());
|
||||
}
|
||||
}
|
||||
|
||||
public static NBTTagCompound stackToNBT(ItemStack is) {
|
||||
NBTTagCompound itemNBT = new NBTTagCompound();
|
||||
stackWriteToNBT(is, itemNBT);
|
||||
return itemNBT;
|
||||
}
|
||||
}
|
||||
@@ -40,6 +40,8 @@ import net.minecraftforge.common.crafting.IShapedRecipe;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static appeng.helpers.ItemStackHelper.stackFromNBT;
|
||||
|
||||
|
||||
public class PatternHelper implements ICraftingPatternDetails, Comparable<PatternHelper> {
|
||||
|
||||
@@ -91,11 +93,7 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable<Patter
|
||||
|
||||
for (int x = 0; x < inTag.tagCount(); x++) {
|
||||
NBTTagCompound ingredient = inTag.getCompoundTagAt(x);
|
||||
final ItemStack gs = new ItemStack(ingredient);
|
||||
|
||||
if (ingredient.hasKey("stackSize")) {
|
||||
gs.setCount(ingredient.getInteger("stackSize"));
|
||||
}
|
||||
final ItemStack gs = stackFromNBT(ingredient);
|
||||
|
||||
if (!ingredient.hasNoTags() && gs.isEmpty()) {
|
||||
throw new IllegalArgumentException("No pattern here!");
|
||||
@@ -126,11 +124,7 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable<Patter
|
||||
|
||||
for (int x = 0; x < outTag.tagCount(); x++) {
|
||||
NBTTagCompound resultItemTag = outTag.getCompoundTagAt(x);
|
||||
final ItemStack gs = new ItemStack(resultItemTag);
|
||||
|
||||
if (resultItemTag.hasKey("stackSize")) {
|
||||
gs.setCount(resultItemTag.getInteger("stackSize"));
|
||||
}
|
||||
final ItemStack gs = stackFromNBT(resultItemTag);
|
||||
|
||||
if (!resultItemTag.hasNoTags() && gs.isEmpty()) {
|
||||
throw new IllegalArgumentException("No pattern here!");
|
||||
|
||||
@@ -48,6 +48,8 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static appeng.helpers.ItemStackHelper.stackToNBT;
|
||||
|
||||
|
||||
class RecipeTransferHandler<T extends Container> implements IRecipeTransferHandler<T> {
|
||||
|
||||
@@ -108,8 +110,7 @@ class RecipeTransferHandler<T extends Container> implements IRecipeTransferHandl
|
||||
if (!ingredient.isInput()) {
|
||||
ItemStack output = ingredient.getDisplayedIngredient();
|
||||
if (output != null) {
|
||||
final NBTTagCompound tag = new NBTTagCompound();
|
||||
output.writeToNBT(tag);
|
||||
final NBTTagCompound tag = stackToNBT(output);
|
||||
outputs.appendTag(tag);
|
||||
}
|
||||
continue;
|
||||
@@ -140,8 +141,7 @@ class RecipeTransferHandler<T extends Container> implements IRecipeTransferHandl
|
||||
}
|
||||
|
||||
for (final ItemStack is : list) {
|
||||
final NBTTagCompound tag = new NBTTagCompound();
|
||||
is.writeToNBT(tag);
|
||||
final NBTTagCompound tag = stackToNBT(is);
|
||||
tags.appendTag(tag);
|
||||
}
|
||||
|
||||
|
||||
+4
-6
@@ -138,16 +138,14 @@ public class SecurityCache implements ISecurityGrid {
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(final int playerID, final SecurityPermissions perm) {
|
||||
if (playerID == -1) {
|
||||
return true;
|
||||
}
|
||||
if (this.isAvailable()) {
|
||||
final EnumSet<SecurityPermissions> perms = this.playerPerms.get(playerID);
|
||||
|
||||
if (perms == null) {
|
||||
if (playerID == -1) // no default?
|
||||
{
|
||||
return false;
|
||||
} else {
|
||||
return this.hasPermission(-1, perm);
|
||||
}
|
||||
return this.hasPermission(-1, perm);
|
||||
}
|
||||
|
||||
return perms.contains(perm);
|
||||
|
||||
@@ -138,18 +138,12 @@ public final class CompassService {
|
||||
public void kill() {
|
||||
this.executor.shutdown();
|
||||
|
||||
try {
|
||||
this.executor.awaitTermination(6, TimeUnit.MINUTES);
|
||||
this.jobSize = 0;
|
||||
|
||||
for (final CompassReader cr : this.worldSet.values()) {
|
||||
cr.close();
|
||||
}
|
||||
|
||||
this.worldSet.clear();
|
||||
} catch (final InterruptedException e) {
|
||||
// wrap this up..
|
||||
this.jobSize = 0;
|
||||
for (final CompassReader cr : this.worldSet.values()) {
|
||||
cr.close();
|
||||
}
|
||||
|
||||
this.worldSet.clear();
|
||||
}
|
||||
|
||||
private CompassReader getReader(final World w) {
|
||||
|
||||
@@ -39,6 +39,9 @@ import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
import static appeng.helpers.ItemStackHelper.stackFromNBT;
|
||||
import static appeng.helpers.ItemStackHelper.stackWriteToNBT;
|
||||
|
||||
|
||||
public abstract class AEBaseInvTile extends AEBaseTile implements IAEAppEngInventory {
|
||||
|
||||
@@ -50,7 +53,7 @@ public abstract class AEBaseInvTile extends AEBaseTile implements IAEAppEngInven
|
||||
final NBTTagCompound opt = data.getCompoundTag("inv");
|
||||
for (int x = 0; x < inv.getSlots(); x++) {
|
||||
final NBTTagCompound item = opt.getCompoundTag("item" + x);
|
||||
ItemHandlerUtil.setStackInSlot(inv, x, new ItemStack(item));
|
||||
ItemHandlerUtil.setStackInSlot(inv, x, stackFromNBT(item));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -65,12 +68,12 @@ public abstract class AEBaseInvTile extends AEBaseTile implements IAEAppEngInven
|
||||
if (inv != EmptyHandler.INSTANCE) {
|
||||
final NBTTagCompound opt = new NBTTagCompound();
|
||||
for (int x = 0; x < inv.getSlots(); x++) {
|
||||
final NBTTagCompound item = new NBTTagCompound();
|
||||
final NBTTagCompound itemNBT = new NBTTagCompound();
|
||||
final ItemStack is = inv.getStackInSlot(x);
|
||||
if (!is.isEmpty()) {
|
||||
is.writeToNBT(item);
|
||||
stackWriteToNBT(is, itemNBT);
|
||||
}
|
||||
opt.setTag("item" + x, item);
|
||||
opt.setTag("item" + x, itemNBT);
|
||||
}
|
||||
data.setTag("inv", opt);
|
||||
}
|
||||
|
||||
@@ -80,6 +80,9 @@ import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static appeng.helpers.ItemStackHelper.stackFromNBT;
|
||||
import static appeng.helpers.ItemStackHelper.stackWriteToNBT;
|
||||
|
||||
|
||||
public class TileMolecularAssembler extends AENetworkInvTile implements IUpgradeableHost, IConfigManagerHost, IGridTickable, ICraftingMachine, IPowerChannelState {
|
||||
private final InventoryCrafting craftingInv;
|
||||
@@ -288,7 +291,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
|
||||
final ItemStack pattern = this.myPlan.getPattern();
|
||||
if (!pattern.isEmpty()) {
|
||||
final NBTTagCompound compound = new NBTTagCompound();
|
||||
pattern.writeToNBT(compound);
|
||||
stackWriteToNBT(pattern, compound);
|
||||
data.setTag("myPlan", compound);
|
||||
data.setInteger("pushDirection", this.pushDirection.ordinal());
|
||||
}
|
||||
@@ -303,7 +306,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
|
||||
public void readFromNBT(final NBTTagCompound data) {
|
||||
super.readFromNBT(data);
|
||||
if (data.hasKey("myPlan")) {
|
||||
final ItemStack myPat = new ItemStack(data.getCompoundTag("myPlan"));
|
||||
final ItemStack myPat = stackFromNBT(data.getCompoundTag("myPlan"));
|
||||
|
||||
if (!myPat.isEmpty() && myPat.getItem() instanceof ItemEncodedPattern) {
|
||||
final World w = this.getWorld();
|
||||
|
||||
@@ -35,6 +35,9 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
|
||||
import static appeng.helpers.ItemStackHelper.stackFromNBT;
|
||||
import static appeng.helpers.ItemStackHelper.stackToNBT;
|
||||
|
||||
|
||||
public class AppEngInternalInventory extends ItemStackHandler implements Iterable<ItemStack> {
|
||||
protected boolean enableClientEvents = false;
|
||||
@@ -162,12 +165,8 @@ public class AppEngInternalInventory extends ItemStackHandler implements Iterabl
|
||||
for (int i = 0; i < stacks.size(); i++) {
|
||||
ItemStack is = stacks.get(i);
|
||||
if (!is.isEmpty()) {
|
||||
NBTTagCompound itemTag = new NBTTagCompound();
|
||||
NBTTagCompound itemTag = stackToNBT(is);
|
||||
itemTag.setInteger("Slot", i);
|
||||
if (is.getCount() > Byte.MAX_VALUE) {
|
||||
itemTag.setInteger("stackSize", stacks.get(i).getCount());
|
||||
}
|
||||
stacks.get(i).writeToNBT(itemTag);
|
||||
nbtTagList.appendTag(itemTag);
|
||||
}
|
||||
}
|
||||
@@ -196,11 +195,7 @@ public class AppEngInternalInventory extends ItemStackHandler implements Iterabl
|
||||
NBTTagCompound itemTags = tagList.getCompoundTagAt(i);
|
||||
int slot = itemTags.getInteger("Slot");
|
||||
if (slot >= 0 && slot < stacks.size()) {
|
||||
stacks.set(slot, new ItemStack(itemTags));
|
||||
if (itemTags.hasKey("stackSize")) {
|
||||
int stackSize = itemTags.getInteger("stackSize");
|
||||
stacks.get(slot).setCount(stackSize);
|
||||
}
|
||||
stacks.set(slot, stackFromNBT(itemTags));
|
||||
}
|
||||
}
|
||||
onLoad();
|
||||
|
||||
@@ -71,6 +71,8 @@ import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static appeng.helpers.ItemStackHelper.stackFromNBT;
|
||||
|
||||
|
||||
public class TileSecurityStation extends AENetworkTile implements ITerminalHost, IAEAppEngInventory, ILocatable, IConfigManagerHost, ISecurityProvider, IColorableTile {
|
||||
|
||||
@@ -175,7 +177,7 @@ public class TileSecurityStation extends AENetworkTile implements ITerminalHost,
|
||||
for (final Object key : storedItems.getKeySet()) {
|
||||
final NBTBase obj = storedItems.getTag((String) key);
|
||||
if (obj instanceof NBTTagCompound) {
|
||||
this.inventory.getStoredItems().add(AEItemStack.fromItemStack(new ItemStack((NBTTagCompound) obj)));
|
||||
this.inventory.getStoredItems().add(AEItemStack.fromItemStack(stackFromNBT((NBTTagCompound) obj)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,9 +94,4 @@ public class ItemListIgnoreCrafting<T extends IAEStack<T>> implements IItemList<
|
||||
public void resetStatus() {
|
||||
this.target.resetStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemListIgnoreCrafting<T> clone() {
|
||||
return new ItemListIgnoreCrafting<>(target);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,14 +140,6 @@ public final class ItemList implements IItemList<IAEItemStack> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemList clone() {
|
||||
ItemList list = new ItemList();
|
||||
list.records.putAll(records);
|
||||
list.version.set(version.get());
|
||||
return list;
|
||||
}
|
||||
|
||||
private ItemVariantList getOrCreateRecord(Item item) {
|
||||
return this.records.computeIfAbsent(item, this::makeRecordMap);
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"parent": "appliedenergistics2:part/p2p/p2p_tunnel_base",
|
||||
"textures": {
|
||||
"type": "blocks/redstone_block"
|
||||
"type": "appliedenergistics2:blocks/redstone_p2p"
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 140 B |
Reference in New Issue
Block a user