From b65b81a32eb554d6ecfba9d355f9b7ffab50ebaf Mon Sep 17 00:00:00 2001 From: Deniz Date: Sun, 6 Aug 2023 00:59:45 +0200 Subject: [PATCH] [#486] Fixed that the player detector will not detect players in different dimensions. But only if the max range is set to infinite(-1) while the config option `playerDetMultiDimensional` is set to true Added a new checkstyle rule for singleline if statements --- build.gradle | 26 +++--- config/checkstyle/checkstyle.xml | 4 + .../client/HudOverlayHandler.java | 9 +- .../addons/appliedenergistics/AppEngApi.java | 42 ++++++---- .../addons/appliedenergistics/CraftJob.java | 3 +- .../computercraft/owner/OperationAbility.java | 3 +- .../peripheral/ChatBoxPeripheral.java | 8 +- .../peripheral/ColonyPeripheral.java | 6 +- .../InventoryManagerPeripheral.java | 3 +- .../peripheral/PlayerDetectorPeripheral.java | 84 +++++++++++++++---- .../turtles/TurtleChatBoxUpgrade.java | 4 +- .../addons/minecolonies/MineColonies.java | 9 +- .../common/argoggles/ARRenderAction.java | 3 +- .../blocks/base/BaseBlockEntityBlock.java | 9 +- .../blocks/base/PeripheralBlockEntity.java | 9 +- .../blockentities/ARControllerEntity.java | 13 +-- .../configuration/PeripheralsConfig.java | 16 +++- .../common/container/base/BaseContainer.java | 3 +- .../common/events/Events.java | 12 ++- .../common/items/ARGogglesItem.java | 3 +- .../common/util/ChunkManager.java | 9 +- .../common/util/CoordUtil.java | 25 +++--- .../common/util/Platform.java | 3 +- .../common/util/fakeplayer/APFakePlayer.java | 11 +-- .../common/village/VillageStructures.java | 3 +- .../lib/peripherals/BasePeripheral.java | 9 +- .../peripherals/IntegrationPeripheral.java | 9 +- .../ClockwiseAnimatedTurtleUpgrade.java | 6 +- .../messages/RequestHudCanvasMessage.java | 3 +- 29 files changed, 226 insertions(+), 121 deletions(-) diff --git a/build.gradle b/build.gradle index 1bf5c9596..ca6f940ae 100644 --- a/build.gradle +++ b/build.gradle @@ -271,30 +271,30 @@ dependencies { // Extended requirements // We don't use the api since we need a specific class from mekanism - implementation fg.deobf("mekanism:Mekanism:${mekanism_version}") + compileOnly fg.deobf("mekanism:Mekanism:${mekanism_version}") // Applied Energistics 2 - implementation fg.deobf("appeng:appliedenergistics2-forge:${appliedenergistics_version}") + compileOnly fg.deobf("appeng:appliedenergistics2-forge:${appliedenergistics_version}") // Curios - runtimeOnly fg.deobf("top.theillusivec4.curios:curios-forge:${curios_version}") + compileOnly fg.deobf("top.theillusivec4.curios:curios-forge:${curios_version}") // Refined Storage - implementation fg.deobf("com.refinedmods:refinedstorage:${refinedstorage_version}") { + compileOnly fg.deobf("com.refinedmods:refinedstorage:${refinedstorage_version}") { transitive false } // AE2 Things compileOnly fg.deobf("curse.maven:ae2things-609977:${ae2things_version}-sources") - runtimeOnly fg.deobf("curse.maven:ae2things-609977:${ae2things_version}-sources") + //runtimeOnly fg.deobf("curse.maven:ae2things-609977:${ae2things_version}-sources") // AE2 Additions compileOnly fg.deobf("curse.maven:ae-additions-493962:${ae2additions_version}") - runtimeOnly fg.deobf("curse.maven:ae-additions-493962:${ae2additions_version}") + //runtimeOnly fg.deobf("curse.maven:ae-additions-493962:${ae2additions_version}") implementation 'thedarkcolour:kotlinforforge:3.12.0' // Botania - implementation fg.deobf("vazkii.botania:Botania:${botania_version}") + compileOnly fg.deobf("vazkii.botania:Botania:${botania_version}") // Minecolonies // Change to compileOnly when running `runData` @@ -305,20 +305,20 @@ dependencies { compileOnly fg.deobf("com.ldtteam:blockui:${blockui_version}") //Patchouli - runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:${patchouli_version}") + compileOnly fg.deobf("vazkii.patchouli:Patchouli:${patchouli_version}") // Create - implementation fg.deobf("com.simibubi.create:create-${minecraft_version}:${create_version}:all") + compileOnly fg.deobf("com.simibubi.create:create-${minecraft_version}:${create_version}:all") //Removed until fully ported //testImplementation fg.deobf("site.siredvin.ttoolkit:ttoolkit-${minecraft_version}:${ttoolkit_version}") //Powah - implementation fg.deobf("curse.maven:powah-633483:${powah_version}") - implementation fg.deobf("me.shedaniel.cloth:cloth-config-forge:8.2.88") - implementation fg.deobf("dev.architectury:architectury-forge:6.2.43") + compileOnly fg.deobf("curse.maven:powah-633483:${powah_version}") + compileOnly fg.deobf("me.shedaniel.cloth:cloth-config-forge:8.2.88") + compileOnly fg.deobf("dev.architectury:architectury-forge:6.2.43") - implementation fg.deobf("curse.maven:crash-utilities-371813:4406293") + compileOnly fg.deobf("curse.maven:crash-utilities-371813:4406293") testImplementation "org.junit.jupiter:junit-jupiter-api:${junit_version}" testImplementation "org.junit.jupiter:junit-jupiter-params:${junit_version}" diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml index f6bf1a9ac..7ca06cbc2 100644 --- a/config/checkstyle/checkstyle.xml +++ b/config/checkstyle/checkstyle.xml @@ -136,6 +136,10 @@ + + + + diff --git a/src/main/java/de/srendi/advancedperipherals/client/HudOverlayHandler.java b/src/main/java/de/srendi/advancedperipherals/client/HudOverlayHandler.java index ffd79ec58..217c52745 100644 --- a/src/main/java/de/srendi/advancedperipherals/client/HudOverlayHandler.java +++ b/src/main/java/de/srendi/advancedperipherals/client/HudOverlayHandler.java @@ -20,20 +20,23 @@ public static HudOverlayHandler getInstance() { } public static void updateCanvas(List actions) { - if (instance == null) return; + if (instance == null) + return; instance.canvas.clear(); instance.canvas.addAll(actions); } public static void clearCanvas() { - if (instance == null) return; + if (instance == null) + return; instance.canvas.clear(); } //TODO: Use the forge Overlay System instead /*@SubscribeEvent(priority = EventPriority.LOWEST) public void onRender(RenderGuiEvent.Post event) { - if (event.getWindow() == null) return; + if (event.getWindow() == null) + return; Minecraft mc = Minecraft.getInstance(); PoseStack matrixStack = event.getMatrixStack(); for (ARRenderAction action : canvas) { diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/appliedenergistics/AppEngApi.java b/src/main/java/de/srendi/advancedperipherals/common/addons/appliedenergistics/AppEngApi.java index 15dcaf4d7..0c954e1a0 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/appliedenergistics/AppEngApi.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/appliedenergistics/AppEngApi.java @@ -278,14 +278,16 @@ public static long getTotalItemStorage(IGridNode node) { while (iterator.hasNext()) { DriveBlockEntity entity = (DriveBlockEntity) iterator.next().getService(IStorageProvider.class); - if (entity == null) continue; + if (entity == null) + continue; InternalInventory inventory = entity.getInternalInventory(); for (int i = 0; i < inventory.size(); i++) { ItemStack stack = inventory.getStackInSlot(i); - if (stack.isEmpty()) continue; + if (stack.isEmpty()) + continue; if (stack.getItem() instanceof BasicStorageCell cell) { if (cell.getKeyType().getClass().isAssignableFrom(AEKeyType.items().getClass())) { @@ -328,14 +330,16 @@ public static long getTotalFluidStorage(IGridNode node) { while (iterator.hasNext()) { DriveBlockEntity entity = (DriveBlockEntity) iterator.next().getService(IStorageProvider.class); - if (entity == null) continue; + if (entity == null) + continue; InternalInventory inventory = entity.getInternalInventory(); for (int i = 0; i < inventory.size(); i++) { ItemStack stack = inventory.getStackInSlot(i); - if (stack.isEmpty()) continue; + if (stack.isEmpty()) + continue; if (stack.getItem() instanceof BasicStorageCell cell) { if (cell.getKeyType().getClass().isAssignableFrom(AEKeyType.fluids().getClass())) { @@ -374,20 +378,23 @@ public static long getUsedItemStorage(IGridNode node) { while (iterator.hasNext()) { DriveBlockEntity entity = (DriveBlockEntity) iterator.next().getService(IStorageProvider.class); - if (entity == null) continue; + if (entity == null) + continue; InternalInventory inventory = entity.getInternalInventory(); for (int i = 0; i < inventory.size(); i++) { ItemStack stack = inventory.getStackInSlot(i); - if (stack.isEmpty()) continue; + if (stack.isEmpty()) + continue; if (stack.getItem() instanceof BasicStorageCell cell) { int bytesPerType = cell.getBytesPerType(null); if (cell.getKeyType().getClass().isAssignableFrom(AEKeyType.items().getClass())) { - if (stack.getTag() == null) continue; + if (stack.getTag() == null) + continue; int numOfType = stack.getTag().getLongArray("amts").length; long numItemsInCell = stack.getTag().getLong("ic"); @@ -395,12 +402,14 @@ public static long getUsedItemStorage(IGridNode node) { } } else if (APAddons.aeThingsLoaded && stack.getItem() instanceof DISKDrive disk) { if (disk.getKeyType().toString().equals("ae2:i")) { - if (stack.getTag() == null) continue; + if (stack.getTag() == null) + continue; long numBytesInCell = stack.getTag().getLong("ic"); used += numBytesInCell; } } else if (APAddons.aeAdditionsLoaded && stack.getItem() instanceof SuperStorageCell) { - if (stack.getTag() == null) continue; + if (stack.getTag() == null) + continue; long numItemsInCell = stack.getTag().getLong("ic"); used += numItemsInCell; @@ -431,7 +440,8 @@ public static long getUsedFluidStorage(IGridNode node) { while (iterator.hasNext()) { DriveBlockEntity entity = (DriveBlockEntity) iterator.next().getService(IStorageProvider.class); - if (entity == null) continue; + if (entity == null) + continue; InternalInventory inventory = entity.getInternalInventory(); @@ -442,14 +452,16 @@ public static long getUsedFluidStorage(IGridNode node) { int bytesPerType = cell.getBytesPerType(null); if (cell.getKeyType().getClass().isAssignableFrom(AEKeyType.fluids().getClass())) { - if (stack.getTag() == null) continue; + if (stack.getTag() == null) + continue; int numOfType = stack.getTag().getLongArray("amts").length; long numBucketsInCell = stack.getTag().getLong("ic") / 1000; used += ((int) Math.ceil(((double) numBucketsInCell) / 8)) + ((long) bytesPerType * numOfType); } } else if (APAddons.aeAdditionsLoaded && stack.getItem() instanceof SuperStorageCell superStorageCell) { - if (stack.getTag() == null) continue; + if (stack.getTag() == null) + continue; long numItemsInCell = stack.getTag().getLong("ic"); used += numItemsInCell; @@ -489,14 +501,16 @@ public static List listCells(IGridNode node) { if (!iterator.hasNext()) return items; while (iterator.hasNext()) { DriveBlockEntity entity = (DriveBlockEntity) iterator.next().getService(IStorageProvider.class); - if (entity == null) continue; + if (entity == null) + continue; InternalInventory inventory = entity.getInternalInventory(); for (int i = 0; i < inventory.size(); i++) { ItemStack stack = inventory.getStackInSlot(i); - if (stack.isEmpty()) continue; + if (stack.isEmpty()) + continue; if (stack.getItem() instanceof BasicStorageCell cell) { items.add(getObjectFromCell(cell, stack)); diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/appliedenergistics/CraftJob.java b/src/main/java/de/srendi/advancedperipherals/common/addons/appliedenergistics/CraftJob.java index c75960ef2..1b2d5d9a9 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/appliedenergistics/CraftJob.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/appliedenergistics/CraftJob.java @@ -91,7 +91,8 @@ public void startCrafting() { } public void maybeCraft() { - if (startedCrafting || futureJob == null || !futureJob.isDone()) return; + if (startedCrafting || futureJob == null || !futureJob.isDone()) + return; ICraftingPlan job; try { job = futureJob.get(); diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/OperationAbility.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/OperationAbility.java index 121f5d239..af5cf5718 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/OperationAbility.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/OperationAbility.java @@ -87,7 +87,8 @@ public void registerOperation(@NotNull IPeripheralOperation operation) { cooldown = fuelAbility.reduceCooldownAccordingToConsumptionRate(cooldown); } MethodResult result = method.apply(context); - if (successCallback != null) successCallback.accept(context); + if (successCallback != null) + successCallback.accept(context); setCooldown(operation, cooldown); return result; } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/ChatBoxPeripheral.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/ChatBoxPeripheral.java index 167907970..ee9f20d6b 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/ChatBoxPeripheral.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/ChatBoxPeripheral.java @@ -117,7 +117,7 @@ public final MethodResult sendFormattedMessage(@NotNull IArguments arguments) th for (ServerPlayer player : ServerLifecycleHooks.getCurrentServer().getPlayerList().getPlayers()) { if (!APConfig.PERIPHERALS_CONFIG.chatBoxMultiDimensional.get() && player.getLevel().dimension() != dimension) continue; - if (range == -1 || CoordUtil.isInRange(getPos(), getLevel(), player, range)) + if (range == -1 || CoordUtil.isInRange(getPos(), getLevel(), player, range, maxRange)) player.sendSystemMessage(preparedMessage); } return MethodResult.of(true); @@ -139,7 +139,7 @@ public final MethodResult sendMessage(@NotNull IArguments arguments) throws LuaE for (ServerPlayer player : ServerLifecycleHooks.getCurrentServer().getPlayerList().getPlayers()) { if (!APConfig.PERIPHERALS_CONFIG.chatBoxMultiDimensional.get() && player.getLevel().dimension() != dimension) continue; - if (range == -1 || CoordUtil.isInRange(getPos(), getLevel(), player, range)) + if (range == -1 || CoordUtil.isInRange(getPos(), getLevel(), player, range, maxRange)) player.sendSystemMessage(preparedMessage); } return MethodResult.of(true); @@ -170,7 +170,7 @@ public final MethodResult sendFormattedMessageToPlayer(@NotNull IArguments argum if (!APConfig.PERIPHERALS_CONFIG.chatBoxMultiDimensional.get() && player.getLevel().dimension() != dimension) return MethodResult.of(false, "NOT_SAME_DIMENSION"); - if (range == -1 || CoordUtil.isInRange(getPos(), getLevel(), player, range)) + if (range == -1 || CoordUtil.isInRange(getPos(), getLevel(), player, range, maxRange)) player.sendSystemMessage(preparedMessage); return MethodResult.of(true); }); @@ -196,7 +196,7 @@ public final MethodResult sendMessageToPlayer(@NotNull IArguments arguments) thr if (!APConfig.PERIPHERALS_CONFIG.chatBoxMultiDimensional.get() && player.getLevel().dimension() != dimension) return MethodResult.of(false, "NOT_SAME_DIMENSION"); - if (range == -1 || CoordUtil.isInRange(getPos(), getLevel(), player, range)) + if (range == -1 || CoordUtil.isInRange(getPos(), getLevel(), player, range, maxRange)) player.sendSystemMessage(preparedMessage, false); return MethodResult.of(true); }); diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/ColonyPeripheral.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/ColonyPeripheral.java index ecf80dd04..5a689c538 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/ColonyPeripheral.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/ColonyPeripheral.java @@ -170,7 +170,8 @@ public final Object getVisitors() throws LuaException { List list = new ArrayList<>(); for (ICivilianData civilian : colony.getVisitorManager().getCivilianDataMap().values()) { - if (!(civilian instanceof IVisitorData visitorData)) continue; + if (!(civilian instanceof IVisitorData visitorData)) + continue; list.add(MineColonies.visitorToObject(visitorData)); } return list; @@ -257,7 +258,8 @@ public final Object getRequests() throws LuaException { List> requests = new ArrayList<>(); for (IToken token : tokens) { IRequest request = requestManager.getRequestForToken(token); - if (request.getRequest() instanceof IDeliverable) requests.add(request); + if (request.getRequest() instanceof IDeliverable) + requests.add(request); } List result = new ArrayList<>(); diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/InventoryManagerPeripheral.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/InventoryManagerPeripheral.java index c86241a14..6bb94e8de 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/InventoryManagerPeripheral.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/InventoryManagerPeripheral.java @@ -222,7 +222,8 @@ public final boolean isWearing(int index) throws LuaException { public final int getEmptySpace() throws LuaException { int i = 0; for (ItemStack stack : getOwnerPlayer().getInventory().items) { - if (stack.isEmpty()) i++; + if (stack.isEmpty()) + i++; } return i; } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/PlayerDetectorPeripheral.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/PlayerDetectorPeripheral.java index 40ad0c737..737ddbbc1 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/PlayerDetectorPeripheral.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/PlayerDetectorPeripheral.java @@ -2,6 +2,7 @@ import dan200.computercraft.api.lua.LuaException; import dan200.computercraft.api.lua.LuaFunction; +import dan200.computercraft.api.lua.MethodResult; import dan200.computercraft.api.pocket.IPocketAccess; import dan200.computercraft.api.turtle.ITurtleAccess; import dan200.computercraft.api.turtle.TurtleSide; @@ -15,8 +16,10 @@ import de.srendi.advancedperipherals.common.util.LuaConverter; import de.srendi.advancedperipherals.lib.peripherals.BasePeripheral; import net.minecraft.core.BlockPos; +import net.minecraft.resources.ResourceKey; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.Level; import net.minecraftforge.server.ServerLifecycleHooks; import java.util.*; @@ -24,6 +27,7 @@ public class PlayerDetectorPeripheral extends BasePeripheral { public static final String PERIPHERAL_TYPE = "playerDetector"; + private static final int MAX_RANGE = APConfig.PERIPHERALS_CONFIG.playerDetMaxRange.get(); public PlayerDetectorPeripheral(PeripheralBlockEntity tileEntity) { super(PERIPHERAL_TYPE, new BlockEntityPeripheralOwner<>(tileEntity)); @@ -37,6 +41,13 @@ public PlayerDetectorPeripheral(IPocketAccess pocket) { super(PERIPHERAL_TYPE, new PocketPeripheralOwner(pocket)); } + private boolean isAllowedMultiDimensional() { + int maxRange = MAX_RANGE; + // We also check if the max range is 100000000 since the old default was 100000000, so we don't break servers/worlds + // with the old default value in the configuration + return APConfig.PERIPHERALS_CONFIG.playerDetMultiDimensional.get() && (maxRange == -1 || maxRange >= 100000000); + } + @Override public boolean isEnabled() { return APConfig.PERIPHERALS_CONFIG.enablePlayerDetector.get(); @@ -48,22 +59,30 @@ public final String[] getOnlinePlayers() { } @LuaFunction(mainThread = true) - public final List getPlayersInCoords(Map firstCoord, Map secondCoord) throws LuaException { + public final MethodResult getPlayersInCoords(Map firstCoord, Map secondCoord) throws LuaException { List playersName = new ArrayList<>(); BlockPos firstPos = LuaConverter.convertToBlockPos(firstCoord); BlockPos secondPos = LuaConverter.convertToBlockPos(secondCoord); + ResourceKey dimension = getLevel().dimension(); + for (ServerPlayer player : getPlayers()) { - if (CoordUtil.isInRange(getPos(), player, getLevel(), firstPos, secondPos)) + if (!isAllowedMultiDimensional() && player.getLevel().dimension() != dimension) + continue; + if (CoordUtil.isInRange(getPos(), player, getLevel(), firstPos, secondPos, MAX_RANGE)) playersName.add(player.getName().getString()); } - return playersName; + return MethodResult.of(playersName); } @LuaFunction(mainThread = true) public final List getPlayersInCubic(int x, int y, int z) { List playersName = new ArrayList<>(); + ResourceKey dimension = getLevel().dimension(); + for (ServerPlayer player : getPlayers()) { - if (CoordUtil.isInRange(getPos(), getLevel(), player, x, y, z)) + if (!isAllowedMultiDimensional() && player.getLevel().dimension() != dimension) + continue; + if (CoordUtil.isInRange(getPos(), getLevel(), player, x, y, z, MAX_RANGE)) playersName.add(player.getName().getString()); } return playersName; @@ -72,8 +91,12 @@ public final List getPlayersInCubic(int x, int y, int z) { @LuaFunction(mainThread = true) public final List getPlayersInRange(int range) { List playersName = new ArrayList<>(); + ResourceKey dimension = getLevel().dimension(); + for (ServerPlayer player : getPlayers()) { - if (CoordUtil.isInRange(getPos(), getLevel(), player, range)) + if (!isAllowedMultiDimensional() && player.getLevel().dimension() != dimension) + continue; + if (range == -1 || CoordUtil.isInRange(getPos(), getLevel(), player, range, MAX_RANGE)) playersName.add(player.getName().getString()); } return playersName; @@ -81,29 +104,44 @@ public final List getPlayersInRange(int range) { @LuaFunction(mainThread = true) public final boolean isPlayersInCoords(Map firstCoord, Map secondCoord) throws LuaException { - if (getPlayers().isEmpty()) return false; + if (getPlayers().isEmpty()) + return false; BlockPos firstPos = LuaConverter.convertToBlockPos(firstCoord); BlockPos secondPos = LuaConverter.convertToBlockPos(secondCoord); + ResourceKey dimension = getLevel().dimension(); + for (ServerPlayer player : getPlayers()) { - if (CoordUtil.isInRange(getPos(), player, getLevel(), firstPos, secondPos)) return true; + if (!isAllowedMultiDimensional() && player.getLevel().dimension() != dimension) + continue; + if (CoordUtil.isInRange(getPos(), player, getLevel(), firstPos, secondPos, MAX_RANGE)) return true; } return false; } @LuaFunction(mainThread = true) public final boolean isPlayersInCubic(int x, int y, int z) { - if (getPlayers().isEmpty()) return false; + if (getPlayers().isEmpty()) + return false; + ResourceKey dimension = getLevel().dimension(); + for (ServerPlayer player : getPlayers()) { - if (CoordUtil.isInRange(getPos(), getLevel(), player, x, y, z)) return true; + if (!isAllowedMultiDimensional() && player.getLevel().dimension() != dimension) + continue; + if (CoordUtil.isInRange(getPos(), getLevel(), player, x, y, z, MAX_RANGE)) return true; } return false; } @LuaFunction(mainThread = true) public final boolean isPlayersInRange(int range) { - if (getPlayers().isEmpty()) return false; + if (getPlayers().isEmpty()) + return false; + ResourceKey dimension = getLevel().dimension(); + for (ServerPlayer player : getPlayers()) { - if (CoordUtil.isInRange(getPos(), getLevel(), player, range)) return true; + if (!isAllowedMultiDimensional() && player.getLevel().dimension() != dimension) + continue; + if (range == -1 || CoordUtil.isInRange(getPos(), getLevel(), player, range, MAX_RANGE)) return true; } return false; } @@ -112,8 +150,12 @@ public final boolean isPlayersInRange(int range) { public final boolean isPlayerInCoords(Map firstCoord, Map secondCoord, String username) throws LuaException { BlockPos firstPos = LuaConverter.convertToBlockPos(firstCoord); BlockPos secondPos = LuaConverter.convertToBlockPos(secondCoord); + ResourceKey dimension = getLevel().dimension(); + for (Player player : getPlayers()) { - if (CoordUtil.isInRange(getPos(), player, getLevel(), firstPos, secondPos)) + if (!isAllowedMultiDimensional() && player.getLevel().dimension() != dimension) + continue; + if (CoordUtil.isInRange(getPos(), player, getLevel(), firstPos, secondPos, MAX_RANGE)) if(player.getName().getString().equals(username)) return true; } @@ -122,8 +164,12 @@ public final boolean isPlayerInCoords(Map firstCoord, Map secondCoor @LuaFunction(mainThread = true) public final boolean isPlayerInCubic(int x, int y, int z, String username) { + ResourceKey dimension = getLevel().dimension(); + for (Player player : getPlayers()) { - if (CoordUtil.isInRange(getPos(), getLevel(), player, x, y, z)) { + if (!isAllowedMultiDimensional() && player.getLevel().dimension() != dimension) + continue; + if (CoordUtil.isInRange(getPos(), getLevel(), player, x, y, z, MAX_RANGE)) { if(player.getName().getString().equals(username)) return true; } @@ -133,8 +179,12 @@ public final boolean isPlayerInCubic(int x, int y, int z, String username) { @LuaFunction(mainThread = true) public final boolean isPlayerInRange(int range, String username) { + ResourceKey dimension = getLevel().dimension(); + for (Player player : getPlayers()) { - if (CoordUtil.isInRange(getPos(), getLevel(), player, range)) { + if (!isAllowedMultiDimensional() && player.getLevel().dimension() != dimension) + continue; + if (range == -1 || CoordUtil.isInRange(getPos(), getLevel(), player, range, MAX_RANGE)) { if(player.getName().getString().equals(username)) return true; } @@ -146,10 +196,14 @@ public final boolean isPlayerInRange(int range, String username) { public final Map getPlayerPos(String username) throws LuaException { if (!APConfig.PERIPHERALS_CONFIG.playerSpy.get()) throw new LuaException("This function is disabled in the config. Activate it or ask an admin if he can activate it."); + ResourceKey dimension = getLevel().dimension(); + ServerPlayer existingPlayer = null; for (ServerPlayer player : getPlayers()) { + if (!isAllowedMultiDimensional() && player.getLevel().dimension() != dimension) + continue; if (player.getName().getString().equals(username)) { - if (CoordUtil.isInRange(getPos(), getLevel(), player, APConfig.PERIPHERALS_CONFIG.playerDetMaxRange.get())) + if (MAX_RANGE == -1 || CoordUtil.isInRange(getPos(), getLevel(), player, MAX_RANGE, MAX_RANGE)) existingPlayer = player; break; } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/TurtleChatBoxUpgrade.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/TurtleChatBoxUpgrade.java index 096386ae8..74aa5e703 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/TurtleChatBoxUpgrade.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/TurtleChatBoxUpgrade.java @@ -3,7 +3,6 @@ import dan200.computercraft.api.turtle.ITurtleAccess; import dan200.computercraft.api.turtle.TurtleSide; import dan200.computercraft.shared.computer.core.ServerComputer; - import dan200.computercraft.shared.turtle.blocks.TileTurtle; import de.srendi.advancedperipherals.AdvancedPeripherals; import de.srendi.advancedperipherals.common.addons.computercraft.peripheral.ChatBoxPeripheral; @@ -42,7 +41,8 @@ protected ChatBoxPeripheral buildPeripheral(@NotNull ITurtleAccess turtle, @NotN @Override public void update(@NotNull ITurtleAccess turtle, @NotNull TurtleSide side) { super.update(turtle, side); - if (turtle.getLevel().isClientSide) return; + if (turtle.getLevel().isClientSide) + return; if (turtle.getUpgrade(side) instanceof TurtleChatBoxUpgrade) { BlockEntity tile = turtle.getLevel().getBlockEntity(turtle.getPosition()); diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/minecolonies/MineColonies.java b/src/main/java/de/srendi/advancedperipherals/common/addons/minecolonies/MineColonies.java index 2d47657b9..fdebab8db 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/minecolonies/MineColonies.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/minecolonies/MineColonies.java @@ -10,11 +10,7 @@ import com.minecolonies.api.colony.workorders.IWorkOrder; import com.minecolonies.api.crafting.ItemStorage; import com.minecolonies.api.entity.citizen.Skill; -import com.minecolonies.api.research.IGlobalResearch; -import com.minecolonies.api.research.IGlobalResearchTree; -import com.minecolonies.api.research.ILocalResearch; -import com.minecolonies.api.research.ILocalResearchTree; -import com.minecolonies.api.research.IResearchRequirement; +import com.minecolonies.api.research.*; import com.minecolonies.api.research.effects.IResearchEffect; import com.minecolonies.api.research.util.ResearchState; import com.minecolonies.coremod.colony.buildings.AbstractBuildingStructureBuilder; @@ -226,7 +222,8 @@ public static int getStorageSize(IBuilding building) { public static int getAmountOfConstructionSites(IColony colony) { int constructionSites = 0; for (IBuilding building : colony.getBuildingManager().getBuildings().values()) { - if (building.hasWorkOrder()) constructionSites++; + if (building.hasWorkOrder()) + constructionSites++; } return constructionSites; diff --git a/src/main/java/de/srendi/advancedperipherals/common/argoggles/ARRenderAction.java b/src/main/java/de/srendi/advancedperipherals/common/argoggles/ARRenderAction.java index cc4bb693e..d3682e6d8 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/argoggles/ARRenderAction.java +++ b/src/main/java/de/srendi/advancedperipherals/common/argoggles/ARRenderAction.java @@ -55,7 +55,8 @@ public String getId() { } /*public void draw(Minecraft mc, PoseStack matrixStack, int w, int h) { - if (!type.ensureArgs(intArgs)) return; + if (!type.ensureArgs(intArgs)) + return; int[] i = intArgs; switch (type) { case DRAW_CENTERED_STRING: diff --git a/src/main/java/de/srendi/advancedperipherals/common/blocks/base/BaseBlockEntityBlock.java b/src/main/java/de/srendi/advancedperipherals/common/blocks/base/BaseBlockEntityBlock.java index 7c611bb9c..14549c842 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/blocks/base/BaseBlockEntityBlock.java +++ b/src/main/java/de/srendi/advancedperipherals/common/blocks/base/BaseBlockEntityBlock.java @@ -4,11 +4,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerPlayer; import net.minecraft.tags.BlockTags; -import net.minecraft.world.Container; -import net.minecraft.world.Containers; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; -import net.minecraft.world.MenuProvider; +import net.minecraft.world.*; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; @@ -65,7 +61,8 @@ public void onRemove(BlockState state, @NotNull Level worldIn, @NotNull BlockPos @Override public void setPlacedBy(@NotNull Level worldIn, @NotNull BlockPos pos, @NotNull BlockState state, @Nullable LivingEntity placer, ItemStack stack) { super.setPlacedBy(worldIn, pos, state, placer, stack); - if (worldIn.getBlockEntity(pos) == null) return; + if (worldIn.getBlockEntity(pos) == null) + return; //Used for the lua function getName() worldIn.getBlockEntity(pos).getPersistentData().putString("CustomName", stack.getDisplayName().getString()); } diff --git a/src/main/java/de/srendi/advancedperipherals/common/blocks/base/PeripheralBlockEntity.java b/src/main/java/de/srendi/advancedperipherals/common/blocks/base/PeripheralBlockEntity.java index f73eb1fc7..7facc6a31 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/blocks/base/PeripheralBlockEntity.java +++ b/src/main/java/de/srendi/advancedperipherals/common/blocks/base/PeripheralBlockEntity.java @@ -97,9 +97,12 @@ public LazyOptional getCapability(@NotNull Capability cap, @Nullabl @Override public void invalidateCaps() { super.invalidateCaps(); - if (peripheralCap != null) peripheralCap.invalidate(); - if (handler != null) handler.invalidate(); - if (fluidHandler != null) fluidHandler.invalidate(); + if (peripheralCap != null) + peripheralCap.invalidate(); + if (handler != null) + handler.invalidate(); + if (fluidHandler != null) + fluidHandler.invalidate(); } @NotNull diff --git a/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/ARControllerEntity.java b/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/ARControllerEntity.java index 2bf2c73c6..2bce3e1e0 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/ARControllerEntity.java +++ b/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/ARControllerEntity.java @@ -35,10 +35,11 @@ public ARControllerEntity(BlockPos pos, BlockState state) { * @param action The action to add to the canvas. */ public void addToCanvas(ARRenderAction action) { - if (canvas.contains(action)) return; - if (action.getId() != null) { + if (canvas.contains(action)) + return; + if (action.getId() != null) canvas.removeIf(old -> action.getId().equals(old.getId())); - } + canvas.add(action); blockChanged(); } @@ -81,8 +82,10 @@ public void deserializeNBT(CompoundTag nbt) { public void saveAdditional(@NotNull CompoundTag compound) { super.saveAdditional(compound); - if (virtualScreenSize.isPresent()) compound.putIntArray(VIRTUAL_SCREEN_SIZE, virtualScreenSize.get()); - else if (compound.contains(VIRTUAL_SCREEN_SIZE)) compound.remove(VIRTUAL_SCREEN_SIZE); + if (virtualScreenSize.isPresent()) + compound.putIntArray(VIRTUAL_SCREEN_SIZE, virtualScreenSize.get()); + else if (compound.contains(VIRTUAL_SCREEN_SIZE)) + compound.remove(VIRTUAL_SCREEN_SIZE); ListTag list = new ListTag(); for (ARRenderAction action : new ArrayList<>(canvas)) { list.add(action.serializeNBT()); diff --git a/src/main/java/de/srendi/advancedperipherals/common/configuration/PeripheralsConfig.java b/src/main/java/de/srendi/advancedperipherals/common/configuration/PeripheralsConfig.java index 1b3afd7a6..34e69955c 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/configuration/PeripheralsConfig.java +++ b/src/main/java/de/srendi/advancedperipherals/common/configuration/PeripheralsConfig.java @@ -15,9 +15,12 @@ public class PeripheralsConfig implements IAPConfig { public final ForgeConfigSpec.BooleanValue playerSpy; public final ForgeConfigSpec.BooleanValue morePlayerInformation; public final ForgeConfigSpec.BooleanValue enablePlayerDetector; + public final ForgeConfigSpec.BooleanValue playerDetMultiDimensional; + //Energy Detector public final ForgeConfigSpec.IntValue energyDetectorMaxFlow; public final ForgeConfigSpec.BooleanValue enableEnergyDetector; + //NBT Storage public final ForgeConfigSpec.IntValue nbtStorageMaxSize; public final ForgeConfigSpec.BooleanValue enableNBTStorage; @@ -35,25 +38,35 @@ public class PeripheralsConfig implements IAPConfig { //ME Bridge public final ForgeConfigSpec.BooleanValue enableMEBridge; public final ForgeConfigSpec.IntValue meConsumption; + //Rs Bridge public final ForgeConfigSpec.BooleanValue enableRSBridge; public final ForgeConfigSpec.IntValue rsConsumption; + //Environment Detector public final ForgeConfigSpec.BooleanValue enableEnvironmentDetector; + //AR Controller public final ForgeConfigSpec.BooleanValue enableARGoggles; + //Inventory Manager public final ForgeConfigSpec.BooleanValue enableInventoryManager; + //Redstone Integrator public final ForgeConfigSpec.BooleanValue enableRedstoneIntegrator; + //Block reader public final ForgeConfigSpec.BooleanValue enableBlockReader; + //Geo Scanner public final ForgeConfigSpec.BooleanValue enableGeoScanner; + //Colony integrator public final ForgeConfigSpec.BooleanValue enableColonyIntegrator; + //Compass turtle public final ForgeConfigSpec.BooleanValue enableCompassTurtle; + //Powered Peripherals public final ForgeConfigSpec.BooleanValue enablePoweredPeripherals; public final ForgeConfigSpec.BooleanValue disablePocketFuelConsumption; @@ -68,9 +81,10 @@ public PeripheralsConfig() { builder.push("Player_Detector"); enablePlayerDetector = builder.comment("Enable the Player Detector or not.").define("enablePlayerDetector", true); - playerDetMaxRange = builder.comment("The max range of the player detector functions. " + "If anyone use a higher range, the detector will use this max range").defineInRange("playerDetMaxRange", 100000000, 0, 100000000); + playerDetMaxRange = builder.comment("The max range of the player detector functions. If anyone use a higher range, the detector will use this max range. -1 for unlimited").defineInRange("playerDetMaxRange", -1, -1, Integer.MAX_VALUE); playerSpy = builder.comment("Activates the \"getPlayerPos\" function of the Player Detector").define("enablePlayerPosFunction", true); morePlayerInformation = builder.comment("Adds more information to `getPlayerPos` of the Player Detector. Like rotation and dimension").define("morePlayerInformation", true); + playerDetMultiDimensional = builder.comment("If true, the player detector can observe players which aren't in the same dimension as the detector itself. `playerDetMaxRange` needs to be infinite(-1) for it to work.").define("chatBoxMultiDimensional", true); pop("Energy_Detector", builder); diff --git a/src/main/java/de/srendi/advancedperipherals/common/container/base/BaseContainer.java b/src/main/java/de/srendi/advancedperipherals/common/container/base/BaseContainer.java index 9c2736442..9d11ca901 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/container/base/BaseContainer.java +++ b/src/main/java/de/srendi/advancedperipherals/common/container/base/BaseContainer.java @@ -23,7 +23,8 @@ public abstract class BaseContainer extends AbstractContainerMenu { protected BaseContainer(@Nullable MenuType type, int id, Inventory inventory, BlockPos pos, Level world) { super(type, id); this.inventory = new InvWrapper(inventory); - if (world != null) this.tileEntity = (PeripheralBlockEntity) world.getBlockEntity(pos); + if (world != null) + this.tileEntity = (PeripheralBlockEntity) world.getBlockEntity(pos); } @Override diff --git a/src/main/java/de/srendi/advancedperipherals/common/events/Events.java b/src/main/java/de/srendi/advancedperipherals/common/events/Events.java index 95d869f92..e1f31efba 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/events/Events.java +++ b/src/main/java/de/srendi/advancedperipherals/common/events/Events.java @@ -72,7 +72,8 @@ public static void onPlayerChangeDimension(PlayerEvent.PlayerChangedDimensionEve @SubscribeEvent public static void onCommand(CommandEvent event) throws CommandSyntaxException { - if (!getCommandName(event.getParseResults().getContext()).equals("say")) return; + if (!getCommandName(event.getParseResults().getContext()).equals("say")) + return; String username = "sayCommand"; String uuid = null; String message = MessageArgument.getMessage(event.getParseResults().getContext().build("apChatEvent"), "message").getString(); @@ -114,7 +115,8 @@ public static void onChatBox(ServerChatEvent.Submitted event) { @SubscribeEvent public static void onEquipmentChange(LivingEquipmentChangeEvent event) { LivingEntity livingEntity = event.getEntity(); - if (!(livingEntity instanceof ServerPlayer serverPlayer)) return; + if (!(livingEntity instanceof ServerPlayer serverPlayer)) + return; if (event.getFrom().getItem() instanceof ARGogglesItem) MNetwork.sendTo(new ClearHudCanvasMessage(), serverPlayer); @@ -132,7 +134,8 @@ public static synchronized void putPlayerMessage(Pair public static synchronized long traverseChatMessages(long lastConsumedMessage, Consumer consumer) { for (Pair message : messageQueue) { - if (message.getLeft() <= lastConsumedMessage) continue; + if (message.getLeft() <= lastConsumedMessage) + continue; consumer.accept(message.getRight()); lastConsumedMessage = message.getLeft(); } @@ -141,7 +144,8 @@ public static synchronized long traverseChatMessages(long lastConsumedMessage, C public static synchronized long traversePlayerMessages(long lastConsumedMessage, Consumer consumer) { for (Pair message : playerMessageQueue) { - if (message.getLeft() <= lastConsumedMessage) continue; + if (message.getLeft() <= lastConsumedMessage) + continue; consumer.accept(message.getRight()); lastConsumedMessage = message.getLeft(); } diff --git a/src/main/java/de/srendi/advancedperipherals/common/items/ARGogglesItem.java b/src/main/java/de/srendi/advancedperipherals/common/items/ARGogglesItem.java index fffab6fec..9ce543380 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/items/ARGogglesItem.java +++ b/src/main/java/de/srendi/advancedperipherals/common/items/ARGogglesItem.java @@ -28,7 +28,8 @@ public void appendHoverText(ItemStack stack, @Nullable Level levelIn, List APConfig.PERIPHERALS_CONFIG.playerDetMaxRange.get()) + if (i + j > (maxRange != -1 ? maxRange : Integer.MAX_VALUE)) return false; return world.getNearbyPlayers(TargetingConditions.forNonCombat(), null, new AABB(firstPos, secondPos)).contains(player); } diff --git a/src/main/java/de/srendi/advancedperipherals/common/util/Platform.java b/src/main/java/de/srendi/advancedperipherals/common/util/Platform.java index 380981349..9acab5e70 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/util/Platform.java +++ b/src/main/java/de/srendi/advancedperipherals/common/util/Platform.java @@ -21,7 +21,8 @@ public static Optional maybeLoadIntegration(final String path) { Class clazz = Class.forName(AdvancedPeripherals.class.getPackage().getName() + ".common.addons." + path); return Optional.of(clazz.getDeclaredConstructor().newInstance()); } catch (InstantiationException | IllegalAccessException | ClassNotFoundException loadException) { - if (APConfig.GENERAL_CONFIG.enableDebugMode.get()) loadException.printStackTrace(); + if (APConfig.GENERAL_CONFIG.enableDebugMode.get()) + loadException.printStackTrace(); return Optional.empty(); } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/java/de/srendi/advancedperipherals/common/util/fakeplayer/APFakePlayer.java b/src/main/java/de/srendi/advancedperipherals/common/util/fakeplayer/APFakePlayer.java index 804370617..aa804874c 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/util/fakeplayer/APFakePlayer.java +++ b/src/main/java/de/srendi/advancedperipherals/common/util/fakeplayer/APFakePlayer.java @@ -34,11 +34,7 @@ import net.minecraft.world.level.block.StructureBlock; import net.minecraft.world.level.block.entity.SignBlockEntity; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.phys.AABB; -import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.EntityHitResult; -import net.minecraft.world.phys.HitResult; -import net.minecraft.world.phys.Vec3; +import net.minecraft.world.phys.*; import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.ForgeMod; import net.minecraftforge.common.util.FakePlayer; @@ -46,8 +42,8 @@ import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.eventbus.api.Event; import org.jetbrains.annotations.NotNull; - import org.jetbrains.annotations.Nullable; + import java.lang.ref.WeakReference; import java.util.List; import java.util.Optional; @@ -83,7 +79,8 @@ public void awardStat(@NotNull Stat stat) { MinecraftServer server = level.getServer(); if (server != null && getGameProfile() != PROFILE) { Player player = server.getPlayerList().getPlayer(getUUID()); - if (player != null) player.awardStat(stat); + if (player != null) + player.awardStat(stat); } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/village/VillageStructures.java b/src/main/java/de/srendi/advancedperipherals/common/village/VillageStructures.java index 67ea33714..d88dd5f0b 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/village/VillageStructures.java +++ b/src/main/java/de/srendi/advancedperipherals/common/village/VillageStructures.java @@ -18,7 +18,8 @@ public class VillageStructures { // Adapted from Pneumaticcraft public static void init() { - if (!APConfig.WORLD_CONFIG.enableVillagerStructures.get()) return; + if (!APConfig.WORLD_CONFIG.enableVillagerStructures.get()) + return; //Ensure the vanilla static init is done PlainVillagePools.bootstrap(); SavannaVillagePools.bootstrap(); diff --git a/src/main/java/de/srendi/advancedperipherals/lib/peripherals/BasePeripheral.java b/src/main/java/de/srendi/advancedperipherals/lib/peripherals/BasePeripheral.java index 4ff475459..ecf986acc 100644 --- a/src/main/java/de/srendi/advancedperipherals/lib/peripherals/BasePeripheral.java +++ b/src/main/java/de/srendi/advancedperipherals/lib/peripherals/BasePeripheral.java @@ -38,7 +38,8 @@ protected void buildPlugins() { initialized = true; this.pluggedMethods.clear(); if (plugins != null) plugins.forEach(plugin -> { - if (plugin.isSuitable(this)) pluggedMethods.addAll(plugin.getMethods()); + if (plugin.isSuitable(this)) + pluggedMethods.addAll(plugin.getMethods()); }); owner.getAbilities().forEach(ability -> { if (ability instanceof IPeripheralPlugin peripheralPlugin) @@ -129,14 +130,16 @@ protected Direction validateSide(String direction) throws LuaException { @Override @NotNull public String @NotNull [] getMethodNames() { - if (!initialized) buildPlugins(); + if (!initialized) + buildPlugins(); return methodNames; } @Override @NotNull public MethodResult callMethod(@NotNull IComputerAccess access, @NotNull ILuaContext context, int index, @NotNull IArguments arguments) throws LuaException { - if (!initialized) buildPlugins(); + if (!initialized) + buildPlugins(); return pluggedMethods.get(index).apply(access, context, arguments); } diff --git a/src/main/java/de/srendi/advancedperipherals/lib/peripherals/IntegrationPeripheral.java b/src/main/java/de/srendi/advancedperipherals/lib/peripherals/IntegrationPeripheral.java index 418d5812f..b9369189b 100644 --- a/src/main/java/de/srendi/advancedperipherals/lib/peripherals/IntegrationPeripheral.java +++ b/src/main/java/de/srendi/advancedperipherals/lib/peripherals/IntegrationPeripheral.java @@ -28,7 +28,8 @@ protected void buildPlugins() { initialized = true; this.pluggedMethods.clear(); if (plugins != null) plugins.forEach(plugin -> { - if (plugin.isSuitable(this)) pluggedMethods.addAll(plugin.getMethods()); + if (plugin.isSuitable(this)) + pluggedMethods.addAll(plugin.getMethods()); }); this.methodNames = pluggedMethods.stream().map(BoundMethod::getName).toArray(String[]::new); } @@ -65,14 +66,16 @@ public boolean equals(@Nullable IPeripheral iPeripheral) { @Override @NotNull public String @NotNull [] getMethodNames() { - if (!initialized) buildPlugins(); + if (!initialized) + buildPlugins(); return methodNames; } @Override @NotNull public MethodResult callMethod(@NotNull IComputerAccess access, @NotNull ILuaContext context, int index, @NotNull IArguments arguments) throws LuaException { - if (!initialized) buildPlugins(); + if (!initialized) + buildPlugins(); return pluggedMethods.get(index).apply(access, context, arguments); } } diff --git a/src/main/java/de/srendi/advancedperipherals/lib/turtle/ClockwiseAnimatedTurtleUpgrade.java b/src/main/java/de/srendi/advancedperipherals/lib/turtle/ClockwiseAnimatedTurtleUpgrade.java index aad7cff03..0c8391873 100644 --- a/src/main/java/de/srendi/advancedperipherals/lib/turtle/ClockwiseAnimatedTurtleUpgrade.java +++ b/src/main/java/de/srendi/advancedperipherals/lib/turtle/ClockwiseAnimatedTurtleUpgrade.java @@ -45,7 +45,9 @@ public void chargeConsumingCallback() { @Override public void update(@NotNull ITurtleAccess turtle, @NotNull TurtleSide side) { super.update(turtle, side); - if (tick % 2 == 0) - if (DataStorageUtil.RotationCharge.consume(turtle, side)) chargeConsumingCallback(); + if (tick % 2 == 0) { + if (DataStorageUtil.RotationCharge.consume(turtle, side)) + chargeConsumingCallback(); + } } } diff --git a/src/main/java/de/srendi/advancedperipherals/network/messages/RequestHudCanvasMessage.java b/src/main/java/de/srendi/advancedperipherals/network/messages/RequestHudCanvasMessage.java index 2aa4167ff..76fa84e43 100644 --- a/src/main/java/de/srendi/advancedperipherals/network/messages/RequestHudCanvasMessage.java +++ b/src/main/java/de/srendi/advancedperipherals/network/messages/RequestHudCanvasMessage.java @@ -37,7 +37,8 @@ public static void handle(RequestHudCanvasMessage mes, Supplier