mirror of
https://github.com/GTNewHorizons/Applied-Energistics-2-Unofficial.git
synced 2026-11-14 01:14:11 +00:00
Cache enum .values() (#1494)
This commit is contained in:
1 parent
94e2a184b8
commit
f134d4211e
12 files changed
+33
-32
No files matched your search
@@ -74,14 +74,14 @@ public class BlockWirelessConnector extends AEBaseTileBlock {
|
||||
if (is.getItemDamage() == 0) {
|
||||
lines.add(AEColor.Transparent.toString());
|
||||
} else {
|
||||
lines.add(AEColor.values()[is.getItemDamage() - 1].toString());
|
||||
lines.add(AEColor.VALUES[is.getItemDamage() - 1].toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getCheckedSubBlocks(Item item, CreativeTabs tabs, List<ItemStack> itemStacks) {
|
||||
for (int i = 0; i < AEColor.values().length; i++) {
|
||||
for (int i = 0; i < AEColor.VALUES.length; i++) {
|
||||
itemStacks.add(new ItemStack(this, 1, i));
|
||||
}
|
||||
}
|
||||
@@ -103,7 +103,7 @@ public class BlockWirelessConnector extends AEBaseTileBlock {
|
||||
int damage = is.getItemDamage();
|
||||
if (damage > 0) {
|
||||
if (w.getTileEntity(x, y, z) instanceof TileWirelessBase twc) {
|
||||
twc.recolourBlock(ForgeDirection.UNKNOWN, AEColor.values()[damage - 1], (EntityPlayer) player);
|
||||
twc.recolourBlock(ForgeDirection.UNKNOWN, AEColor.VALUES[damage - 1], (EntityPlayer) player);
|
||||
w.setBlockMetadataWithNotify(x, y, z, 0, 3);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -229,7 +229,7 @@ public abstract class GuiUpgradeable extends AEBaseGui {
|
||||
return;
|
||||
}
|
||||
|
||||
for (final MaterialType materialType : MaterialType.values()) {
|
||||
for (final MaterialType materialType : MaterialType.VALUES) {
|
||||
if (!materialType.isRegistered() || materialType.getItemInstance() == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -190,8 +190,8 @@ public class GuiWirelessKit extends AEBaseGui implements IConfigManagerHost {
|
||||
this.guiTop + TOP_OFFSET + 8 + (9 * i),
|
||||
8,
|
||||
8,
|
||||
AEColor.values()[i],
|
||||
AEColor.values()[i].toString());
|
||||
AEColor.VALUES[i],
|
||||
AEColor.VALUES[i].toString());
|
||||
this.buttonList.add(this.colorButtons[i]);
|
||||
}
|
||||
|
||||
@@ -202,8 +202,8 @@ public class GuiWirelessKit extends AEBaseGui implements IConfigManagerHost {
|
||||
this.guiTop + TOP_OFFSET + 8 + (9 * (i - 8)),
|
||||
8,
|
||||
8,
|
||||
AEColor.values()[i],
|
||||
AEColor.values()[i].toString());
|
||||
AEColor.VALUES[i],
|
||||
AEColor.VALUES[i].toString());
|
||||
this.buttonList.add(this.colorButtons[i]);
|
||||
}
|
||||
|
||||
@@ -213,8 +213,8 @@ public class GuiWirelessKit extends AEBaseGui implements IConfigManagerHost {
|
||||
this.guiTop + TOP_OFFSET - 1,
|
||||
8,
|
||||
8,
|
||||
AEColor.values()[16],
|
||||
AEColor.values()[16].toString());
|
||||
AEColor.VALUES[16],
|
||||
AEColor.VALUES[16].toString());
|
||||
|
||||
this.buttonList.add(this.colorButtons[16]);
|
||||
|
||||
@@ -1206,7 +1206,7 @@ public class GuiWirelessKit extends AEBaseGui implements IConfigManagerHost {
|
||||
new SavedName(
|
||||
DimensionalCoord.readFromNBT(tag.getCompoundTag("network")),
|
||||
tag.getString("networkName"),
|
||||
AEColor.values()[tag.getInteger("color")],
|
||||
AEColor.VALUES[tag.getInteger("color")],
|
||||
tag.hasKey("color"),
|
||||
tag.getString("colorName")));
|
||||
}
|
||||
@@ -1219,7 +1219,7 @@ public class GuiWirelessKit extends AEBaseGui implements IConfigManagerHost {
|
||||
savedPins.add(
|
||||
new SavedPin(
|
||||
DimensionalCoord.readFromNBT(tag.getCompoundTag("network")),
|
||||
AEColor.values()[tag.getInteger("color")],
|
||||
AEColor.VALUES[tag.getInteger("color")],
|
||||
PinType.values()[tag.getInteger("type")],
|
||||
DimensionalCoord.readFromNBT(tag.getCompoundTag("coord")),
|
||||
!tag.hasKey("incCon"),
|
||||
|
||||
@@ -54,7 +54,7 @@ public class GuiWirelessNetworkManager extends AEBaseGui {
|
||||
this.guiTop + 5 + (14 * y),
|
||||
96,
|
||||
12,
|
||||
AEColor.values()[y],
|
||||
AEColor.VALUES[y],
|
||||
keyStatus.value(),
|
||||
GuiText.WirelessManagerToolTips.getLocal(
|
||||
GameSettings.getKeyDisplayString(ServerHelper.WIRELESS_EXTRA_ACTION.getKeyCode())));
|
||||
|
||||
@@ -66,8 +66,8 @@ public class ContainerWirelessNetworkManager extends AEBaseContainer {
|
||||
if (!data.hasKey("encryptionKeys") && data.hasKey("encryptionKey")) {
|
||||
final NBTTagCompound keys = new NBTTagCompound();
|
||||
final String key = data.getString("encryptionKey");
|
||||
final String colorKey = AEColor.values()[0].name();
|
||||
final String colorName = AEColor.values()[0].toString();
|
||||
final String colorKey = AEColor.VALUES[0].name();
|
||||
final String colorName = AEColor.VALUES[0].toString();
|
||||
|
||||
keys.setString(colorKey, key);
|
||||
keys.setString(colorKey + "Name", colorName);
|
||||
@@ -83,9 +83,9 @@ public class ContainerWirelessNetworkManager extends AEBaseContainer {
|
||||
if (data.hasKey("encryptionKeys")) {
|
||||
final NBTTagCompound keys = data.getCompoundTag("encryptionKeys");
|
||||
for (int i = 0; i < 16; i++) {
|
||||
final String key = AEColor.values()[i].name();
|
||||
final String key = AEColor.VALUES[i].name();
|
||||
final String name = keys.hasKey(key + "Name") ? keys.getString(key + "Name")
|
||||
: AEColor.values()[i].toString();
|
||||
: AEColor.VALUES[i].toString();
|
||||
keysStatus.put(i, Pair.of(keys.hasKey(key), name));
|
||||
}
|
||||
}
|
||||
@@ -103,7 +103,7 @@ public class ContainerWirelessNetworkManager extends AEBaseContainer {
|
||||
private void setCurrent(final byte color) {
|
||||
final NBTTagCompound data = ItemStackNBT.get(this.terminal);
|
||||
final NBTTagCompound keys = data.getCompoundTag("encryptionKeys");
|
||||
ItemStackNBT.of(this.terminal).setString("encryptionKey", keys.getString(AEColor.values()[color].name()));
|
||||
ItemStackNBT.of(this.terminal).setString("encryptionKey", keys.getString(AEColor.VALUES[color].name()));
|
||||
this.checkItem(this.getTarget());
|
||||
this.getInventoryPlayer().player.closeScreen();
|
||||
}
|
||||
@@ -117,7 +117,7 @@ public class ContainerWirelessNetworkManager extends AEBaseContainer {
|
||||
final NBTTagCompound data = ItemStackNBT.get(this.terminal);
|
||||
final NBTTagCompound keys = data.getCompoundTag("encryptionKeys");
|
||||
|
||||
final String key = AEColor.values()[color].name();
|
||||
final String key = AEColor.VALUES[color].name();
|
||||
final String encryptionKey = keys.getString(key);
|
||||
final String currentEncryptionKey = data.getString("encryptionKey");
|
||||
|
||||
@@ -125,7 +125,7 @@ public class ContainerWirelessNetworkManager extends AEBaseContainer {
|
||||
data.removeTag("encryptionKey");
|
||||
|
||||
for (int i = 0; i < 16; i++) {
|
||||
final String tempKey = AEColor.values()[i].name();
|
||||
final String tempKey = AEColor.VALUES[i].name();
|
||||
if (tempKey.equals(key)) continue;
|
||||
if (keys.hasKey(tempKey)) {
|
||||
data.setString("encryptionKey", keys.getString(tempKey));
|
||||
|
||||
@@ -65,7 +65,7 @@ public class WirelessKitCommand {
|
||||
if (buf.readBoolean()) cmd.setNetworkPos(DimensionalCoord.readFromPacket(buf));
|
||||
if (buf.readBoolean()) cmd.includeConnectors();
|
||||
if (buf.readBoolean()) cmd.includeHubs();
|
||||
if (buf.readBoolean()) cmd.setColor(AEColor.values()[buf.readInt()]);
|
||||
if (buf.readBoolean()) cmd.setColor(AEColor.VALUES[buf.readInt()]);
|
||||
if (buf.readBoolean()) cmd.setGroupBy(PinType.values()[buf.readInt()]);
|
||||
|
||||
return cmd;
|
||||
@@ -141,7 +141,7 @@ public class WirelessKitCommand {
|
||||
final WirelessKitCommand command = new WirelessKitCommand(WirelessKitCommands.values()[buf.readInt()]);
|
||||
command.setName(ByteBufUtils.readUTF8String(buf));
|
||||
|
||||
if (buf.readBoolean()) command.setColor(AEColor.values()[buf.readInt()]);
|
||||
if (buf.readBoolean()) command.setColor(AEColor.VALUES[buf.readInt()]);
|
||||
if (buf.readBoolean()) command.setNetworkPos(DimensionalCoord.readFromPacket(buf));
|
||||
final boolean pin = buf.readBoolean();
|
||||
if (buf.readBoolean()) {
|
||||
|
||||
@@ -65,7 +65,7 @@ public class WirelessToolDataObject {
|
||||
coord,
|
||||
isConnected,
|
||||
targets,
|
||||
AEColor.values()[buf.readInt()],
|
||||
AEColor.VALUES[buf.readInt()],
|
||||
buf.readInt(),
|
||||
isHub,
|
||||
buf.readInt());
|
||||
|
||||
@@ -71,7 +71,7 @@ public class WirelessDataProvider extends BaseWailaDataProvider {
|
||||
currentToolTip.add(WailaText.wireless_notconnected.getLocal());
|
||||
}
|
||||
|
||||
AEColor color = AEColor.values()[tag.getInteger("color")];
|
||||
AEColor color = AEColor.VALUES[tag.getInteger("color")];
|
||||
if (color != AEColor.Transparent) {
|
||||
currentToolTip.add(StatCollector.translateToLocal("gui.appliedenergistics2." + color.name()));
|
||||
}
|
||||
|
||||
@@ -250,7 +250,7 @@ public final class ItemMultiMaterial extends AEBaseItem implements IStorageCompo
|
||||
@Override
|
||||
protected void getCheckedSubItems(final Item sameItem, final CreativeTabs creativeTab,
|
||||
final List<ItemStack> itemStacks) {
|
||||
for (final MaterialType mat : MaterialType.values()) {
|
||||
for (final MaterialType mat : MaterialType.VALUES) {
|
||||
if (mat.getDamageValue() >= 0 && mat.isRegistered() && mat.getItemInstance() == this) {
|
||||
itemStacks.add(new ItemStack(this, 1, mat.getDamageValue()));
|
||||
}
|
||||
@@ -259,7 +259,7 @@ public final class ItemMultiMaterial extends AEBaseItem implements IStorageCompo
|
||||
|
||||
@Override
|
||||
public void registerIcons(final IIconRegister icoRegister) {
|
||||
for (final MaterialType mat : MaterialType.values()) {
|
||||
for (final MaterialType mat : MaterialType.VALUES) {
|
||||
if (mat.getDamageValue() != -1) {
|
||||
final ItemStack what = new ItemStack(this, 1, mat.getDamageValue());
|
||||
if (this.getTypeByStack(what) != MaterialType.InvalidType) {
|
||||
|
||||
@@ -121,6 +121,7 @@ public enum MaterialType {
|
||||
QESingularity(48, AEFeature.QuantumNetworkBridge, EntitySingularity.class);
|
||||
// the last meta is 69
|
||||
|
||||
public static final MaterialType[] VALUES = values();
|
||||
private final EnumSet<AEFeature> features;
|
||||
// IIcon for the material.
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
@@ -132,13 +132,13 @@ public class ToolWirelessTerminal extends AEBasePoweredItem implements IWireless
|
||||
final NBTTagCompound data = ItemStackNBT.get(item);
|
||||
final NBTTagCompound keys = data.getCompoundTag("encryptionKeys");
|
||||
|
||||
if (!keys.hasKey(AEColor.values()[0].name()) && data.hasKey("encryptionKey")) {
|
||||
keys.setString(AEColor.values()[0].name(), data.getString("encryptionKey"));
|
||||
if (!keys.hasKey(AEColor.VALUES[0].name()) && data.hasKey("encryptionKey")) {
|
||||
keys.setString(AEColor.VALUES[0].name(), data.getString("encryptionKey"));
|
||||
}
|
||||
|
||||
String freeKey = "";
|
||||
for (int i = 0; i < 16; i++) {
|
||||
final String key = AEColor.values()[i].name();
|
||||
final String key = AEColor.VALUES[i].name();
|
||||
if (keys.hasKey(key)) {
|
||||
if (keys.getString(key).equals(encKey)) return;
|
||||
} else {
|
||||
|
||||
@@ -263,7 +263,7 @@ public abstract class TileWirelessBase extends AENetworkTile implements IColorab
|
||||
@TileEvent(TileEventType.NETWORK_READ)
|
||||
public boolean readFromStream_TileSecurity(final ByteBuf data) {
|
||||
final AEColor oldColor = this.color;
|
||||
this.color = AEColor.values()[data.readByte()];
|
||||
this.color = AEColor.VALUES[data.readByte()];
|
||||
return oldColor != this.color;
|
||||
}
|
||||
|
||||
@@ -311,7 +311,7 @@ public abstract class TileWirelessBase extends AENetworkTile implements IColorab
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBT_TileWirelessConnector(final NBTTagCompound data) {
|
||||
if (data.hasKey("Color")) {
|
||||
this.color = AEColor.values()[data.getShort("Color")];
|
||||
this.color = AEColor.VALUES[data.getShort("Color")];
|
||||
this.getProxy().setColor(this.color);
|
||||
}
|
||||
|
||||
@@ -411,7 +411,7 @@ public abstract class TileWirelessBase extends AENetworkTile implements IColorab
|
||||
}
|
||||
}
|
||||
|
||||
AEColor colour = AEColor.values()[i];
|
||||
AEColor colour = AEColor.VALUES[i];
|
||||
|
||||
if (this.color == colour) return;
|
||||
this.color = colour;
|
||||
|
||||
Reference in new issue
Block a user