Merge remote-tracking branch 'origin/cleanups' into fabric-1.16
# Conflicts: # api/src/main/java/appeng/api/implementations/items/IItemGroup.java # core/src/main/java/appeng/items/materials/MaterialItem.java # src/main/java/appeng/core/Registration.java # src/main/java/appeng/core/api/definitions/ApiParts.java # src/main/java/appeng/items/parts/ColoredPartItem.java # src/main/java/appeng/items/parts/PartItem.java # src/main/java/appeng/items/parts/PartModelsHelper.java # src/main/java/appeng/items/parts/PartType.java # src/main/java/appeng/items/tools/powered/PortableCellItem.java
This commit is contained in:
@@ -18,12 +18,7 @@
|
||||
|
||||
package appeng.items.materials;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import appeng.hooks.AEToolItem;
|
||||
import net.minecraft.client.item.TooltipContext;
|
||||
@@ -45,7 +40,6 @@ import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.implementations.IUpgradeableHost;
|
||||
import appeng.api.implementations.items.IItemGroup;
|
||||
import appeng.api.implementations.items.IStorageComponent;
|
||||
import appeng.api.implementations.items.IUpgradeModule;
|
||||
import appeng.api.implementations.tiles.ISegmentedInventory;
|
||||
@@ -86,34 +80,7 @@ public final class MaterialItem extends AEBaseItem implements IStorageComponent,
|
||||
|
||||
final Upgrades u = this.getType(stack);
|
||||
if (u != null) {
|
||||
final List<Text> textList = new ArrayList<>();
|
||||
for (final Entry<ItemStack, Integer> j : u.getSupported().entrySet()) {
|
||||
Text name = null;
|
||||
|
||||
final int limit = j.getValue();
|
||||
|
||||
if (j.getKey().getItem() instanceof IItemGroup) {
|
||||
final IItemGroup ig = (IItemGroup) j.getKey().getItem();
|
||||
final String str = ig.getUnlocalizedGroupName(u.getSupported().keySet(), j.getKey());
|
||||
if (str != null) {
|
||||
name = new TranslatableText(str).append(limit > 1 ? " (" + limit + ')' : "");
|
||||
}
|
||||
}
|
||||
|
||||
if (name == null) {
|
||||
name = j.getKey().getName().copy().append((limit > 1 ? " (" + limit + ')' : ""));
|
||||
}
|
||||
|
||||
if (!textList.contains(name)) {
|
||||
textList.add(name);
|
||||
}
|
||||
}
|
||||
|
||||
final Pattern p = Pattern.compile("(\\d+)[^\\d]");
|
||||
// FIXME This comparison is not great...
|
||||
final SlightlyBetterSort s = new SlightlyBetterSort(p);
|
||||
textList.sort(s);
|
||||
lines.addAll(textList);
|
||||
lines.addAll(u.getTooltipLines());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,27 +201,4 @@ public final class MaterialItem extends AEBaseItem implements IStorageComponent,
|
||||
return false;
|
||||
}
|
||||
|
||||
private static class SlightlyBetterSort implements Comparator<Text> {
|
||||
private final Pattern pattern;
|
||||
|
||||
public SlightlyBetterSort(final Pattern pattern) {
|
||||
this.pattern = pattern;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(final Text o1, final Text o2) {
|
||||
try {
|
||||
final Matcher a = this.pattern.matcher(o1.getString());
|
||||
final Matcher b = this.pattern.matcher(o2.getString());
|
||||
if (a.find() && b.find()) {
|
||||
final int ia = Integer.parseInt(a.group(1));
|
||||
final int ib = Integer.parseInt(b.group(1));
|
||||
return Integer.compare(ia, ib);
|
||||
}
|
||||
} catch (final Throwable t) {
|
||||
// ek!
|
||||
}
|
||||
return o1.getString().compareTo(o2.getString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,17 +36,12 @@ public class BlockUpgradeInventory extends UpgradeInventory {
|
||||
|
||||
@Override
|
||||
public int getMaxInstalled(final Upgrades upgrades) {
|
||||
int max = 0;
|
||||
|
||||
for (final ItemStack is : upgrades.getSupported().keySet()) {
|
||||
final Item encodedItem = is.getItem();
|
||||
|
||||
if (encodedItem instanceof BlockItem && Block.getBlockFromItem(encodedItem) == this.block) {
|
||||
max = upgrades.getSupported().get(is);
|
||||
break;
|
||||
for (final Upgrades.Supported supported : upgrades.getSupported()) {
|
||||
if (supported.isSupported(block)) {
|
||||
return supported.getMaxCount();
|
||||
}
|
||||
}
|
||||
|
||||
return max;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,15 +33,12 @@ public class StackUpgradeInventory extends UpgradeInventory {
|
||||
|
||||
@Override
|
||||
public int getMaxInstalled(final Upgrades upgrades) {
|
||||
int max = 0;
|
||||
|
||||
for (final ItemStack is : upgrades.getSupported().keySet()) {
|
||||
if (ItemStack.areItemsEqual(this.stack, is)) {
|
||||
max = upgrades.getSupported().get(is);
|
||||
break;
|
||||
for (final Upgrades.Supported supported : upgrades.getSupported()) {
|
||||
if (supported.isSupported(stack.getItem())) {
|
||||
return supported.getMaxCount();
|
||||
}
|
||||
}
|
||||
|
||||
return max;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user