Fixes #4453: Avoid using clientside methods serverside.
This commit is contained in:
@@ -23,7 +23,11 @@
|
||||
|
||||
package appeng.api.config;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@@ -34,6 +38,7 @@ import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.IItemProvider;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
|
||||
public enum Upgrades {
|
||||
/**
|
||||
@@ -76,7 +81,7 @@ public enum Upgrades {
|
||||
* items have different maxSupported values, the highest
|
||||
* will be shown.
|
||||
*/
|
||||
public void registerItem(final IItemProvider item, final int maxSupported, @Nullable ITextComponent tooltipGroup) {
|
||||
public void registerItem(final IItemProvider item, final int maxSupported, @Nullable String tooltipGroup) {
|
||||
Preconditions.checkNotNull(item);
|
||||
this.supported.add(new Supported(item.asItem(), maxSupported, tooltipGroup));
|
||||
supportedTooltipLines = null; // Reset tooltip
|
||||
@@ -95,17 +100,17 @@ public enum Upgrades {
|
||||
ITextComponent name = supported.item.getName();
|
||||
|
||||
// If the group was already added by a previous item, skip this
|
||||
if (supported.tooltipGroup != null && namesAdded.contains(supported.tooltipGroup)) {
|
||||
if (supported.getTooltipGroup() != null && namesAdded.contains(supported.getTooltipGroup())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// If any of the following items would be of the same group, use the group name
|
||||
// instead
|
||||
if (supported.tooltipGroup != null) {
|
||||
if (supported.getTooltipGroup() != null) {
|
||||
for (int j = i + 1; j < this.supported.size(); j++) {
|
||||
ITextComponent otherGroup = this.supported.get(j).tooltipGroup;
|
||||
if (supported.tooltipGroup.equals(otherGroup)) {
|
||||
name = supported.tooltipGroup;
|
||||
ITextComponent otherGroup = this.supported.get(j).getTooltipGroup();
|
||||
if (supported.getTooltipGroup().equals(otherGroup)) {
|
||||
name = supported.getTooltipGroup();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -133,9 +138,9 @@ public enum Upgrades {
|
||||
private final Block block;
|
||||
private final int maxCount;
|
||||
@Nullable
|
||||
private final ITextComponent tooltipGroup;
|
||||
private final String tooltipGroup;
|
||||
|
||||
public Supported(Item item, int maxCount, @Nullable ITextComponent tooltipGroup) {
|
||||
public Supported(Item item, int maxCount, @Nullable String tooltipGroup) {
|
||||
this.item = item;
|
||||
if (item.getItem() instanceof BlockItem) {
|
||||
this.block = ((BlockItem) item.getItem()).getBlock();
|
||||
@@ -158,6 +163,10 @@ public enum Upgrades {
|
||||
return item != null && this.item == item;
|
||||
}
|
||||
|
||||
public ITextComponent getTooltipGroup() {
|
||||
return this.tooltipGroup != null ? new TranslationTextComponent(this.tooltipGroup) : null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user