Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 653557bc65 | |||
| dde87448a9 |
@@ -83,7 +83,9 @@ configurations {
|
||||
dependencies {
|
||||
// deobfCompile "gregtechce:gregtech:1.12.2:1.15.1.735"
|
||||
// installable runtime dependencies
|
||||
deobfCompile "curse.maven:gregtechceu-557242:3949406"
|
||||
//deobfCompile "curse.maven:gregtechceu-557242:3949406"
|
||||
|
||||
compileOnly(files("etc/gregtech-1.12.2-2.4.4-beta.jar"))
|
||||
|
||||
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>
|
||||
public interface IItemList<T extends IAEStack<T>> extends IItemContainer<T>, Iterable<T>, Cloneable
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -85,4 +85,9 @@ 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();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.enderio.core.common.interfaces;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public interface IOverlayRenderAware {
|
||||
|
||||
public void renderItemOverlayIntoGUI(@Nonnull ItemStack stack, int xPosition, int yPosition);
|
||||
|
||||
}
|
||||
@@ -103,6 +103,7 @@ 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) {
|
||||
@@ -161,8 +162,7 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
|
||||
}
|
||||
|
||||
if (!this.delayedUpdate) {
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
this.updateView = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -319,8 +319,7 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
|
||||
this.searchField.setText(memoryText);
|
||||
this.searchField.selectAll();
|
||||
this.repo.setSearchString(memoryText);
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
this.updateView = true;
|
||||
}
|
||||
|
||||
craftingGridOffsetX = Integer.MAX_VALUE;
|
||||
@@ -381,8 +380,7 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
|
||||
if (btn == 1 && this.searchField.isMouseIn(xCoord, yCoord)) {
|
||||
this.searchField.setText("");
|
||||
this.repo.setSearchString("");
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
this.updateView = true;
|
||||
}
|
||||
|
||||
super.mouseClicked(xCoord, yCoord, btn);
|
||||
@@ -476,8 +474,7 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
|
||||
|
||||
if (this.searchField.textboxKeyTyped(character, key)) {
|
||||
this.repo.setSearchString(this.searchField.getText());
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
this.updateView = true;
|
||||
// tell forge the key event is handled and should not be sent out
|
||||
this.keyHandled = mouseInGui;
|
||||
} else {
|
||||
@@ -504,7 +501,7 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
|
||||
this.delayedUpdate = false;
|
||||
}
|
||||
}
|
||||
if (!this.delayedUpdate) {
|
||||
if (!this.delayedUpdate && updateView) {
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
}
|
||||
@@ -540,7 +537,7 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
|
||||
this.ViewBox.set(this.configSrc.getSetting(Settings.VIEW_MODE));
|
||||
}
|
||||
|
||||
this.repo.updateView();
|
||||
this.updateView = true;
|
||||
}
|
||||
|
||||
int getReservedSpace() {
|
||||
|
||||
@@ -55,6 +55,8 @@ 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();
|
||||
@@ -206,9 +208,17 @@ public class GuiNetworkStatus extends AEBaseGui implements ISortSource {
|
||||
for (final IAEItemStack is : list) {
|
||||
this.repo.postUpdate(is);
|
||||
}
|
||||
this.updateView = true;
|
||||
}
|
||||
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
@Override
|
||||
public void updateScreen() {
|
||||
if (updateView) {
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
updateView = false;
|
||||
}
|
||||
super.updateScreen();
|
||||
}
|
||||
|
||||
private void setScrollBar() {
|
||||
|
||||
@@ -39,19 +39,22 @@ 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 ArrayList<IAEItemStack> view = new ArrayList<>();
|
||||
private final List<IAEItemStack> view;
|
||||
private List<IAEItemStack> asyncUpdatedView;
|
||||
private boolean updated;
|
||||
private final IScrollSource src;
|
||||
private final ISortSource sortSrc;
|
||||
|
||||
private int rowSize = 9;
|
||||
|
||||
private String searchString = "";
|
||||
private volatile String searchString = "";
|
||||
private IPartitionList<IAEItemStack> myPartitionList;
|
||||
private String innerSearch = "";
|
||||
private boolean hasPower;
|
||||
@@ -59,11 +62,14 @@ 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;
|
||||
}
|
||||
@@ -95,111 +101,128 @@ public class ItemRepo {
|
||||
this.updateView();
|
||||
}
|
||||
|
||||
private CompletableFuture<Void> searchTask = null;
|
||||
|
||||
public void updateView() {
|
||||
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 (searchTask != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
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);
|
||||
if (updated) {
|
||||
this.view.clear();
|
||||
this.view.addAll(asyncUpdatedView);
|
||||
this.asyncUpdatedView.clear();
|
||||
this.updated = false;
|
||||
}
|
||||
|
||||
Pattern m = null;
|
||||
try {
|
||||
m = Pattern.compile(this.innerSearch, Pattern.CASE_INSENSITIVE);
|
||||
} catch (final Throwable ignore) {
|
||||
try {
|
||||
m = Pattern.compile(Pattern.quote(this.innerSearch), Pattern.CASE_INSENSITIVE);
|
||||
} catch (final Throwable __) {
|
||||
return;
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
boolean notDone = false;
|
||||
for (IAEItemStack is : this.list) {
|
||||
if (this.myPartitionList != null) {
|
||||
if (!this.myPartitionList.isListed(is)) {
|
||||
continue;
|
||||
Pattern m = null;
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
if (viewMode == ViewItems.CRAFTABLE && !is.isCraftable()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (viewMode == ViewItems.STORED && is.getStackSize() == 0) {
|
||||
continue;
|
||||
}
|
||||
for (IAEItemStack is : list) {
|
||||
if (this.myPartitionList != null) {
|
||||
if (!this.myPartitionList.isListed(is)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
final String dspName = (searchMod ? Platform.getModId(is) : Platform.getItemDisplayName(is)).toLowerCase();
|
||||
boolean foundMatchingItemStack = true;
|
||||
if (viewMode == ViewItems.CRAFTABLE && !is.isCraftable()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (String term : innerSearch.split(" ")) {
|
||||
if (term.length() > 1 && (term.startsWith("-") || term.startsWith("!"))) {
|
||||
term = term.substring(1);
|
||||
if (dspName.contains(term)) {
|
||||
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)) {
|
||||
foundMatchingItemStack = false;
|
||||
break;
|
||||
}
|
||||
} else 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 (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);
|
||||
if (foundMatchingItemStack) {
|
||||
if (needsZeroCopy) {
|
||||
is = is.copy();
|
||||
is.setStackSize(0);
|
||||
}
|
||||
|
||||
view.add(is);
|
||||
}
|
||||
|
||||
this.view.add(is);
|
||||
}
|
||||
}
|
||||
|
||||
final Enum SortBy = this.sortSrc.getSortBy();
|
||||
final Enum SortDir = this.sortSrc.getSortDir();
|
||||
final Enum SortBy = this.sortSrc.getSortBy();
|
||||
final Enum SortDir = this.sortSrc.getSortDir();
|
||||
|
||||
ItemSorters.setDirection((appeng.api.config.SortDir) SortDir);
|
||||
ItemSorters.init();
|
||||
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);
|
||||
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);
|
||||
}
|
||||
} else {
|
||||
Collections.sort(this.view, ItemSorters.CONFIG_BASED_SORT_BY_INV_TWEAKS);
|
||||
view.sort(ItemSorters.CONFIG_BASED_SORT_BY_NAME);
|
||||
}
|
||||
} else {
|
||||
Collections.sort(this.view, ItemSorters.CONFIG_BASED_SORT_BY_NAME);
|
||||
}
|
||||
|
||||
return view;
|
||||
}).thenAcceptAsync(view -> {
|
||||
this.updated = true;
|
||||
this.asyncUpdatedView.addAll(view);
|
||||
}).thenRunAsync(() -> {
|
||||
this.searchTask = null; // Prevent redundant cancellation
|
||||
});
|
||||
}
|
||||
|
||||
private void updateJEI(String filter) {
|
||||
@@ -211,6 +234,10 @@ public class ItemRepo {
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
if (searchTask != null) {
|
||||
searchTask.cancel(true);
|
||||
searchTask = null;
|
||||
}
|
||||
this.list.resetStatus();
|
||||
}
|
||||
|
||||
@@ -236,6 +263,17 @@ 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() {
|
||||
|
||||
@@ -41,7 +41,6 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@Optional.Interface(iface = "gregtech.api.items.IToolItem", modid = "gregtech")
|
||||
public class CraftingTreeNode {
|
||||
|
||||
// what slot!
|
||||
|
||||
@@ -161,6 +161,13 @@ 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);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
package appeng.integration.modules.gregtech;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
import net.minecraftforge.fml.relauncher.ReflectionHelper;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class ToolClass {
|
||||
private static Class<?> GTToolClass;
|
||||
private static Method getMaxItemDamage = null;
|
||||
private static Method getItemDamage = null;
|
||||
|
||||
static {
|
||||
try {
|
||||
GTToolClass = Class.forName("gregtech.api.items.IToolItem", false, Launch.classLoader);
|
||||
getItemDamage = ReflectionHelper.findMethod(GTToolClass, "getItemDamage", null, ItemStack.class);
|
||||
getMaxItemDamage = ReflectionHelper.findMethod(GTToolClass, "getMaxItemDamage", null, ItemStack.class);
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
try {
|
||||
GTToolClass = Class.forName("gregtech.api.items.toolitem.IGTTool", false, Launch.classLoader);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static final Enum<Interfaces> GTToolInterface = getGTToolInterface();
|
||||
|
||||
public static Class<?> getGTToolClass() {
|
||||
if (GTToolClass == null) {
|
||||
System.out.printf("TToolClass == null");
|
||||
}
|
||||
return GTToolClass;
|
||||
}
|
||||
|
||||
public static Enum<Interfaces> getGTToolInterface() {
|
||||
if (GTToolClass.getName().equals("IToolItem")) {
|
||||
return Interfaces.ITOOLITEM;
|
||||
} else {
|
||||
return Interfaces.IGTTOOL;
|
||||
}
|
||||
}
|
||||
|
||||
public static int getGTMaxDamage(ItemStack itemStack) {
|
||||
if (GTToolInterface == Interfaces.ITOOLITEM) {
|
||||
try {
|
||||
return (int) getMaxItemDamage.invoke(itemStack.getItem(), itemStack);
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
} else {
|
||||
return itemStack.getMaxDamage();
|
||||
}
|
||||
}
|
||||
|
||||
public static int getGTitemDamage(ItemStack itemStack) {
|
||||
if (GTToolInterface == Interfaces.ITOOLITEM) {
|
||||
try {
|
||||
return (int) getItemDamage.invoke(itemStack.getItem(), itemStack);
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
} else {
|
||||
return itemStack.getItemDamage();
|
||||
}
|
||||
}
|
||||
|
||||
enum Interfaces {
|
||||
ITOOLITEM,
|
||||
IGTTOOL
|
||||
}
|
||||
}
|
||||
@@ -56,6 +56,7 @@ import appeng.fluids.util.AEFluidStack;
|
||||
import appeng.hooks.TickHandler;
|
||||
import appeng.integration.Integrations;
|
||||
import appeng.integration.modules.bogosorter.InventoryBogoSortModule;
|
||||
import appeng.integration.modules.gregtech.ToolClass;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.me.GridNode;
|
||||
import appeng.me.helpers.AENetworkProxy;
|
||||
@@ -67,7 +68,6 @@ import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
import gregtech.api.block.machines.BlockMachine;
|
||||
import gregtech.api.items.IToolItem;
|
||||
import gregtech.api.metatileentity.MetaTileEntity;
|
||||
import gregtech.api.util.GTUtility;
|
||||
import ic2.api.item.ICustomDamageItem;
|
||||
@@ -126,7 +126,6 @@ import java.util.*;
|
||||
* @version rv2
|
||||
* @since rv0
|
||||
*/
|
||||
@Optional.Interface(iface = "gregtech.api.items.IToolItem", modid = "gregtech")
|
||||
@Optional.Interface(iface = "ic2.api.item.ICustomDamageItem", modid = "IC2")
|
||||
public class Platform {
|
||||
|
||||
@@ -1417,7 +1416,7 @@ public class Platform {
|
||||
|
||||
//consider methods below moving to a compability class
|
||||
public static boolean isGTDamageableItem(Item item) {
|
||||
return ((GTLoaded) && item instanceof IToolItem);
|
||||
return ((GTLoaded) && ToolClass.getGTToolClass().isAssignableFrom(item.getClass()));
|
||||
}
|
||||
|
||||
public static MetaTileEntity getMetaTileEntity(IBlockAccess world, BlockPos pos) {
|
||||
|
||||
@@ -94,4 +94,9 @@ public class ItemListIgnoreCrafting<T extends IAEStack<T>> implements IItemList<
|
||||
public void resetStatus() {
|
||||
this.target.resetStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemListIgnoreCrafting<T> clone() {
|
||||
return new ItemListIgnoreCrafting<>(target);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,9 +23,9 @@ import appeng.api.storage.IStorageChannel;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.core.Api;
|
||||
import appeng.integration.modules.gregtech.ToolClass;
|
||||
import appeng.util.Platform;
|
||||
import com.google.common.primitives.Ints;
|
||||
import gregtech.api.items.IToolItem;
|
||||
import ic2.api.item.ICustomDamageItem;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -326,7 +326,7 @@ public class AEItemStack extends AEStack<IAEItemStack> implements IAEItemStack {
|
||||
} else if (a.getItem().isDamageable()) {
|
||||
return a.getItemDamage() > 1 == b.getItemDamage() > 1;
|
||||
} else if (Platform.isGTDamageableItem(a.getItem())) {
|
||||
return ((IToolItem) a.getItem()).getItemDamage(a) > 1 == ((IToolItem) b.getItem()).getItemDamage(b) > 1;
|
||||
return (ToolClass.getGTitemDamage(a) > 1 == ToolClass.getGTitemDamage(b) > 1);
|
||||
}
|
||||
} else {
|
||||
float percentDamageOfA = 0;
|
||||
@@ -338,8 +338,8 @@ public class AEItemStack extends AEStack<IAEItemStack> implements IAEItemStack {
|
||||
percentDamageOfA = (float) a.getItemDamage() / a.getMaxDamage();
|
||||
percentDamageOfB = (float) b.getItemDamage() / b.getMaxDamage();
|
||||
} else if (Platform.isGTDamageableItem(a.getItem())) {
|
||||
percentDamageOfA = (float) ((IToolItem) a.getItem()).getItemDamage(a) / ((IToolItem) a.getItem()).getMaxItemDamage(a);
|
||||
percentDamageOfB = (float) ((IToolItem) b.getItem()).getItemDamage(b) / ((IToolItem) b.getItem()).getMaxItemDamage(b);
|
||||
percentDamageOfA = (float) ToolClass.getGTitemDamage(a) / ToolClass.getGTMaxDamage(a);
|
||||
percentDamageOfB = (float) ToolClass.getGTitemDamage(b) / ToolClass.getGTMaxDamage(b);
|
||||
}
|
||||
|
||||
return percentDamageOfA > mode.breakPoint == percentDamageOfB > mode.breakPoint;
|
||||
|
||||
@@ -20,9 +20,9 @@ package appeng.util.item;
|
||||
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.integration.modules.gregtech.ToolClass;
|
||||
import appeng.util.Platform;
|
||||
import com.google.common.base.Preconditions;
|
||||
import gregtech.api.items.IToolItem;
|
||||
import ic2.api.item.ICustomDamageItem;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectAVLTreeMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectSortedMap;
|
||||
@@ -154,8 +154,8 @@ class FuzzyItemVariantList extends ItemVariantList {
|
||||
maxDamage = ((ICustomDamageItem) stack.getItem()).getMaxCustomDamage(stack);
|
||||
damage = ((ICustomDamageItem) stack.getItem()).getCustomDamage(stack);
|
||||
} else if (Platform.isGTDamageableItem(stack.getItem())) {
|
||||
maxDamage = ((IToolItem) stack.getItem()).getMaxItemDamage(stack);
|
||||
damage = ((IToolItem) stack.getItem()).getItemDamage(stack);
|
||||
maxDamage = ToolClass.getGTMaxDamage(stack);
|
||||
damage = ToolClass.getGTitemDamage(stack);
|
||||
} else {
|
||||
maxDamage = stack.getMaxDamage();
|
||||
damage = stack.getItemDamage();
|
||||
@@ -189,8 +189,8 @@ class FuzzyItemVariantList extends ItemVariantList {
|
||||
maxDamage = ((ICustomDamageItem) stack.getItem()).getMaxCustomDamage(stack);
|
||||
damage = ((ICustomDamageItem) stack.getItem()).getCustomDamage(stack);
|
||||
} else if (Platform.isGTDamageableItem(stack.getItem())) {
|
||||
maxDamage = ((IToolItem) stack.getItem()).getMaxItemDamage(stack);
|
||||
damage = ((IToolItem) stack.getItem()).getItemDamage(stack);
|
||||
maxDamage = ToolClass.getGTMaxDamage(stack);
|
||||
damage = ToolClass.getGTitemDamage(stack);
|
||||
} else {
|
||||
maxDamage = stack.getMaxDamage();
|
||||
damage = stack.getItemDamage();
|
||||
|
||||
@@ -140,6 +140,14 @@ 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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user