Code cleanup (#133)

* gradle updateBuildScript

* fix comments and commented-out code

Code deletion, converting comments into javadocs, and refactoring code to not
need comments.

* remove redundant suppressions

* replace C-style array declaration with Java-style

* make private field final

* remove unnecessary semicolon

* extract a common part from an if

* simplify boolean expression

* simplify ternary if

* remove unused imports

* convert escaped characters for clarity

* replace while with for

* replace explicit types with diamond operators

* replace anonymous type with lambda

* enable modern Java syntax

* migrate to enhanced switch

* migrate to pattern variables for instanceof

* remove empty javadoc

* add Nonnull annotation to overrides of Nonnull methods

* replace wailaStack with null

When wailaStack is not null, the flow breaks out of the loop,
so there's no need to confuse the reader with putting wailaStack
both as the result and the parameter of the call - there's no
recursion.

* int cannot be bigger than its max value

* suppress dataflow warning

* remove redundant initializer

The default value of int is 0.

* null check is covered by instanceof

* simplify some calls of addVertexWithUV

* fix typos and add TODOs

* make flipState more understandable
This commit is contained in:
chill authored and GitHub committed 2023-06-18 23:29:57 +02:00
1 parent f87b76347e
commit d5b8ef6ea9
89 files changed
+421 -633

No files matched your search

+24 -9
View File
@@ -1,4 +1,4 @@
//version: 1683563728
//version: 1685785062
/*
DO NOT CHANGE THIS FILE!
Also, you may replace this file at any time if there is an update available.
@@ -69,7 +69,7 @@ plugins {
id 'com.diffplug.spotless' version '6.13.0' apply false // 6.13.0 is the last jvm8 supporting version
id 'com.modrinth.minotaur' version '2.+' apply false
id 'com.matthewprenger.cursegradle' version '1.4.0' apply false
id 'com.gtnewhorizons.retrofuturagradle' version '1.3.7'
id 'com.gtnewhorizons.retrofuturagradle' version '1.3.14'
}
print("You might want to check out './gradlew :faq' if your build fails.\n")
@@ -569,9 +569,10 @@ repositories {
def mixinProviderGroup = "io.github.legacymoddingmc"
def mixinProviderModule = "unimixins"
def mixinProviderVersion = "0.1.6"
def mixinProviderVersion = "0.1.7.1"
def mixinProviderSpecNoClassifer = "${mixinProviderGroup}:${mixinProviderModule}:${mixinProviderVersion}"
def mixinProviderSpec = "${mixinProviderSpecNoClassifer}:dev"
ext.mixinProviderSpec = mixinProviderSpec
dependencies {
if (usesMixins.toBoolean()) {
@@ -729,7 +730,7 @@ dependencies {
java17Dependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}")
}
if (modId != 'hodgepodge') {
java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.2.8')
java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.2.13')
}
java17PatchDependencies('net.minecraft:launchwrapper:1.15') {transitive = false}
@@ -822,6 +823,18 @@ public abstract class RunHotswappableMinecraftTask extends RunMinecraftTask {
}
this.classpath(project.java17DependenciesCfg)
}
public void setup(Project project) {
super.setup(project)
if (project.usesMixins.toBoolean()) {
this.extraJvmArgs.addAll(project.provider(() -> {
def mixinCfg = project.configurations.detachedConfiguration(project.dependencies.create(project.mixinProviderSpec))
mixinCfg.canBeConsumed = false
mixinCfg.transitive = false
enableHotswap ? ["-javaagent:" + mixinCfg.singleFile.absolutePath] : []
}))
}
}
}
def runClient17Task = tasks.register("runClient17", RunHotswappableMinecraftTask, Distribution.CLIENT, "runClient")
@@ -1263,12 +1276,14 @@ tasks.register('faq') {
description = 'Prints frequently asked questions about building a project'
doLast {
print("If your build fails to fetch dependencies, they might have been deleted and replaced by newer " +
"versions.\nCheck if the versions you try to fetch are still on the distributing sites.\n" +
"The links can be found in repositories.gradle and build.gradle:repositories, " +
"not build.gradle:buildscript.repositories - this one is for gradle plugin metadata.\n\n" +
print("If your build fails to fetch dependencies, run './gradlew updateDependencies'. " +
"Or you can manually check if the versions are still on the distributing sites - " +
"the links can be found in repositories.gradle and build.gradle:repositories, " +
"but not build.gradle:buildscript.repositories - those ones are for gradle plugin metadata.\n\n" +
"If your build fails to recognize the syntax of new Java versions, enable Jabel in your " +
"gradle.properties. See how it's done in GTNH ExampleMod/gradle.properties.")
"gradle.properties. See how it's done in GTNH ExampleMod/gradle.properties. " +
"However, keep in mind that Jabel enables only syntax features, but not APIs that were introduced in " +
"Java 9 or later.")
}
}
+4
View File
@@ -21,6 +21,10 @@ forgeVersion = 10.13.4.1614
# Do you need to test how your custom blocks interacts with a player that is not the owner? -> leave name empty
developmentEnvironmentUserName = Developer
# Enables using modern java syntax (up to version 17) via Jabel, while still targetting JVM 8.
# See https://github.com/bsideup/jabel for details on how this works.
enableModernJavaSyntax = true
# Define a source file of your project with:
# public static final String VERSION = "GRADLETOKEN_VERSION";
# The string's content will be replaced with your mods version when compiled. You should use this to specify your mod's
@@ -128,15 +128,12 @@ public class GuiDualInterface extends GuiUpgradeable {
@Override
protected String getBackground() {
if (!ModAndClassUtil.isBigInterface) return "guis/interface.png";
switch (((ContainerInterface) this.cvb).getPatternCapacityCardsInstalled()) {
case 1:
return "guis/interface2.png";
case 2:
return "guis/interface3.png";
case 3:
return "guis/interface4.png";
}
return "guis/interface.png";
return switch (((ContainerInterface) this.cvb).getPatternCapacityCardsInstalled()) {
case 1 -> "guis/interface2.png";
case 2 -> "guis/interface3.png";
case 3 -> "guis/interface4.png";
default -> "guis/interface.png";
};
}
@Override
@@ -244,9 +244,7 @@ public class GuiFCImgButton extends GuiButton implements ITooltip {
Math.round(uv_y * 16F * 16F / 3F),
Math.round(16F * 16F / 3F),
Math.round(16F * 16F / 3F));
this.mouseDragged(par1Minecraft, par2, par3);
GL11.glPopMatrix();
} else {
GL11.glPushMatrix();
GL11.glTranslatef(this.xPosition, this.yPosition, 0.0F);
@@ -280,9 +278,9 @@ public class GuiFCImgButton extends GuiButton implements ITooltip {
Math.round(uv_y * 16F * 16F / 3F),
Math.round(16F * 16F / 3F),
Math.round(16F * 16F / 3F));
this.mouseDragged(par1Minecraft, par2, par3);
GL11.glPopMatrix();
}
this.mouseDragged(par1Minecraft, par2, par3);
GL11.glPopMatrix();
}
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
}
@@ -1,7 +1,5 @@
package com.glodblock.github.client.gui;
import java.util.*;
import net.minecraft.entity.player.InventoryPlayer;
import com.glodblock.github.FluidCraft;
@@ -164,7 +164,6 @@ public class GuiFluidLevelEmitter extends GuiUpgradeable {
FluidCraft.proxy.netHandler.sendToServer(new CPacketValueConfig(result, 0));
} catch (final NumberFormatException e) {
// nope..
this.level.setText("0");
}
}
@@ -76,7 +76,6 @@ public class GuiInterfaceTerminalWireless extends FCBaseMEGui implements IDropTo
protected static boolean onlyBrokenRecipes = false;
protected GuiTabButton craftingStatusBtn;
// private final IConfigManager configSrc;
private int rows = 3;
private static final String MOLECULAR_ASSEMBLER = "tile.appliedenergistics2.BlockMolecularAssembler";
@@ -210,8 +209,7 @@ public class GuiInterfaceTerminalWireless extends FCBaseMEGui implements IDropTo
protected void repositionSlots() {
for (final Object obj : this.inventorySlots.inventorySlots) {
if (obj instanceof AppEngSlot) {
final AppEngSlot slot = (AppEngSlot) obj;
if (obj instanceof final AppEngSlot slot) {
slot.yDisplayPosition = this.ySize + slot.getY() - 78 - 7;
}
}
@@ -220,7 +218,9 @@ public class GuiInterfaceTerminalWireless extends FCBaseMEGui implements IDropTo
protected int calculateRowsCount() {
final int maxRows = this.getMaxRows();
final boolean hasNEI = IntegrationRegistry.INSTANCE.isEnabled(IntegrationType.NEI);
final int NEIPadding = hasNEI ? 22 /* input */ + 18 /* top panel */ : 0;
final int input = 22;
final int topPanel = 18;
final int NEIPadding = hasNEI ? input + topPanel : 0;
final int extraSpace = this.height - MAGIC_HEIGHT_NUMBER - NEIPadding;
return Math.max(3, Math.min(maxRows, extraSpace / 18));
@@ -243,8 +243,7 @@ public class GuiInterfaceTerminalWireless extends FCBaseMEGui implements IDropTo
final int ex = getScrollBar().getCurrentScroll();
for (int x = 0; x < this.rows && ex + x < this.lines.size(); x++) {
final Object lineObj = this.lines.get(ex + x);
if (lineObj instanceof ClientDCInternalInv) {
final ClientDCInternalInv inv = (ClientDCInternalInv) lineObj;
if (lineObj instanceof final ClientDCInternalInv inv) {
for (int z = 0; z < inv.getInventory().getSizeInventory(); z++) {
if (this.matchedStacks.contains(inv.getInventory().getStackInSlot(z))) drawRect(
z * 18 + 22,
@@ -253,8 +252,7 @@ public class GuiInterfaceTerminalWireless extends FCBaseMEGui implements IDropTo
1 + offset + 16,
GuiColors.InterfaceTerminalMatch.getColor());
}
} else if (lineObj instanceof String) {
String name = (String) lineObj;
} else if (lineObj instanceof String name) {
final int rows = this.byName.get(name).size();
String postfix = "";
@@ -309,8 +307,7 @@ public class GuiInterfaceTerminalWireless extends FCBaseMEGui implements IDropTo
final int ex = this.getScrollBar().getCurrentScroll();
for (int x = 0; x < this.rows && ex + x < this.lines.size(); x++) {
final Object lineObj = this.lines.get(ex + x);
if (lineObj instanceof ClientDCInternalInv) {
final ClientDCInternalInv inv = (ClientDCInternalInv) lineObj;
if (lineObj instanceof final ClientDCInternalInv inv) {
for (int z = 0; z < inv.getInventory().getSizeInventory(); z++) {
inventorySlots.inventorySlots.add(new SlotDisconnected(inv, z, z * 18 + 22, 1 + offset));
}
@@ -405,8 +402,7 @@ public class GuiInterfaceTerminalWireless extends FCBaseMEGui implements IDropTo
} else if (btn == craftingStatusBtn) {
InventoryHandler.switchGui(GuiType.CRAFTING_STATUS);
} else if (btn instanceof GuiImgButton) {
final GuiImgButton iBtn = (GuiImgButton) btn;
} else if (btn instanceof final GuiImgButton iBtn) {
if (iBtn.getSetting() != Settings.ACTIONS) {
final Enum cv = iBtn.getCurrentValue();
final boolean backwards = Mouse.isButtonDown(1);
@@ -444,8 +440,7 @@ public class GuiInterfaceTerminalWireless extends FCBaseMEGui implements IDropTo
for (int x = 0; x < this.rows && ex + x < this.lines.size(); x++) {
final Object lineObj = this.lines.get(ex + x);
if (lineObj instanceof ClientDCInternalInv) {
final ClientDCInternalInv inv = (ClientDCInternalInv) lineObj;
if (lineObj instanceof final ClientDCInternalInv inv) {
GL11.glColor4f(1, 1, 1, 1);
final int width = inv.getInventory().getSizeInventory() * 18;
@@ -539,7 +534,7 @@ public class GuiInterfaceTerminalWireless extends FCBaseMEGui implements IDropTo
if (this.refreshList) {
this.refreshList = false;
// invalid caches on refresh
// invalidate caches on refresh
this.cachedSearches.clear();
this.refreshList();
}
@@ -364,32 +364,33 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
public void draw() {
this.getQty().draw();
this.getBatch().draw();
ArrayList<String> message = new ArrayList<String>();
ArrayList<String> message = new ArrayList<>();
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_TITLE) + "\n");
switch (this.state) {
case Idling:
case Idling -> {
this.line.setColor(0xFF55FF55);
message.add(
NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT)
+ NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_IDLE));
break;
case Crafting:
}
case Crafting -> {
this.line.setColor(0xFFFFFF55);
message.add(
NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT)
+ NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_LINK));
break;
case Exporting:
}
case Exporting -> {
this.line.setColor(0xFFAA00AA);
message.add(
NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT)
+ NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_EXPORT));
break;
default:
}
default -> {
this.line.setColor(0);
message.add(
NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT)
+ NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_NONE));
}
}
message.add("");
if (isShiftKeyDown()) {
@@ -430,7 +431,7 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
this.textField = textField;
this.textField.setEnableBackgroundDrawing(false);
this.textField.setText("0");
this.textField.setMaxStringLength(10); // it's enough to useful
this.textField.setMaxStringLength(10); // this length is enough to useful
this.idx = idx;
this.action = action;
this.tooltip = tooltip;
@@ -16,7 +16,7 @@ import appeng.core.localization.GuiText;
public class GuiRenamer extends AEBaseGui implements IDropToFillTextField {
private MEGuiTextField textField;
private final MEGuiTextField textField;
public GuiRenamer(InventoryPlayer ip, ITerminalHost monitorable) {
super(new ContainerRenamer(ip, monitorable));
@@ -122,9 +122,8 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
if (btn == this.craftingStatusBtn || btn == this.craftingStatusImgBtn) {
InventoryHandler.switchGui(GuiType.CRAFTING_STATUS);
}
if (btn instanceof GuiImgButton) {
if (btn instanceof final GuiImgButton iBtn) {
final boolean backwards = Mouse.isButtonDown(1);
final GuiImgButton iBtn = (GuiImgButton) btn;
if (iBtn.getSetting() != Settings.ACTIONS) {
final Enum<?> cv = iBtn.getCurrentValue();
final Enum<?> next = Platform.rotateEnum(cv, backwards, iBtn.getSetting().getPossibleValues());
@@ -273,6 +272,8 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
AEConfig.instance.settings.getSetting(Settings.TERMINAL_STYLE)));
this.offsetY += 20;
// Right now 80 > offsetX, but that can be changed later.
// noinspection DataFlowIssue
this.searchField = new FCGuiTextField(
this.fontRendererObj,
this.guiLeft + Math.max(80, this.offsetX),
@@ -433,7 +434,7 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
if (slot instanceof SlotPatternTerm) {
if (mouseButton == 6) {
return; // prevent weird double clicks..
return; // prevents weird double clicks
}
try {
NetworkHandler.instance.sendToServer(((SlotPatternTerm) slot).getRequest(isShiftKeyDown()));
@@ -442,13 +443,13 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
}
} else if (slot instanceof SlotCraftingTerm) {
if (mouseButton == 6) {
return; // prevent weird double clicks..
return; // prevents weird double clicks
}
InventoryAction action;
if (isShiftKeyDown()) {
action = InventoryAction.CRAFT_SHIFT;
} else {
// Craft stack on right-click, craft single on left-click
// Craft a stack on right-click, craft a single one on left-click
action = (mouseButton == 1) ? InventoryAction.CRAFT_STACK : InventoryAction.CRAFT_ITEM;
}
final PacketInventoryAction p = new PacketInventoryAction(action, slotIdx, 0);
@@ -222,7 +222,7 @@ public class ContainerFluidMonitor extends FCContainerMonitor<IAEFluidStack> {
}
/**
* The insert operation. For input, we have an filled container stack. For outputs, we have the following: 1.
* The insert operation. For input, we have a filled container stack. For outputs, we have the following: 1.
* Leftover filled container stack - primary output. 2. Empty containers 3. Partially filled container x1 In order
* above, the itemstack at `slotIndex` is transformed into the output.
*/
@@ -106,7 +106,10 @@ public class ContainerFluidPatternEncoder extends AEBaseContainer implements IPa
}
private static IAEItemStack[] collectAeInventory(AeStackInventory<IAEItemStack> inv) {
// see note at top of DensePatternDetails
/*
* AE2 API documentation says the input/output arrays can contain nulls, but their use of the API directly
* contradicts that, so we just go by behaviour and filter out nulls.
*/
List<IAEItemStack> acc = new ArrayList<>();
for (IAEItemStack stack : inv) {
if (stack != null) {
@@ -130,20 +133,20 @@ public class ContainerFluidPatternEncoder extends AEBaseContainer implements IPa
if (slot instanceof SlotFluidConvertingFake) {
final ItemStack stack = player.inventory.getItemStack();
switch (action) {
case PICKUP_OR_SET_DOWN:
case PICKUP_OR_SET_DOWN -> {
if (stack == null) {
slot.putStack(null);
} else {
((SlotFluidConvertingFake) slot).putConvertedStack(stack.copy());
}
break;
case PLACE_SINGLE:
}
case PLACE_SINGLE -> {
if (stack != null) {
((SlotFluidConvertingFake) slot)
.putConvertedStack(Objects.requireNonNull(Util.copyStackWithSize(stack, 1)));
}
break;
case SPLIT_OR_PLACE_SINGLE:
}
case SPLIT_OR_PLACE_SINGLE -> {
ItemStack inSlot = slot.getStack();
if (inSlot != null) {
if (stack == null) {
@@ -161,7 +164,7 @@ public class ContainerFluidPatternEncoder extends AEBaseContainer implements IPa
((SlotFluidConvertingFake) slot)
.putConvertedStack(Objects.requireNonNull(Util.copyStackWithSize(stack, 1)));
}
break;
}
}
} else {
super.doAction(player, action, slotId, id);
@@ -42,13 +42,12 @@ import appeng.util.inv.WrapperInvSlot;
public class ContainerInterfaceWireless extends FCBaseContainer {
/**
* this stuff is all server side..
* this stuff is all server side
*/
private static long autoBase = Long.MIN_VALUE;
private final Multimap<IInterfaceHost, ContainerInterfaceWireless.InvTracker> diList = HashMultimap.create();
private final Map<Long, ContainerInterfaceWireless.InvTracker> byId = new HashMap<Long, ContainerInterfaceWireless.InvTracker>();
// private final Map<Long, InvTracker> byId = new HashMap<>();
private final Map<Long, ContainerInterfaceWireless.InvTracker> byId = new HashMap<>();
private IGrid grid;
private NBTTagCompound data = new NBTTagCompound();
@@ -114,9 +113,7 @@ public class ContainerInterfaceWireless extends FCBaseContainer {
try {
NetworkHandler.instance
.sendTo(new PacketCompressedNBT(this.data), (EntityPlayerMP) this.getPlayerInv().player);
} catch (final IOException e) {
// :P
}
} catch (final IOException ignored) {}
this.data = new NBTTagCompound();
}
@@ -140,7 +137,7 @@ public class ContainerInterfaceWireless extends FCBaseContainer {
boolean canInsert = true;
switch (action) {
case PICKUP_OR_SET_DOWN:
case PICKUP_OR_SET_DOWN -> {
if (hasItemInHand) {
for (int s = 0; s < interfaceHandler.getSizeInventory(); s++) {
if (Platform.isSameItemPrecise(
@@ -175,9 +172,8 @@ public class ContainerInterfaceWireless extends FCBaseContainer {
final IInventory mySlot = slotInv.getWrapper(slot + inv.offset);
mySlot.setInventorySlotContents(0, playerHand.addItems(mySlot.getStackInSlot(0)));
}
break;
case SPLIT_OR_PLACE_SINGLE:
}
case SPLIT_OR_PLACE_SINGLE -> {
if (hasItemInHand) {
for (int s = 0; s < interfaceHandler.getSizeInventory(); s++) {
if (Platform.isSameItemPrecise(
@@ -205,31 +201,28 @@ public class ContainerInterfaceWireless extends FCBaseContainer {
interfaceSlot.addItems(extra);
}
}
break;
case SHIFT_CLICK:
}
case SHIFT_CLICK -> {
final IInventory mySlot = slotInv.getWrapper(slot + inv.offset);
final InventoryAdaptor playerInv = InventoryAdaptor.getAdaptor(player, ForgeDirection.UNKNOWN);
mySlot.setInventorySlotContents(0, mergeToPlayerInventory(playerInv, mySlot.getStackInSlot(0)));
break;
case MOVE_REGION:
}
case MOVE_REGION -> {
final InventoryAdaptor playerInvAd = InventoryAdaptor.getAdaptor(player, ForgeDirection.UNKNOWN);
for (int x = 0; x < inv.client.getSizeInventory(); x++) {
inv.server.setInventorySlotContents(
x + inv.offset,
mergeToPlayerInventory(playerInvAd, inv.server.getStackInSlot(x + inv.offset)));
}
break;
case CREATIVE_DUPLICATE:
}
case CREATIVE_DUPLICATE -> {
if (player.capabilities.isCreativeMode && !hasItemInHand) {
player.inventory.setItemStack(is == null ? null : is.copy());
}
break;
default:
}
default -> {
return;
}
}
this.updateHeld(player);
@@ -132,11 +132,11 @@ public abstract class FCContainerEncodeTerminal extends ContainerItemMonitor
&& (stack.getItem() instanceof IFluidContainerItem || FluidContainerRegistry.isContainer(stack))) {
FluidStack fluid = null;
switch (action) {
case PICKUP_OR_SET_DOWN:
case PICKUP_OR_SET_DOWN -> {
fluid = Util.getFluidFromItem(stack);
slot.putStack(ItemFluidPacket.newStack(fluid));
break;
case SPLIT_OR_PLACE_SINGLE:
}
case SPLIT_OR_PLACE_SINGLE -> {
fluid = Util.getFluidFromItem(Util.copyStackWithSize(stack, 1));
FluidStack origin = ItemFluidPacket.getFluidStack(slot.getStack());
if (fluid != null && fluid.equals(origin)) {
@@ -144,7 +144,7 @@ public abstract class FCContainerEncodeTerminal extends ContainerItemMonitor
if (fluid.amount <= 0) fluid = null;
}
slot.putStack(ItemFluidPacket.newStack(fluid));
break;
}
}
if (fluid == null) {
super.doAction(player, action, slotId, id);
@@ -98,7 +98,7 @@ public abstract class FCContainerFluidConfigurable extends ContainerUpgradeable
@Override
protected void standardDetectAndSendChanges() {
if (Platform.isServer()) {
// clear out config items that are no longer valid (eg capacity upgrade removed)
// clear out config items that are no longer valid (for instance, capacity upgrade removed)
final AppEngInternalAEInventory inv = this.getFakeFluidInv();
final Map<Integer, IAEFluidStack> tmp = new HashMap<>();
for (int i = 0; i < inv.getSizeInventory(); ++i) {
@@ -210,8 +210,7 @@ public abstract class FCContainerMonitor<T extends IAEStack<T>> extends FCBaseCo
@Override
public void onListUpdate() {
for (final Object c : this.crafters) {
if (c instanceof ICrafting) {
final ICrafting cr = (ICrafting) c;
if (c instanceof final ICrafting cr) {
this.queueInventory(cr);
}
}
@@ -37,15 +37,12 @@ public class ItemWalrusRender implements IItemRenderer {
Minecraft.getMinecraft().renderEngine.bindTexture(this.textureWalrus);
GL11.glPushMatrix();
switch (type) {
case EQUIPPED_FIRST_PERSON:
case EQUIPPED_FIRST_PERSON -> {
GL11.glRotated(180, 0, 1, 0);
GL11.glTranslatef(-1F, 0.5F, -0.5F);
break;
case INVENTORY:
GL11.glTranslatef(-0.5F, -0.5F, -0.1F);
break;
default:
break;
}
case INVENTORY -> GL11.glTranslatef(-0.5F, -0.5F, -0.1F);
default -> {}
}
this.modelWalrus.renderAll();
GL11.glPopMatrix();
@@ -97,7 +97,7 @@ public class FluidTankRenderer {
for (int s = 0; s < DISPLAY_STAGES; ++s) {
diplayLists[s] = GLAllocation.generateDisplayLists(1);
GL11.glNewList(diplayLists[s], 4864 /* GL_COMPILE */);
GL11.glNewList(diplayLists[s], GL11.GL_COMPILE);
liquidBlock.minX = 0.01f;
liquidBlock.minY = 0;
@@ -78,16 +78,12 @@ public class BlockCertusQuartzTank extends BaseBlockContainer implements IRegist
@Override
public IIcon getIcon(int side, int meta) {
switch (meta) {
case 1:
return this.sideTopIcon;
case 2:
return this.sideBottomIcon;
case 3:
return this.sideMiddleIcon;
default:
return side == 0 ? this.bottomIcon : side == 1 ? this.topIcon : this.sideIcon;
}
return switch (meta) {
case 1 -> this.sideTopIcon;
case 2 -> this.sideBottomIcon;
case 3 -> this.sideMiddleIcon;
default -> side == 0 ? this.bottomIcon : side == 1 ? this.topIcon : this.sideIcon;
};
}
@Override
@@ -103,8 +99,7 @@ public class BlockCertusQuartzTank extends BaseBlockContainer implements IRegist
@Override
public int getLightValue(IBlockAccess world, int x, int y, int z) {
TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof TileCertusQuartzTank) {
TileCertusQuartzTank tank = (TileCertusQuartzTank) tile;
if (tile instanceof TileCertusQuartzTank tank) {
return tank.getFluidLightLevel();
}
return super.getLightValue(world, x, y, z);
@@ -76,21 +76,11 @@ public class BlockWalrus extends BaseBlockContainer {
@Override
public void setBlockBoundsBasedOnState(IBlockAccess blockAccess, int x, int y, int z) {
switch (ForgeDirection.getOrientation(blockAccess.getBlockMetadata(x, y, z))) {
case NORTH:
setBlockBounds(0.0F, 0.0F, -1.0F, 1.0F, 1.0F, 1.0F);
break;
case EAST:
setBlockBounds(0.0F, 0.0F, 0.0F, 2.0F, 1.0F, 1.0F);
break;
case SOUTH:
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 2.0F);
break;
case WEST:
setBlockBounds(-1.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
break;
default:
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
break;
case NORTH -> setBlockBounds(0.0F, 0.0F, -1.0F, 1.0F, 1.0F, 1.0F);
case EAST -> setBlockBounds(0.0F, 0.0F, 0.0F, 2.0F, 1.0F, 1.0F);
case SOUTH -> setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 2.0F);
case WEST -> setBlockBounds(-1.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
default -> setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
}
@@ -86,11 +86,6 @@ public abstract class FCBaseItemCell extends AEBaseItem implements IStorageFluid
@Override
public boolean isBlackListed(ItemStack cellItem, IAEFluidStack requestedAddition) {
// if (Config.blacklistEssentiaGas && ModAndClassUtil.ThE && requestedAddition != null) {
// return ModAndClassUtil.essentiaGas.isInstance(requestedAddition.getFluid());
// }
//
// What even is a null fluid
return requestedAddition == null || requestedAddition.getFluid() == null
|| FluidCraftAPI.instance().isBlacklistedInStorage(requestedAddition.getFluid().getClass());
}
@@ -101,8 +96,7 @@ public abstract class FCBaseItemCell extends AEBaseItem implements IStorageFluid
final IMEInventoryHandler<?> inventory = AEApi.instance().registries().cell()
.getCellInventory(stack, null, StorageChannel.FLUIDS);
if (inventory instanceof IFluidCellInventoryHandler) {
final IFluidCellInventoryHandler handler = (IFluidCellInventoryHandler) inventory;
if (inventory instanceof final IFluidCellInventoryHandler handler) {
final IFluidCellInventory cellInventory = handler.getCellInv();
if (cellInventory != null) {
@@ -46,41 +46,42 @@ public class ItemBasicFluidStorageCell extends FCBaseItemCell
setUnlocalizedName(NameConst.ITEM_FLUID_STORAGE + kilobytes);
switch (this.component) {
case Cell1kPart:
case Cell1kPart -> {
this.idleDrain = 0.5;
this.perType = 8;
break;
case Cell4kPart:
}
case Cell4kPart -> {
this.idleDrain = 1.0;
this.perType = 8;
break;
case Cell16kPart:
}
case Cell16kPart -> {
this.idleDrain = 1.5;
this.perType = 8;
break;
case Cell64kPart:
}
case Cell64kPart -> {
this.idleDrain = 2.0;
this.perType = 8;
break;
case Cell256kPart:
}
case Cell256kPart -> {
this.idleDrain = 2.5;
this.perType = 8;
break;
case Cell1024kPart:
}
case Cell1024kPart -> {
this.idleDrain = 3.0;
this.perType = 8;
break;
case Cell4096kPart:
}
case Cell4096kPart -> {
this.idleDrain = 3.5;
this.perType = 8;
break;
case Cell16384kPart:
}
case Cell16384kPart -> {
this.idleDrain = 4.0;
this.perType = 8;
break;
default:
}
default -> {
this.idleDrain = 0.0;
this.perType = 8;
}
}
}
@@ -53,7 +53,6 @@ public class ItemCreativeFluidStorageCell extends AEBaseItem
@Override
public boolean isBlackListed(ItemStack cellItem, IAEFluidStack requestedAddition) {
// What even is a null fluid
return requestedAddition == null || requestedAddition.getFluid() == null
|| FluidCraftAPI.instance().isBlacklistedInStorage(requestedAddition.getFluid().getClass());
}
@@ -109,8 +108,7 @@ public class ItemCreativeFluidStorageCell extends AEBaseItem
final IMEInventoryHandler<?> inventory = AEApi.instance().registries().cell()
.getCellInventory(stack, null, StorageChannel.FLUIDS);
if (inventory instanceof IFluidCellInventoryHandler) {
final IFluidCellInventoryHandler handler = (IFluidCellInventoryHandler) inventory;
if (inventory instanceof final IFluidCellInventoryHandler handler) {
final IFluidCellInventory cellInventory = handler.getCellInv();
if (GuiScreen.isCtrlKeyDown()) {
@@ -47,41 +47,42 @@ public class ItemMultiFluidStorageCell extends FCBaseItemCell
setUnlocalizedName(NameConst.ITEM_MULTI_FLUID_STORAGE + kilobytes);
switch (this.component) {
case Cell1kPart:
case Cell1kPart -> {
this.idleDrain = 0.5;
this.perType = 8;
break;
case Cell4kPart:
}
case Cell4kPart -> {
this.idleDrain = 1.0;
this.perType = 32;
break;
case Cell16kPart:
}
case Cell16kPart -> {
this.idleDrain = 1.5;
this.perType = 128;
break;
case Cell64kPart:
}
case Cell64kPart -> {
this.idleDrain = 2.0;
this.perType = 512;
break;
case Cell256kPart:
}
case Cell256kPart -> {
this.idleDrain = 2.5;
this.perType = 2048;
break;
case Cell1024kPart:
}
case Cell1024kPart -> {
this.idleDrain = 3.0;
this.perType = 8192;
break;
case Cell4096kPart:
}
case Cell4096kPart -> {
this.idleDrain = 3.5;
this.perType = 32768;
break;
case Cell16384kPart:
}
case Cell16384kPart -> {
this.idleDrain = 4.0;
this.perType = 131072;
break;
default:
}
default -> {
this.idleDrain = 0.0;
this.perType = 8;
}
}
}
@@ -78,8 +78,7 @@ public class ItemPortableFluidCell extends AEBasePoweredItem
super.addCheckedInformation(stack, player, lines, displayMoreInfo);
final IMEInventoryHandler<?> inventory = AEApi.instance().registries().cell()
.getCellInventory(stack, null, StorageChannel.FLUIDS);
if (inventory instanceof IFluidCellInventoryHandler) {
final IFluidCellInventoryHandler handler = (IFluidCellInventoryHandler) inventory;
if (inventory instanceof final IFluidCellInventoryHandler handler) {
final IFluidCellInventory cellInventory = handler.getCellInv();
if (cellInventory != null) {
lines.add(
@@ -132,7 +131,6 @@ public class ItemPortableFluidCell extends AEBasePoweredItem
@Override
public boolean isBlackListed(ItemStack cellItem, IAEFluidStack requestedAddition) {
// What even is a null fluid
return requestedAddition == null || requestedAddition.getFluid() == null
|| FluidCraftAPI.instance().isBlacklistedInStorage(requestedAddition.getFluid().getClass());
}
@@ -102,9 +102,7 @@ public class PartFluidConversionMonitor extends PartFluidStorageMonitor {
}
}
} catch (final GridAccessException e) {
// :P
}
} catch (final GridAccessException ignored) {}
return true;
}
@@ -153,9 +151,7 @@ public class PartFluidConversionMonitor extends PartFluidStorageMonitor {
player.openContainer.detectAndSendChanges();
}
}
} catch (final GridAccessException e) {
// :P
}
} catch (final GridAccessException ignored) {}
}
}
}
@@ -163,9 +163,7 @@ public class PartFluidExportBus extends FCSharedFluidBus implements ICraftingReq
}
this.updateSchedulingMode(this.getSchedulingMode(), i);
return didSomething ? TickRateModulation.FASTER : TickRateModulation.SLOWER;
} catch (GridAccessException e) {
// Ignore
}
} catch (GridAccessException ignored) {}
}
return TickRateModulation.SLEEP;
@@ -130,10 +130,16 @@ public class PartFluidLevelEmitter extends PartUpgradeable
return false;
}
final boolean flipState = this.getConfigManager().getSetting(Settings.REDSTONE_EMITTER)
== RedstoneMode.LOW_SIGNAL;
return flipState ? this.reportingValue >= this.lastReportedValue + 1
: this.reportingValue < this.lastReportedValue + 1;
final Enum<?> redstoneEmitterSetting = this.getConfigManager().getSetting(Settings.REDSTONE_EMITTER);
final boolean result;
if (redstoneEmitterSetting == RedstoneMode.LOW_SIGNAL) {
result = this.reportingValue >= this.lastReportedValue + 1;
} else {
result = this.reportingValue < this.lastReportedValue + 1;
}
return result;
}
@MENetworkEventSubscribe
@@ -181,9 +187,7 @@ public class PartFluidLevelEmitter extends PartUpgradeable
this.myWatcher.add(myStack);
}
this.updateReportingValue(this.getProxy().getStorage().getFluidInventory());
} catch (final GridAccessException e1) {
// :/
}
} catch (final GridAccessException ignored) {}
}
private void updateReportingValue(final IMEMonitor<IAEFluidStack> monitor) {
@@ -282,9 +286,7 @@ public class PartFluidLevelEmitter extends PartUpgradeable
public void onListUpdate() {
try {
this.updateReportingValue(this.getProxy().getStorage().getFluidInventory());
} catch (final GridAccessException e) {
// ;P
}
} catch (final GridAccessException ignored) {}
}
@Override
@@ -304,40 +306,23 @@ public class PartFluidLevelEmitter extends PartUpgradeable
Tessellator.instance.startDrawingQuads();
this.renderTorchAtAngle(0, -0.5, 0);
Tessellator.instance.draw();
// rh.setBounds( 7, 7, 10, 9, 9, 15 );
// rh.renderInventoryBox( renderer );
}
private void renderTorchAtAngle(double baseX, double baseY, double baseZ) {
final boolean isOn = this.isLevelEmitterOn();
final IIcon offTexture = this.getItemStack().getIconIndex();
final IIcon IIcon = (isOn ? CableBusTextures.LevelEmitterTorchOn.getIcon() : offTexture);
//
this.centerX = baseX + 0.5;
this.centerY = baseY + 0.5;
this.centerZ = baseZ + 0.5;
baseY += 7.0 / 16.0;
// double par11 = 0;
/*
* double d5 = (double)IIcon.func_94209_e(); double d6 = (double)IIcon.func_94206_g(); double d7 =
* (double)IIcon.func_94212_f(); double d8 = (double)IIcon.func_94210_h(); double d9 =
* (double)IIcon.func_94214_a(7.0D); double d10 = (double)IIcon.func_94207_b(6.0D); double d11 =
* (double)IIcon.func_94214_a(9.0D); double d12 = (double)IIcon.func_94207_b(8.0D); double d13 =
* (double)IIcon.func_94214_a(7.0D); double d14 = (double)IIcon.func_94207_b(13.0D); double d15 =
* (double)IIcon.func_94214_a(9.0D); double d16 = (double)IIcon.func_94207_b(15.0D);
*/
final float var16 = IIcon.getMinU();
final float var17 = IIcon.getMaxU();
final float var18 = IIcon.getMinV();
final float var19 = IIcon.getMaxV();
/*
* float var16 = (float)var14 / 256.0F; float var17 = ((float)var14 + 15.99F) / 256.0F; float var18 =
* (float)var15 / 256.0F; float var19 = ((float)var15 + 15.99F) / 256.0F;
*/
final double var20b = offTexture.getInterpolatedU(7.0D);
final double var24b = offTexture.getInterpolatedU(9.0D);
@@ -376,56 +361,26 @@ public class PartFluidLevelEmitter extends PartUpgradeable
final double var44 = 0.0625D;
final double Zero = 0;
final double par10 = 0;
this.addVertexWithUV(
baseX + Zero * (1.0D - TorchLen) - var44,
baseY + TorchLen - toff,
baseZ + par10 * (1.0D - TorchLen) - var44,
var20,
var22);
this.addVertexWithUV(
baseX + Zero * (1.0D - TorchLen) - var44,
baseY + TorchLen - toff,
baseZ + par10 * (1.0D - TorchLen) + var44,
var20,
var26);
this.addVertexWithUV(
baseX + Zero * (1.0D - TorchLen) + var44,
baseY + TorchLen - toff,
baseZ + par10 * (1.0D - TorchLen) + var44,
var24,
var26);
this.addVertexWithUV(
baseX + Zero * (1.0D - TorchLen) + var44,
baseY + TorchLen - toff,
baseZ + par10 * (1.0D - TorchLen) - var44,
var24,
var22);
final double x = baseX + Zero * (1.0D - TorchLen) - var44;
final double x1 = baseX + Zero * (1.0D - TorchLen) + var44;
final double y = baseY + TorchLen - toff;
final double var422 = 0.1915D + 1.0 / 16.0;
this.addVertexWithUV(
baseX + Zero * (1.0D - TorchLen) + var44,
baseY + var422,
baseZ + par10 * (1.0D - TorchLen) - var44,
var24b,
var22b);
this.addVertexWithUV(
baseX + Zero * (1.0D - TorchLen) + var44,
baseY + var422,
baseZ + par10 * (1.0D - TorchLen) + var44,
var24b,
var26b);
this.addVertexWithUV(
baseX + Zero * (1.0D - TorchLen) - var44,
baseY + var422,
baseZ + par10 * (1.0D - TorchLen) + var44,
var20b,
var26b);
this.addVertexWithUV(
baseX + Zero * (1.0D - TorchLen) - var44,
baseY + var422,
baseZ + par10 * (1.0D - TorchLen) - var44,
var20b,
var22b);
final double y1 = baseY + var422;
final double z = baseZ + par10 * (1.0D - TorchLen) - var44;
final double z1 = baseZ + par10 * (1.0D - TorchLen) + var44;
this.addVertexWithUV(x, y, z, var20, var22);
this.addVertexWithUV(x, y, z1, var20, var26);
this.addVertexWithUV(x1, y, z1, var24, var26);
this.addVertexWithUV(x1, y, z, var24, var22);
this.addVertexWithUV(x1, y1, z, var24b, var22b);
this.addVertexWithUV(x1, y1, z1, var24b, var26b);
this.addVertexWithUV(x, y1, z1, var20b, var26b);
this.addVertexWithUV(x, y1, z, var20b, var22b);
this.addVertexWithUV(baseX + var44 + Zero, baseY, baseZ - var44 + par10, var32, var30);
this.addVertexWithUV(baseX + var44 + Zero, baseY, baseZ + var44 + par10, var32, var34);
@@ -503,13 +458,6 @@ public class PartFluidLevelEmitter extends PartUpgradeable
public void renderStatic(final int x, final int y, final int z, final IPartRenderHelper rh,
final RenderBlocks renderer) {
rh.setTexture(this.getItemStack().getIconIndex());
// rh.setTexture( CableBusTextures.ItemPartLevelEmitterOn.getIcon() );
// rh.setBounds( 2, 2, 14, 14, 14, 16 );
// rh.renderBlock( x, y, z, renderer );
// rh.setBounds( 7, 7, 10, 9, 9, 15 );
// rh.renderBlock( x, y, z, renderer );
renderer.renderAllFaces = true;
@@ -523,8 +471,6 @@ public class PartFluidLevelEmitter extends PartUpgradeable
rh.setBounds(7, 7, 11, 9, 9, 12);
this.renderLights(x, y, z, rh, renderer);
// super.renderWorldBlock( world, x, y, z, block, modelId, renderer );
}
@Override
@@ -41,9 +41,8 @@ public class PartFluidPatternTerminal extends FCFluidEncodeTerminal {
final ItemStack removedStack, final ItemStack newStack) {
if (inv == this.pattern && slot == 1) {
final ItemStack is = inv.getStackInSlot(1);
if (is != null && is.getItem() instanceof ICraftingPatternItem) {
final ICraftingPatternItem pattern = (ICraftingPatternItem) is.getItem();
final ICraftingPatternDetails details = pattern
if (is != null && is.getItem() instanceof final ICraftingPatternItem craftingPatternItem) {
final ICraftingPatternDetails details = craftingPatternItem
.getPatternForItem(is, this.getHost().getTile().getWorldObj());
if (details != null) {
final IAEItemStack[] inItems = details.getInputs();
@@ -40,9 +40,8 @@ public class PartFluidPatternTerminalEx extends FCFluidEncodeTerminal {
if (inv == this.pattern && slot == 1) {
final ItemStack is = inv.getStackInSlot(1);
if (is != null && is.getItem() instanceof ICraftingPatternItem) {
final ICraftingPatternItem pattern = (ICraftingPatternItem) is.getItem();
final ICraftingPatternDetails details = pattern
if (is != null && is.getItem() instanceof final ICraftingPatternItem craftingPatternItem) {
final ICraftingPatternDetails details = craftingPatternItem
.getPatternForItem(is, this.getHost().getTile().getWorldObj());
if (details != null) {
@@ -348,8 +348,7 @@ public class PartFluidStorageBus extends PartUpgradeable
if (esh != null) {
final IMEInventory<?> inv = esh
.getInventory(target, this.getSide().getOpposite(), StorageChannel.FLUIDS, this.source);
if (inv instanceof MEMonitorIFluidHandler) {
final MEMonitorIFluidHandler h = (MEMonitorIFluidHandler) inv;
if (inv instanceof final MEMonitorIFluidHandler h) {
h.setMode((StorageFilter) this.getConfigManager().getSetting(Settings.STORAGE_FILTER));
h.setActionSource(new MachineSource(this));
this.monitor = (MEMonitorIFluidHandler) inv;
@@ -179,8 +179,8 @@ public abstract class FCFluidEncodeTerminal extends FCPart implements IItemPatte
@Override
public void sortCraftingItems() {
List<ItemStack> items = new ArrayList<ItemStack>();
List<ItemStack> fluids = new ArrayList<ItemStack>();
List<ItemStack> items = new ArrayList<>();
List<ItemStack> fluids = new ArrayList<>();
for (ItemStack is : this.crafting) {
if (is == null) continue;
if (is.getItem() instanceof ItemFluidPacket) {
@@ -76,7 +76,7 @@ public abstract class FCPart extends AEBasePart
this.getProxy().setFlags(GridFlags.REQUIRE_CHANNEL);
this.getProxy().setIdlePowerUsage(1.0 / 2.0);
} else {
this.getProxy().setIdlePowerUsage(1.0 / 16.0); // lights drain a little bit.
this.getProxy().setIdlePowerUsage(1.0 / 16.0); // lights drain a little
}
this.cm.registerSetting(Settings.SORT_BY, SortOrder.NAME);
this.cm.registerSetting(Settings.VIEW_MODE, ViewItems.ALL);
@@ -163,9 +163,7 @@ public abstract class FCPart extends AEBasePart
if (this.getProxy().getNode().meetsChannelRequirements()) {
this.clientFlags = this.getClientFlags() | FCPart.CHANNEL_FLAG;
}
} catch (final GridAccessException e) {
// um.. nothing.
}
} catch (final GridAccessException ignored) {}
data.writeByte((byte) this.getClientFlags());
}
@@ -195,18 +193,10 @@ public abstract class FCPart extends AEBasePart
}
switch (this.getSpin()) {
case 0:
this.spin = 1;
break;
case 1:
this.spin = 3;
break;
case 2:
this.spin = 0;
break;
case 3:
this.spin = 2;
break;
case 0 -> this.spin = 1;
case 1 -> this.spin = 3;
case 2 -> this.spin = 0;
case 3 -> this.spin = 2;
}
this.getHost().markForUpdate();
@@ -276,9 +266,7 @@ public abstract class FCPart extends AEBasePart
public IMEMonitor<IAEItemStack> getItemInventory() {
try {
return this.getProxy().getStorage().getItemInventory();
} catch (final GridAccessException e) {
// err nope?
}
} catch (final GridAccessException ignored) {}
return null;
}
@@ -286,9 +274,7 @@ public abstract class FCPart extends AEBasePart
public IMEMonitor<IAEFluidStack> getFluidInventory() {
try {
return this.getProxy().getStorage().getFluidInventory();
} catch (final GridAccessException e) {
// err nope?
}
} catch (final GridAccessException ignored) {}
return null;
}
@@ -434,27 +420,27 @@ public abstract class FCPart extends AEBasePart
/**
* The texture used for the bright front layer.
* <p>
* The final texture can overlap any of the the texture in no particular order.
* The final texture can overlap any of the texture in no particular order.
*/
public abstract FCPartsTexture getFrontBright();
/**
* The texture used for the colored (medium) front layer.
* <p>
* The final texture can overlap any of the the texture in no particular order.
* The final texture can overlap any of the texture in no particular order.
*/
public abstract FCPartsTexture getFrontColored();
/**
* The texture used for the dark front layer.
* <p>
* The final texture can overlap any of the the texture in no particular order.
* The final texture can overlap any of the texture in no particular order.
*/
public abstract FCPartsTexture getFrontDark();
/**
* Should the part emit light. This actually only affects the light level, light source use a level of 15 and non
* light source 9.
* Should the part emit light. This actually only affects the light level, light source use a level of 15 and
* non-light source 9.
*/
public abstract boolean isLightSource();
}
@@ -175,9 +175,7 @@ public abstract class FCPartMonitor extends AbstractPartDisplay implements IPart
this.updateReportingValue(this.getProxy().getStorage().getFluidInventory());
}
} catch (final GridAccessException e) {
// >.>
}
} catch (final GridAccessException ignored) {}
}
protected void extractItem(final EntityPlayer player) {}
@@ -248,41 +246,35 @@ public abstract class FCPartMonitor extends AbstractPartDisplay implements IPart
}
private void tesrRenderScreen(final Tessellator tess, final IAEFluidStack ais) {
// GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
final ForgeDirection d = this.getSide();
GL11.glTranslated(d.offsetX * 0.77, d.offsetY * 0.77, d.offsetZ * 0.77);
switch (d) {
case UP:
case UP -> {
GL11.glScalef(1.0f, -1.0f, 1.0f);
GL11.glRotatef(90.0f, 1.0f, 0.0f, 0.0f);
GL11.glRotatef(this.getSpin() * 90.0F, 0, 0, 1);
break;
case DOWN:
}
case DOWN -> {
GL11.glScalef(1.0f, -1.0f, 1.0f);
GL11.glRotatef(-90.0f, 1.0f, 0.0f, 0.0f);
GL11.glRotatef(this.getSpin() * -90.0F, 0, 0, 1);
break;
case EAST:
}
case EAST -> {
GL11.glScalef(-1.0f, -1.0f, -1.0f);
GL11.glRotatef(-90.0f, 0.0f, 1.0f, 0.0f);
break;
case WEST:
}
case WEST -> {
GL11.glScalef(-1.0f, -1.0f, -1.0f);
GL11.glRotatef(90.0f, 0.0f, 1.0f, 0.0f);
break;
case NORTH:
GL11.glScalef(-1.0f, -1.0f, -1.0f);
break;
case SOUTH:
}
case NORTH -> GL11.glScalef(-1.0f, -1.0f, -1.0f);
case SOUTH -> {
GL11.glScalef(-1.0f, -1.0f, -1.0f);
GL11.glRotatef(180.0f, 0.0f, 1.0f, 0.0f);
break;
default:
break;
}
default -> {}
}
final ItemStack sis = ItemFluidPacket.newDisplayStack(ais.getFluidStack());
@@ -296,7 +288,6 @@ public abstract class FCPartMonitor extends AbstractPartDisplay implements IPart
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
// RenderHelper.enableGUIStandardItemLighting();
tess.setColorOpaque_F(1.0f, 1.0f, 1.0f);
ClientHelper.proxy.doRenderItem(sis, this.getTile().getWorldObj());
@@ -318,7 +309,6 @@ public abstract class FCPartMonitor extends AbstractPartDisplay implements IPart
GL11.glTranslatef(-0.5f * width, 0.0f, -1.0f);
fr.drawString(renderedStackSize, 0, 0, 0);
}
// GL11.glPopAttrib();
}
@Override
@@ -62,9 +62,7 @@ public abstract class FCSharedFluidBus extends PartUpgradeable implements IGridT
} else {
this.getProxy().getTick().sleepDevice(this.getProxy().getNode());
}
} catch (final GridAccessException e) {
// :P
}
} catch (final GridAccessException ignored) {}
}
@Override
@@ -57,24 +57,15 @@ public enum CellType {
}
public static EnumChatFormatting getTypeColor(CellType type) {
switch (type) {
case Cell1kPart:
return EnumChatFormatting.GOLD;
case Cell4kPart:
return EnumChatFormatting.YELLOW;
case Cell16kPart:
return EnumChatFormatting.GREEN;
case Cell64kPart:
return EnumChatFormatting.AQUA;
case Cell256kPart:
return EnumChatFormatting.BLUE;
case Cell1024kPart:
return EnumChatFormatting.LIGHT_PURPLE;
case Cell4096kPart:
return EnumChatFormatting.RED;
case Cell16384kPart:
return EnumChatFormatting.DARK_PURPLE;
}
return EnumChatFormatting.WHITE;
return switch (type) {
case Cell1kPart -> EnumChatFormatting.GOLD;
case Cell4kPart -> EnumChatFormatting.YELLOW;
case Cell16kPart -> EnumChatFormatting.GREEN;
case Cell64kPart -> EnumChatFormatting.AQUA;
case Cell256kPart -> EnumChatFormatting.BLUE;
case Cell1024kPart -> EnumChatFormatting.LIGHT_PURPLE;
case Cell4096kPart -> EnumChatFormatting.RED;
case Cell16384kPart -> EnumChatFormatting.DARK_PURPLE;
};
}
}
@@ -49,8 +49,7 @@ public class FluidCellHandler implements ICellHandler {
public void openChestGui(final EntityPlayer player, final IChestOrDrive chest, final ICellHandler cellHandler,
final IMEInventoryHandler inv, final ItemStack is, final StorageChannel chan) {
if (chan == StorageChannel.FLUIDS) {
if (chest instanceof TileEntity) {
TileEntity te = (TileEntity) chest;
if (chest instanceof TileEntity te) {
InventoryHandler
.openGui(player, te.getWorldObj(), new BlockPos(te), chest.getUp(), GuiType.FLUID_TERMINAL);
}
@@ -59,8 +58,7 @@ public class FluidCellHandler implements ICellHandler {
@Override
public int getStatusForCell(final ItemStack is, final IMEInventory handler) {
if (handler instanceof FluidCellInventoryHandler) {
final FluidCellInventoryHandler ci = (FluidCellInventoryHandler) handler;
if (handler instanceof final FluidCellInventoryHandler ci) {
return ci.getStatusForCell();
}
return 0;
@@ -99,9 +99,8 @@ public class TileCertusQuartzTank extends TileEntity implements IFluidHandler {
if (drained == null || drained.amount < fluid.amount) {
TileEntity offTE = this.worldObj.getTileEntity(this.xCoord, this.yCoord - 1, this.zCoord);
if (offTE instanceof TileCertusQuartzTank) {
TileCertusQuartzTank tank = (TileCertusQuartzTank) offTE;
FluidStack externallyDrained = tank.drain(
if (offTE instanceof TileCertusQuartzTank tileCertusQuartzTank) {
FluidStack externallyDrained = tileCertusQuartzTank.drain(
new FluidStack(fluid.getFluid(), fluid.amount - (drained != null ? drained.amount : 0)),
doDrain,
false);
@@ -158,16 +157,18 @@ public class TileCertusQuartzTank extends TileEntity implements IFluidHandler {
if (filled < fluid.amount) {
TileEntity offTE = this.worldObj.getTileEntity(this.xCoord, this.yCoord + 1, this.zCoord);
if (offTE instanceof TileCertusQuartzTank) {
TileCertusQuartzTank tank = (TileCertusQuartzTank) offTE;
return filled + tank.fill(new FluidStack(fluid.getFluid(), fluid.amount - filled), doFill, false);
if (offTE instanceof TileCertusQuartzTank tileCertusQuartzTank) {
return filled + tileCertusQuartzTank
.fill(new FluidStack(fluid.getFluid(), fluid.amount - filled), doFill, false);
}
}
return filled;
}
/* IFluidHandler */
/**
* An override for {@link IFluidHandler}
*/
@Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
if (resource == null || this.tank.getFluid() != null && resource.getFluid() != this.tank.getFluid().getFluid())
@@ -223,7 +224,7 @@ public class TileCertusQuartzTank extends TileEntity implements IFluidHandler {
private TileCertusQuartzTank getTankBelow(TileEntity tile) {
TileEntity tank = new BlockPos(tile).getOffSet(0, -1, 0).getTileEntity();
if (tank != null && tank instanceof TileCertusQuartzTank) {
if (tank instanceof TileCertusQuartzTank) {
return (TileCertusQuartzTank) tank;
}
return null;
@@ -50,9 +50,7 @@ public class TileFluidBuffer extends AENetworkTile implements IAEFluidInventory,
.findPrecise(AEFluidStack.create(fs));
this.invFluids.setFluidInSlot(0, ias);
if (ias != null) return true;
} catch (final GridAccessException e) {
// :P
}
} catch (final GridAccessException ignored) {}
return false;
}
@@ -67,9 +65,7 @@ public class TileFluidBuffer extends AENetworkTile implements IAEFluidInventory,
this.source);
if (notInserted != null) return fluidStack.amount -= notInserted.getStackSize();
return fluidStack.amount;
} catch (final GridAccessException e) {
// :P
}
} catch (final GridAccessException ignored) {}
}
return 0;
}
@@ -92,9 +88,7 @@ public class TileFluidBuffer extends AENetworkTile implements IAEFluidInventory,
.extractItems(ias, actionable, this.source);
if (extracted == null) return null;
return extracted.getFluidStack();
} catch (final GridAccessException e) {
// :P
}
} catch (final GridAccessException ignored) {}
return null;
}
@@ -113,9 +107,7 @@ public class TileFluidBuffer extends AENetworkTile implements IAEFluidInventory,
try {
return this.getProxy().getStorage().getFluidInventory().getStorageList()
.findPrecise(this.getAEFluidStack());
} catch (final GridAccessException e) {
// :P
}
} catch (final GridAccessException ignored) {}
return null;
}
@@ -44,7 +44,6 @@ public class TileFluidDiscretizer extends AENetworkTile implements IPriorityHost
@Override
public boolean canBeRotated() {
return false;
// based
}
@Override
@@ -212,7 +211,7 @@ public class TileFluidDiscretizer extends AENetworkTile implements IPriorityHost
@Override
public boolean isValid(Object verificationToken) {
IMEMonitor<IAEFluidStack> fluidGrid = getFluidGrid();
return fluidGrid != null && fluidGrid == verificationToken /* && !conflict */;
return fluidGrid != null && fluidGrid == verificationToken;
}
@Override
@@ -14,34 +14,17 @@ public class FCClassTransformer implements IClassTransformer {
public byte[] transform(String name, String transformedName, byte[] code) {
Transform tform;
switch (transformedName) {
case "appeng.crafting.CraftingTreeNode":
tform = CraftingTreeNodeTransformer.INSTANCE;
break;
case "appeng.me.cluster.implementations.CraftingCPUCluster":
tform = CraftingCpuTransformer.INSTANCE;
break;
case "appeng.helpers.DualityInterface":
tform = DualityInterfaceTransformer.INSTANCE;
break;
case "appeng.container.implementations.ContainerInterfaceTerminal":
tform = ContainerInterfaceTerminalTransformer.INSTANCE;
break;
case "appeng.client.gui.implementations.GuiCraftingCPU":
case "appeng.client.gui.implementations.GuiCraftConfirm":
case "net.p455w0rd.wirelesscraftingterminal.client.gui.GuiCraftConfirm":
tform = GuiCraftingTransformer.INSTANCE;
break;
case "appeng.integration.modules.NEI":
tform = NEITransfermer.INSTANCE;
break;
case "appeng.core.features.registries.ExternalStorageRegistry":
tform = ExternalStorageRegistryTransformer.INSTANCE;
break;
case "appeng.core.sync.packets.PacketCompressedNBT":
tform = PacketCompressedNBTTransformer.INSTANCE;
break;
default:
case "appeng.crafting.CraftingTreeNode" -> tform = CraftingTreeNodeTransformer.INSTANCE;
case "appeng.me.cluster.implementations.CraftingCPUCluster" -> tform = CraftingCpuTransformer.INSTANCE;
case "appeng.helpers.DualityInterface" -> tform = DualityInterfaceTransformer.INSTANCE;
case "appeng.container.implementations.ContainerInterfaceTerminal" -> tform = ContainerInterfaceTerminalTransformer.INSTANCE;
case "appeng.client.gui.implementations.GuiCraftingCPU", "appeng.client.gui.implementations.GuiCraftConfirm", "net.p455w0rd.wirelesscraftingterminal.client.gui.GuiCraftConfirm" -> tform = GuiCraftingTransformer.INSTANCE;
case "appeng.integration.modules.NEI" -> tform = NEITransfermer.INSTANCE;
case "appeng.core.features.registries.ExternalStorageRegistry" -> tform = ExternalStorageRegistryTransformer.INSTANCE;
case "appeng.core.sync.packets.PacketCompressedNBT" -> tform = PacketCompressedNBTTransformer.INSTANCE;
default -> {
return code;
}
}
System.out.println("[AE2FC] Transforming class: " + transformedName);
return tform.transformClass(code);
@@ -27,16 +27,12 @@ public class DualityInterfaceTransformer extends FCClassTransformer.ClassMapper
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
switch (name) {
case "pushItemsOut":
case "pushPattern":
case "isBusy":
return new TransformInvAdaptorCalls(
api,
super.visitMethod(access, name, desc, signature, exceptions));
default:
return super.visitMethod(access, name, desc, signature, exceptions);
}
return switch (name) {
case "pushItemsOut", "pushPattern", "isBusy" -> new TransformInvAdaptorCalls(
api,
super.visitMethod(access, name, desc, signature, exceptions));
default -> super.visitMethod(access, name, desc, signature, exceptions);
};
}
}
@@ -27,16 +27,15 @@ public class NEITransfermer extends FCClassTransformer.ClassMapper {
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
switch (name) {
case "getStackUnderMouse":
return new TransformStackUnderMouse(
api,
super.visitMethod(access, name, desc, signature, exceptions));
case "shouldShowTooltip":
return new TransformShowTooltip(api, super.visitMethod(access, name, desc, signature, exceptions));
default:
return super.visitMethod(access, name, desc, signature, exceptions);
}
return switch (name) {
case "getStackUnderMouse" -> new TransformStackUnderMouse(
api,
super.visitMethod(access, name, desc, signature, exceptions));
case "shouldShowTooltip" -> new TransformShowTooltip(
api,
super.visitMethod(access, name, desc, signature, exceptions));
default -> super.visitMethod(access, name, desc, signature, exceptions);
};
}
}
@@ -22,7 +22,7 @@ import li.cil.oc.api.Items;
import li.cil.oc.api.detail.ItemInfo;
/**
* Shell class to organize proxy replacements and hide the ugliness
* A shell class to organize proxy replacements and hide the ugliness
*/
public class ItemReplacements {
@@ -78,9 +78,11 @@ public class ItemReplacements {
registry.put("extracells:storage.physical.void", voidCell);
deprecateItem("pattern.fluid", ItemAndBlockHolder.PATTERN);
deprecateWireless("terminal.fluid.wireless", ItemAndBlockHolder.WIRELESS_FLUID_TERM);
/* Storage casings */
deprecateItem("storage.casing", 0, AEApi.instance().definitions().materials().emptyAdvancedStorageCell());
deprecateItem("storage.casing", 1, ItemAndBlockHolder.CELL_HOUSING, 2);
/* Storage components (1k component, etc.) */
deprecateItem("storage.component", 0, AEApi.instance().definitions().materials().cell256kPart());
deprecateItem("storage.component", 1, AEApi.instance().definitions().materials().cell1024kPart());
@@ -69,8 +69,7 @@ public class ProxyItem extends FCBaseItem {
@Override
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int p_77663_4_, boolean p_77663_5_) {
if (!worldIn.isRemote && entityIn instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) entityIn;
if (!worldIn.isRemote && entityIn instanceof EntityPlayer player) {
for (int i = 0; i < player.inventory.getSizeInventory(); ++i) {
ItemStack s = player.inventory.getStackInSlot(i);
if (s == stack) {
@@ -4,6 +4,8 @@ import java.lang.ref.WeakReference;
import java.util.List;
import java.util.Random;
import javax.annotation.Nonnull;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
@@ -186,6 +188,7 @@ public class ProxyPart implements IPart, IPartDeprecated {
return def;
}
@Nonnull
@Override
public NBTTagCompound transformNBT(NBTTagCompound extra) {
return extra;
@@ -23,12 +23,6 @@ public class ProxyPartItem extends ProxyItem implements IPartItem {
super(ec2itemName);
}
/**
*
* @param srcMeta
* @param replacement
* @param part
*/
protected void addItemPart(int srcMeta, Item replacement, Function<ProxyPartItem, ProxyPart> part) {
this.replacements.put(srcMeta, new PartReplacement(replacement, part));
}
@@ -42,8 +36,7 @@ public class ProxyPartItem extends ProxyItem implements IPartItem {
@Override
public IPart createPartFromItemStack(ItemStack is) {
final int meta = is.getItemDamage();
if (this.replacements.get(meta) instanceof PartReplacement) {
PartReplacement part = (PartReplacement) this.replacements.get(meta);
if (this.replacements.get(meta) instanceof PartReplacement part) {
return part.proxyPart.apply(this);
}
return null;
@@ -2,6 +2,8 @@ package com.glodblock.github.crossmod.extracells.parts;
import static net.minecraftforge.common.util.Constants.NBT.TAG_COMPOUND;
import javax.annotation.Nonnull;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
@@ -25,6 +27,7 @@ public class ProxyFluidBusIO extends ProxyPart {
super(partItem);
}
@Nonnull
@Override
public NBTTagCompound transformNBT(NBTTagCompound extra) {
// Transform NBT in place
@@ -50,18 +53,10 @@ public class ProxyFluidBusIO extends ProxyPart {
// Redstone mode
RedstoneMode redstoneMode = RedstoneMode.values()[extra.getInteger("redstoneMode")];
switch (redstoneMode) {
case LOW_SIGNAL:
extra.setString("REDSTONE_CONTROLLED", "LOW_SIGNAL");
break;
case HIGH_SIGNAL:
extra.setString("REDSTONE_CONTROLLED", "HIGH_SIGNAL");
break;
case SIGNAL_PULSE:
extra.setString("REDSTONE_CONTROLLED", "SIGNAL_PULSE");
break;
default:
extra.setString("REDSTONE_CONTROLLED", "IGNORE");
break;
case LOW_SIGNAL -> extra.setString("REDSTONE_CONTROLLED", "LOW_SIGNAL");
case HIGH_SIGNAL -> extra.setString("REDSTONE_CONTROLLED", "HIGH_SIGNAL");
case SIGNAL_PULSE -> extra.setString("REDSTONE_CONTROLLED", "SIGNAL_PULSE");
default -> extra.setString("REDSTONE_CONTROLLED", "IGNORE");
}
extra.removeTag("redstoneMode");
// Part data
@@ -1,5 +1,7 @@
package com.glodblock.github.crossmod.extracells.parts;
import javax.annotation.Nonnull;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraftforge.common.util.Constants;
@@ -13,6 +15,7 @@ public class ProxyFluidInterface extends ProxyPart {
super(item);
}
@Nonnull
@Override
public NBTTagCompound transformNBT(NBTTagCompound extra) {
// Internal fluids - ConfigInv and FluidInv
@@ -2,6 +2,8 @@ package com.glodblock.github.crossmod.extracells.parts;
import static net.minecraftforge.common.util.Constants.NBT.TAG_COMPOUND;
import javax.annotation.Nonnull;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
@@ -31,6 +33,7 @@ public class ProxyFluidStorage extends ProxyPart {
super(item);
}
@Nonnull
@Override
public NBTTagCompound transformNBT(NBTTagCompound extra) {
// Transform in place, less messy IMO
@@ -1,5 +1,7 @@
package com.glodblock.github.crossmod.extracells.parts;
import javax.annotation.Nonnull;
import net.minecraft.nbt.NBTTagCompound;
import com.glodblock.github.crossmod.extracells.ProxyPart;
@@ -13,6 +15,7 @@ public class ProxyLevelEmitter extends ProxyPart {
super(item);
}
@Nonnull
@Override
public NBTTagCompound transformNBT(NBTTagCompound extra) {
// Fluid
@@ -1,5 +1,7 @@
package com.glodblock.github.crossmod.extracells.parts;
import javax.annotation.Nonnull;
import net.minecraft.nbt.NBTTagCompound;
import com.glodblock.github.crossmod.extracells.ProxyPart;
@@ -13,9 +15,10 @@ public class ProxyOreDictExportBus extends ProxyPart {
super(item);
}
@Nonnull
@Override
public NBTTagCompound transformNBT(NBTTagCompound extra) {
// Node tag... should've used OOP here but im too lazy to fix it now
// TODO: Node tag... should use OOP here.
extra.setTag("part", extra.getCompoundTag("node").getCompoundTag("node0"));
extra.removeTag("node");
// Ore dict card
@@ -1,5 +1,7 @@
package com.glodblock.github.crossmod.extracells.parts;
import javax.annotation.Nonnull;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
@@ -13,6 +15,7 @@ public class ProxyStorageMonitor extends ProxyPart {
super(item);
}
@Nonnull
@Override
public NBTTagCompound transformNBT(NBTTagCompound extra) {
// Fluid
@@ -45,7 +45,6 @@ public class ProxyFluidStorageCell extends ProxyItem implements IStorageFluidCel
@Override
public boolean isBlackListed(ItemStack cellItem, IAEFluidStack requestedAddition) {
// What even is a null fluid
return requestedAddition == null || requestedAddition.getFluid() == null
|| FluidCraftAPI.instance().isBlacklistedInStorage(requestedAddition.getFluid().getClass());
}
@@ -28,8 +28,7 @@ public class ProxyVoidStorageCell extends ItemVoidStorageCell {
@Override
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int p_77663_4_, boolean p_77663_5_) {
if (!worldIn.isRemote && entityIn instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) entityIn;
if (!worldIn.isRemote && entityIn instanceof EntityPlayer player) {
for (int i = 0; i < player.inventory.getSizeInventory(); ++i) {
ItemStack s = player.inventory.getStackInSlot(i);
if (s == stack) {
@@ -73,8 +73,7 @@ public class DriverDualFluidInterface implements SidedBlock {
}
Node node = node().network().node(address);
if (!(node instanceof Component)) throw new IllegalArgumentException("no such component");
if (!(node.host() instanceof Database)) throw new IllegalArgumentException("not a database");
Database database = (Database) node.host();
if (!(node.host() instanceof Database database)) throw new IllegalArgumentException("not a database");
if (index >= 0 && index < DualityFluidInterface.NUMBER_OF_TANKS) {
ItemStack data = database.getStackInSlot(entry - 1);
if (data == null) {
@@ -77,9 +77,8 @@ public class DriverOCPatternEditor extends DriverSidedTileEntity {
if (pattern == null) {
throw new IllegalArgumentException("No pattern here!");
}
if (pattern.getItem() instanceof ItemEncodedPattern
if (pattern.getItem() instanceof ItemEncodedPattern iep
&& !(pattern.getItem() instanceof ItemFluidEncodedPattern)) {
ItemEncodedPattern iep = (ItemEncodedPattern) pattern.getItem();
return iep.getOutput(pattern) == null;
}
return true;
@@ -40,7 +40,7 @@ public class AspectUtil {
}
public static boolean isEssentiaGas(Fluid fluid) {
return fluid != null && fluid instanceof GaseousEssentia;
return fluid instanceof GaseousEssentia;
}
public static boolean isEssentiaGas(FluidStack fluid) {
@@ -35,8 +35,7 @@ public class FCTooltipHandlerWaila extends TooltipHandlerWaila {
+ EnumChatFormatting.RESET);
}
String modName = Util.getFluidModName(fs.getFluid());
if (modName != null && !modName.equals(""))
currenttip.set(currenttip.size() - 1, "\u00a79\u00a7o" + modName);
if (modName != null && !modName.equals("")) currenttip.set(currenttip.size() - 1, "§9§o" + modName);
}
return currenttip;
}
@@ -49,7 +49,7 @@ public class PartWailaDataProvider implements IWailaDataProvider {
ItemStack wailaStack = null;
for (final IPartWailaDataProvider provider : this.providers) {
wailaStack = provider.getWailaStack(part, config, wailaStack);
wailaStack = provider.getWailaStack(part, config, null);
if (wailaStack != null) break;
}
return wailaStack;
@@ -349,7 +349,7 @@ public class AEFluidInventory implements IAEFluidTank {
@Override
public int getCapacity() {
return Math.min(AEFluidInventory.this.capacity, Integer.MAX_VALUE);
return AEFluidInventory.this.capacity;
}
@Override
@@ -82,7 +82,6 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
}
public static InventoryAdaptor wrap(TileEntity capProvider, ForgeDirection face) {
// sometimes i wish 1.7.10 has cap system.
TileEntity inter = capProvider.getWorldObj().getTileEntity(
capProvider.xCoord + face.offsetX,
capProvider.yCoord + face.offsetY,
@@ -376,9 +375,8 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
}
if (tank != null && tank.getTankInfo(direction) != null) {
List<FluidTankInfo[]> tankInfos = new LinkedList<>();
if (Util.getPart(tank, direction) instanceof PartP2PLiquids) {
if (Util.getPart(tank, direction) instanceof PartP2PLiquids invFluidsP2P) {
// read other ends of p2p for blocking mode
PartP2PLiquids invFluidsP2P = (PartP2PLiquids) Util.getPart(tank, direction);
try {
Iterator<PartP2PLiquids> it = invFluidsP2P.getOutputs().iterator();
boolean checkedInput = false;
@@ -22,7 +22,6 @@ public class FluidConvertingInventoryCrafting extends InventoryCrafting {
if (fluid != null) {
super.setInventorySlotContents(index, ItemFluidPacket.newStack(new FluidStack(fluid, stack.stackSize)));
} else {
// wtf?
super.setInventorySlotContents(
index,
ItemFluidPacket.newStack(new FluidStack(FluidRegistry.WATER, 1000)));
@@ -181,10 +181,8 @@ public class MEMonitorIFluidHandler implements IMEMonitor<IAEFluidStack> {
}
public IItemList<IAEFluidStack> getAvailableItems(IItemList out) {
Iterator<?> var2 = this.cache.iterator();
while (var2.hasNext()) {
IAEFluidStack fs = (IAEFluidStack) var2.next();
for (IAEFluidStack fs : this.cache) {
out.addStorage(fs);
}
@@ -30,9 +30,8 @@ public class AEFluidInterfaceHandler implements IExternalStorageHandler {
if (te instanceof ITileStorageMonitorable
&& ((ITileStorageMonitorable) te).getMonitorable(d, src) != null) {
return ((ITileStorageMonitorable) te).getMonitorable(d, src).getFluidInventory();
} else if (Util.getPart(te, d.getOpposite()) instanceof ITileStorageMonitorable
} else if (Util.getPart(te, d.getOpposite()) instanceof ITileStorageMonitorable part
&& ((ITileStorageMonitorable) Util.getPart(te, d.getOpposite())).getMonitorable(d, src) != null) {
ITileStorageMonitorable part = (ITileStorageMonitorable) Util.getPart(te, d.getOpposite());
return part.getMonitorable(d, src).getFluidInventory();
}
}
@@ -27,7 +27,7 @@ import appeng.helpers.IPriorityHost;
public enum GuiType {
RENAMER(new PartOrItemGuiFactory<ITerminalHost>(ITerminalHost.class) {
RENAMER(new PartOrItemGuiFactory<>(ITerminalHost.class) {
@Override
protected Object createServerGui(EntityPlayer player, ITerminalHost inv) {
@@ -39,7 +39,7 @@ public enum GuiType {
return new GuiRenamer(player.inventory, inv);
}
}),
FLUID_AUTO_FILLER(new TileGuiFactory<TileFluidAutoFiller>(TileFluidAutoFiller.class) {
FLUID_AUTO_FILLER(new TileGuiFactory<>(TileFluidAutoFiller.class) {
@Override
protected Object createServerGui(EntityPlayer player, TileFluidAutoFiller inv) {
@@ -52,7 +52,7 @@ public enum GuiType {
}
}),
FLUID_LEVEL_EMITTER(new PartGuiFactory<PartFluidLevelEmitter>(PartFluidLevelEmitter.class) {
FLUID_LEVEL_EMITTER(new PartGuiFactory<>(PartFluidLevelEmitter.class) {
@Override
protected Object createServerGui(EntityPlayer player, PartFluidLevelEmitter inv) {
@@ -65,7 +65,7 @@ public enum GuiType {
}
}),
LEVEL_MAINTAINER(new TileGuiFactory<TileLevelMaintainer>(TileLevelMaintainer.class) {
LEVEL_MAINTAINER(new TileGuiFactory<>(TileLevelMaintainer.class) {
@Override
protected Object createServerGui(EntityPlayer player, TileLevelMaintainer inv) {
@@ -78,7 +78,7 @@ public enum GuiType {
}
}),
OC_PATTERN_EDITOR(new TileGuiFactory<TileOCPatternEditor>(TileOCPatternEditor.class) {
OC_PATTERN_EDITOR(new TileGuiFactory<>(TileOCPatternEditor.class) {
@Override
protected Object createServerGui(EntityPlayer player, TileOCPatternEditor inv) {
@@ -91,7 +91,7 @@ public enum GuiType {
}
}),
DUAL_INTERFACE(new TileOrPartGuiFactory<IInterfaceHost>(IInterfaceHost.class) {
DUAL_INTERFACE(new TileOrPartGuiFactory<>(IInterfaceHost.class) {
@Override
protected Object createServerGui(EntityPlayer player, IInterfaceHost inv) {
@@ -104,7 +104,7 @@ public enum GuiType {
}
}),
DUAL_INTERFACE_FLUID(new TileOrPartGuiFactory<IDualHost>(IDualHost.class) {
DUAL_INTERFACE_FLUID(new TileOrPartGuiFactory<>(IDualHost.class) {
@Override
protected Object createServerGui(EntityPlayer player, IDualHost inv) {
@@ -117,7 +117,7 @@ public enum GuiType {
}
}),
PRIORITY(new TileOrPartGuiFactory<IPriorityHost>(IPriorityHost.class) {
PRIORITY(new TileOrPartGuiFactory<>(IPriorityHost.class) {
@Override
protected Object createServerGui(EntityPlayer player, IPriorityHost inv) {
@@ -130,7 +130,7 @@ public enum GuiType {
}
}),
FLUID_BUS_IO(new PartGuiFactory<FCSharedFluidBus>(FCSharedFluidBus.class) {
FLUID_BUS_IO(new PartGuiFactory<>(FCSharedFluidBus.class) {
@Override
protected Object createServerGui(EntityPlayer player, FCSharedFluidBus inv) {
@@ -143,7 +143,7 @@ public enum GuiType {
}
}),
FLUID_STORAGE_BUS(new PartGuiFactory<PartFluidStorageBus>(PartFluidStorageBus.class) {
FLUID_STORAGE_BUS(new PartGuiFactory<>(PartFluidStorageBus.class) {
@Override
protected Object createServerGui(EntityPlayer player, PartFluidStorageBus inv) {
@@ -156,7 +156,7 @@ public enum GuiType {
}
}),
INGREDIENT_BUFFER(new TileGuiFactory<TileIngredientBuffer>(TileIngredientBuffer.class) {
INGREDIENT_BUFFER(new TileGuiFactory<>(TileIngredientBuffer.class) {
@Override
protected Object createServerGui(EntityPlayer player, TileIngredientBuffer inv) {
@@ -169,7 +169,7 @@ public enum GuiType {
}
}),
LARGE_INGREDIENT_BUFFER(new TileGuiFactory<TileLargeIngredientBuffer>(TileLargeIngredientBuffer.class) {
LARGE_INGREDIENT_BUFFER(new TileGuiFactory<>(TileLargeIngredientBuffer.class) {
@Override
protected Object createServerGui(EntityPlayer player, TileLargeIngredientBuffer inv) {
@@ -182,7 +182,7 @@ public enum GuiType {
}
}),
CRAFTING_STATUS(new PartOrItemGuiFactory<ITerminalHost>(ITerminalHost.class) {
CRAFTING_STATUS(new PartOrItemGuiFactory<>(ITerminalHost.class) {
@Override
protected Object createServerGui(EntityPlayer player, ITerminalHost inv) {
@@ -195,7 +195,7 @@ public enum GuiType {
}
}),
FLUID_TERMINAL(new TileOrPartGuiFactory<ITerminalHost>(ITerminalHost.class) {
FLUID_TERMINAL(new TileOrPartGuiFactory<>(ITerminalHost.class) {
@Override
protected Object createServerGui(EntityPlayer player, ITerminalHost inv) {
@@ -208,7 +208,7 @@ public enum GuiType {
}
}),
PORTABLE_FLUID_CELL(new ItemGuiFactory<IFluidPortableCell>(IFluidPortableCell.class) {
PORTABLE_FLUID_CELL(new ItemGuiFactory<>(IFluidPortableCell.class) {
@Override
protected Object createServerGui(EntityPlayer player, IFluidPortableCell inv) {
@@ -221,7 +221,7 @@ public enum GuiType {
}
}),
WIRELESS_FLUID_TERMINAL(new ItemGuiFactory<IWirelessTerminal>(IWirelessTerminal.class) {
WIRELESS_FLUID_TERMINAL(new ItemGuiFactory<>(IWirelessTerminal.class) {
@Override
protected Object createServerGui(EntityPlayer player, IWirelessTerminal inv) {
@@ -234,7 +234,7 @@ public enum GuiType {
}
}),
WIRELESS_ESSENTIA_TERMINAL(new ItemGuiFactory<IWirelessTerminal>(IWirelessTerminal.class) {
WIRELESS_ESSENTIA_TERMINAL(new ItemGuiFactory<>(IWirelessTerminal.class) {
@Override
protected Object createServerGui(EntityPlayer player, IWirelessTerminal inv) {
@@ -247,7 +247,7 @@ public enum GuiType {
}
}),
WIRELESS_FLUID_PATTERN_TERMINAL(new ItemGuiFactory<IWirelessTerminal>(IWirelessTerminal.class) {
WIRELESS_FLUID_PATTERN_TERMINAL(new ItemGuiFactory<>(IWirelessTerminal.class) {
@Override
protected Object createServerGui(EntityPlayer player, IWirelessTerminal inv) {
@@ -259,7 +259,7 @@ public enum GuiType {
return new GuiFluidPatternWireless(player.inventory, inv);
}
}),
WIRELESS_FLUID_PATTERN_TERMINAL_EX(new ItemGuiFactory<IWirelessTerminal>(IWirelessTerminal.class) {
WIRELESS_FLUID_PATTERN_TERMINAL_EX(new ItemGuiFactory<>(IWirelessTerminal.class) {
@Override
protected Object createServerGui(EntityPlayer player, IWirelessTerminal inv) {
@@ -271,7 +271,7 @@ public enum GuiType {
return new GuiFluidPatternExWireless(player.inventory, inv);
}
}),
WIRELESS_INTERFACE_TERMINAL(new ItemGuiFactory<IWirelessTerminal>(IWirelessTerminal.class) {
WIRELESS_INTERFACE_TERMINAL(new ItemGuiFactory<>(IWirelessTerminal.class) {
@Override
protected Object createServerGui(EntityPlayer player, IWirelessTerminal inv) {
@@ -284,7 +284,7 @@ public enum GuiType {
}
}),
WIRELESS_CRAFTING_TERMINAL(new ItemGuiFactory<IWirelessTerminal>(IWirelessTerminal.class) {
WIRELESS_CRAFTING_TERMINAL(new ItemGuiFactory<>(IWirelessTerminal.class) {
@Override
protected Object createServerGui(EntityPlayer player, IWirelessTerminal inv) {
@@ -297,7 +297,7 @@ public enum GuiType {
}
}),
FLUID_PATTERN_TERMINAL(new PartGuiFactory<ITerminalHost>(ITerminalHost.class) {
FLUID_PATTERN_TERMINAL(new PartGuiFactory<>(ITerminalHost.class) {
@Override
protected Object createServerGui(EntityPlayer player, ITerminalHost inv) {
@@ -310,7 +310,7 @@ public enum GuiType {
}
}),
FLUID_PATTERN_TERMINAL_EX(new PartGuiFactory<ITerminalHost>(ITerminalHost.class) {
FLUID_PATTERN_TERMINAL_EX(new PartGuiFactory<>(ITerminalHost.class) {
@Override
protected Object createServerGui(EntityPlayer player, ITerminalHost inv) {
@@ -323,7 +323,7 @@ public enum GuiType {
}
}),
FLUID_PATTERN_ENCODER(new TileGuiFactory<TileFluidPatternEncoder>(TileFluidPatternEncoder.class) {
FLUID_PATTERN_ENCODER(new TileGuiFactory<>(TileFluidPatternEncoder.class) {
@Override
protected Object createServerGui(EntityPlayer player, TileFluidPatternEncoder inv) {
@@ -336,7 +336,7 @@ public enum GuiType {
}
}),
FLUID_CRAFTING_CONFIRM(new PartGuiFactory<FCPart>(FCPart.class) {
FLUID_CRAFTING_CONFIRM(new PartGuiFactory<>(FCPart.class) {
@Override
protected Object createServerGui(EntityPlayer player, FCPart inv) {
@@ -349,7 +349,7 @@ public enum GuiType {
}
}),
FLUID_CRAFTING_CONFIRM_ITEM(new ItemGuiFactory<IWirelessTerminal>(IWirelessTerminal.class) {
FLUID_CRAFTING_CONFIRM_ITEM(new ItemGuiFactory<>(IWirelessTerminal.class) {
@Override
protected Object createServerGui(EntityPlayer player, IWirelessTerminal inv) {
@@ -362,7 +362,7 @@ public enum GuiType {
}
}),
FLUID_CRAFTING_AMOUNT(new PartOrItemGuiFactory<ITerminalHost>(ITerminalHost.class) {
FLUID_CRAFTING_AMOUNT(new PartOrItemGuiFactory<>(ITerminalHost.class) {
@Override
protected Object createServerGui(EntityPlayer player, ITerminalHost inv) {
@@ -375,7 +375,7 @@ public enum GuiType {
}
}),
FLUID_PACKET_DECODER(new TileGuiFactory<TileFluidPacketDecoder>(TileFluidPacketDecoder.class) {
FLUID_PACKET_DECODER(new TileGuiFactory<>(TileFluidPacketDecoder.class) {
@Override
protected Object createServerGui(EntityPlayer player, TileFluidPacketDecoder inv) {
@@ -388,7 +388,7 @@ public enum GuiType {
}
}),
PATTERN_VALUE_SET(new PartOrItemGuiFactory<ITerminalHost>(ITerminalHost.class) {
PATTERN_VALUE_SET(new PartOrItemGuiFactory<>(ITerminalHost.class) {
@Override
protected Object createServerGui(EntityPlayer player, ITerminalHost inv) {
@@ -177,9 +177,8 @@ public class WirelessPatternTerminalExInventory extends MEMonitorHandler<IAEItem
if (inv == this.pattern && slot == 1) {
final ItemStack is = inv.getStackInSlot(1);
if (is != null && is.getItem() instanceof ICraftingPatternItem) {
final ICraftingPatternItem pattern = (ICraftingPatternItem) is.getItem();
final ICraftingPatternDetails details = pattern
if (is != null && is.getItem() instanceof final ICraftingPatternItem craftingPatternItem) {
final ICraftingPatternDetails details = craftingPatternItem
.getPatternForItem(is, this.getActionableNode().getWorld());
if (details != null) {
@@ -373,8 +372,8 @@ public class WirelessPatternTerminalExInventory extends MEMonitorHandler<IAEItem
@Override
public void sortCraftingItems() {
List<ItemStack> items = new ArrayList<ItemStack>();
List<ItemStack> fluids = new ArrayList<ItemStack>();
List<ItemStack> items = new ArrayList<>();
List<ItemStack> fluids = new ArrayList<>();
for (ItemStack is : this.crafting) {
if (is == null) continue;
if (is.getItem() instanceof ItemFluidPacket) {
@@ -174,9 +174,8 @@ public class WirelessPatternTerminalInventory extends MEMonitorHandler<IAEItemSt
ItemStack newStack) {
if (inv == this.pattern && slot == 1) {
final ItemStack is = inv.getStackInSlot(1);
if (is != null && is.getItem() instanceof ICraftingPatternItem) {
final ICraftingPatternItem pattern = (ICraftingPatternItem) is.getItem();
final ICraftingPatternDetails details = pattern
if (is != null && is.getItem() instanceof final ICraftingPatternItem craftingPatternItem) {
final ICraftingPatternDetails details = craftingPatternItem
.getPatternForItem(is, this.getActionableNode().getWorld());
if (details != null) {
final IAEItemStack[] inItems = details.getInputs();
@@ -345,8 +344,8 @@ public class WirelessPatternTerminalInventory extends MEMonitorHandler<IAEItemSt
@Override
public void sortCraftingItems() {
List<ItemStack> items = new ArrayList<ItemStack>();
List<ItemStack> fluids = new ArrayList<ItemStack>();
List<ItemStack> items = new ArrayList<>();
List<ItemStack> fluids = new ArrayList<>();
for (ItemStack is : this.crafting) {
if (is == null) continue;
if (is.getItem() instanceof ItemFluidPacket) {
@@ -2,7 +2,6 @@ package com.glodblock.github.loader;
import static com.glodblock.github.common.storage.CellType.Cell16384kPart;
import static com.glodblock.github.loader.ItemAndBlockHolder.*;
import static com.glodblock.github.loader.ItemAndBlockHolder.CELL4KM;
import static net.minecraft.init.Blocks.redstone_torch;
import static net.minecraft.init.Items.fish;
@@ -18,10 +18,12 @@ public class FluidFilter {
Item item = ((IAEItemStack) stack).getItem();
if (item != null) {
switch (typeFilter) {
case ITEMS:
case ITEMS -> {
return !(item instanceof ItemFluidDrop);
case FLUIDS:
}
case FLUIDS -> {
return item instanceof ItemFluidDrop;
}
}
}
}
@@ -50,7 +50,7 @@ public class FluidCraftingTransferHandler implements IOverlayHandler {
Slot slot = (Slot) o;
if (slot.getSlotIndex() == col + row * 3) {
final NBTTagList tags = new NBTTagList();
final List<ItemStack> list = new LinkedList<ItemStack>();
final List<ItemStack> list = new LinkedList<>();
// prefer pure crystals.
for (int x = 0; x < positionedStack.items.length; x++) {
if (Platform.isRecipePrioritized(positionedStack.items[x])) {
@@ -41,8 +41,7 @@ public class NEIItemFilter implements SearchField.ISearchProvider {
if (itemStack.getItem() instanceof IStorageFluidCell) {
final IMEInventoryHandler<?> inventory = AEApi.instance().registries().cell()
.getCellInventory(itemStack, null, StorageChannel.FLUIDS);
if (inventory instanceof IFluidCellInventoryHandler) {
final IFluidCellInventoryHandler handler = (IFluidCellInventoryHandler) inventory;
if (inventory instanceof final IFluidCellInventoryHandler handler) {
final IFluidCellInventory cellInventory = handler.getCellInv();
if (cellInventory != null) {
for (IAEFluidStack fluid : cellInventory.getContents()) {
@@ -23,8 +23,7 @@ public class NEIUtils {
if (currentStack.stackSize == 0) continue;
boolean find = false;
for (OrderStack<?> storedStack : comp) {
if (storedStack == null || !(storedStack.getStack() instanceof ItemStack)) continue;
ItemStack firstStack = (ItemStack) storedStack.getStack();
if (storedStack == null || !(storedStack.getStack() instanceof ItemStack firstStack)) continue;
boolean areItemStackEqual = firstStack.isItemEqual(currentStack)
&& ItemStack.areItemStackTagsEqual(firstStack, currentStack);
if (areItemStackEqual
@@ -124,7 +124,7 @@ public class OrderStack<T> {
NBTTagCompound info = buf.getCompoundTag(index + ":");
byte id = info.getByte("t");
switch (id) {
case ITEM:
case ITEM -> {
List<ItemStack> list = new ArrayList<>();
if (info.hasKey(index + ":")) {
NBTTagList items = info.getTagList(index + ":", 10);
@@ -134,13 +134,15 @@ public class OrderStack<T> {
}
}
return new OrderStack<>(ItemStack.loadItemStackFromNBT(info), index, list.toArray(new ItemStack[0]));
case FLUID:
}
case FLUID -> {
return new OrderStack<>(FluidStack.loadFluidStackFromNBT(info), index);
case CUSTOM:
}
case CUSTOM -> {
if (dummy == null) throw new IllegalOrderStackID(id);
return new OrderStack<>(dummy.customNBTReader(buf), index);
default:
throw new IllegalOrderStackID(id);
}
default -> throw new IllegalOrderStackID(id);
}
}
}
@@ -35,8 +35,7 @@ public class EnderIORecipeExtractor implements IRecipeExtractor {
public List<OrderStack<?>> getInputIngredients(List<PositionedStack> rawInputs, IRecipeHandler recipe, int index) {
TemplateRecipeHandler tRecipe = (TemplateRecipeHandler) recipe;
List<OrderStack<?>> tmp;
if (tRecipe.arecipes.get(index) instanceof VatRecipeHandler.InnerVatRecipe) {
VatRecipeHandler.InnerVatRecipe vatRecipe = (VatRecipeHandler.InnerVatRecipe) tRecipe.arecipes.get(index);
if (tRecipe.arecipes.get(index) instanceof VatRecipeHandler.InnerVatRecipe vatRecipe) {
ArrayList<PositionedStack> inputs = ReflectEIO.getInputs(vatRecipe);
tmp = ExtractorUtil.packItemStack(inputs);
FluidStack in = ReflectEIO.getInputFluid(vatRecipe);
@@ -63,8 +62,7 @@ public class EnderIORecipeExtractor implements IRecipeExtractor {
int index) {
TemplateRecipeHandler tRecipe = (TemplateRecipeHandler) recipe;
List<OrderStack<?>> tmp = new LinkedList<>();
if (tRecipe.arecipes.get(index) instanceof VatRecipeHandler.InnerVatRecipe) {
VatRecipeHandler.InnerVatRecipe vatRecipe = (VatRecipeHandler.InnerVatRecipe) tRecipe.arecipes.get(index);
if (tRecipe.arecipes.get(index) instanceof VatRecipeHandler.InnerVatRecipe vatRecipe) {
FluidStack result = ReflectEIO.getResult(vatRecipe);
if (result != null) {
tmp.add(new OrderStack<>(result, 0));
@@ -57,13 +57,10 @@ public class CPacketCraftRequest implements IMessage {
@Nullable
@Override
public IMessage onMessage(CPacketCraftRequest message, MessageContext ctx) {
if (ctx.getServerHandler().playerEntity.openContainer instanceof ContainerCraftAmount) {
if (ctx.getServerHandler().playerEntity.openContainer instanceof final ContainerCraftAmount cca) {
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
final ContainerCraftAmount cca = (ContainerCraftAmount) ctx
.getServerHandler().playerEntity.openContainer;
final Object target = cca.getTarget();
if (target instanceof IGridHost) {
final IGridHost gh = (IGridHost) target;
if (target instanceof final IGridHost gh) {
final IGridNode gn = gh.getGridNode(ForgeDirection.UNKNOWN);
if (gn == null) {
@@ -106,8 +103,7 @@ public class CPacketCraftRequest implements IMessage {
GuiType.FLUID_CRAFTING_CONFIRM_ITEM);
}
if (player.openContainer instanceof ContainerCraftConfirm) {
final ContainerCraftConfirm ccc = (ContainerCraftConfirm) player.openContainer;
if (player.openContainer instanceof final ContainerCraftConfirm ccc) {
ccc.setAutoStart(message.heldShift);
ccc.setJob(futureJob);
cca.detectAndSendChanges();
@@ -64,60 +64,32 @@ public class CPacketFluidPatternTermBtns implements IMessage {
String Name = message.Name;
String Value = message.Value;
final Container c = ctx.getServerHandler().playerEntity.openContainer;
if (Name.startsWith("PatternTerminal.") && (c instanceof FCContainerEncodeTerminal)) {
final FCContainerEncodeTerminal cpt = (FCContainerEncodeTerminal) c;
if (Name.startsWith("PatternTerminal.") && (c instanceof final FCContainerEncodeTerminal cpt)) {
switch (Name) {
case "PatternTerminal.CraftMode":
cpt.getPatternTerminal().setCraftingRecipe(Value.equals("1"));
break;
case "PatternTerminal.Encode":
case "PatternTerminal.CraftMode" -> cpt.getPatternTerminal().setCraftingRecipe(Value.equals("1"));
case "PatternTerminal.Encode" -> {
switch (Value) {
case "0":
cpt.encode();
break;
case "1":
cpt.encodeAndMoveToInventory();
break;
case "3":
cpt.encodeAllItemAndMoveToInventory();
break;
case "0" -> cpt.encode();
case "1" -> cpt.encodeAndMoveToInventory();
case "3" -> cpt.encodeAllItemAndMoveToInventory();
}
break;
case "PatternTerminal.Clear":
cpt.clear();
break;
case "PatternTerminal.Substitute":
cpt.getPatternTerminal().setSubstitution(Value.equals("1"));
break;
case "PatternTerminal.Invert":
cpt.getPatternTerminal().setInverted(Value.equals("1"));
break;
case "PatternTerminal.Double":
cpt.doubleStacks(Value.equals("1"));
break;
case "PatternTerminal.Combine":
cpt.getPatternTerminal().setCombineMode(Value.equals("1"));
break;
case "PatternTerminal.beSubstitute":
cpt.getPatternTerminal().setBeSubstitute(Value.equals("1"));
break;
case "PatternTerminal.ActivePage":
cpt.getPatternTerminal().setActivePage(Integer.parseInt(Value));
break;
case "PatternTerminal.Prioritize":
}
case "PatternTerminal.Clear" -> cpt.clear();
case "PatternTerminal.Substitute" -> cpt.getPatternTerminal().setSubstitution(Value.equals("1"));
case "PatternTerminal.Invert" -> cpt.getPatternTerminal().setInverted(Value.equals("1"));
case "PatternTerminal.Double" -> cpt.doubleStacks(Value.equals("1"));
case "PatternTerminal.Combine" -> cpt.getPatternTerminal().setCombineMode(Value.equals("1"));
case "PatternTerminal.beSubstitute" -> cpt.getPatternTerminal().setBeSubstitute(Value.equals("1"));
case "PatternTerminal.ActivePage" -> cpt.getPatternTerminal()
.setActivePage(Integer.parseInt(Value));
case "PatternTerminal.Prioritize" -> {
switch (Value) {
case "0":
case "1":
cpt.getPatternTerminal().setPrioritization(Value.equals("1"));
break;
case "2":
cpt.getPatternTerminal().sortCraftingItems();
break;
case "0", "1" -> cpt.getPatternTerminal().setPrioritization(Value.equals("1"));
case "2" -> cpt.getPatternTerminal().sortCraftingItems();
}
break;
case "PatternTerminal.AutoFillerPattern":
cpt.getPatternTerminal().setAutoFillPattern(Value.equals("1"));
break;
}
case "PatternTerminal.AutoFillerPattern" -> cpt.getPatternTerminal()
.setAutoFillPattern(Value.equals("1"));
}
cpt.getPatternTerminal().saveSettings();
} else if (Name.startsWith("StorageBus.") && c instanceof ContainerFluidStorageBus) {
@@ -92,8 +92,7 @@ public class CPacketInventoryAction implements IMessage {
@Override
public IMessage onMessage(CPacketInventoryAction message, MessageContext ctx) {
final EntityPlayerMP sender = ctx.getServerHandler().playerEntity;
if (sender.openContainer instanceof AEBaseContainer) {
final AEBaseContainer baseContainer = (AEBaseContainer) sender.openContainer;
if (sender.openContainer instanceof final AEBaseContainer baseContainer) {
Object target = baseContainer.getTarget();
if (message.action == InventoryAction.AUTO_CRAFT) {
final ContainerOpenContext context = baseContainer.getOpenContext();
@@ -117,8 +116,7 @@ public class CPacketInventoryAction implements IMessage {
ForgeDirection.UNKNOWN,
GuiType.FLUID_CRAFTING_AMOUNT);
}
if (sender.openContainer instanceof ContainerCraftAmount) {
final ContainerCraftAmount cca = (ContainerCraftAmount) sender.openContainer;
if (sender.openContainer instanceof final ContainerCraftAmount cca) {
if (baseContainer.getTargetStack() != null) {
cca.getCraftingItem().putStack(baseContainer.getTargetStack().getItemStack());
cca.setItemToCraft(baseContainer.getTargetStack());
@@ -154,8 +152,7 @@ public class CPacketInventoryAction implements IMessage {
amt = fluid == null ? 1 : fluid.amount;
}
FluidCraft.proxy.netHandler.sendTo(new SPacketSetItemAmount(amt), sender);
if (sender.openContainer instanceof ContainerPatternValueAmount) {
final ContainerPatternValueAmount cpv = (ContainerPatternValueAmount) sender.openContainer;
if (sender.openContainer instanceof final ContainerPatternValueAmount cpv) {
if (baseContainer.getTargetStack() != null) {
cpv.setValueIndex(message.slot);
cpv.getPatternValue().putStack(baseContainer.getTargetStack().getItemStack());
@@ -116,23 +116,14 @@ public class CPacketLevelMaintainer implements IMessage {
@Override
public IMessage onMessage(CPacketLevelMaintainer message, MessageContext ctx) {
if (message.action.startsWith("TileLevelMaintainer.")
&& ctx.getServerHandler().playerEntity.openContainer instanceof ContainerLevelMaintainer) {
&& ctx.getServerHandler().playerEntity.openContainer instanceof final ContainerLevelMaintainer cca) {
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
final ContainerLevelMaintainer cca = (ContainerLevelMaintainer) ctx
.getServerHandler().playerEntity.openContainer;
switch (message.action) {
case "TileLevelMaintainer.Quantity":
cca.getTile().updateQuantity(message.slotIndex, message.size);
break;
case "TileLevelMaintainer.Batch":
cca.getTile().updateBatchSize(message.slotIndex, message.size);
break;
case "TileLevelMaintainer.Enable":
cca.getTile().setRequestStatus(message.slotIndex, false);
break;
case "TileLevelMaintainer.Disable":
cca.getTile().setRequestStatus(message.slotIndex, true);
break;
case "TileLevelMaintainer.Quantity" -> cca.getTile()
.updateQuantity(message.slotIndex, message.size);
case "TileLevelMaintainer.Batch" -> cca.getTile().updateBatchSize(message.slotIndex, message.size);
case "TileLevelMaintainer.Enable" -> cca.getTile().setRequestStatus(message.slotIndex, false);
case "TileLevelMaintainer.Disable" -> cca.getTile().setRequestStatus(message.slotIndex, true);
}
this.refresh(cca, player);
}
@@ -61,8 +61,7 @@ public class CPacketPatternValueSet implements IMessage {
@Override
public IMessage onMessage(CPacketPatternValueSet message, MessageContext ctx) {
EntityPlayer player = ctx.getServerHandler().playerEntity;
if (player.openContainer instanceof ContainerPatternValueAmount) {
ContainerPatternValueAmount cpv = (ContainerPatternValueAmount) player.openContainer;
if (player.openContainer instanceof ContainerPatternValueAmount cpv) {
final Object target = cpv.getTarget();
if (target instanceof IGridHost) {
final ContainerOpenContext context = cpv.getOpenContext();
@@ -48,7 +48,7 @@ public class CPacketTransferRecipe implements IMessage {
this.shift = shift;
}
// I should use GZIP to compress the message, but i'm too lazy.
// TODO: this should use GZIP to compress the message
// NBT to ByteBuf has a compress stream
@Override
public void toBytes(ByteBuf buf) {
@@ -100,9 +100,8 @@ public class CPacketTransferRecipe implements IMessage {
if (monitor != null) {
storageList = monitor.getStorageList();
}
if (c instanceof FCContainerEncodeTerminal) {
if (c instanceof FCContainerEncodeTerminal cf) {
// pattern terminal only
FCContainerEncodeTerminal cf = (FCContainerEncodeTerminal) c;
boolean combine = cf.combine;
cf.getPatternTerminal().setCraftingRecipe(message.isCraft);
@@ -91,7 +91,6 @@ public class SPacketMEItemInvUpdate implements IMessage {
public static class Handler implements IMessageHandler<SPacketMEItemInvUpdate, IMessage> {
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public IMessage onMessage(SPacketMEItemInvUpdate message, MessageContext ctx) {
final GuiScreen gs = Minecraft.getMinecraft().currentScreen;
if (gs instanceof GuiItemMonitor) {
@@ -83,6 +83,8 @@ public class Ae2Reflect {
for (String name : names) {
try {
f = owner.getDeclaredField(name);
// IntelliJ misses that the exception is ignored and thus "f" can indeed be null.
// noinspection ConstantValue
if (f != null) break;
} catch (NoSuchFieldException ignore) {}
}
@@ -69,8 +69,7 @@ public class BlockPos {
@Override
public boolean equals(Object obj) {
if (obj instanceof BlockPos) {
BlockPos pos = (BlockPos) obj;
if (obj instanceof BlockPos pos) {
return pos.x == x && pos.y == y && pos.z == z && Objects.equals(pos.w, w);
}
return false;
@@ -301,7 +301,7 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
toStore.setStackSize(-toStore.getStackSize());
FluidStack canExtract = this.tanks.drain(slot, toStore.getFluidStack(), false);
if (canExtract != null && (long) canExtract.amount == toStore.getStackSize()) {
IAEFluidStack notStored = dest.injectItems(toStore, Actionable.MODULATE, this.mySource);;
IAEFluidStack notStored = dest.injectItems(toStore, Actionable.MODULATE, this.mySource);
toStore.setStackSize(toStore.getStackSize() - (notStored == null ? 0L : notStored.getStackSize()));
if (toStore.getStackSize() > 0L) {
changed = true;
@@ -141,7 +141,7 @@ public class FluidPatternDetails implements ICraftingPatternDetails, Comparable<
@Override
public boolean equals(Object obj) {
// ae2 null-checks the pattern stack here for some reason, but doesn't null-check in hashCode()
// this is inconsistent, so i've just decided to assert non-null in the constructor, which is to say that
// this is inconsistent, so I've just decided to assert non-null in the constructor, which is to say that
// the pattern stack can never be null here
return obj instanceof FluidPatternDetails && patternStackAe.equals(((FluidPatternDetails) obj).patternStackAe);
}
@@ -16,7 +16,7 @@ import appeng.util.Platform;
public class FluidSorters {
private static SortDir Direction = SortDir.ASCENDING;
public static final Comparator<IAEItemStack> CONFIG_BASED_SORT_BY_MOD = new Comparator<IAEItemStack>() {
public static final Comparator<IAEItemStack> CONFIG_BASED_SORT_BY_MOD = new Comparator<>() {
@Override
public int compare(final IAEItemStack o1, final IAEItemStack o2) {
@@ -44,18 +44,14 @@ public class FluidSorters {
}
return Platform.getItemDisplayName(o2).compareToIgnoreCase(Platform.getItemDisplayName(o1));
};
public static final Comparator<IAEItemStack> CONFIG_BASED_SORT_BY_SIZE = new Comparator<IAEItemStack>() {
@Override
public int compare(final IAEItemStack o1, final IAEItemStack o2) {
if (getDirection() == SortDir.ASCENDING) {
return compareLong(o2.getStackSize(), o1.getStackSize());
}
return compareLong(o1.getStackSize(), o2.getStackSize());
public static final Comparator<IAEItemStack> CONFIG_BASED_SORT_BY_SIZE = (o1, o2) -> {
if (getDirection() == SortDir.ASCENDING) {
return compareLong(o2.getStackSize(), o1.getStackSize());
}
return compareLong(o1.getStackSize(), o2.getStackSize());
};
private static IInvTweaks api;
public static final Comparator<IAEItemStack> CONFIG_BASED_SORT_BY_INV_TWEAKS = new Comparator<IAEItemStack>() {
public static final Comparator<IAEItemStack> CONFIG_BASED_SORT_BY_INV_TWEAKS = new Comparator<>() {
@Override
public int compare(final IAEItemStack o1, final IAEItemStack o2) {
@@ -23,9 +23,8 @@ public class ObjectArrayIterator<E> implements /* Resettable */ Iterator<E> {
/** The end index to loop to */
final int endIndex;
/** The current iterator index */
int index = 0;
int index;
// -------------------------------------------------------------------------
/**
* Constructs an ObjectArrayIterator that will iterate over the values in the specified array.
*
@@ -46,7 +45,7 @@ public class ObjectArrayIterator<E> implements /* Resettable */ Iterator<E> {
* @throws NullPointerException if <code>array</code> is <code>null</code>
* @throws IndexOutOfBoundsException if the start index is out of bounds
*/
public ObjectArrayIterator(final E array[], final int start) {
public ObjectArrayIterator(final E[] array, final int start) {
this(array, start, array.length);
}
@@ -60,7 +59,7 @@ public class ObjectArrayIterator<E> implements /* Resettable */ Iterator<E> {
* @throws IllegalArgumentException if end index is before the start
* @throws NullPointerException if <code>array</code> is <code>null</code>
*/
public ObjectArrayIterator(final E array[], final int start, final int end) {
public ObjectArrayIterator(final E[] array, final int start, final int end) {
super();
if (start < 0) {
throw new ArrayIndexOutOfBoundsException("Start index must not be less than zero");
@@ -80,8 +79,7 @@ public class ObjectArrayIterator<E> implements /* Resettable */ Iterator<E> {
this.index = start;
}
// Iterator interface
// -------------------------------------------------------------------------
// region Iterator interface
/**
* Returns true if there are more elements to return from the array.
@@ -101,7 +99,7 @@ public class ObjectArrayIterator<E> implements /* Resettable */ Iterator<E> {
*/
@Override
public E next() {
if (hasNext() == false) {
if (!hasNext()) {
throw new NoSuchElementException();
}
return this.array[this.index++];
@@ -116,9 +114,9 @@ public class ObjectArrayIterator<E> implements /* Resettable */ Iterator<E> {
public void remove() {
throw new UnsupportedOperationException("remove() method is not supported for an ObjectArrayIterator");
}
// endregion
// Properties
// -------------------------------------------------------------------------
// region Properties
/**
* Gets the array that this iterator is iterating over.
@@ -147,6 +145,8 @@ public class ObjectArrayIterator<E> implements /* Resettable */ Iterator<E> {
return this.endIndex;
}
// endregion
/**
* Resets the iterator back to the start index.
*/
@@ -300,7 +300,6 @@ public final class Util {
}
public static IAEFluidStack loadFluidStackFromNBT(final NBTTagCompound i) {
// Fuck ae2
final FluidStack t = FluidRegistry.getFluidStack(i.getString("FluidName"), 1);
if (t == null) return null;
final AEFluidStack fluid = AEFluidStack.create(t);
@@ -503,8 +502,7 @@ public final class Util {
public static int getCapacity(ItemStack itemStack, Fluid fluid) {
if (itemStack == null) return 0;
Item item = itemStack.getItem();
if (item instanceof IFluidContainerItem) {
IFluidContainerItem fluidContainerItem = (IFluidContainerItem) item;
if (item instanceof IFluidContainerItem fluidContainerItem) {
int capacity = fluidContainerItem.getCapacity(itemStack);
FluidStack existing = fluidContainerItem.getFluid(itemStack);
if (existing != null) {