From 84481c22d7d4e0834de97a150d257ce6e85ad690 Mon Sep 17 00:00:00 2001 From: Raven Szewczyk Date: Sat, 25 May 2024 14:05:54 +0100 Subject: Update spotless to the GT5u version --- .../blocks/tileEntity/YottaFluidTank.java | 318 ++++++++++++--------- 1 file changed, 177 insertions(+), 141 deletions(-) (limited to 'src/main/java/goodgenerator/blocks/tileEntity/YottaFluidTank.java') diff --git a/src/main/java/goodgenerator/blocks/tileEntity/YottaFluidTank.java b/src/main/java/goodgenerator/blocks/tileEntity/YottaFluidTank.java index ca5d44fd32..f712fa12a7 100644 --- a/src/main/java/goodgenerator/blocks/tileEntity/YottaFluidTank.java +++ b/src/main/java/goodgenerator/blocks/tileEntity/YottaFluidTank.java @@ -62,14 +62,14 @@ import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; public class YottaFluidTank extends GT_MetaTileEntity_TooltipMultiBlockBase_EM - implements IConstructable, ISurvivalConstructable { + implements IConstructable, ISurvivalConstructable { private static final IIconContainer textureFontOn = new Textures.BlockIcons.CustomIcon("iconsets/OVERLAY_QTANK"); private static final IIconContainer textureFontOn_Glow = new Textures.BlockIcons.CustomIcon( - "iconsets/OVERLAY_QTANK_GLOW"); + "iconsets/OVERLAY_QTANK_GLOW"); private static final IIconContainer textureFontOff = new Textures.BlockIcons.CustomIcon("iconsets/OVERLAY_QCHEST"); private static final IIconContainer textureFontOff_Glow = new Textures.BlockIcons.CustomIcon( - "iconsets/OVERLAY_QCHEST_GLOW"); + "iconsets/OVERLAY_QCHEST_GLOW"); protected IStructureDefinition multiDefinition = null; protected final ArrayList mYottaHatch = new ArrayList<>(); @@ -158,8 +158,16 @@ public class YottaFluidTank extends GT_MetaTileEntity_TooltipMultiBlockBase_EM public void saveNBTData(NBTTagCompound aNBT) { aNBT.setString("mStorage", mStorage.toString(10)); aNBT.setString("mStorageCurrent", mStorageCurrent.toString(10)); - aNBT.setString("mFluidName", mFluid == null ? "" : mFluid.getFluid().getName()); - aNBT.setString("mLockedFluidName", mLockedFluid == null ? "" : mLockedFluid.getFluid().getName()); + aNBT.setString( + "mFluidName", + mFluid == null ? "" + : mFluid.getFluid() + .getName()); + aNBT.setString( + "mLockedFluidName", + mLockedFluid == null ? "" + : mLockedFluid.getFluid() + .getName()); aNBT.setBoolean("voidExcessEnabled", voidExcessEnabled); aNBT.setBoolean("isFluidLocked", isFluidLocked); super.saveNBTData(aNBT); @@ -277,45 +285,50 @@ public class YottaFluidTank extends GT_MetaTileEntity_TooltipMultiBlockBase_EM public IStructureDefinition getStructure_EM() { if (multiDefinition == null) { multiDefinition = StructureDefinition.builder() - .addShape( - YOTTANK_BOTTOM, - transpose( - new String[][] { { "MM~MM", "MCCCM", "MCCCM", "MCCCM", "MMMMM" }, - { " ", " OOO ", " OOO ", " OOO ", " " } })) - .addShape( - YOTTANK_MID, - transpose(new String[][] { { "GGGGG", "GRRRG", "GRRRG", "GRRRG", "GGGGG" } })) - .addShape( - YOTTANK_TOP, - transpose( - new String[][] { { "FFFFF", "F F", "F F", "F F", "FFFFF" }, - { "CCCCC", "CIIIC", "CIIIC", "CIIIC", "CCCCC" } })) - .addElement('C', ofBlock(Loaders.yottaFluidTankCasing, 0)) - .addElement( - 'G', - withChannel( - "glass", - BorosilicateGlass.ofBoroGlass( - (byte) 0, - (byte) 1, - Byte.MAX_VALUE, - YottaFluidTank::setMeta, - te -> (byte) te.getMeta()))) - .addElement('R', ofChain(cells(10))).addElement('F', ofFrame(Materials.Steel)) - .addElement( - 'I', - buildHatchAdder(YottaFluidTank.class).atLeast(GT_HatchElement.InputHatch).casingIndex(1537) - .dot(1).buildAndChain(Loaders.yottaFluidTankCasing, 0)) - .addElement( - 'M', - buildHatchAdder(YottaFluidTank.class).atLeast(GT_HatchElement.Maintenance).casingIndex(1537) - .dot(2).buildAndChain(Loaders.yottaFluidTankCasing, 0)) - .addElement( - 'O', - buildHatchAdder(YottaFluidTank.class).atLeast(GT_HatchElement.OutputHatch) - .adder(YottaFluidTank::addOutput).casingIndex(1537).dot(1) - .buildAndChain(Loaders.yottaFluidTankCasing, 0)) - .build(); + .addShape( + YOTTANK_BOTTOM, + transpose( + new String[][] { { "MM~MM", "MCCCM", "MCCCM", "MCCCM", "MMMMM" }, + { " ", " OOO ", " OOO ", " OOO ", " " } })) + .addShape(YOTTANK_MID, transpose(new String[][] { { "GGGGG", "GRRRG", "GRRRG", "GRRRG", "GGGGG" } })) + .addShape( + YOTTANK_TOP, + transpose( + new String[][] { { "FFFFF", "F F", "F F", "F F", "FFFFF" }, + { "CCCCC", "CIIIC", "CIIIC", "CIIIC", "CCCCC" } })) + .addElement('C', ofBlock(Loaders.yottaFluidTankCasing, 0)) + .addElement( + 'G', + withChannel( + "glass", + BorosilicateGlass.ofBoroGlass( + (byte) 0, + (byte) 1, + Byte.MAX_VALUE, + YottaFluidTank::setMeta, + te -> (byte) te.getMeta()))) + .addElement('R', ofChain(cells(10))) + .addElement('F', ofFrame(Materials.Steel)) + .addElement( + 'I', + buildHatchAdder(YottaFluidTank.class).atLeast(GT_HatchElement.InputHatch) + .casingIndex(1537) + .dot(1) + .buildAndChain(Loaders.yottaFluidTankCasing, 0)) + .addElement( + 'M', + buildHatchAdder(YottaFluidTank.class).atLeast(GT_HatchElement.Maintenance) + .casingIndex(1537) + .dot(2) + .buildAndChain(Loaders.yottaFluidTankCasing, 0)) + .addElement( + 'O', + buildHatchAdder(YottaFluidTank.class).atLeast(GT_HatchElement.OutputHatch) + .adder(YottaFluidTank::addOutput) + .casingIndex(1537) + .dot(1) + .buildAndChain(Loaders.yottaFluidTankCasing, 0)) + .build(); } return multiDefinition; } @@ -357,51 +370,60 @@ public class YottaFluidTank extends GT_MetaTileEntity_TooltipMultiBlockBase_EM @Override public String[] getInfoData() { - return new String[] { StatCollector.translateToLocal("scanner.info.YOTTank.1"), StatCollector.translateToLocal( + return new String[] { StatCollector.translateToLocal("scanner.info.YOTTank.1"), + StatCollector.translateToLocal( EnumChatFormatting.YELLOW + CharExchanger.formatNumber(getFluidName() + EnumChatFormatting.RESET)), - StatCollector.translateToLocal("scanner.info.YOTTank.0"), - StatCollector.translateToLocal( - EnumChatFormatting.GREEN + CharExchanger.formatNumber(getCap()) - + EnumChatFormatting.RESET - + " L"), - - StatCollector.translateToLocal("scanner.info.YOTTank.2"), - StatCollector.translateToLocal( - EnumChatFormatting.GREEN + CharExchanger.formatNumber(getStored()) - + EnumChatFormatting.RESET - + " L" - + " (" - + EnumChatFormatting.GREEN - + getPercent() - + "%" - + EnumChatFormatting.RESET - + ")"), - - StatCollector.translateToLocal("scanner.info.YOTTank.3"), - StatCollector.translateToLocal( - EnumChatFormatting.YELLOW + CharExchanger.formatNumber(getLockedFluidName()) - + EnumChatFormatting.RESET) }; + StatCollector.translateToLocal("scanner.info.YOTTank.0"), + StatCollector.translateToLocal( + EnumChatFormatting.GREEN + CharExchanger.formatNumber(getCap()) + EnumChatFormatting.RESET + " L"), + + StatCollector.translateToLocal("scanner.info.YOTTank.2"), + StatCollector.translateToLocal( + EnumChatFormatting.GREEN + CharExchanger.formatNumber(getStored()) + + EnumChatFormatting.RESET + + " L" + + " (" + + EnumChatFormatting.GREEN + + getPercent() + + "%" + + EnumChatFormatting.RESET + + ")"), + + StatCollector.translateToLocal("scanner.info.YOTTank.3"), + StatCollector.translateToLocal( + EnumChatFormatting.YELLOW + CharExchanger.formatNumber(getLockedFluidName()) + + EnumChatFormatting.RESET) }; } private String getPercent() { if (mStorage.signum() == 0) return "0"; - return mStorageCurrent.multiply(ONE_HUNDRED).divide(mStorage).toString(); + return mStorageCurrent.multiply(ONE_HUNDRED) + .divide(mStorage) + .toString(); } @Override protected GT_Multiblock_Tooltip_Builder createTooltip() { final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType("Fluid Tank").addInfo("Controller block for the YOTTank.").addInfo( - "The max output speed is decided by the amount of stored liquid and the output hatch's capacity.") - .addInfo("The max fluid cell tier is limited by the glass tier.") - .addInfo("HV glass for T1, EV glass for T2, IV glass for T3. . .") - .addInfo("The max height of the cell blocks is 15.").addInfo("The structure is too complex!") - .addInfo(BLUE_PRINT_INFO).addSeparator().beginVariableStructureBlock(5, 5, 1, 15, 5, 5, false) - .addController("Front of the second layer").addCasingInfoExactly("Steel Frame Box", 16, false) - .addCasingInfoRange("Glass (HV+)", 16, 240, true).addCasingInfoRange("Fluid Cell Block", 9, 135, true) - .addCasingInfoRange("YOTTank Casing", 25, 43, false).addInputHatch("Hint block with dot 1") - .addOutputHatch("Hint block with dot 3").toolTipFinisher("Good Generator"); + tt.addMachineType("Fluid Tank") + .addInfo("Controller block for the YOTTank.") + .addInfo("The max output speed is decided by the amount of stored liquid and the output hatch's capacity.") + .addInfo("The max fluid cell tier is limited by the glass tier.") + .addInfo("HV glass for T1, EV glass for T2, IV glass for T3. . .") + .addInfo("The max height of the cell blocks is 15.") + .addInfo("The structure is too complex!") + .addInfo(BLUE_PRINT_INFO) + .addSeparator() + .beginVariableStructureBlock(5, 5, 1, 15, 5, 5, false) + .addController("Front of the second layer") + .addCasingInfoExactly("Steel Frame Box", 16, false) + .addCasingInfoRange("Glass (HV+)", 16, 240, true) + .addCasingInfoRange("Fluid Cell Block", 9, 135, true) + .addCasingInfoRange("YOTTank Casing", 25, 43, false) + .addInputHatch("Hint block with dot 1") + .addOutputHatch("Hint block with dot 3") + .toolTipFinisher("Good Generator"); return tt; } @@ -425,7 +447,8 @@ public class YottaFluidTank extends GT_MetaTileEntity_TooltipMultiBlockBase_EM @Override public boolean onRunningTick(ItemStack aStack) { super.onRunningTick(aStack); - if (this.getBaseMetaTileEntity().isServerSide()) { + if (this.getBaseMetaTileEntity() + .isServerSide()) { ++workTickCounter; if (workTickCounter < 20) { return true; @@ -468,7 +491,10 @@ public class YottaFluidTank extends GT_MetaTileEntity_TooltipMultiBlockBase_EM if (mFluid != null) { // Try to drain 1% of the tank per tick, so 20% per second aka 1/5 - int outputAmount = mStorageCurrent.divide(FIVE).min(MAX_INT_BIGINT).max(BigInteger.ONE).intValueExact(); + int outputAmount = mStorageCurrent.divide(FIVE) + .min(MAX_INT_BIGINT) + .max(BigInteger.ONE) + .intValueExact(); final int originalOutputAmount = outputAmount; for (final GT_MetaTileEntity_Hatch outputHatch : mOutputHatches) { @@ -500,7 +526,7 @@ public class YottaFluidTank extends GT_MetaTileEntity_TooltipMultiBlockBase_EM mStorageCurrent = mStorageCurrent.subtract(BigInteger.valueOf(totalDrainedAmount)); if (mStorageCurrent.signum() < 0) { throw new IllegalStateException( - "YOTTank drained beyond its fluid amount, indicating logic bug: " + mStorageCurrent); + "YOTTank drained beyond its fluid amount, indicating logic bug: " + mStorageCurrent); } } } @@ -522,12 +548,12 @@ public class YottaFluidTank extends GT_MetaTileEntity_TooltipMultiBlockBase_EM @Override public boolean onSolderingToolRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer aPlayer, - float aX, float aY, float aZ, ItemStack toolStack) { + float aX, float aY, float aZ, ItemStack toolStack) { if (side == getBaseMetaTileEntity().getFrontFacing()) { voidExcessEnabled ^= true; aPlayer.addChatMessage( - new ChatComponentTranslation( - voidExcessEnabled ? "yottank.chat.voidExcessEnabled" : "yottank.chat.voidExcessDisabled")); + new ChatComponentTranslation( + voidExcessEnabled ? "yottank.chat.voidExcessEnabled" : "yottank.chat.voidExcessDisabled")); return true; } return false; @@ -535,7 +561,7 @@ public class YottaFluidTank extends GT_MetaTileEntity_TooltipMultiBlockBase_EM @Override public boolean onWireCutterRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer aPlayer, - float aX, float aY, float aZ, ItemStack toolStack) { + float aX, float aY, float aZ, ItemStack toolStack) { if (side == getBaseMetaTileEntity().getFrontFacing()) { if (mLockedFluid == null) { if (mFluid != null) { @@ -567,14 +593,18 @@ public class YottaFluidTank extends GT_MetaTileEntity_TooltipMultiBlockBase_EM @Override public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, - int colorIndex, boolean aActive, boolean aRedstone) { + int colorIndex, boolean aActive, boolean aRedstone) { if (side == facing) { if (aActive) return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(1537), - TextureFactory.of(textureFontOn), - TextureFactory.builder().addIcon(textureFontOn_Glow).glow().build() }; + TextureFactory.of(textureFontOn), TextureFactory.builder() + .addIcon(textureFontOn_Glow) + .glow() + .build() }; else return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(1537), - TextureFactory.of(textureFontOff), - TextureFactory.builder().addIcon(textureFontOff_Glow).glow().build() }; + TextureFactory.of(textureFontOff), TextureFactory.builder() + .addIcon(textureFontOff_Glow) + .glow() + .build() }; } else return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(1537) }; } @@ -603,39 +633,36 @@ public class YottaFluidTank extends GT_MetaTileEntity_TooltipMultiBlockBase_EM super.drawTexts(screenElements, inventorySlot); screenElements - .widget( - new TextWidget() - .setStringSupplier( - () -> StatCollector.translateToLocal("gui.YOTTank.0") + " " - + numberFormat.format(mStorage) - + " L") - .setDefaultColor(COLOR_TEXT_WHITE.get()) - .setEnabled(widget -> getBaseMetaTileEntity().getErrorDisplayID() == 0)) - .widget(new FakeSyncWidget.BigIntegerSyncer(() -> mStorage, val -> mStorage = val)) - .widget( - new TextWidget() - .setStringSupplier( - () -> StatCollector.translateToLocal("gui.YOTTank.1") + " " + getFluidName()) - .setDefaultColor(COLOR_TEXT_WHITE.get()) - .setEnabled(widget -> getBaseMetaTileEntity().getErrorDisplayID() == 0)) - .widget(new FakeSyncWidget.FluidStackSyncer(() -> mFluid, val -> mFluid = val)) - .widget( - new TextWidget() - .setStringSupplier( - () -> StatCollector.translateToLocal("gui.YOTTank.2") + " " - + numberFormat.format(mStorageCurrent) - + " L") - .setDefaultColor(COLOR_TEXT_WHITE.get()) - .setEnabled(widget -> getBaseMetaTileEntity().getErrorDisplayID() == 0)) - .widget(new FakeSyncWidget.BigIntegerSyncer(() -> mStorageCurrent, val -> mStorageCurrent = val)) - .widget( - new TextWidget().setStringSupplier( - () -> StatCollector.translateToLocal("gui.YOTTank.3") + " " + getLockedFluidName()) - .setDefaultColor(COLOR_TEXT_WHITE.get()) - .setEnabled(widget -> getBaseMetaTileEntity().getErrorDisplayID() == 0)) - .widget(new FakeSyncWidget.FluidStackSyncer(() -> mLockedFluid, val -> mLockedFluid = val)) - .widget(new FakeSyncWidget.BooleanSyncer(() -> isFluidLocked, val -> isFluidLocked = val)) - .widget(new FakeSyncWidget.BooleanSyncer(() -> voidExcessEnabled, val -> voidExcessEnabled = val)); + .widget( + new TextWidget().setStringSupplier( + () -> StatCollector.translateToLocal("gui.YOTTank.0") + " " + numberFormat.format(mStorage) + " L") + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setEnabled(widget -> getBaseMetaTileEntity().getErrorDisplayID() == 0)) + .widget(new FakeSyncWidget.BigIntegerSyncer(() -> mStorage, val -> mStorage = val)) + .widget( + new TextWidget() + .setStringSupplier(() -> StatCollector.translateToLocal("gui.YOTTank.1") + " " + getFluidName()) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setEnabled(widget -> getBaseMetaTileEntity().getErrorDisplayID() == 0)) + .widget(new FakeSyncWidget.FluidStackSyncer(() -> mFluid, val -> mFluid = val)) + .widget( + new TextWidget() + .setStringSupplier( + () -> StatCollector.translateToLocal("gui.YOTTank.2") + " " + + numberFormat.format(mStorageCurrent) + + " L") + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setEnabled(widget -> getBaseMetaTileEntity().getErrorDisplayID() == 0)) + .widget(new FakeSyncWidget.BigIntegerSyncer(() -> mStorageCurrent, val -> mStorageCurrent = val)) + .widget( + new TextWidget() + .setStringSupplier( + () -> StatCollector.translateToLocal("gui.YOTTank.3") + " " + getLockedFluidName()) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setEnabled(widget -> getBaseMetaTileEntity().getErrorDisplayID() == 0)) + .widget(new FakeSyncWidget.FluidStackSyncer(() -> mLockedFluid, val -> mLockedFluid = val)) + .widget(new FakeSyncWidget.BooleanSyncer(() -> isFluidLocked, val -> isFluidLocked = val)) + .widget(new FakeSyncWidget.BooleanSyncer(() -> voidExcessEnabled, val -> voidExcessEnabled = val)); } @Override @@ -643,16 +670,20 @@ public class YottaFluidTank extends GT_MetaTileEntity_TooltipMultiBlockBase_EM return (ButtonWidget) new ButtonWidget().setOnClick((clickData, widget) -> { TecTech.proxy.playSound(getBaseMetaTileEntity(), "fx_click"); voidExcessEnabled = !voidExcessEnabled; - }).setPlayClickSound(false).setBackground(() -> { - List ret = new ArrayList<>(); - ret.add(TecTechUITextures.BUTTON_STANDARD_16x16); - ret.add( + }) + .setPlayClickSound(false) + .setBackground(() -> { + List ret = new ArrayList<>(); + ret.add(TecTechUITextures.BUTTON_STANDARD_16x16); + ret.add( voidExcessEnabled ? TecTechUITextures.OVERLAY_BUTTON_SAFE_VOID_ON - : TecTechUITextures.OVERLAY_BUTTON_SAFE_VOID_OFF); - return ret.toArray(new IDrawable[0]); - }).setPos(174, doesBindPlayerInventory() ? 132 : 156).setSize(16, 16) - .addTooltip(StatCollector.translateToLocal("gui.YOTTank.button.void")) - .setTooltipShowUpDelay(TOOLTIP_DELAY); + : TecTechUITextures.OVERLAY_BUTTON_SAFE_VOID_OFF); + return ret.toArray(new IDrawable[0]); + }) + .setPos(174, doesBindPlayerInventory() ? 132 : 156) + .setSize(16, 16) + .addTooltip(StatCollector.translateToLocal("gui.YOTTank.button.void")) + .setTooltipShowUpDelay(TOOLTIP_DELAY); } @Override @@ -660,14 +691,19 @@ public class YottaFluidTank extends GT_MetaTileEntity_TooltipMultiBlockBase_EM return (ButtonWidget) new ButtonWidget().setOnClick((clickData, widget) -> { TecTech.proxy.playSound(getBaseMetaTileEntity(), "fx_click"); isFluidLocked = !isFluidLocked; - if (!widget.getContext().isClient()) mLockedFluid = isFluidLocked ? mFluid : null; - }).setPlayClickSound(false).setBackground(() -> { - List ret = new ArrayList<>(); - ret.add(TecTechUITextures.BUTTON_STANDARD_16x16); - ret.add(isFluidLocked ? GG_UITextures.OVERLAY_BUTTON_LOCK_ON : GG_UITextures.OVERLAY_BUTTON_LOCK_OFF); - return ret.toArray(new IDrawable[0]); - }).setPos(174, doesBindPlayerInventory() ? 116 : 140).setSize(16, 16) - .addTooltip(StatCollector.translateToLocal("gui.YOTTank.button.locking")) - .setTooltipShowUpDelay(TOOLTIP_DELAY); + if (!widget.getContext() + .isClient()) mLockedFluid = isFluidLocked ? mFluid : null; + }) + .setPlayClickSound(false) + .setBackground(() -> { + List ret = new ArrayList<>(); + ret.add(TecTechUITextures.BUTTON_STANDARD_16x16); + ret.add(isFluidLocked ? GG_UITextures.OVERLAY_BUTTON_LOCK_ON : GG_UITextures.OVERLAY_BUTTON_LOCK_OFF); + return ret.toArray(new IDrawable[0]); + }) + .setPos(174, doesBindPlayerInventory() ? 116 : 140) + .setSize(16, 16) + .addTooltip(StatCollector.translateToLocal("gui.YOTTank.button.locking")) + .setTooltipShowUpDelay(TOOLTIP_DELAY); } } -- cgit