From 1db6c276a851852695df908daf019db421f9ad41 Mon Sep 17 00:00:00 2001 From: Emanuel Ferraz Date: Tue, 7 Nov 2023 13:50:28 +0000 Subject: [PATCH] Run spotless --- src/main/java/vazkii/psi/api/PsiAPI.java | 24 +- .../vazkii/psi/api/cad/AssembleCADEvent.java | 2 +- src/main/java/vazkii/psi/api/cad/ICAD.java | 2 +- .../java/vazkii/psi/api/cad/ISocketable.java | 14 +- .../vazkii/psi/api/cad/RegenPsiEvent.java | 18 +- .../vazkii/psi/api/exosuit/PsiArmorEvent.java | 4 +- .../vazkii/psi/api/internal/MathHelper.java | 12 +- .../java/vazkii/psi/api/internal/Quat.java | 2 +- .../psi/api/internal/TooltipHelper.java | 4 +- .../api/internal/VanillaPacketDispatcher.java | 10 +- .../java/vazkii/psi/api/internal/Vector3.java | 12 +- .../vazkii/psi/api/internal/math/Gamma.java | 29 +- .../api/inventory/InventorySocketable.java | 20 +- .../psi/api/inventory/IteratorSocketable.java | 2 +- .../psi/api/recipe/TrickRecipeBuilder.java | 6 +- .../vazkii/psi/api/spell/CompiledSpell.java | 26 +- src/main/java/vazkii/psi/api/spell/Spell.java | 16 +- .../vazkii/psi/api/spell/SpellContext.java | 22 +- .../java/vazkii/psi/api/spell/SpellGrid.java | 80 +++--- .../vazkii/psi/api/spell/SpellHelpers.java | 22 +- .../vazkii/psi/api/spell/SpellMetadata.java | 14 +- .../java/vazkii/psi/api/spell/SpellParam.java | 4 +- .../java/vazkii/psi/api/spell/SpellPiece.java | 82 +++--- .../java/vazkii/psi/api/spell/StatLabel.java | 6 +- .../spell/detonator/IDetonationHandler.java | 10 +- .../api/spell/piece/PieceCraftingTrick.java | 2 +- .../psi/api/spell/piece/PieceTrick.java | 4 +- .../api/spell/wrapper/EntityListWrapper.java | 18 +- .../client/core/handler/BookSoundHandler.java | 10 +- .../core/handler/ClientTickHandler.java | 12 +- .../psi/client/core/handler/ColorHandler.java | 6 +- .../psi/client/core/handler/HUDHandler.java | 60 ++-- .../client/core/handler/KeybindHandler.java | 17 +- .../client/core/handler/ShaderHandler.java | 28 +- .../psi/client/core/helper/SharingHelper.java | 2 +- .../psi/client/core/helper/TextHelper.java | 18 +- .../psi/client/core/proxy/ClientProxy.java | 10 +- .../java/vazkii/psi/client/fx/FXSparkle.java | 6 +- .../java/vazkii/psi/client/fx/FXWisp.java | 4 +- .../psi/client/gui/GuiCADAssembler.java | 8 +- .../vazkii/psi/client/gui/GuiProgrammer.java | 262 +++++++++--------- .../psi/client/gui/GuiSocketSelect.java | 76 ++--- .../psi/client/gui/button/GuiButtonHelp.java | 6 +- .../psi/client/gui/button/GuiButtonIO.java | 4 +- .../psi/client/gui/button/GuiButtonPage.java | 4 +- .../gui/button/GuiButtonSideConfig.java | 12 +- .../gui/button/GuiButtonSpellPiece.java | 4 +- .../client/gui/widget/PiecePanelWidget.java | 120 ++++---- .../client/gui/widget/SideConfigWidget.java | 14 +- .../client/gui/widget/SpellCostsWidget.java | 10 +- .../psi/client/gui/widget/StatusWidget.java | 10 +- .../java/vazkii/psi/client/jei/JEICompat.java | 2 +- .../psi/client/jei/tricks/DrawablePiece.java | 8 +- .../jei/tricks/TrickCraftingCategory.java | 28 +- .../vazkii/psi/client/model/ArmorModels.java | 4 +- .../vazkii/psi/client/model/ModelArmor.java | 4 +- .../vazkii/psi/client/model/ModelCAD.java | 2 +- .../patchouli/MultiCraftingProcessor.java | 28 +- .../psi/client/patchouli/PatchouliUtils.java | 10 +- .../client/patchouli/SpellGridComponent.java | 10 +- .../client/patchouli/SpellPieceComponent.java | 2 +- .../render/entity/RenderSpellCircle.java | 22 +- .../render/tile/RenderTileProgrammer.java | 6 +- src/main/java/vazkii/psi/common/Psi.java | 2 +- .../psi/common/block/BlockCADAssembler.java | 16 +- .../psi/common/block/BlockConjured.java | 10 +- .../psi/common/block/BlockProgrammer.java | 39 +-- .../base/DirectionBlockItemUseContext.java | 2 +- .../common/block/tile/TileCADAssembler.java | 52 ++-- .../psi/common/block/tile/TileConjured.java | 24 +- .../psi/common/block/tile/TileProgrammer.java | 6 +- .../tile/container/ContainerCADAssembler.java | 44 +-- .../tile/container/slot/SlotCADOutput.java | 6 +- .../capability/CapabilityTriggerSensor.java | 2 +- .../core/handler/AdditiveMotionHandler.java | 16 +- .../ContributorSpellCircleHandler.java | 8 +- .../core/handler/CrashReportHandler.java | 4 +- .../core/handler/InternalMethodHandler.java | 4 +- .../core/handler/LoopcastTrackingHandler.java | 2 +- .../core/handler/PlayerDataHandler.java | 212 +++++++------- .../core/handler/capability/CADData.java | 32 +-- .../handler/capability/CapabilityHandler.java | 10 +- .../core/handler/capability/SocketWheel.java | 4 +- .../psi/common/core/proxy/ServerProxy.java | 2 +- .../recipe/AssemblyScavengeRecipe.java | 18 +- .../crafting/recipe/BulletToDriveRecipe.java | 22 +- .../crafting/recipe/BulletUpgradeRecipe.java | 4 +- .../recipe/ColorizerChangeRecipe.java | 28 +- .../crafting/recipe/DriveDuplicateRecipe.java | 22 +- .../crafting/recipe/SensorAttachRecipe.java | 18 +- .../crafting/recipe/SensorRemoveRecipe.java | 14 +- .../common/crafting/recipe/TrickRecipe.java | 6 +- .../psi/common/entity/EntitySpellCircle.java | 22 +- .../psi/common/entity/EntitySpellGrenade.java | 18 +- .../psi/common/entity/EntitySpellMine.java | 8 +- .../common/entity/EntitySpellProjectile.java | 34 +-- .../java/vazkii/psi/common/item/ItemCAD.java | 112 ++++---- .../common/item/ItemCircleSpellBullet.java | 2 +- .../vazkii/psi/common/item/ItemDetonator.java | 2 +- .../common/item/ItemExosuitController.java | 12 +- .../common/item/ItemLoopcastSpellBullet.java | 4 +- .../psi/common/item/ItemSpellBullet.java | 12 +- .../psi/common/item/ItemSpellDrive.java | 24 +- .../psi/common/item/ItemVectorRuler.java | 8 +- .../common/item/armor/ItemPsimetalArmor.java | 10 +- .../item/armor/ItemPsimetalExosuitHelmet.java | 6 +- .../common/item/component/DefaultStats.java | 4 +- .../item/component/ItemCADColorizerPsi.java | 2 +- .../item/component/ItemCADComponent.java | 10 +- .../psi/common/item/tool/IPsimetalTool.java | 10 +- .../psi/common/item/tool/ItemPsimetalAxe.java | 10 +- .../common/item/tool/ItemPsimetalPickaxe.java | 10 +- .../common/item/tool/ItemPsimetalShovel.java | 10 +- .../common/item/tool/ItemPsimetalSword.java | 12 +- .../psi/common/item/tool/ToolSocketable.java | 10 +- .../message/MessageAdditiveMotion.java | 4 +- .../common/network/message/MessageBlink.java | 2 +- .../network/message/MessageCADDataSync.java | 2 +- .../message/MessageChangeControllerSlot.java | 4 +- .../message/MessageChangeSocketableSlot.java | 4 +- .../network/message/MessageDataSync.java | 2 +- .../network/message/MessageDeductPsi.java | 2 +- .../network/message/MessageEidosSync.java | 2 +- .../network/message/MessageLoopcastSync.java | 8 +- .../network/message/MessageParticleTrail.java | 2 +- .../network/message/MessageSpellModified.java | 6 +- .../network/message/MessageVisualEffect.java | 6 +- .../vazkii/psi/common/spell/SpellCache.java | 2 +- .../psi/common/spell/SpellCompiler.java | 56 ++-- .../spell/constant/PieceConstantNumber.java | 36 +-- .../spell/constant/PieceConstantWrapper.java | 6 +- .../PieceOperatorBlockComparatorStrength.java | 2 +- .../block/PieceOperatorBlockMiningLevel.java | 2 +- .../entity/PieceOperatorClosestToLine.java | 14 +- .../entity/PieceOperatorClosestToPoint.java | 6 +- .../entity/PieceOperatorEntityAxialLook.java | 2 +- .../entity/PieceOperatorEntityHealth.java | 2 +- .../entity/PieceOperatorEntityHeight.java | 2 +- .../entity/PieceOperatorEntityLook.java | 4 +- .../entity/PieceOperatorEntityMotion.java | 8 +- .../entity/PieceOperatorEntityPosition.java | 4 +- .../entity/PieceOperatorEntityRaycast.java | 14 +- .../entity/PieceOperatorFocusedEntity.java | 22 +- .../operator/entity/PieceOperatorListAdd.java | 2 +- .../entity/PieceOperatorListRemove.java | 2 +- .../entity/PieceOperatorRandomEntity.java | 2 +- .../operator/list/PieceOperatorListIndex.java | 2 +- .../operator/number/PieceOperatorDivide.java | 2 +- .../number/PieceOperatorGammaFunc.java | 2 +- .../number/PieceOperatorIntegerDivide.java | 4 +- .../operator/number/PieceOperatorInverse.java | 2 +- .../operator/number/PieceOperatorLog.java | 6 +- .../operator/number/PieceOperatorMax.java | 2 +- .../operator/number/PieceOperatorMin.java | 2 +- .../operator/number/PieceOperatorModulus.java | 2 +- .../number/PieceOperatorMultiply.java | 2 +- .../operator/number/PieceOperatorRandom.java | 2 +- .../operator/number/PieceOperatorRoot.java | 2 +- .../number/PieceOperatorSquareRoot.java | 2 +- .../number/PieceOperatorSubtract.java | 2 +- .../operator/number/PieceOperatorSum.java | 2 +- .../number/trig/PieceOperatorAcos.java | 2 +- .../number/trig/PieceOperatorAsin.java | 2 +- .../vector/PieceOperatorVectorConstruct.java | 6 +- .../vector/PieceOperatorVectorDivide.java | 2 +- .../vector/PieceOperatorVectorRaycast.java | 4 +- .../PieceOperatorVectorRaycastAxis.java | 4 +- .../vector/PieceOperatorVectorSubtract.java | 2 +- .../vector/PieceOperatorVectorSum.java | 2 +- .../common/spell/other/PieceConnector.java | 16 +- .../spell/other/PieceCrossConnector.java | 8 +- .../selector/PieceSelectorAttackTarget.java | 2 +- .../spell/selector/PieceSelectorAttacker.java | 2 +- .../selector/PieceSelectorBlockBroken.java | 2 +- .../selector/PieceSelectorBlockPresence.java | 6 +- .../PieceSelectorBlockSideBroken.java | 4 +- .../selector/PieceSelectorEidosChangelog.java | 4 +- .../selector/PieceSelectorSavedVector.java | 6 +- .../spell/selector/PieceSelectorTickTime.java | 4 +- .../spell/selector/PieceSelectorTime.java | 2 +- .../entity/PieceSelectorCasterBattery.java | 2 +- .../selector/entity/PieceSelectorNearby.java | 4 +- .../entity/PieceSelectorNearbySmeltables.java | 2 +- .../entity/PieceSelectorSuccessCounter.java | 2 +- .../common/spell/trick/PieceTrickBlaze.java | 10 +- .../spell/trick/PieceTrickBreakLoop.java | 8 +- .../common/spell/trick/PieceTrickDebug.java | 4 +- .../spell/trick/PieceTrickDebugSpamless.java | 6 +- .../common/spell/trick/PieceTrickDelay.java | 2 +- .../spell/trick/PieceTrickDetonate.java | 4 +- .../psi/common/spell/trick/PieceTrickDie.java | 2 +- .../spell/trick/PieceTrickEidosAnchor.java | 2 +- .../spell/trick/PieceTrickEidosReversal.java | 6 +- .../common/spell/trick/PieceTrickExplode.java | 6 +- .../spell/trick/PieceTrickOvergrow.java | 2 +- .../spell/trick/PieceTrickParticleTrail.java | 4 +- .../spell/trick/PieceTrickPlaySound.java | 4 +- .../trick/PieceTrickRussianRoulette.java | 2 +- .../spell/trick/PieceTrickSaveVector.java | 6 +- .../common/spell/trick/PieceTrickSmite.java | 8 +- .../spell/trick/PieceTrickSpinChamber.java | 8 +- .../trick/PieceTrickSwitchTargetSlot.java | 6 +- .../common/spell/trick/PieceTrickTorrent.java | 18 +- .../trick/block/PieceTrickBreakBlock.java | 26 +- .../block/PieceTrickBreakInSequence.java | 8 +- .../trick/block/PieceTrickCollapseBlock.java | 10 +- .../PieceTrickCollapseBlockSequence.java | 16 +- .../trick/block/PieceTrickConjureBlock.java | 18 +- .../block/PieceTrickConjureBlockSequence.java | 10 +- .../trick/block/PieceTrickMoveBlock.java | 16 +- .../block/PieceTrickMoveBlockSequence.java | 30 +- .../trick/block/PieceTrickPlaceBlock.java | 32 +-- .../block/PieceTrickPlaceInSequence.java | 10 +- .../trick/block/PieceTrickSmeltBlock.java | 14 +- .../block/PieceTrickSmeltBlockSequence.java | 18 +- .../spell/trick/block/PieceTrickTill.java | 2 +- .../trick/block/PieceTrickTillSequence.java | 4 +- .../trick/entity/PieceTrickAddMotion.java | 14 +- .../spell/trick/entity/PieceTrickBlink.java | 6 +- .../spell/trick/entity/PieceTrickIgnite.java | 2 +- .../trick/entity/PieceTrickMassAddMotion.java | 4 +- .../trick/entity/PieceTrickMassBlink.java | 4 +- .../trick/entity/PieceTrickMassExodus.java | 4 +- .../trick/entity/PieceTrickSmeltItem.java | 6 +- .../trick/potion/PieceTrickPotionBase.java | 12 +- .../java/vazkii/psi/data/DataGenerator.java | 11 +- .../vazkii/psi/data/PsiBlockTagProvider.java | 1 + .../vazkii/psi/data/PsiItemTagProvider.java | 3 +- .../vazkii/psi/data/PsiRecipeGenerator.java | 2 +- .../java/vazkii/psi/data/WrapperResult.java | 4 +- 230 files changed, 1518 insertions(+), 1512 deletions(-) diff --git a/src/main/java/vazkii/psi/api/PsiAPI.java b/src/main/java/vazkii/psi/api/PsiAPI.java index 48f59fd92..93d58ff89 100644 --- a/src/main/java/vazkii/psi/api/PsiAPI.java +++ b/src/main/java/vazkii/psi/api/PsiAPI.java @@ -116,8 +116,8 @@ public static void addPieceToGroup(Class clazz, ResourceLo advancementGroups.put(resLoc, clazz); advancementGroupsInverse.put(clazz, resLoc); - if (main) { - if (mainPieceForGroup.containsKey(resLoc)) { + if(main) { + if(mainPieceForGroup.containsKey(resLoc)) { LogManager.getLogger(MOD_ID).info("Group " + resLoc + " already has a main piece!"); } mainPieceForGroup.put(resLoc, clazz); @@ -129,15 +129,15 @@ public static void addPieceToGroup(Class clazz, ResourceLo * more than one, this will return null. */ public static ItemStack getPlayerCAD(Player player) { - if (player == null) { + if(player == null) { return ItemStack.EMPTY; } ItemStack cad = ItemStack.EMPTY; - for (int i = 0; i < player.getInventory().getContainerSize(); i++) { + for(int i = 0; i < player.getInventory().getContainerSize(); i++) { ItemStack stackAt = player.getInventory().getItem(i); - if (!stackAt.isEmpty() && stackAt.getItem() instanceof ICAD) { - if (!cad.isEmpty()) { + if(!stackAt.isEmpty() && stackAt.getItem() instanceof ICAD) { + if(!cad.isEmpty()) { return ItemStack.EMPTY; // Player can only have one CAD } @@ -149,15 +149,15 @@ public static ItemStack getPlayerCAD(Player player) { } public static int getPlayerCADSlot(Player player) { - if (player == null) { + if(player == null) { return -1; } int slot = -1; - for (int i = 0; i < player.getInventory().getContainerSize(); i++) { + for(int i = 0; i < player.getInventory().getContainerSize(); i++) { ItemStack stackAt = player.getInventory().getItem(i); - if (!stackAt.isEmpty() && stackAt.getItem() instanceof ICAD) { - if (slot != -1) { + if(!stackAt.isEmpty() && stackAt.getItem() instanceof ICAD) { + if(slot != -1) { return -1; // Player can only have one CAD } @@ -169,11 +169,11 @@ public static int getPlayerCADSlot(Player player) { } public static boolean canCADBeUpdated(Player player) { - if (player == null) { + if(player == null) { return false; } - if (player.containerMenu == null) { + if(player.containerMenu == null) { return true; } diff --git a/src/main/java/vazkii/psi/api/cad/AssembleCADEvent.java b/src/main/java/vazkii/psi/api/cad/AssembleCADEvent.java index 4ed698179..2ac2e2872 100644 --- a/src/main/java/vazkii/psi/api/cad/AssembleCADEvent.java +++ b/src/main/java/vazkii/psi/api/cad/AssembleCADEvent.java @@ -48,7 +48,7 @@ public ItemStack getCad() { } public void setCad(ItemStack cad) { - if (!cad.isEmpty() && !(cad.getItem() instanceof ICAD)) { + if(!cad.isEmpty() && !(cad.getItem() instanceof ICAD)) { throw new IllegalStateException("Only a CAD can be crafted by the CAD Assembler!"); } this.cad = cad; diff --git a/src/main/java/vazkii/psi/api/cad/ICAD.java b/src/main/java/vazkii/psi/api/cad/ICAD.java index 335906c3b..298a01a88 100644 --- a/src/main/java/vazkii/psi/api/cad/ICAD.java +++ b/src/main/java/vazkii/psi/api/cad/ICAD.java @@ -31,7 +31,7 @@ public interface ICAD { */ static void setComponent(ItemStack stack, ItemStack componentStack) { - if (!componentStack.isEmpty() && componentStack.getItem() instanceof ICADComponent) { + if(!componentStack.isEmpty() && componentStack.getItem() instanceof ICADComponent) { ICADComponent component = (ICADComponent) componentStack.getItem(); EnumCADComponent componentType = component.getComponentType(componentStack); String name = TAG_COMPONENT_PREFIX + componentType.name(); diff --git a/src/main/java/vazkii/psi/api/cad/ISocketable.java b/src/main/java/vazkii/psi/api/cad/ISocketable.java index 252dd005c..241cac622 100644 --- a/src/main/java/vazkii/psi/api/cad/ISocketable.java +++ b/src/main/java/vazkii/psi/api/cad/ISocketable.java @@ -44,13 +44,13 @@ public interface ISocketable { int MAX_ASSEMBLER_SLOTS = 12; static Component getSocketedItemName(ItemStack stack, String fallbackKey) { - if (stack.isEmpty() || !isSocketable(stack)) { + if(stack.isEmpty() || !isSocketable(stack)) { return Component.translatable(fallbackKey); } ISocketable socketable = socketable(stack); ItemStack item = socketable.getSelectedBullet(); - if (item.isEmpty()) { + if(item.isEmpty()) { return Component.translatable(fallbackKey); } @@ -69,8 +69,8 @@ static ISocketable socketable(ItemStack stack) { default List getRadialMenuSlots() { List list = new ArrayList<>(); - for (int i = 0; i < MAX_ASSEMBLER_SLOTS; i++) { - if (isSocketSlotAvailable(i)) { + for(int i = 0; i < MAX_ASSEMBLER_SLOTS; i++) { + if(isSocketSlotAvailable(i)) { list.add(i); } } @@ -91,7 +91,7 @@ default List getRadialMenuIcons() { default int getLastSlot() { int slot = 0; - while (isSocketSlotAvailable(slot + 1)) { + while(isSocketSlotAvailable(slot + 1)) { slot++; } return slot; @@ -102,11 +102,11 @@ default ItemStack getSelectedBullet() { } default boolean isItemValid(int slot, ItemStack bullet) { - if (!isSocketSlotAvailable(slot)) { + if(!isSocketSlotAvailable(slot)) { return false; } - if (!ISpellAcceptor.isContainer(bullet)) { + if(!ISpellAcceptor.isContainer(bullet)) { return false; } diff --git a/src/main/java/vazkii/psi/api/cad/RegenPsiEvent.java b/src/main/java/vazkii/psi/api/cad/RegenPsiEvent.java index f55b2eb5c..bfdfd8619 100644 --- a/src/main/java/vazkii/psi/api/cad/RegenPsiEvent.java +++ b/src/main/java/vazkii/psi/api/cad/RegenPsiEvent.java @@ -60,7 +60,7 @@ public RegenPsiEvent(Player player, IPlayerData playerData, ItemStack cad) { this.previousRegenCooldown = playerData.getRegenCooldown(); this.regenCooldown = Math.max(0, this.previousRegenCooldown - 1); - if (!cad.isEmpty()) { + if(!cad.isEmpty()) { ICAD cadItem = (ICAD) cad.getItem(); this.cadPsiCapacity = cadItem.getStatValue(cad, EnumCADStat.OVERFLOW); this.cadPsi = cadItem.getStoredPsi(cad); @@ -264,7 +264,7 @@ public void regenCadFirst(boolean regenCadFirst) { } private void applyRegen() { - if (regenCooldown != 0) { + if(regenCooldown != 0) { return; } @@ -274,22 +274,22 @@ private void applyRegen() { int regenLeft = regenRate; - if (regenCadFirst) { + if(regenCadFirst) { regenLeft = applyCadRegen(regenLeft); } regenLeft = applyPlayerRegen(regenLeft); - if (!regenCadFirst) { + if(!regenCadFirst) { applyCadRegen(regenLeft); } } private int applyPlayerRegen(int regenLeft) { int playerRegenTotal = Math.min(playerPsiCapacity - playerPsi, regenLeft); - if (maxPlayerRegen >= 0) { + if(maxPlayerRegen >= 0) { playerRegenTotal = Math.min(maxPlayerRegen, playerRegenTotal); } - if (regenLeft > 0 && playerRegenTotal > 0) { + if(regenLeft > 0 && playerRegenTotal > 0) { playerRegen = playerRegenTotal; regenLeft -= playerRegenTotal; } else { @@ -297,7 +297,7 @@ private int applyPlayerRegen(int regenLeft) { } healOverflow = regenLeft > 0; - if (healOverflow && wasOverflowed) { + if(healOverflow && wasOverflowed) { regenLeft--; } @@ -306,13 +306,13 @@ private int applyPlayerRegen(int regenLeft) { private int applyCadRegen(int regenLeft) { int cadRegenTotal = cadPsiCapacity - cadPsi; - if (maxCadRegen >= 0) { + if(maxCadRegen >= 0) { cadRegenTotal = Math.min(maxCadRegen, cadRegenTotal); } cadRegenCost = Math.min(regenLeft, cadRegenTotal * 2); - if (cadRegenCost > 0) { + if(cadRegenCost > 0) { cadRegen = Math.min(Math.max(1, cadRegenCost / 2), cadRegenTotal); regenLeft -= cadRegenCost; } else { diff --git a/src/main/java/vazkii/psi/api/exosuit/PsiArmorEvent.java b/src/main/java/vazkii/psi/api/exosuit/PsiArmorEvent.java index 61545b69c..0922be970 100644 --- a/src/main/java/vazkii/psi/api/exosuit/PsiArmorEvent.java +++ b/src/main/java/vazkii/psi/api/exosuit/PsiArmorEvent.java @@ -44,13 +44,13 @@ public PsiArmorEvent(Player player, String type, double damage, LivingEntity att this.damage = damage; this.attacker = attacker; - if (type.equals(NONE)) { + if(type.equals(NONE)) { throw new IllegalArgumentException("Can't you read?"); } } public static void post(PsiArmorEvent event) { - if (!posting) { + if(!posting) { posting = true; MinecraftForge.EVENT_BUS.post(event); posting = false; diff --git a/src/main/java/vazkii/psi/api/internal/MathHelper.java b/src/main/java/vazkii/psi/api/internal/MathHelper.java index 5437865be..0b329d5cf 100644 --- a/src/main/java/vazkii/psi/api/internal/MathHelper.java +++ b/src/main/java/vazkii/psi/api/internal/MathHelper.java @@ -33,10 +33,10 @@ public static LinkedHashSet getBlocksAlongRay(Vec3 origin, Vec3 end) { */ public static LinkedHashSet getBlocksAlongRay(Vec3 origin, Vec3 end, int maxBlocks) { LinkedHashSet positions = new LinkedHashSet<>(); - if (maxBlocks == 0) { + if(maxBlocks == 0) { return positions; } - if (origin.equals(end)) { + if(origin.equals(end)) { positions.add(new BlockPos(origin.x, origin.y, origin.z)); } else { double endX = end.x; @@ -63,16 +63,16 @@ public static LinkedHashSet getBlocksAlongRay(Vec3 origin, Vec3 end, i double totalStepsY = stepSizeY * (signumY > 0 ? 1.0D - net.minecraft.util.Mth.frac(originY) : net.minecraft.util.Mth.frac(originY)); double totalStepsZ = stepSizeZ * (signumZ > 0 ? 1.0D - net.minecraft.util.Mth.frac(originZ) : net.minecraft.util.Mth.frac(originZ)); - while ((totalStepsX <= 1.0D || totalStepsY <= 1.0D || totalStepsZ <= 1.0D) && positions.size() != maxBlocks) { - if (totalStepsX < totalStepsY) { - if (totalStepsX < totalStepsZ) { + while((totalStepsX <= 1.0D || totalStepsY <= 1.0D || totalStepsZ <= 1.0D) && positions.size() != maxBlocks) { + if(totalStepsX < totalStepsY) { + if(totalStepsX < totalStepsZ) { blockX += signumX; totalStepsX += stepSizeX; } else { blockZ += signumZ; totalStepsZ += stepSizeZ; } - } else if (totalStepsY < totalStepsZ) { + } else if(totalStepsY < totalStepsZ) { blockY += signumY; totalStepsY += stepSizeY; } else { diff --git a/src/main/java/vazkii/psi/api/internal/Quat.java b/src/main/java/vazkii/psi/api/internal/Quat.java index 645934505..c57407d83 100644 --- a/src/main/java/vazkii/psi/api/internal/Quat.java +++ b/src/main/java/vazkii/psi/api/internal/Quat.java @@ -80,7 +80,7 @@ public double mag() { public void normalize() { double d = mag(); - if (d == 0.0D) {} else { + if(d == 0.0D) {} else { d = 1.0D / d; x *= d; y *= d; diff --git a/src/main/java/vazkii/psi/api/internal/TooltipHelper.java b/src/main/java/vazkii/psi/api/internal/TooltipHelper.java index 55c1ab28c..de8369a3a 100644 --- a/src/main/java/vazkii/psi/api/internal/TooltipHelper.java +++ b/src/main/java/vazkii/psi/api/internal/TooltipHelper.java @@ -19,7 +19,7 @@ public final class TooltipHelper { @OnlyIn(Dist.CLIENT) public static void tooltipIfShift(List tooltip, Runnable r) { - if (Screen.hasShiftDown()) { + if(Screen.hasShiftDown()) { r.run(); } else { tooltip.add(Component.translatable("psimisc.shift_for_info")); @@ -28,7 +28,7 @@ public static void tooltipIfShift(List tooltip, Runnable r) { @OnlyIn(Dist.CLIENT) public static void tooltipIfCtrl(List tooltip, Runnable r) { - if (Screen.hasControlDown()) { + if(Screen.hasControlDown()) { r.run(); } else { tooltip.add(Component.translatable("psimisc.ctrl_for_stats")); diff --git a/src/main/java/vazkii/psi/api/internal/VanillaPacketDispatcher.java b/src/main/java/vazkii/psi/api/internal/VanillaPacketDispatcher.java index 93a754935..39cf07298 100644 --- a/src/main/java/vazkii/psi/api/internal/VanillaPacketDispatcher.java +++ b/src/main/java/vazkii/psi/api/internal/VanillaPacketDispatcher.java @@ -20,10 +20,10 @@ public final class VanillaPacketDispatcher { public static void dispatchTEToNearbyPlayers(BlockEntity tile) { Level world = tile.getLevel(); - for (Player player : world.players()) { - if (player instanceof ServerPlayer) { + for(Player player : world.players()) { + if(player instanceof ServerPlayer) { ServerPlayer mp = (ServerPlayer) player; - if (MathHelper.pointDistancePlane(mp.getX(), mp.getZ(), tile.getBlockPos().getX() + 0.5, tile.getBlockPos().getZ() + 0.5) < 64) { + if(MathHelper.pointDistancePlane(mp.getX(), mp.getZ(), tile.getBlockPos().getX() + 0.5, tile.getBlockPos().getZ() + 0.5) < 64) { dispatchTEToPlayer(tile, mp); } } @@ -32,14 +32,14 @@ public static void dispatchTEToNearbyPlayers(BlockEntity tile) { public static void dispatchTEToNearbyPlayers(Level world, BlockPos pos) { BlockEntity tile = world.getBlockEntity(pos); - if (tile != null) { + if(tile != null) { dispatchTEToNearbyPlayers(tile); } } public static void dispatchTEToPlayer(BlockEntity tile, ServerPlayer p) { Packet packet = tile.getUpdatePacket(); - if (packet != null) { + if(packet != null) { p.connection.send(packet); } } diff --git a/src/main/java/vazkii/psi/api/internal/Vector3.java b/src/main/java/vazkii/psi/api/internal/Vector3.java index ca8be9a0f..29754bc43 100644 --- a/src/main/java/vazkii/psi/api/internal/Vector3.java +++ b/src/main/java/vazkii/psi/api/internal/Vector3.java @@ -108,9 +108,9 @@ public Vector3 set(Vector3 vec) { public double dotProduct(Vector3 vec) { double d = vec.x * x + vec.y * y + vec.z * z; - if (d > 1 && d < 1.00001) { + if(d > 1 && d < 1.00001) { d = 1; - } else if (d < -1 && d > -1.00001) { + } else if(d < -1 && d > -1.00001) { d = -1; } return d; @@ -197,7 +197,7 @@ public double magSquared() { public Vector3 normalize() { double d = mag(); - if (d != 0) { + if(d != 0) { multiply(1 / d); } @@ -211,7 +211,7 @@ public String toString() { } public Vector3 perpendicular() { - if (z == 0) { + if(z == 0) { return zCrossProduct(); } return xCrossProduct(); @@ -288,7 +288,7 @@ public double scalarProject(Vector3 b) { public Vector3 project(Vector3 b) { double l = b.magSquared(); - if (l == 0) { + if(l == 0) { set(0, 0, 0); return this; } @@ -305,7 +305,7 @@ public Vector3 rotate(double angle, Vector3 axis) { @Override public boolean equals(Object o) { - if (!(o instanceof Vector3)) { + if(!(o instanceof Vector3)) { return false; } diff --git a/src/main/java/vazkii/psi/api/internal/math/Gamma.java b/src/main/java/vazkii/psi/api/internal/math/Gamma.java index 188b19554..9dda7f432 100644 --- a/src/main/java/vazkii/psi/api/internal/math/Gamma.java +++ b/src/main/java/vazkii/psi/api/internal/math/Gamma.java @@ -1,19 +1,18 @@ package vazkii.psi.api.internal.math; -//https://hewgill.com/picomath/java/Gamma.java.html +// https://hewgill.com/picomath/java/Gamma.java.html public class Gamma { // Visit http://www.johndcook.com/stand_alone_code.html for the source of this code and more like it. // Note that the functions Gamma and LogGamma are mutually dependent. - /** * * @param x must be greater than 0 * @return */ public static double gamma(double x) { - if (x <= 0.0) { + if(x <= 0.0) { String msg = String.format("Invalid input argument {0}. Argument must be positive.", x); throw new IllegalArgumentException(msg); } @@ -23,7 +22,6 @@ public static double gamma(double x) { * (0, 0.001), [0.001, 12), and (12, infinity) */ - /* * First interval: (0, 0.001) * For small x, 1/Gamma(x) has power series x + gamma x^2 - ... @@ -31,10 +29,9 @@ public static double gamma(double x) { * The relative error over this interval is less than 6e-7. */ - final double gamma = 0.577215664901532860606512090; // Euler's gamma constant - if (x < 0.001) { + if(x < 0.001) { return 1.0 / (x * (1.0 + gamma * x)); } @@ -42,7 +39,7 @@ public static double gamma(double x) { * Second interval: [0.001, 12) */ - if (x < 12.0) { + if(x < 12.0) { /* * The algorithm directly approximates gamma over (1,2) and @@ -58,10 +55,10 @@ public static double gamma(double x) { * Will correct for this below */ - if (arg_was_less_than_one) { + if(arg_was_less_than_one) { y += 1.0; } else { - n = (int)(Math.floor(y)) - 1; // will use n later + n = (int) (Math.floor(y)) - 1; // will use n later y -= n; } @@ -94,14 +91,14 @@ public static double gamma(double x) { int i; double z = y - 1; - for (i = 0; i < 8; i++) { + for(i = 0; i < 8; i++) { num = (num + p[i]) * z; den = den * z + q[i]; } double result = num / den + 1.0; // Apply correction if argument was not initially in (1,2) - if (arg_was_less_than_one) { + if(arg_was_less_than_one) { /* * Use identity gamma(z) = gamma(z+1)/z * The variable "result" now holds gamma of the original y + 1 @@ -110,7 +107,7 @@ public static double gamma(double x) { result /= (y - 1.0); } else { // Use the identity gamma(z+n) = z*(z+1)* ... *(z+n-1)*gamma(z) - for (i = 0; i < n; i++) { + for(i = 0; i < n; i++) { result *= y++; } } @@ -122,7 +119,7 @@ public static double gamma(double x) { * Third interval: [12, infinity) */ - if (x > 171.624) { + if(x > 171.624) { // Correct answer too large to display. return Double.POSITIVE_INFINITY; } @@ -136,12 +133,12 @@ public static double gamma(double x) { * @return */ public static double logGamma(double x) { - if (x <= 0.0) { + if(x <= 0.0) { String msg = String.format("Invalid input argument {0}. Argument must be positive.", x); throw new IllegalArgumentException(msg); } - if (x < 12.0) { + if(x < 12.0) { return Math.log(Math.abs(gamma(x))); } @@ -164,7 +161,7 @@ public static double logGamma(double x) { }; double z = 1.0 / (x * x); double sum = c[7]; - for (int i = 6; i >= 0; i--) { + for(int i = 6; i >= 0; i--) { sum *= z; sum += c[i]; } diff --git a/src/main/java/vazkii/psi/api/inventory/InventorySocketable.java b/src/main/java/vazkii/psi/api/inventory/InventorySocketable.java index d1a704f36..e66b88fa6 100644 --- a/src/main/java/vazkii/psi/api/inventory/InventorySocketable.java +++ b/src/main/java/vazkii/psi/api/inventory/InventorySocketable.java @@ -31,7 +31,7 @@ public class InventorySocketable implements Container, Nameable, ContainerData { private ISocketable socketable; public InventorySocketable(ItemStack stack) { - if (stack.isEmpty()) { + if(stack.isEmpty()) { socketable = null; } else { socketable = ISocketable.socketable(stack); @@ -39,7 +39,7 @@ public InventorySocketable(ItemStack stack) { } public void setStack(ItemStack stack) { - if (stack.isEmpty()) { + if(stack.isEmpty()) { socketable = null; } else { socketable = ISocketable.socketable(stack); @@ -47,7 +47,7 @@ public void setStack(ItemStack stack) { } private Iterator getSockerator() { - if (socketable == null) { + if(socketable == null) { return Collections.emptyIterator(); } return new IteratorSocketable(socketable); @@ -62,8 +62,8 @@ public int getContainerSize() { @Override public boolean isEmpty() { Iterator sockerator = getSockerator(); - while (sockerator.hasNext()) { - if (!sockerator.next().isEmpty()) { + while(sockerator.hasNext()) { + if(!sockerator.next().isEmpty()) { return false; } } @@ -73,7 +73,7 @@ public boolean isEmpty() { @Nonnull @Override public ItemStack getItem(int index) { - if (socketable == null) { + if(socketable == null) { return ItemStack.EMPTY; } return socketable.getBulletInSocket(index); @@ -82,12 +82,12 @@ public ItemStack getItem(int index) { @Nonnull @Override public ItemStack removeItem(int index, int count) { - if (socketable == null) { + if(socketable == null) { return ItemStack.EMPTY; } ItemStack bullet = socketable.getBulletInSocket(index); - if (!bullet.isEmpty()) { + if(!bullet.isEmpty()) { socketable.setBulletInSocket(index, ItemStack.EMPTY); } return bullet; @@ -101,7 +101,7 @@ public ItemStack removeItemNoUpdate(int index) { @Override public void setItem(int index, @Nonnull ItemStack bullet) { - if (socketable == null) { + if(socketable == null) { return; } @@ -156,7 +156,7 @@ public int getCount() { @Override public void clearContent() { Iterator sockerator = getSockerator(); - while (sockerator.hasNext()) { + while(sockerator.hasNext()) { sockerator.next(); sockerator.remove(); } diff --git a/src/main/java/vazkii/psi/api/inventory/IteratorSocketable.java b/src/main/java/vazkii/psi/api/inventory/IteratorSocketable.java index 5c15052d4..d072d303c 100644 --- a/src/main/java/vazkii/psi/api/inventory/IteratorSocketable.java +++ b/src/main/java/vazkii/psi/api/inventory/IteratorSocketable.java @@ -37,7 +37,7 @@ public ItemStack next() { @Override public void remove() { - if (index < 0 || removed) { + if(index < 0 || removed) { throw new IllegalStateException(); } diff --git a/src/main/java/vazkii/psi/api/recipe/TrickRecipeBuilder.java b/src/main/java/vazkii/psi/api/recipe/TrickRecipeBuilder.java index 326dca6f3..eb417b0b0 100644 --- a/src/main/java/vazkii/psi/api/recipe/TrickRecipeBuilder.java +++ b/src/main/java/vazkii/psi/api/recipe/TrickRecipeBuilder.java @@ -120,7 +120,7 @@ public void serializeRecipeData(@Nonnull JsonObject json) { json.add("input", input.toJson()); json.add("output", serializeStack(output)); json.add("cad", serializeStack(cadAssembly)); - if (trick != null) { + if(trick != null) { json.addProperty("trick", trick.toString()); } } @@ -158,7 +158,7 @@ public ResourceLocation getAdvancementId() { private static JsonObject serializeStack(ItemStack stack) { CompoundTag nbt = stack.save(new CompoundTag()); byte c = nbt.getByte("Count"); - if (c != 1) { + if(c != 1) { nbt.putByte("count", c); } nbt.remove("Count"); @@ -170,7 +170,7 @@ private static JsonObject serializeStack(ItemStack stack) { private static void renameTag(CompoundTag nbt, String oldName, String newName) { Tag tag = nbt.get(oldName); - if (tag != null) { + if(tag != null) { nbt.remove(oldName); nbt.put(newName, tag); } diff --git a/src/main/java/vazkii/psi/api/spell/CompiledSpell.java b/src/main/java/vazkii/psi/api/spell/CompiledSpell.java index df56993ee..208545851 100644 --- a/src/main/java/vazkii/psi/api/spell/CompiledSpell.java +++ b/src/main/java/vazkii/psi/api/spell/CompiledSpell.java @@ -49,7 +49,7 @@ public CompiledSpell(Spell source) { */ public boolean execute(SpellContext context) throws SpellRuntimeException { IPlayerData data = PsiAPI.internalHandler.getDataForPlayer(context.caster); - while (!context.actions.isEmpty()) { + while(!context.actions.isEmpty()) { Action a = context.actions.pop(); currentAction = a; @@ -59,11 +59,11 @@ public boolean execute(SpellContext context) throws SpellRuntimeException { currentAction = null; - if (context.stopped) { + if(context.stopped) { return false; } - if (context.delay > 0) { + if(context.delay > 0) { return true; } } @@ -76,20 +76,20 @@ public boolean execute(SpellContext context) throws SpellRuntimeException { */ @SuppressWarnings("unchecked") public void safeExecute(SpellContext context) { - if (context.caster.getCommandSenderWorld().isClientSide) { + if(context.caster.getCommandSenderWorld().isClientSide) { return; } try { - if (context.actions == null) { + if(context.actions == null) { context.actions = (Stack) actions.clone(); } - if (context.cspell.execute(context)) { + if(context.cspell.execute(context)) { PsiAPI.internalHandler.delayContext(context); } } catch (SpellRuntimeException e) { - if (!context.shouldSuppressErrors()) { + if(!context.shouldSuppressErrors()) { context.caster.sendSystemMessage(Component.translatable(e.getMessage()).setStyle(Style.EMPTY.withColor(ChatFormatting.RED))); int x = context.cspell.currentAction.piece.x + 1; @@ -101,7 +101,7 @@ public void safeExecute(SpellContext context) { } public boolean hasEvaluated(int x, int y) { - if (!SpellGrid.exists(x, y)) { + if(!SpellGrid.exists(x, y)) { return false; } @@ -122,12 +122,12 @@ public void execute(IPlayerData data, SpellContext context) throws SpellRuntimeE Object o = piece.execute(context); Class eval = piece.getEvaluationType(); - if (eval != null && eval != Void.class) { + if(eval != null && eval != Void.class) { context.evaluatedObjects[piece.x][piece.y] = o; } } catch (SpellRuntimeException exception) { - if (errorHandlers.containsKey(piece)) { - if (!errorHandlers.get(piece).suppress(piece, context, exception)) { + if(errorHandlers.containsKey(piece)) { + if(!errorHandlers.get(piece).suppress(piece, context, exception)) { throw exception; } return; @@ -150,9 +150,9 @@ public CatchHandler(SpellPiece handlerPiece) { public boolean suppress(SpellPiece piece, SpellContext context, SpellRuntimeException exception) { boolean handled = handler.catchException(piece, context, exception); - if (handled) { + if(handled) { Class eval = piece.getEvaluationType(); - if (eval != null && eval != Void.class) { + if(eval != null && eval != Void.class) { context.evaluatedObjects[piece.x][piece.y] = handler.supplyReplacementValue(piece, context, exception); } diff --git a/src/main/java/vazkii/psi/api/spell/Spell.java b/src/main/java/vazkii/psi/api/spell/Spell.java index 318c1c60c..1b8f4463a 100644 --- a/src/main/java/vazkii/psi/api/spell/Spell.java +++ b/src/main/java/vazkii/psi/api/spell/Spell.java @@ -52,7 +52,7 @@ public void draw(PoseStack ms, MultiBufferSource buffers, int light) { @Nullable public static Spell createFromNBT(CompoundTag cmp) { - if (cmp == null || !cmp.getBoolean(TAG_VALID)) { + if(cmp == null || !cmp.getBoolean(TAG_VALID)) { return null; } @@ -64,10 +64,10 @@ public static Spell createFromNBT(CompoundTag cmp) { public void readFromNBT(CompoundTag cmp) { name = cmp.getString(TAG_SPELL_NAME); - if (cmp.contains(TAG_UUID_MOST)) { + if(cmp.contains(TAG_UUID_MOST)) { long uuidMost = cmp.getLong(TAG_UUID_MOST); long uuidLeast = cmp.getLong(TAG_UUID_LEAST); - if (uuid.getMostSignificantBits() != uuidMost || uuid.getLeastSignificantBits() != uuidLeast) { + if(uuid.getMostSignificantBits() != uuidMost || uuid.getLeastSignificantBits() != uuidLeast) { uuid = new UUID(uuidMost, uuidLeast); } } @@ -77,9 +77,9 @@ public void readFromNBT(CompoundTag cmp) { public Set getPieceNamespaces() { Set temp = Collections.newSetFromMap(new HashMap<>()); - for (SpellPiece[] gridDatum : grid.gridData) { - for (SpellPiece spellPiece : gridDatum) { - if (spellPiece != null) { + for(SpellPiece[] gridDatum : grid.gridData) { + for(SpellPiece spellPiece : gridDatum) { + if(spellPiece != null) { temp.add(spellPiece.registryKey.getNamespace()); } } @@ -91,10 +91,10 @@ public void writeToNBT(CompoundTag cmp) { cmp.putBoolean(TAG_VALID, true); cmp.putString(TAG_SPELL_NAME, name); ListTag modList = new ListTag(); - for (String namespace : getPieceNamespaces()) { + for(String namespace : getPieceNamespaces()) { CompoundTag nbt = new CompoundTag(); nbt.putString(TAG_MOD_NAME, namespace); - if (ModList.get().getModContainerById(namespace).isPresent()) { + if(ModList.get().getModContainerById(namespace).isPresent()) { nbt.putString(TAG_MOD_VERSION, ModList.get().getModContainerById(namespace).get().getModInfo().getVersion().toString()); } modList.add(nbt); diff --git a/src/main/java/vazkii/psi/api/spell/SpellContext.java b/src/main/java/vazkii/psi/api/spell/SpellContext.java index 3235b437e..9189cf93a 100644 --- a/src/main/java/vazkii/psi/api/spell/SpellContext.java +++ b/src/main/java/vazkii/psi/api/spell/SpellContext.java @@ -161,10 +161,10 @@ public boolean isInRadius(Vector3 vec) { * @see #MAX_DISTANCE */ public boolean isInRadius(Entity e) { - if (e == null) { + if(e == null) { return false; } - if (e == focalPoint || e == caster) { + if(e == focalPoint || e == caster) { return true; } @@ -181,27 +181,27 @@ public boolean isInRadius(double x, double y, double z) { } public void verifyEntity(Entity e) throws SpellRuntimeException { - if (e == null) { + if(e == null) { throw new SpellRuntimeException(SpellRuntimeException.NULL_TARGET); } - if (ISpellImmune.isImmune(e)) { + if(ISpellImmune.isImmune(e)) { throw new SpellRuntimeException(SpellRuntimeException.IMMUNE_TARGET); } } public int getTargetSlot() throws SpellRuntimeException { int slot; - if (customTargetSlot) { + if(customTargetSlot) { return targetSlot % 36; } - if (shiftTargetSlot) { + if(shiftTargetSlot) { int cadSlot = PsiAPI.getPlayerCADSlot(caster); - if (cadSlot == -1) { + if(cadSlot == -1) { throw new SpellRuntimeException(SpellRuntimeException.NO_CAD); } - if (Inventory.isHotbarSlot(cadSlot)) { + if(Inventory.isHotbarSlot(cadSlot)) { slot = (cadSlot + targetSlot) % 9; } else { slot = (caster.getInventory().selected + targetSlot) % 9; @@ -210,7 +210,7 @@ public int getTargetSlot() throws SpellRuntimeException { slot = (targetSlot - 1) % 9; } - if (slot < 0) { + if(slot < 0) { slot = 10 + slot; } return slot; @@ -223,12 +223,12 @@ public int getTargetSlot() throws SpellRuntimeException { * @throws SpellRuntimeException NO_CAD */ public ItemStack getHarvestTool() throws SpellRuntimeException { - if (!tool.isEmpty()) { //TODO Armor + if(!tool.isEmpty()) { //TODO Armor return tool; } ItemStack cad = PsiAPI.getPlayerCAD(caster); - if (cad.isEmpty()) { + if(cad.isEmpty()) { throw new SpellRuntimeException(SpellRuntimeException.NO_CAD); } return cad; diff --git a/src/main/java/vazkii/psi/api/spell/SpellGrid.java b/src/main/java/vazkii/psi/api/spell/SpellGrid.java index b0f46b19b..20abb1791 100644 --- a/src/main/java/vazkii/psi/api/spell/SpellGrid.java +++ b/src/main/java/vazkii/psi/api/spell/SpellGrid.java @@ -46,10 +46,10 @@ public final class SpellGrid { @OnlyIn(Dist.CLIENT) public void draw(PoseStack ms, MultiBufferSource buffers, int light) { - for (int i = 0; i < GRID_SIZE; i++) { - for (int j = 0; j < GRID_SIZE; j++) { + for(int i = 0; i < GRID_SIZE; i++) { + for(int j = 0; j < GRID_SIZE; j++) { SpellPiece p = gridData[i][j]; - if (p != null) { + if(p != null) { ms.pushPose(); ms.translate(i * 18, j * 18, 0); p.draw(ms, buffers, light); @@ -66,21 +66,21 @@ private void recalculateBoundaries() { topmost = GRID_SIZE; bottommost = -1; - for (int i = 0; i < GRID_SIZE; i++) { - for (int j = 0; j < GRID_SIZE; j++) { + for(int i = 0; i < GRID_SIZE; i++) { + for(int j = 0; j < GRID_SIZE; j++) { SpellPiece p = gridData[i][j]; - if (p != null) { + if(p != null) { empty = false; - if (i < leftmost) { + if(i < leftmost) { leftmost = i; } - if (i > rightmost) { + if(i > rightmost) { rightmost = i; } - if (j < topmost) { + if(j < topmost) { topmost = j; } - if (j > bottommost) { + if(j > bottommost) { bottommost = j; } } @@ -91,7 +91,7 @@ private void recalculateBoundaries() { public int getSize() { recalculateBoundaries(); - if (empty) { + if(empty) { return 0; } @@ -100,17 +100,17 @@ public int getSize() { public void mirrorVertical() { recalculateBoundaries(); - if (empty) { + if(empty) { return; } SpellPiece[][] newGrid = new SpellPiece[GRID_SIZE][GRID_SIZE]; - for (int i = 0; i < GRID_SIZE; i++) { - for (int j = 0; j < GRID_SIZE; j++) { + for(int i = 0; i < GRID_SIZE; i++) { + for(int j = 0; j < GRID_SIZE; j++) { SpellPiece p = gridData[i][j]; - if (p != null) { + if(p != null) { int newY = GRID_SIZE - j - 1; newGrid[i][newY] = p; @@ -126,7 +126,7 @@ public void mirrorVertical() { public void rotate(boolean ccw) { recalculateBoundaries(); - if (empty) { + if(empty) { return; } @@ -135,11 +135,11 @@ public void rotate(boolean ccw) { SpellPiece[][] newGrid = new SpellPiece[GRID_SIZE][GRID_SIZE]; - for (int i = 0; i < GRID_SIZE; i++) { - for (int j = 0; j < GRID_SIZE; j++) { + for(int i = 0; i < GRID_SIZE; i++) { + for(int j = 0; j < GRID_SIZE; j++) { SpellPiece p = gridData[i][j]; - if (p != null) { + if(p != null) { int newX = xMod * (j - GRID_CENTER) + GRID_CENTER; int newY = yMod * (i - GRID_CENTER) + GRID_CENTER; @@ -147,7 +147,7 @@ public void rotate(boolean ccw) { p.x = newX; p.y = newY; - for (SpellParam param : p.paramSides.keySet()) { + for(SpellParam param : p.paramSides.keySet()) { SpellParam.Side side = p.paramSides.get(param); p.paramSides.put(param, ccw ? side.rotateCCW() : side.rotateCW()); } @@ -161,22 +161,22 @@ public void rotate(boolean ccw) { public boolean shift(SpellParam.Side side, boolean doit) { recalculateBoundaries(); - if (empty) { + if(empty) { return false; } - if (exists(leftmost + side.offx, topmost + side.offy) && exists(rightmost + side.offx, bottommost + side.offy)) { - if (!doit) { + if(exists(leftmost + side.offx, topmost + side.offy) && exists(rightmost + side.offx, bottommost + side.offy)) { + if(!doit) { return true; } SpellPiece[][] newGrid = new SpellPiece[GRID_SIZE][GRID_SIZE]; - for (int i = 0; i < GRID_SIZE; i++) { - for (int j = 0; j < GRID_SIZE; j++) { + for(int i = 0; i < GRID_SIZE; i++) { + for(int j = 0; j < GRID_SIZE; j++) { SpellPiece p = gridData[i][j]; - if (p != null) { + if(p != null) { int newX = i + side.offx; int newY = j + side.offy; newGrid[newX][newY] = p; @@ -198,7 +198,7 @@ public static boolean exists(int x, int y) { private SpellPiece getPieceAtSide(Multimap traversed, int x, int y, SpellParam.Side side) throws SpellCompilationException { SpellPiece atSide = getPieceAtSideSafely(x, y, side); - if (!traversed.put(atSide, side)) { + if(!traversed.put(atSide, side)) { throw new SpellCompilationException(SpellCompilationException.INFINITE_LOOP); } @@ -219,11 +219,11 @@ public SpellPiece getPieceAtSideWithRedirections(int x, int y, SpellParam.Side s public SpellPiece getPieceAtSideWithRedirections(int x, int y, SpellParam.Side side, SpellPieceConsumer walker) throws SpellCompilationException { SpellPiece atSide; Multimap traversed = HashMultimap.create(); - while ((atSide = getPieceAtSide(traversed, x, y, side)) instanceof IGenericRedirector) { + while((atSide = getPieceAtSide(traversed, x, y, side)) instanceof IGenericRedirector) { IGenericRedirector redirector = (IGenericRedirector) atSide; walker.accept(atSide); SpellParam.Side rside = redirector.remapSide(side); - if (!rside.isEnabled()) { + if(!rside.isEnabled()) { return null; } side = rside; @@ -237,7 +237,7 @@ public SpellPiece getPieceAtSideWithRedirections(int x, int y, SpellParam.Side s public SpellPiece getPieceAtSideSafely(int x, int y, SpellParam.Side side) { int xp = x + side.offx; int yp = y + side.offy; - if (!exists(xp, yp)) { + if(!exists(xp, yp)) { return null; } @@ -250,10 +250,10 @@ public SpellGrid(Spell spell) { } public boolean isEmpty() { - for (int i = 0; i < GRID_SIZE; i++) { - for (int j = 0; j < GRID_SIZE; j++) { + for(int i = 0; i < GRID_SIZE; i++) { + for(int j = 0; j < GRID_SIZE; j++) { SpellPiece piece = gridData[i][j]; - if (piece != null) { + if(piece != null) { return false; } } @@ -267,11 +267,11 @@ public void readFromNBT(CompoundTag cmp) { ListTag list = cmp.getList(TAG_SPELL_LIST, 10); int len = list.size(); - for (int i = 0; i < len; i++) { + for(int i = 0; i < len; i++) { CompoundTag lcmp = list.getCompound(i); int posX, posY; - if (lcmp.contains(TAG_SPELL_POS_X_LEGACY)) { + if(lcmp.contains(TAG_SPELL_POS_X_LEGACY)) { posX = lcmp.getInt(TAG_SPELL_POS_X_LEGACY); posY = lcmp.getInt(TAG_SPELL_POS_Y_LEGACY); } else { @@ -280,14 +280,14 @@ public void readFromNBT(CompoundTag cmp) { } CompoundTag data; - if (lcmp.contains(TAG_SPELL_DATA_LEGACY)) { + if(lcmp.contains(TAG_SPELL_DATA_LEGACY)) { data = lcmp.getCompound(TAG_SPELL_DATA_LEGACY); } else { data = lcmp.getCompound(TAG_SPELL_DATA); } SpellPiece piece = SpellPiece.createFromNBT(spell, data); - if (piece != null) { + if(piece != null) { gridData[posX][posY] = piece; piece.isInGrid = true; piece.x = posX; @@ -298,10 +298,10 @@ public void readFromNBT(CompoundTag cmp) { public void writeToNBT(CompoundTag cmp) { ListTag list = new ListTag(); - for (int i = 0; i < GRID_SIZE; i++) { - for (int j = 0; j < GRID_SIZE; j++) { + for(int i = 0; i < GRID_SIZE; i++) { + for(int j = 0; j < GRID_SIZE; j++) { SpellPiece piece = gridData[i][j]; - if (piece != null) { + if(piece != null) { CompoundTag lcmp = new CompoundTag(); lcmp.putInt(TAG_SPELL_POS_X, i); lcmp.putInt(TAG_SPELL_POS_Y, j); diff --git a/src/main/java/vazkii/psi/api/spell/SpellHelpers.java b/src/main/java/vazkii/psi/api/spell/SpellHelpers.java index e4df27609..ac1e61d79 100644 --- a/src/main/java/vazkii/psi/api/spell/SpellHelpers.java +++ b/src/main/java/vazkii/psi/api/spell/SpellHelpers.java @@ -17,7 +17,7 @@ public class SpellHelpers { public static double ensurePositiveOrZero(SpellPiece piece, SpellParam param) throws SpellCompilationException { double val = piece.getNonNullParamEvaluation(param).doubleValue(); - if (val < 0) { + if(val < 0) { throw new SpellCompilationException(SpellCompilationException.NON_POSITIVE_VALUE, piece.x, piece.y); } return val; @@ -25,7 +25,7 @@ public static double ensurePositiveOrZero(SpellPiece piece, SpellParam p public static double ensurePositiveAndNonzero(SpellPiece piece, SpellParam param) throws SpellCompilationException { double val = piece.getNonNullParamEvaluation(param).doubleValue(); - if (val <= 0) { + if(val <= 0) { throw new SpellCompilationException(SpellCompilationException.NON_POSITIVE_VALUE, piece.x, piece.y); } @@ -34,7 +34,7 @@ public static double ensurePositiveAndNonzero(SpellPiece piece, SpellParam param, double max) throws SpellRuntimeException { Number numberVal = piece.getParamValue(context, param); - if (numberVal == null) { + if(numberVal == null) { return max; } return Math.min(max, Math.max(-max, numberVal.doubleValue())); @@ -47,7 +47,7 @@ public static Direction getFacing(SpellPiece piece, SpellContext context, SpellP public static Direction getFacing(SpellPiece piece, SpellContext context, SpellParam param, Direction def) throws SpellRuntimeException { Vector3 face = getVector3(piece, context, param, true, false, true); - if (face == null) { + if(face == null) { return def; } return Direction.getNearest((float) face.x, (float) face.y, (float) face.z); @@ -59,7 +59,7 @@ public static boolean isBlockPosInRadius(SpellContext context, BlockPos pos) { public static double ensurePositiveOrZero(SpellPiece piece, SpellParam param, double def) throws SpellCompilationException { double val = piece.getParamEvaluationeOrDefault(param, def).doubleValue(); - if (val < 0) { + if(val < 0) { throw new SpellCompilationException(SpellCompilationException.NON_POSITIVE_VALUE, piece.x, piece.y); } return val; @@ -67,7 +67,7 @@ public static double ensurePositiveOrZero(SpellPiece piece, SpellParam p public static double ensurePositiveAndNonzero(SpellPiece piece, SpellParam param, double def) throws SpellCompilationException { double val = piece.getParamEvaluationeOrDefault(param, def).doubleValue(); - if (val <= 0) { + if(val <= 0) { throw new SpellCompilationException(SpellCompilationException.NON_POSITIVE_VALUE, piece.x, piece.y); } @@ -76,10 +76,10 @@ public static double ensurePositiveAndNonzero(SpellPiece piece, SpellParam param) throws SpellRuntimeException { Vector3 position = piece.getParamValue(context, param); - if (position == null) { + if(position == null) { throw new SpellRuntimeException(SpellRuntimeException.NULL_VECTOR); } - if (!context.isInRadius(position)) { + if(!context.isInRadius(position)) { throw new SpellRuntimeException(SpellRuntimeException.OUTSIDE_RADIUS); } return position.toBlockPos(); @@ -111,13 +111,13 @@ public static Vector3 checkPos(SpellPiece piece, SpellContext context, SpellPara public static Vector3 checkPos(SpellPiece piece, SpellContext context, SpellParam param, boolean nonnull, boolean check, boolean shouldBeAxial) throws SpellRuntimeException { Vector3 position = piece.getParamValue(context, param); - if (nonnull && (position == null || position.isZero())) { + if(nonnull && (position == null || position.isZero())) { throw new SpellRuntimeException(SpellRuntimeException.NULL_VECTOR); } - if (check && !context.isInRadius(position)) { + if(check && !context.isInRadius(position)) { throw new SpellRuntimeException(SpellRuntimeException.OUTSIDE_RADIUS); } - if (shouldBeAxial && !position.isAxial()) { + if(shouldBeAxial && !position.isAxial()) { throw new SpellRuntimeException(SpellRuntimeException.NON_AXIAL_VECTOR); } return position; diff --git a/src/main/java/vazkii/psi/api/spell/SpellMetadata.java b/src/main/java/vazkii/psi/api/spell/SpellMetadata.java index 80a7d87a6..13e277118 100644 --- a/src/main/java/vazkii/psi/api/spell/SpellMetadata.java +++ b/src/main/java/vazkii/psi/api/spell/SpellMetadata.java @@ -30,7 +30,7 @@ public final class SpellMetadata { public boolean errorsSuppressed = false; public SpellMetadata() { - for (EnumSpellStat stat : EnumSpellStat.class.getEnumConstants()) { + for(EnumSpellStat stat : EnumSpellStat.class.getEnumConstants()) { stats.put(stat, 0); statMultipliers.put(stat, 1.0); } @@ -47,7 +47,7 @@ public void addStat(EnumSpellStat stat, int val) throws SpellCompilationExceptio } catch (ArithmeticException exception) { overflow = true; } - if (overflow) { + if(overflow) { throw new SpellCompilationException(SpellCompilationException.STAT_OVERFLOW); } } @@ -110,7 +110,7 @@ public Set getStatSet() { * Sets a flag in the metadata. */ public void setFlag(String flag, boolean val) { - if (val) { + if(val) { flags.add(flag); } else { flags.remove(flag); @@ -129,20 +129,20 @@ public boolean getFlag(String flag) { * of {@link ICAD}). Returns true if the stats are equal to or above the CAD. */ public boolean evaluateAgainst(ItemStack stack) { - if (stack == null || !(stack.getItem() instanceof ICAD)) { + if(stack == null || !(stack.getItem() instanceof ICAD)) { return false; } ICAD cad = (ICAD) stack.getItem(); - for (EnumSpellStat stat : stats.keySet()) { + for(EnumSpellStat stat : stats.keySet()) { EnumCADStat cadStat = stat.getTarget(); - if (cadStat == null) { + if(cadStat == null) { continue; } int statVal = (int) Math.ceil(stats.get(stat) * statMultipliers.get(stat)); int cadVal = cad.getStatValue(stack, cadStat); - if (cadVal != -1 && cadVal < statVal) { + if(cadVal != -1 && cadVal < statVal) { return false; } } diff --git a/src/main/java/vazkii/psi/api/spell/SpellParam.java b/src/main/java/vazkii/psi/api/spell/SpellParam.java index 94ce46f5f..80d0d4293 100644 --- a/src/main/java/vazkii/psi/api/spell/SpellParam.java +++ b/src/main/java/vazkii/psi/api/spell/SpellParam.java @@ -119,7 +119,7 @@ public Component getRequiredTypeString() { Class evalType = getRequiredType(); String evalStr = evalType == null ? "null" : CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, evalType.getSimpleName()); MutableComponent s = Component.translatable("psi.datatype." + evalStr); - if (requiresConstant()) { + if(requiresConstant()) { s.append(" ").append(Component.translatable("psimisc.constant")); } @@ -195,7 +195,7 @@ public Side rotateCCW() { } private Side mapSides(Side whenUp, Side whenDown, Side whenL, Side whenR) { - switch (this) { + switch(this) { case TOP: return whenUp; case BOTTOM: diff --git a/src/main/java/vazkii/psi/api/spell/SpellPiece.java b/src/main/java/vazkii/psi/api/spell/SpellPiece.java index 096b3ca1c..75a3b0fcd 100644 --- a/src/main/java/vazkii/psi/api/spell/SpellPiece.java +++ b/src/main/java/vazkii/psi/api/spell/SpellPiece.java @@ -123,7 +123,7 @@ public Component getEvaluationTypeString() { Class evalType = getEvaluationType(); String evalStr = evalType == null ? "null" : CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, evalType.getSimpleName()); MutableComponent s = Component.translatable("psi.datatype." + evalStr); - if (getPieceType() == EnumPieceType.CONSTANT) { + if(getPieceType() == EnumPieceType.CONSTANT) { s.append(" ").append(Component.translatable("psimisc.constant")); } @@ -171,7 +171,7 @@ public T getParamValueOrDefault(SpellContext context, SpellParam param, T */ public T getNonnullParamValue(SpellContext context, SpellParam param) throws SpellRuntimeException { T v = getParamValue(context, param); - if (v == null) { + if(v == null) { throw new SpellRuntimeException(SpellRuntimeException.NULL_TARGET); } return v; @@ -183,9 +183,9 @@ public T getNonnullParamValue(SpellContext context, SpellParam param) thr @SuppressWarnings("unchecked") public T getParamValue(SpellContext context, SpellParam param) throws SpellRuntimeException { T returnValue = (T) getRawParamValue(context, param); - if (returnValue instanceof Number) { + if(returnValue instanceof Number) { Number number = (Number) returnValue; - if (Double.isNaN(number.doubleValue()) || Double.isInfinite(number.doubleValue())) { + if(Double.isNaN(number.doubleValue()) || Double.isInfinite(number.doubleValue())) { throw new SpellRuntimeException(SpellRuntimeException.NAN); } } @@ -197,13 +197,13 @@ public T getParamValue(SpellContext context, SpellParam param) throws Spe */ public Object getRawParamValue(SpellContext context, SpellParam param) { SpellParam.Side side = paramSides.get(param); - if (!side.isEnabled()) { + if(!side.isEnabled()) { return null; } try { SpellPiece piece = spell.grid.getPieceAtSideWithRedirections(x, y, side); - if (piece == null || !param.canAccept(piece)) { + if(piece == null || !param.canAccept(piece)) { return null; } @@ -227,7 +227,7 @@ public T getParamEvaluationeOrDefault(SpellParam param, T def) throws Spe */ public T getNonNullParamEvaluation(SpellParam param) throws SpellCompilationException { T v = getParamEvaluation(param); - if (v == null) { + if(v == null) { throw new SpellCompilationException(SpellCompilationException.NULL_PARAM, this.x, this.y); } return v; @@ -240,13 +240,13 @@ public T getNonNullParamEvaluation(SpellParam param) throws SpellCompilat @SuppressWarnings("unchecked") public T getParamEvaluation(SpellParam param) throws SpellCompilationException { SpellParam.Side side = paramSides.get(param); - if (!side.isEnabled()) { + if(!side.isEnabled()) { return null; } SpellPiece piece = spell.grid.getPieceAtSideWithRedirections(x, y, side); - if (piece == null || !param.canAccept(piece)) { + if(piece == null || !param.canAccept(piece)) { return null; } @@ -283,7 +283,7 @@ public void draw(PoseStack ms, MultiBufferSource buffers, int light) { drawBackground(ms, buffers, light); ms.translate(0F, 0F, 0.1F); drawAdditional(ms, buffers, light); - if (isInGrid) { + if(isInGrid) { ms.translate(0F, 0F, 0.1F); drawParams(ms, buffers, light); ms.translate(0F, 0F, 0.1F); @@ -295,7 +295,7 @@ public void draw(PoseStack ms, MultiBufferSource buffers, int light) { @OnlyIn(Dist.CLIENT) public static RenderType getLayer() { - if (layer == null) { + if(layer == null) { RenderType.CompositeState glState = RenderType.CompositeState.builder() .setShaderState(new RenderStateShard.ShaderStateShard(GameRenderer::getPositionColorTexShader)) .setTextureState(new RenderStateShard.TextureStateShard(ClientPsiAPI.PSI_PIECE_TEXTURE_ATLAS, false, false)) @@ -354,7 +354,7 @@ public void drawAdditional(PoseStack ms, MultiBufferSource buffers, int light) { */ @OnlyIn(Dist.CLIENT) public void drawComment(PoseStack ms, MultiBufferSource buffers, int light) { - if (comment != null && !comment.isEmpty()) { + if(comment != null && !comment.isEmpty()) { VertexConsumer buffer = buffers.getBuffer(PsiAPI.internalHandler.getProgrammerLayer()); float wh = 6F; @@ -377,7 +377,7 @@ public void drawComment(PoseStack ms, MultiBufferSource buffers, int light) { @OnlyIn(Dist.CLIENT) public void drawParams(PoseStack ms, MultiBufferSource buffers, int light) { VertexConsumer buffer = buffers.getBuffer(PsiAPI.internalHandler.getProgrammerLayer()); - for (SpellParam param : paramSides.keySet()) { + for(SpellParam param : paramSides.keySet()) { drawParam(ms, buffer, light, param); } } @@ -385,23 +385,23 @@ public void drawParams(PoseStack ms, MultiBufferSource buffers, int light) { @OnlyIn(Dist.CLIENT) public void drawParam(PoseStack ms, VertexConsumer buffer, int light, SpellParam param) { SpellParam.Side side = paramSides.get(param); - if (!side.isEnabled() || param.getArrowType() == ArrowType.NONE) { + if(!side.isEnabled() || param.getArrowType() == ArrowType.NONE) { return; } int index = getParamArrowIndex(param); int count = getParamArrowCount(side); SpellPiece neighbour = spell.grid.getPieceAtSideSafely(x, y, side); - if (neighbour != null) { + if(neighbour != null) { int nbcount = neighbour.getParamArrowCount(side.getOpposite()); - if (side.asInt() > side.getOpposite().asInt()) { + if(side.asInt() > side.getOpposite().asInt()) { index += nbcount; } count += nbcount; } float percent = 0.5f; - if (count > 1) { + if(count > 1) { percent = (float) index / (count - 1); } drawParam(ms, buffer, light, side, param.color, param.getArrowType(), percent); @@ -409,7 +409,7 @@ public void drawParam(PoseStack ms, VertexConsumer buffer, int light, SpellParam @OnlyIn(Dist.CLIENT) public void drawParam(PoseStack ms, VertexConsumer buffer, int light, SpellParam.Side side, int color, SpellParam.ArrowType arrowType, float percent) { - if (arrowType == ArrowType.NONE) { + if(arrowType == ArrowType.NONE) { return; } @@ -418,7 +418,7 @@ public void drawParam(PoseStack ms, VertexConsumer buffer, int light, SpellParam float maxX = minX + 8; float maxY = minY + 8; - if (arrowType == ArrowType.OUT) { + if(arrowType == ArrowType.OUT) { side = side.getOpposite(); } float wh = 8F; @@ -442,8 +442,8 @@ public void drawParam(PoseStack ms, VertexConsumer buffer, int light, SpellParam @OnlyIn(Dist.CLIENT) public int getParamArrowCount(SpellParam.Side side) { int count = 0; - for (SpellParam p : paramSides.keySet()) { - if (p.getArrowType() != ArrowType.NONE && paramSides.get(p) == side) { + for(SpellParam p : paramSides.keySet()) { + if(p.getArrowType() != ArrowType.NONE && paramSides.get(p) == side) { count++; } } @@ -454,11 +454,11 @@ public int getParamArrowCount(SpellParam.Side side) { public int getParamArrowIndex(SpellParam param) { SpellParam.Side side = paramSides.get(param); int count = 0; - for (SpellParam p : paramSides.keySet()) { - if (p == param) { + for(SpellParam p : paramSides.keySet()) { + if(p == param) { return count; } - if (p.getArrowType() != ArrowType.NONE && paramSides.get(p) == side) { + if(p.getArrowType() != ArrowType.NONE && paramSides.get(p) == side) { count++; } } @@ -486,14 +486,14 @@ public void getTooltip(List tooltip) { tooltip.add(Component.translatable(getUnlocalizedName())); tooltip.add(Component.translatable(getUnlocalizedDesc()).withStyle(ChatFormatting.GRAY)); TooltipHelper.tooltipIfShift(tooltip, () -> addToTooltipAfterShift(tooltip)); - if (!statLabels.isEmpty()) { + if(!statLabels.isEmpty()) { TooltipHelper.tooltipIfCtrl(tooltip, () -> addToTooltipAfterCtrl(tooltip)); } String addon = registryKey.getNamespace(); - if (!addon.equals("psi")) { + if(!addon.equals("psi")) { - if (ModList.get().getModContainerById(addon).isPresent()) { + if(ModList.get().getModContainerById(addon).isPresent()) { tooltip.add(Component.translatable("psimisc.provider_mod", ModList.get().getModContainerById(addon).get().getNamespace())); } } @@ -505,7 +505,7 @@ public void addToTooltipAfterShift(List tooltip) { MutableComponent eval = getEvaluationTypeString().plainCopy().withStyle(ChatFormatting.GOLD); tooltip.add(Component.literal("Output ").append(eval)); - for (SpellParam param : paramSides.keySet()) { + for(SpellParam param : paramSides.keySet()) { Component pName = Component.translatable(param.name).withStyle(ChatFormatting.YELLOW); Component pEval = Component.literal(" [").append(param.getRequiredTypeString()).append("]").withStyle(ChatFormatting.YELLOW); tooltip.add(Component.literal(param.canDisable ? "[Input] " : " Input ").append(pName).append(pEval)); @@ -558,13 +558,13 @@ public void getShownPieces(List pieces) { public static SpellPiece createFromNBT(Spell spell, CompoundTag cmp) { String key; - if (cmp.contains(TAG_KEY_LEGACY)) { + if(cmp.contains(TAG_KEY_LEGACY)) { key = cmp.getString(TAG_KEY_LEGACY); } else { key = cmp.getString(TAG_KEY); } - if (key.startsWith("_")) { + if(key.startsWith("_")) { key = PSI_PREFIX + key.substring(1); } try { @@ -574,20 +574,20 @@ public static SpellPiece createFromNBT(Spell spell, CompoundTag cmp) { } boolean exists = false; ResourceLocation rl = new ResourceLocation(key); - if (PsiAPI.isPieceRegistered(rl)) { + if(PsiAPI.isPieceRegistered(rl)) { exists = true; } else { Set pieceNamespaces = PsiAPI.getSpellPieceRegistry().keySet().stream().map(ResourceLocation::getNamespace).collect(Collectors.toSet()); - for (String namespace : pieceNamespaces) { + for(String namespace : pieceNamespaces) { rl = new ResourceLocation(namespace, key); - if (PsiAPI.isPieceRegistered(rl)) { + if(PsiAPI.isPieceRegistered(rl)) { exists = true; break; } } } - if (exists) { + if(exists) { Class clazz = PsiAPI.getSpellPiece(rl); SpellPiece p = create(clazz, spell); p.readFromNBT(cmp); @@ -618,14 +618,14 @@ public SpellPiece copyFromSpell(Spell spell) { public void readFromNBT(CompoundTag cmp) { CompoundTag paramCmp = cmp.getCompound(TAG_PARAMS); - for (String s : params.keySet()) { + for(String s : params.keySet()) { SpellParam param = params.get(s); String key = s; - if (paramCmp.contains(key)) { + if(paramCmp.contains(key)) { paramSides.put(param, SpellParam.Side.fromInt(paramCmp.getInt(key))); } else { - if (key.startsWith(SpellParam.PSI_PREFIX)) { + if(key.startsWith(SpellParam.PSI_PREFIX)) { key = "_" + key.substring(SpellParam.PSI_PREFIX.length()); } paramSides.put(param, SpellParam.Side.fromInt(paramCmp.getInt(key))); @@ -636,7 +636,7 @@ public void readFromNBT(CompoundTag cmp) { } public void writeToNBT(CompoundTag cmp) { - if (comment == null) { + if(comment == null) { comment = ""; } @@ -644,17 +644,17 @@ public void writeToNBT(CompoundTag cmp) { int paramCount = 0; CompoundTag paramCmp = new CompoundTag(); - for (String s : params.keySet()) { + for(String s : params.keySet()) { SpellParam param = params.get(s); SpellParam.Side side = paramSides.get(param); paramCmp.putInt(s.replaceAll("^" + SpellParam.PSI_PREFIX, "_"), side.asInt()); paramCount++; } - if (paramCount > 0) { + if(paramCount > 0) { cmp.put(TAG_PARAMS, paramCmp); } - if (!comment.isEmpty()) { + if(!comment.isEmpty()) { cmp.putString(TAG_COMMENT, comment); } } diff --git a/src/main/java/vazkii/psi/api/spell/StatLabel.java b/src/main/java/vazkii/psi/api/spell/StatLabel.java index 5c6555af9..7e60ad60c 100644 --- a/src/main/java/vazkii/psi/api/spell/StatLabel.java +++ b/src/main/java/vazkii/psi/api/spell/StatLabel.java @@ -82,7 +82,7 @@ public StatLabel sub(double value) { } public StatLabel times() { - if (order < 2) { + if(order < 2) { parenthesize(); } order = 2; @@ -106,7 +106,7 @@ public StatLabel mul(double value) { } public StatLabel div() { - if (order < 2) { + if(order < 2) { parenthesize(); } order = 2; @@ -247,7 +247,7 @@ private String translate(String str) { private String formatDouble(double value) { String s = String.valueOf(value); - if (s.endsWith(".0")) { + if(s.endsWith(".0")) { s = s.substring(0, s.length() - 2); } return s; diff --git a/src/main/java/vazkii/psi/api/spell/detonator/IDetonationHandler.java b/src/main/java/vazkii/psi/api/spell/detonator/IDetonationHandler.java index 0ee9f13df..06e0f13e8 100644 --- a/src/main/java/vazkii/psi/api/spell/detonator/IDetonationHandler.java +++ b/src/main/java/vazkii/psi/api/spell/detonator/IDetonationHandler.java @@ -65,12 +65,12 @@ static void performDetonation(Level world, Player player, Entity center, double List charges = world.getEntitiesOfClass(Entity.class, center.getBoundingBox().inflate(range), entity -> { - if (entity == null) { + if(entity == null) { return false; } return entity.getCapability(PsiAPI.DETONATION_HANDLER_CAPABILITY).map(detonator -> { Vec3 locus = detonator.objectLocus(); - if (locus == null || locus.distanceToSqr(center.getX(), center.getY(), center.getZ()) > range * range) { + if(locus == null || locus.distanceToSqr(center.getX(), center.getY(), center.getZ()) > range * range) { return false; } return filter == null || filter.test(entity); @@ -81,9 +81,9 @@ static void performDetonation(Level world, Player player, Entity center, double .map(e -> e.getCapability(PsiAPI.DETONATION_HANDLER_CAPABILITY).orElseThrow(NullPointerException::new)) .collect(Collectors.toList()); - if (!MinecraftForge.EVENT_BUS.post(new DetonationEvent(player, center, range, handlers))) { - if (!handlers.isEmpty()) { - for (IDetonationHandler handler : handlers) { + if(!MinecraftForge.EVENT_BUS.post(new DetonationEvent(player, center, range, handlers))) { + if(!handlers.isEmpty()) { + for(IDetonationHandler handler : handlers) { handler.detonate(); } } diff --git a/src/main/java/vazkii/psi/api/spell/piece/PieceCraftingTrick.java b/src/main/java/vazkii/psi/api/spell/piece/PieceCraftingTrick.java index 070e45335..5895fc502 100644 --- a/src/main/java/vazkii/psi/api/spell/piece/PieceCraftingTrick.java +++ b/src/main/java/vazkii/psi/api/spell/piece/PieceCraftingTrick.java @@ -27,7 +27,7 @@ public PieceCraftingTrick(Spell spell) { @Override public Object execute(SpellContext context) throws SpellRuntimeException { ItemStack cad = PsiAPI.getPlayerCAD(context.caster); - if (cad.getItem() instanceof ItemCAD) { + if(cad.getItem() instanceof ItemCAD) { ((ItemCAD) cad.getItem()).craft(cad, context.caster, this); } return null; diff --git a/src/main/java/vazkii/psi/api/spell/piece/PieceTrick.java b/src/main/java/vazkii/psi/api/spell/piece/PieceTrick.java index 583a51b62..023c0619f 100644 --- a/src/main/java/vazkii/psi/api/spell/piece/PieceTrick.java +++ b/src/main/java/vazkii/psi/api/spell/piece/PieceTrick.java @@ -54,9 +54,9 @@ public Object execute(SpellContext context) throws SpellRuntimeException { public double multiplySafe(double v1, double... arr) throws SpellCompilationException { double a = v1; - for (double b : arr) { + for(double b : arr) { a = a * b; - if ((int) a < 0 || (int) a == Integer.MAX_VALUE) { + if((int) a < 0 || (int) a == Integer.MAX_VALUE) { throw new SpellCompilationException(SpellCompilationException.STAT_OVERFLOW); } } diff --git a/src/main/java/vazkii/psi/api/spell/wrapper/EntityListWrapper.java b/src/main/java/vazkii/psi/api/spell/wrapper/EntityListWrapper.java index 8575597d1..66da59b78 100644 --- a/src/main/java/vazkii/psi/api/spell/wrapper/EntityListWrapper.java +++ b/src/main/java/vazkii/psi/api/spell/wrapper/EntityListWrapper.java @@ -37,8 +37,8 @@ private EntityListWrapper(@Nonnull List list) { */ public static EntityListWrapper make(@Nonnull List list) { List copy = new ArrayList<>(); - for (Entity e : list) { - if (e != null) { + for(Entity e : list) { + if(e != null) { copy.add(e); } } @@ -50,9 +50,9 @@ public static EntityListWrapper union(@Nonnull EntityListWrapper left, @Nonnull List l1 = left.list, l2 = right.list; List entities = new ArrayList<>(l1.size() + l2.size()); int i = 0, j = 0; - while (i < l1.size() && j < l2.size()) { + while(i < l1.size() && j < l2.size()) { int cmp = compareEntities(l1.get(i), l2.get(j)); - if (cmp == 0) { + if(cmp == 0) { i++; continue; } @@ -66,8 +66,8 @@ public static EntityListWrapper union(@Nonnull EntityListWrapper left, @Nonnull public static EntityListWrapper exclusion(@Nonnull EntityListWrapper list, @Nonnull EntityListWrapper remove) { List result = new ArrayList<>(); List search = remove.list; - for (Entity e : list) { - if (Collections.binarySearch(search, e, EntityListWrapper::compareEntities) < 0) { + for(Entity e : list) { + if(Collections.binarySearch(search, e, EntityListWrapper::compareEntities) < 0) { result.add(e); } } @@ -78,8 +78,8 @@ public static EntityListWrapper exclusion(@Nonnull EntityListWrapper list, @Nonn public static EntityListWrapper intersection(@Nonnull EntityListWrapper left, @Nonnull EntityListWrapper right) { List result = new ArrayList<>(); List search = right.list; - for (Entity e : left) { - if (Collections.binarySearch(search, e, EntityListWrapper::compareEntities) >= 0) { + for(Entity e : left) { + if(Collections.binarySearch(search, e, EntityListWrapper::compareEntities) >= 0) { result.add(e); } } @@ -91,7 +91,7 @@ public static EntityListWrapper intersection(@Nonnull EntityListWrapper left, @N public static EntityListWrapper withAdded(@Nonnull EntityListWrapper base, @Nonnull Entity toAdd) { List list = new ArrayList<>(base.list); int index = Collections.binarySearch(list, toAdd, EntityListWrapper::compareEntities); - if (index < 0) { + if(index < 0) { list.add(~index, toAdd); } return new EntityListWrapper(list); diff --git a/src/main/java/vazkii/psi/client/core/handler/BookSoundHandler.java b/src/main/java/vazkii/psi/client/core/handler/BookSoundHandler.java index 6909e037f..b85b2229d 100644 --- a/src/main/java/vazkii/psi/client/core/handler/BookSoundHandler.java +++ b/src/main/java/vazkii/psi/client/core/handler/BookSoundHandler.java @@ -43,11 +43,11 @@ private static boolean isBookOpen() { @SubscribeEvent public static void clientTick(TickEvent.ClientTickEvent evt) { - if (bookTime > 0) { + if(bookTime > 0) { bookTime--; } - if (!isBookOpen()) { + if(!isBookOpen()) { nextLetter = 0; } } @@ -55,10 +55,10 @@ public static void clientTick(TickEvent.ClientTickEvent evt) { @SubscribeEvent public static void handleInput(InputEvent.Key evt) { Minecraft mc = Minecraft.getInstance(); - if (evt.getModifiers() == 0 && evt.getAction() == GLFW.GLFW_PRESS && isBookOpen()) { - if (bookTime == 0 && evt.getKey() == SECRET_CODE[nextLetter]) { + if(evt.getModifiers() == 0 && evt.getAction() == GLFW.GLFW_PRESS && isBookOpen()) { + if(bookTime == 0 && evt.getKey() == SECRET_CODE[nextLetter]) { nextLetter++; - if (nextLetter >= SECRET_CODE.length) { + if(nextLetter >= SECRET_CODE.length) { mc.getSoundManager().play(SimpleSoundInstance.forUI(PsiSoundHandler.book, 1.0F)); nextLetter = 0; bookTime = 320; diff --git a/src/main/java/vazkii/psi/client/core/handler/ClientTickHandler.java b/src/main/java/vazkii/psi/client/core/handler/ClientTickHandler.java index 93af2c6f4..db76e4e9f 100644 --- a/src/main/java/vazkii/psi/client/core/handler/ClientTickHandler.java +++ b/src/main/java/vazkii/psi/client/core/handler/ClientTickHandler.java @@ -44,7 +44,7 @@ private static void calcDelta() { @SubscribeEvent @OnlyIn(Dist.CLIENT) public static void renderTick(TickEvent.RenderTickEvent event) { - if (event.phase == TickEvent.Phase.START) { + if(event.phase == TickEvent.Phase.START) { partialTicks = event.renderTickTime; } else { calcDelta(); @@ -56,25 +56,25 @@ public static void clientTick(TickEvent.ClientTickEvent event) { Minecraft mc = Minecraft.getInstance(); - if (event.phase == TickEvent.Phase.START) { + if(event.phase == TickEvent.Phase.START) { boolean pressed = mc.options.keyJump.consumeClick(); - if (mc.player != null && pressed && (!lastJumpKeyState && !mc.player.isOnGround())) { + if(mc.player != null && pressed && (!lastJumpKeyState && !mc.player.isOnGround())) { PsiArmorEvent.post(new PsiArmorEvent(mc.player, PsiArmorEvent.JUMP)); MessageRegister.HANDLER.sendToServer(new MessageTriggerJumpSpell()); } lastJumpKeyState = pressed; } - if (event.phase == TickEvent.Phase.END) { + if(event.phase == TickEvent.Phase.END) { HUDHandler.tick(); Screen gui = mc.screen; - if (gui == null && KeybindHandler.keybind.isDown()) { + if(gui == null && KeybindHandler.keybind.isDown()) { KeybindHandler.keyDown(); } - if (!mc.isPaused()) { + if(!mc.isPaused()) { ++ticksInGame; partialTicks = 0.0F; } diff --git a/src/main/java/vazkii/psi/client/core/handler/ColorHandler.java b/src/main/java/vazkii/psi/client/core/handler/ColorHandler.java index 044dfe257..db948ac71 100644 --- a/src/main/java/vazkii/psi/client/core/handler/ColorHandler.java +++ b/src/main/java/vazkii/psi/client/core/handler/ColorHandler.java @@ -38,7 +38,7 @@ public static int slideColor(int[] color, float speed) { double t = (ClientTickHandler.total * speed * n / Math.PI) % n; int phase = (int) t; double dt = t - phase; - if (dt == 0) { + if(dt == 0) { return color[phase]; } int nextPhase = (phase + 1) % n; @@ -70,9 +70,9 @@ public static int pulseColor(int source, float multiplier, float speed, int magn public static int slideColorTime(int color, int secondColor, float t) { float shift = (1 - Mth.cos(t)) / 2; - if (shift == 0) { + if(shift == 0) { return color; - } else if (shift == 1) { + } else if(shift == 1) { return secondColor; } diff --git a/src/main/java/vazkii/psi/client/core/handler/HUDHandler.java b/src/main/java/vazkii/psi/client/core/handler/HUDHandler.java index 08cfc9024..784189d72 100644 --- a/src/main/java/vazkii/psi/client/core/handler/HUDHandler.java +++ b/src/main/java/vazkii/psi/client/core/handler/HUDHandler.java @@ -65,25 +65,25 @@ public final class HUDHandler { private static int remainingCount; public static final IGuiOverlay PSI_BAR = (gui, poseStack, partialTick, screenWidth, screenHeight) -> { - if (!MinecraftForge.EVENT_BUS.post(new RenderPsiHudEvent(PsiHudElementType.PSI_BAR))) { + if(!MinecraftForge.EVENT_BUS.post(new RenderPsiHudEvent(PsiHudElementType.PSI_BAR))) { drawPsiBar(poseStack, partialTick, screenWidth, screenHeight); } }; public static final IGuiOverlay SOCKETABLE_EQUIPPED_NAME = (gui, poseStack, partialTick, screenWidth, screenHeight) -> { - if (!MinecraftForge.EVENT_BUS.post(new RenderPsiHudEvent(PsiHudElementType.SOCKETABLE_EQUIPPED_NAME))) { + if(!MinecraftForge.EVENT_BUS.post(new RenderPsiHudEvent(PsiHudElementType.SOCKETABLE_EQUIPPED_NAME))) { renderSocketableEquippedName(poseStack, partialTick, screenWidth, screenHeight); } }; public static final IGuiOverlay REMAINING_ITEMS = (gui, poseStack, partialTick, screenWidth, screenHeight) -> { - if (!MinecraftForge.EVENT_BUS.post(new RenderPsiHudEvent(PsiHudElementType.REMAINING_ITEMS))) { + if(!MinecraftForge.EVENT_BUS.post(new RenderPsiHudEvent(PsiHudElementType.REMAINING_ITEMS))) { renderRemainingItems(poseStack, partialTick, screenWidth, screenHeight); } }; public static final IGuiOverlay HUD_ITEM = (gui, poseStack, partialTick, screenWidth, screenHeight) -> { - if (!MinecraftForge.EVENT_BUS.post(new RenderPsiHudEvent(PsiHudElementType.HUD_ITEM))) { + if(!MinecraftForge.EVENT_BUS.post(new RenderPsiHudEvent(PsiHudElementType.HUD_ITEM))) { renderHUDItem(poseStack, partialTick, screenWidth, screenHeight); } }; @@ -99,13 +99,13 @@ public static void register(RegisterGuiOverlaysEvent event) { public static void tick() { - if (remainingTime > 0) { + if(remainingTime > 0) { --remainingTime; } } private static boolean showsBar(PlayerData data, ItemStack stack) { - if (stack.isEmpty()) { + if(stack.isEmpty()) { return false; } else { return stack.getCapability(PsiAPI.PSI_BAR_DISPLAY_CAPABILITY).map(c -> c.shouldShow(data)).orElse(false); @@ -117,7 +117,7 @@ public static void drawPsiBar(PoseStack poseStack, float partialTick, int screen Minecraft mc = Minecraft.getInstance(); ItemStack cadStack = PsiAPI.getPlayerCAD(mc.player); - if (cadStack.isEmpty()) { + if(cadStack.isEmpty()) { return; } @@ -127,7 +127,7 @@ public static void drawPsiBar(PoseStack poseStack, float partialTick, int screen int totalPsi = data.getTotalPsi(); int currPsi = data.getAvailablePsi(); - if (ConfigHandler.CLIENT.contextSensitiveBar.get() && currPsi == totalPsi && + if(ConfigHandler.CLIENT.contextSensitiveBar.get() && currPsi == totalPsi && !showsBar(data, mc.player.getMainHandItem()) && !showsBar(data, mc.player.getOffhandItem())) { return; @@ -142,12 +142,12 @@ public static void drawPsiBar(PoseStack poseStack, float partialTick, int screen int height = 140; int x = -pad; - if (right) { + if(right) { x = screenWidth + pad - width; } int y = screenHeight / 2 - height / 2; - if (!registeredMask) { + if(!registeredMask) { RenderSystem.setShaderTexture(0, psiBarMask); RenderSystem.setShaderTexture(1, psiBarShatter); registeredMask = true; @@ -167,7 +167,7 @@ public static void drawPsiBar(PoseStack poseStack, float partialTick, int screen float g = 0.65F; float b = 1F; - if (data.isOverflowed()) { + if(data.isOverflowed()) { r = 1F; g = 0.6F; b = 0.6F; @@ -180,7 +180,7 @@ public static void drawPsiBar(PoseStack poseStack, float partialTick, int screen int texture = 0; boolean shaders = ShaderHandler.useShaders; - if (shaders) { + if(shaders) { RenderSystem.activeTexture(ARBMultitexture.GL_TEXTURE0_ARB + secondaryTextureUnit); texture = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D); } @@ -188,7 +188,7 @@ public static void drawPsiBar(PoseStack poseStack, float partialTick, int screen RenderSystem.enableBlend(); RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - for (Deduction d : data.deductions) { + for(Deduction d : data.deductions) { float a = d.getPercentile(partialTick); RenderSystem.setShaderColor(r, g, b, a); height = (int) Math.ceil(origHeight * (double) d.deduct / totalPsi); @@ -201,12 +201,12 @@ public static void drawPsiBar(PoseStack poseStack, float partialTick, int screen } float textY = origY; - if (totalPsi > 0) { + if(totalPsi > 0) { height = (int) ((double) origHeight * (double) data.availablePsi / totalPsi); v = origHeight - height; y = origY + v; - if (data.availablePsi != data.lastAvailablePsi) { + if(data.availablePsi != data.lastAvailablePsi) { float textHeight = (float) (origHeight * (data.availablePsi * partialTick + data.lastAvailablePsi * (1.0 - partialTick)) / totalPsi); textY = origY + (origHeight - textHeight); @@ -222,7 +222,7 @@ public static void drawPsiBar(PoseStack poseStack, float partialTick, int screen GuiComponent.blit(poseStack, x, y, 32, v, width, height, 64, 256); ShaderHandler.releaseShader(); - if (shaders) { + if(shaders) { RenderSystem.activeTexture(ARBMultitexture.GL_TEXTURE0_ARB + secondaryTextureUnit); RenderSystem.bindTexture(texture); RenderSystem.activeTexture(ARBMultitexture.GL_TEXTURE0_ARB); @@ -244,7 +244,7 @@ public static void drawPsiBar(PoseStack poseStack, float partialTick, int screen int offStr1 = 7 + mc.font.width(s1); int offStr2 = 7 + mc.font.width(s2); - if (!right) { + if(!right) { offBar = 6; offStr1 = -23; offStr2 = -23; @@ -259,7 +259,7 @@ public static void drawPsiBar(PoseStack poseStack, float partialTick, int screen mc.font.drawShadow(poseStack, s1, x - offStr1, -11, 0xFFFFFF); poseStack.popPose(); - if (storedPsi != -1) { + if(storedPsi != -1) { poseStack.pushPose(); poseStack.translate(0F, Math.max(textY + 3, origY + 100), 0F); mc.font.drawShadow(poseStack, s2, x - offStr2, 0, 0xFFFFFF); @@ -273,18 +273,18 @@ public static void drawPsiBar(PoseStack poseStack, float partialTick, int screen private static void renderSocketableEquippedName(PoseStack poseStack, float partialTick, int screenWidth, int screenHeight) { Minecraft mc = Minecraft.getInstance(); ItemStack stack = mc.player.getItemInHand(InteractionHand.MAIN_HAND); - if (!ISocketable.isSocketable(stack)) { + if(!ISocketable.isSocketable(stack)) { return; } String name = ISocketable.getSocketedItemName(stack, "").getString(); - if (stack.isEmpty() || name.trim().isEmpty()) { + if(stack.isEmpty() || name.trim().isEmpty()) { return; } int ticks = mc.gui.toolHighlightTimer; ticks -= 10; - if (ticks > 0) { + if(ticks > 0) { ISocketable socketable = ISocketable.socketable(stack); ItemStack bullet = socketable.getSelectedBullet(); @@ -293,7 +293,7 @@ private static void renderSocketableEquippedName(PoseStack poseStack, float part int x = screenWidth / 2 - mc.font.width(name) / 2; int y = screenHeight - 71; - if (mc.player.isCreative()) { + if(mc.player.isCreative()) { y += 14; } @@ -310,7 +310,7 @@ private static void renderSocketableEquippedName(PoseStack poseStack, float part @OnlyIn(Dist.CLIENT) private static void renderRemainingItems(PoseStack poseStack, float partialTick, int screenWidth, int screenHeight) { - if (remainingTime > 0 && !remainingDisplayStack.isEmpty()) { + if(remainingTime > 0 && !remainingDisplayStack.isEmpty()) { int pos = maxRemainingTicks - remainingTime; Minecraft mc = Minecraft.getInstance(); int remainingLeaveTicks = 20; @@ -331,19 +331,19 @@ private static void renderRemainingItems(PoseStack poseStack, float partialTick, RenderSystem.setShaderColor(1F, 1F, 1F, 1F); String text = remainingDisplayStack.getHoverName().plainCopy().withStyle(ChatFormatting.GREEN).getString(); - if (remainingCount >= 0) { + if(remainingCount >= 0) { int max = remainingDisplayStack.getMaxStackSize(); int stacks = remainingCount / max; int rem = remainingCount % max; - if (stacks == 0) { + if(stacks == 0) { text = "" + remainingCount; } else { text = remainingCount + " (" + ChatFormatting.AQUA + stacks + ChatFormatting.RESET + "*" + ChatFormatting.GRAY + max + ChatFormatting.RESET + "+" + ChatFormatting.YELLOW + rem + ChatFormatting.RESET + ")"; } - } else if (remainingCount == -1) { + } else if(remainingCount == -1) { text = "\u221E"; } @@ -358,12 +358,12 @@ private static void renderRemainingItems(PoseStack poseStack, float partialTick, private static void renderHUDItem(PoseStack poseStack, float partialTicks, int screenWidth, int screenHeight) { Minecraft mc = Minecraft.getInstance(); ItemStack stack = mc.player.getMainHandItem(); - if (!stack.isEmpty() && stack.getItem() instanceof IHUDItem) { + if(!stack.isEmpty() && stack.getItem() instanceof IHUDItem) { ((IHUDItem) stack.getItem()).drawHUD(poseStack, partialTicks, screenWidth, screenHeight, stack); } stack = mc.player.getOffhandItem(); - if (!stack.isEmpty() && stack.getItem() instanceof IHUDItem) { + if(!stack.isEmpty() && stack.getItem() instanceof IHUDItem) { ((IHUDItem) stack.getItem()).drawHUD(poseStack, partialTicks, screenWidth, screenHeight, stack); } } @@ -376,9 +376,9 @@ public static void setRemaining(ItemStack stack, int count) { public static void setRemaining(Player player, ItemStack displayStack, Pattern pattern) { int count = 0; - for (int i = 0; i < player.getInventory().getContainerSize(); i++) { + for(int i = 0; i < player.getInventory().getContainerSize(); i++) { ItemStack stack = player.getInventory().getItem(i); - if (!stack.isEmpty() && (pattern == null ? ItemStack.isSame(displayStack, stack) : pattern.matcher(stack.getDescriptionId()).find())) { + if(!stack.isEmpty() && (pattern == null ? ItemStack.isSame(displayStack, stack) : pattern.matcher(stack.getDescriptionId()).find())) { count += stack.getCount(); } } diff --git a/src/main/java/vazkii/psi/client/core/handler/KeybindHandler.java b/src/main/java/vazkii/psi/client/core/handler/KeybindHandler.java index 62840d203..8a89d676b 100644 --- a/src/main/java/vazkii/psi/client/core/handler/KeybindHandler.java +++ b/src/main/java/vazkii/psi/client/core/handler/KeybindHandler.java @@ -8,8 +8,6 @@ */ package vazkii.psi.client.core.handler; -import static org.lwjgl.glfw.GLFW.GLFW_KEY_C; - import net.minecraft.client.KeyMapping; import net.minecraft.client.Minecraft; import net.minecraft.world.InteractionHand; @@ -21,6 +19,7 @@ import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus; + import vazkii.patchouli.api.PatchouliAPI; import vazkii.psi.api.cad.ISocketable; import vazkii.psi.api.cad.ISocketableController; @@ -28,6 +27,8 @@ import vazkii.psi.common.lib.LibMisc; import vazkii.psi.common.lib.LibResources; +import static org.lwjgl.glfw.GLFW.GLFW_KEY_C; + @Mod.EventBusSubscriber(value = Dist.CLIENT, modid = LibMisc.MOD_ID, bus = Bus.MOD) @OnlyIn(Dist.CLIENT) public class KeybindHandler { @@ -40,14 +41,14 @@ public static void register(RegisterKeyMappingsEvent event) { } private static boolean isSocketableController(Player player, ItemStack stack) { - if (!(stack.getItem() instanceof ISocketableController)) { + if(!(stack.getItem() instanceof ISocketableController)) { return false; } ItemStack[] stacks = ((ISocketableController) stack.getItem()).getControlledStacks(player, stack); - for (ItemStack controlled : stacks) { - if (!controlled.isEmpty() && ISocketable.isSocketable(controlled)) { + for(ItemStack controlled : stacks) { + if(!controlled.isEmpty() && ISocketable.isSocketable(controlled)) { return true; } } @@ -59,12 +60,12 @@ public static void keyDown() { Minecraft mc = Minecraft.getInstance(); ItemStack stack = mc.player.getItemInHand(InteractionHand.MAIN_HAND); - if (mc.screen == null) { - if (!stack.isEmpty() && (ISocketable.isSocketable(stack) || isSocketableController(mc.player, stack))) { + if(mc.screen == null) { + if(!stack.isEmpty() && (ISocketable.isSocketable(stack) || isSocketableController(mc.player, stack))) { mc.setScreen(new GuiSocketSelect(stack)); } else { stack = mc.player.getItemInHand(InteractionHand.OFF_HAND); - if (!stack.isEmpty() && (ISocketable.isSocketable(stack) || isSocketableController(mc.player, stack))) { + if(!stack.isEmpty() && (ISocketable.isSocketable(stack) || isSocketableController(mc.player, stack))) { mc.setScreen(new GuiSocketSelect(stack)); } else { PatchouliAPI.get().openBookGUI(LibResources.PATCHOULI_BOOK); diff --git a/src/main/java/vazkii/psi/client/core/handler/ShaderHandler.java b/src/main/java/vazkii/psi/client/core/handler/ShaderHandler.java index 41cc11a5a..8c9c6fb4d 100644 --- a/src/main/java/vazkii/psi/client/core/handler/ShaderHandler.java +++ b/src/main/java/vazkii/psi/client/core/handler/ShaderHandler.java @@ -44,7 +44,7 @@ public final class ShaderHandler { public static void init() { useShaders = canUseShaders(); - if (!useShaders) { + if(!useShaders) { return; } Psi.logger.info("Initializing Psi shaders!"); @@ -55,17 +55,17 @@ public static void init() { } public static void useShader(int shader, Consumer callback) { - if (!useShaders) { + if(!useShaders) { return; } ARBShaderObjects.glUseProgramObjectARB(shader); - if (shader != 0) { + if(shader != 0) { int time = ARBShaderObjects.glGetUniformLocationARB(shader, "time"); ARBShaderObjects.glUniform1iARB(time, ClientTickHandler.ticksInGame); - if (callback != null) { + if(callback != null) { callback.accept(shader); } } @@ -97,33 +97,33 @@ private static int createProgram(String s, int sides) { private static int createProgram(String vert, String frag) { int vertId = 0, fragId = 0, program; - if (vert != null) { + if(vert != null) { vertId = createShader(vert, VERT_ST); } - if (frag != null) { + if(frag != null) { fragId = createShader(frag, FRAG_ST); } program = ARBShaderObjects.glCreateProgramObjectARB(); - if (program == 0) { + if(program == 0) { return 0; } - if (vert != null) { + if(vert != null) { ARBShaderObjects.glAttachObjectARB(program, vertId); } - if (frag != null) { + if(frag != null) { ARBShaderObjects.glAttachObjectARB(program, fragId); } ARBShaderObjects.glLinkProgramARB(program); - if (ARBShaderObjects.glGetObjectParameteriARB(program, ARBShaderObjects.GL_OBJECT_LINK_STATUS_ARB) == GL11.GL_FALSE) { + if(ARBShaderObjects.glGetObjectParameteriARB(program, ARBShaderObjects.GL_OBJECT_LINK_STATUS_ARB) == GL11.GL_FALSE) { Psi.logger.error(getLogInfo(program)); return 0; } ARBShaderObjects.glValidateProgramARB(program); - if (ARBShaderObjects.glGetObjectParameteriARB(program, ARBShaderObjects.GL_OBJECT_VALIDATE_STATUS_ARB) == GL11.GL_FALSE) { + if(ARBShaderObjects.glGetObjectParameteriARB(program, ARBShaderObjects.GL_OBJECT_VALIDATE_STATUS_ARB) == GL11.GL_FALSE) { Psi.logger.error(getLogInfo(program)); return 0; } @@ -136,14 +136,14 @@ private static int createShader(String filename, int shaderType) { try { shader = ARBShaderObjects.glCreateShaderObjectARB(shaderType); - if (shader == 0) { + if(shader == 0) { return 0; } ARBShaderObjects.glShaderSourceARB(shader, readFileAsString(filename)); ARBShaderObjects.glCompileShaderARB(shader); - if (ARBShaderObjects.glGetObjectParameteriARB(shader, ARBShaderObjects.GL_OBJECT_COMPILE_STATUS_ARB) == GL11.GL_FALSE) { + if(ARBShaderObjects.glGetObjectParameteriARB(shader, ARBShaderObjects.GL_OBJECT_COMPILE_STATUS_ARB) == GL11.GL_FALSE) { throw new RuntimeException("Error creating shader: " + getLogInfo(shader)); } @@ -161,7 +161,7 @@ private static String getLogInfo(int obj) { private static String readFileAsString(String filename) throws Exception { try (InputStream in = ShaderHandler.class.getResourceAsStream(filename)) { - if (in == null) { + if(in == null) { return ""; } diff --git a/src/main/java/vazkii/psi/client/core/helper/SharingHelper.java b/src/main/java/vazkii/psi/client/core/helper/SharingHelper.java index 9d75e35c8..586628c98 100644 --- a/src/main/java/vazkii/psi/client/core/helper/SharingHelper.java +++ b/src/main/java/vazkii/psi/client/core/helper/SharingHelper.java @@ -91,7 +91,7 @@ public static String uploadImage(String title, String export) { HttpResponse res = client.execute(post); JsonObject resJson = new JsonParser().parse(EntityUtils.toString(res.getEntity())).getAsJsonObject(); - if (resJson.has("success") && resJson.get("success").getAsBoolean()) { + if(resJson.has("success") && resJson.get("success").getAsBoolean()) { JsonObject data = resJson.get("data").getAsJsonObject(); String id = data.get("id").getAsString(); diff --git a/src/main/java/vazkii/psi/client/core/helper/TextHelper.java b/src/main/java/vazkii/psi/client/core/helper/TextHelper.java index 8b20d1900..0affbf89e 100644 --- a/src/main/java/vazkii/psi/client/core/helper/TextHelper.java +++ b/src/main/java/vazkii/psi/client/core/helper/TextHelper.java @@ -31,17 +31,17 @@ public static List renderText(int x, int y, int width, String unlocalize List> lines = new ArrayList<>(); String controlCodes; - for (String s : textEntries) { + for(String s : textEntries) { List words = new ArrayList<>(); String lineStr = ""; String[] tokens = s.split(" "); - for (String token : tokens) { + for(String token : tokens) { String prev = lineStr; String spaced = token + " "; lineStr += spaced; controlCodes = toControlCodes(getControlCodes(prev)); - if (font.width(lineStr) > width) { + if(font.width(lineStr) > width) { lines.add(words); lineStr = controlCodes + spaced; words = new ArrayList<>(); @@ -50,7 +50,7 @@ public static List renderText(int x, int y, int width, String unlocalize words.add(controlCodes + token); } - if (!lineStr.isEmpty()) { + if(!lineStr.isEmpty()) { lines.add(words); } lines.add(new ArrayList<>()); @@ -59,18 +59,18 @@ public static List renderText(int x, int y, int width, String unlocalize List textLines = new ArrayList<>(); String lastLine = ""; - for (List words : lines) { + for(List words : lines) { words.size(); int xi = x; int spacing = 4; StringBuilder lineStr = new StringBuilder(); - for (String s : words) { + for(String s : words) { int extra = 0; int swidth = font.width(s); - if (doit) { - if (centered) { + if(doit) { + if(centered) { font.draw(matrixStack, s, xi + width / 2 - swidth / 2, y, 0xFFFFFF); } else { font.draw(matrixStack, s, xi, y, 0xFFFFFF); @@ -80,7 +80,7 @@ public static List renderText(int x, int y, int width, String unlocalize lineStr.append(s).append(" "); } - if ((lineStr.length() > 0) || lastLine.isEmpty()) { + if((lineStr.length() > 0) || lastLine.isEmpty()) { y += 10; textLines.add(lineStr.toString()); } diff --git a/src/main/java/vazkii/psi/client/core/proxy/ClientProxy.java b/src/main/java/vazkii/psi/client/core/proxy/ClientProxy.java index c03329111..778384c22 100644 --- a/src/main/java/vazkii/psi/client/core/proxy/ClientProxy.java +++ b/src/main/java/vazkii/psi/client/core/proxy/ClientProxy.java @@ -115,10 +115,10 @@ private void addCADModels(ModelEvent.RegisterAdditional event) { @Override public boolean hasAdvancement(ResourceLocation advancement, Player playerEntity) { - if (playerEntity instanceof LocalPlayer) { + if(playerEntity instanceof LocalPlayer) { LocalPlayer clientPlayerEntity = (LocalPlayer) playerEntity; return clientPlayerEntity.connection.getAdvancements().getAdvancements().get(advancement) != null; - } else if (playerEntity instanceof ServerPlayer) { + } else if(playerEntity instanceof ServerPlayer) { ServerPlayer serverPlayerEntity = (ServerPlayer) playerEntity; return serverPlayerEntity.getServer().getAdvancements().getAdvancement(advancement) != null && serverPlayerEntity.getAdvancements().getOrStartProgress(serverPlayerEntity.getServer().getAdvancements().getAdvancement(advancement)).isDone(); } @@ -158,7 +158,7 @@ public int getColorForCAD(ItemStack cadStack) { @Override public int getColorForColorizer(ItemStack colorizer) { - if (colorizer.isEmpty() || !(colorizer.getItem() instanceof ICADColorizer)) { + if(colorizer.isEmpty() || !(colorizer.getItem() instanceof ICADColorizer)) { return ICADColorizer.DEFAULT_SPELL_COLOR; } ICADColorizer icc = (ICADColorizer) colorizer.getItem(); @@ -167,7 +167,7 @@ public int getColorForColorizer(ItemStack colorizer) { @Override public void sparkleFX(Level world, double x, double y, double z, float r, float g, float b, float motionx, float motiony, float motionz, float size, int m) { - if (m == 0) { + if(m == 0) { return; } SparkleParticleData data = new SparkleParticleData(size, r, g, b, m, motionx, motiony, motionz); @@ -182,7 +182,7 @@ public void sparkleFX(double x, double y, double z, float r, float g, float b, f @Override public void wispFX(Level world, double x, double y, double z, float r, float g, float b, float size, float motionx, float motiony, float motionz, float maxAgeMul) { - if (maxAgeMul == 0) { + if(maxAgeMul == 0) { return; } WispParticleData data = new WispParticleData(size, r, g, b, maxAgeMul); diff --git a/src/main/java/vazkii/psi/client/fx/FXSparkle.java b/src/main/java/vazkii/psi/client/fx/FXSparkle.java index a49654911..64d42166b 100644 --- a/src/main/java/vazkii/psi/client/fx/FXSparkle.java +++ b/src/main/java/vazkii/psi/client/fx/FXSparkle.java @@ -70,10 +70,10 @@ public void tick() { yo = y; zo = z; - if (age++ >= lifetime) { + if(age++ >= lifetime) { remove(); } -// if (!noClip) +// if(!noClip) // pushOutOfBlocks(posX, (getEntityBoundingBox().minY + getEntityBoundingBox().maxY) / 2.0D, posZ); x += xd; @@ -84,7 +84,7 @@ public void tick() { yd *= 0.9f; zd *= 0.9f; - if (onGround) { + if(onGround) { xd *= 0.7f; zd *= 0.7f; } diff --git a/src/main/java/vazkii/psi/client/fx/FXWisp.java b/src/main/java/vazkii/psi/client/fx/FXWisp.java index e798ffa01..a8f6ce620 100644 --- a/src/main/java/vazkii/psi/client/fx/FXWisp.java +++ b/src/main/java/vazkii/psi/client/fx/FXWisp.java @@ -60,7 +60,7 @@ public FXWisp(ClientLevel world, double d, double d1, double d2, double xSpeed, @Override public float getQuadSize(float scaleFactor) { float agescale = (float) age / (float) moteHalfLife; - if (agescale > 1F) { + if(agescale > 1F) { agescale = 2 - agescale; } @@ -86,7 +86,7 @@ public void tick() { this.yo = this.y; this.zo = this.z; - if (this.age++ >= this.lifetime) { + if(this.age++ >= this.lifetime) { this.remove(); } diff --git a/src/main/java/vazkii/psi/client/gui/GuiCADAssembler.java b/src/main/java/vazkii/psi/client/gui/GuiCADAssembler.java index 6134b815a..5ec604da0 100644 --- a/src/main/java/vazkii/psi/client/gui/GuiCADAssembler.java +++ b/src/main/java/vazkii/psi/client/gui/GuiCADAssembler.java @@ -59,7 +59,7 @@ protected void renderLabels(PoseStack ms, int mouseX, int mouseY) { font.draw(ms, name, imageWidth / 2 - font.width(name) / 2, 10, color); ItemStack cad = assembler.getCachedCAD(player); - if (!cad.isEmpty()) { + if(!cad.isEmpty()) { color = 0xFFFFFF; int i = 0; @@ -68,7 +68,7 @@ protected void renderLabels(PoseStack ms, int mouseX, int mouseY) { String s = ChatFormatting.BOLD + stats; font.drawShadow(ms, s, 213 - font.width(s) / 2f, 32, color); - for (EnumCADStat stat : EnumCADStat.class.getEnumConstants()) { + for(EnumCADStat stat : EnumCADStat.class.getEnumConstants()) { s = (Psi.magical ? ChatFormatting.LIGHT_PURPLE : ChatFormatting.AQUA) + I18n.get(stat.getName()) + ChatFormatting.RESET + ": " + cadItem.getStatValue(cad, stat); font.drawShadow(ms, s, 179, 45 + i * 10, color); i++; @@ -84,8 +84,8 @@ protected void renderBg(PoseStack ms, float partialTicks, int mouseX, int mouseY int y = (height - imageHeight) / 2; blit(ms, x, y, 0, 0, imageWidth, imageHeight); - for (int i = 0; i < 12; i++) { - if (!assembler.isBulletSlotEnabled(i)) { + for(int i = 0; i < 12; i++) { + if(!assembler.isBulletSlotEnabled(i)) { blit(ms, x + 17 + i % 3 * 18, y + 57 + i / 3 * 18, 16, imageHeight, 16, 16); } } diff --git a/src/main/java/vazkii/psi/client/gui/GuiProgrammer.java b/src/main/java/vazkii/psi/client/gui/GuiProgrammer.java index 666e14ba0..1c40902a0 100644 --- a/src/main/java/vazkii/psi/client/gui/GuiProgrammer.java +++ b/src/main/java/vazkii/psi/client/gui/GuiProgrammer.java @@ -162,7 +162,7 @@ protected void init() { cursorX = cursorY = -1; tooltipFlag = getMinecraft().options.advancedItemTooltips ? TooltipFlag.Default.ADVANCED : TooltipFlag.Default.NORMAL; - if (programmer == null) { + if(programmer == null) { spectator = false; } else { spectator = !programmer.playerLock.isEmpty() && !programmer.playerLock.equals(getMinecraft().player.getName().getString()); @@ -197,10 +197,10 @@ protected void init() { panelWidget.searchField.setVisible(false); panelWidget.searchField.setBordered(false); - if (spell == null) { + if(spell == null) { spell = new Spell(); } - if (programmer != null && programmer.spell == null) { + if(programmer != null && programmer.spell == null) { programmer.spell = spell; } @@ -215,9 +215,9 @@ protected void init() { */ addRenderableWidget(new GuiButtonIO(left + xSize + 2, top + ySize - (spectator ? 16 : 32), true, this, button -> { - if (hasShiftDown()) { + if(hasShiftDown()) { CompoundTag cmp = new CompoundTag(); - if (spell != null) { + if(spell != null) { spell.writeToNBT(cmp); } getMinecraft().keyboardHandler.setClipboard(cmp.toString()); @@ -227,40 +227,40 @@ protected void init() { /* * Import button */ - if (!spectator) { + if(!spectator) { addRenderableWidget(new GuiButtonIO(left + xSize + 2, top + ySize - 16, false, this, button -> { - if (hasShiftDown()) { + if(hasShiftDown()) { String cb = getMinecraft().keyboardHandler.getClipboard(); LocalPlayer player = Minecraft.getInstance().player; try { cb = cb.replaceAll("([^a-z0-9])\\d+:", "$1"); // backwards compatibility with pre 1.12 nbt json CompoundTag cmp = TagParser.parseTag(cb); - if (cmp.contains(Spell.TAG_MODS_REQUIRED)) { + if(cmp.contains(Spell.TAG_MODS_REQUIRED)) { ListTag mods = (ListTag) cmp.get(Spell.TAG_MODS_REQUIRED); - for (Tag mod : mods) { + for(Tag mod : mods) { String modName = ((CompoundTag) mod).getString(Spell.TAG_MOD_NAME); - if (!PsiAPI.getSpellPieceRegistry().keySet().stream().map(ResourceLocation::getNamespace).collect(Collectors.toSet()).contains(modName)) { + if(!PsiAPI.getSpellPieceRegistry().keySet().stream().map(ResourceLocation::getNamespace).collect(Collectors.toSet()).contains(modName)) { player.sendSystemMessage(Component.translatable("psimisc.modnotfound", modName).setStyle(Style.EMPTY.withColor(ChatFormatting.RED))); } - if (modName.equals("psi")) { + if(modName.equals("psi")) { boolean sendMessage = false; String modVersion = ((CompoundTag) mod).getString(Spell.TAG_MOD_VERSION); int[] versionEntry = Arrays.stream(modVersion.replaceFirst("^\\D+", "").split("\\D+")).mapToInt(Integer::parseInt).toArray(); int[] currentVersion = Arrays.stream(ModList.get().getModContainerById("psi").get().getModInfo().getVersion().toString().replaceFirst("^\\D+", "").split("\\D+")).mapToInt(Integer::parseInt).toArray(); - for (int i = 0; i < versionEntry.length; i++) { - if (i + 1 > currentVersion.length) { + for(int i = 0; i < versionEntry.length; i++) { + if(i + 1 > currentVersion.length) { sendMessage = true; break; } - if (currentVersion[i] > versionEntry[i]) { + if(currentVersion[i] > versionEntry[i]) { break; - } else if (currentVersion[i] < versionEntry[i]) { + } else if(currentVersion[i] < versionEntry[i]) { sendMessage = true; break; } } - if (sendMessage) { + if(sendMessage) { player.sendSystemMessage(Component.translatable("psimisc.spellonnewerversion").setStyle(Style.EMPTY.withColor(ChatFormatting.RED))); } } @@ -269,16 +269,16 @@ protected void init() { player.sendSystemMessage(Component.translatable("psimisc.spellmaynotfunctionasintended").setStyle(Style.EMPTY.withColor(ChatFormatting.RED))); } spell = Spell.createFromNBT(cmp); - if (spell == null) { + if(spell == null) { return; } PlayerDataHandler.PlayerData data = PlayerDataHandler.get(player); - for (int i = 0; i < SpellGrid.GRID_SIZE; i++) { - for (int j = 0; j < SpellGrid.GRID_SIZE; j++) { + for(int i = 0; i < SpellGrid.GRID_SIZE; i++) { + for(int j = 0; j < SpellGrid.GRID_SIZE; j++) { SpellPiece piece = spell.grid.gridData[i][j]; - if (piece != null) { + if(piece != null) { ResourceLocation group = PsiAPI.getGroupForPiece(piece.getClass()); - if (!player.isCreative() && (group == null || !data.isPieceGroupUnlocked(group, piece.registryKey))) { + if(!player.isCreative() && (group == null || !data.isPieceGroupUnlocked(group, piece.registryKey))) { player.sendSystemMessage(Component.translatable("psimisc.missing_pieces").setStyle(Style.EMPTY.withColor(ChatFormatting.RED))); return; } @@ -300,7 +300,7 @@ protected void init() { @Override public void render(PoseStack ms, int mouseX, int mouseY, float partialTicks) { - if (programmer != null && (programmer.getLevel().getBlockEntity(programmer.getBlockPos()) != programmer || !programmer.canPlayerInteract(getMinecraft().player))) { + if(programmer != null && (programmer.getLevel().getBlockEntity(programmer.getBlockPos()) != programmer || !programmer.canPlayerInteract(getMinecraft().player))) { getMinecraft().setScreen(null); return; } @@ -318,13 +318,13 @@ public void render(PoseStack ms, int mouseX, int mouseY, float partialTicks) { //Currently selected piece SpellPiece piece = null; - if (SpellGrid.exists(selectedX, selectedY)) { + if(SpellGrid.exists(selectedX, selectedY)) { piece = spell.grid.gridData[selectedX][selectedY]; } cursorX = (mouseX - gridLeft) / 18; cursorY = (mouseY - gridTop) / 18; - if (panelWidget.panelEnabled || cursorX > 8 || cursorY > 8 || cursorX < 0 || cursorY < 0 || mouseX < gridLeft || mouseY < gridTop) { + if(panelWidget.panelEnabled || cursorX > 8 || cursorY > 8 || cursorX < 0 || cursorY < 0 || mouseX < gridLeft || mouseY < gridTop) { cursorX = -1; cursorY = -1; } @@ -338,7 +338,7 @@ public void render(PoseStack ms, int mouseX, int mouseY, float partialTicks) { compileResult.right().ifPresent(ex -> { Pair errorPos = ex.location; - if (errorPos != null && errorPos.getRight() != -1 && errorPos.getLeft() != -1) { + if(errorPos != null && errorPos.getRight() != -1 && errorPos.getLeft() != -1) { font.drawShadow(ms, "!!", errorPos.getLeft() * 18 + 12, errorPos.getRight() * 18 + 8, 0xFF0000); } }); @@ -347,11 +347,11 @@ public void render(PoseStack ms, int mouseX, int mouseY, float partialTicks) { ms.translate(0, 0, 1); RenderSystem.setShaderTexture(0, texture); - if (selectedX != -1 && selectedY != -1 && !takingScreenshot) { + if(selectedX != -1 && selectedY != -1 && !takingScreenshot) { blit(ms, gridLeft + selectedX * 18, gridTop + selectedY * 18, 32, ySize, 16, 16); } - if (hasAltDown()) { + if(hasAltDown()) { tooltip.clear(); cursorX = selectedX; cursorY = selectedY; @@ -359,14 +359,14 @@ public void render(PoseStack ms, int mouseX, int mouseY, float partialTicks) { mouseY = gridTop + cursorY * 18 + 8; } - if (takingScreenshot) { + if(takingScreenshot) { Set addons = spell.getPieceNamespaces().stream().filter(namespace -> !namespace.equals("psi")).collect(Collectors.toSet()); - if (addons.size() > 0) { + if(addons.size() > 0) { String requiredAddons = ChatFormatting.GREEN + "Required Addons:"; font.drawShadow(ms, requiredAddons, left - font.width(requiredAddons) - 5, top + 40, 0xFFFFFF); int i = 1; - for (String addon : addons) { - if (ModList.get().getModContainerById(addon).isPresent()) { + for(String addon : addons) { + if(ModList.get().getModContainerById(addon).isPresent()) { String modName = ModList.get().getModContainerById(addon).get().getModInfo().getDisplayName(); font.drawShadow(ms, "* " + modName, left - font.width(requiredAddons) - 5, top + 40 + 10 * i, 0xFFFFFF); i++; @@ -378,15 +378,15 @@ public void render(PoseStack ms, int mouseX, int mouseY, float partialTicks) { } SpellPiece pieceAtCursor = null; - if (cursorX != -1 && cursorY != -1) { + if(cursorX != -1 && cursorY != -1) { pieceAtCursor = spell.grid.gridData[cursorX][cursorY]; - if (pieceAtCursor != null) { + if(pieceAtCursor != null) { pieceAtCursor.getTooltip(tooltip); comment = pieceAtCursor.comment; } - if (!takingScreenshot) { - if (cursorX == selectedX && cursorY == selectedY) { + if(!takingScreenshot) { + if(cursorX == selectedX && cursorY == selectedY) { blit(ms, gridLeft + cursorX * 18, gridTop + cursorY * 18, 16, ySize, 8, 16); } else { blit(ms, gridLeft + cursorX * 18, gridTop + cursorY * 18, 16, ySize, 16, 16); @@ -396,26 +396,26 @@ public void render(PoseStack ms, int mouseX, int mouseY, float partialTicks) { int topY = top - 22; - if (!takingScreenshot) { + if(!takingScreenshot) { int topYText = topY; - if (spectator) { + if(spectator) { String spectator = ChatFormatting.RED + I18n.get("psimisc.spectator"); font.drawShadow(ms, spectator, left + xSize / 2f - font.width(spectator) / 2f, topYText, 0xFFFFFF); topYText -= 10; } - if (piece != null) { + if(piece != null) { String pieceName = I18n.get(piece.getUnlocalizedName()); font.drawShadow(ms, pieceName, left + xSize / 2f - font.width(pieceName) / 2f, topYText, 0xFFFFFF); topYText -= 10; } - if (LibMisc.BETA_TESTING) { + if(LibMisc.BETA_TESTING) { String betaTest = ChatFormatting.GOLD + I18n.get("psimisc.wip"); font.drawShadow(ms, betaTest, left + xSize / 2f - font.width(betaTest) / 2f, topYText, 0xFFFFFF); } String coords; - if (SpellGrid.exists(cursorX, cursorY)) { + if(SpellGrid.exists(cursorX, cursorY)) { coords = I18n.get("psimisc.programmer_coords", convertIntToLetter(selectedX + 1), selectedY + 1, convertIntToLetter(cursorX + 1), cursorY + 1); } else { coords = I18n.get("psimisc.programmer_coords_no_cursor", convertIntToLetter(selectedX + 1), selectedY + 1); @@ -425,14 +425,14 @@ public void render(PoseStack ms, int mouseX, int mouseY, float partialTicks) { font.drawShadow(ms, version, left + xSize / 2f - font.width(version) / 2f, topY + ySize + 24 + font.wordWrapHeight(coords, font.width(coords)) + 5, 0x44FFFFFF); } - if (Psi.magical) { + if(Psi.magical) { font.draw(ms, I18n.get("psimisc.name"), left + padLeft, spellNameField.y + 1, color); } else { font.drawShadow(ms, I18n.get("psimisc.name"), left + padLeft, spellNameField.y + 1, color); } //Add here comment - if (commentEnabled) { + if(commentEnabled) { String enterCommit = I18n.get("psimisc.enter_commit"); font.drawShadow(ms, enterCommit, left + xSize / 2f - font.width(enterCommit) / 2f, commentField.y + 24, 0xFFFFFF); @@ -441,25 +441,25 @@ public void render(PoseStack ms, int mouseX, int mouseY, float partialTicks) { } List legitTooltip = null; - if (hasAltDown()) { + if(hasAltDown()) { legitTooltip = new ArrayList<>(tooltip); } - if (hasAltDown()) { + if(hasAltDown()) { tooltip = legitTooltip; } super.render(ms, mouseX, mouseY, partialTicks); - if (!takingScreenshot && tooltip != null && !tooltip.isEmpty() && pieceAtCursor == null && mouseMoved) { + if(!takingScreenshot && tooltip != null && !tooltip.isEmpty() && pieceAtCursor == null && mouseMoved) { this.renderComponentTooltip(ms, tooltip, mouseX, mouseY); } - if (!takingScreenshot && pieceAtCursor != null && mouseMoved) { - if (tooltip != null && !tooltip.isEmpty()) { + if(!takingScreenshot && pieceAtCursor != null && mouseMoved) { + if(tooltip != null && !tooltip.isEmpty()) { pieceAtCursor.drawTooltip(ms, mouseX, mouseY, tooltip, this); } - if (comment != null && !comment.isEmpty()) { + if(comment != null && !comment.isEmpty()) { List commentList = Arrays.stream(comment.split(";")).map(Component::literal).collect(Collectors.toList()); pieceAtCursor.drawCommentText(ms, mouseX, mouseY, commentList, this); } @@ -467,15 +467,15 @@ public void render(PoseStack ms, int mouseX, int mouseY, float partialTicks) { ms.popPose(); - if (takingScreenshot) { + if(takingScreenshot) { String name = spell.name; CompoundTag cmp = new CompoundTag(); - if (spell != null) { + if(spell != null) { spell.writeToNBT(cmp); } String export = cmp.toString(); - if (shareToReddit) { + if(shareToReddit) { SharingHelper.uploadAndShare(name, export); } else { SharingHelper.uploadAndOpen(name, export); @@ -501,18 +501,18 @@ public void addButtons(List