diff --git a/build.gradle b/build.gradle index 65efa6a1c..e7be2ecd9 100644 --- a/build.gradle +++ b/build.gradle @@ -1,3 +1,4 @@ +import de.srendi.advancedperipherals.JustPlayingAroundStep import net.darkhax.curseforgegradle.TaskPublishCurseForge import java.text.SimpleDateFormat @@ -12,7 +13,7 @@ plugins { id 'org.parchmentmc.librarian.forgegradle' version '1.+' id 'org.spongepowered.mixin' version '0.7.+' id "com.github.breadmoirai.github-release" version "2.5.2" - id 'checkstyle' + id "com.diffplug.spotless" version "6.25.0" id 'java' } @@ -366,6 +367,57 @@ dependencies { // runtimeOnly fg.deobf("curse.maven:createaddition-439890:5099757") } +spotless { + // optional: limit format enforcement to just the files changed by this feature branch + format 'misc', { + // define the files to apply `misc` to + target '*.gradle', '.gitattributes', '.gitignore' + + // define the steps to apply to those files + trimTrailingWhitespace() + indentWithSpaces() // or spaces. Takes an integer argument if you don't like 4 + endWithNewline() + } + java { + // don't need to set target, it is inferred from java + // apply a specific flavor of google-java-format + eclipse('4.26') + formatAnnotations() + indentWithSpaces() + // fix formatting of type annotations + //formatAnnotations() + // make sure every file has the following copyright header. + // optionally, Spotless can set copyright years by digging + // through git history (see "license" section below) + licenseHeader '''/* + * Copyright $YEAR Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +''' + // https://github.com/diffplug/spotless/issues/240#issuecomment-385206606 + custom 'noWildcardImports', { + if (it.contains('*;\n')) { + throw new Error('No wildcard imports allowed') + } + } + bumpThisNumberIfACustomStepChanges(1) + + // Needs to be placed after the eclipse formatter does its thing + //addStep(JustPlayingAroundStep.create()) + + } +} changelog { version = "${project.version}" @@ -454,20 +506,20 @@ tasks.withType(Checkstyle) { tasks.named('processResources', ProcessResources).configure { var replaceProperties = [minecraft_version : minecraft_version, - forge_version : forge_version, - loader_version : loader_version, - mod_id : mod_id, - version : version, - cc_version : cc_version, - curios_version : curios_version, - minecolonies_version : minecolonies_version, - appliedenergistics_version: appliedenergistics_version, - patchouli_version : patchouli_version, - refinedstorage_version : refinedstorage_version, - botania_version : botania_version, - mekanism_version : mekanism_version, - ae2things_version : ae2things_version, - powah_version : powah_version,] + forge_version : forge_version, + loader_version : loader_version, + mod_id : mod_id, + version : version, + cc_version : cc_version, + curios_version : curios_version, + minecolonies_version : minecolonies_version, + appliedenergistics_version: appliedenergistics_version, + patchouli_version : patchouli_version, + refinedstorage_version : refinedstorage_version, + botania_version : botania_version, + mekanism_version : mekanism_version, + ae2things_version : ae2things_version, + powah_version : powah_version,] inputs.properties replaceProperties diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle new file mode 100644 index 000000000..c9decf9f7 --- /dev/null +++ b/buildSrc/build.gradle @@ -0,0 +1,7 @@ +repositories { + mavenCentral() +} + +dependencies { + implementation 'com.diffplug.spotless:spotless-lib-extra:2.45.0' +} diff --git a/buildSrc/src/main/java/de/srendi/advancedperipherals/JustPlayingAroundStep.java b/buildSrc/src/main/java/de/srendi/advancedperipherals/JustPlayingAroundStep.java new file mode 100644 index 000000000..aa41d05c5 --- /dev/null +++ b/buildSrc/src/main/java/de/srendi/advancedperipherals/JustPlayingAroundStep.java @@ -0,0 +1,20 @@ +package de.srendi.advancedperipherals; + +import com.diffplug.spotless.FormatterFunc; +import com.diffplug.spotless.FormatterStep; + +import java.io.Serializable; + +// Just a step for me to play around. Could evolve into something bigger when this branch gets merged into production +public class JustPlayingAroundStep { + + public static FormatterStep create() { + return FormatterStep.create("", new State(), State::toFormatter); + } + + private static class State implements Serializable { + FormatterFunc toFormatter() { + return input -> input; + } + } +} diff --git a/settings.gradle b/settings.gradle index 6b39aa618..26b001c1b 100644 --- a/settings.gradle +++ b/settings.gradle @@ -17,4 +17,4 @@ pluginManagement { plugins { id 'org.gradle.toolchains.foojay-resolver-convention' version '0.7.0' -} \ No newline at end of file +} diff --git a/src/main/java/de/srendi/advancedperipherals/APCreativeTab.java b/src/main/java/de/srendi/advancedperipherals/APCreativeTab.java index 52eba5e66..5419d1feb 100644 --- a/src/main/java/de/srendi/advancedperipherals/APCreativeTab.java +++ b/src/main/java/de/srendi/advancedperipherals/APCreativeTab.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals; import de.srendi.advancedperipherals.common.setup.APBlocks; @@ -22,7 +37,8 @@ public APCreativeTab() { @Override public void fillItemList(NonNullList items) { - APRegistration.ITEMS.getEntries().stream().map(RegistryObject::get).forEach(item -> items.add(new ItemStack(item))); + APRegistration.ITEMS.getEntries().stream().map(RegistryObject::get) + .forEach(item -> items.add(new ItemStack(item))); items.addAll(pocketUpgrade(CCRegistration.ID.COLONY_POCKET)); items.addAll(pocketUpgrade(CCRegistration.ID.CHATTY_POCKET)); items.addAll(pocketUpgrade(CCRegistration.ID.PLAYER_POCKET)); @@ -55,8 +71,7 @@ private static Collection turtleUpgrade(ResourceLocation pocketId) { } @Override - @NotNull - public ItemStack makeIcon() { + @NotNull public ItemStack makeIcon() { return new ItemStack(APBlocks.CHAT_BOX.get()); } } diff --git a/src/main/java/de/srendi/advancedperipherals/AdvancedPeripherals.java b/src/main/java/de/srendi/advancedperipherals/AdvancedPeripherals.java index a52cf0fa7..4e090ac3c 100644 --- a/src/main/java/de/srendi/advancedperipherals/AdvancedPeripherals.java +++ b/src/main/java/de/srendi/advancedperipherals/AdvancedPeripherals.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals; import de.srendi.advancedperipherals.common.addons.APAddons; diff --git a/src/main/java/de/srendi/advancedperipherals/client/ClientRegistry.java b/src/main/java/de/srendi/advancedperipherals/client/ClientRegistry.java index d5e52ae28..e58b68c1e 100644 --- a/src/main/java/de/srendi/advancedperipherals/client/ClientRegistry.java +++ b/src/main/java/de/srendi/advancedperipherals/client/ClientRegistry.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.client; import dan200.computercraft.api.client.ComputerCraftAPIClient; @@ -23,12 +38,16 @@ @Mod.EventBusSubscriber(modid = AdvancedPeripherals.MOD_ID, value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.MOD) public class ClientRegistry { - private static final String[] TURTLE_MODELS = new String[]{"turtle_chat_box_upgrade_left", "turtle_chat_box_upgrade_right", "turtle_environment_upgrade_left", "turtle_environment_upgrade_right", "turtle_player_upgrade_left", "turtle_player_upgrade_right", "turtle_geoscanner_upgrade_left", "turtle_geoscanner_upgrade_right"}; + private static final String[] TURTLE_MODELS = new String[]{"turtle_chat_box_upgrade_left", + "turtle_chat_box_upgrade_right", "turtle_environment_upgrade_left", "turtle_environment_upgrade_right", + "turtle_player_upgrade_left", "turtle_player_upgrade_right", "turtle_geoscanner_upgrade_left", + "turtle_geoscanner_upgrade_right"}; @SubscribeEvent public static void registerModels(ModelEvent.RegisterAdditional event) { for (String model : TURTLE_MODELS) { - event.register(new ModelResourceLocation(new ResourceLocation(AdvancedPeripherals.MOD_ID, model), "inventory")); + event.register( + new ModelResourceLocation(new ResourceLocation(AdvancedPeripherals.MOD_ID, model), "inventory")); } } @@ -37,18 +56,45 @@ public static void onClientSetup(FMLClientSetupEvent event) { MenuScreens.register(APContainerTypes.INVENTORY_MANAGER_CONTAINER.get(), InventoryManagerScreen::new); MenuScreens.register(APContainerTypes.SMART_GLASSES_CONTAINER.get(), SmartGlassesScreen::new); - ComputerCraftAPIClient.registerTurtleUpgradeModeller(CCRegistration.CHUNKY_TURTLE.get(), TurtleUpgradeModeller.flatItem()); - ComputerCraftAPIClient.registerTurtleUpgradeModeller(CCRegistration.COMPASS_TURTLE.get(), TurtleUpgradeModeller.flatItem()); - ComputerCraftAPIClient.registerTurtleUpgradeModeller(CCRegistration.CHAT_BOX_TURTLE.get(), TurtleUpgradeModeller.sided(new ModelResourceLocation(AdvancedPeripherals.getRL("turtle_chat_box_upgrade_left"), "inventory"), new ModelResourceLocation(AdvancedPeripherals.getRL("turtle_chat_box_upgrade_right"), "inventory"))); - ComputerCraftAPIClient.registerTurtleUpgradeModeller(CCRegistration.ENVIRONMENT_TURTLE.get(), TurtleUpgradeModeller.sided(new ModelResourceLocation(AdvancedPeripherals.getRL("turtle_environment_upgrade_left"), "inventory"), new ModelResourceLocation(AdvancedPeripherals.getRL("turtle_environment_upgrade_right"), "inventory"))); - ComputerCraftAPIClient.registerTurtleUpgradeModeller(CCRegistration.GEO_SCANNER_TURTLE.get(), TurtleUpgradeModeller.sided(new ModelResourceLocation(AdvancedPeripherals.getRL("turtle_geoscanner_upgrade_left"), "inventory"), new ModelResourceLocation(AdvancedPeripherals.getRL("turtle_geoscanner_upgrade_right"), "inventory"))); - ComputerCraftAPIClient.registerTurtleUpgradeModeller(CCRegistration.PLAYER_DETECTOR_TURTLE.get(), TurtleUpgradeModeller.sided(new ModelResourceLocation(AdvancedPeripherals.getRL("turtle_player_upgrade_left"), "inventory"), new ModelResourceLocation(AdvancedPeripherals.getRL("turtle_player_upgrade_right"), "inventory"))); - ComputerCraftAPIClient.registerTurtleUpgradeModeller(CCRegistration.OP_END_TURTLE.get(), new MetaTurtleUpgradeModeller<>()); - ComputerCraftAPIClient.registerTurtleUpgradeModeller(CCRegistration.OP_HUSBANDRY_TURTLE.get(), new MetaTurtleUpgradeModeller<>()); - ComputerCraftAPIClient.registerTurtleUpgradeModeller(CCRegistration.OP_WEAK_TURTLE.get(), new MetaTurtleUpgradeModeller<>()); - ComputerCraftAPIClient.registerTurtleUpgradeModeller(CCRegistration.HUSBANDRY_TURTLE.get(), new MetaTurtleUpgradeModeller<>()); - ComputerCraftAPIClient.registerTurtleUpgradeModeller(CCRegistration.END_TURTLE.get(), new MetaTurtleUpgradeModeller<>()); - ComputerCraftAPIClient.registerTurtleUpgradeModeller(CCRegistration.WEAK_TURTLE.get(), new MetaTurtleUpgradeModeller<>()); + ComputerCraftAPIClient.registerTurtleUpgradeModeller(CCRegistration.CHUNKY_TURTLE.get(), + TurtleUpgradeModeller.flatItem()); + ComputerCraftAPIClient.registerTurtleUpgradeModeller(CCRegistration.COMPASS_TURTLE.get(), + TurtleUpgradeModeller.flatItem()); + ComputerCraftAPIClient.registerTurtleUpgradeModeller(CCRegistration.CHAT_BOX_TURTLE.get(), + TurtleUpgradeModeller.sided( + new ModelResourceLocation(AdvancedPeripherals.getRL("turtle_chat_box_upgrade_left"), + "inventory"), + new ModelResourceLocation(AdvancedPeripherals.getRL("turtle_chat_box_upgrade_right"), + "inventory"))); + ComputerCraftAPIClient.registerTurtleUpgradeModeller(CCRegistration.ENVIRONMENT_TURTLE.get(), + TurtleUpgradeModeller.sided( + new ModelResourceLocation(AdvancedPeripherals.getRL("turtle_environment_upgrade_left"), + "inventory"), + new ModelResourceLocation(AdvancedPeripherals.getRL("turtle_environment_upgrade_right"), + "inventory"))); + ComputerCraftAPIClient.registerTurtleUpgradeModeller(CCRegistration.GEO_SCANNER_TURTLE.get(), + TurtleUpgradeModeller.sided( + new ModelResourceLocation(AdvancedPeripherals.getRL("turtle_geoscanner_upgrade_left"), + "inventory"), + new ModelResourceLocation(AdvancedPeripherals.getRL("turtle_geoscanner_upgrade_right"), + "inventory"))); + ComputerCraftAPIClient.registerTurtleUpgradeModeller(CCRegistration.PLAYER_DETECTOR_TURTLE.get(), + TurtleUpgradeModeller.sided( + new ModelResourceLocation(AdvancedPeripherals.getRL("turtle_player_upgrade_left"), "inventory"), + new ModelResourceLocation(AdvancedPeripherals.getRL("turtle_player_upgrade_right"), + "inventory"))); + ComputerCraftAPIClient.registerTurtleUpgradeModeller(CCRegistration.OP_END_TURTLE.get(), + new MetaTurtleUpgradeModeller<>()); + ComputerCraftAPIClient.registerTurtleUpgradeModeller(CCRegistration.OP_HUSBANDRY_TURTLE.get(), + new MetaTurtleUpgradeModeller<>()); + ComputerCraftAPIClient.registerTurtleUpgradeModeller(CCRegistration.OP_WEAK_TURTLE.get(), + new MetaTurtleUpgradeModeller<>()); + ComputerCraftAPIClient.registerTurtleUpgradeModeller(CCRegistration.HUSBANDRY_TURTLE.get(), + new MetaTurtleUpgradeModeller<>()); + ComputerCraftAPIClient.registerTurtleUpgradeModeller(CCRegistration.END_TURTLE.get(), + new MetaTurtleUpgradeModeller<>()); + ComputerCraftAPIClient.registerTurtleUpgradeModeller(CCRegistration.WEAK_TURTLE.get(), + new MetaTurtleUpgradeModeller<>()); ItemPropertiesRegistry.register(); } diff --git a/src/main/java/de/srendi/advancedperipherals/client/ItemPropertiesRegistry.java b/src/main/java/de/srendi/advancedperipherals/client/ItemPropertiesRegistry.java index 00ef43539..629030826 100644 --- a/src/main/java/de/srendi/advancedperipherals/client/ItemPropertiesRegistry.java +++ b/src/main/java/de/srendi/advancedperipherals/client/ItemPropertiesRegistry.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.client; import de.srendi.advancedperipherals.AdvancedPeripherals; @@ -8,10 +23,11 @@ public class ItemPropertiesRegistry { public static void register() { - ItemProperties.register(APItems.MEMORY_CARD.get(), new ResourceLocation(AdvancedPeripherals.MOD_ID, "bounded"), (stack, level, entity, seed) -> { - boolean bounded = stack.getOrCreateTag().contains("owner"); - return bounded ? 1 : 0; - }); + ItemProperties.register(APItems.MEMORY_CARD.get(), new ResourceLocation(AdvancedPeripherals.MOD_ID, "bounded"), + (stack, level, entity, seed) -> { + boolean bounded = stack.getOrCreateTag().contains("owner"); + return bounded ? 1 : 0; + }); } } diff --git a/src/main/java/de/srendi/advancedperipherals/client/KeyBindings.java b/src/main/java/de/srendi/advancedperipherals/client/KeyBindings.java index 37cea5f0d..76a16c4ac 100644 --- a/src/main/java/de/srendi/advancedperipherals/client/KeyBindings.java +++ b/src/main/java/de/srendi/advancedperipherals/client/KeyBindings.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.client; import net.minecraft.client.KeyMapping; @@ -6,8 +21,10 @@ public class KeyBindings { - public static final KeyMapping DESCRIPTION_KEYBINDING = new KeyMapping("keybind.advancedperipherals.description", GLFW.GLFW_KEY_LEFT_CONTROL, "keybind.advancedperipherals.category"); - public static final KeyMapping GLASSES_HOTKEY_KEYBINDING = new KeyMapping("keybind.advancedperipherals.glasses_hotkey", GLFW.GLFW_KEY_G, "keybind.advancedperipherals.category"); + public static final KeyMapping DESCRIPTION_KEYBINDING = new KeyMapping("keybind.advancedperipherals.description", + GLFW.GLFW_KEY_LEFT_CONTROL, "keybind.advancedperipherals.category"); + public static final KeyMapping GLASSES_HOTKEY_KEYBINDING = new KeyMapping( + "keybind.advancedperipherals.glasses_hotkey", GLFW.GLFW_KEY_G, "keybind.advancedperipherals.category"); public static void register(RegisterKeyMappingsEvent event) { event.register(DESCRIPTION_KEYBINDING); diff --git a/src/main/java/de/srendi/advancedperipherals/client/MetaTurtleUpgradeModeller.java b/src/main/java/de/srendi/advancedperipherals/client/MetaTurtleUpgradeModeller.java index 0d6e14fe9..5e877ef98 100644 --- a/src/main/java/de/srendi/advancedperipherals/client/MetaTurtleUpgradeModeller.java +++ b/src/main/java/de/srendi/advancedperipherals/client/MetaTurtleUpgradeModeller.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.client; import com.mojang.blaze3d.vertex.PoseStack; @@ -12,10 +27,11 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -public class MetaTurtleUpgradeModeller> implements TurtleUpgradeModeller { +public class MetaTurtleUpgradeModeller> + implements + TurtleUpgradeModeller { - @NotNull - @Override + @NotNull @Override public TransformedModel getModel(T upgrade, @Nullable ITurtleAccess turtle, @NotNull TurtleSide side) { if (upgrade.getLeftModel() == null) { PoseStack stack = new PoseStack(); diff --git a/src/main/java/de/srendi/advancedperipherals/client/renderer/DistanceDetectorRenderer.java b/src/main/java/de/srendi/advancedperipherals/client/renderer/DistanceDetectorRenderer.java index 6731f755e..0a38e0ce0 100644 --- a/src/main/java/de/srendi/advancedperipherals/client/renderer/DistanceDetectorRenderer.java +++ b/src/main/java/de/srendi/advancedperipherals/client/renderer/DistanceDetectorRenderer.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.client.renderer; import com.mojang.blaze3d.vertex.PoseStack; @@ -27,9 +42,11 @@ public DistanceDetectorRenderer(BlockEntityRendererProvider.Context pContext) { } @Override - public void render(@NotNull DistanceDetectorEntity pBlockEntity, float pPartialTick, @NotNull PoseStack pPoseStack, MultiBufferSource pBufferSource, int pPackedLight, int pPackedOverlay) { + public void render(@NotNull DistanceDetectorEntity pBlockEntity, float pPartialTick, @NotNull PoseStack pPoseStack, + MultiBufferSource pBufferSource, int pPackedLight, int pPackedOverlay) { if (pBlockEntity.getLaserVisibility()) - renderBeaconBeam(pBlockEntity, pPoseStack, pBufferSource, BeaconRenderer.BEAM_LOCATION, pPartialTick, 1, 0, pBlockEntity.getCurrentDistance() - 0.5f, EnumColor.RED.getRgb(), 0.05f, 0.09f); + renderBeaconBeam(pBlockEntity, pPoseStack, pBufferSource, BeaconRenderer.BEAM_LOCATION, pPartialTick, 1, 0, + pBlockEntity.getCurrentDistance() - 0.5f, EnumColor.RED.getRgb(), 0.05f, 0.09f); } @Override @@ -47,7 +64,9 @@ public boolean shouldRender(@NotNull DistanceDetectorEntity pBlockEntity, @NotNu return true; } - public static void renderBeaconBeam(DistanceDetectorEntity detectorEntity, PoseStack pPoseStack, MultiBufferSource pBufferSource, ResourceLocation pBeamLocation, float pPartialTick, float pTextureScale, int pYOffset, float pHeight, float[] pColors, float pBeamRadius, float pGlowRadius) { + public static void renderBeaconBeam(DistanceDetectorEntity detectorEntity, PoseStack pPoseStack, + MultiBufferSource pBufferSource, ResourceLocation pBeamLocation, float pPartialTick, float pTextureScale, + int pYOffset, float pHeight, float[] pColors, float pBeamRadius, float pGlowRadius) { long pGameTime = detectorEntity.getLevel().getGameTime(); float maxX = pYOffset + pHeight; Direction direction = detectorEntity.getBlockState().getValue(BaseBlock.ORIENTATION).front(); @@ -64,34 +83,48 @@ public static void renderBeaconBeam(DistanceDetectorEntity detectorEntity, PoseS pPoseStack.mulPose(Vector3f.YP.rotationDegrees(degrees * 2.25F - 45.0F)); float f15 = -1.0F + time; float f16 = pHeight * pTextureScale * (0.5F / pBeamRadius) + f15; - renderPart(pPoseStack, pBufferSource.getBuffer(RenderType.beaconBeam(pBeamLocation, false)), r, g, b, 1.0F, pYOffset, maxX, 0.0F, pBeamRadius, pBeamRadius, 0.0F, -pBeamRadius, 0.0F, 0.0F, -pBeamRadius, 0.0F, 1.0F, f16, f15); + renderPart(pPoseStack, pBufferSource.getBuffer(RenderType.beaconBeam(pBeamLocation, false)), r, g, b, 1.0F, + pYOffset, maxX, 0.0F, pBeamRadius, pBeamRadius, 0.0F, -pBeamRadius, 0.0F, 0.0F, -pBeamRadius, 0.0F, + 1.0F, f16, f15); pPoseStack.popPose(); pPoseStack.mulPose(direction.getRotation()); f15 = -1.0F + time; f16 = pHeight * pTextureScale + f15; - renderPart(pPoseStack, pBufferSource.getBuffer(RenderType.beaconBeam(pBeamLocation, true)), r, g, b, 0.225F, pYOffset, maxX, -pGlowRadius, -pGlowRadius, pGlowRadius, -pGlowRadius, -pBeamRadius, pGlowRadius, pGlowRadius, pGlowRadius, 0.0F, 1.0F, f16, f15); + renderPart(pPoseStack, pBufferSource.getBuffer(RenderType.beaconBeam(pBeamLocation, true)), r, g, b, 0.225F, + pYOffset, maxX, -pGlowRadius, -pGlowRadius, pGlowRadius, -pGlowRadius, -pBeamRadius, pGlowRadius, + pGlowRadius, pGlowRadius, 0.0F, 1.0F, f16, f15); pPoseStack.popPose(); } - private static void renderPart(PoseStack pPoseStack, VertexConsumer pConsumer, float pRed, float pGreen, float pBlue, float pAlpha, int pMinY, float pMaxY, float pX0, float pZ0, float pX1, float pZ1, float pX2, float pZ2, float pX3, float pZ3, float pMinU, float pMaxU, float pMinV, float pMaxV) { + private static void renderPart(PoseStack pPoseStack, VertexConsumer pConsumer, float pRed, float pGreen, + float pBlue, float pAlpha, int pMinY, float pMaxY, float pX0, float pZ0, float pX1, float pZ1, float pX2, + float pZ2, float pX3, float pZ3, float pMinU, float pMaxU, float pMinV, float pMaxV) { PoseStack.Pose posestackPose = pPoseStack.last(); Matrix4f matrix4f = posestackPose.pose(); Matrix3f matrix3f = posestackPose.normal(); - renderQuad(matrix4f, matrix3f, pConsumer, pRed, pGreen, pBlue, pAlpha, pMinY, pMaxY, pX0, pZ0, pX1, pZ1, pMinU, pMaxU, pMinV, pMaxV); - renderQuad(matrix4f, matrix3f, pConsumer, pRed, pGreen, pBlue, pAlpha, pMinY, pMaxY, pX3, pZ3, pX2, pZ2, pMinU, pMaxU, pMinV, pMaxV); - renderQuad(matrix4f, matrix3f, pConsumer, pRed, pGreen, pBlue, pAlpha, pMinY, pMaxY, pX1, pZ1, pX3, pZ3, pMinU, pMaxU, pMinV, pMaxV); - renderQuad(matrix4f, matrix3f, pConsumer, pRed, pGreen, pBlue, pAlpha, pMinY, pMaxY, pX2, pZ2, pX0, pZ0, pMinU, pMaxU, pMinV, pMaxV); + renderQuad(matrix4f, matrix3f, pConsumer, pRed, pGreen, pBlue, pAlpha, pMinY, pMaxY, pX0, pZ0, pX1, pZ1, pMinU, + pMaxU, pMinV, pMaxV); + renderQuad(matrix4f, matrix3f, pConsumer, pRed, pGreen, pBlue, pAlpha, pMinY, pMaxY, pX3, pZ3, pX2, pZ2, pMinU, + pMaxU, pMinV, pMaxV); + renderQuad(matrix4f, matrix3f, pConsumer, pRed, pGreen, pBlue, pAlpha, pMinY, pMaxY, pX1, pZ1, pX3, pZ3, pMinU, + pMaxU, pMinV, pMaxV); + renderQuad(matrix4f, matrix3f, pConsumer, pRed, pGreen, pBlue, pAlpha, pMinY, pMaxY, pX2, pZ2, pX0, pZ0, pMinU, + pMaxU, pMinV, pMaxV); } - private static void renderQuad(Matrix4f pPose, Matrix3f pNormal, VertexConsumer pConsumer, float pRed, float pGreen, float pBlue, float pAlpha, int pMinY, float pMaxY, float pMinX, float pMinZ, float pMaxX, float pMaxZ, float pMinU, float pMaxU, float pMinV, float pMaxV) { + private static void renderQuad(Matrix4f pPose, Matrix3f pNormal, VertexConsumer pConsumer, float pRed, float pGreen, + float pBlue, float pAlpha, int pMinY, float pMaxY, float pMinX, float pMinZ, float pMaxX, float pMaxZ, + float pMinU, float pMaxU, float pMinV, float pMaxV) { addVertex(pPose, pNormal, pConsumer, pRed, pGreen, pBlue, pAlpha, pMaxY, pMinX, pMinZ, pMaxU, pMinV); addVertex(pPose, pNormal, pConsumer, pRed, pGreen, pBlue, pAlpha, pMinY, pMinX, pMinZ, pMaxU, pMaxV); addVertex(pPose, pNormal, pConsumer, pRed, pGreen, pBlue, pAlpha, pMinY, pMaxX, pMaxZ, pMinU, pMaxV); addVertex(pPose, pNormal, pConsumer, pRed, pGreen, pBlue, pAlpha, pMaxY, pMaxX, pMaxZ, pMinU, pMinV); } - private static void addVertex(Matrix4f pPose, Matrix3f pNormal, VertexConsumer pConsumer, float pRed, float pGreen, float pBlue, float pAlpha, float pY, float pX, float pZ, float pU, float pV) { - pConsumer.vertex(pPose, pX, pY, pZ).color(pRed, pGreen, pBlue, pAlpha).uv(pU, pV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(15728880).normal(pNormal, 0.0F, 1.0F, 0.0F).endVertex(); + private static void addVertex(Matrix4f pPose, Matrix3f pNormal, VertexConsumer pConsumer, float pRed, float pGreen, + float pBlue, float pAlpha, float pY, float pX, float pZ, float pU, float pV) { + pConsumer.vertex(pPose, pX, pY, pZ).color(pRed, pGreen, pBlue, pAlpha).uv(pU, pV) + .overlayCoords(OverlayTexture.NO_OVERLAY).uv2(15728880).normal(pNormal, 0.0F, 1.0F, 0.0F).endVertex(); } } diff --git a/src/main/java/de/srendi/advancedperipherals/client/screens/InventoryManagerScreen.java b/src/main/java/de/srendi/advancedperipherals/client/screens/InventoryManagerScreen.java index d1730b50b..99667c63b 100644 --- a/src/main/java/de/srendi/advancedperipherals/client/screens/InventoryManagerScreen.java +++ b/src/main/java/de/srendi/advancedperipherals/client/screens/InventoryManagerScreen.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.client.screens; import de.srendi.advancedperipherals.AdvancedPeripherals; diff --git a/src/main/java/de/srendi/advancedperipherals/client/screens/SmartGlassesScreen.java b/src/main/java/de/srendi/advancedperipherals/client/screens/SmartGlassesScreen.java index 9b4aa2346..cc9af070e 100644 --- a/src/main/java/de/srendi/advancedperipherals/client/screens/SmartGlassesScreen.java +++ b/src/main/java/de/srendi/advancedperipherals/client/screens/SmartGlassesScreen.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.client.screens; import com.mojang.blaze3d.systems.RenderSystem; @@ -18,8 +33,10 @@ public class SmartGlassesScreen extends ComputerScreenBase { - private static final ResourceLocation BACKGROUND = new ResourceLocation(AdvancedPeripherals.MOD_ID, "textures/gui/smart_glasses_gui.png"); - public static final ResourceLocation SIDEBAR = new ResourceLocation(AdvancedPeripherals.MOD_ID, "textures/gui/corners_glasses.png"); + private static final ResourceLocation BACKGROUND = new ResourceLocation(AdvancedPeripherals.MOD_ID, + "textures/gui/smart_glasses_gui.png"); + public static final ResourceLocation SIDEBAR = new ResourceLocation(AdvancedPeripherals.MOD_ID, + "textures/gui/corners_glasses.png"); private static final int TEX_WIDTH = 254; private static final int TEX_HEIGHT = 217; @@ -41,7 +58,8 @@ protected void init() { @Override protected WidgetTerminal createTerminal() { - return new WidgetTerminal(terminalData, input, leftPos + ContainerTurtle.BORDER + ComputerSidebar.WIDTH, topPos + ContainerTurtle.BORDER); + return new WidgetTerminal(terminalData, input, leftPos + ContainerTurtle.BORDER + ComputerSidebar.WIDTH, + topPos + ContainerTurtle.BORDER); } @Override @@ -69,7 +87,8 @@ protected void renderTooltip(@NotNull PoseStack poseStack, int x, int y) { @Override protected void renderLabels(PoseStack poseStack, int x, int y) { FormattedCharSequence formattedcharsequence = currentType.getName().getVisualOrderText(); - this.font.draw(poseStack, formattedcharsequence, (212 + ComputerSidebar.WIDTH - (float) this.font.width(formattedcharsequence) / 2), 133, 4210752); + this.font.draw(poseStack, formattedcharsequence, + (212 + ComputerSidebar.WIDTH - (float) this.font.width(formattedcharsequence) / 2), 133, 4210752); } public void setCurrentType(SlotType currentType) { diff --git a/src/main/java/de/srendi/advancedperipherals/client/screens/base/BaseItemScreen.java b/src/main/java/de/srendi/advancedperipherals/client/screens/base/BaseItemScreen.java index a7e7e9476..e73281849 100644 --- a/src/main/java/de/srendi/advancedperipherals/client/screens/base/BaseItemScreen.java +++ b/src/main/java/de/srendi/advancedperipherals/client/screens/base/BaseItemScreen.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.client.screens.base; import com.mojang.blaze3d.systems.RenderSystem; diff --git a/src/main/java/de/srendi/advancedperipherals/client/screens/base/BaseScreen.java b/src/main/java/de/srendi/advancedperipherals/client/screens/base/BaseScreen.java index 9390fa902..d9cbb583a 100644 --- a/src/main/java/de/srendi/advancedperipherals/client/screens/base/BaseScreen.java +++ b/src/main/java/de/srendi/advancedperipherals/client/screens/base/BaseScreen.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.client.screens.base; import com.mojang.blaze3d.systems.RenderSystem; diff --git a/src/main/java/de/srendi/advancedperipherals/client/widgets/SmartGlassesSettingsSwitch.java b/src/main/java/de/srendi/advancedperipherals/client/widgets/SmartGlassesSettingsSwitch.java index 3ee6e1fb1..e4edc0edd 100644 --- a/src/main/java/de/srendi/advancedperipherals/client/widgets/SmartGlassesSettingsSwitch.java +++ b/src/main/java/de/srendi/advancedperipherals/client/widgets/SmartGlassesSettingsSwitch.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.client.widgets; import com.mojang.blaze3d.systems.RenderSystem; @@ -18,7 +33,8 @@ public class SmartGlassesSettingsSwitch extends AbstractWidget { - private static final ResourceLocation BACKGROUND = new ResourceLocation(AdvancedPeripherals.MOD_ID, "textures/gui/smart_glasses_gui.png"); + private static final ResourceLocation BACKGROUND = new ResourceLocation(AdvancedPeripherals.MOD_ID, + "textures/gui/smart_glasses_gui.png"); private final SmartGlassesScreen screen; private final SlotType type; diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/APAddons.java b/src/main/java/de/srendi/advancedperipherals/common/addons/APAddons.java index 5bdce0093..1e0568315 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/APAddons.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/APAddons.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons; import de.srendi.advancedperipherals.AdvancedPeripherals; @@ -35,7 +50,8 @@ public class APAddons { public static boolean aeAdditionsLoaded; public static boolean appMekLoaded; - // Use static so these checks run as early as possible, so we can use them for our registries + // Use static so these checks run as early as possible, so we can use them for + // our registries static { ModList modList = ModList.get(); curiosLoaded = modList.isLoaded(CURIOS_MODID); @@ -55,11 +71,8 @@ public static void interModComms(InterModEnqueueEvent event) { if (!curiosLoaded) return; - InterModComms.sendTo(CURIOS_MODID, SlotTypeMessage.REGISTER_TYPE, - () -> new SlotTypeMessage.Builder("glasses") - .size(1) - .icon(new ResourceLocation(AdvancedPeripherals.MOD_ID, "slot/empty_glasses_slot")) - .build()); + InterModComms.sendTo(CURIOS_MODID, SlotTypeMessage.REGISTER_TYPE, () -> new SlotTypeMessage.Builder("glasses") + .size(1).icon(new ResourceLocation(AdvancedPeripherals.MOD_ID, "slot/empty_glasses_slot")).build()); } public static ItemStack getCurioGlasses(Player player) { 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 c640159b9..0541d3df2 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 @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.appliedenergistics; import appeng.api.crafting.IPatternDetails; @@ -8,7 +23,12 @@ import appeng.api.networking.crafting.ICraftingCPU; import appeng.api.networking.crafting.ICraftingService; import appeng.api.networking.storage.IStorageService; -import appeng.api.stacks.*; +import appeng.api.stacks.AEFluidKey; +import appeng.api.stacks.AEItemKey; +import appeng.api.stacks.AEKey; +import appeng.api.stacks.AEKeyType; +import appeng.api.stacks.GenericStack; +import appeng.api.stacks.KeyCounter; import appeng.api.storage.AEKeyFilter; import appeng.api.storage.IStorageProvider; import appeng.api.storage.MEStorage; @@ -51,16 +71,25 @@ import net.minecraftforge.registries.ForgeRegistries; import org.jetbrains.annotations.Nullable; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; import java.util.stream.Collectors; public class AppEngApi { - public static Pair findAEStackFromStack(MEStorage monitor, @Nullable ICraftingService crafting, ItemStack item) { + public static Pair findAEStackFromStack(MEStorage monitor, @Nullable ICraftingService crafting, + ItemStack item) { return findAEStackFromFilter(monitor, crafting, ItemFilter.fromStack(item)); } - public static Pair findAEStackFromFilter(MEStorage monitor, @Nullable ICraftingService crafting, ItemFilter item) { + public static Pair findAEStackFromFilter(MEStorage monitor, @Nullable ICraftingService crafting, + ItemFilter item) { for (Object2LongMap.Entry temp : monitor.getAvailableStacks()) { if (temp.getKey() instanceof AEItemKey key && item.test(key.toStack())) return Pair.of(temp.getLongValue(), key); @@ -77,11 +106,13 @@ public static Pair findAEStackFromFilter(MEStorage monitor, @Nu return Pair.of(0L, AEItemKey.of(ItemStack.EMPTY)); } - public static Pair findAEFluidFromStack(MEStorage monitor, @Nullable ICraftingService crafting, FluidStack item) { + public static Pair findAEFluidFromStack(MEStorage monitor, @Nullable ICraftingService crafting, + FluidStack item) { return findAEFluidFromFilter(monitor, crafting, FluidFilter.fromStack(item)); } - public static Pair findAEFluidFromFilter(MEStorage monitor, @Nullable ICraftingService crafting, FluidFilter item) { + public static Pair findAEFluidFromFilter(MEStorage monitor, @Nullable ICraftingService crafting, + FluidFilter item) { for (Object2LongMap.Entry temp : monitor.getAvailableStacks()) { if (temp.getKey() instanceof AEFluidKey key && item.test(key.toStack(1))) return Pair.of(temp.getLongValue(), key); @@ -101,15 +132,20 @@ public static Pair findAEFluidFromFilter(MEStorage monitor, @N /** * Finds a pattern from filters. * - * @param grid The grid to search patterns from. - * @param level The level of the grid. - * @param inputFilter The input filter to apply, can be null to ignore input filter. - * @param outputFilter The output filter to apply, can be null to ignore output filter. - * @return A Pair object containing the matched pattern and an error message if no pattern is found. - * The pattern can be null if no pattern is found. - * The error message is "NO_PATTERN_FOUND" if no pattern is found. + * @param grid + * The grid to search patterns from. + * @param level + * The level of the grid. + * @param inputFilter + * The input filter to apply, can be null to ignore input filter. + * @param outputFilter + * The output filter to apply, can be null to ignore output filter. + * @return A Pair object containing the matched pattern and an error message if + * no pattern is found. The pattern can be null if no pattern is found. + * The error message is "NO_PATTERN_FOUND" if no pattern is found. */ - public static Pair findPatternFromFilters(IGrid grid, Level level, @Nullable GenericFilter inputFilter, @Nullable GenericFilter outputFilter) { + public static Pair findPatternFromFilters(IGrid grid, Level level, + @Nullable GenericFilter inputFilter, @Nullable GenericFilter outputFilter) { for (IPatternDetails pattern : getPatterns(grid, level)) { if (pattern.getInputs().length == 0) continue; @@ -120,8 +156,7 @@ public static Pair findPatternFromFilters(IGrid grid, L boolean outputMatch = false; if (inputFilter != null) { - outerLoop: - for (IPatternDetails.IInput input : pattern.getInputs()) { + outerLoop : for (IPatternDetails.IInput input : pattern.getInputs()) { for (GenericStack possibleInput : input.getPossibleInputs()) { if (inputFilter.test(possibleInput)) { inputMatch = true; @@ -151,7 +186,6 @@ public static Pair findPatternFromFilters(IGrid grid, L return Pair.of(null, "NO_PATTERN_FOUND"); } - public static List listStacks(MEStorage monitor, ICraftingService service) { List items = new ArrayList<>(); KeyCounter keyCounter = monitor.getAvailableStacks(); @@ -256,7 +290,8 @@ private static Class tryCastMachineToContainer(Class return null; } - public static Map getObjectFromStack(Pair stack, @Nullable ICraftingService service) { + public static Map getObjectFromStack(Pair stack, + @Nullable ICraftingService service) { if (stack.getRight() == null) return Collections.emptyMap(); if (stack.getRight() instanceof AEItemKey itemKey) @@ -266,7 +301,8 @@ public static Map getObjectFromStack(Pair getObjectFromCell(BasicStorageCell cell, ItemS return map; } - private static Map getObjectFromItemStack(Pair stack, @Nullable ICraftingService craftingService) { + private static Map getObjectFromItemStack(Pair stack, + @Nullable ICraftingService craftingService) { Map map = new HashMap<>(); String displayName = stack.getRight().getDisplayName().getString(); CompoundTag nbt = stack.getRight().toTag(); @@ -334,7 +371,8 @@ private static Map getObjectFromItemStack(Pair return map; } - private static Map getObjectFromFluidStack(Pair stack, @Nullable ICraftingService craftingService) { + private static Map getObjectFromFluidStack(Pair stack, + @Nullable ICraftingService craftingService) { Map map = new HashMap<>(); long amount = stack.getLeft(); map.put("name", ForgeRegistries.FLUIDS.getKey(stack.getRight().getFluid()).toString()); @@ -346,7 +384,8 @@ private static Map getObjectFromFluidStack(Pair getObjectFromGasStack(Pair stack, @Nullable ICraftingService craftingService) { + private static Map getObjectFromGasStack(Pair stack, + @Nullable ICraftingService craftingService) { Map map = new HashMap<>(); long amount = stack.getLeft(); map.put("name", stack.getRight().getStack().getTypeRegistryName().toString()); @@ -360,8 +399,10 @@ private static Map getObjectFromGasStack(Pair public static Map getObjectFromPattern(IPatternDetails pattern) { Map map = new HashMap<>(); - map.put("inputs", Arrays.stream(pattern.getInputs()).map(AppEngApi::getObjectFromPatternInput).collect(Collectors.toList())); - map.put("outputs", Arrays.stream(pattern.getOutputs()).map(AppEngApi::getObjectFromGenericStack).collect(Collectors.toList())); + map.put("inputs", Arrays.stream(pattern.getInputs()).map(AppEngApi::getObjectFromPatternInput) + .collect(Collectors.toList())); + map.put("outputs", Arrays.stream(pattern.getOutputs()).map(AppEngApi::getObjectFromGenericStack) + .collect(Collectors.toList())); map.put("primaryOutput", getObjectFromGenericStack(pattern.getPrimaryOutput())); return map; } @@ -369,9 +410,9 @@ public static Map getObjectFromPattern(IPatternDetails pattern) public static Map getObjectFromPatternInput(IPatternDetails.IInput patternInput) { Map map = new HashMap<>(); map.put("primaryInput", getObjectFromGenericStack(patternInput.getPossibleInputs()[0])); - map.put("possibleInputs", - Arrays.stream(Arrays.copyOfRange(patternInput.getPossibleInputs(), 1, patternInput.getPossibleInputs().length)) - .map(AppEngApi::getObjectFromGenericStack)); + map.put("possibleInputs", Arrays.stream( + Arrays.copyOfRange(patternInput.getPossibleInputs(), 1, patternInput.getPossibleInputs().length)) + .map(AppEngApi::getObjectFromGenericStack)); map.put("multiplier", patternInput.getMultiplier()); map.put("remaining", patternInput.getRemainingKey(patternInput.getPossibleInputs()[0].what())); return map; @@ -421,7 +462,7 @@ public static MEStorage getMonitor(IGridNode node) { } public static boolean isItemCrafting(MEStorage monitor, ICraftingService grid, ItemFilter filter, - @Nullable ICraftingCPU craftingCPU) { + @Nullable ICraftingCPU craftingCPU) { Pair stack = AppEngApi.findAEStackFromFilter(monitor, grid, filter); // If the item stack does not exist, it cannot be crafted. @@ -459,7 +500,7 @@ public static boolean isItemCrafting(MEStorage monitor, ICraftingService grid, I } public static boolean isFluidCrafting(MEStorage monitor, ICraftingService grid, FluidFilter filter, - @Nullable ICraftingCPU craftingCPU) { + @Nullable ICraftingCPU craftingCPU) { Pair stack = AppEngApi.findAEFluidFromFilter(monitor, grid, filter); // If the fluid stack does not exist, it cannot be crafted. @@ -511,7 +552,8 @@ public static long getTotalExternalItemStorage(IGridNode node) { if (connectedInventoryEntity == null) continue; - LazyOptional itemHandler = connectedInventoryEntity.getCapability(ForgeCapabilities.ITEM_HANDLER); + LazyOptional itemHandler = connectedInventoryEntity + .getCapability(ForgeCapabilities.ITEM_HANDLER); if (itemHandler.isPresent()) { IItemHandler handler = itemHandler.orElse(null); for (int i = 0; i < handler.getSlots(); i++) { @@ -535,7 +577,8 @@ public static long getTotalExternalFluidStorage(IGridNode node) { if (connectedInventoryEntity == null) continue; - LazyOptional fluidHandler = connectedInventoryEntity.getCapability(ForgeCapabilities.FLUID_HANDLER); + LazyOptional fluidHandler = connectedInventoryEntity + .getCapability(ForgeCapabilities.FLUID_HANDLER); if (fluidHandler.isPresent()) { IFluidHandler handler = fluidHandler.orElse(null); for (int i = 0; i < handler.getTanks(); i++) { @@ -563,7 +606,10 @@ public static long getTotalExternalChemicalStorage(IGridNode node) { continue; if (connectedInventoryEntity instanceof TileEntityChemicalTank tank) { - MergedChemicalTank.Current current = tank.getChemicalTank().getCurrent() == MergedChemicalTank.Current.EMPTY ? MergedChemicalTank.Current.GAS : tank.getChemicalTank().getCurrent(); + MergedChemicalTank.Current current = tank.getChemicalTank() + .getCurrent() == MergedChemicalTank.Current.EMPTY + ? MergedChemicalTank.Current.GAS + : tank.getChemicalTank().getCurrent(); total += tank.getChemicalTank().getTankFromCurrent(current).getCapacity(); } } @@ -630,7 +676,8 @@ public static long getUsedExternalChemicalStorage(IGridNode node) { public static long getTotalItemStorage(IGridNode node) { long total = 0; - // note: do not query DriveBlockEntity.class specifically here, because it will avoid subclasses, e.g. the ME Extended Drive from ExtendedAE + // note: do not query DriveBlockEntity.class specifically here, because it will + // avoid subclasses, e.g. the ME Extended Drive from ExtendedAE Iterator iterator = node.getGrid().getNodes().iterator(); while (iterator.hasNext()) { @@ -653,7 +700,8 @@ public static long getTotalItemStorage(IGridNode node) { if (disk.getKeyType().toString().equals("ae2:i")) { total += disk.getBytes(null); } - } else if (APAddons.aeAdditionsLoaded && (stack.getItem() instanceof SuperStorageCell superStorageCell)) { + } else if (APAddons.aeAdditionsLoaded + && (stack.getItem() instanceof SuperStorageCell superStorageCell)) { total += superStorageCell.getKiloBytes() * 1024L; } else if (APAddons.aeAdditionsLoaded && (stack.getItem() instanceof StorageCell storageCell)) { if (storageCell.getKeyType() != AEKeyType.items()) @@ -853,10 +901,11 @@ public static long getUsedChemicalStorage(IGridNode node) { /// Available Storage /** - * Calculates the available item storage on a given grid node. - * It subtracts the used item storage from the total item storage. + * Calculates the available item storage on a given grid node. It subtracts the + * used item storage from the total item storage. * - * @param node The grid node to calculate the available item storage for. + * @param node + * The grid node to calculate the available item storage for. * @return The available item storage in bytes. */ public static long getAvailableItemStorage(IGridNode node) { @@ -866,7 +915,8 @@ public static long getAvailableItemStorage(IGridNode node) { /** * Calculates the available fluid storage in a given grid node. * - * @param node The grid node to calculate the available fluid storage for. + * @param node + * The grid node to calculate the available fluid storage for. * @return The available fluid storage in bytes. */ public static long getAvailableFluidStorage(IGridNode node) { @@ -880,7 +930,9 @@ public static long getAvailableChemicalStorage(IGridNode node) { /** * Calculates the available external item storage of a given grid node. * - * @param node The grid node for which to calculate the available external item storage. + * @param node + * The grid node for which to calculate the available external item + * storage. * @return The available external item storage. */ public static long getAvailableExternalItemStorage(IGridNode node) { @@ -888,10 +940,13 @@ public static long getAvailableExternalItemStorage(IGridNode node) { } /** - * Calculates the available external fluid storage on a given grid node by subtracting the used external fluid storage - * from the total external fluid storage. + * Calculates the available external fluid storage on a given grid node by + * subtracting the used external fluid storage from the total external fluid + * storage. * - * @param node The grid node on which to calculate the available external fluid storage. + * @param node + * The grid node on which to calculate the available external fluid + * storage. * @return The available external fluid storage on the grid node. */ public static long getAvailableExternalFluidStorage(IGridNode node) { @@ -903,12 +958,15 @@ public static long getAvailableExternalChemicalStorage(IGridNode node) { } public static ICraftingCPU getCraftingCPU(IGridNode node, String cpuName) { - if (cpuName.isEmpty()) return null; + if (cpuName.isEmpty()) + return null; ICraftingService grid = node.getGrid().getService(ICraftingService.class); - if (grid == null) return null; + if (grid == null) + return null; Iterator iterator = grid.getCpus().iterator(); - if (!iterator.hasNext()) return null; + if (!iterator.hasNext()) + return null; while (iterator.hasNext()) { ICraftingCPU cpu = iterator.next(); @@ -926,7 +984,8 @@ public static List listCells(IGridNode node) { Iterator iterator = node.getGrid().getMachineNodes(DriveBlockEntity.class).iterator(); - if (!iterator.hasNext()) return items; + if (!iterator.hasNext()) + return items; while (iterator.hasNext()) { DriveBlockEntity entity = (DriveBlockEntity) iterator.next().getService(IStorageProvider.class); if (entity == null) 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 05db7c7c6..69a0ace29 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 @@ -1,8 +1,27 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.appliedenergistics; import appeng.api.networking.IGrid; import appeng.api.networking.IGridNode; -import appeng.api.networking.crafting.*; +import appeng.api.networking.crafting.CalculationStrategy; +import appeng.api.networking.crafting.ICraftingCPU; +import appeng.api.networking.crafting.ICraftingPlan; +import appeng.api.networking.crafting.ICraftingService; +import appeng.api.networking.crafting.ICraftingSimulationRequester; import appeng.api.networking.security.IActionSource; import appeng.api.stacks.AEKey; import dan200.computercraft.api.lua.ILuaCallback; @@ -36,8 +55,8 @@ public class CraftJob implements ILuaCallback { private MethodResult result; private LuaException exception; - public CraftJob(Level world, final IComputerAccess computer, IGridNode node, AEKey item, long amount, IActionSource source, - ICraftingSimulationRequester requester, ICraftingCPU target) { + public CraftJob(Level world, final IComputerAccess computer, IGridNode node, AEKey item, long amount, + IActionSource source, ICraftingSimulationRequester requester, ICraftingCPU target) { this.computer = computer; this.node = node; this.world = world; @@ -68,7 +87,7 @@ public boolean isCraftingStarted() { public void startCrafting() { IGrid grid = node.getGrid(); - if (grid == null) { //true when the block is not connected + if (grid == null) { // true when the block is not connected fireNotConnected(); return; } @@ -85,8 +104,10 @@ public void startCrafting() { return; } - futureJob = crafting.beginCraftingCalculation(world, this.requester, item, amount, CalculationStrategy.REPORT_MISSING_ITEMS); - fireEvent(true, "Started calculation of the recipe. After it's finished, the system will start crafting the item."); + futureJob = crafting.beginCraftingCalculation(world, this.requester, item, amount, + CalculationStrategy.REPORT_MISSING_ITEMS); + fireEvent(true, + "Started calculation of the recipe. After it's finished, the system will start crafting the item."); } public void maybeCraft() { @@ -96,7 +117,8 @@ public void maybeCraft() { try { job = futureJob.get(); } catch (ExecutionException | InterruptedException ex) { - AdvancedPeripherals.debug("Tried to get job, but job calculation is not done. Should be done.", org.apache.logging.log4j.Level.FATAL); + AdvancedPeripherals.debug("Tried to get job, but job calculation is not done. Should be done.", + org.apache.logging.log4j.Level.FATAL); ex.printStackTrace(); return; } @@ -115,7 +137,8 @@ public void maybeCraft() { return; } - //TODO: Create events or methods like `isCraftingFinished` or `getCraftingJobState` + // TODO: Create events or methods like `isCraftingFinished` or + // `getCraftingJobState` ICraftingService crafting = grid.getService(ICraftingService.class); crafting.submitJob(job, null, target, false, this.source); @@ -124,11 +147,12 @@ public void maybeCraft() { this.futureJob = null; } - @NotNull - @Override + @NotNull @Override public MethodResult resume(Object[] objects) { - if (result != null) return result; - if (exception != null) return MethodResult.of(exception); + if (result != null) + return result; + if (exception != null) + return MethodResult.of(exception); return MethodResult.of(); } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/appliedenergistics/MeBridgeEntityListener.java b/src/main/java/de/srendi/advancedperipherals/common/addons/appliedenergistics/MeBridgeEntityListener.java index 10cc242fb..b53d30d13 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/appliedenergistics/MeBridgeEntityListener.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/appliedenergistics/MeBridgeEntityListener.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.appliedenergistics; import appeng.api.networking.IGridNode; diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/appliedenergistics/MeFluidHandler.java b/src/main/java/de/srendi/advancedperipherals/common/addons/appliedenergistics/MeFluidHandler.java index 6f10b6be9..562bbfeaf 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/appliedenergistics/MeFluidHandler.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/appliedenergistics/MeFluidHandler.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.appliedenergistics; import appeng.api.config.Actionable; @@ -17,10 +32,8 @@ */ public class MeFluidHandler implements IStorageSystemFluidHandler { - @NotNull - private final MEStorage storageMonitor; - @NotNull - private final IActionSource actionSource; + @NotNull private final MEStorage storageMonitor; + @NotNull private final IActionSource actionSource; public MeFluidHandler(@NotNull MEStorage storageMonitor, @NotNull IActionSource actionSource) { this.storageMonitor = storageMonitor; @@ -32,18 +45,19 @@ public int fill(FluidStack resource, FluidAction action) { if (resource.isEmpty()) return 0; AEFluidKey itemKey = AEFluidKey.of(resource.getFluid()); - long inserted = storageMonitor.insert(itemKey, resource.getAmount(), action == FluidAction.SIMULATE ? Actionable.SIMULATE : Actionable.MODULATE, actionSource); + long inserted = storageMonitor.insert(itemKey, resource.getAmount(), + action == FluidAction.SIMULATE ? Actionable.SIMULATE : Actionable.MODULATE, actionSource); return (int) Math.min(inserted, Integer.MAX_VALUE); } - @NotNull - @Override + @NotNull @Override public FluidStack drain(FluidFilter filter, FluidAction simulate) { Pair itemKey = AppEngApi.findAEFluidFromFilter(storageMonitor, null, filter); if (itemKey == null) return FluidStack.EMPTY; - long extracted = storageMonitor.extract(itemKey.getRight(), filter.getCount(), simulate == FluidAction.SIMULATE ? Actionable.SIMULATE : Actionable.MODULATE, actionSource); + long extracted = storageMonitor.extract(itemKey.getRight(), filter.getCount(), + simulate == FluidAction.SIMULATE ? Actionable.SIMULATE : Actionable.MODULATE, actionSource); return new FluidStack(itemKey.getRight().getFluid(), (int) Math.min(extracted, Integer.MAX_VALUE)); } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/appliedenergistics/MeItemHandler.java b/src/main/java/de/srendi/advancedperipherals/common/addons/appliedenergistics/MeItemHandler.java index a3542cda3..59d7c3a04 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/appliedenergistics/MeItemHandler.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/appliedenergistics/MeItemHandler.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.appliedenergistics; import appeng.api.config.Actionable; @@ -17,21 +32,19 @@ */ public class MeItemHandler implements IStorageSystemItemHandler { - @NotNull - private final MEStorage storageMonitor; - @NotNull - private final IActionSource actionSource; + @NotNull private final MEStorage storageMonitor; + @NotNull private final IActionSource actionSource; public MeItemHandler(@NotNull MEStorage storageMonitor, @NotNull IActionSource actionSource) { this.storageMonitor = storageMonitor; this.actionSource = actionSource; } - @NotNull - @Override + @NotNull @Override public ItemStack insertItem(int slot, @NotNull ItemStack stack, boolean simulate) { AEItemKey itemKey = AEItemKey.of(stack.getItem(), stack.getTag()); - long inserted = storageMonitor.insert(itemKey, stack.getCount(), simulate ? Actionable.SIMULATE : Actionable.MODULATE, actionSource); + long inserted = storageMonitor.insert(itemKey, stack.getCount(), + simulate ? Actionable.SIMULATE : Actionable.MODULATE, actionSource); ItemStack insertedStack = stack.copy(); // Safe to cast here, the amount will never be higher than 64 insertedStack.setCount(insertedStack.getCount() - (int) inserted); @@ -43,7 +56,8 @@ public ItemStack extractItem(ItemFilter filter, int count, boolean simulate) { Pair itemKey = AppEngApi.findAEStackFromFilter(storageMonitor, null, filter); if (itemKey.getRight() == null) return ItemStack.EMPTY; - long extracted = storageMonitor.extract(itemKey.getRight(), count, simulate ? Actionable.SIMULATE : Actionable.MODULATE, actionSource); + long extracted = storageMonitor.extract(itemKey.getRight(), count, + simulate ? Actionable.SIMULATE : Actionable.MODULATE, actionSource); // Safe to cast here, the amount will never be higher than 64 ItemStack stack = itemKey.getRight().toStack(); stack.setCount((int) extracted); diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/botania/Integration.java b/src/main/java/de/srendi/advancedperipherals/common/addons/botania/Integration.java index f0dc96e86..cc876c29f 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/botania/Integration.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/botania/Integration.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.botania; import de.srendi.advancedperipherals.common.addons.computercraft.integrations.IntegrationPeripheralProvider; @@ -9,8 +24,11 @@ public class Integration implements Runnable { @Override public void run() { - IntegrationPeripheralProvider.registerBlockEntityIntegration(ManaFlowerIntegration::new, GeneratingFlowerBlockEntity.class); - IntegrationPeripheralProvider.registerBlockEntityIntegration(ManaPoolIntegration::new, ManaPoolBlockEntity.class); - IntegrationPeripheralProvider.registerBlockEntityIntegration(SpreaderIntegration::new, ManaSpreaderBlockEntity.class); + IntegrationPeripheralProvider.registerBlockEntityIntegration(ManaFlowerIntegration::new, + GeneratingFlowerBlockEntity.class); + IntegrationPeripheralProvider.registerBlockEntityIntegration(ManaPoolIntegration::new, + ManaPoolBlockEntity.class); + IntegrationPeripheralProvider.registerBlockEntityIntegration(SpreaderIntegration::new, + ManaSpreaderBlockEntity.class); } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/botania/ManaFlowerIntegration.java b/src/main/java/de/srendi/advancedperipherals/common/addons/botania/ManaFlowerIntegration.java index fb3c8e1c2..f12f024b8 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/botania/ManaFlowerIntegration.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/botania/ManaFlowerIntegration.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.botania; import dan200.computercraft.api.lua.LuaFunction; @@ -12,8 +27,7 @@ public ManaFlowerIntegration(BlockEntity entity) { super(entity); } - @NotNull - @Override + @NotNull @Override public String getType() { return "mana_flower"; } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/botania/ManaPoolIntegration.java b/src/main/java/de/srendi/advancedperipherals/common/addons/botania/ManaPoolIntegration.java index 2d2fb83c9..b228674eb 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/botania/ManaPoolIntegration.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/botania/ManaPoolIntegration.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.botania; import dan200.computercraft.api.lua.LuaFunction; @@ -12,8 +27,7 @@ public ManaPoolIntegration(BlockEntity entity) { super(entity); } - @NotNull - @Override + @NotNull @Override public String getType() { return "mana_pool"; } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/botania/SpreaderIntegration.java b/src/main/java/de/srendi/advancedperipherals/common/addons/botania/SpreaderIntegration.java index d615db44f..f6da34072 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/botania/SpreaderIntegration.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/botania/SpreaderIntegration.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.botania; import dan200.computercraft.api.lua.LuaFunction; @@ -13,8 +28,7 @@ public SpreaderIntegration(BlockEntity entity) { super(entity); } - @NotNull - @Override + @NotNull @Override public String getType() { return "mana_spreader"; } @@ -31,7 +45,8 @@ public final int getMaxMana() { @LuaFunction(mainThread = true) public final Object getBounding() { - if (blockEntity.getBinding() == null) return null; + if (blockEntity.getBinding() == null) + return null; return LuaConverter.posToObject(blockEntity.getBinding()); } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/integrations/BeaconIntegration.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/integrations/BeaconIntegration.java index 0a35755df..e4d9bcb20 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/integrations/BeaconIntegration.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/integrations/BeaconIntegration.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.integrations; import dan200.computercraft.api.lua.LuaFunction; diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/integrations/BlockEntityIntegration.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/integrations/BlockEntityIntegration.java index faadf8c24..6ba349d16 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/integrations/BlockEntityIntegration.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/integrations/BlockEntityIntegration.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.integrations; import dan200.computercraft.api.peripheral.IPeripheral; @@ -19,27 +34,32 @@ public class BlockEntityIntegration implements IPeripheralIntegration { private final Predicate predicate; private final int priority; - public BlockEntityIntegration(Function build, Predicate predicate, int priority) { + public BlockEntityIntegration(Function build, Predicate predicate, + int priority) { this.build = build; this.predicate = predicate; this.priority = priority; } - public BlockEntityIntegration(Function build, Predicate predicate) { + public BlockEntityIntegration(Function build, + Predicate predicate) { this(build, predicate, DEFAULT_PRIORITY); } @Override public boolean isSuitable(@NotNull Level level, @NotNull BlockPos blockPos, @NotNull Direction direction) { BlockEntity te = level.getBlockEntity(blockPos); - if (te == null) return false; + if (te == null) + return false; return predicate.test(te); } @Override - public @NotNull IPeripheral buildPeripheral(@NotNull Level level, @NotNull BlockPos blockPos, @NotNull Direction direction) { + public @NotNull IPeripheral buildPeripheral(@NotNull Level level, @NotNull BlockPos blockPos, + @NotNull Direction direction) { BlockEntity te = level.getBlockEntity(blockPos); - if (te == null) throw new IllegalArgumentException("This should not happen"); + if (te == null) + throw new IllegalArgumentException("This should not happen"); return build.apply(te); } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/integrations/BlockIntegration.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/integrations/BlockIntegration.java index 909ca1afa..a95c029f1 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/integrations/BlockIntegration.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/integrations/BlockIntegration.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.integrations; import dan200.computercraft.api.peripheral.IPeripheral; @@ -19,7 +34,8 @@ public class BlockIntegration implements IPeripheralIntegration { private final Predicate predicate; private final int priority; - public BlockIntegration(BiFunction build, Predicate predicate, int priority) { + public BlockIntegration(BiFunction build, Predicate predicate, + int priority) { this.build = build; this.predicate = predicate; this.priority = priority; @@ -36,7 +52,8 @@ public boolean isSuitable(@NotNull Level world, @NotNull BlockPos blockPos, @Not } @Override - public @NotNull IPeripheral buildPeripheral(@NotNull Level world, @NotNull BlockPos blockPos, @NotNull Direction direction) { + public @NotNull IPeripheral buildPeripheral(@NotNull Level world, @NotNull BlockPos blockPos, + @NotNull Direction direction) { return build.apply(world, blockPos); } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/integrations/IntegrationPeripheralProvider.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/integrations/IntegrationPeripheralProvider.java index 2d9ccb553..76ec418e6 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/integrations/IntegrationPeripheralProvider.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/integrations/IntegrationPeripheralProvider.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.integrations; import dan200.computercraft.api.peripheral.IPeripheral; @@ -25,47 +40,68 @@ public class IntegrationPeripheralProvider implements IPeripheralProvider { private static final String[] SUPPORTED_MODS = new String[]{"botania", "create", "mekanism", "powah", "dimstorage"}; - private static final PriorityQueue integrations = new PriorityQueue<>(Comparator.comparingInt(IPeripheralIntegration::getPriority)); + private static final PriorityQueue integrations = new PriorityQueue<>( + Comparator.comparingInt(IPeripheralIntegration::getPriority)); private static void registerIntegration(IPeripheralIntegration integration) { integrations.add(integration); } /** - * Register tile entity integration, better use this method over manual TileEntityIntegration creation, because this method provides type check + * Register tile entity integration, better use this method over manual + * TileEntityIntegration creation, because this method provides type check * - * @param integration integration generator - * @param tileClass target integration class - * @param target integration + * @param integration + * integration generator + * @param tileClass + * target integration class + * @param + * target integration */ - public static void registerBlockEntityIntegration(Function> integration, Class tileClass) { + public static void registerBlockEntityIntegration( + Function> integration, Class tileClass) { registerIntegration(new BlockEntityIntegration(integration, tileClass::isInstance)); } /** - * Register tile entity integration, better use this method over manual TileEntityIntegration creation, because this method provides type check + * Register tile entity integration, better use this method over manual + * TileEntityIntegration creation, because this method provides type check * - * @param integration integration generator - * @param tileClass target integration class - * @param priority Integration priority, lower is better - * @param target integration + * @param integration + * integration generator + * @param tileClass + * target integration class + * @param priority + * Integration priority, lower is better + * @param + * target integration */ - public static void registerBlockEntityIntegration(Function> integration, Class tileClass, int priority) { + public static void registerBlockEntityIntegration( + Function> integration, Class tileClass, int priority) { registerIntegration(new BlockEntityIntegration(integration, tileClass::isInstance, priority)); } /** - * Register tile entity integration, better use this method over manual TileEntityIntegration creation, because this method provides type check + * Register tile entity integration, better use this method over manual + * TileEntityIntegration creation, because this method provides type check * Provides a predicate for specific block entity checks * - * @param integration integration generator - * @param tileClass target integration class - * @param predicate target block entity - * @param priority Integration priority, lower is better - * @param target integration + * @param integration + * integration generator + * @param tileClass + * target integration class + * @param predicate + * target block entity + * @param priority + * Integration priority, lower is better + * @param + * target integration */ - public static void registerBlockEntityIntegration(Function> integration, Class tileClass, Predicate predicate, int priority) { - registerIntegration(new BlockEntityIntegration(integration, tile -> tileClass.isInstance(tile) && predicate.test((T) tile), priority)); + public static void registerBlockEntityIntegration( + Function> integration, Class tileClass, + Predicate predicate, int priority) { + registerIntegration(new BlockEntityIntegration(integration, + tile -> tileClass.isInstance(tile) && predicate.test((T) tile), priority)); } public static void load() { @@ -78,13 +114,14 @@ public static void load() { AdvancedPeripherals.LOGGER.warn("Successfully loaded integration for {}", mod); ((Runnable) obj).run(); }); - if (integration.isEmpty()) AdvancedPeripherals.LOGGER.warn("Failed to load integration for {}", mod); + if (integration.isEmpty()) + AdvancedPeripherals.LOGGER.warn("Failed to load integration for {}", mod); } } - @NotNull - @Override - public LazyOptional getPeripheral(@NotNull Level level, @NotNull BlockPos blockPos, @NotNull Direction direction) { + @NotNull @Override + public LazyOptional getPeripheral(@NotNull Level level, @NotNull BlockPos blockPos, + @NotNull Direction direction) { for (IPeripheralIntegration integration : integrations) { if (integration.isSuitable(level, blockPos, direction)) return LazyOptional.of(() -> integration.buildPeripheral(level, blockPos, direction)); diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/integrations/NoteBlockIntegration.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/integrations/NoteBlockIntegration.java index ad5a653d3..2bcadd9ad 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/integrations/NoteBlockIntegration.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/integrations/NoteBlockIntegration.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.integrations; import dan200.computercraft.api.lua.LuaException; @@ -16,8 +31,7 @@ public NoteBlockIntegration(Level world, BlockPos pos) { super(world, pos); } - @NotNull - @Override + @NotNull @Override public String getType() { return "noteBlock"; } @@ -25,8 +39,10 @@ public String getType() { @LuaFunction(mainThread = true) public final int changeNote() { BlockState state = world.getBlockState(pos); - int newNote = net.minecraftforge.common.ForgeHooks.onNoteChange(world, pos, state, state.getValue(NoteBlock.NOTE), state.cycle(NoteBlock.NOTE).getValue(NoteBlock.NOTE)); - if (newNote == -1) return -1; + int newNote = net.minecraftforge.common.ForgeHooks.onNoteChange(world, pos, state, + state.getValue(NoteBlock.NOTE), state.cycle(NoteBlock.NOTE).getValue(NoteBlock.NOTE)); + if (newNote == -1) + return -1; state = state.setValue(NoteBlock.NOTE, newNote); world.setBlock(pos, state, 3); return newNote; @@ -35,7 +51,8 @@ public final int changeNote() { @LuaFunction(mainThread = true) public final int changeNoteBy(int note) throws LuaException { BlockState state = world.getBlockState(pos); - if (!(note >= 0 && note <= 24)) throw new LuaException("Note argument need to be in a range of 0 and 24"); + if (!(note >= 0 && note <= 24)) + throw new LuaException("Note argument need to be in a range of 0 and 24"); state = state.setValue(NoteBlock.NOTE, note); world.setBlock(pos, state, 3); return note; diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/operations/AutomataCoreTier.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/operations/AutomataCoreTier.java index 2166839f8..3c246c62a 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/operations/AutomataCoreTier.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/operations/AutomataCoreTier.java @@ -1,13 +1,25 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.operations; import de.srendi.advancedperipherals.lib.metaphysics.IAutomataCoreTier; import net.minecraftforge.common.ForgeConfigSpec; public enum AutomataCoreTier implements IAutomataCoreTier { - TIER1(2, 2), - TIER2(4, 3), - OVERPOWERED_TIER1(4, 3), - OVERPOWERED_TIER2(6, 4); + TIER1(2, 2), TIER2(4, 3), OVERPOWERED_TIER1(4, 3), OVERPOWERED_TIER2(6, 4); private final int defaultInteractionRadius; private final int defaultMaxFuelConsumptionRate; @@ -21,20 +33,24 @@ public enum AutomataCoreTier implements IAutomataCoreTier { @Override public int getInteractionRadius() { - if (interactionRadius == null) return 0; + if (interactionRadius == null) + return 0; return interactionRadius.get(); } @Override public int getMaxFuelConsumptionRate() { - if (maxFuelConsumptionRate == null) return 0; + if (maxFuelConsumptionRate == null) + return 0; return maxFuelConsumptionRate.get(); } @Override public void addToConfig(ForgeConfigSpec.Builder builder) { - interactionRadius = builder.defineInRange(settingsName() + "InteractionRadius", defaultInteractionRadius, 1, 64); - maxFuelConsumptionRate = builder.defineInRange(settingsName() + "MaxFuelConsumptionRate", defaultMaxFuelConsumptionRate, 1, 32); + interactionRadius = builder.defineInRange(settingsName() + "InteractionRadius", defaultInteractionRadius, 1, + 64); + maxFuelConsumptionRate = builder.defineInRange(settingsName() + "MaxFuelConsumptionRate", + defaultMaxFuelConsumptionRate, 1, 32); } @Override diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/operations/SimpleFreeOperation.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/operations/SimpleFreeOperation.java index b86b1aa39..0864b656b 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/operations/SimpleFreeOperation.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/operations/SimpleFreeOperation.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.operations; import de.srendi.advancedperipherals.lib.peripherals.IPeripheralOperation; diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/operations/SingleOperation.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/operations/SingleOperation.java index df8cd27e9..efc6e71d6 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/operations/SingleOperation.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/operations/SingleOperation.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.operations; import de.srendi.advancedperipherals.lib.peripherals.IPeripheralOperation; @@ -8,12 +23,8 @@ import java.util.function.UnaryOperator; public enum SingleOperation implements IPeripheralOperation { - DIG(1000, 1), - USE_ON_BLOCK(5000, 1), - SUCK(1000, 1), - USE_ON_ANIMAL(2500, 10), - CAPTURE_ANIMAL(50_000, 100), - WARP(1000, DistancePolicy.IGNORED, CountPolicy.MULTIPLY, 1, DistancePolicy.SQRT, CountPolicy.MULTIPLY); + DIG(1000, 1), USE_ON_BLOCK(5000, 1), SUCK(1000, 1), USE_ON_ANIMAL(2500, 10), CAPTURE_ANIMAL(50_000, 100), WARP(1000, + DistancePolicy.IGNORED, CountPolicy.MULTIPLY, 1, DistancePolicy.SQRT, CountPolicy.MULTIPLY); private final int defaultCooldown; private final DistancePolicy distanceCooldownPolicy; @@ -24,7 +35,8 @@ public enum SingleOperation implements IPeripheralOperation 1), - SQRT(d -> (int) Math.sqrt(d)); + IGNORED(d -> 1), SQRT(d -> (int) Math.sqrt(d)); private final UnaryOperator factorFunction; diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/operations/SingleOperationContext.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/operations/SingleOperationContext.java index a8d8b03b5..cb761e421 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/operations/SingleOperationContext.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/operations/SingleOperationContext.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.operations; import java.io.Serializable; diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/operations/SphereOperation.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/operations/SphereOperation.java index 147b06400..9b5f3b7b5 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/operations/SphereOperation.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/operations/SphereOperation.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.operations; import com.google.common.math.IntMath; @@ -8,8 +23,7 @@ import java.util.Map; public enum SphereOperation implements IPeripheralOperation { - SCAN_BLOCKS(2_000, 8, 16, 0.17), - SCAN_ENTITIES(2_000, 8, 16, 0.17); + SCAN_BLOCKS(2_000, 8, 16, 0.17), SCAN_ENTITIES(2_000, 8, 16, 0.17); private final int defaultCooldown; private final int defaultMaxFreeRadius; @@ -20,7 +34,8 @@ public enum SphereOperation implements IPeripheralOperation void attachAbility(PeripheralOwnerAbility ab @SuppressWarnings("unchecked") @Override - @Nullable - public T getAbility(PeripheralOwnerAbility ability) { + @Nullable public T getAbility(PeripheralOwnerAbility ability) { return (T) abilities.get(ability); } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/BlockEntityPeripheralOwner.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/BlockEntityPeripheralOwner.java index 4e7d1bd94..710208f60 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/BlockEntityPeripheralOwner.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/BlockEntityPeripheralOwner.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.owner; import de.srendi.advancedperipherals.common.blocks.base.BaseBlock; @@ -29,46 +44,39 @@ public BlockEntityPeripheralOwner(T tileEntity) { this.tileEntity = tileEntity; } - @Nullable - @Override + @Nullable @Override public String getCustomName() { return tileEntity.getPersistentData().getString("CustomName"); } - @NotNull - @Override + @NotNull @Override public Level getLevel() { return Objects.requireNonNull(tileEntity.getLevel()); } - @NotNull - @Override + @NotNull @Override public BlockPos getPos() { return tileEntity.getBlockPos(); } - @NotNull - @Override + @NotNull @Override public Direction getFacing() { return getOrientation().front(); } - @NotNull - @Override + @NotNull @Override public FrontAndTop getOrientation() { return tileEntity.getBlockState().getValue(BaseBlock.ORIENTATION); } - @Nullable - @Override + @Nullable @Override public Player getOwner() { if (tileEntity instanceof InventoryManagerEntity inventoryManagerEntity) return inventoryManagerEntity.getOwnerPlayer(); return null; } - @NotNull - @Override + @NotNull @Override public CompoundTag getDataStorage() { return DataStorageUtil.getDataStorage(tileEntity); } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/FuelAbility.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/FuelAbility.java index 80ecdefb0..fc65cb6ff 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/FuelAbility.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/FuelAbility.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.owner; import dan200.computercraft.api.lua.LuaFunction; @@ -38,12 +53,15 @@ protected int getConsumptionRate() { /** * Sets the fuel consumption rate * - * @param rate the new fuel consumption rate + * @param rate + * the new fuel consumption rate */ protected void setConsumptionRate(int rate) { - if (rate < DEFAULT_FUEL_CONSUMING_RATE) rate = DEFAULT_FUEL_CONSUMING_RATE; + if (rate < DEFAULT_FUEL_CONSUMING_RATE) + rate = DEFAULT_FUEL_CONSUMING_RATE; int maxFuelRate = getMaxFuelConsumptionRate(); - if (rate > maxFuelRate) rate = maxFuelRate; + if (rate > maxFuelRate) + rate = maxFuelRate; owner.getDataStorage().putInt(FUEL_CONSUMING_RATE_SETTING, rate); } @@ -64,9 +82,11 @@ public int reduceCooldownAccordingToConsumptionRate(int cooldown) { } public boolean consumeFuel(int count, boolean simulate) { - if (isFuelConsumptionDisable()) return true; + if (isFuelConsumptionDisable()) + return true; int realCount = count * getFuelConsumptionMultiply(); - if (simulate) return getFuelLevel() >= realCount; + if (simulate) + return getFuelLevel() >= realCount; return consumeFuel(realCount); } @@ -87,8 +107,10 @@ public final int getFuelConsumptionRate() { @LuaFunction(mainThread = true) public final MethodResult setFuelConsumptionRate(int rate) { - if (rate < 1) return MethodResult.of(null, "Too small fuel consumption rate"); - if (rate > getMaxFuelConsumptionRate()) return MethodResult.of(null, "Too big fuel consumption rate"); + if (rate < 1) + return MethodResult.of(null, "Too small fuel consumption rate"); + if (rate > getMaxFuelConsumptionRate()) + return MethodResult.of(null, "Too big fuel consumption rate"); setConsumptionRate(rate); return MethodResult.of(true); } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/IOwnerAbility.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/IOwnerAbility.java index 038e037c0..bec0f8a25 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/IOwnerAbility.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/IOwnerAbility.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.owner; import java.util.Map; diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/IPeripheralOwner.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/IPeripheralOwner.java index c99e9442b..47b057c48 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/IPeripheralOwner.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/IPeripheralOwner.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.owner; import de.srendi.advancedperipherals.common.util.fakeplayer.APFakePlayer; diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/InfinitePocketFuelAbility.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/InfinitePocketFuelAbility.java index 40e66151c..d16410d52 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/InfinitePocketFuelAbility.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/InfinitePocketFuelAbility.java @@ -1,10 +1,25 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.owner; import org.jetbrains.annotations.NotNull; /** - * This is a copy of the FuelAbility class, but with the fuel consumption disabled. - * This is used for the Pocket Computer. + * This is a copy of the FuelAbility class, but with the fuel consumption + * disabled. This is used for the Pocket Computer. */ public class InfinitePocketFuelAbility extends FuelAbility { @@ -42,4 +57,3 @@ public void addFuel(int count) { // Not needed for infinite fuel } } - 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 af5cf5718..0b72a6657 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 @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.owner; import dan200.computercraft.api.lua.LuaException; @@ -33,17 +48,21 @@ public OperationAbility(IPeripheralOwner owner) { protected void setCooldown(@NotNull IPeripheralOperation operation, int cooldown) { if (cooldown > 0) { CompoundTag dataStorage = owner.getDataStorage(); - if (!dataStorage.contains(COOLDOWNS_TAG)) dataStorage.put(COOLDOWNS_TAG, new CompoundTag()); - dataStorage.getCompound(COOLDOWNS_TAG).putLong(operation.settingsName(), Timestamp.valueOf(LocalDateTime.now().plus(cooldown, ChronoUnit.MILLIS)).getTime()); + if (!dataStorage.contains(COOLDOWNS_TAG)) + dataStorage.put(COOLDOWNS_TAG, new CompoundTag()); + dataStorage.getCompound(COOLDOWNS_TAG).putLong(operation.settingsName(), + Timestamp.valueOf(LocalDateTime.now().plus(cooldown, ChronoUnit.MILLIS)).getTime()); } } protected int getCooldown(@NotNull IPeripheralOperation operation) { CompoundTag dataStorage = owner.getDataStorage(); - if (!dataStorage.contains(COOLDOWNS_TAG)) return 0; + if (!dataStorage.contains(COOLDOWNS_TAG)) + return 0; CompoundTag cooldowns = dataStorage.getCompound(COOLDOWNS_TAG); String operationName = operation.settingsName(); - if (!cooldowns.contains(operationName)) return 0; + if (!cooldowns.contains(operationName)) + return 0; long currentTime = Timestamp.valueOf(LocalDateTime.now()).getTime(); return (int) Math.max(0, cooldowns.getLong(operationName) - currentTime); } @@ -52,20 +71,26 @@ public void registerOperation(@NotNull IPeripheralOperation operation) { allowedOperations.put(operation.settingsName(), operation); if (LibConfig.initialCooldownEnabled) { int initialCooldown = operation.getInitialCooldown(); - if (initialCooldown >= LibConfig.initialCooldownSensitivity) setCooldown(operation, initialCooldown); + if (initialCooldown >= LibConfig.initialCooldownSensitivity) + setCooldown(operation, initialCooldown); } } - public @NotNull MethodResult performOperation(IPeripheralOperation operation, T context, @Nullable IPeripheralCheck check, IPeripheralFunction method, @Nullable Consumer successCallback, @Nullable BiConsumer failCallback) throws LuaException { + public @NotNull MethodResult performOperation(IPeripheralOperation operation, T context, + @Nullable IPeripheralCheck check, IPeripheralFunction method, + @Nullable Consumer successCallback, @Nullable BiConsumer failCallback) + throws LuaException { if (isOnCooldown(operation)) { MethodResult result = MethodResult.of(null, String.format("%s is on cooldown", operation.settingsName())); - if (failCallback != null) failCallback.accept(result, FailReason.COOLDOWN); + if (failCallback != null) + failCallback.accept(result, FailReason.COOLDOWN); return result; } if (check != null) { MethodResult checkResult = check.check(context); if (checkResult != null) { - if (failCallback != null) failCallback.accept(checkResult, FailReason.CHECK_FAILED); + if (failCallback != null) + failCallback.accept(checkResult, FailReason.CHECK_FAILED); return checkResult; } } @@ -76,12 +101,14 @@ public void registerOperation(@NotNull IPeripheralOperation operation) { fuelAbility = owner.getAbility(PeripheralOwnerAbility.FUEL); if (fuelAbility == null) { MethodResult result = MethodResult.of(null, "This peripheral has no fuel at all"); - if (failCallback != null) failCallback.accept(result, FailReason.NOT_ENOUGH_FUEL); + if (failCallback != null) + failCallback.accept(result, FailReason.NOT_ENOUGH_FUEL); return result; } if (!fuelAbility.consumeFuel(cost, false)) { MethodResult result = MethodResult.of(null, "Not enough fuel for operation"); - if (failCallback != null) failCallback.accept(result, FailReason.NOT_ENOUGH_FUEL); + if (failCallback != null) + failCallback.accept(result, FailReason.NOT_ENOUGH_FUEL); return result; } cooldown = fuelAbility.reduceCooldownAccordingToConsumptionRate(cooldown); @@ -111,13 +138,12 @@ public void collectConfiguration(Map dict) { @LuaFunction(mainThread = true) public final MethodResult getOperationCooldown(String name) { IPeripheralOperation op = allowedOperations.get(name); - if (op == null) return MethodResult.of(null, "Cannot find this operation"); + if (op == null) + return MethodResult.of(null, "Cannot find this operation"); return MethodResult.of(getCurrentCooldown(op)); } public enum FailReason { - COOLDOWN, - NOT_ENOUGH_FUEL, - CHECK_FAILED + COOLDOWN, NOT_ENOUGH_FUEL, CHECK_FAILED } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/PeripheralOwnerAbility.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/PeripheralOwnerAbility.java index fefa8a5be..08bc29f9f 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/PeripheralOwnerAbility.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/PeripheralOwnerAbility.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.owner; @SuppressWarnings("InstantiationOfUtilityClass") diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/PocketPeripheralOwner.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/PocketPeripheralOwner.java index ee9153f06..6c0e74b71 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/PocketPeripheralOwner.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/PocketPeripheralOwner.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.owner; import dan200.computercraft.api.pocket.IPocketAccess; @@ -24,60 +39,56 @@ public class PocketPeripheralOwner extends BasePeripheralOwner { public PocketPeripheralOwner(IPocketAccess pocket) { super(); this.pocket = pocket; - if(APConfig.PERIPHERALS_CONFIG.disablePocketFuelConsumption.get()) + if (APConfig.PERIPHERALS_CONFIG.disablePocketFuelConsumption.get()) attachAbility(PeripheralOwnerAbility.FUEL, new InfinitePocketFuelAbility(this)); } - @Nullable - @Override + @Nullable @Override public String getCustomName() { return null; } - @Nullable - @Override + @Nullable @Override public Level getLevel() { Entity owner = pocket.getEntity(); - if (owner == null) return null; + if (owner == null) + return null; return owner.getCommandSenderWorld(); } - @NotNull - @Override + @NotNull @Override public BlockPos getPos() { Entity owner = pocket.getEntity(); - if (owner == null) return new BlockPos(0, 0, 0); + if (owner == null) + return new BlockPos(0, 0, 0); return owner.blockPosition(); } - @NotNull - @Override + @NotNull @Override public Direction getFacing() { Entity owner = pocket.getEntity(); - if (owner == null) return Direction.NORTH; + if (owner == null) + return Direction.NORTH; return owner.getDirection(); } - /** * Not used for pockets */ - @NotNull - @Override + @NotNull @Override public FrontAndTop getOrientation() { return FrontAndTop.NORTH_UP; } - @Nullable - @Override + @Nullable @Override public Player getOwner() { Entity owner = pocket.getEntity(); - if (owner instanceof Player player) return player; + if (owner instanceof Player player) + return player; return null; } - @NotNull - @Override + @NotNull @Override public CompoundTag getDataStorage() { return DataStorageUtil.getDataStorage(pocket); } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/TileEntityFuelAbility.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/TileEntityFuelAbility.java index d6f279fb1..ea74ea607 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/TileEntityFuelAbility.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/TileEntityFuelAbility.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.owner; import de.srendi.advancedperipherals.common.configuration.APConfig; @@ -6,7 +21,9 @@ import net.minecraftforge.common.capabilities.ForgeCapabilities; import org.jetbrains.annotations.NotNull; -public class TileEntityFuelAbility extends FuelAbility> { +public class TileEntityFuelAbility + extends + FuelAbility> { public TileEntityFuelAbility(@NotNull BlockEntityPeripheralOwner owner) { super(owner); @@ -37,12 +54,16 @@ public boolean isFuelConsumptionDisable() { @Override public int getFuelCount() { - return owner.tileEntity.getCapability(ForgeCapabilities.ENERGY).map(storage -> storage.getEnergyStored() / APConfig.METAPHYSICS_CONFIG.energyToFuelRate.get()).orElse(0); + return owner.tileEntity.getCapability(ForgeCapabilities.ENERGY) + .map(storage -> storage.getEnergyStored() / APConfig.METAPHYSICS_CONFIG.energyToFuelRate.get()) + .orElse(0); } @Override public int getFuelMaxCount() { - return owner.tileEntity.getCapability(ForgeCapabilities.ENERGY).map(storage -> storage.getMaxEnergyStored() / APConfig.METAPHYSICS_CONFIG.energyToFuelRate.get()).orElse(0); + return owner.tileEntity.getCapability(ForgeCapabilities.ENERGY) + .map(storage -> storage.getMaxEnergyStored() / APConfig.METAPHYSICS_CONFIG.energyToFuelRate.get()) + .orElse(0); } @Override diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/TurtleFuelAbility.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/TurtleFuelAbility.java index 324c66d0d..d1b8e6f92 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/TurtleFuelAbility.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/TurtleFuelAbility.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.owner; import org.jetbrains.annotations.NotNull; diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/TurtlePeripheralOwner.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/TurtlePeripheralOwner.java index 02ad29cea..996e5c95d 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/TurtlePeripheralOwner.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/owner/TurtlePeripheralOwner.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.owner; import com.mojang.authlib.GameProfile; @@ -31,26 +46,22 @@ public TurtlePeripheralOwner(ITurtleAccess turtle, TurtleSide side) { this.side = side; } - @Nullable - @Override + @Nullable @Override public String getCustomName() { return null; } - @NotNull - @Override + @NotNull @Override public Level getLevel() { return turtle.getLevel(); } - @NotNull - @Override + @NotNull @Override public BlockPos getPos() { return turtle.getPosition(); } - @NotNull - @Override + @NotNull @Override public Direction getFacing() { return turtle.getDirection(); } @@ -58,22 +69,20 @@ public Direction getFacing() { /** * Not used for turtles */ - @NotNull - @Override + @NotNull @Override public FrontAndTop getOrientation() { return FrontAndTop.NORTH_UP; } - @Nullable - @Override + @Nullable @Override public Player getOwner() { GameProfile owningPlayer = turtle.getOwningPlayer(); - if (owningPlayer == null) return null; + if (owningPlayer == null) + return null; return turtle.getLevel().getPlayerByUUID(owningPlayer.getId()); } - @NotNull - @Override + @NotNull @Override public CompoundTag getDataStorage() { return DataStorageUtil.getDataStorage(turtle, side); } @@ -106,11 +115,14 @@ public void destroyUpgrade() { @Override public boolean isMovementPossible(@NotNull Level level, @NotNull BlockPos pos) { return FakePlayerProviderTurtle.withPlayer(turtle, player -> { - if (level.isOutsideBuildHeight(pos)) return false; - if (!level.isInWorldBounds(pos)) return false; + if (level.isOutsideBuildHeight(pos)) + return false; + if (!level.isInWorldBounds(pos)) + return false; if (ComputerCraft.turtlesObeyBlockProtection && !TurtlePermissions.isBlockEnterable(level, pos, player)) return false; - if (!level.isAreaLoaded(pos, 0)) return false; + if (!level.isAreaLoaded(pos, 0)) + return false; return level.getWorldBorder().isWithinBounds(pos); }); } @@ -120,13 +132,11 @@ public boolean move(@NotNull Level level, @NotNull BlockPos pos) { return turtle.teleportTo(level, pos); } - @NotNull - public ITurtleAccess getTurtle() { + @NotNull public ITurtleAccess getTurtle() { return turtle; } - @NotNull - public TurtleSide getSide() { + @NotNull public TurtleSide getSide() { return side; } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/BlockReaderPeripheral.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/BlockReaderPeripheral.java index ce78b5077..38ceda929 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/BlockReaderPeripheral.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/BlockReaderPeripheral.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.peripheral; import dan200.computercraft.api.lua.LuaFunction; @@ -31,7 +46,8 @@ public boolean isEnabled() { @LuaFunction(mainThread = true) public final String getBlockName() { - if (getBlockInFront().is(Blocks.AIR)) return "none"; + if (getBlockInFront().is(Blocks.AIR)) + return "none"; return ForgeRegistries.BLOCKS.getKey(getBlockInFront().getBlock()).toString(); } 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 41469e211..49fa56eeb 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 @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.peripheral; import com.google.gson.JsonSyntaxException; @@ -18,10 +33,10 @@ import de.srendi.advancedperipherals.common.configuration.APConfig; import de.srendi.advancedperipherals.common.events.Events; import de.srendi.advancedperipherals.common.network.PacketHandler; +import de.srendi.advancedperipherals.common.network.toclient.ToastToClientPacket; import de.srendi.advancedperipherals.common.util.CoordUtil; import de.srendi.advancedperipherals.lib.peripherals.BasePeripheral; import de.srendi.advancedperipherals.lib.peripherals.IPeripheralFunction; -import de.srendi.advancedperipherals.common.network.toclient.ToastToClientPacket; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; import net.minecraft.resources.ResourceKey; @@ -80,13 +95,16 @@ private MutableComponent appendPrefix(String prefix, String brackets, String col prefixComponent = Component.literal(prefix); } } - if (brackets.isEmpty()) brackets = "[]"; + if (brackets.isEmpty()) + brackets = "[]"; - return Component.literal(color + brackets.charAt(0) + "\u00a7r").append(prefixComponent).append(color + brackets.charAt(1) + "\u00a7r "); + return Component.literal(color + brackets.charAt(0) + "\u00a7r").append(prefixComponent) + .append(color + brackets.charAt(1) + "\u00a7r "); } /** - * @param argument uuid/name of a player + * @param argument + * uuid/name of a player * @return a player if the name/uuid belongs to a player */ private ServerPlayer getPlayer(String argument) { @@ -98,7 +116,8 @@ private ServerPlayer getPlayer(String argument) { /** * Checks if brackets are in correct format if present * - * @param brackets {@link IArguments#optString(int) IArguments.optString()} to check + * @param brackets + * {@link IArguments#optString(int) IArguments.optString()} to check * @return true if brackets are in the right format */ private boolean checkBrackets(Optional brackets) { @@ -121,12 +140,13 @@ public final MethodResult sendFormattedMessage(@NotNull IArguments arguments) th return MethodResult.of(null, "incorrect bracket string (e.g. [], {}, <>, ...)"); MutableComponent preparedMessage = appendPrefix( - arguments.optString(1, APConfig.PERIPHERALS_CONFIG.defaultChatBoxPrefix.get()).replaceAll("&", "\u00a7"), - arguments.optString(2, "[]"), - arguments.optString(3, "").replaceAll("&", "\u00a7") - ).append(component); + arguments.optString(1, APConfig.PERIPHERALS_CONFIG.defaultChatBoxPrefix.get()).replaceAll("&", + "\u00a7"), + arguments.optString(2, "[]"), arguments.optString(3, "").replaceAll("&", "\u00a7")) + .append(component); for (ServerPlayer player : ServerLifecycleHooks.getCurrentServer().getPlayerList().getPlayers()) { - if (!APConfig.PERIPHERALS_CONFIG.chatBoxMultiDimensional.get() && player.getLevel().dimension() != dimension) + if (!APConfig.PERIPHERALS_CONFIG.chatBoxMultiDimensional.get() + && player.getLevel().dimension() != dimension) continue; if (range == -1 || CoordUtil.isInRange(getPos(), getLevel(), player, range, maxRange)) player.sendSystemMessage(preparedMessage); @@ -147,12 +167,12 @@ public final MethodResult sendMessage(@NotNull IArguments arguments) throws LuaE return MethodResult.of(null, "incorrect bracket string (e.g. [], {}, <>, ...)"); MutableComponent preparedMessage = appendPrefix( - arguments.optString(1, APConfig.PERIPHERALS_CONFIG.defaultChatBoxPrefix.get()).replaceAll("&", "\u00a7"), - arguments.optString(2, "[]"), - arguments.optString(3, "").replaceAll("&", "\u00a7") - ).append(message); + arguments.optString(1, APConfig.PERIPHERALS_CONFIG.defaultChatBoxPrefix.get()).replaceAll("&", + "\u00a7"), + arguments.optString(2, "[]"), arguments.optString(3, "").replaceAll("&", "\u00a7")).append(message); for (ServerPlayer player : ServerLifecycleHooks.getCurrentServer().getPlayerList().getPlayers()) { - if (!APConfig.PERIPHERALS_CONFIG.chatBoxMultiDimensional.get() && player.getLevel().dimension() != dimension) + if (!APConfig.PERIPHERALS_CONFIG.chatBoxMultiDimensional.get() + && player.getLevel().dimension() != dimension) continue; if (range == -1 || CoordUtil.isInRange(getPos(), getLevel(), player, range, maxRange)) player.sendSystemMessage(preparedMessage); @@ -182,11 +202,12 @@ public final MethodResult sendFormattedMessageToPlayer(@NotNull IArguments argum return MethodResult.of(null, "incorrect bracket string (e.g. [], {}, <>, ...)"); MutableComponent preparedMessage = appendPrefix( - arguments.optString(2, APConfig.PERIPHERALS_CONFIG.defaultChatBoxPrefix.get()).replaceAll("&", "\u00a7"), - arguments.optString(3, "[]"), - arguments.optString(4, "").replaceAll("&", "\u00a7") - ).append(component); - if (!APConfig.PERIPHERALS_CONFIG.chatBoxMultiDimensional.get() && player.getLevel().dimension() != dimension) + arguments.optString(2, APConfig.PERIPHERALS_CONFIG.defaultChatBoxPrefix.get()).replaceAll("&", + "\u00a7"), + arguments.optString(3, "[]"), arguments.optString(4, "").replaceAll("&", "\u00a7")) + .append(component); + 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, maxRange)) @@ -195,7 +216,6 @@ public final MethodResult sendFormattedMessageToPlayer(@NotNull IArguments argum }); } - @LuaFunction(mainThread = true) public final MethodResult sendFormattedToastToPlayer(@NotNull IArguments arguments) throws LuaException { return withChatOperation(ignored -> { @@ -222,12 +242,13 @@ public final MethodResult sendFormattedToastToPlayer(@NotNull IArguments argumen return MethodResult.of(null, "incorrect bracket string (e.g. [], {}, <>, ,,,)"); MutableComponent preparedMessage = appendPrefix( - arguments.optString(3, APConfig.PERIPHERALS_CONFIG.defaultChatBoxPrefix.get()).replaceAll("&", "\u00a7"), - arguments.optString(4, "[]"), - arguments.optString(5, "").replaceAll("&", "\u00a7") - ).append(messageComponent); + arguments.optString(3, APConfig.PERIPHERALS_CONFIG.defaultChatBoxPrefix.get()).replaceAll("&", + "\u00a7"), + arguments.optString(4, "[]"), arguments.optString(5, "").replaceAll("&", "\u00a7")) + .append(messageComponent); - if (!APConfig.PERIPHERALS_CONFIG.chatBoxMultiDimensional.get() && player.getLevel().dimension() != dimension) + 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, maxRange)) { @@ -256,11 +277,11 @@ public final MethodResult sendMessageToPlayer(@NotNull IArguments arguments) thr return MethodResult.of(null, "incorrect bracket string (e.g. [], {}, <>, ...)"); MutableComponent preparedMessage = appendPrefix( - arguments.optString(2, APConfig.PERIPHERALS_CONFIG.defaultChatBoxPrefix.get()).replaceAll("&", "\u00a7"), - arguments.optString(3, "[]"), - arguments.optString(4, "").replaceAll("&", "\u00a7") - ).append(message); - if (!APConfig.PERIPHERALS_CONFIG.chatBoxMultiDimensional.get() && player.getLevel().dimension() != dimension) + arguments.optString(2, APConfig.PERIPHERALS_CONFIG.defaultChatBoxPrefix.get()).replaceAll("&", + "\u00a7"), + arguments.optString(3, "[]"), arguments.optString(4, "").replaceAll("&", "\u00a7")).append(message); + 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, maxRange)) @@ -287,12 +308,12 @@ public final MethodResult sendToastToPlayer(@NotNull IArguments arguments) throw return MethodResult.of(null, "incorrect bracket string (e.g. [], {}, <>, ...)"); MutableComponent preparedMessage = appendPrefix( - arguments.optString(3, APConfig.PERIPHERALS_CONFIG.defaultChatBoxPrefix.get()).replaceAll("&", "\u00a7"), - arguments.optString(4, "[]"), - arguments.optString(5, "").replaceAll("&", "\u00a7") - ).append(message); + arguments.optString(3, APConfig.PERIPHERALS_CONFIG.defaultChatBoxPrefix.get()).replaceAll("&", + "\u00a7"), + arguments.optString(4, "[]"), arguments.optString(5, "").replaceAll("&", "\u00a7")).append(message); - if (!APConfig.PERIPHERALS_CONFIG.chatBoxMultiDimensional.get() && player.getLevel().dimension() != dimension) + 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, maxRange)) { diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/ChunkyPeripheral.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/ChunkyPeripheral.java index 94829b12f..ed1b9f1a0 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/ChunkyPeripheral.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/ChunkyPeripheral.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.peripheral; import dan200.computercraft.api.peripheral.IComputerAccess; @@ -45,7 +60,8 @@ public boolean isEnabled() { } public void updateChunkState() { - // TODO: should find someway to update after turtle moved or while moving, but not every tick + // TODO: should find someway to update after turtle moved or while moving, but + // not every tick ServerLevel level = (ServerLevel) getLevel(); ChunkManager manager = ChunkManager.get(level); ChunkPos currentChunk = getChunkPos(); @@ -85,8 +101,10 @@ public void detach(@NotNull IComputerAccess computer) { super.detach(computer); // Should not remove the loaded chunk when detaching, // because CC:T will detach all peripherals before server stopped. - // So the chunk record will never be saved if we removed the chunk record when detaching. - // The records will be automatically removed by the ChunkManager if they have not been touched a while ago. + // So the chunk record will never be saved if we removed the chunk record when + // detaching. + // The records will be automatically removed by the ChunkManager if they have + // not been touched a while ago. // ServerLevel level = (ServerLevel) owner.getLevel(); // ChunkManager manager = ChunkManager.get(Objects.requireNonNull(level)); 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 ae97a5c6b..7006fd2c8 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 @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.peripheral; import com.minecolonies.api.IMinecoloniesAPI; @@ -32,7 +47,12 @@ import net.minecraft.resources.ResourceLocation; import net.minecraftforge.fml.ModList; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; import java.util.stream.Collectors; public class ColonyPeripheral extends BasePeripheral { @@ -65,7 +85,8 @@ public final boolean isWithin(Map pos) throws LuaException { if (!(pos.containsKey("x") && pos.containsKey("y") && pos.containsKey("z"))) throw new LuaException("Coordinates expected"); - BlockPos p = new BlockPos(((Number) pos.get("x")).intValue(), ((Number) pos.get("y")).intValue(), ((Number) pos.get("z")).intValue()); + BlockPos p = new BlockPos(((Number) pos.get("x")).intValue(), ((Number) pos.get("y")).intValue(), + ((Number) pos.get("z")).intValue()); return colony.isCoordInColony(this.getLevel(), p); } @@ -210,9 +231,12 @@ public final Object getResearch() throws LuaException { Map result = new HashMap<>(); for (ResourceLocation branch : globalTree.getBranches()) { try { - result.put(branch.toString(), MineColonies.getResearch(branch, globalTree.getPrimaryResearch(branch), colony)); + result.put(branch.toString(), + MineColonies.getResearch(branch, globalTree.getPrimaryResearch(branch), colony)); } catch (CommandSyntaxException ex) { - AdvancedPeripherals.debug("Error getting research for branch " + branch.toString() + ": " + ex.getMessage(), org.apache.logging.log4j.Level.WARN); + AdvancedPeripherals.debug( + "Error getting research for branch " + branch.toString() + ": " + ex.getMessage(), + org.apache.logging.log4j.Level.WARN); ex.printStackTrace(); } } @@ -225,7 +249,8 @@ public final Object getWorkOrderResources(int id) throws LuaException { IColony colony = getColony(); IWorkOrder workOrder = colony.getWorkManager().getWorkOrder(id); - if (workOrder == null) return null; + if (workOrder == null) + return null; return MineColonies.builderResourcesToObject(colony, workOrder.getClaimedBy()); } @@ -246,9 +271,9 @@ public final Object getRequests() throws LuaException { IColony colony = getColony(); IRequestManager requestManager = colony.getRequestManager(); - //All requests assigned to players + // All requests assigned to players IPlayerRequestResolver playerResolver = requestManager.getPlayerResolver(); - //All requests not assigned to players + // All requests not assigned to players IRetryingRequestResolver requestResolver = requestManager.getRetryingRequestResolver(); Set> tokens = new HashSet<>(); @@ -272,7 +297,8 @@ public final Object getRequests() throws LuaException { map.put("state", request.getState().toString()); map.put("count", deliverableRequest.getCount()); map.put("minCount", deliverableRequest.getMinimumCount()); - map.put("items", request.getDisplayStacks().stream().map(LuaConverter::itemStackToObject).collect(Collectors.toList())); + map.put("items", request.getDisplayStacks().stream().map(LuaConverter::itemStackToObject) + .collect(Collectors.toList())); map.put("target", request.getRequester().getRequesterDisplayName(requestManager, request).getString()); result.add(map); }); @@ -282,7 +308,8 @@ public final Object getRequests() throws LuaException { private IColony getColony() throws LuaException { IMinecoloniesAPI api = IMinecoloniesAPI.getInstance(); IColony colony = api.getColonyManager().getColonyByPosFromWorld(getLevel(), getPos()); - this.hasPermission = !(owner instanceof PocketPeripheralOwner) || MineColonies.hasAccess(owner.getOwner(), colony); + this.hasPermission = !(owner instanceof PocketPeripheralOwner) + || MineColonies.hasAccess(owner.getOwner(), colony); if (colony == null || !this.hasPermission) throw new LuaException("Here is no colony or you don't have the right permissions"); return colony; diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/CompassPeripheral.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/CompassPeripheral.java index fb24c8c1a..0bc10678a 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/CompassPeripheral.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/CompassPeripheral.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.peripheral; import dan200.computercraft.api.lua.LuaFunction; diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/DistanceDetectorPeripheral.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/DistanceDetectorPeripheral.java index af1045e4c..3f32b2b2e 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/DistanceDetectorPeripheral.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/DistanceDetectorPeripheral.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.peripheral; import dan200.computercraft.api.lua.LuaFunction; @@ -41,8 +56,10 @@ public final boolean ignoresTransparency() { @LuaFunction public final void setDetectionMode(int mode) { - if (mode > 2) mode = 2; - if (mode < 0) mode = 0; + if (mode > 2) + mode = 2; + if (mode < 0) + mode = 0; getPeripheralOwner().tileEntity.setDetectionType(DetectionType.values()[mode]); } @@ -86,7 +103,8 @@ public final void setCalculatePeriodically(boolean shouldRenderPeriodically) { @LuaFunction public final void setMaxRange(double maxDistance) { - getPeripheralOwner().tileEntity.setMaxRange(Math.max(0, Math.min(APConfig.PERIPHERALS_CONFIG.distanceDetectorRange.get(), maxDistance))); + getPeripheralOwner().tileEntity.setMaxRange( + Math.max(0, Math.min(APConfig.PERIPHERALS_CONFIG.distanceDetectorRange.get(), maxDistance))); } @LuaFunction @@ -95,9 +113,7 @@ public final double getMaxRange() { } public enum DetectionType { - BLOCK, - ENTITIES, - BOTH + BLOCK, ENTITIES, BOTH } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/EnergyDetectorPeripheral.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/EnergyDetectorPeripheral.java index 0898fb611..ed8a7db53 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/EnergyDetectorPeripheral.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/EnergyDetectorPeripheral.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.peripheral; import dan200.computercraft.api.lua.LuaFunction; diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/EnvironmentDetectorPeripheral.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/EnvironmentDetectorPeripheral.java index 0054a4d45..a83cb47b2 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/EnvironmentDetectorPeripheral.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/EnvironmentDetectorPeripheral.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.peripheral; import dan200.computercraft.api.lua.IArguments; @@ -38,7 +53,14 @@ import net.minecraftforge.server.ServerLifecycleHooks; import org.jetbrains.annotations.NotNull; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; import java.util.function.Function; import static de.srendi.advancedperipherals.common.addons.computercraft.operations.SphereOperation.SCAN_ENTITIES; @@ -124,7 +146,8 @@ public final long getTime() { @LuaFunction(mainThread = true) public final boolean isSlimeChunk() { ChunkPos chunkPos = new ChunkPos(getPos()); - return WorldgenRandom.seedSlimeChunk(chunkPos.x, chunkPos.z, ((WorldGenLevel) getLevel()).getSeed(), 987234911L).nextInt(10) == 0; + return WorldgenRandom.seedSlimeChunk(chunkPos.x, chunkPos.z, ((WorldGenLevel) getLevel()).getSeed(), 987234911L) + .nextInt(10) == 0; } @LuaFunction(mainThread = true) @@ -140,7 +163,8 @@ public final boolean isDimension(String dimension) { @LuaFunction(mainThread = true) public final Set listDimensions() { Set dimensions = new HashSet<>(); - ServerLifecycleHooks.getCurrentServer().getAllLevels().forEach(serverWorld -> dimensions.add(serverWorld.dimension().location().getPath())); + ServerLifecycleHooks.getCurrentServer().getAllLevels() + .forEach(serverWorld -> dimensions.add(serverWorld.dimension().location().getPath())); return dimensions; } @@ -197,7 +221,8 @@ public final boolean isSunny() { } @LuaFunction(mainThread = true) - public final MethodResult scanEntities(@NotNull IComputerAccess access, @NotNull IArguments arguments) throws LuaException { + public final MethodResult scanEntities(@NotNull IComputerAccess access, @NotNull IArguments arguments) + throws LuaException { int radius = arguments.getInt(0); return withOperation(SCAN_ENTITIES, new SphereOperationContext(radius), context -> { if (radius > SCAN_ENTITIES.getMaxCostRadius()) @@ -207,7 +232,8 @@ public final MethodResult scanEntities(@NotNull IComputerAccess access, @NotNull BlockPos pos = owner.getPos(); AABB box = new AABB(pos); List> entities = new ArrayList<>(); - getLevel().getEntities((Entity) null, box.inflate(radius), LivingEntity.class::isInstance).forEach(entity -> entities.add(LuaConverter.completeEntityWithPositionToLua(entity, ItemStack.EMPTY, pos))); + getLevel().getEntities((Entity) null, box.inflate(radius), LivingEntity.class::isInstance).forEach( + entity -> entities.add(LuaConverter.completeEntityWithPositionToLua(entity, ItemStack.EMPTY, pos))); return MethodResult.of(entities); }, null); } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/FluidDetectorPeripheral.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/FluidDetectorPeripheral.java index c54dde612..ca4281c3d 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/FluidDetectorPeripheral.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/FluidDetectorPeripheral.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.peripheral; import dan200.computercraft.api.lua.LuaFunction; diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/GasDetectorPeripheral.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/GasDetectorPeripheral.java index fd94811e3..740988208 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/GasDetectorPeripheral.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/GasDetectorPeripheral.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.peripheral; import dan200.computercraft.api.lua.LuaFunction; diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/GeoScannerPeripheral.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/GeoScannerPeripheral.java index c94496149..d351be8b4 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/GeoScannerPeripheral.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/GeoScannerPeripheral.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.peripheral; import dan200.computercraft.api.lua.IArguments; @@ -38,8 +53,8 @@ public class GeoScannerPeripheral extends BasePeripheral { /* - Highly inspired by https://github.com/SquidDev-CC/plethora/ BlockScanner - */ + * Highly inspired by https://github.com/SquidDev-CC/plethora/ BlockScanner + */ public static final String PERIPHERAL_TYPE = "geo_scanner"; @@ -80,7 +95,8 @@ public GeoScannerPeripheral(IPocketAccess pocket) { } private static int estimateCost(int radius) { - if (radius > SCAN_BLOCKS.getMaxCostRadius()) return -1; + if (radius > SCAN_BLOCKS.getMaxCostRadius()) + return -1; return SCAN_BLOCKS.getCost(SphereOperationContext.of(radius)); } 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 6f93e56cf..b390cb011 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 @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.peripheral; import dan200.computercraft.api.lua.LuaException; @@ -23,8 +38,8 @@ import net.minecraftforge.items.wrapper.PlayerArmorInvWrapper; import net.minecraftforge.items.wrapper.PlayerInvWrapper; import net.minecraftforge.items.wrapper.PlayerOffhandInvWrapper; - import org.jetbrains.annotations.NotNull; + import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -44,14 +59,15 @@ public boolean isEnabled() { @LuaFunction public final String getOwner() throws LuaException { - if (owner.getOwner() == null) return null; + if (owner.getOwner() == null) + return null; return getOwnerPlayer().getName().getString(); } - - //Add the specified item to the player - //The item is specified the same as with the RS/ME bridge: - //{name="minecraft:enchanted_book", count=1, nbt="ae70053c97f877de546b0248b9ddf525"} + // Add the specified item to the player + // The item is specified the same as with the RS/ME bridge: + // {name="minecraft:enchanted_book", count=1, + // nbt="ae70053c97f877de546b0248b9ddf525"} @LuaFunction(mainThread = true) public final MethodResult addItemToPlayer(String invDirection, Map item) throws LuaException { Pair filter = ItemFilter.parse(item); @@ -65,13 +81,16 @@ private int addItemCommon(String invDirection, ItemFilter filter) throws LuaExce Direction direction = validateSide(invDirection); BlockEntity targetEntity = owner.getLevel().getBlockEntity(owner.getPos().relative(direction)); - IItemHandler inventoryFrom = targetEntity != null ? targetEntity.getCapability(ForgeCapabilities.ITEM_HANDLER, direction).resolve().orElse(null) : null; + IItemHandler inventoryFrom = targetEntity != null + ? targetEntity.getCapability(ForgeCapabilities.ITEM_HANDLER, direction).resolve().orElse(null) + : null; Pair inventoryTo = getHandlerFromSlot(filter.getToSlot()); inventoryTo.ifRightPresent(slot -> filter.toSlot = slot); - //if (invSlot >= inventoryTo.getSlots() || invSlot < 0) - // throw new LuaException("Inventory out of bounds " + invSlot + " (max: " + (inventoryTo.getSlots() - 1) + ")"); + // if (invSlot >= inventoryTo.getSlots() || invSlot < 0) + // throw new LuaException("Inventory out of bounds " + invSlot + " (max: " + + // (inventoryTo.getSlots() - 1) + ")"); return InventoryUtil.moveItem(inventoryFrom, inventoryTo.getLeft(), filter); } @@ -90,7 +109,9 @@ private MethodResult removeItemCommon(String invDirection, ItemFilter filter) th BlockEntity targetEntity = owner.getLevel().getBlockEntity(owner.getPos().relative(direction)); Pair inventoryFrom = getHandlerFromSlot(filter.getFromSlot()); - IItemHandler inventoryTo = targetEntity != null ? targetEntity.getCapability(ForgeCapabilities.ITEM_HANDLER, direction).resolve().orElse(null) : null; + IItemHandler inventoryTo = targetEntity != null + ? targetEntity.getCapability(ForgeCapabilities.ITEM_HANDLER, direction).resolve().orElse(null) + : null; if (inventoryTo == null) return MethodResult.of(0, "INVENTORY_TO_INVALID"); @@ -103,7 +124,8 @@ private MethodResult removeItemCommon(String invDirection, ItemFilter filter) th @LuaFunction(value = {"list", "getItems"}, mainThread = true) public final List getItems() throws LuaException { List items = new ArrayList<>(); - int i = 0; //Used to let users easily sort the items by the slots. Also, a better way for the user to see where an item actually is + int i = 0; // Used to let users easily sort the items by the slots. Also, a better way for + // the user to see where an item actually is for (ItemStack stack : getOwnerPlayer().getInventory().items) { ItemStack copiedStack = stack.copy(); if (!copiedStack.isEmpty()) @@ -119,7 +141,9 @@ public final MethodResult getItemsChest(String target) throws LuaException { Direction direction = validateSide(target); BlockEntity targetEntity = owner.getLevel().getBlockEntity(owner.getPos().relative(direction)); - IItemHandler inventoryTo = targetEntity != null ? targetEntity.getCapability(ForgeCapabilities.ITEM_HANDLER, direction).resolve().orElse(null) : null; + IItemHandler inventoryTo = targetEntity != null + ? targetEntity.getCapability(ForgeCapabilities.ITEM_HANDLER, direction).resolve().orElse(null) + : null; if (inventoryTo == null) return MethodResult.of(null, "INVENTORY_TO_INVALID"); @@ -160,7 +184,8 @@ public final boolean isWearing(int index) throws LuaException { int i = 0; for (ItemStack stack : getOwnerPlayer().getInventory().armor) { if (!stack.isEmpty()) { - if (index == i - 100) return true; + if (index == i - 100) + return true; i++; } } @@ -194,7 +219,8 @@ public final int getHandSlot() throws LuaException { @LuaFunction(mainThread = true) public final Map getItemInHand() throws LuaException { - return LuaConverter.itemStackToObject(getOwnerPlayer().getMainHandItem(), getOwnerPlayer().getInventory().selected); + return LuaConverter.itemStackToObject(getOwnerPlayer().getMainHandItem(), + getOwnerPlayer().getInventory().selected); } @LuaFunction(mainThread = true) @@ -208,13 +234,14 @@ private Player getOwnerPlayer() throws LuaException { return owner.getOwner(); } - @NotNull - private Pair getHandlerFromSlot(int slot) throws LuaException { + @NotNull private Pair getHandlerFromSlot(int slot) throws LuaException { IItemHandler handler; if (slot >= 100 && slot <= 103) { handler = new PlayerArmorInvWrapper(getOwnerPlayer().getInventory()); - // If the slot is between 100 and 103, change the index to a normal index between 0 and 3. - // This is necessary since the PlayerArmorInvWrapper does not work with these higher indexes + // If the slot is between 100 and 103, change the index to a normal index + // between 0 and 3. + // This is necessary since the PlayerArmorInvWrapper does not work with these + // higher indexes slot = slot - 100; } else if (slot == 36) { handler = new PlayerOffhandInvWrapper(getOwnerPlayer().getInventory()); @@ -233,10 +260,8 @@ private Pair getHandlerFromSlot(int slot) throws LuaExcep */ private enum ArmorSlot { - HELMET_SLOT(103, EquipmentSlot.HEAD), - CHEST_SLOT(102, EquipmentSlot.CHEST), - LEGGINGS_SLOT(101, EquipmentSlot.LEGS), - BOOTS_SLOT(100, EquipmentSlot.FEET); + HELMET_SLOT(103, EquipmentSlot.HEAD), CHEST_SLOT(102, EquipmentSlot.CHEST), LEGGINGS_SLOT(101, + EquipmentSlot.LEGS), BOOTS_SLOT(100, EquipmentSlot.FEET); private final int slot; private final EquipmentSlot slotType; @@ -254,7 +279,8 @@ public static int getSlotForItem(ItemStack stack) { } } } - AdvancedPeripherals.LOGGER.warn("Tried to get armor item slot for non armor item " + stack + ". Returning 0"); + AdvancedPeripherals.LOGGER + .warn("Tried to get armor item slot for non armor item " + stack + ". Returning 0"); return 0; } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/MeBridgePeripheral.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/MeBridgePeripheral.java index 7eb22d097..c91fabc4b 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/MeBridgePeripheral.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/MeBridgePeripheral.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.peripheral; import appeng.api.crafting.IPatternDetails; @@ -25,7 +40,12 @@ import de.srendi.advancedperipherals.common.configuration.APConfig; import de.srendi.advancedperipherals.common.util.Pair; import de.srendi.advancedperipherals.common.util.ServerWorker; -import de.srendi.advancedperipherals.common.util.inventory.*; +import de.srendi.advancedperipherals.common.util.inventory.FluidFilter; +import de.srendi.advancedperipherals.common.util.inventory.FluidUtil; +import de.srendi.advancedperipherals.common.util.inventory.GenericFilter; +import de.srendi.advancedperipherals.common.util.inventory.IStorageSystemPeripheral; +import de.srendi.advancedperipherals.common.util.inventory.InventoryUtil; +import de.srendi.advancedperipherals.common.util.inventory.ItemFilter; import de.srendi.advancedperipherals.lib.peripherals.BasePeripheral; import net.minecraft.core.Direction; import net.minecraftforge.fluids.capability.IFluidHandler; @@ -33,9 +53,15 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Optional; -public class MeBridgePeripheral extends BasePeripheral> implements IStorageSystemPeripheral { +public class MeBridgePeripheral extends BasePeripheral> + implements + IStorageSystemPeripheral { public static final String PERIPHERAL_TYPE = "meBridge"; private final MeBridgeEntity tile; @@ -63,11 +89,14 @@ private ICraftingService getCraftingService() { /** * exports an item out of the system to a valid inventory * - * @param arguments the arguments given by the computer - * @param targetInventory the give inventory + * @param arguments + * the arguments given by the computer + * @param targetInventory + * the give inventory * @return the exportable amount or null with a string if something went wrong */ - protected MethodResult exportToChest(@NotNull IArguments arguments, @Nullable IItemHandler targetInventory) throws LuaException { + protected MethodResult exportToChest(@NotNull IArguments arguments, @Nullable IItemHandler targetInventory) + throws LuaException { MEStorage monitor = AppEngApi.getMonitor(node); MeItemHandler itemHandler = new MeItemHandler(monitor, tile); Pair filter = ItemFilter.parse(arguments.getTable(0)); @@ -84,11 +113,14 @@ protected MethodResult exportToChest(@NotNull IArguments arguments, @Nullable II /** * exports a fluid out of the system to a valid tank * - * @param arguments the arguments given by the computer - * @param targetTank the give tank + * @param arguments + * the arguments given by the computer + * @param targetTank + * the give tank * @return the exportable amount or null with a string if something went wrong */ - protected MethodResult exportToTank(@NotNull IArguments arguments, @Nullable IFluidHandler targetTank) throws LuaException { + protected MethodResult exportToTank(@NotNull IArguments arguments, @Nullable IFluidHandler targetTank) + throws LuaException { MEStorage monitor = AppEngApi.getMonitor(node); MeFluidHandler fluidHandler = new MeFluidHandler(monitor, tile); Pair filter = FluidFilter.parse(arguments.getTable(0)); @@ -105,11 +137,14 @@ protected MethodResult exportToTank(@NotNull IArguments arguments, @Nullable IFl /** * imports an item to the system from a valid inventory * - * @param arguments the arguments given by the computer - * @param targetInventory the give inventory + * @param arguments + * the arguments given by the computer + * @param targetInventory + * the give inventory * @return the imported amount or null with a string if something went wrong */ - protected MethodResult importToME(@NotNull IArguments arguments, @Nullable IItemHandler targetInventory) throws LuaException { + protected MethodResult importToME(@NotNull IArguments arguments, @Nullable IItemHandler targetInventory) + throws LuaException { MEStorage monitor = AppEngApi.getMonitor(node); MeItemHandler itemHandler = new MeItemHandler(monitor, tile); Pair filter = ItemFilter.parse(arguments.getTable(0)); @@ -126,11 +161,14 @@ protected MethodResult importToME(@NotNull IArguments arguments, @Nullable IItem /** * imports a fluid to the system from a valid tank * - * @param arguments the arguments given by the computer - * @param targetTank the give tank + * @param arguments + * the arguments given by the computer + * @param targetTank + * the give tank * @return the imported amount or null with a string if something went wrong */ - protected MethodResult importToME(@NotNull IArguments arguments, @Nullable IFluidHandler targetTank) throws LuaException { + protected MethodResult importToME(@NotNull IArguments arguments, @Nullable IFluidHandler targetTank) + throws LuaException { MEStorage monitor = AppEngApi.getMonitor(node); MeFluidHandler fluidHandler = new MeFluidHandler(monitor, tile); Pair filter = FluidFilter.parse(arguments.getTable(0)); @@ -179,7 +217,8 @@ public final MethodResult getItem(IArguments arguments) throws LuaException { if (parsedFilter.isEmpty()) return MethodResult.of(null, "EMPTY_FILTER"); - return MethodResult.of(AppEngApi.getObjectFromStack(AppEngApi.findAEStackFromFilter(monitor, getCraftingService(), parsedFilter), getCraftingService())); + return MethodResult.of(AppEngApi.getObjectFromStack( + AppEngApi.findAEStackFromFilter(monitor, getCraftingService(), parsedFilter), getCraftingService())); } @Override @@ -196,7 +235,8 @@ public MethodResult getFluid(IArguments arguments) throws LuaException { if (parsedFilter.isEmpty()) return MethodResult.of(null, "EMPTY_FILTER"); - return MethodResult.of(AppEngApi.findAEFluidFromFilter(AppEngApi.getMonitor(node), getCraftingService(), parsedFilter)); + return MethodResult + .of(AppEngApi.findAEFluidFromFilter(AppEngApi.getMonitor(node), getCraftingService(), parsedFilter)); } @Override @@ -262,7 +302,8 @@ public final MethodResult importItem(IComputerAccess computer, IArguments argume String side = arguments.getString(1); IItemHandler inventory; - if (Direction.byName(side.toUpperCase(Locale.ROOT)) == null && ComputerSide.valueOfInsensitive(side.toUpperCase(Locale.ROOT)) == null) { + if (Direction.byName(side.toUpperCase(Locale.ROOT)) == null + && ComputerSide.valueOfInsensitive(side.toUpperCase(Locale.ROOT)) == null) { inventory = InventoryUtil.getHandlerFromDirection(arguments.getString(1), owner); } else { inventory = InventoryUtil.getHandlerFromName(computer, arguments.getString(1)); @@ -280,7 +321,8 @@ public final MethodResult exportItem(IComputerAccess computer, @NotNull IArgumen String side = arguments.getString(1); IItemHandler inventory; - if (Direction.byName(side.toUpperCase(Locale.ROOT)) == null && ComputerSide.valueOfInsensitive(side.toUpperCase(Locale.ROOT)) == null) { + if (Direction.byName(side.toUpperCase(Locale.ROOT)) == null + && ComputerSide.valueOfInsensitive(side.toUpperCase(Locale.ROOT)) == null) { inventory = InventoryUtil.getHandlerFromDirection(arguments.getString(1), owner); } else { inventory = InventoryUtil.getHandlerFromName(computer, arguments.getString(1)); @@ -295,7 +337,8 @@ public MethodResult getFilteredPatterns(IArguments arguments) throws LuaExceptio if (!isAvailable()) return notConnected(); - // Expected input is a table with either an input table, an output table or both to filter for both + // Expected input is a table with either an input table, an output table or both + // to filter for both Map filterTable; try { Optional> optionalTable = arguments.optTable(0); @@ -328,8 +371,8 @@ public MethodResult getFilteredPatterns(IArguments arguments) throws LuaExceptio outputFilter = GenericFilter.parseGeneric(outputFilterTable).getLeft(); } - - Pair pattern = AppEngApi.findPatternFromFilters(node.getGrid(), getLevel(), inputFilter, outputFilter); + Pair pattern = AppEngApi.findPatternFromFilters(node.getGrid(), getLevel(), + inputFilter, outputFilter); if (pattern.getRight() != null) return MethodResult.of(null, pattern.getRight()); @@ -558,11 +601,13 @@ public final MethodResult craftItem(IComputerAccess computer, IArguments argumen return MethodResult.of(false, "CPU " + cpuName + " does not exists"); ICraftingService craftingGrid = node.getGrid().getService(ICraftingService.class); - Pair stack = AppEngApi.findAEStackFromFilter(AppEngApi.getMonitor(tile.getGridNode()), craftingGrid, filter.getLeft()); + Pair stack = AppEngApi.findAEStackFromFilter(AppEngApi.getMonitor(tile.getGridNode()), + craftingGrid, filter.getLeft()); if (stack.getRight() == null && stack.getLeft() == 0) return MethodResult.of(null, "NOT_CRAFTABLE"); - CraftJob job = new CraftJob(owner.getLevel(), computer, node, stack.getRight(), parsedFilter.getCount(), tile, tile, target); + CraftJob job = new CraftJob(owner.getLevel(), computer, node, stack.getRight(), parsedFilter.getCount(), tile, + tile, target); tile.addJob(job); ServerWorker.add(job::startCrafting); return MethodResult.of(true); @@ -588,11 +633,13 @@ public final MethodResult craftFluid(IComputerAccess computer, IArguments argume return MethodResult.of(false, "CPU " + cpuName + " does not exists"); ICraftingService craftingGrid = node.getGrid().getService(ICraftingService.class); - Pair stack = AppEngApi.findAEFluidFromFilter(AppEngApi.getMonitor(tile.getGridNode()), craftingGrid, filter.getLeft()); + Pair stack = AppEngApi.findAEFluidFromFilter(AppEngApi.getMonitor(tile.getGridNode()), + craftingGrid, filter.getLeft()); if (stack.getRight() == null && stack.getLeft() == 0) return MethodResult.of(null, "NOT_CRAFTABLE"); - CraftJob job = new CraftJob(owner.getLevel(), computer, node, stack.getRight(), parsedFilter.getCount(), tile, tile, target); + CraftJob job = new CraftJob(owner.getLevel(), computer, node, stack.getRight(), parsedFilter.getCount(), tile, + tile, target); tile.addJob(job); ServerWorker.add(job::startCrafting); return MethodResult.of(true); @@ -715,14 +762,16 @@ public final MethodResult exportFluid(IComputerAccess computer, IArguments argum String side = arguments.getString(1); IFluidHandler fluidHandler; - if (Direction.byName(side.toUpperCase(Locale.ROOT)) == null && ComputerSide.valueOfInsensitive(side.toUpperCase(Locale.ROOT)) == null) { + if (Direction.byName(side.toUpperCase(Locale.ROOT)) == null + && ComputerSide.valueOfInsensitive(side.toUpperCase(Locale.ROOT)) == null) { fluidHandler = FluidUtil.getHandlerFromDirection(arguments.getString(1), owner); } else { fluidHandler = FluidUtil.getHandlerFromName(computer, arguments.getString(1)); } if (fluidHandler == null) - return MethodResult.of(0, "The target tank does not exist. Make sure the bridge is exposed in the computer network. Reach out to our discord or our documentation for help."); + return MethodResult.of(0, + "The target tank does not exist. Make sure the bridge is exposed in the computer network. Reach out to our discord or our documentation for help."); return exportToTank(arguments, fluidHandler); } @@ -733,14 +782,16 @@ public final MethodResult importFluid(IComputerAccess computer, IArguments argum String side = arguments.getString(1); IFluidHandler fluidHandler; - if (Direction.byName(side.toUpperCase(Locale.ROOT)) == null && ComputerSide.valueOfInsensitive(side.toUpperCase(Locale.ROOT)) == null) { + if (Direction.byName(side.toUpperCase(Locale.ROOT)) == null + && ComputerSide.valueOfInsensitive(side.toUpperCase(Locale.ROOT)) == null) { fluidHandler = FluidUtil.getHandlerFromDirection(arguments.getString(1), owner); } else { fluidHandler = FluidUtil.getHandlerFromName(computer, arguments.getString(1)); } if (fluidHandler == null) - return MethodResult.of(0, "The target tank does not exist. Make sure the bridge is exposed in the computer network. Reach out to our discord or our documentation for help."); + return MethodResult.of(0, + "The target tank does not exist. Make sure the bridge is exposed in the computer network. Reach out to our discord or our documentation for help."); return importToME(arguments, fluidHandler); } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/NBTStoragePeripheral.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/NBTStoragePeripheral.java index 957594180..ae88a8885 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/NBTStoragePeripheral.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/NBTStoragePeripheral.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.peripheral; import com.mojang.brigadier.exceptions.CommandSyntaxException; @@ -62,7 +77,8 @@ public final MethodResult writeTable(Map data) { try (ObjectOutputStream objectOutputStream = new ObjectOutputStream(countingStream)) { objectOutputStream.writeObject(data); } catch (IOException e) { - return MethodResult.of(null, String.format("No idea, how this happened, but java IO Exception appear %s", e.getMessage())); + return MethodResult.of(null, + String.format("No idea, how this happened, but java IO Exception appear %s", e.getMessage())); } if (countingStream.getWrittenBytes() > APConfig.PERIPHERALS_CONFIG.nbtStorageMaxSize.get()) return MethodResult.of(null, "JSON size is bigger than allowed"); 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 d6489bc3d..aa9a6eeb6 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 @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.peripheral; import dan200.computercraft.api.lua.IArguments; @@ -23,7 +38,11 @@ import net.minecraft.world.level.Level; import net.minecraftforge.server.ServerLifecycleHooks; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; public class PlayerDetectorPeripheral extends BasePeripheral { @@ -44,7 +63,8 @@ public PlayerDetectorPeripheral(IPocketAccess 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 + // 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); } @@ -114,7 +134,8 @@ public final boolean isPlayersInCoords(Map firstCoord, Map secondCoo for (ServerPlayer player : getPlayers()) { if (!isAllowedMultiDimensional() && player.getLevel().dimension() != dimension) continue; - if (CoordUtil.isInRange(getPos(), player, getLevel(), firstPos, secondPos, MAX_RANGE)) return true; + if (CoordUtil.isInRange(getPos(), player, getLevel(), firstPos, secondPos, MAX_RANGE)) + return true; } return false; } @@ -128,7 +149,8 @@ public final boolean isPlayersInCubic(int x, int y, int z) { for (ServerPlayer player : getPlayers()) { if (!isAllowedMultiDimensional() && player.getLevel().dimension() != dimension) continue; - if (CoordUtil.isInRange(getPos(), getLevel(), player, x, y, z, MAX_RANGE)) return true; + if (CoordUtil.isInRange(getPos(), getLevel(), player, x, y, z, MAX_RANGE)) + return true; } return false; } @@ -142,13 +164,15 @@ public final boolean isPlayersInRange(int range) { for (ServerPlayer player : getPlayers()) { if (!isAllowedMultiDimensional() && player.getLevel().dimension() != dimension) continue; - if (range == -1 || CoordUtil.isInRange(getPos(), getLevel(), player, range, MAX_RANGE)) return true; + if (range == -1 || CoordUtil.isInRange(getPos(), getLevel(), player, range, MAX_RANGE)) + return true; } return false; } @LuaFunction(mainThread = true) - public final boolean isPlayerInCoords(Map firstCoord, Map secondCoord, String username) throws LuaException { + 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(); @@ -157,7 +181,7 @@ public final boolean isPlayerInCoords(Map firstCoord, Map secondCoor if (!isAllowedMultiDimensional() && player.getLevel().dimension() != dimension) continue; if (CoordUtil.isInRange(getPos(), player, getLevel(), firstPos, secondPos, MAX_RANGE)) - if(player.getName().getString().equals(username)) + if (player.getName().getString().equals(username)) return true; } return false; @@ -171,7 +195,7 @@ public final boolean isPlayerInCubic(int x, int y, int z, String username) { if (!isAllowedMultiDimensional() && player.getLevel().dimension() != dimension) continue; if (CoordUtil.isInRange(getPos(), getLevel(), player, x, y, z, MAX_RANGE)) { - if(player.getName().getString().equals(username)) + if (player.getName().getString().equals(username)) return true; } } @@ -186,7 +210,7 @@ public final boolean isPlayerInRange(int range, String username) { if (!isAllowedMultiDimensional() && player.getLevel().dimension() != dimension) continue; if (range == -1 || CoordUtil.isInRange(getPos(), getLevel(), player, range, MAX_RANGE)) { - if(player.getName().getString().equals(username)) + if (player.getName().getString().equals(username)) return true; } } @@ -196,7 +220,8 @@ public final boolean isPlayerInRange(int range, String username) { @LuaFunction(value = {"getPlayerPos", "getPlayer"}, mainThread = true) public final Map getPlayerPos(IArguments arguments) 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."); + 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; @@ -217,29 +242,39 @@ public final Map getPlayerPos(IArguments arguments) throws LuaEx double x = existingPlayer.getX(), y = existingPlayer.getY(), z = existingPlayer.getZ(); if (APConfig.PERIPHERALS_CONFIG.playerSpyRandError.get()) { - // We apply random error to the returned player position if so enabled in the configuration. + // We apply random error to the returned player position if so enabled in the + // configuration. // minDistance: Below this distance, the player's exact position is returned int minDistance = APConfig.PERIPHERALS_CONFIG.playerSpyPreciseMaxRange.get(); - // maxError: The maximum amount of blocks that the player's position can be off by (on each axis) at the max distance + // maxError: The maximum amount of blocks that the player's position can be off + // by (on each axis) at the max distance int maxError = APConfig.PERIPHERALS_CONFIG.playerSpyRandErrorAmount.get(); - // maxDistance: At this distance, maximum error is applied. Hard-coded to the minimum of MAX_RANGE and 10000, or just 10000 if MAX_RANGE is unlimited + // maxDistance: At this distance, maximum error is applied. Hard-coded to the + // minimum of MAX_RANGE and 10000, or just 10000 if MAX_RANGE is unlimited int maxDistance = MAX_RANGE == -1 ? 10000 : Math.min(MAX_RANGE, 10000); - // sublinearFactor: We apply exponent to the calculations so that error increases quickly at first before leveling out - // This is hard-coded so as not to overwhelm the player with configuration options, but this can probably be changed + // sublinearFactor: We apply exponent to the calculations so that error + // increases quickly at first before leveling out + // This is hard-coded so as not to overwhelm the player with configuration + // options, but this can probably be changed double sublinearFactor = 0.8; - // yAxisWeight: Since the Y-axis obviously has a much smaller range than X- and Z- axes - // (which can theoretically be infinite) in the Minecraft world, we should apply less error to it + // yAxisWeight: Since the Y-axis obviously has a much smaller range than X- and + // Z- axes + // (which can theoretically be infinite) in the Minecraft world, we should apply + // less error to it double yAxisWeight = (double) 1 / 4; maxDistance = Math.max(minDistance, maxDistance); - // Calculate Euclidean distance between the player locator and the player in question - double distanceFromPlayer = Math.sqrt(Math.pow(x - getPos().getX(), 2) + Math.pow(y - getPos().getY(), 2) + Math.pow(z - getPos().getZ(), 2)); + // Calculate Euclidean distance between the player locator and the player in + // question + double distanceFromPlayer = Math.sqrt(Math.pow(x - getPos().getX(), 2) + Math.pow(y - getPos().getY(), 2) + + Math.pow(z - getPos().getZ(), 2)); distanceFromPlayer -= minDistance; if (distanceFromPlayer > 0) { - // We calculate error as the fraction of the player's distance and the max distance defined in the configuration + // We calculate error as the fraction of the player's distance and the max + // distance defined in the configuration // then we raise it to sublinearFactor to make it somewhat exponential double error = maxError * Math.min(Math.pow(distanceFromPlayer / maxDistance, sublinearFactor), 1); x += (Math.random() - 0.5) * 2 * error; diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/RedstoneIntegratorPeripheral.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/RedstoneIntegratorPeripheral.java index b3d181a4c..39f090cea 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/RedstoneIntegratorPeripheral.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/RedstoneIntegratorPeripheral.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.peripheral; import dan200.computercraft.api.lua.LuaException; diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/RsBridgePeripheral.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/RsBridgePeripheral.java index 15ca27785..45b969961 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/RsBridgePeripheral.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/RsBridgePeripheral.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.peripheral; import com.refinedmods.refinedstorage.api.autocrafting.task.CalculationResultType; @@ -19,7 +34,12 @@ import de.srendi.advancedperipherals.common.blocks.blockentities.RsBridgeEntity; import de.srendi.advancedperipherals.common.configuration.APConfig; import de.srendi.advancedperipherals.common.util.Pair; -import de.srendi.advancedperipherals.common.util.inventory.*; +import de.srendi.advancedperipherals.common.util.inventory.FluidFilter; +import de.srendi.advancedperipherals.common.util.inventory.FluidUtil; +import de.srendi.advancedperipherals.common.util.inventory.IStorageSystemPeripheral; +import de.srendi.advancedperipherals.common.util.inventory.InventoryUtil; +import de.srendi.advancedperipherals.common.util.inventory.ItemFilter; +import de.srendi.advancedperipherals.common.util.inventory.ItemUtil; import de.srendi.advancedperipherals.lib.peripherals.BasePeripheral; import net.minecraft.core.Direction; import net.minecraft.world.item.ItemStack; @@ -33,7 +53,9 @@ import java.util.List; import java.util.Locale; -public class RsBridgePeripheral extends BasePeripheral> implements IStorageSystemPeripheral { +public class RsBridgePeripheral extends BasePeripheral> + implements + IStorageSystemPeripheral { public static final String PERIPHERAL_TYPE = "rs_bridge"; @@ -75,7 +97,6 @@ public final MethodResult isOnline() { return MethodResult.of(getNode().isActive()); } - @Override @LuaFunction(mainThread = true) public final MethodResult listItems() { @@ -92,7 +113,8 @@ public final MethodResult listCraftableItems() { return notConnected(); List items = new ArrayList<>(); - RefinedStorage.getCraftableItems(getNetwork()).forEach(item -> items.add(RefinedStorage.getObjectFromStack(item.copy(), getNetwork()))); + RefinedStorage.getCraftableItems(getNetwork()) + .forEach(item -> items.add(RefinedStorage.getObjectFromStack(item.copy(), getNetwork()))); return MethodResult.of(items); } @@ -103,7 +125,8 @@ public final MethodResult listCraftableFluids() { return notConnected(); List fluids = new ArrayList<>(); - RefinedStorage.getCraftableFluids(getNetwork()).forEach(fluid -> fluids.add(RefinedStorage.getObjectFromFluid(fluid, getNetwork()))); + RefinedStorage.getCraftableFluids(getNetwork()) + .forEach(fluid -> fluids.add(RefinedStorage.getObjectFromFluid(fluid, getNetwork()))); return MethodResult.of(fluids); } @@ -259,9 +282,11 @@ public final MethodResult getFilteredPatterns(IArguments arguments) throws LuaEx if (parsedFilter.isEmpty()) return MethodResult.of(false, "EMPTY_FILTER"); - ItemStack patternItem = RefinedStorage.findStackFromFilter(getNetwork(), getNetwork().getCraftingManager(), parsedFilter); + ItemStack patternItem = RefinedStorage.findStackFromFilter(getNetwork(), getNetwork().getCraftingManager(), + parsedFilter); - return MethodResult.of(RefinedStorage.getObjectFromPattern(getNetwork().getCraftingManager().getPattern(patternItem), getNetwork())); + return MethodResult.of(RefinedStorage + .getObjectFromPattern(getNetwork().getCraftingManager().getPattern(patternItem), getNetwork())); } @Override @@ -270,7 +295,8 @@ public final MethodResult getPatterns() { return null; } - protected MethodResult exportToChest(@NotNull IArguments arguments, @Nullable IItemHandler targetInventory) throws LuaException { + protected MethodResult exportToChest(@NotNull IArguments arguments, @Nullable IItemHandler targetInventory) + throws LuaException { RsItemHandler itemHandler = new RsItemHandler(getNetwork()); if (targetInventory == null) return MethodResult.of(0, "INVALID_TARGET"); @@ -282,7 +308,8 @@ protected MethodResult exportToChest(@NotNull IArguments arguments, @Nullable II return MethodResult.of(InventoryUtil.moveItem(itemHandler, targetInventory, filter.getLeft()), null); } - protected MethodResult importToSystem(@NotNull IArguments arguments, @Nullable IItemHandler targetInventory) throws LuaException { + protected MethodResult importToSystem(@NotNull IArguments arguments, @Nullable IItemHandler targetInventory) + throws LuaException { RsItemHandler itemHandler = new RsItemHandler(getNetwork()); if (targetInventory == null) return MethodResult.of(0, "INVALID_TARGET"); @@ -294,7 +321,8 @@ protected MethodResult importToSystem(@NotNull IArguments arguments, @Nullable I return MethodResult.of(InventoryUtil.moveItem(targetInventory, itemHandler, filter.getLeft()), null); } - protected MethodResult exportToTank(@NotNull IArguments arguments, @Nullable IFluidHandler targetInventory) throws LuaException { + protected MethodResult exportToTank(@NotNull IArguments arguments, @Nullable IFluidHandler targetInventory) + throws LuaException { RsFluidHandler itemHandler = new RsFluidHandler(getNetwork()); if (targetInventory == null) return MethodResult.of(0, "INVALID_TARGET"); @@ -306,7 +334,8 @@ protected MethodResult exportToTank(@NotNull IArguments arguments, @Nullable IFl return MethodResult.of(InventoryUtil.moveFluid(itemHandler, targetInventory, filter.getLeft()), null); } - protected MethodResult importToSystem(@NotNull IArguments arguments, @Nullable IFluidHandler targetInventory) throws LuaException { + protected MethodResult importToSystem(@NotNull IArguments arguments, @Nullable IFluidHandler targetInventory) + throws LuaException { RsFluidHandler itemHandler = new RsFluidHandler(getNetwork()); if (targetInventory == null) return MethodResult.of(0, "INVALID_TARGET"); @@ -327,7 +356,8 @@ public final MethodResult exportItem(IComputerAccess computer, IArguments argume String side = arguments.getString(1); IItemHandler inventory; - if (Direction.byName(side.toUpperCase(Locale.ROOT)) == null && ComputerSide.valueOfInsensitive(side.toUpperCase(Locale.ROOT)) == null) { + if (Direction.byName(side.toUpperCase(Locale.ROOT)) == null + && ComputerSide.valueOfInsensitive(side.toUpperCase(Locale.ROOT)) == null) { inventory = InventoryUtil.getHandlerFromDirection(arguments.getString(1), owner); } else { inventory = InventoryUtil.getHandlerFromName(computer, arguments.getString(1)); @@ -345,7 +375,8 @@ public final MethodResult importItem(IComputerAccess computer, IArguments argume String side = arguments.getString(1); IItemHandler inventory; - if (Direction.byName(side.toUpperCase(Locale.ROOT)) == null && ComputerSide.valueOfInsensitive(side.toUpperCase(Locale.ROOT)) == null) { + if (Direction.byName(side.toUpperCase(Locale.ROOT)) == null + && ComputerSide.valueOfInsensitive(side.toUpperCase(Locale.ROOT)) == null) { inventory = InventoryUtil.getHandlerFromDirection(arguments.getString(1), owner); } else { inventory = InventoryUtil.getHandlerFromName(computer, arguments.getString(1)); @@ -363,14 +394,16 @@ public final MethodResult exportFluid(IComputerAccess computer, IArguments argum String side = arguments.getString(1); IFluidHandler fluidHandler; - if (Direction.byName(side.toUpperCase(Locale.ROOT)) == null && ComputerSide.valueOfInsensitive(side.toUpperCase(Locale.ROOT)) == null) { + if (Direction.byName(side.toUpperCase(Locale.ROOT)) == null + && ComputerSide.valueOfInsensitive(side.toUpperCase(Locale.ROOT)) == null) { fluidHandler = FluidUtil.getHandlerFromDirection(arguments.getString(1), owner); } else { fluidHandler = FluidUtil.getHandlerFromName(computer, arguments.getString(1)); } if (fluidHandler == null) - return MethodResult.of(0, "The target tank does not exist. Make sure the bridge is exposed in the computer network. Reach out to our discord or our documentation for help."); + return MethodResult.of(0, + "The target tank does not exist. Make sure the bridge is exposed in the computer network. Reach out to our discord or our documentation for help."); return exportToTank(arguments, fluidHandler); } @@ -384,14 +417,16 @@ public final MethodResult importFluid(IComputerAccess computer, IArguments argum String side = arguments.getString(1); IFluidHandler fluidHandler; - if (Direction.byName(side.toUpperCase(Locale.ROOT)) == null && ComputerSide.valueOfInsensitive(side.toUpperCase(Locale.ROOT)) == null) { + if (Direction.byName(side.toUpperCase(Locale.ROOT)) == null + && ComputerSide.valueOfInsensitive(side.toUpperCase(Locale.ROOT)) == null) { fluidHandler = FluidUtil.getHandlerFromDirection(arguments.getString(1), owner); } else { fluidHandler = FluidUtil.getHandlerFromName(computer, arguments.getString(1)); } if (fluidHandler == null) - return MethodResult.of(0, "The target tank does not exist. Make sure the bridge is exposed in the computer network. Reach out to our discord or our documentation for help."); + return MethodResult.of(0, + "The target tank does not exist. Make sure the bridge is exposed in the computer network. Reach out to our discord or our documentation for help."); return importToSystem(arguments, fluidHandler); } @@ -406,7 +441,9 @@ public final MethodResult getItem(IArguments arguments) throws LuaException { if (filter.rightPresent()) return MethodResult.of(null, filter.getRight()); - return MethodResult.of(RefinedStorage.getObjectFromStack(RefinedStorage.findStackFromFilter(getNetwork(), getNetwork().getCraftingManager(), filter.getLeft()), getNetwork())); + return MethodResult.of(RefinedStorage.getObjectFromStack( + RefinedStorage.findStackFromFilter(getNetwork(), getNetwork().getCraftingManager(), filter.getLeft()), + getNetwork())); } @Override @@ -421,12 +458,12 @@ public final MethodResult craftItem(IComputerAccess computerAccess, IArguments a if (!isAvailable()) return notConnected(); - Pair filter = ItemFilter.parse(arguments.getTable(0)); if (filter.rightPresent()) return MethodResult.of(null, filter.getRight()); - ItemStack stack = RefinedStorage.findStackFromFilter(getNetwork(), getNetwork().getCraftingManager(), filter.getLeft()); + ItemStack stack = RefinedStorage.findStackFromFilter(getNetwork(), getNetwork().getCraftingManager(), + filter.getLeft()); if (stack == null) return MethodResult.of(null, "NOT_CRAFTABLE"); @@ -448,7 +485,8 @@ public final MethodResult craftFluid(IComputerAccess computerAccess, IArguments if (filter.rightPresent()) return MethodResult.of(null, filter.getRight()); - FluidStack stack = RefinedStorage.findFluidFromFilter(getNetwork(), getNetwork().getCraftingManager(), filter.getLeft()); + FluidStack stack = RefinedStorage.findFluidFromFilter(getNetwork(), getNetwork().getCraftingManager(), + filter.getLeft()); if (stack == null) return MethodResult.of(null, "NOT_CRAFTABLE"); @@ -479,7 +517,8 @@ public final MethodResult isItemCrafting(IArguments arguments) throws LuaExcepti if (filter.rightPresent()) return MethodResult.of(null, filter.getRight()); - ItemStack stack = RefinedStorage.findStackFromFilter(getNetwork(), getNetwork().getCraftingManager(), filter.getLeft()); + ItemStack stack = RefinedStorage.findStackFromFilter(getNetwork(), getNetwork().getCraftingManager(), + filter.getLeft()); if (stack == null) return MethodResult.of(null, "NOT_CRAFTABLE"); diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/metaphysics/EndAutomataCorePeripheral.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/metaphysics/EndAutomataCorePeripheral.java index bb50f1d60..d5f976f91 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/metaphysics/EndAutomataCorePeripheral.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/metaphysics/EndAutomataCorePeripheral.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.peripheral.metaphysics; import dan200.computercraft.api.turtle.ITurtleAccess; @@ -7,7 +22,6 @@ import de.srendi.advancedperipherals.common.configuration.APConfig; import de.srendi.advancedperipherals.lib.metaphysics.IAutomataCoreTier; - public class EndAutomataCorePeripheral extends WeakAutomataCorePeripheral { public static final String TYPE = "end_automata"; diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/metaphysics/HusbandryAutomataCorePeripheral.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/metaphysics/HusbandryAutomataCorePeripheral.java index ba89f1629..b9d1cf09b 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/metaphysics/HusbandryAutomataCorePeripheral.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/metaphysics/HusbandryAutomataCorePeripheral.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.peripheral.metaphysics; import dan200.computercraft.api.turtle.ITurtleAccess; @@ -25,7 +40,8 @@ public HusbandryAutomataCorePeripheral(ITurtleAccess turtle, TurtleSide side) { this(TYPE, turtle, side, AutomataCoreTier.TIER2); } - protected HusbandryAutomataCorePeripheral(String type, ITurtleAccess turtle, TurtleSide side, IAutomataCoreTier tier) { + protected HusbandryAutomataCorePeripheral(String type, ITurtleAccess turtle, TurtleSide side, + IAutomataCoreTier tier) { super(type, turtle, side, tier); addPlugin(new AutomataEntityTransferPlugin(this, suitableEntity)); addPlugin(new AutomataEntityHandPlugin(this, suitableEntity)); diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/metaphysics/OverpoweredEndAutomataCorePeripheral.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/metaphysics/OverpoweredEndAutomataCorePeripheral.java index 392dcfaf2..7fbf48558 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/metaphysics/OverpoweredEndAutomataCorePeripheral.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/metaphysics/OverpoweredEndAutomataCorePeripheral.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.peripheral.metaphysics; import dan200.computercraft.api.turtle.ITurtleAccess; diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/metaphysics/OverpoweredHusbandryAutomataCorePeripheral.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/metaphysics/OverpoweredHusbandryAutomataCorePeripheral.java index 220e9ce49..0c5878367 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/metaphysics/OverpoweredHusbandryAutomataCorePeripheral.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/metaphysics/OverpoweredHusbandryAutomataCorePeripheral.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.peripheral.metaphysics; import dan200.computercraft.api.turtle.ITurtleAccess; diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/metaphysics/OverpoweredWeakAutomataCorePeripheral.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/metaphysics/OverpoweredWeakAutomataCorePeripheral.java index 1b19eb40e..20f7e50cd 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/metaphysics/OverpoweredWeakAutomataCorePeripheral.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/metaphysics/OverpoweredWeakAutomataCorePeripheral.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.peripheral.metaphysics; import dan200.computercraft.api.turtle.ITurtleAccess; diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/metaphysics/WeakAutomataCorePeripheral.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/metaphysics/WeakAutomataCorePeripheral.java index 64bd72511..2ee227c33 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/metaphysics/WeakAutomataCorePeripheral.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/metaphysics/WeakAutomataCorePeripheral.java @@ -1,9 +1,28 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.peripheral.metaphysics; import dan200.computercraft.api.turtle.ITurtleAccess; import dan200.computercraft.api.turtle.TurtleSide; import de.srendi.advancedperipherals.common.addons.computercraft.operations.AutomataCoreTier; -import de.srendi.advancedperipherals.common.addons.computercraft.peripheral.plugins.*; +import de.srendi.advancedperipherals.common.addons.computercraft.peripheral.plugins.AutomataBlockHandPlugin; +import de.srendi.advancedperipherals.common.addons.computercraft.peripheral.plugins.AutomataChargingPlugin; +import de.srendi.advancedperipherals.common.addons.computercraft.peripheral.plugins.AutomataItemSuckPlugin; +import de.srendi.advancedperipherals.common.addons.computercraft.peripheral.plugins.AutomataLookPlugin; +import de.srendi.advancedperipherals.common.addons.computercraft.peripheral.plugins.AutomataSoulFeedingPlugin; import de.srendi.advancedperipherals.common.configuration.APConfig; import de.srendi.advancedperipherals.lib.metaphysics.IAutomataCoreTier; import de.srendi.advancedperipherals.lib.peripherals.AutomataCorePeripheral; diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataBlockHandPlugin.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataBlockHandPlugin.java index 4f9fb08e6..bf9f8259f 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataBlockHandPlugin.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataBlockHandPlugin.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.peripheral.plugins; import dan200.computercraft.api.lua.IArguments; @@ -12,9 +27,9 @@ import de.srendi.advancedperipherals.lib.peripherals.IPeripheralOperation; import net.minecraft.world.InteractionResult; import net.minecraft.world.item.ItemStack; - import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; + import java.util.Collections; import java.util.Map; @@ -42,7 +57,8 @@ public final MethodResult digBlock(@NotNull IArguments arguments) throws LuaExce TurtlePeripheralOwner owner = automataCore.getPeripheralOwner(); ItemStack selectedTool = owner.getToolInMainHand(); int previousDamageValue = selectedTool.getDamageValue(); - Pair result = owner.withPlayer(APFakePlayer.wrapActionWithShiftKey(sneak, APFakePlayer.wrapActionWithRot(yaw, pitch, APFakePlayer::digBlock))); + Pair result = owner.withPlayer(APFakePlayer.wrapActionWithShiftKey(sneak, + APFakePlayer.wrapActionWithRot(yaw, pitch, APFakePlayer::digBlock))); if (!result.getLeft()) { return MethodResult.of(false, result.getRight()); } @@ -63,7 +79,8 @@ public final MethodResult useOnBlock(@NotNull IArguments arguments) throws LuaEx TurtlePeripheralOwner owner = automataCore.getPeripheralOwner(); ItemStack selectedTool = owner.getToolInMainHand(); int previousDamageValue = selectedTool.getDamageValue(); - InteractionResult result = owner.withPlayer(APFakePlayer.wrapActionWithShiftKey(sneak, APFakePlayer.wrapActionWithRot(yaw, pitch, APFakePlayer::useOnBlock))); + InteractionResult result = owner.withPlayer(APFakePlayer.wrapActionWithShiftKey(sneak, + APFakePlayer.wrapActionWithRot(yaw, pitch, APFakePlayer::useOnBlock))); if (automataCore.hasAttribute(AutomataCorePeripheral.ATTR_STORING_TOOL_DURABILITY)) { selectedTool.setDamageValue(previousDamageValue); } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataChargingPlugin.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataChargingPlugin.java index d47108ac4..420ebf666 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataChargingPlugin.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataChargingPlugin.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.peripheral.plugins; import dan200.computercraft.api.lua.IArguments; @@ -11,8 +26,8 @@ import de.srendi.advancedperipherals.lib.peripherals.AutomataCorePeripheral; import net.minecraft.world.item.ItemStack; import net.minecraftforge.common.capabilities.ForgeCapabilities; - import org.jetbrains.annotations.NotNull; + import java.util.Objects; public class AutomataChargingPlugin extends AutomataCorePlugin { @@ -39,7 +54,9 @@ public final MethodResult chargeTurtle(@NotNull IArguments arguments) throws Lua } else { requestedRF = storage.getEnergyStored(); } - int realConsumedRF = storage.extractEnergy(Math.min(requestedRF, availableFuelSpace * APConfig.METAPHYSICS_CONFIG.energyToFuelRate.get()), false); + int realConsumedRF = storage.extractEnergy( + Math.min(requestedRF, availableFuelSpace * APConfig.METAPHYSICS_CONFIG.energyToFuelRate.get()), + false); int receivedFuel = realConsumedRF / APConfig.METAPHYSICS_CONFIG.energyToFuelRate.get(); fuelAbility.addFuel(receivedFuel); automataCore.addRotationCycle(); diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataCorePlugin.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataCorePlugin.java index ee80600f6..1388913af 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataCorePlugin.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataCorePlugin.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.peripheral.plugins; import de.srendi.advancedperipherals.lib.peripherals.AutomataCorePeripheral; diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataEntityHandPlugin.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataEntityHandPlugin.java index 14dd9e6f1..d88dbceec 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataEntityHandPlugin.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataEntityHandPlugin.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.peripheral.plugins; import dan200.computercraft.api.lua.IArguments; @@ -18,9 +33,9 @@ import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.EntityHitResult; import net.minecraft.world.phys.HitResult; - import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; + import java.util.Collections; import java.util.List; import java.util.Map; @@ -52,7 +67,8 @@ public final MethodResult useOnAnimal(@NotNull IArguments arguments) throws LuaE TurtlePeripheralOwner owner = automataCore.getPeripheralOwner(); ItemStack selectedTool = owner.getToolInMainHand(); int previousDamageValue = selectedTool.getDamageValue(); - InteractionResult result = owner.withPlayer(APFakePlayer.wrapActionWithShiftKey(sneak, APFakePlayer.wrapActionWithRot(yaw, pitch, p -> p.useOnFilteredEntity(suitableEntity)))); + InteractionResult result = owner.withPlayer(APFakePlayer.wrapActionWithShiftKey(sneak, + APFakePlayer.wrapActionWithRot(yaw, pitch, p -> p.useOnFilteredEntity(suitableEntity)))); if (automataCore.hasAttribute(AutomataCorePeripheral.ATTR_STORING_TOOL_DURABILITY)) selectedTool.setDamageValue(previousDamageValue); @@ -68,7 +84,8 @@ public final MethodResult inspectAnimal(@NotNull IArguments arguments) throws Lu automataCore.addRotationCycle(); TurtlePeripheralOwner owner = automataCore.getPeripheralOwner(); - HitResult entityHit = owner.withPlayer(APFakePlayer.wrapActionWithRot(yaw, pitch, p -> p.findHit(false, true, suitableEntity))); + HitResult entityHit = owner + .withPlayer(APFakePlayer.wrapActionWithRot(yaw, pitch, p -> p.findHit(false, true, suitableEntity))); if (entityHit.getType() == HitResult.Type.MISS) return MethodResult.of(null, "Nothing found"); @@ -86,7 +103,9 @@ public final MethodResult searchAnimals() { BlockPos currentPos = owner.getPos(); AABB box = new AABB(currentPos); ItemStack itemInHand = owner.getToolInMainHand(); - List> entities = owner.getLevel().getEntities((Entity) null, box.inflate(automataCore.getInteractionRadius()), suitableEntity).stream().map(entity -> LuaConverter.completeEntityWithPositionToLua(entity, itemInHand, currentPos)).toList(); + List> entities = owner.getLevel() + .getEntities((Entity) null, box.inflate(automataCore.getInteractionRadius()), suitableEntity).stream() + .map(entity -> LuaConverter.completeEntityWithPositionToLua(entity, itemInHand, currentPos)).toList(); return MethodResult.of(entities); } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataEntityTransferPlugin.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataEntityTransferPlugin.java index e46ca4356..5b9face10 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataEntityTransferPlugin.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataEntityTransferPlugin.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.peripheral.plugins; import dan200.computercraft.api.lua.IArguments; @@ -18,9 +33,9 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.phys.EntityHitResult; import net.minecraft.world.phys.HitResult; - import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; + import java.util.Collections; import java.util.Map; import java.util.function.Predicate; @@ -59,8 +74,7 @@ protected void removeEntity() { automataCore.getPeripheralOwner().getDataStorage().remove(ENTITY_NBT_KEY); } - @Nullable - protected Entity extractEntity() { + @Nullable protected Entity extractEntity() { CompoundTag data = getEntity(); EntityType type = EntityType.byString(data.getString("entity")).orElse(null); if (type != null) { @@ -73,14 +87,14 @@ protected Entity extractEntity() { return null; } - @LuaFunction(mainThread = true) public final MethodResult captureAnimal(@NotNull IArguments arguments) throws LuaException { Map opts = arguments.count() > 0 ? arguments.getTable(0) : Collections.emptyMap(); float yaw = opts != null ? (float) TableHelper.optNumberField(opts, "yaw", 0) : 0; float pitch = opts != null ? (float) TableHelper.optNumberField(opts, "pitch", 0) : 0; - HitResult entityHit = automataCore.getPeripheralOwner().withPlayer(APFakePlayer.wrapActionWithRot(yaw, pitch, p -> p.findHit(false, true, suitableEntity))); + HitResult entityHit = automataCore.getPeripheralOwner() + .withPlayer(APFakePlayer.wrapActionWithRot(yaw, pitch, p -> p.findHit(false, true, suitableEntity))); if (entityHit.getType() == HitResult.Type.MISS) return MethodResult.of(null, "Nothing found"); return automataCore.withOperation(CAPTURE_ANIMAL, context -> { @@ -122,6 +136,7 @@ public final MethodResult releaseAnimal() { @LuaFunction(mainThread = true) public final MethodResult getCapturedAnimal() { Entity extractedEntity = extractEntity(); - return MethodResult.of(LuaConverter.completeEntityToLua(extractedEntity, automataCore.getPeripheralOwner().getToolInMainHand())); + return MethodResult.of(LuaConverter.completeEntityToLua(extractedEntity, + automataCore.getPeripheralOwner().getToolInMainHand())); } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataItemSuckPlugin.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataItemSuckPlugin.java index 7c2ea5a92..c4d136e47 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataItemSuckPlugin.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataItemSuckPlugin.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.peripheral.plugins; import dan200.computercraft.api.lua.IArguments; @@ -15,8 +30,8 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.phys.AABB; import net.minecraftforge.registries.ForgeRegistries; - import org.jetbrains.annotations.NotNull; + import java.util.HashMap; import java.util.List; import java.util.Map; @@ -37,7 +52,8 @@ public IPeripheralOperation[] getOperations() { protected AABB getBox(BlockPos pos) { int x = pos.getX(), y = pos.getY(), z = pos.getZ(); int interactionRadius = automataCore.getInteractionRadius(); - return new AABB(x - interactionRadius, y - interactionRadius, z - interactionRadius, x + interactionRadius, y + interactionRadius, z + interactionRadius); + return new AABB(x - interactionRadius, y - interactionRadius, z - interactionRadius, x + interactionRadius, + y + interactionRadius, z + interactionRadius); } protected List getItems() { diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataLookPlugin.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataLookPlugin.java index 2b27487bf..b3d67522b 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataLookPlugin.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataLookPlugin.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.peripheral.plugins; import dan200.computercraft.api.lua.IArguments; @@ -15,8 +30,8 @@ import net.minecraft.world.phys.EntityHitResult; import net.minecraft.world.phys.HitResult; import net.minecraftforge.registries.ForgeRegistries; - import org.jetbrains.annotations.NotNull; + import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -56,7 +71,8 @@ public final MethodResult lookAtEntity(@NotNull IArguments arguments) throws Lua float pitch = opts != null ? (float) TableHelper.optNumberField(opts, "pitch", 0) : 0; automataCore.addRotationCycle(); - HitResult result = automataCore.getPeripheralOwner().withPlayer(APFakePlayer.wrapActionWithRot(yaw, pitch, p -> p.findHit(false, true))); + HitResult result = automataCore.getPeripheralOwner() + .withPlayer(APFakePlayer.wrapActionWithRot(yaw, pitch, p -> p.findHit(false, true))); if (result.getType() == HitResult.Type.MISS) return MethodResult.of(null, "No entity find"); diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataSoulFeedingPlugin.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataSoulFeedingPlugin.java index 79368507e..92cf34951 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataSoulFeedingPlugin.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataSoulFeedingPlugin.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.peripheral.plugins; import dan200.computercraft.api.lua.LuaFunction; diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataWarpingPlugin.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataWarpingPlugin.java index 712ce2c29..4b394c1f3 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataWarpingPlugin.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataWarpingPlugin.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.peripheral.plugins; import dan200.computercraft.api.lua.LuaException; @@ -36,8 +51,7 @@ public AutomataWarpingPlugin(AutomataCorePeripheral automataCore) { return new IPeripheralOperation[]{WARP}; } - @NotNull - protected Pair getPointData() { + @NotNull protected Pair getPointData() { TurtlePeripheralOwner owner = automataCore.getPeripheralOwner(); CompoundTag settings = owner.getDataStorage(); if (!settings.contains(WORLD_DATA_MARK)) { diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/pocket/PocketChatBoxUpgrade.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/pocket/PocketChatBoxUpgrade.java index e0a17833b..32c5833b7 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/pocket/PocketChatBoxUpgrade.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/pocket/PocketChatBoxUpgrade.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.pocket; import dan200.computercraft.api.pocket.IPocketAccess; @@ -13,8 +28,7 @@ public PocketChatBoxUpgrade(ResourceLocation id, ItemStack stack) { super(id, stack); } - @Nullable - @Override + @Nullable @Override public ChatBoxPeripheral getPeripheral(IPocketAccess access) { return new ChatBoxPeripheral(access); } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/pocket/PocketColonyIntegratorUpgrade.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/pocket/PocketColonyIntegratorUpgrade.java index 752ccb18e..af247e9a1 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/pocket/PocketColonyIntegratorUpgrade.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/pocket/PocketColonyIntegratorUpgrade.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.pocket; import dan200.computercraft.api.pocket.IPocketAccess; diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/pocket/PocketEnvironmentUpgrade.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/pocket/PocketEnvironmentUpgrade.java index dc6719b17..361f05744 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/pocket/PocketEnvironmentUpgrade.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/pocket/PocketEnvironmentUpgrade.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.pocket; import dan200.computercraft.api.pocket.IPocketAccess; @@ -14,8 +29,7 @@ public PocketEnvironmentUpgrade(ResourceLocation id, ItemStack stack) { super(id, stack); } - @Nullable - @Override + @Nullable @Override public EnvironmentDetectorPeripheral getPeripheral(@NotNull IPocketAccess iPocketAccess) { return new EnvironmentDetectorPeripheral(iPocketAccess); } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/pocket/PocketGeoScannerUpgrade.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/pocket/PocketGeoScannerUpgrade.java index 98823d94a..3bca9b1f4 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/pocket/PocketGeoScannerUpgrade.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/pocket/PocketGeoScannerUpgrade.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.pocket; import dan200.computercraft.api.pocket.IPocketAccess; @@ -14,8 +29,7 @@ public PocketGeoScannerUpgrade(ResourceLocation id, ItemStack stack) { super(id, stack); } - @Nullable - @Override + @Nullable @Override public GeoScannerPeripheral getPeripheral(@NotNull IPocketAccess iPocketAccess) { return new GeoScannerPeripheral(iPocketAccess); } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/pocket/PocketPlayerDetectorUpgrade.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/pocket/PocketPlayerDetectorUpgrade.java index 1e2b6bb43..878e99a7d 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/pocket/PocketPlayerDetectorUpgrade.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/pocket/PocketPlayerDetectorUpgrade.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.pocket; import dan200.computercraft.api.pocket.IPocketAccess; @@ -14,8 +29,7 @@ public PocketPlayerDetectorUpgrade(ResourceLocation id, ItemStack stack) { super(id, stack); } - @Nullable - @Override + @Nullable @Override public PlayerDetectorPeripheral getPeripheral(@NotNull IPocketAccess iPocketAccess) { return new PlayerDetectorPeripheral(iPocketAccess); } 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 b82aafab2..2faef582e 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 @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.turtles; import dan200.computercraft.api.turtle.ITurtleAccess; diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/TurtleChunkyUpgrade.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/TurtleChunkyUpgrade.java index bed242638..49a130dc6 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/TurtleChunkyUpgrade.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/TurtleChunkyUpgrade.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.turtles; import dan200.computercraft.api.peripheral.IPeripheral; @@ -42,7 +57,7 @@ public void update(@NotNull ITurtleAccess turtle, @NotNull TurtleSide side) { // TODO: turtle will stop work when crossing chunks if update every 10 ticks // updateTick++; // if (updateTick < 10) { - // return; + // return; // } // updateTick = 0; IPeripheral peripheral = turtle.getPeripheral(side); diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/TurtleCompassUpgrade.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/TurtleCompassUpgrade.java index d7a1482d9..429fed572 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/TurtleCompassUpgrade.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/TurtleCompassUpgrade.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.turtles; import dan200.computercraft.api.turtle.ITurtleAccess; diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/TurtleEnvironmentDetectorUpgrade.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/TurtleEnvironmentDetectorUpgrade.java index f30886d5c..26da84417 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/TurtleEnvironmentDetectorUpgrade.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/TurtleEnvironmentDetectorUpgrade.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.turtles; import dan200.computercraft.api.turtle.ITurtleAccess; diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/TurtleGeoScannerUpgrade.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/TurtleGeoScannerUpgrade.java index f2f927f2e..e8e2cfa75 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/TurtleGeoScannerUpgrade.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/TurtleGeoScannerUpgrade.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.turtles; import dan200.computercraft.api.turtle.ITurtleAccess; diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/TurtlePlayerDetectorUpgrade.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/TurtlePlayerDetectorUpgrade.java index 135e19eb9..eae383d6f 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/TurtlePlayerDetectorUpgrade.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/TurtlePlayerDetectorUpgrade.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.turtles; import dan200.computercraft.api.turtle.ITurtleAccess; diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/metaphysics/EndAutomata.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/metaphysics/EndAutomata.java index 3d100360e..8c4866661 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/metaphysics/EndAutomata.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/metaphysics/EndAutomata.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.turtles.metaphysics; import dan200.computercraft.api.turtle.ITurtleAccess; diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/metaphysics/HusbandryAutomata.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/metaphysics/HusbandryAutomata.java index 898710cb9..3b501eb9e 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/metaphysics/HusbandryAutomata.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/metaphysics/HusbandryAutomata.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.turtles.metaphysics; import dan200.computercraft.api.turtle.ITurtleAccess; diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/metaphysics/OverpoweredEndAutomata.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/metaphysics/OverpoweredEndAutomata.java index 408965f4e..ba842a647 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/metaphysics/OverpoweredEndAutomata.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/metaphysics/OverpoweredEndAutomata.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.turtles.metaphysics; import dan200.computercraft.api.turtle.ITurtleAccess; @@ -26,7 +41,8 @@ public ModelResourceLocation getRightModel() { } @Override - protected OverpoweredEndAutomataCorePeripheral buildPeripheral(@NotNull ITurtleAccess turtle, @NotNull TurtleSide side) { + protected OverpoweredEndAutomataCorePeripheral buildPeripheral(@NotNull ITurtleAccess turtle, + @NotNull TurtleSide side) { return new OverpoweredEndAutomataCorePeripheral(turtle, side); } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/metaphysics/OverpoweredHusbandryAutomata.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/metaphysics/OverpoweredHusbandryAutomata.java index 83f1e27d8..b30743fb8 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/metaphysics/OverpoweredHusbandryAutomata.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/metaphysics/OverpoweredHusbandryAutomata.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.turtles.metaphysics; import dan200.computercraft.api.turtle.ITurtleAccess; @@ -9,7 +24,9 @@ import net.minecraft.world.item.ItemStack; import org.jetbrains.annotations.NotNull; -public class OverpoweredHusbandryAutomata extends ClockwiseAnimatedTurtleUpgrade { +public class OverpoweredHusbandryAutomata + extends + ClockwiseAnimatedTurtleUpgrade { public OverpoweredHusbandryAutomata(ResourceLocation id, ItemStack stack) { super(id, stack); @@ -26,7 +43,8 @@ public ModelResourceLocation getRightModel() { } @Override - protected OverpoweredHusbandryAutomataCorePeripheral buildPeripheral(@NotNull ITurtleAccess turtle, @NotNull TurtleSide side) { + protected OverpoweredHusbandryAutomataCorePeripheral buildPeripheral(@NotNull ITurtleAccess turtle, + @NotNull TurtleSide side) { return new OverpoweredHusbandryAutomataCorePeripheral(turtle, side); } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/metaphysics/OverpoweredWeakAutomata.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/metaphysics/OverpoweredWeakAutomata.java index 4ed87f62c..f2819221a 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/metaphysics/OverpoweredWeakAutomata.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/metaphysics/OverpoweredWeakAutomata.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.turtles.metaphysics; import dan200.computercraft.api.turtle.ITurtleAccess; @@ -26,7 +41,8 @@ public ModelResourceLocation getRightModel() { } @Override - protected OverpoweredWeakAutomataCorePeripheral buildPeripheral(@NotNull ITurtleAccess turtle, @NotNull TurtleSide side) { + protected OverpoweredWeakAutomataCorePeripheral buildPeripheral(@NotNull ITurtleAccess turtle, + @NotNull TurtleSide side) { return new OverpoweredWeakAutomataCorePeripheral(turtle, side); } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/metaphysics/WeakAutomata.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/metaphysics/WeakAutomata.java index 3d35bfa0c..d360786e4 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/metaphysics/WeakAutomata.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/turtles/metaphysics/WeakAutomata.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.computercraft.turtles.metaphysics; import dan200.computercraft.api.turtle.ITurtleAccess; diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/create/BasinIntegration.java b/src/main/java/de/srendi/advancedperipherals/common/addons/create/BasinIntegration.java index 04c9711b2..633a32ce8 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/create/BasinIntegration.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/create/BasinIntegration.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.create; import com.simibubi.create.content.processing.basin.BasinBlockEntity; @@ -12,7 +27,11 @@ import net.minecraftforge.registries.ForgeRegistries; import org.jetbrains.annotations.NotNull; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; public class BasinIntegration extends BlockEntityIntegrationPeripheral { @@ -20,8 +39,7 @@ public BasinIntegration(BlockEntity entity) { super(entity); } - @NotNull - @Override + @NotNull @Override public String getType() { return "basin"; } @@ -70,7 +88,8 @@ public final Map getFilter() { @LuaFunction(mainThread = true) public final List getInventory() { Optional handlerOptional = blockEntity.getCapability(ForgeCapabilities.ITEM_HANDLER).resolve(); - if (handlerOptional.isEmpty()) return null; + if (handlerOptional.isEmpty()) + return null; IItemHandler handler = handlerOptional.get(); List items = new ArrayList<>(); for (int slot = 0; slot < handler.getSlots(); slot++) { diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/create/BlazeBurnerIntegration.java b/src/main/java/de/srendi/advancedperipherals/common/addons/create/BlazeBurnerIntegration.java index eb45e1f28..40a8f0cd7 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/create/BlazeBurnerIntegration.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/create/BlazeBurnerIntegration.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.create; import com.simibubi.create.content.processing.burner.BlazeBurnerBlockEntity; @@ -15,8 +30,7 @@ public BlazeBurnerIntegration(BlockEntity entity) { super(entity); } - @NotNull - @Override + @NotNull @Override public String getType() { return "blaze_burner"; } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/create/FluidTankIntegration.java b/src/main/java/de/srendi/advancedperipherals/common/addons/create/FluidTankIntegration.java index cc59643e2..e98be8161 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/create/FluidTankIntegration.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/create/FluidTankIntegration.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.create; import com.simibubi.create.content.fluids.tank.FluidTankBlockEntity; @@ -16,8 +31,7 @@ public FluidTankIntegration(BlockEntity entity) { super(entity); } - @NotNull - @Override + @NotNull @Override public String getType() { return "fluid_tank"; } @@ -27,7 +41,8 @@ public final Map getInfo() { Map data = new HashMap<>(); data.put("capacity", blockEntity.getControllerBE().getTankInventory().getCapacity()); data.put("amount", blockEntity.getControllerBE().getTankInventory().getFluidAmount()); - data.put("fluid", ForgeRegistries.FLUIDS.getKey(blockEntity.getControllerBE().getTankInventory().getFluid().getFluid()).toString()); + data.put("fluid", ForgeRegistries.FLUIDS + .getKey(blockEntity.getControllerBE().getTankInventory().getFluid().getFluid()).toString()); data.put("isBoiler", blockEntity.getControllerBE().boiler.isActive()); return data; } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/create/Integration.java b/src/main/java/de/srendi/advancedperipherals/common/addons/create/Integration.java index 2f5228058..e21781609 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/create/Integration.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/create/Integration.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.create; import com.simibubi.create.content.fluids.tank.FluidTankBlockEntity; @@ -10,11 +25,17 @@ public class Integration implements Runnable { @Override public void run() { - IntegrationPeripheralProvider.registerBlockEntityIntegration(BlazeBurnerIntegration::new, BlazeBurnerBlockEntity.class); - IntegrationPeripheralProvider.registerBlockEntityIntegration(FluidTankIntegration::new, FluidTankBlockEntity.class); - // Disable until verified that it does not clash with the existing create CC integration - //IntegrationPeripheralProvider.registerBlockEntityIntegration(ScrollValueBehaviourIntegration::new, KineticTileEntity.class, tile -> tile.getBehaviour(ScrollValueBehaviour.TYPE) != null, 10); + IntegrationPeripheralProvider.registerBlockEntityIntegration(BlazeBurnerIntegration::new, + BlazeBurnerBlockEntity.class); + IntegrationPeripheralProvider.registerBlockEntityIntegration(FluidTankIntegration::new, + FluidTankBlockEntity.class); + // Disable until verified that it does not clash with the existing create CC + // integration + // IntegrationPeripheralProvider.registerBlockEntityIntegration(ScrollValueBehaviourIntegration::new, + // KineticTileEntity.class, tile -> tile.getBehaviour(ScrollValueBehaviour.TYPE) + // != null, 10); IntegrationPeripheralProvider.registerBlockEntityIntegration(BasinIntegration::new, BasinBlockEntity.class); - IntegrationPeripheralProvider.registerBlockEntityIntegration(MechanicalMixerIntegration::new, MechanicalMixerBlockEntity.class); + IntegrationPeripheralProvider.registerBlockEntityIntegration(MechanicalMixerIntegration::new, + MechanicalMixerBlockEntity.class); } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/create/MechanicalMixerIntegration.java b/src/main/java/de/srendi/advancedperipherals/common/addons/create/MechanicalMixerIntegration.java index 91140fd47..f54806ba9 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/create/MechanicalMixerIntegration.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/create/MechanicalMixerIntegration.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.create; import com.simibubi.create.content.kinetics.mixer.MechanicalMixerBlockEntity; @@ -13,8 +28,7 @@ public MechanicalMixerIntegration(BlockEntity entity) { super(entity); } - @NotNull - @Override + @NotNull @Override public String getType() { return "mechanical_mixer"; } @@ -26,7 +40,8 @@ public final boolean isRunning() { @LuaFunction(mainThread = true) public final boolean hasBasin() { - if (blockEntity.getLevel() == null) return false; + if (blockEntity.getLevel() == null) + return false; BlockEntity basinTE = blockEntity.getLevel().getBlockEntity(blockEntity.getBlockPos().below(2)); return basinTE instanceof BasinBlockEntity; } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/create/ScrollValueBehaviourIntegration.java b/src/main/java/de/srendi/advancedperipherals/common/addons/create/ScrollValueBehaviourIntegration.java index 81e58614b..c5e873c50 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/create/ScrollValueBehaviourIntegration.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/create/ScrollValueBehaviourIntegration.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.create; import com.simibubi.create.content.kinetics.base.KineticBlockEntity; @@ -8,7 +23,8 @@ import org.jetbrains.annotations.NotNull; /** - * Integration for kinetic tile entities with scroll value behaviours like the speed controller or the creative motor + * Integration for kinetic tile entities with scroll value behaviours like the + * speed controller or the creative motor */ public class ScrollValueBehaviourIntegration extends BlockEntityIntegrationPeripheral { @@ -16,8 +32,7 @@ public ScrollValueBehaviourIntegration(BlockEntity entity) { super(entity); } - @NotNull - @Override + @NotNull @Override public String getType() { return "scroll_behaviour_entity"; } @@ -25,14 +40,16 @@ public String getType() { @LuaFunction(mainThread = true) public final int getTargetSpeed() { ScrollValueBehaviour scrollBehaviour = blockEntity.getBehaviour(ScrollValueBehaviour.TYPE); - if (scrollBehaviour == null) return 0; + if (scrollBehaviour == null) + return 0; return scrollBehaviour.getValue(); } @LuaFunction(mainThread = true) public final boolean setTargetSpeed(int speed) { ScrollValueBehaviour scrollBehaviour = blockEntity.getBehaviour(ScrollValueBehaviour.TYPE); - if (scrollBehaviour == null) return false; + if (scrollBehaviour == null) + return false; scrollBehaviour.setValue(speed); return true; } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/curios/CuriosHelper.java b/src/main/java/de/srendi/advancedperipherals/common/addons/curios/CuriosHelper.java index 2c6fc1241..85d3379bc 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/curios/CuriosHelper.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/curios/CuriosHelper.java @@ -1,35 +1,39 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.curios; public class CuriosHelper { - /*public static ICapabilityProvider createARGogglesProvider(ItemStack stackFor) { - return new ICapabilityProvider() { - - @Override - public LazyOptional getCapability(Capability cap, Direction side) { - return CuriosCapability.ITEM.orEmpty(cap, LazyOptional.of(() -> new ICurio() { - - @Override - public void curioTick(String identifier, int index, LivingEntity livingEntity) { - if (!SideHelper.isClientPlayer(livingEntity)) - return; - ARGogglesItem.clientTick((LocalPlayer) livingEntity, stackFor); - } - - @Override - public ItemStack getStack() { - return stackFor; - } - - @Override - public void onUnequip(SlotContext slotContext, ItemStack newStack) { - if (!(slotContext.getWearer() instanceof ServerPlayer serverPlayer)) - return; - MNetwork.sendTo(new ClearHudCanvasMessage(), serverPlayer); - } - - //TODO: add rendering if in Curio slot - })); - } - }; - }*/ + /* + * public static ICapabilityProvider createARGogglesProvider(ItemStack stackFor) + * { return new ICapabilityProvider() { + * + * @Override public LazyOptional getCapability(Capability cap, + * Direction side) { return CuriosCapability.ITEM.orEmpty(cap, + * LazyOptional.of(() -> new ICurio() { + * + * @Override public void curioTick(String identifier, int index, LivingEntity + * livingEntity) { if (!SideHelper.isClientPlayer(livingEntity)) return; + * ARGogglesItem.clientTick((LocalPlayer) livingEntity, stackFor); } + * + * @Override public ItemStack getStack() { return stackFor; } + * + * @Override public void onUnequip(SlotContext slotContext, ItemStack newStack) + * { if (!(slotContext.getWearer() instanceof ServerPlayer serverPlayer)) + * return; MNetwork.sendTo(new ClearHudCanvasMessage(), serverPlayer); } + * + * //TODO: add rendering if in Curio slot })); } }; } + */ } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/dimstorage/DimChestIntegration.java b/src/main/java/de/srendi/advancedperipherals/common/addons/dimstorage/DimChestIntegration.java index 037775037..b5c9aef19 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/dimstorage/DimChestIntegration.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/dimstorage/DimChestIntegration.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.dimstorage; import dan200.computercraft.api.lua.LuaFunction; @@ -15,8 +30,7 @@ protected DimChestIntegration(BlockEntity entity) { super(entity); } - @NotNull - @Override + @NotNull @Override public String getType() { return "dimChest"; } @@ -47,7 +61,8 @@ public final int getChannel() { @LuaFunction(mainThread = true) public final boolean setChannel(int channel) { Frequency fre = blockEntity.getFrequency(); - if (fre.hasOwner()) return false; + if (fre.hasOwner()) + return false; fre.setChannel(channel); blockEntity.setFrequency(fre); return true; diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/dimstorage/Integration.java b/src/main/java/de/srendi/advancedperipherals/common/addons/dimstorage/Integration.java index a74e46b62..1dd0f0031 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/dimstorage/Integration.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/dimstorage/Integration.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.dimstorage; import de.srendi.advancedperipherals.common.addons.computercraft.integrations.IntegrationPeripheralProvider; @@ -7,6 +22,7 @@ public class Integration implements Runnable { @Override public void run() { - IntegrationPeripheralProvider.registerBlockEntityIntegration(DimChestIntegration::new, BlockEntityDimChest.class); + IntegrationPeripheralProvider.registerBlockEntityIntegration(DimChestIntegration::new, + BlockEntityDimChest.class); } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/mekanism/EnvironmentRadiationPlugin.java b/src/main/java/de/srendi/advancedperipherals/common/addons/mekanism/EnvironmentRadiationPlugin.java index 9bb14e274..fb287ea20 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/mekanism/EnvironmentRadiationPlugin.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/mekanism/EnvironmentRadiationPlugin.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.mekanism; import dan200.computercraft.api.lua.LuaFunction; diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/mekanism/Integration.java b/src/main/java/de/srendi/advancedperipherals/common/addons/mekanism/Integration.java index 9f880445a..ad8281999 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/mekanism/Integration.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/mekanism/Integration.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.mekanism; import de.srendi.advancedperipherals.common.addons.computercraft.peripheral.EnvironmentDetectorPeripheral; diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/mekanism/Mekanism.java b/src/main/java/de/srendi/advancedperipherals/common/addons/mekanism/Mekanism.java index 42ef0ee66..ed631e00b 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/mekanism/Mekanism.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/mekanism/Mekanism.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.mekanism; import mekanism.api.Coord4D; @@ -18,7 +33,10 @@ private Mekanism() { public static Object getRadiation(Level world, BlockPos pos) { if (!world.isClientSide) { Map map = new HashMap<>(); - String[] radiation = UnitDisplayUtils.getDisplayShort(MekanismAPI.getRadiationManager().getRadiationLevel(new Coord4D(pos, world)), UnitDisplayUtils.RadiationUnit.SV, 4).getString().split(" "); + String[] radiation = UnitDisplayUtils + .getDisplayShort(MekanismAPI.getRadiationManager().getRadiationLevel(new Coord4D(pos, world)), + UnitDisplayUtils.RadiationUnit.SV, 4) + .getString().split(" "); map.put("radiation", radiation[0]); map.put("unit", radiation[1]); return map; diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/mekanism/MekanismCapabilities.java b/src/main/java/de/srendi/advancedperipherals/common/addons/mekanism/MekanismCapabilities.java index 858a11b3d..cd31f51d5 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/mekanism/MekanismCapabilities.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/mekanism/MekanismCapabilities.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.mekanism; import mekanism.api.chemical.gas.IGasHandler; @@ -11,5 +26,4 @@ public class MekanismCapabilities { public static final Capability GAS_HANDLER = get(new CapabilityToken<>() { }); - } 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 52f1fe572..e3449ed22 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 @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.minecolonies; import com.minecolonies.api.colony.ICitizenData; @@ -9,7 +24,11 @@ import com.minecolonies.api.colony.permissions.Action; import com.minecolonies.api.colony.workorders.IWorkOrder; import com.minecolonies.api.entity.citizen.Skill; -import com.minecolonies.api.research.*; +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.costs.IResearchCost; import com.minecolonies.api.research.effects.IResearchEffect; import com.minecolonies.api.research.util.ResearchState; @@ -44,8 +63,10 @@ public class MineColonies { /** * To ensure that the user of a pocket computer has the appropriate rights. * - * @param entity the user of the pocket computer - * @param colony the colony where the user is in it + * @param entity + * the user of the pocket computer + * @param colony + * the colony where the user is in it * @return true if the user has the appropriate rights */ public static boolean hasAccess(Entity entity, IColony colony) { @@ -60,7 +81,8 @@ public static boolean hasAccess(Entity entity, IColony colony) { /** * Converts a citizen to a map * - * @param citizen the citizen + * @param citizen + * the citizen * @return a map with information about the citizen */ public static Object citizenToObject(ICitizenData citizen) { @@ -70,13 +92,17 @@ public static Object citizenToObject(ICitizenData citizen) { map.put("bedPos", LuaConverter.posToObject(citizen.getBedPos())); map.put("children", citizen.getChildren()); map.put("location", LuaConverter.posToObject(citizen.getLastPosition())); - map.put("state", citizen.getStatus() == null ? "Idle" : Component.translatable(citizen.getStatus().getTranslationKey()).getString()); + map.put("state", + citizen.getStatus() == null + ? "Idle" + : Component.translatable(citizen.getStatus().getTranslationKey()).getString()); map.put("age", citizen.isChild() ? "child" : "adult"); map.put("gender", citizen.isFemale() ? "female" : "male"); map.put("saturation", citizen.getSaturation()); map.put("happiness", citizen.getCitizenHappinessHandler().getHappiness(citizen.getColony(), citizen)); map.put("skills", skillsToObject(citizen.getCitizenSkillHandler().getSkills())); - map.put("work", citizen.getWorkBuilding() == null ? null : jobToObject(citizen.getWorkBuilding(), citizen.getJob())); + map.put("work", + citizen.getWorkBuilding() == null ? null : jobToObject(citizen.getWorkBuilding(), citizen.getJob())); map.put("home", citizen.getHomeBuilding() == null ? null : homeToObject(citizen.getHomeBuilding())); map.put("betterFood", citizen.needsBetterFood()); map.put("isAsleep", map.get("state").toString().toLowerCase().contains("sleeping")); @@ -94,7 +120,8 @@ public static Object citizenToObject(ICitizenData citizen) { /** * Converts a visitor {@link IVisitorData} to a map * - * @param visitor the visitor + * @param visitor + * the visitor * @return a map with information about the visitor */ public static Object visitorToObject(IVisitorData visitor) { @@ -115,8 +142,10 @@ public static Object visitorToObject(IVisitorData visitor) { /** * Converts a building {@link IBuilding} and job {@link IJob} to a map * - * @param work the home building - * @param job the job + * @param work + * the home building + * @param job + * the job * @return a map with information about the building and job */ public static Object jobToObject(IBuilding work, IJob job) { @@ -133,7 +162,8 @@ public static Object jobToObject(IBuilding work, IJob job) { /** * Converts a home {@link IBuilding} to a map * - * @param home the home building + * @param home + * the home building * @return a map with information about the home building */ public static Object homeToObject(IBuilding home) { @@ -148,7 +178,9 @@ public static Object homeToObject(IBuilding home) { /** * Converts a skill {@link Skill} into a map * - * @param skills skills as list. Can be obtained via {@link ICitizenData#getCitizenSkillHandler} + * @param skills + * skills as list. Can be obtained via + * {@link ICitizenData#getCitizenSkillHandler} * @return a map with information about the skill */ public static Object skillsToObject(Map> skills) { @@ -164,14 +196,19 @@ public static Object skillsToObject(Map> skills) { } /** - * Returns information about the building like structure data, the citizens and some other values + * Returns information about the building like structure data, the citizens and + * some other values * - * @param buildingManager The building manager of the colony - * @param building The building as instance - * @param pos The location of the buildings block + * @param buildingManager + * The building manager of the colony + * @param building + * The building as instance + * @param pos + * The location of the buildings block * @return information about the building */ - public static Object buildingToObject(IRegisteredStructureManager buildingManager, IBuilding building, BlockPos pos) { + public static Object buildingToObject(IRegisteredStructureManager buildingManager, IBuilding building, + BlockPos pos) { Map structureData = new HashMap<>(); structureData.put("cornerA", LuaConverter.posToObject(building.getCorners().getA())); structureData.put("cornerB", LuaConverter.posToObject(building.getCorners().getB())); @@ -208,7 +245,8 @@ public static Object buildingToObject(IRegisteredStructureManager buildingManage /** * Returns the size of all inventories in this building * - * @param building the proper building with racks(Or other inventories) + * @param building + * the proper building with racks(Or other inventories) * @return the size of all inventories in this building */ public static int getStorageSize(IBuilding building) { @@ -250,18 +288,22 @@ public static Object workOrderToObject(IWorkOrder workOrder) { /** * Returns a list with all possible researches * - * @param branch The branch, there are only a few branches - * @param researches The primary researches of the branch - * @param colony The colony + * @param branch + * The branch, there are only a few branches + * @param researches + * The primary researches of the branch + * @param colony + * The colony * @return a list including maps with all possible researches */ - public static List getResearch(ResourceLocation branch, List researches, IColony colony) throws CommandSyntaxException { + public static List getResearch(ResourceLocation branch, List researches, IColony colony) + throws CommandSyntaxException { List result = new ArrayList<>(); if (researches != null) { for (ResourceLocation researchName : researches) { - //All global possible researches + // All global possible researches IGlobalResearchTree globalTree = IGlobalResearchTree.getInstance(); - //The research tree of the colony + // The research tree of the colony ILocalResearchTree colonyTree = colony.getResearchManager().getResearchTree(); IGlobalResearch research = globalTree.getResearch(branch, researchName); @@ -273,7 +315,8 @@ public static List getResearch(ResourceLocation branch, List effects = new ArrayList<>(); for (IResearchEffect researchEffect : research.getEffects()) - effects.add(TextComponentHelper.createComponentTranslation(null, researchEffect.getDesc().getKey(), researchEffect.getDesc().getArgs()).getString()); + effects.add(TextComponentHelper.createComponentTranslation(null, researchEffect.getDesc().getKey(), + researchEffect.getDesc().getArgs()).getString()); List> cost = new ArrayList<>(); for (IResearchCost item : research.getCostList()) { @@ -306,12 +349,21 @@ public static List getResearch(ResourceLocation branch, List map = new HashMap<>(); map.put("id", researchName.toString()); - map.put("name", TextComponentHelper.createComponentTranslation(null, research.getName().getKey(), research.getName().getArgs()).getString()); + map.put("name", TextComponentHelper + .createComponentTranslation(null, research.getName().getKey(), research.getName().getArgs()) + .getString()); map.put("requirements", requirements); map.put("cost", cost); map.put("researchEffects", effects); - map.put("status", colonyResearch == null ? ResearchState.NOT_STARTED.toString() : colonyResearch.getState().toString()); - map.put("neededTime", colonyResearch == null ? 0 : IGlobalResearchTree.getInstance().getBranchData(colonyResearch.getBranch()).getBaseTime(colonyResearch.getDepth())); + map.put("status", + colonyResearch == null + ? ResearchState.NOT_STARTED.toString() + : colonyResearch.getState().toString()); + map.put("neededTime", + colonyResearch == null + ? 0 + : IGlobalResearchTree.getInstance().getBranchData(colonyResearch.getBranch()) + .getBaseTime(colonyResearch.getDepth())); map.put("progress", colonyResearch == null ? 0 : colonyResearch.getProgress()); List childrenResearch = getResearch(branch, research.getChildren(), colony); @@ -327,8 +379,10 @@ public static List getResearch(ResourceLocation branch, List temp : network.getItemStorageCache().getList().getStacks()) { if (filter.test(temp.getStack().copy())) return temp.getStack().copy(); @@ -66,11 +88,13 @@ public static ItemStack findStackFromFilter(INetwork network, @Nullable ICraftin return ItemStack.EMPTY; } - public static FluidStack findFluidFromStack(INetwork network, @Nullable ICraftingManager crafting, FluidStack stack) { + public static FluidStack findFluidFromStack(INetwork network, @Nullable ICraftingManager crafting, + FluidStack stack) { return findFluidFromFilter(network, crafting, FluidFilter.fromStack(stack)); } - public static FluidStack findFluidFromFilter(INetwork network, @Nullable ICraftingManager crafting, FluidFilter filter) { + public static FluidStack findFluidFromFilter(INetwork network, @Nullable ICraftingManager crafting, + FluidFilter filter) { for (StackListEntry temp : network.getFluidStorageCache().getList().getStacks()) { if (filter.test(temp.getStack().copy())) return temp.getStack().copy(); @@ -81,7 +105,8 @@ public static FluidStack findFluidFromFilter(INetwork network, @Nullable ICrafti for (ICraftingPattern pattern : crafting.getPatterns()) { if (pattern.getFluidOutputs().stream().anyMatch(filter::test)) - return pattern.getFluidOutputs().stream().filter(filter::test).findFirst().orElse(FluidStack.EMPTY).copy(); + return pattern.getFluidOutputs().stream().filter(filter::test).findFirst().orElse(FluidStack.EMPTY) + .copy(); } return FluidStack.EMPTY; @@ -113,8 +138,10 @@ public static long getMaxItemDiskStorage(INetwork network) { for (IStorage store : network.getItemStorageCache().getStorages()) { if (store instanceof IStorageDisk storageDisk) { int cap = storageDisk.getCapacity(); - if (cap > 0) total += cap; - else creative = true; + if (cap > 0) + total += cap; + else + creative = true; } } return creative ? -1 : total; @@ -126,8 +153,10 @@ public static long getMaxFluidDiskStorage(INetwork network) { for (IStorage store : network.getFluidStorageCache().getStorages()) { if (store instanceof IStorageDisk storageDisk) { int cap = storageDisk.getCapacity(); - if (cap > 0) total += cap; - else creative = true; + if (cap > 0) + total += cap; + else + creative = true; } } return creative ? -1 : total; @@ -158,25 +187,24 @@ public static Object getObjectFromPattern(ICraftingPattern pattern, INetwork net return null; Map map = new HashMap<>(); - map.put("outputs", pattern.getOutputs().stream().map(stack -> getObjectFromStack(stack.copy(), network)).toList()); - map.put("fluidOutputs", pattern.getFluidOutputs().stream().map(stack -> getObjectFromFluid(stack.copy(), network)).toList()); - - List>> inputs = pattern.getInputs().stream() - .map(singleInputList -> singleInputList.stream() - .map(stack -> getObjectFromStack(stack.copy(), network)) - .collect(Collectors.toList())) + map.put("outputs", + pattern.getOutputs().stream().map(stack -> getObjectFromStack(stack.copy(), network)).toList()); + map.put("fluidOutputs", + pattern.getFluidOutputs().stream().map(stack -> getObjectFromFluid(stack.copy(), network)).toList()); + + List>> inputs = pattern + .getInputs().stream().map(singleInputList -> singleInputList.stream() + .map(stack -> getObjectFromStack(stack.copy(), network)).collect(Collectors.toList())) .collect(Collectors.toList()); - List>> fluidInputs = pattern.getInputs().stream() - .map(singleInputList -> singleInputList.stream() - .map(stack -> getObjectFromStack(stack.copy(), network)) - .collect(Collectors.toList())) + List>> fluidInputs = pattern + .getInputs().stream().map(singleInputList -> singleInputList.stream() + .map(stack -> getObjectFromStack(stack.copy(), network)).collect(Collectors.toList())) .collect(Collectors.toList()); List byproducts = new ArrayList<>(); if (!pattern.isProcessing()) { - byproducts = pattern.getByproducts().stream() - .map(stack -> getObjectFromStack(stack.copy(), network)) + byproducts = pattern.getByproducts().stream().map(stack -> getObjectFromStack(stack.copy(), network)) .collect(Collectors.toList()); } @@ -275,7 +303,8 @@ public static List getFluids(INetwork network) { } public void initiate() { - api.getNetworkNodeRegistry().add(new ResourceLocation(AdvancedPeripherals.MOD_ID, "rs_bridge"), (tag, world, pos) -> read(tag, new RefinedStorageNode(world, pos))); + api.getNetworkNodeRegistry().add(new ResourceLocation(AdvancedPeripherals.MOD_ID, "rs_bridge"), + (tag, world, pos) -> read(tag, new RefinedStorageNode(world, pos))); } public IRSAPI getApi() { diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/refinedstorage/RefinedStorageNode.java b/src/main/java/de/srendi/advancedperipherals/common/addons/refinedstorage/RefinedStorageNode.java index 6c19489de..ad6051f99 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/refinedstorage/RefinedStorageNode.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/refinedstorage/RefinedStorageNode.java @@ -1,6 +1,20 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.refinedstorage; - import com.refinedmods.refinedstorage.apiimpl.network.node.NetworkNode; import de.srendi.advancedperipherals.AdvancedPeripherals; import de.srendi.advancedperipherals.common.configuration.APConfig; @@ -26,8 +40,7 @@ public ResourceLocation getId() { return new ResourceLocation(AdvancedPeripherals.MOD_ID, "rs_bridge"); } - @NotNull - @Override + @NotNull @Override public ItemStack getItemStack() { return super.getItemStack(); } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/refinedstorage/RsFluidHandler.java b/src/main/java/de/srendi/advancedperipherals/common/addons/refinedstorage/RsFluidHandler.java index 06da6c0bf..84c7005d2 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/refinedstorage/RsFluidHandler.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/refinedstorage/RsFluidHandler.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.refinedstorage; import com.refinedmods.refinedstorage.api.network.INetwork; @@ -10,8 +25,7 @@ public class RsFluidHandler implements IStorageSystemFluidHandler { - @NotNull - private final INetwork network; + @NotNull private final INetwork network; public RsFluidHandler(@NotNull INetwork network) { this.network = network; @@ -21,15 +35,16 @@ public RsFluidHandler(@NotNull INetwork network) { public int fill(FluidStack resource, FluidAction action) { if (resource.isEmpty()) return 0; - return resource.getAmount() - network.insertFluid(resource, resource.getAmount(), action == FluidAction.SIMULATE ? Action.SIMULATE : Action.PERFORM).getAmount(); + return resource.getAmount() - network.insertFluid(resource, resource.getAmount(), + action == FluidAction.SIMULATE ? Action.SIMULATE : Action.PERFORM).getAmount(); } - @NotNull - @Override + @NotNull @Override public FluidStack drain(FluidFilter filter, FluidAction simulate) { FluidStack fluid = RefinedStorage.findFluidFromFilter(network, null, filter); if (fluid == null) return FluidStack.EMPTY; - return network.extractFluid(fluid, filter.getCount(), IComparer.COMPARE_QUANTITY, simulate == FluidAction.SIMULATE ? Action.SIMULATE : Action.PERFORM); + return network.extractFluid(fluid, filter.getCount(), IComparer.COMPARE_QUANTITY, + simulate == FluidAction.SIMULATE ? Action.SIMULATE : Action.PERFORM); } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/refinedstorage/RsItemHandler.java b/src/main/java/de/srendi/advancedperipherals/common/addons/refinedstorage/RsItemHandler.java index 900c8a5b0..639298b3f 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/refinedstorage/RsItemHandler.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/refinedstorage/RsItemHandler.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.addons.refinedstorage; import com.refinedmods.refinedstorage.api.network.INetwork; @@ -16,15 +31,13 @@ */ public class RsItemHandler implements IStorageSystemItemHandler { - @NotNull - private final INetwork network; + @NotNull private final INetwork network; public RsItemHandler(@NotNull INetwork network) { this.network = network; } - @NotNull - @Override + @NotNull @Override public ItemStack insertItem(int slot, @NotNull ItemStack stack, boolean simulate) { return network.insertItem(stack, stack.getCount(), simulate ? Action.SIMULATE : Action.PERFORM); } @@ -34,9 +47,10 @@ public ItemStack extractItem(ItemFilter filter, int count, boolean simulate) { ItemStack item = RefinedStorage.findStackFromFilter(network, network.getCraftingManager(), filter); if (item == null) AdvancedPeripherals.debug("Trying to extract item: " + item + " from filter: " + filter); - if(item == null) + if (item == null) return ItemStack.EMPTY; - ItemStack extracted = network.extractItem(item, count, IComparer.COMPARE_NBT, simulate ? Action.SIMULATE : Action.PERFORM); + ItemStack extracted = network.extractItem(item, count, IComparer.COMPARE_NBT, + simulate ? Action.SIMULATE : Action.PERFORM); AdvancedPeripherals.debug("Extracted item: " + extracted + " from filter: " + filter); return extracted; } diff --git a/src/main/java/de/srendi/advancedperipherals/common/blocks/PlayerDetectorBlock.java b/src/main/java/de/srendi/advancedperipherals/common/blocks/PlayerDetectorBlock.java index fec9f22c5..fb1231466 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/blocks/PlayerDetectorBlock.java +++ b/src/main/java/de/srendi/advancedperipherals/common/blocks/PlayerDetectorBlock.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.blocks; import dan200.computercraft.api.peripheral.IComputerAccess; @@ -22,14 +37,14 @@ public PlayerDetectorBlock() { super(APBlockEntityTypes.PLAYER_DETECTOR, true); } - @Nullable - @Override + @Nullable @Override public BlockEntity newBlockEntity(@NotNull BlockPos pos, @NotNull BlockState state) { return APBlockEntityTypes.PLAYER_DETECTOR.get().create(pos, state); } @Override - public @NotNull InteractionResult use(@NotNull BlockState state, Level levelIn, @NotNull BlockPos pos, @NotNull Player player, @NotNull InteractionHand handIn, @NotNull BlockHitResult hit) { + public @NotNull InteractionResult use(@NotNull BlockState state, Level levelIn, @NotNull BlockPos pos, + @NotNull Player player, @NotNull InteractionHand handIn, @NotNull BlockHitResult hit) { if (!APConfig.PERIPHERALS_CONFIG.enablePlayerDetector.get()) return super.use(state, levelIn, pos, player, handIn, hit); BlockEntity tileEntity = levelIn.getBlockEntity(pos); diff --git a/src/main/java/de/srendi/advancedperipherals/common/blocks/RedstoneIntegratorBlock.java b/src/main/java/de/srendi/advancedperipherals/common/blocks/RedstoneIntegratorBlock.java index 209d4e106..988b24de5 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/blocks/RedstoneIntegratorBlock.java +++ b/src/main/java/de/srendi/advancedperipherals/common/blocks/RedstoneIntegratorBlock.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.blocks; import de.srendi.advancedperipherals.common.blocks.base.BaseBlockEntityBlock; @@ -19,8 +34,7 @@ public RedstoneIntegratorBlock() { super(false, Properties.of(Material.METAL).isRedstoneConductor(APBlocks::never)); } - @Nullable - @Override + @Nullable @Override public BlockEntity newBlockEntity(@NotNull BlockPos pos, @NotNull BlockState state) { return APBlockEntityTypes.REDSTONE_INTEGRATOR.get().create(pos, state); } @@ -31,7 +45,8 @@ public boolean isSignalSource(@NotNull BlockState blockState) { } @Override - public int getDirectSignal(@NotNull BlockState blockState, BlockGetter blockGetter, @NotNull BlockPos pos, @NotNull Direction side) { + public int getDirectSignal(@NotNull BlockState blockState, BlockGetter blockGetter, @NotNull BlockPos pos, + @NotNull Direction side) { BlockEntity te = blockGetter.getBlockEntity(pos); if (te instanceof RedstoneIntegratorEntity redstoneIntegratorTile) return redstoneIntegratorTile.power[side.getOpposite().get3DDataValue()]; @@ -39,7 +54,8 @@ public int getDirectSignal(@NotNull BlockState blockState, BlockGetter blockGett } @Override - public int getSignal(@NotNull BlockState blockState, @NotNull BlockGetter blockGetter, @NotNull BlockPos pos, @NotNull Direction side) { + public int getSignal(@NotNull BlockState blockState, @NotNull BlockGetter blockGetter, @NotNull BlockPos pos, + @NotNull Direction side) { return getDirectSignal(blockState, blockGetter, pos, side); } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/blocks/base/APBlockEntityBlock.java b/src/main/java/de/srendi/advancedperipherals/common/blocks/base/APBlockEntityBlock.java index abbc0c374..5f9a9ccad 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/blocks/base/APBlockEntityBlock.java +++ b/src/main/java/de/srendi/advancedperipherals/common/blocks/base/APBlockEntityBlock.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.blocks.base; import de.srendi.advancedperipherals.common.blocks.blockentities.EnergyDetectorEntity; @@ -15,7 +30,8 @@ public class APBlockEntityBlock extends BaseBlockEntityBl private final RegistryObject> tileEntity; - public APBlockEntityBlock(RegistryObject> tileEntity, Properties properties, boolean belongToTickingEntity) { + public APBlockEntityBlock(RegistryObject> tileEntity, Properties properties, + boolean belongToTickingEntity) { super(belongToTickingEntity, properties); this.tileEntity = tileEntity; } @@ -24,8 +40,7 @@ public APBlockEntityBlock(RegistryObject> tileEntity, boolean this(tileEntity, Properties.of(Material.METAL), belongToTickingEntity); } - @Nullable - @Override + @Nullable @Override public BlockEntity newBlockEntity(@NotNull BlockPos pos, @NotNull BlockState state) { return tileEntity != null ? tileEntity.get().create(pos, state) : null; } @@ -36,7 +51,7 @@ public void onNeighborChange(BlockState state, LevelReader level, BlockPos pos, BlockEntity blockEntity = level.getBlockEntity(pos); - if(blockEntity instanceof EnergyDetectorEntity energyDetector) + if (blockEntity instanceof EnergyDetectorEntity energyDetector) energyDetector.invalidateStorages(); } diff --git a/src/main/java/de/srendi/advancedperipherals/common/blocks/base/BaseBlock.java b/src/main/java/de/srendi/advancedperipherals/common/blocks/base/BaseBlock.java index 3472e78ee..f41e98ba0 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/blocks/base/BaseBlock.java +++ b/src/main/java/de/srendi/advancedperipherals/common/blocks/base/BaseBlock.java @@ -1,10 +1,29 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.blocks.base; import net.minecraft.core.Direction; import net.minecraft.core.FrontAndTop; import net.minecraft.tags.TagKey; import net.minecraft.world.item.context.BlockPlaceContext; -import net.minecraft.world.level.block.*; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Mirror; +import net.minecraft.world.level.block.RenderShape; +import net.minecraft.world.level.block.Rotation; +import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.properties.BlockStateProperties; @@ -24,7 +43,8 @@ public BaseBlock() { } public BaseBlock(TagKey harvestTag) { - this(Properties.of(Material.METAL).strength(1, 5).sound(SoundType.METAL).noOcclusion().requiresCorrectToolForDrops(), harvestTag); + this(Properties.of(Material.METAL).strength(1, 5).sound(SoundType.METAL).noOcclusion() + .requiresCorrectToolForDrops(), harvestTag); } public BaseBlock(Properties properties, TagKey harvestTag) { @@ -33,8 +53,7 @@ public BaseBlock(Properties properties, TagKey harvestTag) { this.harvestTag = harvestTag; } - @NotNull - @Override + @NotNull @Override public RenderShape getRenderShape(@NotNull BlockState state) { return RenderShape.MODEL; } 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 aaf4a1e7e..cb6b04ff6 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 @@ -1,10 +1,29 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.blocks.base; import de.srendi.advancedperipherals.lib.peripherals.IPeripheralTileEntity; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerPlayer; import net.minecraft.tags.BlockTags; -import net.minecraft.world.*; +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.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; @@ -27,7 +46,8 @@ public abstract class BaseBlockEntityBlock extends BaseBlock implements EntityBl private final boolean belongToTickingEntity; public BaseBlockEntityBlock(boolean belongToTickingEntity) { - this(belongToTickingEntity, Properties.of(Material.METAL).strength(1, 5).sound(SoundType.METAL).noOcclusion().requiresCorrectToolForDrops()); + this(belongToTickingEntity, Properties.of(Material.METAL).strength(1, 5).sound(SoundType.METAL).noOcclusion() + .requiresCorrectToolForDrops()); } public BaseBlockEntityBlock(boolean belongToTickingEntity, Properties properties) { @@ -35,42 +55,49 @@ public BaseBlockEntityBlock(boolean belongToTickingEntity, Properties properties this.belongToTickingEntity = belongToTickingEntity; } - @NotNull - @Override - public InteractionResult use(@NotNull BlockState state, Level levelIn, @NotNull BlockPos pos, @NotNull Player player, @NotNull InteractionHand handIn, @NotNull BlockHitResult hit) { - if (levelIn.isClientSide) return InteractionResult.SUCCESS; + @NotNull @Override + public InteractionResult use(@NotNull BlockState state, Level levelIn, @NotNull BlockPos pos, + @NotNull Player player, @NotNull InteractionHand handIn, @NotNull BlockHitResult hit) { + if (levelIn.isClientSide) + return InteractionResult.SUCCESS; BlockEntity tileEntity = levelIn.getBlockEntity(pos); - if (tileEntity != null && !(tileEntity instanceof IInventoryBlock)) return InteractionResult.PASS; + if (tileEntity != null && !(tileEntity instanceof IInventoryBlock)) + return InteractionResult.PASS; MenuProvider namedContainerProvider = this.getMenuProvider(state, levelIn, pos); if (namedContainerProvider != null) { - if (!(player instanceof ServerPlayer serverPlayerEntity)) return InteractionResult.PASS; + if (!(player instanceof ServerPlayer serverPlayerEntity)) + return InteractionResult.PASS; NetworkHooks.openScreen(serverPlayerEntity, namedContainerProvider, pos); } return InteractionResult.SUCCESS; } @Override - public void onRemove(BlockState state, @NotNull Level worldIn, @NotNull BlockPos pos, BlockState newState, boolean isMoving) { + public void onRemove(BlockState state, @NotNull Level worldIn, @NotNull BlockPos pos, BlockState newState, + boolean isMoving) { if (state.getBlock() != newState.getBlock()) { BlockEntity tileEntity = worldIn.getBlockEntity(pos); - if (tileEntity instanceof Container container) Containers.dropContents(worldIn, pos, container); + if (tileEntity instanceof Container container) + Containers.dropContents(worldIn, pos, container); super.onRemove(state, worldIn, pos, newState, isMoving); } } @Override - public void setPlacedBy(@NotNull Level worldIn, @NotNull BlockPos pos, @NotNull BlockState state, @Nullable LivingEntity placer, ItemStack stack) { + 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; - //Used for the lua function getName() + // Used for the lua function getName() worldIn.getBlockEntity(pos).getPersistentData().putString("CustomName", stack.getDisplayName().getString()); } - @Nullable - @Override - public BlockEntityTicker getTicker(Level level, @NotNull BlockState state, @NotNull BlockEntityType type) { - if (level.isClientSide || !belongToTickingEntity) return null; + @Nullable @Override + public BlockEntityTicker getTicker(Level level, @NotNull BlockState state, + @NotNull BlockEntityType type) { + if (level.isClientSide || !belongToTickingEntity) + return null; return (level1, blockPos, blockState, entity) -> { if (entity instanceof IPeripheralTileEntity blockEntity) { blockEntity.handleTick(level, state, type); @@ -78,18 +105,16 @@ public BlockEntityTicker getTicker(Level level, @NotN }; } - @Deprecated - @Nullable - @Override + @Nullable @Override public MenuProvider getMenuProvider(@NotNull BlockState pState, Level pLevel, @NotNull BlockPos pPos) { BlockEntity blockentity = pLevel.getBlockEntity(pPos); - if (!(blockentity instanceof MenuProvider menuProvider)) return null; + if (!(blockentity instanceof MenuProvider menuProvider)) + return null; return menuProvider; } - @NotNull - public RenderShape getRenderShape(@NotNull BlockState state) { + @NotNull public RenderShape getRenderShape(@NotNull BlockState state) { return RenderShape.MODEL; } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/blocks/base/IHarvestableBlock.java b/src/main/java/de/srendi/advancedperipherals/common/blocks/base/IHarvestableBlock.java index 0fbdc49a1..d5090bdf9 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/blocks/base/IHarvestableBlock.java +++ b/src/main/java/de/srendi/advancedperipherals/common/blocks/base/IHarvestableBlock.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.blocks.base; import net.minecraft.tags.BlockTags; diff --git a/src/main/java/de/srendi/advancedperipherals/common/blocks/base/IInventoryBlock.java b/src/main/java/de/srendi/advancedperipherals/common/blocks/base/IInventoryBlock.java index 5bfa6325c..b7f512258 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/blocks/base/IInventoryBlock.java +++ b/src/main/java/de/srendi/advancedperipherals/common/blocks/base/IInventoryBlock.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.blocks.base; import de.srendi.advancedperipherals.common.container.base.BaseContainer; @@ -9,7 +24,8 @@ /** * Used to assign a container to a TileEntity * - * @param The container related to this inventory + * @param + * The container related to this inventory */ public interface IInventoryBlock { 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 6fe4d3354..b89f029d0 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 @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.blocks.base; import dan200.computercraft.api.peripheral.IComputerAccess; @@ -33,13 +48,16 @@ import java.util.Collections; -public abstract class PeripheralBlockEntity> extends BaseContainerBlockEntity implements WorldlyContainer, MenuProvider, IPeripheralTileEntity { +public abstract class PeripheralBlockEntity> extends BaseContainerBlockEntity + implements + WorldlyContainer, + MenuProvider, + IPeripheralTileEntity { private static final String PERIPHERAL_SETTINGS_KEY = "peripheralSettings"; protected CompoundTag peripheralSettings; protected NonNullList items; - @Nullable - protected T peripheral = null; + @Nullable protected T peripheral = null; private LazyOptional handler; private LazyOptional fluidHandler; private LazyOptional peripheralCap; @@ -54,8 +72,7 @@ protected PeripheralBlockEntity(BlockEntityType tileEntityTypeIn, BlockPos po peripheralSettings = new CompoundTag(); } - @NotNull - @Override + @NotNull @Override public LazyOptional getCapability(@NotNull Capability cap, @Nullable Direction direction) { if (cap == Capabilities.CAPABILITY_PERIPHERAL) { if (peripheral == null) @@ -75,7 +92,8 @@ public LazyOptional getCapability(@NotNull Capability cap, @Nullabl } return peripheralCap.cast(); } else { - AdvancedPeripherals.debug(peripheral.getType() + " is disabled, you can enable it in the Configuration."); + AdvancedPeripherals + .debug(peripheral.getType() + " is disabled, you can enable it in the Configuration."); } } @@ -104,8 +122,7 @@ public void invalidateCaps() { fluidHandler.invalidate(); } - @NotNull - protected abstract T createPeripheral(); + @NotNull protected abstract T createPeripheral(); public Iterable getConnectedComputers() { if (peripheral == null) // just avoid some NPE in strange cases @@ -113,21 +130,21 @@ public Iterable getConnectedComputers() { return peripheral.getConnectedComputers(); } - @Nullable - public T getPeripheral() { + @Nullable public T getPeripheral() { return peripheral; } - /*@Override - public ITextComponent getDisplayName() { - return this instanceof IInventoryBlock ? ((IInventoryBlock) this).getDisplayName() : null; - }*/ + /* + * @Override public ITextComponent getDisplayName() { return this instanceof + * IInventoryBlock ? ((IInventoryBlock) this).getDisplayName() : null; } + */ @Override public void saveAdditional(@NotNull CompoundTag compound) { super.saveAdditional(compound); ContainerHelper.saveAllItems(compound, items); - if (!peripheralSettings.isEmpty()) compound.put(PERIPHERAL_SETTINGS_KEY, peripheralSettings); + if (!peripheralSettings.isEmpty()) + compound.put(PERIPHERAL_SETTINGS_KEY, peripheralSettings); } @Override @@ -142,15 +159,16 @@ protected Component getDefaultName() { return this instanceof IInventoryBlock inventoryBlock ? inventoryBlock.getDisplayName() : null; } - @Nullable - @Override + @Nullable @Override public AbstractContainerMenu createMenu(int id, @NotNull Inventory inventory, @NotNull Player playerEntity) { return createMenu(id, inventory); } @Override protected AbstractContainerMenu createMenu(int id, @NotNull Inventory player) { - return this instanceof IInventoryBlock inventoryBlock ? inventoryBlock.createContainer(id, player, worldPosition, level) : null; + return this instanceof IInventoryBlock inventoryBlock + ? inventoryBlock.createContainer(id, player, worldPosition, level) + : null; } @Override @@ -176,14 +194,13 @@ public int getContainerSize() { @Override public boolean isEmpty() { for (ItemStack itemStack : items) { - if (itemStack.isEmpty()) return true; + if (itemStack.isEmpty()) + return true; } return false; } - - @NotNull - @Override + @NotNull @Override public ItemStack getItem(int index) { if (index < 0 || index >= items.size()) { return ItemStack.EMPTY; @@ -191,14 +208,12 @@ public ItemStack getItem(int index) { return items.get(index); } - @NotNull - @Override + @NotNull @Override public ItemStack removeItem(int index, int count) { return ContainerHelper.removeItem(items, index, count); } - @NotNull - @Override + @NotNull @Override public ItemStack removeItemNoUpdate(int index) { return ContainerHelper.takeItem(items, index); } @@ -230,4 +245,3 @@ public void markSettingsChanged() { setChanged(); } } - diff --git a/src/main/java/de/srendi/advancedperipherals/common/blocks/base/PoweredPeripheralBlockEntity.java b/src/main/java/de/srendi/advancedperipherals/common/blocks/base/PoweredPeripheralBlockEntity.java index 21a25c070..0e541108d 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/blocks/base/PoweredPeripheralBlockEntity.java +++ b/src/main/java/de/srendi/advancedperipherals/common/blocks/base/PoweredPeripheralBlockEntity.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.blocks.base; import de.srendi.advancedperipherals.common.configuration.APConfig; @@ -39,7 +54,8 @@ public void saveAdditional(@NotNull CompoundTag compound) { @Override public void load(@NotNull CompoundTag compound) { super.load(compound); - lazyEnergyStorage.ifPresent(iEnergyStorage -> iEnergyStorage.receiveEnergy(compound.getInt("energy") - iEnergyStorage.getEnergyStored(), false)); + lazyEnergyStorage.ifPresent(iEnergyStorage -> iEnergyStorage + .receiveEnergy(compound.getInt("energy") - iEnergyStorage.getEnergyStored(), false)); } @Override diff --git a/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/BlockReaderEntity.java b/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/BlockReaderEntity.java index 33e7b128f..2f1afda65 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/BlockReaderEntity.java +++ b/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/BlockReaderEntity.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.blocks.blockentities; import de.srendi.advancedperipherals.common.addons.computercraft.peripheral.BlockReaderPeripheral; @@ -13,8 +28,7 @@ public BlockReaderEntity(BlockPos pos, BlockState state) { super(APBlockEntityTypes.BLOCK_READER.get(), pos, state); } - @NotNull - @Override + @NotNull @Override protected BlockReaderPeripheral createPeripheral() { return new BlockReaderPeripheral(this); } diff --git a/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/ChatBoxEntity.java b/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/ChatBoxEntity.java index 594645f0c..ddc0c2e49 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/ChatBoxEntity.java +++ b/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/ChatBoxEntity.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.blocks.blockentities; import de.srendi.advancedperipherals.common.addons.computercraft.peripheral.ChatBoxPeripheral; @@ -16,8 +31,7 @@ public ChatBoxEntity(BlockPos pos, BlockState state) { super(APBlockEntityTypes.CHAT_BOX.get(), pos, state); } - @NotNull - @Override + @NotNull @Override protected ChatBoxPeripheral createPeripheral() { return new ChatBoxPeripheral(this); } diff --git a/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/ColonyIntegratorEntity.java b/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/ColonyIntegratorEntity.java index 27e9d5e1f..cbeb97a8f 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/ColonyIntegratorEntity.java +++ b/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/ColonyIntegratorEntity.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.blocks.blockentities; import de.srendi.advancedperipherals.common.addons.computercraft.peripheral.ColonyPeripheral; @@ -13,8 +28,7 @@ public ColonyIntegratorEntity(BlockPos pos, BlockState state) { super(APBlockEntityTypes.COLONY_INTEGRATOR.get(), pos, state); } - @NotNull - @Override + @NotNull @Override protected ColonyPeripheral createPeripheral() { return new ColonyPeripheral(this); } diff --git a/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/DistanceDetectorEntity.java b/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/DistanceDetectorEntity.java index 94c8b11d9..3eeaa6783 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/DistanceDetectorEntity.java +++ b/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/DistanceDetectorEntity.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.blocks.blockentities; import de.srendi.advancedperipherals.common.addons.computercraft.peripheral.DistanceDetectorPeripheral; @@ -16,7 +31,11 @@ import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.SlabType; -import net.minecraft.world.phys.*; +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 org.jetbrains.annotations.NotNull; public class DistanceDetectorEntity extends PeripheralBlockEntity { @@ -32,21 +51,22 @@ public DistanceDetectorEntity(BlockPos pos, BlockState state) { super(APBlockEntityTypes.DISTANCE_DETECTOR.get(), pos, state); } - @NotNull - @Override + @NotNull @Override protected DistanceDetectorPeripheral createPeripheral() { return new DistanceDetectorPeripheral(this); } public void setShowLaser(boolean showLaser) { if (this.showLaser != showLaser) - PacketHandler.sendToAll(new DistanceDetectorSyncPacket(getBlockPos(), getLevel().dimension(), currentDistance, showLaser)); + PacketHandler.sendToAll( + new DistanceDetectorSyncPacket(getBlockPos(), getLevel().dimension(), currentDistance, showLaser)); this.showLaser = showLaser; } public void setCurrentDistance(float currentDistance) { if (this.currentDistance != currentDistance) - PacketHandler.sendToAll(new DistanceDetectorSyncPacket(getBlockPos(), getLevel().dimension(), currentDistance, showLaser)); + PacketHandler.sendToAll( + new DistanceDetectorSyncPacket(getBlockPos(), getLevel().dimension(), currentDistance, showLaser)); this.currentDistance = currentDistance; } @@ -92,11 +112,15 @@ public void setDetectionType(DistanceDetectorPeripheral.DetectionType detectionT @Override public void handleTick(Level level, BlockState state, BlockEntityType type) { - if (level.getGameTime() % APConfig.PERIPHERALS_CONFIG.distanceDetectorUpdateRate.get() == 0 && shouldCalculatePeriodically) { - // We calculate the distance every 2 ticks, so we do not have to run the getDistance function of the peripheral + if (level.getGameTime() % APConfig.PERIPHERALS_CONFIG.distanceDetectorUpdateRate.get() == 0 + && shouldCalculatePeriodically) { + // We calculate the distance every 2 ticks, so we do not have to run the + // getDistance function of the peripheral // on the main thread which prevents the 1 tick yield time of the function. - // The calculateDistance function is not thread safe, so we have to run it on the main thread. - // It should be okay to run that function every 2 ticks, calculating it does not take too much time. + // The calculateDistance function is not thread safe, so we have to run it on + // the main thread. + // It should be okay to run that function every 2 ticks, calculating it does not + // take too much time. calculateDistance(); } } @@ -104,15 +128,20 @@ public void handleTick(Level level, BlockState state, Bl @Override public AABB getRenderBoundingBox() { Direction direction = getBlockState().getValue(BaseBlock.ORIENTATION).front(); - return AABB.ofSize(Vec3.atCenterOf(getBlockPos()), direction.getStepX() * currentDistance + 1, direction.getStepY() * currentDistance + 1, direction.getStepZ() * currentDistance + 1) - .move(direction.getStepX() * currentDistance / 2, direction.getStepY() * currentDistance / 2, direction.getStepZ() * currentDistance / 2); + return AABB + .ofSize(Vec3.atCenterOf(getBlockPos()), direction.getStepX() * currentDistance + 1, + direction.getStepY() * currentDistance + 1, direction.getStepZ() * currentDistance + 1) + .move(direction.getStepX() * currentDistance / 2, direction.getStepY() * currentDistance / 2, + direction.getStepZ() * currentDistance / 2); } public double calculateDistance() { Direction direction = getBlockState().getValue(BaseBlock.ORIENTATION).front(); Vec3 center = Vec3.atCenterOf(getBlockPos()); - Vec3 from = center.add(direction.getStepX() * 0.501, direction.getStepY() * 0.501, direction.getStepZ() * 0.501); - Vec3 to = from.add(direction.getStepX() * maxRange, direction.getStepY() * maxRange, direction.getStepZ() * maxRange); + Vec3 from = center.add(direction.getStepX() * 0.501, direction.getStepY() * 0.501, + direction.getStepZ() * 0.501); + Vec3 to = from.add(direction.getStepX() * maxRange, direction.getStepY() * maxRange, + direction.getStepZ() * maxRange); HitResult result = getResult(to, from); float distance = calculateDistance(result, center, direction); diff --git a/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/EnergyDetectorEntity.java b/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/EnergyDetectorEntity.java index a15e914d2..5307dfb89 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/EnergyDetectorEntity.java +++ b/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/EnergyDetectorEntity.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.blocks.blockentities; import de.srendi.advancedperipherals.common.addons.computercraft.peripheral.EnergyDetectorPeripheral; @@ -26,14 +41,15 @@ public class EnergyDetectorEntity extends PeripheralBlockEntity { public int transferRate = 0; - //storageProxy that will forward the energy to the output but limit it to maxTransferRate - public final EnergyStorageProxy storageProxy = new EnergyStorageProxy(this, APConfig.PERIPHERALS_CONFIG.energyDetectorMaxFlow.get()); - //a zero size, zero transfer energy storage to ensure that cables connect + // storageProxy that will forward the energy to the output but limit it to + // maxTransferRate + public final EnergyStorageProxy storageProxy = new EnergyStorageProxy(this, + APConfig.PERIPHERALS_CONFIG.energyDetectorMaxFlow.get()); + // a zero size, zero transfer energy storage to ensure that cables connect private final EnergyStorage zeroStorage = new EnergyStorage(0, 0, 0); private final LazyOptional energyStorageCap = LazyOptional.of(() -> storageProxy); private final LazyOptional zeroStorageCap = LazyOptional.of(() -> zeroStorage); - @NotNull - private Optional outReceivingStorage = Optional.empty(); + @NotNull private Optional outReceivingStorage = Optional.empty(); private Direction energyInDirection = Direction.NORTH; private Direction energyOutDirection = Direction.SOUTH; @@ -42,14 +58,12 @@ public EnergyDetectorEntity(BlockPos pos, BlockState state) { super(APBlockEntityTypes.ENERGY_DETECTOR.get(), pos, state); } - @NotNull - @Override + @NotNull @Override protected EnergyDetectorPeripheral createPeripheral() { return new EnergyDetectorPeripheral(this); } - @NotNull - @Override + @NotNull @Override public LazyOptional getCapability(@NotNull Capability cap, @Nullable Direction direction) { energyInDirection = getBlockState().getValue(BaseBlock.ORIENTATION).front(); energyOutDirection = getBlockState().getValue(BaseBlock.ORIENTATION).front().getOpposite(); @@ -72,7 +86,8 @@ public void saveAdditional(@NotNull CompoundTag compound) { @Override public void handleTick(Level level, BlockState state, BlockEntityType type) { if (!level.isClientSide) { - // this handles the rare edge case that receiveEnergy is called multiple times in one tick + // this handles the rare edge case that receiveEnergy is called multiple times + // in one tick transferRate = storageProxy.getTransferedInThisTick(); storageProxy.resetTransferedInThisTick(); } @@ -88,16 +103,18 @@ public void invalidateStorages() { outReceivingStorage = Optional.empty(); } - // returns the cached output storage of the receiving block or fetches it if it has been invalidated - @NotNull - public Optional getOutputStorage() { - // the documentation says that the value of the LazyOptional should be cached locally and invalidated using addListener + // returns the cached output storage of the receiving block or fetches it if it + // has been invalidated + @NotNull public Optional getOutputStorage() { + // the documentation says that the value of the LazyOptional should be cached + // locally and invalidated using addListener if (outReceivingStorage.isEmpty()) { BlockEntity teOut = level.getBlockEntity(worldPosition.relative(energyOutDirection)); if (teOut == null) { return Optional.empty(); } - LazyOptional lazyOptionalOutStorage = teOut.getCapability(ForgeCapabilities.ENERGY, energyOutDirection.getOpposite()); + LazyOptional lazyOptionalOutStorage = teOut.getCapability(ForgeCapabilities.ENERGY, + energyOutDirection.getOpposite()); outReceivingStorage = lazyOptionalOutStorage.resolve(); lazyOptionalOutStorage.addListener(l -> { outReceivingStorage = Optional.empty(); diff --git a/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/EnvironmentDetectorEntity.java b/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/EnvironmentDetectorEntity.java index 681ed938e..31636c847 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/EnvironmentDetectorEntity.java +++ b/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/EnvironmentDetectorEntity.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.blocks.blockentities; import de.srendi.advancedperipherals.common.addons.computercraft.peripheral.EnvironmentDetectorPeripheral; @@ -19,8 +34,7 @@ protected int getMaxEnergyStored() { return APConfig.PERIPHERALS_CONFIG.poweredPeripheralMaxEnergyStorage.get(); } - @NotNull - @Override + @NotNull @Override protected EnvironmentDetectorPeripheral createPeripheral() { return new EnvironmentDetectorPeripheral(this); } diff --git a/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/FluidDetectorEntity.java b/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/FluidDetectorEntity.java index 3a808db82..8f63b0b09 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/FluidDetectorEntity.java +++ b/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/FluidDetectorEntity.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.blocks.blockentities; import de.srendi.advancedperipherals.common.addons.computercraft.peripheral.FluidDetectorPeripheral; @@ -29,9 +44,11 @@ public class FluidDetectorEntity extends PeripheralBlockEntity fluidStorageCap = LazyOptional.of(() -> storageProxy); private final LazyOptional zeroStorageCap = LazyOptional.of(() -> zeroStorage); @@ -44,14 +61,12 @@ public FluidDetectorEntity(BlockPos pos, BlockState state) { super(APBlockEntityTypes.FLUID_DETECTOR.get(), pos, state); } - @NotNull - @Override + @NotNull @Override protected FluidDetectorPeripheral createPeripheral() { return new FluidDetectorPeripheral(this); } - @NotNull - @Override + @NotNull @Override public LazyOptional getCapability(@NotNull Capability cap, @Nullable Direction direction) { fluidInDetection = getBlockState().getValue(BaseBlock.ORIENTATION).front(); fluidOutDirection = getBlockState().getValue(BaseBlock.ORIENTATION).front().getOpposite(); @@ -74,7 +89,8 @@ public void saveAdditional(@NotNull CompoundTag compound) { @Override public void handleTick(Level level, BlockState state, BlockEntityType type) { if (!level.isClientSide) { - // this handles the rare edge case that receiveFluid is called multiple times in one tick + // this handles the rare edge case that receiveFluid is called multiple times in + // one tick transferRate = storageProxy.getTransferedInThisTick(); storageProxy.resetTransferedInThisTick(); } @@ -86,16 +102,18 @@ public void load(CompoundTag nbt) { super.load(nbt); } - // returns the cached output storage of the receiving block or fetches it if it has been invalidated - @NotNull - public Optional getOutputStorage() { - // the documentation says that the value of the LazyOptional should be cached locally and invalidated using addListener + // returns the cached output storage of the receiving block or fetches it if it + // has been invalidated + @NotNull public Optional getOutputStorage() { + // the documentation says that the value of the LazyOptional should be cached + // locally and invalidated using addListener if (outReceivingStorage.isEmpty()) { BlockEntity teOut = level.getBlockEntity(worldPosition.relative(fluidOutDirection)); if (teOut == null) { return Optional.empty(); } - LazyOptional lazyOptionalOutStorage = teOut.getCapability(ForgeCapabilities.FLUID_HANDLER, fluidOutDirection.getOpposite()); + LazyOptional lazyOptionalOutStorage = teOut.getCapability(ForgeCapabilities.FLUID_HANDLER, + fluidOutDirection.getOpposite()); outReceivingStorage = lazyOptionalOutStorage.resolve(); lazyOptionalOutStorage.addListener(l -> { outReceivingStorage = Optional.empty(); diff --git a/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/GasDetectorEntity.java b/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/GasDetectorEntity.java index 23f7dda1c..5d9d35844 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/GasDetectorEntity.java +++ b/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/GasDetectorEntity.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.blocks.blockentities; import de.srendi.advancedperipherals.common.addons.computercraft.peripheral.GasDetectorPeripheral; @@ -29,9 +44,11 @@ public class GasDetectorEntity extends PeripheralBlockEntity gasStorageCap = LazyOptional.of(() -> storageProxy); private final LazyOptional zeroStorageCap = LazyOptional.of(() -> zeroStorage); @@ -44,14 +61,12 @@ public GasDetectorEntity(BlockPos pos, BlockState state) { super(APBlockEntityTypes.GAS_DETECTOR.get(), pos, state); } - @NotNull - @Override + @NotNull @Override protected GasDetectorPeripheral createPeripheral() { return new GasDetectorPeripheral(this); } - @NotNull - @Override + @NotNull @Override public LazyOptional getCapability(@NotNull Capability cap, @Nullable Direction direction) { gasInDirection = getBlockState().getValue(BaseBlock.ORIENTATION).front(); gasOutDirection = getBlockState().getValue(BaseBlock.ORIENTATION).front().getOpposite(); @@ -74,7 +89,8 @@ public void saveAdditional(@NotNull CompoundTag compound) { @Override public void handleTick(Level level, BlockState state, BlockEntityType type) { if (!level.isClientSide) { - // this handles the rare edge case that receiveGas is called multiple times in one tick + // this handles the rare edge case that receiveGas is called multiple times in + // one tick transferRate = storageProxy.getTransferedInThisTick(); storageProxy.resetTransferedInThisTick(); } @@ -86,16 +102,18 @@ public void load(CompoundTag nbt) { super.load(nbt); } - // returns the cached output storage of the receiving block or fetches it if it has been invalidated - @NotNull - public Optional getOutputStorage() { - // the documentation says that the value of the LazyOptional should be cached locally and invalidated using addListener + // returns the cached output storage of the receiving block or fetches it if it + // has been invalidated + @NotNull public Optional getOutputStorage() { + // the documentation says that the value of the LazyOptional should be cached + // locally and invalidated using addListener if (outReceivingStorage.isEmpty()) { BlockEntity teOut = level.getBlockEntity(worldPosition.relative(gasOutDirection)); if (teOut == null) { return Optional.empty(); } - LazyOptional lazyOptionalOutStorage = teOut.getCapability(MekanismCapabilities.GAS_HANDLER, gasOutDirection.getOpposite()); + LazyOptional lazyOptionalOutStorage = teOut.getCapability(MekanismCapabilities.GAS_HANDLER, + gasOutDirection.getOpposite()); outReceivingStorage = lazyOptionalOutStorage.resolve(); lazyOptionalOutStorage.addListener(l -> { outReceivingStorage = Optional.empty(); diff --git a/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/GeoScannerEntity.java b/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/GeoScannerEntity.java index 56eab8959..8bda0e489 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/GeoScannerEntity.java +++ b/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/GeoScannerEntity.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.blocks.blockentities; import de.srendi.advancedperipherals.common.addons.computercraft.peripheral.GeoScannerPeripheral; diff --git a/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/InventoryManagerEntity.java b/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/InventoryManagerEntity.java index d92104fe1..67b748f32 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/InventoryManagerEntity.java +++ b/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/InventoryManagerEntity.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.blocks.blockentities; import de.srendi.advancedperipherals.common.addons.computercraft.peripheral.InventoryManagerPeripheral; @@ -18,14 +33,15 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -public class InventoryManagerEntity extends PeripheralBlockEntity implements IInventoryBlock { +public class InventoryManagerEntity extends PeripheralBlockEntity + implements + IInventoryBlock { public InventoryManagerEntity(BlockPos pos, BlockState state) { super(APBlockEntityTypes.INVENTORY_MANAGER.get(), pos, state); } - @NotNull - @Override + @NotNull @Override protected InventoryManagerPeripheral createPeripheral() { return new InventoryManagerPeripheral(this); } @@ -45,21 +61,23 @@ public boolean canPlaceItemThroughFace(int index, @NotNull ItemStack itemStackIn return itemStackIn.getItem() instanceof MemoryCardItem; } - @NotNull - @Override + @NotNull @Override public Component getDisplayName() { return Component.translatable("block.advancedperipherals.inventory_manager"); } public Player getOwnerPlayer() { - //Checks if the tile entity has an item in his inventory - if (items.get(0).isEmpty()) return null; + // Checks if the tile entity has an item in his inventory + if (items.get(0).isEmpty()) + return null; ItemStack stack = items.get(0); - //Checks if the item contains the owner name - if (!stack.getOrCreateTag().contains("owner")) return null; - //Loop through all players and check if the player is online + // Checks if the item contains the owner name + if (!stack.getOrCreateTag().contains("owner")) + return null; + // Loop through all players and check if the player is online for (Player entity : ServerLifecycleHooks.getCurrentServer().getPlayerList().getPlayers()) { - if (entity.getName().getString().equals(stack.getOrCreateTag().getString("owner"))) return entity; + if (entity.getName().getString().equals(stack.getOrCreateTag().getString("owner"))) + return entity; } return null; } diff --git a/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/MeBridgeEntity.java b/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/MeBridgeEntity.java index c85092a9a..182f6981b 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/MeBridgeEntity.java +++ b/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/MeBridgeEntity.java @@ -1,6 +1,25 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.blocks.blockentities; -import appeng.api.networking.*; +import appeng.api.networking.GridFlags; +import appeng.api.networking.GridHelper; +import appeng.api.networking.IGridNode; +import appeng.api.networking.IInWorldGridNodeHost; +import appeng.api.networking.IManagedGridNode; import appeng.api.networking.crafting.ICraftingSimulationRequester; import appeng.api.networking.security.IActionHost; import appeng.api.networking.security.IActionSource; @@ -27,7 +46,12 @@ import java.util.Optional; import java.util.concurrent.CopyOnWriteArrayList; -public class MeBridgeEntity extends PeripheralBlockEntity implements IActionSource, IActionHost, IInWorldGridNodeHost, ICraftingSimulationRequester { +public class MeBridgeEntity extends PeripheralBlockEntity + implements + IActionSource, + IActionHost, + IInWorldGridNodeHost, + ICraftingSimulationRequester { private final List jobs = new CopyOnWriteArrayList<>(); private boolean initialized = false; @@ -37,8 +61,7 @@ public MeBridgeEntity(BlockPos pos, BlockState state) { super(APBlockEntityTypes.ME_BRIDGE.get(), pos, state); } - @NotNull - @Override + @NotNull @Override protected MeBridgePeripheral createPeripheral() { return new MeBridgePeripheral(this); } @@ -54,7 +77,7 @@ public void handleTick(Level level, BlockState state, Bl mainNode.setInWorldNode(true); mainNode.create(level, getBlockPos()); - //peripheral can be null if `getCapability` was not called before + // peripheral can be null if `getCapability` was not called before if (peripheral == null) peripheral = createPeripheral(); peripheral.setNode(mainNode); @@ -69,26 +92,22 @@ public void handleTick(Level level, BlockState state, Bl } } - @NotNull - @Override + @NotNull @Override public Optional player() { return Optional.empty(); } - @NotNull - @Override + @NotNull @Override public Optional machine() { return Optional.of(this); } - @NotNull - @Override + @NotNull @Override public Optional context(@NotNull Class key) { return Optional.empty(); } - @Nullable - @Override + @Nullable @Override public IGridNode getActionableNode() { return mainNode.getNode(); } @@ -105,14 +124,12 @@ public void onChunkUnloaded() { mainNode.destroy(); } - @Nullable - @Override + @Nullable @Override public IGridNode getGridNode(@NotNull Direction dir) { return getActionableNode(); } - @NotNull - @Override + @NotNull @Override public AECableType getCableConnectionType(@NotNull Direction dir) { return AECableType.SMART; } @@ -120,8 +137,7 @@ public AECableType getCableConnectionType(@NotNull Direction dir) { /** * Return the current action source, used to extract items. */ - @Nullable - @Override + @Nullable @Override public IActionSource getActionSource() { return this; } diff --git a/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/NBTStorageEntity.java b/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/NBTStorageEntity.java index 0b56fedc1..6447e085a 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/NBTStorageEntity.java +++ b/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/NBTStorageEntity.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.blocks.blockentities; import de.srendi.advancedperipherals.common.addons.computercraft.peripheral.NBTStoragePeripheral; @@ -17,8 +32,7 @@ public NBTStorageEntity(BlockPos pos, BlockState state) { stored = new CompoundTag(); } - @NotNull - @Override + @NotNull @Override protected NBTStoragePeripheral createPeripheral() { return new NBTStoragePeripheral(this); } diff --git a/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/PlayerDetectorEntity.java b/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/PlayerDetectorEntity.java index 08a0ac6ef..57caf33c1 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/PlayerDetectorEntity.java +++ b/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/PlayerDetectorEntity.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.blocks.blockentities; import de.srendi.advancedperipherals.common.addons.computercraft.peripheral.PlayerDetectorPeripheral; @@ -19,18 +34,20 @@ public PlayerDetectorEntity(BlockPos pos, BlockState state) { lastConsumedMessage = Events.getLastPlayerMessageID() - 1; } - @NotNull - @Override + @NotNull @Override protected PlayerDetectorPeripheral createPeripheral() { return new PlayerDetectorPeripheral(this); } @Override public void handleTick(Level level, BlockState state, BlockEntityType type) { - lastConsumedMessage = Events.traversePlayerMessages(lastConsumedMessage, message -> getConnectedComputers().forEach(computer -> { - if(message.eventName().equals("playerChangedDimension")) { - computer.queueEvent(message.eventName(), message.playerName(), message.fromDimension(), message.toDimension()); - } else computer.queueEvent(message.eventName(), message.playerName(), message.fromDimension()); - })); + lastConsumedMessage = Events.traversePlayerMessages(lastConsumedMessage, + message -> getConnectedComputers().forEach(computer -> { + if (message.eventName().equals("playerChangedDimension")) { + computer.queueEvent(message.eventName(), message.playerName(), message.fromDimension(), + message.toDimension()); + } else + computer.queueEvent(message.eventName(), message.playerName(), message.fromDimension()); + })); } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/RedstoneIntegratorEntity.java b/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/RedstoneIntegratorEntity.java index ecf6ffff3..452751d78 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/RedstoneIntegratorEntity.java +++ b/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/RedstoneIntegratorEntity.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.blocks.blockentities; import dan200.computercraft.shared.util.RedstoneUtil; @@ -23,8 +38,7 @@ public RedstoneIntegratorEntity(BlockPos pos, BlockState state) { super(APBlockEntityTypes.REDSTONE_INTEGRATOR.get(), pos, state); } - @NotNull - @Override + @NotNull @Override protected RedstoneIntegratorPeripheral createPeripheral() { return new RedstoneIntegratorPeripheral(this); } @@ -33,10 +47,13 @@ public int getRedstoneInput(Direction direction) { Objects.requireNonNull(level); BlockPos neighbourPos = getBlockPos().relative(direction); int power = level.getSignal(neighbourPos, direction); - if (power >= 15) return power; + if (power >= 15) + return power; BlockState neighbourState = level.getBlockState(neighbourPos); - return neighbourState.getBlock() == Blocks.REDSTONE_WIRE ? Math.max(power, neighbourState.getValue(RedStoneWireBlock.POWER)) : power; + return neighbourState.getBlock() == Blocks.REDSTONE_WIRE + ? Math.max(power, neighbourState.getValue(RedStoneWireBlock.POWER)) + : power; } private void setRedstoneOutput(Direction direction, int power) { @@ -51,11 +68,14 @@ private void setRedstoneOutput(Direction direction, int power) { } /** - * Used to run redstone integrator functions not on the main thread to prevent long execution times - * See #384 + * Used to run redstone integrator functions not on the main thread to prevent + * long execution times See + * #384 * - * @param direction Cardinal direction - * @param power The redstone power from 0 to 15 + * @param direction + * Cardinal direction + * @param power + * The redstone power from 0 to 15 */ public void setOutput(Direction direction, int power) { ServerWorker.add(() -> setRedstoneOutput(direction, power)); diff --git a/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/RsBridgeEntity.java b/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/RsBridgeEntity.java index aee5e4a58..5930b814b 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/RsBridgeEntity.java +++ b/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/RsBridgeEntity.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.blocks.blockentities; import com.refinedmods.refinedstorage.api.network.node.INetworkNodeProxy; @@ -22,10 +37,14 @@ import static dan200.computercraft.shared.Capabilities.CAPABILITY_PERIPHERAL; -public class RsBridgeEntity extends NetworkNodeBlockEntity implements INetworkNodeProxy, IRedstoneConfigurable, IPeripheralTileEntity { +public class RsBridgeEntity extends NetworkNodeBlockEntity + implements + INetworkNodeProxy, + IRedstoneConfigurable, + IPeripheralTileEntity { private static final String PERIPHERAL_SETTINGS = "AP_SETTINGS"; - //I have no clue what this does, but it works + // I have no clue what this does, but it works private static final BlockEntitySynchronizationSpec SPEC = BlockEntitySynchronizationSpec.builder().build(); protected CompoundTag peripheralSettings; protected RsBridgePeripheral peripheral = new RsBridgePeripheral(this); @@ -36,8 +55,7 @@ public RsBridgeEntity(BlockPos pos, BlockState state) { peripheralSettings = new CompoundTag(); } - @NotNull - public LazyOptional getCapability(@NotNull Capability cap, @Nullable Direction direction) { + @NotNull public LazyOptional getCapability(@NotNull Capability cap, @Nullable Direction direction) { if (cap == CAPABILITY_PERIPHERAL) { if (peripheral.isEnabled()) { if (peripheralCap == null) { @@ -45,7 +63,8 @@ public LazyOptional getCapability(@NotNull Capability cap, @Nullabl } return peripheralCap.cast(); } else { - AdvancedPeripherals.debug(peripheral.getType() + " is disabled, you can enable it in the Configuration."); + AdvancedPeripherals + .debug(peripheral.getType() + " is disabled, you can enable it in the Configuration."); } } return super.getCapability(cap, direction); @@ -58,7 +77,8 @@ public RefinedStorageNode createNode(Level level, BlockPos blockPos) { @Override public void saveAdditional(@NotNull CompoundTag compound) { super.saveAdditional(compound); - if (!peripheralSettings.isEmpty()) compound.put(PERIPHERAL_SETTINGS, peripheralSettings); + if (!peripheralSettings.isEmpty()) + compound.put(PERIPHERAL_SETTINGS, peripheralSettings); } @Override diff --git a/src/main/java/de/srendi/advancedperipherals/common/commands/APCommands.java b/src/main/java/de/srendi/advancedperipherals/common/commands/APCommands.java index 3a641a7cc..f6cd4cec6 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/commands/APCommands.java +++ b/src/main/java/de/srendi/advancedperipherals/common/commands/APCommands.java @@ -1,7 +1,21 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.commands; import com.mojang.brigadier.exceptions.CommandSyntaxException; - import dan200.computercraft.core.computer.ComputerSide; import dan200.computercraft.core.computer.Environment; import dan200.computercraft.shared.command.UserLevel; @@ -9,11 +23,9 @@ import dan200.computercraft.shared.command.text.TableBuilder; import dan200.computercraft.shared.computer.core.ServerComputer; import dan200.computercraft.shared.computer.core.ServerContext; - import de.srendi.advancedperipherals.AdvancedPeripherals; import de.srendi.advancedperipherals.common.addons.computercraft.peripheral.ChunkyPeripheral; import de.srendi.advancedperipherals.common.util.inventory.ItemUtil; - import net.minecraft.ChatFormatting; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; @@ -30,23 +42,18 @@ public class APCommands { public static final String ROOT_LITERAL = "advancedperipherals"; public static final String FORCELOAD_LITERAL = "forceload"; - static final String FORCELOAD_HELP = - "/" + ROOT_LITERAL + " " + FORCELOAD_LITERAL + " help" + " - show this help message\n" + - "/" + ROOT_LITERAL + " " + FORCELOAD_LITERAL + " dump" + " - show all chunky turtles\n"; + static final String FORCELOAD_HELP = "/" + ROOT_LITERAL + " " + FORCELOAD_LITERAL + " help" + + " - show this help message\n" + "/" + ROOT_LITERAL + " " + FORCELOAD_LITERAL + " dump" + + " - show all chunky turtles\n"; @SubscribeEvent public static void register(RegisterCommandsEvent event) { event.getDispatcher().register(Commands.literal(ROOT_LITERAL) - .then(Commands.literal("getHashItem") - .executes(context -> getHashItem(context.getSource()))).then(Commands.literal(FORCELOAD_LITERAL) - .executes(context -> forceloadHelp(context.getSource())) - .then(Commands.literal("help") - .executes(context -> forceloadHelp(context.getSource()))) - .then(Commands.literal("dump") - .requires(UserLevel.OWNER_OP) - .executes(context -> forceloadDump(context.getSource()))) - ) - ); + .then(Commands.literal("getHashItem").executes(context -> getHashItem(context.getSource()))) + .then(Commands.literal(FORCELOAD_LITERAL).executes(context -> forceloadHelp(context.getSource())) + .then(Commands.literal("help").executes(context -> forceloadHelp(context.getSource()))) + .then(Commands.literal("dump").requires(UserLevel.OWNER_OP) + .executes(context -> forceloadDump(context.getSource()))))); } private static int getHashItem(CommandSourceStack source) throws CommandSyntaxException { @@ -61,11 +68,11 @@ private static int getHashItem(CommandSourceStack source) throws CommandSyntaxEx return 0; } source.sendSuccess(Component.literal("Fingerprint of the item: "), true); - source.sendSuccess(ComponentUtils.wrapInSquareBrackets( - Component.literal(fingerprint) - .withStyle(style -> style.applyFormat(ChatFormatting.GREEN) - .withClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, fingerprint)) - .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("Copy"))))), true); + source.sendSuccess(ComponentUtils.wrapInSquareBrackets(Component.literal(fingerprint) + .withStyle(style -> style.applyFormat(ChatFormatting.GREEN) + .withClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, fingerprint)) + .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("Copy"))))), + true); return 1; } @@ -77,41 +84,34 @@ private static int forceloadHelp(CommandSourceStack source) throws CommandSyntax private static int forceloadDump(CommandSourceStack source) throws CommandSyntaxException { TableBuilder table = new TableBuilder("ChunkyTurtles", "Computer", "Position"); - ServerComputer[] computers = ServerContext.get(source.getServer()).registry().getComputers().stream().filter((computer) -> { - Environment env = computer.getComputer().getEnvironment(); - for (ComputerSide side : ComputerSide.values()) { - if (env.getPeripheral(side) instanceof ChunkyPeripheral) { - return true; - } - } - return false; - }).sorted((a, b) -> a.getID() - b.getID()).toArray(size -> new ServerComputer[size]); + ServerComputer[] computers = ServerContext.get(source.getServer()).registry().getComputers().stream() + .filter((computer) -> { + Environment env = computer.getComputer().getEnvironment(); + for (ComputerSide side : ComputerSide.values()) { + if (env.getPeripheral(side) instanceof ChunkyPeripheral) { + return true; + } + } + return false; + }).sorted((a, b) -> a.getID() - b.getID()).toArray(size -> new ServerComputer[size]); for (ServerComputer computer : computers) { - table.row( - makeComputerDumpCommand(computer), - makeComputerPosCommand(computer) - ); + table.row(makeComputerDumpCommand(computer), makeComputerPosCommand(computer)); } table.display(source); return computers.length; } - private static Component makeComputerDumpCommand(ServerComputer computer) { - return ChatHelpers.link( - Component.literal("#" + computer.getID()), - "/computercraft dump " + computer.getInstanceID(), - Component.translatable("commands.computercraft.dump.action") - ); + return ChatHelpers.link(Component.literal("#" + computer.getID()), + "/computercraft dump " + computer.getInstanceID(), + Component.translatable("commands.computercraft.dump.action")); } private static Component makeComputerPosCommand(ServerComputer computer) { - return ChatHelpers.link( - ChatHelpers.position(computer.getPosition()), - "/computercraft tp " + computer.getInstanceID(), - Component.translatable("commands.computercraft.tp.action") - ); + return ChatHelpers.link(ChatHelpers.position(computer.getPosition()), + "/computercraft tp " + computer.getInstanceID(), + Component.translatable("commands.computercraft.tp.action")); } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/configuration/APConfig.java b/src/main/java/de/srendi/advancedperipherals/common/configuration/APConfig.java index f19dbc4c2..3527fc495 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/configuration/APConfig.java +++ b/src/main/java/de/srendi/advancedperipherals/common/configuration/APConfig.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.configuration; import com.electronwill.nightconfig.core.file.CommentedFileConfig; @@ -20,12 +35,14 @@ public class APConfig extends ModConfig { public static final WorldConfig WORLD_CONFIG = new WorldConfig(); public APConfig(IAPConfig config, ModContainer container) { - super(config.getType(), config.getConfigSpec(), container, "Advancedperipherals/" + config.getFileName() + ".toml"); + super(config.getType(), config.getConfigSpec(), container, + "Advancedperipherals/" + config.getFileName() + ".toml"); } public static void register(ModLoadingContext context) { - //Creates the config folder - FMLPaths.getOrCreateGameRelativePath(FMLPaths.CONFIGDIR.get().resolve("Advancedperipherals"), "Advancedperipherals"); + // Creates the config folder + FMLPaths.getOrCreateGameRelativePath(FMLPaths.CONFIGDIR.get().resolve("Advancedperipherals"), + "Advancedperipherals"); ModContainer modContainer = context.getActiveContainer(); modContainer.addConfig(new APConfig(GENERAL_CONFIG, modContainer)); @@ -42,7 +59,8 @@ public ConfigFileTypeHandler getHandler() { public static class ConfigFileHandler extends ConfigFileTypeHandler { public static Path getPath(Path path) { - if (path.endsWith("serverconfig")) return FMLPaths.CONFIGDIR.get(); + if (path.endsWith("serverconfig")) + return FMLPaths.CONFIGDIR.get(); return path; } diff --git a/src/main/java/de/srendi/advancedperipherals/common/configuration/GeneralConfig.java b/src/main/java/de/srendi/advancedperipherals/common/configuration/GeneralConfig.java index 954dad5a3..5e1d07db1 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/configuration/GeneralConfig.java +++ b/src/main/java/de/srendi/advancedperipherals/common/configuration/GeneralConfig.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.configuration; import de.srendi.advancedperipherals.lib.LibConfig; @@ -16,7 +31,8 @@ public class GeneralConfig implements IAPConfig { builder.comment("Config to adjust general mod settings").push("General"); - enableDebugMode = builder.comment("Enables the debug mode. Only enable it if needed.").define("enableDebugMode", false); + enableDebugMode = builder.comment("Enables the debug mode. Only enable it if needed.").define("enableDebugMode", + false); builder.pop(); builder.push("Core"); diff --git a/src/main/java/de/srendi/advancedperipherals/common/configuration/IAPConfig.java b/src/main/java/de/srendi/advancedperipherals/common/configuration/IAPConfig.java index 05cb51657..ff589e455 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/configuration/IAPConfig.java +++ b/src/main/java/de/srendi/advancedperipherals/common/configuration/IAPConfig.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.configuration; import de.srendi.advancedperipherals.lib.misc.IConfigHandler; diff --git a/src/main/java/de/srendi/advancedperipherals/common/configuration/MetaphysicsConfig.java b/src/main/java/de/srendi/advancedperipherals/common/configuration/MetaphysicsConfig.java index e45fdcbde..d7ee31752 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/configuration/MetaphysicsConfig.java +++ b/src/main/java/de/srendi/advancedperipherals/common/configuration/MetaphysicsConfig.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.configuration; import de.srendi.advancedperipherals.common.addons.computercraft.operations.AutomataCoreTier; @@ -21,12 +36,17 @@ public MetaphysicsConfig() { builder.comment("Config for metaphysics").push("Metaphysics"); - energyToFuelRate = builder.comment("Defines energy to fuel rate").defineInRange("energyToFuelRate", 575, 575, Integer.MAX_VALUE); + energyToFuelRate = builder.comment("Defines energy to fuel rate").defineInRange("energyToFuelRate", 575, 575, + Integer.MAX_VALUE); enableWeakAutomataCore = builder.define("enableWeakAutomataCore", true); enableEndAutomataCore = builder.define("enableEndAutomataCore", true); enableHusbandryAutomataCore = builder.define("enableHusbandryAutomataCore", true); - endAutomataCoreWarpPointLimit = builder.comment("Defines max warp point stored in warp core. Mostly need to not allow NBT overflow error").defineInRange("endAutomataCoreWarpPointLimit", 64, 1, Integer.MAX_VALUE); - overpoweredAutomataBreakChance = builder.comment("Chance that overpowered automata will break after rotation cycle").defineInRange("overpoweredAutomataBreakChance", 0.002, 0, 1); + endAutomataCoreWarpPointLimit = builder + .comment("Defines max warp point stored in warp core. Mostly need to not allow NBT overflow error") + .defineInRange("endAutomataCoreWarpPointLimit", 64, 1, Integer.MAX_VALUE); + overpoweredAutomataBreakChance = builder + .comment("Chance that overpowered automata will break after rotation cycle") + .defineInRange("overpoweredAutomataBreakChance", 0.002, 0, 1); register(AutomataCoreTier.values(), builder); 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 9589d4f43..7e21d0808 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/configuration/PeripheralsConfig.java +++ b/src/main/java/de/srendi/advancedperipherals/common/configuration/PeripheralsConfig.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.configuration; import de.srendi.advancedperipherals.common.addons.computercraft.operations.SimpleFreeOperation; @@ -10,7 +25,7 @@ @FieldsAreNonnullByDefault public class PeripheralsConfig implements IAPConfig { - //Player Detector + // Player Detector public final ForgeConfigSpec.IntValue playerDetMaxRange; public final ForgeConfigSpec.BooleanValue playerSpy; public final ForgeConfigSpec.BooleanValue morePlayerInformation; @@ -20,68 +35,68 @@ public class PeripheralsConfig implements IAPConfig { public final ForgeConfigSpec.IntValue playerSpyRandErrorAmount; public final ForgeConfigSpec.IntValue playerSpyPreciseMaxRange; - //Energy Detector + // Energy Detector public final ForgeConfigSpec.IntValue energyDetectorMaxFlow; public final ForgeConfigSpec.BooleanValue enableEnergyDetector; - //Fluid Detector + // Fluid Detector public final ForgeConfigSpec.IntValue fluidDetectorMaxFlow; public final ForgeConfigSpec.BooleanValue enableFluidDetector; - //Gas Detector + // Gas Detector public final ForgeConfigSpec.IntValue gasDetectorMaxFlow; public final ForgeConfigSpec.BooleanValue enableGasDetector; - //NBT Storage + // NBT Storage public final ForgeConfigSpec.IntValue nbtStorageMaxSize; public final ForgeConfigSpec.BooleanValue enableNBTStorage; - //Chunky turtle + // Chunky turtle public final ForgeConfigSpec.IntValue chunkLoadValidTime; public final ForgeConfigSpec.IntValue chunkyTurtleRadius; public final ForgeConfigSpec.BooleanValue enableChunkyTurtle; - //Chat box + // Chat box public final ForgeConfigSpec.BooleanValue enableChatBox; public final ForgeConfigSpec.ConfigValue defaultChatBoxPrefix; public final ForgeConfigSpec.IntValue chatBoxMaxRange; public final ForgeConfigSpec.BooleanValue chatBoxMultiDimensional; - //ME Bridge + // ME Bridge public final ForgeConfigSpec.BooleanValue enableMEBridge; public final ForgeConfigSpec.IntValue meConsumption; - //Rs Bridge + // Rs Bridge public final ForgeConfigSpec.BooleanValue enableRSBridge; public final ForgeConfigSpec.IntValue rsConsumption; - //Environment Detector + // Environment Detector public final ForgeConfigSpec.BooleanValue enableEnvironmentDetector; - //AR Controller + // AR Controller public final ForgeConfigSpec.BooleanValue enableSmartGlasses; - //Inventory Manager + // Inventory Manager public final ForgeConfigSpec.BooleanValue enableInventoryManager; - //Redstone Integrator + // Redstone Integrator public final ForgeConfigSpec.BooleanValue enableRedstoneIntegrator; - //Block reader + // Block reader public final ForgeConfigSpec.BooleanValue enableBlockReader; - //Geo Scanner + // Geo Scanner public final ForgeConfigSpec.BooleanValue enableGeoScanner; - //Colony integrator + // Colony integrator public final ForgeConfigSpec.BooleanValue enableColonyIntegrator; - //Compass turtle + // Compass turtle public final ForgeConfigSpec.BooleanValue enableCompassTurtle; - //Compass turtle + // Compass turtle public final ForgeConfigSpec.BooleanValue enableDistanceDetector; public final ForgeConfigSpec.DoubleValue distanceDetectorRange; public final ForgeConfigSpec.IntValue distanceDetectorUpdateRate; - //Powered Peripherals + // Powered Peripherals public final ForgeConfigSpec.BooleanValue enablePoweredPeripherals; public final ForgeConfigSpec.BooleanValue disablePocketFuelConsumption; public final ForgeConfigSpec.IntValue poweredPeripheralMaxEnergyStorage; @@ -94,60 +109,90 @@ 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. -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); - playerSpyRandError = builder.comment("If true, add random error to `getPlayerPos` player position that varies based on how far the player is from the detector. Prevents getting the exact position of players far from the detector.").define("enablePlayerPosRandomError", false); - playerSpyRandErrorAmount = builder.comment("The maximum amount of error (in blocks) that can be applied to each axis of the player's position.").defineInRange("playerPosRandomErrorAmount", 1000, 0, Integer.MAX_VALUE); - playerSpyPreciseMaxRange = builder.comment("If random error is enabled: this is the maximum range at which an exact player position is returned, before random error starts to be applied.").defineInRange("playerPosPreciseMaxRange", 100, 0, Integer.MAX_VALUE); + 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. -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); + playerSpyRandError = builder.comment( + "If true, add random error to `getPlayerPos` player position that varies based on how far the player is from the detector. Prevents getting the exact position of players far from the detector.") + .define("enablePlayerPosRandomError", false); + playerSpyRandErrorAmount = builder.comment( + "The maximum amount of error (in blocks) that can be applied to each axis of the player's position.") + .defineInRange("playerPosRandomErrorAmount", 1000, 0, Integer.MAX_VALUE); + playerSpyPreciseMaxRange = builder.comment( + "If random error is enabled: this is the maximum range at which an exact player position is returned, before random error starts to be applied.") + .defineInRange("playerPosPreciseMaxRange", 100, 0, Integer.MAX_VALUE); pop("Energy_Detector", builder); - enableEnergyDetector = builder.comment("Enable the Energy Detector or not.").define("enableEnergyDetector", true); - energyDetectorMaxFlow = builder.comment("Defines the maximum energy flow of the energy detector.").defineInRange("energyDetectorMaxFlow", Integer.MAX_VALUE, 0, Integer.MAX_VALUE); + enableEnergyDetector = builder.comment("Enable the Energy Detector or not.").define("enableEnergyDetector", + true); + energyDetectorMaxFlow = builder.comment("Defines the maximum energy flow of the energy detector.") + .defineInRange("energyDetectorMaxFlow", Integer.MAX_VALUE, 0, Integer.MAX_VALUE); pop("Fluid_Detector", builder); enableFluidDetector = builder.comment("Enable the Fluid Detector or not.").define("enableFluidDetector", true); - fluidDetectorMaxFlow = builder.comment("Defines the maximum fluid flow of the fluid detector.").defineInRange("energyDetectorMaxFlow", Integer.MAX_VALUE, 0, Integer.MAX_VALUE); + fluidDetectorMaxFlow = builder.comment("Defines the maximum fluid flow of the fluid detector.") + .defineInRange("energyDetectorMaxFlow", Integer.MAX_VALUE, 0, Integer.MAX_VALUE); pop("Gas_Detector", builder); enableGasDetector = builder.comment("Enable the Gas Detector or not.").define("enableGasDetector", true); - gasDetectorMaxFlow = builder.comment("Defines the maximum gas flow of the gas detector.").defineInRange("gasDetectorMaxFlow", Integer.MAX_VALUE, 0, Integer.MAX_VALUE); + gasDetectorMaxFlow = builder.comment("Defines the maximum gas flow of the gas detector.") + .defineInRange("gasDetectorMaxFlow", Integer.MAX_VALUE, 0, Integer.MAX_VALUE); pop("NBT_Storage", builder); enableNBTStorage = builder.comment("Enable the nbt storage block or not").define("enableNBTStorage", true); - nbtStorageMaxSize = builder.comment("Defines max nbt string length that can be stored in nbt storage").defineInRange("nbtStorageMaxSize", 1048576, 0, Integer.MAX_VALUE); + nbtStorageMaxSize = builder.comment("Defines max nbt string length that can be stored in nbt storage") + .defineInRange("nbtStorageMaxSize", 1048576, 0, Integer.MAX_VALUE); pop("Chunky_Turtle", builder); enableChunkyTurtle = builder.comment("Enable the Chunky Turtle or not.").define("enableChunkyTurtle", true); - chunkLoadValidTime = builder.comment("Time in seconds, while loaded chunk can be consider as valid without touch").defineInRange("chunkLoadValidTime", 600, 60, Integer.MAX_VALUE); - chunkyTurtleRadius = builder.comment("Radius in chunks a single chunky turtle will load. The default value (0) only loads the chunk the turtle is in, 1 would also load the 8 surrounding chunks (9 in total) and so on").defineInRange("chunkyTurtleRadius", 0, 0, 16); + chunkLoadValidTime = builder + .comment("Time in seconds, while loaded chunk can be consider as valid without touch") + .defineInRange("chunkLoadValidTime", 600, 60, Integer.MAX_VALUE); + chunkyTurtleRadius = builder.comment( + "Radius in chunks a single chunky turtle will load. The default value (0) only loads the chunk the turtle is in, 1 would also load the 8 surrounding chunks (9 in total) and so on") + .defineInRange("chunkyTurtleRadius", 0, 0, 16); pop("Chat_Box", builder); enableChatBox = builder.comment("Enable the Chat Box or not.").define("enableChatBox", true); defaultChatBoxPrefix = builder.comment("Defines default chatbox prefix").define("defaultChatBoxPrefix", "AP"); - chatBoxMaxRange = builder.comment("Defines the maximal range of the chat box in blocks. -1 for infinite. If the range is not -1, players in other dimensions won't able to receive messages").defineInRange("chatBoxMaxRange", -1, -1, 30000000); - chatBoxMultiDimensional = builder.comment("If true, the chat box is able to send messages to other dimensions than its own").define("chatBoxMultiDimensional", true); + chatBoxMaxRange = builder.comment( + "Defines the maximal range of the chat box in blocks. -1 for infinite. If the range is not -1, players in other dimensions won't able to receive messages") + .defineInRange("chatBoxMaxRange", -1, -1, 30000000); + chatBoxMultiDimensional = builder + .comment("If true, the chat box is able to send messages to other dimensions than its own") + .define("chatBoxMultiDimensional", true); pop("ME_Bridge", builder); enableMEBridge = builder.comment("Enable the Me Bridge or not.").define("enableMeBridge", true); - meConsumption = builder.comment("Power consumption per tick.").defineInRange("mePowerConsumption", 10, 0, Integer.MAX_VALUE); + meConsumption = builder.comment("Power consumption per tick.").defineInRange("mePowerConsumption", 10, 0, + Integer.MAX_VALUE); pop("RS_Bridge", builder); enableRSBridge = builder.comment("Enable the Rs Bridge or not.").define("enableRsBridge", true); - rsConsumption = builder.comment("Power consumption per tick.").defineInRange("rsPowerConsumption", 10, 0, Integer.MAX_VALUE); + rsConsumption = builder.comment("Power consumption per tick.").defineInRange("rsPowerConsumption", 10, 0, + Integer.MAX_VALUE); pop("Environment_Detector", builder); - enableEnvironmentDetector = builder.comment("Enable the Environment Detector or not.").define("enableEnvironmentDetector", true); + enableEnvironmentDetector = builder.comment("Enable the Environment Detector or not.") + .define("enableEnvironmentDetector", true); pop("AR_Controller", builder); @@ -155,11 +200,13 @@ public PeripheralsConfig() { pop("Inventory_Manager", builder); - enableInventoryManager = builder.comment("Enable the inventory manager or not.").define("enableInventoryManager", true); + enableInventoryManager = builder.comment("Enable the inventory manager or not.") + .define("enableInventoryManager", true); pop("Redstone_Integrator", builder); - enableRedstoneIntegrator = builder.comment("Enable the redstone integrator or not.").define("enableRedstoneIntegrator", true); + enableRedstoneIntegrator = builder.comment("Enable the redstone integrator or not.") + .define("enableRedstoneIntegrator", true); pop("Block_Reader", builder); @@ -171,7 +218,8 @@ public PeripheralsConfig() { pop("Colony_Integrator", builder); - enableColonyIntegrator = builder.comment("Enable the colony integrator or not.").define("enableColonyIntegrator", true); + enableColonyIntegrator = builder.comment("Enable the colony integrator or not.") + .define("enableColonyIntegrator", true); pop("Compass_Turtle", builder); @@ -179,19 +227,26 @@ public PeripheralsConfig() { pop("Distance_Detector", builder); - enableDistanceDetector = builder.comment("Enable the distance detector or not.").define("enableDistanceDetector", true); - distanceDetectorRange = builder.comment("Maximum range of the distance detector").defineInRange("distanceDetectorRange", 64D, 0D, Integer.MAX_VALUE); - distanceDetectorUpdateRate = builder.comment("Defines how often the distance detector updates it's distance if periodically updates are enabled. \n" + - "Periodically updates exists so we do not need to run \"getDistance\" on the main thread which eliminates the 1 tick yield of the lua function").defineInRange("maxUpdateRate", 2, 1, 100); + enableDistanceDetector = builder.comment("Enable the distance detector or not.") + .define("enableDistanceDetector", true); + distanceDetectorRange = builder.comment("Maximum range of the distance detector") + .defineInRange("distanceDetectorRange", 64D, 0D, Integer.MAX_VALUE); + distanceDetectorUpdateRate = builder.comment( + "Defines how often the distance detector updates it's distance if periodically updates are enabled. \n" + + "Periodically updates exists so we do not need to run \"getDistance\" on the main thread which eliminates the 1 tick yield of the lua function") + .defineInRange("maxUpdateRate", 2, 1, 100); pop("Powered_Peripherals", builder); - enablePoweredPeripherals = builder.comment("Enable RF storage for peripherals, that could use it").define("enablePoweredPeripherals", false); - poweredPeripheralMaxEnergyStorage = builder.comment("Defines max energy storage in any powered peripheral").defineInRange("poweredPeripheralMaxEnergyStored", 100_000_000, 1_000_000, Integer.MAX_VALUE); + enablePoweredPeripherals = builder.comment("Enable RF storage for peripherals, that could use it") + .define("enablePoweredPeripherals", false); + poweredPeripheralMaxEnergyStorage = builder.comment("Defines max energy storage in any powered peripheral") + .defineInRange("poweredPeripheralMaxEnergyStored", 100_000_000, 1_000_000, Integer.MAX_VALUE); pop("Pocket_Peripherals", builder); - disablePocketFuelConsumption = builder.comment("If true, pockets will have infinite fuel").define("disablePocketFuelConsumption", true); + disablePocketFuelConsumption = builder.comment("If true, pockets will have infinite fuel") + .define("disablePocketFuelConsumption", true); pop("Operations", builder); diff --git a/src/main/java/de/srendi/advancedperipherals/common/configuration/WorldConfig.java b/src/main/java/de/srendi/advancedperipherals/common/configuration/WorldConfig.java index de050af71..de5c525d3 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/configuration/WorldConfig.java +++ b/src/main/java/de/srendi/advancedperipherals/common/configuration/WorldConfig.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.configuration; import net.minecraft.FieldsAreNonnullByDefault; @@ -17,9 +32,12 @@ public WorldConfig() { builder.comment("Config to adjust world settings").push("World"); - enableVillagerStructures = builder.comment("Enable the villager structures for the computer scientist.").define("enableVillagerStructures", true); - givePlayerBookOnJoin = builder.comment("Gives the ap documentation to new players.").define("givePlayerBookOnJoin", true); - villagerStructureWeight = builder.comment("The weight of the villager structures.").defineInRange("villagerStructureWeight", 10, 0, 16000); + enableVillagerStructures = builder.comment("Enable the villager structures for the computer scientist.") + .define("enableVillagerStructures", true); + givePlayerBookOnJoin = builder.comment("Gives the ap documentation to new players.") + .define("givePlayerBookOnJoin", true); + villagerStructureWeight = builder.comment("The weight of the villager structures.") + .defineInRange("villagerStructureWeight", 10, 0, 16000); builder.pop(); configSpec = builder.build(); @@ -40,6 +58,6 @@ public ModConfig.Type getType() { return ModConfig.Type.COMMON; } /* - [ + * [ */ } diff --git a/src/main/java/de/srendi/advancedperipherals/common/container/InventoryManagerContainer.java b/src/main/java/de/srendi/advancedperipherals/common/container/InventoryManagerContainer.java index b4116aa2c..a5bc777ba 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/container/InventoryManagerContainer.java +++ b/src/main/java/de/srendi/advancedperipherals/common/container/InventoryManagerContainer.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.container; import de.srendi.advancedperipherals.common.container.base.BaseContainer; @@ -21,7 +36,8 @@ public InventoryManagerContainer(int id, Inventory inventory, BlockPos pos, Leve layoutPlayerInventorySlots(7, 84); if (tileEntity != null) { tileEntity.getCapability(ForgeCapabilities.ITEM_HANDLER).ifPresent(handler -> { - addSlot(new SlotInputHandler(handler, 0, 79, 29, new SlotCondition().setNeededItem(APItems.MEMORY_CARD.get()))); //Input + addSlot(new SlotInputHandler(handler, 0, 79, 29, + new SlotCondition().setNeededItem(APItems.MEMORY_CARD.get()))); // Input }); } } @@ -31,8 +47,7 @@ public boolean stillValid(@NotNull Player playerIn) { return true; } - @NotNull - @Override + @NotNull @Override public ItemStack quickMoveStack(@NotNull Player player, int index) { ItemStack itemstack = ItemStack.EMPTY; Slot slot = this.slots.get(index); diff --git a/src/main/java/de/srendi/advancedperipherals/common/container/SmartGlassesContainer.java b/src/main/java/de/srendi/advancedperipherals/common/container/SmartGlassesContainer.java index 8a8bd7684..b202c8a1b 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/container/SmartGlassesContainer.java +++ b/src/main/java/de/srendi/advancedperipherals/common/container/SmartGlassesContainer.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.container; import dan200.computercraft.client.gui.widgets.ComputerSidebar; @@ -23,7 +38,8 @@ public class SmartGlassesContainer extends ContainerComputerBase { public static final int PLAYER_START_Y = 134; public static final int PLAYER_START_X = ComputerSidebar.WIDTH + BORDER; - public SmartGlassesContainer(int id, Predicate canUse, ServerComputer computer, Inventory playerInventory, IItemHandler inventory, ComputerContainerData data) { + public SmartGlassesContainer(int id, Predicate canUse, ServerComputer computer, Inventory playerInventory, + IItemHandler inventory, ComputerContainerData data) { super(APContainerTypes.SMART_GLASSES_CONTAINER.get(), id, canUse, ComputerFamily.ADVANCED, computer, data); // Glasses Peripherals @@ -55,12 +71,13 @@ public SmartGlassesContainer(int id, Predicate canUse, ServerComputer co } - public SmartGlassesContainer(int id, Predicate predicate, ServerComputer computer, ComputerContainerData data, Inventory player, ItemStack glasses) { - this(id, predicate, computer, player, glasses.getCapability(ForgeCapabilities.ITEM_HANDLER).resolve().orElseThrow(), data); + public SmartGlassesContainer(int id, Predicate predicate, ServerComputer computer, + ComputerContainerData data, Inventory player, ItemStack glasses) { + this(id, predicate, computer, player, + glasses.getCapability(ForgeCapabilities.ITEM_HANDLER).resolve().orElseThrow(), data); } - @NotNull - @Override + @NotNull @Override public ItemStack quickMoveStack(@NotNull Player player, int index) { ItemStack itemstack = ItemStack.EMPTY; Slot slot = this.slots.get(index); 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 9d11ca901..93c7f1603 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 @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.container.base; import de.srendi.advancedperipherals.common.blocks.base.PeripheralBlockEntity; @@ -35,12 +50,14 @@ public ItemStack quickMoveStack(Player playerIn, int index) { ItemStack itemstack1 = slot.getItem(); itemstack = itemstack1.copy(); if (index >= 36) { - if (!this.moveItemStackTo(itemstack, 0, 36, false) && !tileEntity.canTakeItemThroughFace(index, itemstack, Direction.NORTH)) { + if (!this.moveItemStackTo(itemstack, 0, 36, false) + && !tileEntity.canTakeItemThroughFace(index, itemstack, Direction.NORTH)) { return ItemStack.EMPTY; } slot.onQuickCraft(itemstack, itemstack1); } else { - if (!this.moveItemStackTo(itemstack, 36, getItems().size(), false) && !tileEntity.canPlaceItemThroughFace(index, itemstack, Direction.NORTH)) { + if (!this.moveItemStackTo(itemstack, 36, getItems().size(), false) + && !tileEntity.canPlaceItemThroughFace(index, itemstack, Direction.NORTH)) { return ItemStack.EMPTY; } } @@ -57,7 +74,6 @@ public ItemStack quickMoveStack(Player playerIn, int index) { return itemstack; } - private int addSlotRange(IItemHandler handler, int index, int x, int y, int amount, int dx) { for (int i = 0; i < amount; i++) { addSlot(new SlotItemHandler(handler, index, x, y)); @@ -67,7 +83,8 @@ private int addSlotRange(IItemHandler handler, int index, int x, int y, int amou return index; } - private int addSlotBox(IItemHandler handler, int index, int x, int y, int horAmount, int dx, int verAmount, int dy) { + private int addSlotBox(IItemHandler handler, int index, int x, int y, int horAmount, int dx, int verAmount, + int dy) { for (int i = 0; i < verAmount; i++) { index = addSlotRange(handler, index, x, y, horAmount, dx); y += dy; diff --git a/src/main/java/de/srendi/advancedperipherals/common/container/base/BaseItemContainer.java b/src/main/java/de/srendi/advancedperipherals/common/container/base/BaseItemContainer.java index dfc8ceab8..d260f87f8 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/container/base/BaseItemContainer.java +++ b/src/main/java/de/srendi/advancedperipherals/common/container/base/BaseItemContainer.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.container.base; import net.minecraft.world.entity.player.Inventory; @@ -20,36 +35,25 @@ protected BaseItemContainer(int id, @Nullable MenuType type, Inventory invent this.item = item; } - /*@Override - public ItemStack transferStackInSlot(PlayerEntity playerIn, int index) { - ItemStack itemstack = ItemStack.EMPTY; - Slot slot = this.inventorySlots.get(index); - if (slot != null && slot.getHasStack()) { - ItemStack itemstack1 = slot.getStack(); - itemstack = itemstack1.copy(); - if (index >= 36) { - if (!this.mergeItemStack(itemstack, 0, 36, false) && !tileEntity.canExtractItem(index, itemstack, Direction.NORTH)) { - return ItemStack.EMPTY; - } - slot.onSlotChange(itemstack, itemstack1); - } else { - if (!this.mergeItemStack(itemstack, 36, getInventory().size(), false) && !tileEntity.canInsertItem(index, itemstack, Direction.NORTH)) { - return ItemStack.EMPTY; - } - } - - if (itemstack.getCount() == 0) { - slot.putStack(ItemStack.EMPTY); - } else { - slot.onSlotChanged(); - } - - slot.onTake(playerIn, itemstack); - } - - return itemstack; - }*/ - + /* + * @Override public ItemStack transferStackInSlot(PlayerEntity playerIn, int + * index) { ItemStack itemstack = ItemStack.EMPTY; Slot slot = + * this.inventorySlots.get(index); if (slot != null && slot.getHasStack()) { + * ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); if + * (index >= 36) { if (!this.mergeItemStack(itemstack, 0, 36, false) && + * !tileEntity.canExtractItem(index, itemstack, Direction.NORTH)) { return + * ItemStack.EMPTY; } slot.onSlotChange(itemstack, itemstack1); } else { if + * (!this.mergeItemStack(itemstack, 36, getInventory().size(), false) && + * !tileEntity.canInsertItem(index, itemstack, Direction.NORTH)) { return + * ItemStack.EMPTY; } } + * + * if (itemstack.getCount() == 0) { slot.putStack(ItemStack.EMPTY); } else { + * slot.onSlotChanged(); } + * + * slot.onTake(playerIn, itemstack); } + * + * return itemstack; } + */ private int addSlotRange(IItemHandler handler, int index, int x, int y, int amount, int dx) { for (int i = 0; i < amount; i++) { @@ -60,7 +64,8 @@ private int addSlotRange(IItemHandler handler, int index, int x, int y, int amou return index; } - private int addSlotBox(IItemHandler handler, int index, int x, int y, int horAmount, int dx, int verAmount, int dy) { + private int addSlotBox(IItemHandler handler, int index, int x, int y, int horAmount, int dx, int verAmount, + int dy) { for (int i = 0; i < verAmount; i++) { index = addSlotRange(handler, index, x, y, horAmount, dx); y += dy; diff --git a/src/main/java/de/srendi/advancedperipherals/common/container/base/NamedContainerProvider.java b/src/main/java/de/srendi/advancedperipherals/common/container/base/NamedContainerProvider.java index f7012e6a6..ab7642740 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/container/base/NamedContainerProvider.java +++ b/src/main/java/de/srendi/advancedperipherals/common/container/base/NamedContainerProvider.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.container.base; import net.minecraft.network.chat.Component; @@ -23,8 +38,7 @@ public Component getDisplayName() { return component; } - @Nullable - @Override + @Nullable @Override public AbstractContainerMenu createMenu(int id, Inventory playerInventory, Player playerEntity) { return containerProvider.createMenu(id, playerInventory, playerEntity); } diff --git a/src/main/java/de/srendi/advancedperipherals/common/container/base/SlotCondition.java b/src/main/java/de/srendi/advancedperipherals/common/container/base/SlotCondition.java index 1adcfcbc3..b580645e5 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/container/base/SlotCondition.java +++ b/src/main/java/de/srendi/advancedperipherals/common/container/base/SlotCondition.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.container.base; import net.minecraft.tags.TagKey; @@ -8,7 +23,8 @@ import java.util.List; /** - * This class is required by {@link SlotInputHandler} to define which item is valid for the slot. + * This class is required by {@link SlotInputHandler} to define which item is + * valid for the slot. */ public class SlotCondition { @@ -19,7 +35,8 @@ public class SlotCondition { /** * Sets the valid tags for the item * - * @param neededTags the tags which the item should have + * @param neededTags + * the tags which the item should have * @return the current instance */ public SlotCondition setNeededTags(List> neededTags) { @@ -30,7 +47,8 @@ public SlotCondition setNeededTags(List> neededTags) { /** * Sets the valid items for the slot * - * @param neededItems the items which the item should be + * @param neededItems + * the items which the item should be * @return the current instance */ public SlotCondition setNeededItems(List neededItems) { @@ -41,7 +59,8 @@ public SlotCondition setNeededItems(List neededItems) { /** * Sets the valid item for the slot * - * @param item the item which the item should be + * @param item + * the item which the item should be * @return the current instance */ public SlotCondition setNeededItem(Item item) { @@ -53,7 +72,8 @@ public SlotCondition setNeededItem(Item item) { /** * Sets the valid tag for the item * - * @param tag the tag which the item should have + * @param tag + * the tag which the item should have * @return the current instance */ public SlotCondition setNeededTag(TagKey tag) { @@ -63,16 +83,19 @@ public SlotCondition setNeededTag(TagKey tag) { } /** - * Checks if the stack is valid for the tags/items. Used in {@link SlotInputHandler} + * Checks if the stack is valid for the tags/items. Used in + * {@link SlotInputHandler} * - * @param stack the {@link ItemStack} which needs to be checked + * @param stack + * the {@link ItemStack} which needs to be checked * @return returns true if the item is valid */ public boolean isValid(ItemStack stack) { boolean valid = true; if (!neededTags.isEmpty()) { for (TagKey tag : neededTags) { - if (stack.getTags().noneMatch(tag::equals)) valid = false; + if (stack.getTags().noneMatch(tag::equals)) + valid = false; } } if (!neededItems.isEmpty() && (!neededItems.contains(stack.getItem()))) diff --git a/src/main/java/de/srendi/advancedperipherals/common/container/base/SlotInputHandler.java b/src/main/java/de/srendi/advancedperipherals/common/container/base/SlotInputHandler.java index ea7e7320d..502668db1 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/container/base/SlotInputHandler.java +++ b/src/main/java/de/srendi/advancedperipherals/common/container/base/SlotInputHandler.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.container.base; import net.minecraft.world.item.ItemStack; @@ -9,7 +24,8 @@ public class SlotInputHandler extends SlotItemHandler { SlotCondition condition; - public SlotInputHandler(IItemHandler itemHandler, int index, int xPosition, int yPosition, SlotCondition condition) { + public SlotInputHandler(IItemHandler itemHandler, int index, int xPosition, int yPosition, + SlotCondition condition) { super(itemHandler, index, xPosition, yPosition); this.condition = condition; } diff --git a/src/main/java/de/srendi/advancedperipherals/common/data/BlockLootTables.java b/src/main/java/de/srendi/advancedperipherals/common/data/BlockLootTables.java index be546eda1..bd54795a4 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/data/BlockLootTables.java +++ b/src/main/java/de/srendi/advancedperipherals/common/data/BlockLootTables.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.data; import de.srendi.advancedperipherals.common.setup.APRegistration; @@ -12,8 +27,7 @@ protected void addTables() { APRegistration.BLOCKS.getEntries().stream().map(RegistryObject::get).forEach(this::dropSelf); } - @NotNull - @Override + @NotNull @Override protected Iterable getKnownBlocks() { return APRegistration.BLOCKS.getEntries().stream().map(RegistryObject::get)::iterator; } diff --git a/src/main/java/de/srendi/advancedperipherals/common/data/BlockLootTablesProvider.java b/src/main/java/de/srendi/advancedperipherals/common/data/BlockLootTablesProvider.java index ffc964ddd..a97e00fa8 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/data/BlockLootTablesProvider.java +++ b/src/main/java/de/srendi/advancedperipherals/common/data/BlockLootTablesProvider.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.data; import com.google.common.collect.ImmutableList; @@ -19,7 +34,6 @@ public class BlockLootTablesProvider extends LootTableProvider { - public BlockLootTablesProvider(DataGenerator dataGeneratorIn) { super(dataGeneratorIn); } diff --git a/src/main/java/de/srendi/advancedperipherals/common/data/BlockStatesAndModelsProvider.java b/src/main/java/de/srendi/advancedperipherals/common/data/BlockStatesAndModelsProvider.java index ac90a7390..f7bcfa6fd 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/data/BlockStatesAndModelsProvider.java +++ b/src/main/java/de/srendi/advancedperipherals/common/data/BlockStatesAndModelsProvider.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.data; import de.srendi.advancedperipherals.AdvancedPeripherals; @@ -8,7 +23,11 @@ import net.minecraft.data.DataGenerator; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.block.Block; -import net.minecraftforge.client.model.generators.*; +import net.minecraftforge.client.model.generators.BlockModelBuilder; +import net.minecraftforge.client.model.generators.BlockStateProvider; +import net.minecraftforge.client.model.generators.ConfiguredModel; +import net.minecraftforge.client.model.generators.ModelFile; +import net.minecraftforge.client.model.generators.ModelProvider; import net.minecraftforge.common.data.ExistingFileHelper; import net.minecraftforge.registries.ForgeRegistries; @@ -29,12 +48,14 @@ protected void registerStatesAndModels() { peripheralBlock(APBlocks.PERIPHERAL_CASING.get()); peripheralBlock(APBlocks.INVENTORY_MANAGER.get(), "front"); peripheralBlock(APBlocks.REDSTONE_INTEGRATOR.get(), "front"); - peripheralBlock(APBlocks.BLOCK_READER.get(), generateModel(APBlocks.BLOCK_READER.get(), false, "north", "south", "east", "west", "up", "down")); + peripheralBlock(APBlocks.BLOCK_READER.get(), + generateModel(APBlocks.BLOCK_READER.get(), false, "north", "south", "east", "west", "up", "down")); peripheralBlock(APBlocks.GEO_SCANNER.get(), "front"); - peripheralBlock(APBlocks.COLONY_INTEGRATOR.get(), generateModel(APBlocks.COLONY_INTEGRATOR.get()) - .texture("particle", blockTexture(APBlocks.COLONY_INTEGRATOR.get())) - .texture("up", blockTexture(net.minecraft.world.level.block.Blocks.OAK_LOG, "top")) - .texture("down", blockTexture(net.minecraft.world.level.block.Blocks.OAK_LOG, "top"))); + peripheralBlock(APBlocks.COLONY_INTEGRATOR.get(), + generateModel(APBlocks.COLONY_INTEGRATOR.get()) + .texture("particle", blockTexture(APBlocks.COLONY_INTEGRATOR.get())) + .texture("up", blockTexture(net.minecraft.world.level.block.Blocks.OAK_LOG, "top")) + .texture("down", blockTexture(net.minecraft.world.level.block.Blocks.OAK_LOG, "top"))); peripheralBlock(APBlocks.NBT_STORAGE.get(), "front"); } @@ -81,10 +102,10 @@ private BlockModelBuilder generateModel(Block block, boolean hasNormalSide, Stri side = "north"; particleTexture = blockTexture(block, "front"); } - if (side.equals("back")) side = "south"; + if (side.equals("back")) + side = "south"; builder.texture(side, blockTexture(block, sideTexture)); - } builder.texture("particle", particleTexture); return builder; @@ -96,7 +117,8 @@ private BlockModelBuilder generateModel(Block block) { private ResourceLocation blockTexture(Block block, String offset) { ResourceLocation name = key(block); - return new ResourceLocation(name.getNamespace(), ModelProvider.BLOCK_FOLDER + "/" + name.getPath() + "_" + offset); + return new ResourceLocation(name.getNamespace(), + ModelProvider.BLOCK_FOLDER + "/" + name.getPath() + "_" + offset); } private ResourceLocation key(Block block) { diff --git a/src/main/java/de/srendi/advancedperipherals/common/data/BlockTagsProvider.java b/src/main/java/de/srendi/advancedperipherals/common/data/BlockTagsProvider.java index 0ccd4f85e..68043ce1b 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/data/BlockTagsProvider.java +++ b/src/main/java/de/srendi/advancedperipherals/common/data/BlockTagsProvider.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.data; import de.srendi.advancedperipherals.AdvancedPeripherals; @@ -20,12 +35,11 @@ public class BlockTagsProvider extends TagsProvider { * Just for note, this provider is designed also for external usage */ - @NotNull - private final DeferredRegister blockRegistry; - @NotNull - private final DataGenerator generator; + @NotNull private final DeferredRegister blockRegistry; + @NotNull private final DataGenerator generator; - public BlockTagsProvider(DataGenerator generator, @Nullable ExistingFileHelper existingFileHelper, @NotNull DeferredRegister blockRegistry) { + public BlockTagsProvider(DataGenerator generator, @Nullable ExistingFileHelper existingFileHelper, + @NotNull DeferredRegister blockRegistry) { super(generator, Registry.BLOCK, AdvancedPeripherals.MOD_ID, existingFileHelper); this.blockRegistry = blockRegistry; this.generator = generator; @@ -43,11 +57,11 @@ protected void addTags() { @Override protected Path getPath(ResourceLocation block) { - return this.generator.getOutputFolder().resolve("data/" + block.getNamespace() + "/tags/blocks/" + block.getPath() + ".json"); + return this.generator.getOutputFolder() + .resolve("data/" + block.getNamespace() + "/tags/blocks/" + block.getPath() + ".json"); } - @NotNull - @Override + @NotNull @Override public String getName() { return "Block tags"; } diff --git a/src/main/java/de/srendi/advancedperipherals/common/data/DataGenerators.java b/src/main/java/de/srendi/advancedperipherals/common/data/DataGenerators.java index b5b92dd20..9844de70c 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/data/DataGenerators.java +++ b/src/main/java/de/srendi/advancedperipherals/common/data/DataGenerators.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.data; import de.srendi.advancedperipherals.AdvancedPeripherals; @@ -19,7 +34,8 @@ public static void genData(GatherDataEvent event) { DataGenerator generator = event.getGenerator(); ExistingFileHelper existingFileHelper = event.getExistingFileHelper(); - generator.addProvider(event.includeServer(), new BlockTagsProvider(generator, existingFileHelper, APRegistration.BLOCKS)); + generator.addProvider(event.includeServer(), + new BlockTagsProvider(generator, existingFileHelper, APRegistration.BLOCKS)); generator.addProvider(event.includeServer(), new RecipesProvider(generator)); generator.addProvider(event.includeServer(), new BlockLootTablesProvider(generator)); generator.addProvider(event.includeServer(), new TurtleUpgradesProvider(generator)); diff --git a/src/main/java/de/srendi/advancedperipherals/common/data/EnUsLanguageProvider.java b/src/main/java/de/srendi/advancedperipherals/common/data/EnUsLanguageProvider.java index 2c96363be..2b12f3d7f 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/data/EnUsLanguageProvider.java +++ b/src/main/java/de/srendi/advancedperipherals/common/data/EnUsLanguageProvider.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.data; import de.srendi.advancedperipherals.AdvancedPeripherals; @@ -96,46 +111,65 @@ private void addPockets() { private void addAdvancements() { addAdvancement("root", AdvancedPeripherals.NAME, "Every journey starts with the first block"); addAdvancement("weak_automata_core", "First automata core", "Does the afterlife exist in minecraft?"); - addAdvancement("end_automata_core", "End automata core", "If you can code gps-free position location with this, you're a powerful human being"); + addAdvancement("end_automata_core", "End automata core", + "If you can code gps-free position location with this, you're a powerful human being"); addAdvancement("husbandry_automata_core", "Husbandry automata core", "Is this core gluten-free?"); addAdvancement("overpowered_automata_core", "Overpowered automata core", "Can you handle so much power?"); - addAdvancement("base_toolkit", "Gentleman's set!", "Collect a redstone integrator, inventory manager and energy detector. How did you even play without this?"); - addAdvancement("nbt_toolkit", "No secrets", "Collect a NBT storage and block reader. Now, all the world's secrets are open to you!"); - addAdvancement("sense_toolkit", "The truth can't hide forever", "Collect a geo scanner and environmental detector. There are no limits for observability!"); + addAdvancement("base_toolkit", "Gentleman's set!", + "Collect a redstone integrator, inventory manager and energy detector. How did you even play without this?"); + addAdvancement("nbt_toolkit", "No secrets", + "Collect a NBT storage and block reader. Now, all the world's secrets are open to you!"); + addAdvancement("sense_toolkit", "The truth can't hide forever", + "Collect a geo scanner and environmental detector. There are no limits for observability!"); } private void addTooltips() { addTooltip("show_desc", "&b[&7%s&b] &7For Description"); - addTooltip("disabled", "&cThis item is disabled in config, so you can craft it, but it'll not have any functionality."); - addTooltip(APItems.COMPUTER_TOOL.get(), "&7This tool was made to tune our blocks. But for now, it's just a blue useless wrench."); + addTooltip("disabled", + "&cThis item is disabled in config, so you can craft it, but it'll not have any functionality."); + addTooltip(APItems.COMPUTER_TOOL.get(), + "&7This tool was made to tune our blocks. But for now, it's just a blue useless wrench."); addTooltip(APBlocks.ENERGY_DETECTOR.get(), "&7Can detect energy flow and acts as a resistor."); addTooltip(APItems.CHUNK_CONTROLLER.get(), "&7A crafting ingredient for the Chunky Turtle."); addTooltip(APBlocks.ENVIRONMENT_DETECTOR.get(), "&7This peripheral interacts with the minecraft world."); - addTooltip(APBlocks.PLAYER_DETECTOR.get(), "&7This peripheral can be used to interact with players, but don't be a stalker."); + addTooltip(APBlocks.PLAYER_DETECTOR.get(), + "&7This peripheral can be used to interact with players, but don't be a stalker."); addTooltip(APBlocks.RS_BRIDGE.get(), "&7The RS Bridge interacts with Refined Storage to manage your items."); - addTooltip(APBlocks.ME_BRIDGE.get(), "&7The ME Bridge interacts with Applied Energistics to manage your items."); + addTooltip(APBlocks.ME_BRIDGE.get(), + "&7The ME Bridge interacts with Applied Energistics to manage your items."); addTooltip(APBlocks.CHAT_BOX.get(), "&7Interacts with the ingame chat, can read and write messages."); - addTooltip(APBlocks.PERIPHERAL_CASING.get(), "&7An empty hull without the love it deserves. Used as crafting ingredient"); + addTooltip(APBlocks.PERIPHERAL_CASING.get(), + "&7An empty hull without the love it deserves. Used as crafting ingredient"); addTooltip(APItems.MEMORY_CARD.get(), "&7Can save the rights of a player to use it in an inventory manager."); addTooltip("memory_card.bound", "&7Bound to &b%s&7."); - addTooltip(APBlocks.INVENTORY_MANAGER.get(), "&7This block is able to send or receive specific items from a player inventory."); - addTooltip(APBlocks.REDSTONE_INTEGRATOR.get(), "&7This block is able to interact with redstone. Works exactly like the redstone api of an computer."); - addTooltip(APBlocks.BLOCK_READER.get(), "&7Reads nbt data of blocks to interact with blocks which do not have computer support."); + addTooltip(APBlocks.INVENTORY_MANAGER.get(), + "&7This block is able to send or receive specific items from a player inventory."); + addTooltip(APBlocks.REDSTONE_INTEGRATOR.get(), + "&7This block is able to interact with redstone. Works exactly like the redstone api of an computer."); + addTooltip(APBlocks.BLOCK_READER.get(), + "&7Reads nbt data of blocks to interact with blocks which do not have computer support."); addTooltip(APBlocks.GEO_SCANNER.get(), "&7Scans the area around it to find some shiny ores."); - addTooltip(APBlocks.COLONY_INTEGRATOR.get(), "&7Interacts with Minecolonies to read data about your colony and citizens."); + addTooltip(APBlocks.COLONY_INTEGRATOR.get(), + "&7Interacts with Minecolonies to read data about your colony and citizens."); addTooltip(APBlocks.NBT_STORAGE.get(), "&7Acts like a storage disk. Can store nbt based data."); addTooltip(APItems.WEAK_AUTOMATA_CORE.get(), "&7Upgrade for turtles, which makes turtles more useful."); - addTooltip(APItems.OVERPOWERED_WEAK_AUTOMATA_CORE.get(), "&7Improved version of the weak automata core, that provides some overpowered uses! Be careful, the upgrade is very fragile."); - addTooltip(APItems.HUSBANDRY_AUTOMATA_CORE.get(), "&7Upgrade for turtles, that allows basic and advanced interactions with animals."); - addTooltip(APItems.OVERPOWERED_HUSBANDRY_AUTOMATA_CORE.get(), "&7Improved version of the husbandry automata core, that provides some overpowered uses! Be careful, the upgrade is very fragile."); - addTooltip(APItems.END_AUTOMATA_CORE.get(), "&7Upgrade for turtles, that allows basic interaction with the world and teleportation in one dimension."); - addTooltip(APItems.OVERPOWERED_END_AUTOMATA_CORE.get(), "&7Improved version of the end automata core, that provides some overpowered uses! Be careful, the upgrade is very fragile."); + addTooltip(APItems.OVERPOWERED_WEAK_AUTOMATA_CORE.get(), + "&7Improved version of the weak automata core, that provides some overpowered uses! Be careful, the upgrade is very fragile."); + addTooltip(APItems.HUSBANDRY_AUTOMATA_CORE.get(), + "&7Upgrade for turtles, that allows basic and advanced interactions with animals."); + addTooltip(APItems.OVERPOWERED_HUSBANDRY_AUTOMATA_CORE.get(), + "&7Improved version of the husbandry automata core, that provides some overpowered uses! Be careful, the upgrade is very fragile."); + addTooltip(APItems.END_AUTOMATA_CORE.get(), + "&7Upgrade for turtles, that allows basic interaction with the world and teleportation in one dimension."); + addTooltip(APItems.OVERPOWERED_END_AUTOMATA_CORE.get(), + "&7Improved version of the end automata core, that provides some overpowered uses! Be careful, the upgrade is very fragile."); } private void addText() { add("text." + AdvancedPeripherals.MOD_ID + ".removed_player", "Cleared the memory card"); add("text." + AdvancedPeripherals.MOD_ID + ".added_player", "Added you to the memory card"); - add("text." + AdvancedPeripherals.MOD_ID + ".automata_core_feed_by_player", "You're trying to feed an entity to a soul, but your own body refuses to do this. Maybe something more mechanical can do this?"); + add("text." + AdvancedPeripherals.MOD_ID + ".automata_core_feed_by_player", + "You're trying to feed an entity to a soul, but your own body refuses to do this. Maybe something more mechanical can do this?"); add("text." + AdvancedPeripherals.MOD_ID + ".smart_glasses.peripherals", "Peripherals"); add("text." + AdvancedPeripherals.MOD_ID + ".smart_glasses.modules", "Modules"); } diff --git a/src/main/java/de/srendi/advancedperipherals/common/data/PocketUpgradesProvider.java b/src/main/java/de/srendi/advancedperipherals/common/data/PocketUpgradesProvider.java index 385b75679..9db7fba28 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/data/PocketUpgradesProvider.java +++ b/src/main/java/de/srendi/advancedperipherals/common/data/PocketUpgradesProvider.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.data; import dan200.computercraft.api.pocket.PocketUpgradeDataProvider; @@ -17,10 +32,15 @@ public PocketUpgradesProvider(DataGenerator output) { @Override protected void addUpgrades(@NotNull Consumer>> addUpgrade) { - simpleWithCustomItem(CCRegistration.ID.CHATTY_POCKET, CCRegistration.CHAT_BOX_POCKET.get(), APBlocks.CHAT_BOX.get().asItem()).add(addUpgrade); - simpleWithCustomItem(CCRegistration.ID.PLAYER_POCKET, CCRegistration.PLAYER_DETECTOR_POCKET.get(), APBlocks.PLAYER_DETECTOR.get().asItem()).add(addUpgrade); - simpleWithCustomItem(CCRegistration.ID.ENVIRONMENT_POCKET, CCRegistration.ENVIRONMENT_POCKET.get(), APBlocks.ENVIRONMENT_DETECTOR.get().asItem()).add(addUpgrade); - simpleWithCustomItem(CCRegistration.ID.GEOSCANNER_POCKET, CCRegistration.GEO_SCANNER_POCKET.get(), APBlocks.GEO_SCANNER.get().asItem()).add(addUpgrade); - simpleWithCustomItem(CCRegistration.ID.COLONY_POCKET, CCRegistration.COLONY_POCKET.get(), APBlocks.COLONY_INTEGRATOR.get().asItem()).add(addUpgrade); + simpleWithCustomItem(CCRegistration.ID.CHATTY_POCKET, CCRegistration.CHAT_BOX_POCKET.get(), + APBlocks.CHAT_BOX.get().asItem()).add(addUpgrade); + simpleWithCustomItem(CCRegistration.ID.PLAYER_POCKET, CCRegistration.PLAYER_DETECTOR_POCKET.get(), + APBlocks.PLAYER_DETECTOR.get().asItem()).add(addUpgrade); + simpleWithCustomItem(CCRegistration.ID.ENVIRONMENT_POCKET, CCRegistration.ENVIRONMENT_POCKET.get(), + APBlocks.ENVIRONMENT_DETECTOR.get().asItem()).add(addUpgrade); + simpleWithCustomItem(CCRegistration.ID.GEOSCANNER_POCKET, CCRegistration.GEO_SCANNER_POCKET.get(), + APBlocks.GEO_SCANNER.get().asItem()).add(addUpgrade); + simpleWithCustomItem(CCRegistration.ID.COLONY_POCKET, CCRegistration.COLONY_POCKET.get(), + APBlocks.COLONY_INTEGRATOR.get().asItem()).add(addUpgrade); } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/data/PoiTypeProvider.java b/src/main/java/de/srendi/advancedperipherals/common/data/PoiTypeProvider.java index f2f22b7ab..607a2460e 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/data/PoiTypeProvider.java +++ b/src/main/java/de/srendi/advancedperipherals/common/data/PoiTypeProvider.java @@ -1,7 +1,21 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.data; import de.srendi.advancedperipherals.AdvancedPeripherals; - import de.srendi.advancedperipherals.common.setup.APRegistration; import net.minecraft.data.DataGenerator; import net.minecraft.data.tags.PoiTypeTagsProvider; @@ -25,8 +39,7 @@ protected void addTags() { APRegistration.POI_TYPES.getEntries().stream().map(RegistryObject::getKey).forEach(appender::add); } - @NotNull - @Override + @NotNull @Override public String getName() { return "AP POI Type Tags"; } diff --git a/src/main/java/de/srendi/advancedperipherals/common/data/RecipesProvider.java b/src/main/java/de/srendi/advancedperipherals/common/data/RecipesProvider.java index 58321dbd2..1683d9778 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/data/RecipesProvider.java +++ b/src/main/java/de/srendi/advancedperipherals/common/data/RecipesProvider.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.data; import appeng.core.definitions.AEBlocks; @@ -9,7 +24,11 @@ import de.srendi.advancedperipherals.common.setup.APItems; import de.srendi.advancedperipherals.common.util.RawValue; import net.minecraft.data.DataGenerator; -import net.minecraft.data.recipes.*; +import net.minecraft.data.recipes.FinishedRecipe; +import net.minecraft.data.recipes.RecipeProvider; +import net.minecraft.data.recipes.ShapedRecipeBuilder; +import net.minecraft.data.recipes.ShapelessRecipeBuilder; +import net.minecraft.data.recipes.UpgradeRecipeBuilder; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.ItemTags; import net.minecraft.world.item.ItemStack; @@ -45,238 +64,121 @@ protected void buildCraftingRecipes(@NotNull Consumer consumer) private void addShapeless(@NotNull Consumer consumer) { ShapelessRecipeBuilder.shapeless(APItems.OVERPOWERED_WEAK_AUTOMATA_CORE.get()) - .requires(APItems.WEAK_AUTOMATA_CORE.get()) - .requires(Items.NETHER_STAR) - .unlockedBy(HAS_ITEM, has(APItems.WEAK_AUTOMATA_CORE.get())) - .save(consumer); + .requires(APItems.WEAK_AUTOMATA_CORE.get()).requires(Items.NETHER_STAR) + .unlockedBy(HAS_ITEM, has(APItems.WEAK_AUTOMATA_CORE.get())).save(consumer); ShapelessRecipeBuilder.shapeless(APItems.OVERPOWERED_END_AUTOMATA_CORE.get()) - .requires(APItems.END_AUTOMATA_CORE.get()) - .requires(Items.NETHER_STAR) - .unlockedBy(HAS_ITEM, has(APItems.END_AUTOMATA_CORE.get())) - .save(consumer); + .requires(APItems.END_AUTOMATA_CORE.get()).requires(Items.NETHER_STAR) + .unlockedBy(HAS_ITEM, has(APItems.END_AUTOMATA_CORE.get())).save(consumer); ShapelessRecipeBuilder.shapeless(APItems.OVERPOWERED_HUSBANDRY_AUTOMATA_CORE.get()) - .requires(APItems.HUSBANDRY_AUTOMATA_CORE.get()) - .requires(Items.NETHER_STAR) - .unlockedBy(HAS_ITEM, has(APItems.HUSBANDRY_AUTOMATA_CORE.get())) - .save(consumer); + .requires(APItems.HUSBANDRY_AUTOMATA_CORE.get()).requires(Items.NETHER_STAR) + .unlockedBy(HAS_ITEM, has(APItems.HUSBANDRY_AUTOMATA_CORE.get())).save(consumer); } private void addShaped(@NotNull Consumer consumer) { - /*ShapedRecipeBuilder.shaped(APItems.AR_GOGGLES.get()) - .define('E', Tags.Items.ENDER_PEARLS) - .define('S', Tags.Items.RODS_WOODEN) - .define('G', Tags.Items.GLASS_BLACK) - .pattern("GSG") - .pattern(" E ") - .unlockedBy(HAS_ITEM, has(Items.STICK)) - .save(consumer); - */ - - ShapedRecipeBuilder.shaped(APBlocks.CHAT_BOX.get()) - .define('P', ItemTags.LOGS) - .define('A', CASING) - .define('G', Tags.Items.INGOTS_GOLD) - .pattern("PPP") - .pattern("PAP") - .pattern("PGP") - .unlockedBy(HAS_ITEM, has(CASING)) - .save(consumer); - - ShapedRecipeBuilder.shaped(APItems.CHUNK_CONTROLLER.get()) - .define('I', Tags.Items.INGOTS_IRON) - .define('R', Tags.Items.DUSTS_REDSTONE) - .define('A', Items.ENDER_EYE) - .pattern("IRI") - .pattern("RAR") - .pattern("IRI") - .unlockedBy(HAS_ITEM, has(Items.RESPAWN_ANCHOR)) - .save(consumer); - - ShapedRecipeBuilder.shaped(APItems.COMPUTER_TOOL.get()) - .define('I', Tags.Items.INGOTS_IRON) - .define('B', Items.BLUE_TERRACOTTA) - .pattern("I I") - .pattern("IBI") - .pattern(" B ") - .unlockedBy(HAS_ITEM, has(Items.BLUE_TERRACOTTA)) - .save(consumer); - - ShapedRecipeBuilder.shaped(APBlocks.ENERGY_DETECTOR.get()) - .define('B', Tags.Items.STORAGE_BLOCKS_REDSTONE) - .define('R', Items.REDSTONE_TORCH) - .define('C', Items.COMPARATOR) - .define('A', CASING) - .define('G', Tags.Items.INGOTS_GOLD) - .pattern("BRB") - .pattern("CAC") - .pattern("BGB") - .unlockedBy(HAS_ITEM, has(CASING)) - .save(consumer); - - ShapedRecipeBuilder.shaped(APBlocks.ENVIRONMENT_DETECTOR.get()) - .define('W', ItemTags.WOOL) - .define('S', ItemTags.SAPLINGS) - .define('C', Tags.Items.CROPS) - .define('A', CASING) - .define('L', ItemTags.LEAVES) - .pattern("WSW") - .pattern("LAL") - .pattern("WCW") - .unlockedBy(HAS_ITEM, has(CASING)) - .save(consumer); - - ShapedRecipeBuilder.shaped(APBlocks.INVENTORY_MANAGER.get()) - .define('I', Tags.Items.INGOTS_IRON) - .define('C', Tags.Items.CHESTS) - .define('A', CASING) - .pattern("ICI") - .pattern("CAC") - .pattern("ICI") - .unlockedBy(HAS_ITEM, has(CASING)) - .save(consumer); - - ShapedRecipeBuilder.shaped(APItems.MEMORY_CARD.get()) - .define('I', Tags.Items.INGOTS_IRON) - .define('W', Tags.Items.GLASS_WHITE) - .define('O', Items.OBSERVER) - .define('G', Tags.Items.INGOTS_GOLD) - .pattern("IWI") - .pattern("IOI") - .pattern(" G ") - .unlockedBy(HAS_ITEM, has(Items.OBSERVER)) - .save(consumer); - - ShapedRecipeBuilder.shaped(APBlocks.PERIPHERAL_CASING.get()) - .define('I', Tags.Items.INGOTS_IRON) - .define('i', Items.IRON_BARS) - .define('R', Tags.Items.STORAGE_BLOCKS_REDSTONE) - .pattern("IiI") - .pattern("iRi") - .pattern("IiI") - .unlockedBy(HAS_ITEM, has(Items.REDSTONE_BLOCK)) - .save(consumer); - - ShapedRecipeBuilder.shaped(APBlocks.PLAYER_DETECTOR.get()) - .define('S', Items.SMOOTH_STONE) - .define('A', CASING) - .define('R', Tags.Items.STORAGE_BLOCKS_REDSTONE) - .pattern("SSS") - .pattern("SAS") - .pattern("SRS") - .unlockedBy(HAS_ITEM, has(CASING)) - .save(consumer); - - ShapedRecipeBuilder.shaped(APBlocks.REDSTONE_INTEGRATOR.get()) - .define('R', Tags.Items.STORAGE_BLOCKS_REDSTONE) - .define('A', CASING) - .define('C', Items.COMPARATOR) - .pattern("RCR") - .pattern("CAC") - .pattern("RCR") - .unlockedBy(HAS_ITEM, has(CASING)) - .save(consumer); - - ShapedRecipeBuilder.shaped(APBlocks.BLOCK_READER.get()) - .define('O', Items.OBSERVER) - .define('I', Tags.Items.INGOTS_IRON) - .define('M', Registry.ModBlocks.WIRED_MODEM_FULL.get()) - .define('R', Tags.Items.STORAGE_BLOCKS_REDSTONE) - .define('A', CASING) - .pattern("IRI") - .pattern("MAO") - .pattern("IRI") - .unlockedBy(HAS_ITEM, has(CASING)) - .save(consumer); - - ShapedRecipeBuilder.shaped(APBlocks.GEO_SCANNER.get()) - .define('O', Items.OBSERVER) - .define('D', Tags.Items.GEMS_DIAMOND) - .define('C', CASING) - .define('R', Tags.Items.STORAGE_BLOCKS_REDSTONE) - .define('M', Registry.ModBlocks.WIRED_MODEM_FULL.get()) - .pattern("DMD") - .pattern("DCD") - .pattern("ROR") - .unlockedBy(HAS_ITEM, has(CASING)) - .save(consumer); - - ShapedRecipeBuilder.shaped(APBlocks.NBT_STORAGE.get()) - .define('C', Tags.Items.CHESTS) - .define('A', CASING) - .define('R', Tags.Items.STORAGE_BLOCKS_REDSTONE) - .define('I', Tags.Items.INGOTS_IRON) - .pattern("ICI") - .pattern("CAC") - .pattern("RCR") - .unlockedBy(HAS_ITEM, has(CASING)) - .save(consumer); - - ConditionalRecipe.builder() - .addCondition( - modLoaded("minecolonies") - ) + /* + * ShapedRecipeBuilder.shaped(APItems.AR_GOGGLES.get()) .define('E', + * Tags.Items.ENDER_PEARLS) .define('S', Tags.Items.RODS_WOODEN) .define('G', + * Tags.Items.GLASS_BLACK) .pattern("GSG") .pattern(" E ") .unlockedBy(HAS_ITEM, + * has(Items.STICK)) .save(consumer); + */ + + ShapedRecipeBuilder.shaped(APBlocks.CHAT_BOX.get()).define('P', ItemTags.LOGS).define('A', CASING) + .define('G', Tags.Items.INGOTS_GOLD).pattern("PPP").pattern("PAP").pattern("PGP") + .unlockedBy(HAS_ITEM, has(CASING)).save(consumer); + + ShapedRecipeBuilder.shaped(APItems.CHUNK_CONTROLLER.get()).define('I', Tags.Items.INGOTS_IRON) + .define('R', Tags.Items.DUSTS_REDSTONE).define('A', Items.ENDER_EYE).pattern("IRI").pattern("RAR") + .pattern("IRI").unlockedBy(HAS_ITEM, has(Items.RESPAWN_ANCHOR)).save(consumer); + + ShapedRecipeBuilder.shaped(APItems.COMPUTER_TOOL.get()).define('I', Tags.Items.INGOTS_IRON) + .define('B', Items.BLUE_TERRACOTTA).pattern("I I").pattern("IBI").pattern(" B ") + .unlockedBy(HAS_ITEM, has(Items.BLUE_TERRACOTTA)).save(consumer); + + ShapedRecipeBuilder.shaped(APBlocks.ENERGY_DETECTOR.get()).define('B', Tags.Items.STORAGE_BLOCKS_REDSTONE) + .define('R', Items.REDSTONE_TORCH).define('C', Items.COMPARATOR).define('A', CASING) + .define('G', Tags.Items.INGOTS_GOLD).pattern("BRB").pattern("CAC").pattern("BGB") + .unlockedBy(HAS_ITEM, has(CASING)).save(consumer); + + ShapedRecipeBuilder.shaped(APBlocks.ENVIRONMENT_DETECTOR.get()).define('W', ItemTags.WOOL) + .define('S', ItemTags.SAPLINGS).define('C', Tags.Items.CROPS).define('A', CASING) + .define('L', ItemTags.LEAVES).pattern("WSW").pattern("LAL").pattern("WCW") + .unlockedBy(HAS_ITEM, has(CASING)).save(consumer); + + ShapedRecipeBuilder.shaped(APBlocks.INVENTORY_MANAGER.get()).define('I', Tags.Items.INGOTS_IRON) + .define('C', Tags.Items.CHESTS).define('A', CASING).pattern("ICI").pattern("CAC").pattern("ICI") + .unlockedBy(HAS_ITEM, has(CASING)).save(consumer); + + ShapedRecipeBuilder.shaped(APItems.MEMORY_CARD.get()).define('I', Tags.Items.INGOTS_IRON) + .define('W', Tags.Items.GLASS_WHITE).define('O', Items.OBSERVER).define('G', Tags.Items.INGOTS_GOLD) + .pattern("IWI").pattern("IOI").pattern(" G ").unlockedBy(HAS_ITEM, has(Items.OBSERVER)).save(consumer); + + ShapedRecipeBuilder.shaped(APBlocks.PERIPHERAL_CASING.get()).define('I', Tags.Items.INGOTS_IRON) + .define('i', Items.IRON_BARS).define('R', Tags.Items.STORAGE_BLOCKS_REDSTONE).pattern("IiI") + .pattern("iRi").pattern("IiI").unlockedBy(HAS_ITEM, has(Items.REDSTONE_BLOCK)).save(consumer); + + ShapedRecipeBuilder.shaped(APBlocks.PLAYER_DETECTOR.get()).define('S', Items.SMOOTH_STONE).define('A', CASING) + .define('R', Tags.Items.STORAGE_BLOCKS_REDSTONE).pattern("SSS").pattern("SAS").pattern("SRS") + .unlockedBy(HAS_ITEM, has(CASING)).save(consumer); + + ShapedRecipeBuilder.shaped(APBlocks.REDSTONE_INTEGRATOR.get()).define('R', Tags.Items.STORAGE_BLOCKS_REDSTONE) + .define('A', CASING).define('C', Items.COMPARATOR).pattern("RCR").pattern("CAC").pattern("RCR") + .unlockedBy(HAS_ITEM, has(CASING)).save(consumer); + + ShapedRecipeBuilder.shaped(APBlocks.BLOCK_READER.get()).define('O', Items.OBSERVER) + .define('I', Tags.Items.INGOTS_IRON).define('M', Registry.ModBlocks.WIRED_MODEM_FULL.get()) + .define('R', Tags.Items.STORAGE_BLOCKS_REDSTONE).define('A', CASING).pattern("IRI").pattern("MAO") + .pattern("IRI").unlockedBy(HAS_ITEM, has(CASING)).save(consumer); + + ShapedRecipeBuilder.shaped(APBlocks.GEO_SCANNER.get()).define('O', Items.OBSERVER) + .define('D', Tags.Items.GEMS_DIAMOND).define('C', CASING) + .define('R', Tags.Items.STORAGE_BLOCKS_REDSTONE).define('M', Registry.ModBlocks.WIRED_MODEM_FULL.get()) + .pattern("DMD").pattern("DCD").pattern("ROR").unlockedBy(HAS_ITEM, has(CASING)).save(consumer); + + ShapedRecipeBuilder.shaped(APBlocks.NBT_STORAGE.get()).define('C', Tags.Items.CHESTS).define('A', CASING) + .define('R', Tags.Items.STORAGE_BLOCKS_REDSTONE).define('I', Tags.Items.INGOTS_IRON).pattern("ICI") + .pattern("CAC").pattern("RCR").unlockedBy(HAS_ITEM, has(CASING)).save(consumer); + + ConditionalRecipe.builder().addCondition(modLoaded("minecolonies")).addRecipe(ShapedRecipeBuilder + .shaped(APBlocks.COLONY_INTEGRATOR.get()).define('O', ItemTags.LOGS).define('A', CASING) + .define('R', + Ingredient.fromValues( + Stream.of(new RawValue(new ResourceLocation("minecolonies", "blockminecoloniesrack"))))) + .pattern("ORO").pattern(" A ").pattern("ORO").unlockedBy(HAS_ITEM, has(CASING))::save) + .build(consumer, new ResourceLocation(AdvancedPeripherals.MOD_ID, "colony_integrator")); + + ConditionalRecipe.builder().addCondition(modLoaded("ae2")) .addRecipe( - ShapedRecipeBuilder.shaped(APBlocks.COLONY_INTEGRATOR.get()) - .define('O', ItemTags.LOGS) - .define('A', CASING) - .define('R', Ingredient.fromValues(Stream.of(new RawValue(new ResourceLocation("minecolonies", "blockminecoloniesrack"))))) - .pattern("ORO") - .pattern(" A ") - .pattern("ORO") - .unlockedBy(HAS_ITEM, has(CASING))::save - ).build(consumer, new ResourceLocation(AdvancedPeripherals.MOD_ID, "colony_integrator")); - - ConditionalRecipe.builder() - .addCondition( - modLoaded("ae2") - ) - .addRecipe( - ShapedRecipeBuilder.shaped(APBlocks.ME_BRIDGE.get()) - .define('F', AEBlocks.FLUIX_BLOCK.asItem()) - .define('A', CASING) - .define('I', AEBlocks.INTERFACE.asItem()) - .pattern("FIF") - .pattern("IAI") - .pattern("FIF") - .unlockedBy(HAS_ITEM, has(CASING))::save - ).build(consumer, new ResourceLocation(AdvancedPeripherals.MOD_ID, "me_bridge")); - - ConditionalRecipe.builder() - .addCondition( - modLoaded("refinedstorage") - ) - .addRecipe( - ShapedRecipeBuilder.shaped(APBlocks.RS_BRIDGE.get()) - .define('Q', RSItems.QUARTZ_ENRICHED_IRON.get()) - .define('A', CASING) - .define('I', RSBlocks.INTERFACE.get()) - .pattern("QIQ") - .pattern("IAI") - .pattern("QIQ") - .unlockedBy(HAS_ITEM, has(CASING))::save - ).build(consumer, new ResourceLocation(AdvancedPeripherals.MOD_ID, "rs_bridge")); - - ShapedRecipeBuilder.shaped(APItems.WEAK_AUTOMATA_CORE.get()) - .define('A', CASING) - .define('R', Tags.Items.STORAGE_BLOCKS_REDSTONE) - .define('S', Items.SOUL_LANTERN) + ShapedRecipeBuilder.shaped(APBlocks.ME_BRIDGE.get()).define('F', AEBlocks.FLUIX_BLOCK.asItem()) + .define('A', CASING).define('I', AEBlocks.INTERFACE.asItem()).pattern("FIF") + .pattern("IAI").pattern("FIF").unlockedBy(HAS_ITEM, has(CASING))::save) + .build(consumer, new ResourceLocation(AdvancedPeripherals.MOD_ID, "me_bridge")); + + ConditionalRecipe.builder().addCondition(modLoaded("refinedstorage")) + .addRecipe(ShapedRecipeBuilder.shaped(APBlocks.RS_BRIDGE.get()) + .define('Q', RSItems.QUARTZ_ENRICHED_IRON.get()).define('A', CASING) + .define('I', RSBlocks.INTERFACE.get()).pattern("QIQ").pattern("IAI").pattern("QIQ") + .unlockedBy(HAS_ITEM, has(CASING))::save) + .build(consumer, new ResourceLocation(AdvancedPeripherals.MOD_ID, "rs_bridge")); + + ShapedRecipeBuilder.shaped(APItems.WEAK_AUTOMATA_CORE.get()).define('A', CASING) + .define('R', Tags.Items.STORAGE_BLOCKS_REDSTONE).define('S', Items.SOUL_LANTERN) .define('D', Tags.Items.GEMS_DIAMOND) - .define('L', StrictNBTIngredient.of(PotionUtils.setPotion(new ItemStack(Items.POTION), Potions.LONG_REGENERATION))) - .pattern("RAR") - .pattern("DSD") - .pattern("RLR") - .unlockedBy(HAS_ITEM, has(CASING)) - .save(consumer); + .define('L', + StrictNBTIngredient + .of(PotionUtils.setPotion(new ItemStack(Items.POTION), Potions.LONG_REGENERATION))) + .pattern("RAR").pattern("DSD").pattern("RLR").unlockedBy(HAS_ITEM, has(CASING)).save(consumer); } private void addSmithing(@NotNull Consumer consumer) { UpgradeRecipeBuilder - .smithing(Ingredient.of(APItems.SMART_GLASSES.get()), Ingredient.of(Items.NETHERITE_INGOT), APItems.SMART_GLASSES_NETHERITE.get()) + .smithing(Ingredient.of(APItems.SMART_GLASSES.get()), Ingredient.of(Items.NETHERITE_INGOT), + APItems.SMART_GLASSES_NETHERITE.get()) .unlocks("has_item", has(Items.NETHERITE_INGOT)) - .save(consumer, new ResourceLocation(AdvancedPeripherals.MOD_ID, "armor/" + APItems.SMART_GLASSES_NETHERITE.getKey().location().getPath())); + .save(consumer, new ResourceLocation(AdvancedPeripherals.MOD_ID, + "armor/" + APItems.SMART_GLASSES_NETHERITE.getKey().location().getPath())); } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/data/TurtleUpgradesProvider.java b/src/main/java/de/srendi/advancedperipherals/common/data/TurtleUpgradesProvider.java index 70ec6c177..cef4679d8 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/data/TurtleUpgradesProvider.java +++ b/src/main/java/de/srendi/advancedperipherals/common/data/TurtleUpgradesProvider.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.data; import dan200.computercraft.api.turtle.TurtleUpgradeDataProvider; @@ -18,18 +33,30 @@ public TurtleUpgradesProvider(DataGenerator generator) { @Override protected void addUpgrades(@NotNull Consumer>> addUpgrade) { - simpleWithCustomItem(CCRegistration.ID.CHATTY_TURTLE, CCRegistration.CHAT_BOX_TURTLE.get(), APBlocks.CHAT_BOX.get().asItem()).add(addUpgrade); - simpleWithCustomItem(CCRegistration.ID.PLAYER_TURTLE, CCRegistration.PLAYER_DETECTOR_TURTLE.get(), APBlocks.PLAYER_DETECTOR.get().asItem()).add(addUpgrade); - simpleWithCustomItem(CCRegistration.ID.ENVIRONMENT_TURTLE, CCRegistration.ENVIRONMENT_TURTLE.get(), APBlocks.ENVIRONMENT_DETECTOR.get().asItem()).add(addUpgrade); - simpleWithCustomItem(CCRegistration.ID.CHUNKY_TURTLE, CCRegistration.CHUNKY_TURTLE.get(), APItems.CHUNK_CONTROLLER.get()).add(addUpgrade); - simpleWithCustomItem(CCRegistration.ID.GEOSCANNER_TURTLE, CCRegistration.GEO_SCANNER_TURTLE.get(), APBlocks.GEO_SCANNER.get().asItem()).add(addUpgrade); - simpleWithCustomItem(CCRegistration.ID.COMPASS_TURTLE, CCRegistration.COMPASS_TURTLE.get(), net.minecraft.world.item.Items.COMPASS).add(addUpgrade); - simpleWithCustomItem(CCRegistration.ID.WEAK_AUTOMATA, CCRegistration.WEAK_TURTLE.get(), APItems.WEAK_AUTOMATA_CORE.get()).add(addUpgrade); - simpleWithCustomItem(CCRegistration.ID.END_AUTOMATA, CCRegistration.END_TURTLE.get(), APItems.END_AUTOMATA_CORE.get()).add(addUpgrade); - simpleWithCustomItem(CCRegistration.ID.HUSBANDRY_AUTOMATA, CCRegistration.HUSBANDRY_TURTLE.get(), APItems.HUSBANDRY_AUTOMATA_CORE.get()).add(addUpgrade); - simpleWithCustomItem(CCRegistration.ID.OP_WEAK_AUTOMATA, CCRegistration.OP_WEAK_TURTLE.get(), APItems.OVERPOWERED_WEAK_AUTOMATA_CORE.get()).add(addUpgrade); - simpleWithCustomItem(CCRegistration.ID.OP_END_AUTOMATA, CCRegistration.OP_END_TURTLE.get(), APItems.OVERPOWERED_END_AUTOMATA_CORE.get()).add(addUpgrade); - simpleWithCustomItem(CCRegistration.ID.OP_HUSBANDRY_AUTOMATA, CCRegistration.OP_HUSBANDRY_TURTLE.get(), APItems.OVERPOWERED_HUSBANDRY_AUTOMATA_CORE.get()).add(addUpgrade); + simpleWithCustomItem(CCRegistration.ID.CHATTY_TURTLE, CCRegistration.CHAT_BOX_TURTLE.get(), + APBlocks.CHAT_BOX.get().asItem()).add(addUpgrade); + simpleWithCustomItem(CCRegistration.ID.PLAYER_TURTLE, CCRegistration.PLAYER_DETECTOR_TURTLE.get(), + APBlocks.PLAYER_DETECTOR.get().asItem()).add(addUpgrade); + simpleWithCustomItem(CCRegistration.ID.ENVIRONMENT_TURTLE, CCRegistration.ENVIRONMENT_TURTLE.get(), + APBlocks.ENVIRONMENT_DETECTOR.get().asItem()).add(addUpgrade); + simpleWithCustomItem(CCRegistration.ID.CHUNKY_TURTLE, CCRegistration.CHUNKY_TURTLE.get(), + APItems.CHUNK_CONTROLLER.get()).add(addUpgrade); + simpleWithCustomItem(CCRegistration.ID.GEOSCANNER_TURTLE, CCRegistration.GEO_SCANNER_TURTLE.get(), + APBlocks.GEO_SCANNER.get().asItem()).add(addUpgrade); + simpleWithCustomItem(CCRegistration.ID.COMPASS_TURTLE, CCRegistration.COMPASS_TURTLE.get(), + net.minecraft.world.item.Items.COMPASS).add(addUpgrade); + simpleWithCustomItem(CCRegistration.ID.WEAK_AUTOMATA, CCRegistration.WEAK_TURTLE.get(), + APItems.WEAK_AUTOMATA_CORE.get()).add(addUpgrade); + simpleWithCustomItem(CCRegistration.ID.END_AUTOMATA, CCRegistration.END_TURTLE.get(), + APItems.END_AUTOMATA_CORE.get()).add(addUpgrade); + simpleWithCustomItem(CCRegistration.ID.HUSBANDRY_AUTOMATA, CCRegistration.HUSBANDRY_TURTLE.get(), + APItems.HUSBANDRY_AUTOMATA_CORE.get()).add(addUpgrade); + simpleWithCustomItem(CCRegistration.ID.OP_WEAK_AUTOMATA, CCRegistration.OP_WEAK_TURTLE.get(), + APItems.OVERPOWERED_WEAK_AUTOMATA_CORE.get()).add(addUpgrade); + simpleWithCustomItem(CCRegistration.ID.OP_END_AUTOMATA, CCRegistration.OP_END_TURTLE.get(), + APItems.OVERPOWERED_END_AUTOMATA_CORE.get()).add(addUpgrade); + simpleWithCustomItem(CCRegistration.ID.OP_HUSBANDRY_AUTOMATA, CCRegistration.OP_HUSBANDRY_TURTLE.get(), + APItems.OVERPOWERED_HUSBANDRY_AUTOMATA_CORE.get()).add(addUpgrade); } } 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 3faf3c754..61739b6d7 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/events/Events.java +++ b/src/main/java/de/srendi/advancedperipherals/common/events/Events.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.events; import com.google.common.collect.EvictingQueue; @@ -28,8 +43,10 @@ public class Events { private static final String PLAYED_BEFORE = "ap_played_before"; private static final int CHAT_QUEUE_MAX_SIZE = 50; private static final int PLAYER_QUEUE_MAX_SIZE = 50; - public static final EvictingQueue> messageQueue = EvictingQueue.create(CHAT_QUEUE_MAX_SIZE); - public static final EvictingQueue> playerMessageQueue = EvictingQueue.create(PLAYER_QUEUE_MAX_SIZE); + public static final EvictingQueue> messageQueue = EvictingQueue + .create(CHAT_QUEUE_MAX_SIZE); + public static final EvictingQueue> playerMessageQueue = EvictingQueue + .create(PLAYER_QUEUE_MAX_SIZE); private static long lastChatMessageID = 0; private static long lastPlayerMessageID = 0; @@ -39,7 +56,8 @@ public static void onWorldJoin(PlayerEvent.PlayerLoggedInEvent event) { if (APConfig.WORLD_CONFIG.givePlayerBookOnJoin.get()) { if (!hasPlayedBefore(player)) { - ItemStack book = new ItemStack(ForgeRegistries.ITEMS.getValue(new ResourceLocation("patchouli", "guide_book"))); + ItemStack book = new ItemStack( + ForgeRegistries.ITEMS.getValue(new ResourceLocation("patchouli", "guide_book"))); CompoundTag nbt = new CompoundTag(); nbt.putString("patchouli:book", "advancedperipherals:manual"); book.setTag(nbt); @@ -47,13 +65,15 @@ public static void onWorldJoin(PlayerEvent.PlayerLoggedInEvent event) { } } - putPlayerMessage(Pair.of(getLastPlayerMessageID(), new PlayerMessageObject("playerJoin", player.getName().getString(), player.getLevel().dimension().location().toString(), ""))); + putPlayerMessage(Pair.of(getLastPlayerMessageID(), new PlayerMessageObject("playerJoin", + player.getName().getString(), player.getLevel().dimension().location().toString(), ""))); } @SubscribeEvent public static void onWorldLeave(PlayerEvent.PlayerLoggedOutEvent event) { Player player = event.getEntity(); - putPlayerMessage(Pair.of(getLastPlayerMessageID(), new PlayerMessageObject("playerLeave", player.getName().getString(), player.getLevel().dimension().location().toString(), ""))); + putPlayerMessage(Pair.of(getLastPlayerMessageID(), new PlayerMessageObject("playerLeave", + player.getName().getString(), player.getLevel().dimension().location().toString(), ""))); } @SubscribeEvent @@ -62,7 +82,8 @@ public static void onPlayerChangeDimension(PlayerEvent.PlayerChangedDimensionEve String fromDim = event.getFrom().location().toString(); String toDim = event.getTo().location().toString(); - putPlayerMessage(Pair.of(getLastPlayerMessageID(), new PlayerMessageObject("playerChangedDimension", player.getName().getString(), fromDim, toDim))); + putPlayerMessage(Pair.of(getLastPlayerMessageID(), + new PlayerMessageObject("playerChangedDimension", player.getName().getString(), fromDim, toDim))); } @SubscribeEvent @@ -71,7 +92,8 @@ public static void onCommand(CommandEvent event) throws CommandSyntaxException { return; String username = "sayCommand"; String uuid = null; - String message = MessageArgument.getMessage(event.getParseResults().getContext().build("apChatEvent"), "message").getString(); + String message = MessageArgument + .getMessage(event.getParseResults().getContext().build("apChatEvent"), "message").getString(); boolean isHidden = false; CommandSourceStack source = event.getParseResults().getContext().getSource(); if (source.getEntity() != null) { @@ -103,7 +125,8 @@ public static void onChatBox(ServerChatEvent.Submitted event) { message = message.replace("$", ""); isHidden = true; } - putChatMessage(Pair.of(getLastChatMessageID(), new ChatMessageObject(event.getUsername(), message, event.getPlayer().getUUID().toString(), isHidden))); + putChatMessage(Pair.of(getLastChatMessageID(), new ChatMessageObject(event.getUsername(), message, + event.getPlayer().getUUID().toString(), isHidden))); } } @@ -117,7 +140,8 @@ public static synchronized void putPlayerMessage(Pair lastPlayerMessageID++; } - public static synchronized long traverseChatMessages(long lastConsumedMessage, Consumer consumer) { + public static synchronized long traverseChatMessages(long lastConsumedMessage, + Consumer consumer) { for (Pair message : messageQueue) { if (message.getLeft() <= lastConsumedMessage) continue; @@ -127,7 +151,8 @@ public static synchronized long traverseChatMessages(long lastConsumedMessage, C return lastConsumedMessage; } - public static synchronized long traversePlayerMessages(long lastConsumedMessage, Consumer consumer) { + public static synchronized long traversePlayerMessages(long lastConsumedMessage, + Consumer consumer) { for (Pair message : playerMessageQueue) { if (message.getLeft() <= lastConsumedMessage) continue; @@ -156,6 +181,8 @@ private static boolean hasPlayedBefore(Player player) { } } - public record ChatMessageObject(String username, String message, String uuid, boolean isHidden) {} - public record PlayerMessageObject(String eventName, String playerName, String fromDimension, String toDimension) {} + public record ChatMessageObject(String username, String message, String uuid, boolean isHidden) { + } + public record PlayerMessageObject(String eventName, String playerName, String fromDimension, String toDimension) { + } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/items/APBlockItem.java b/src/main/java/de/srendi/advancedperipherals/common/items/APBlockItem.java index fbfc664f9..ee2f8eea0 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/items/APBlockItem.java +++ b/src/main/java/de/srendi/advancedperipherals/common/items/APBlockItem.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.items; import de.srendi.advancedperipherals.common.items.base.BaseBlockItem; diff --git a/src/main/java/de/srendi/advancedperipherals/common/items/APItem.java b/src/main/java/de/srendi/advancedperipherals/common/items/APItem.java index 34ffcbeb5..787ce672e 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/items/APItem.java +++ b/src/main/java/de/srendi/advancedperipherals/common/items/APItem.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.items; import de.srendi.advancedperipherals.common.items.base.BaseItem; diff --git a/src/main/java/de/srendi/advancedperipherals/common/items/MemoryCardItem.java b/src/main/java/de/srendi/advancedperipherals/common/items/MemoryCardItem.java index 030862818..4ac2eaf75 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/items/MemoryCardItem.java +++ b/src/main/java/de/srendi/advancedperipherals/common/items/MemoryCardItem.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.items; import de.srendi.advancedperipherals.common.configuration.APConfig; @@ -29,7 +44,8 @@ public boolean isEnabled() { public void appendHoverText(ItemStack stack, @Nullable Level levelIn, List tooltip, TooltipFlag flagIn) { super.appendHoverText(stack, levelIn, tooltip, flagIn); if (stack.getOrCreateTag().contains("owner")) - tooltip.add(EnumColor.buildTextComponent(Component.translatable("item.advancedperipherals.tooltip.memory_card.bound", stack.getOrCreateTag().getString("owner")))); + tooltip.add(EnumColor.buildTextComponent(Component.translatable( + "item.advancedperipherals.tooltip.memory_card.bound", stack.getOrCreateTag().getString("owner")))); } diff --git a/src/main/java/de/srendi/advancedperipherals/common/items/SmartGlassesInterfaceItem.java b/src/main/java/de/srendi/advancedperipherals/common/items/SmartGlassesInterfaceItem.java index a030b25e3..1ec43e416 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/items/SmartGlassesInterfaceItem.java +++ b/src/main/java/de/srendi/advancedperipherals/common/items/SmartGlassesInterfaceItem.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.items; import dan200.computercraft.shared.network.container.ComputerContainerData; @@ -36,30 +51,38 @@ public InteractionResultHolder use(@NotNull Level world, @NotNull Pla ItemStack findGlasses = player.getItemBySlot(EquipmentSlot.HEAD); - // In case this method gets executed by the smart glasses interface, we need to check if the glasses may be in the + // In case this method gets executed by the smart glasses interface, we need to + // check if the glasses may be in the // curio slot or on the head if (!findGlasses.is(APItems.SMART_GLASSES.get())) { - if (APAddons.curiosLoaded) findGlasses = APAddons.getCurioGlasses(player); + if (APAddons.curiosLoaded) + findGlasses = APAddons.getCurioGlasses(player); if (!findGlasses.is(APItems.SMART_GLASSES.get())) { - player.displayClientMessage(Component.translatable("item.advancedperipherals.smartglasses.dontwear"), false); + player.displayClientMessage(Component.translatable("item.advancedperipherals.smartglasses.dontwear"), + false); return super.use(world, player, hand); } } - // The constructor of the ComputerContainerData in the lambda wants a final version of this var + // The constructor of the ComputerContainerData in the lambda wants a final + // version of this var ItemStack glasses = findGlasses; SmartGlassesItem smartGlasses = (SmartGlassesItem) glasses.getItem(); - SmartGlassesComputer computer = smartGlasses.getOrCreateComputer((ServerLevel) world, player, player.getInventory(), glasses); + SmartGlassesComputer computer = smartGlasses.getOrCreateComputer((ServerLevel) world, player, + player.getInventory(), glasses); computer.turnOn(); LazyOptional itemHandler = glasses.getCapability(ForgeCapabilities.ITEM_HANDLER); if (!itemHandler.isPresent() || itemHandler.resolve().isEmpty()) { - AdvancedPeripherals.debug("There was an issue with the item handler of the glasses while trying to open the gui"); + AdvancedPeripherals + .debug("There was an issue with the item handler of the glasses while trying to open the gui"); return super.use(world, player, hand); } - NetworkHooks.openScreen((ServerPlayer) player, new SmartGlassesMenuProvider(computer, glasses, itemHandler.resolve().get()), bytes -> new ComputerContainerData(computer, glasses).toBytes(bytes)); + NetworkHooks.openScreen((ServerPlayer) player, + new SmartGlassesMenuProvider(computer, glasses, itemHandler.resolve().get()), + bytes -> new ComputerContainerData(computer, glasses).toBytes(bytes)); return super.use(world, player, hand); } diff --git a/src/main/java/de/srendi/advancedperipherals/common/items/SmartGlassesItem.java b/src/main/java/de/srendi/advancedperipherals/common/items/SmartGlassesItem.java index 35ac3cbf7..842248dbe 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/items/SmartGlassesItem.java +++ b/src/main/java/de/srendi/advancedperipherals/common/items/SmartGlassesItem.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.items; import com.google.common.base.Objects; @@ -13,7 +28,11 @@ import dan200.computercraft.shared.network.container.ComputerContainerData; import dan200.computercraft.shared.util.IDAssigner; import de.srendi.advancedperipherals.AdvancedPeripherals; -import de.srendi.advancedperipherals.common.smartglasses.*; +import de.srendi.advancedperipherals.common.smartglasses.SmartGlassesAPI; +import de.srendi.advancedperipherals.common.smartglasses.SmartGlassesAccess; +import de.srendi.advancedperipherals.common.smartglasses.SmartGlassesComputer; +import de.srendi.advancedperipherals.common.smartglasses.SmartGlassesItemHandler; +import de.srendi.advancedperipherals.common.smartglasses.SmartGlassesMenuProvider; import de.srendi.advancedperipherals.common.smartglasses.modules.IModule; import de.srendi.advancedperipherals.common.smartglasses.modules.IModuleItem; import de.srendi.advancedperipherals.common.smartglasses.modules.ModulePeripheral; @@ -60,15 +79,14 @@ public SmartGlassesItem(ArmorMaterial material) { super(material, EquipmentSlot.HEAD, new Properties().stacksTo(1).tab(AdvancedPeripherals.TAB)); } - @Nullable - @Override + @Nullable @Override public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundTag nbt) { return new ICapabilityProvider() { - @NotNull - @Override + @NotNull @Override public LazyOptional getCapability(@NotNull Capability cap, @Nullable Direction side) { if (cap == ForgeCapabilities.ITEM_HANDLER) - return LazyOptional.of(() -> new SmartGlassesItemHandler(stack, getServerComputer(ServerLifecycleHooks.getCurrentServer(), stack))).cast(); + return LazyOptional.of(() -> new SmartGlassesItemHandler(stack, + getServerComputer(ServerLifecycleHooks.getCurrentServer(), stack))).cast(); return LazyOptional.empty(); } }; @@ -115,17 +133,19 @@ private boolean tick(ItemStack stack, Level world, Entity entity, SmartGlassesCo } @Override - public void inventoryTick(@NotNull ItemStack stack, @NotNull Level world, @NotNull Entity entity, int slotNum, boolean selected) { + public void inventoryTick(@NotNull ItemStack stack, @NotNull Level world, @NotNull Entity entity, int slotNum, + boolean selected) { LazyOptional itemHandler = stack.getCapability(ForgeCapabilities.ITEM_HANDLER); - if(itemHandler.isPresent()) { + if (itemHandler.isPresent()) { itemHandler.resolve().ifPresent(iItemHandler -> { - for(int slot = 0; slot < iItemHandler.getSlots(); slot++) { + for (int slot = 0; slot < iItemHandler.getSlots(); slot++) { ItemStack itemStack = iItemHandler.getStackInSlot(slot); - if(itemStack.getItem() instanceof IModuleItem iModuleItem) { + if (itemStack.getItem() instanceof IModuleItem iModuleItem) { SmartGlassesAccess glassesAccess = null; IModule module = null; if (!world.isClientSide) { - SmartGlassesComputer computer = getOrCreateComputer((ServerLevel) world, entity, entity instanceof Player player ? player.getInventory() : null, stack); + SmartGlassesComputer computer = getOrCreateComputer((ServerLevel) world, entity, + entity instanceof Player player ? player.getInventory() : null, stack); module = computer.getModules().get(slot); glassesAccess = computer.getSmartGlassesAccess(); } @@ -148,7 +168,8 @@ public void inventoryTick(@NotNull ItemStack stack, @NotNull Level world, @NotNu @Override public boolean onEntityItemUpdate(ItemStack stack, ItemEntity entity) { - if (entity.level.isClientSide || entity.level.getServer() == null) return false; + if (entity.level.isClientSide || entity.level.getServer() == null) + return false; SmartGlassesComputer computer = getServerComputer(entity.level.getServer(), stack); if (computer != null && tick(stack, entity.level, entity, computer)) @@ -156,21 +177,23 @@ public boolean onEntityItemUpdate(ItemStack stack, ItemEntity entity) { return false; } - @NotNull - @Override + @NotNull @Override public InteractionResultHolder use(Level world, Player player, @NotNull InteractionHand hand) { ItemStack glasses = player.getItemInHand(hand); if (!world.isClientSide) { - SmartGlassesComputer computer = getOrCreateComputer((ServerLevel) world, player, player.getInventory(), glasses); + SmartGlassesComputer computer = getOrCreateComputer((ServerLevel) world, player, player.getInventory(), + glasses); computer.turnOn(); LazyOptional itemHandler = glasses.getCapability(ForgeCapabilities.ITEM_HANDLER); if (!itemHandler.isPresent() || itemHandler.resolve().isEmpty()) { - AdvancedPeripherals.debug("There was an issue with the item handler of the glasses while trying to open the gui"); + AdvancedPeripherals + .debug("There was an issue with the item handler of the glasses while trying to open the gui"); return InteractionResultHolder.sidedSuccess(player.getItemInHand(hand), world.isClientSide); } - new ComputerContainerData(computer, glasses).open(player, new SmartGlassesMenuProvider(computer, glasses, itemHandler.resolve().get())); + new ComputerContainerData(computer, glasses).open(player, + new SmartGlassesMenuProvider(computer, glasses, itemHandler.resolve().get())); } return super.use(world, player, hand); } @@ -195,11 +218,13 @@ public ItemStack withFamily(ItemStack stack, ComputerFamily family) { } @Override - public void appendHoverText(@NotNull ItemStack stack, @Nullable Level world, @NotNull List list, TooltipFlag flag) { + public void appendHoverText(@NotNull ItemStack stack, @Nullable Level world, @NotNull List list, + TooltipFlag flag) { if (flag.isAdvanced() || getLabel(stack) == null) { int id = getComputerID(stack); if (id >= 0) { - list.add(Component.translatable("gui.computercraft.tooltip.computer_id", id).withStyle(ChatFormatting.GRAY)); + list.add(Component.translatable("gui.computercraft.tooltip.computer_id", id) + .withStyle(ChatFormatting.GRAY)); } } } @@ -209,7 +234,8 @@ public String getCreatorModId(ItemStack stack) { return AdvancedPeripherals.MOD_ID; } - public SmartGlassesComputer getOrCreateComputer(ServerLevel level, Entity entity, @Nullable Container inventory, ItemStack stack) { + public SmartGlassesComputer getOrCreateComputer(ServerLevel level, Entity entity, @Nullable Container inventory, + ItemStack stack) { int sessionID = getSessionID(stack); ServerComputerRegistry registry = ServerContext.get(level.getServer()).registry(); @@ -240,11 +266,11 @@ public SmartGlassesComputer getOrCreateComputer(ServerLevel level, Entity entity return computer; } - @Nullable - public static SmartGlassesComputer getServerComputer(MinecraftServer server, ItemStack stack) { + @Nullable public static SmartGlassesComputer getServerComputer(MinecraftServer server, ItemStack stack) { if (server == null) return null; - return (SmartGlassesComputer) ServerContext.get(server).registry().get(getSessionID(stack), getInstanceID(stack)); + return (SmartGlassesComputer) ServerContext.get(server).registry().get(getSessionID(stack), + getInstanceID(stack)); } // IComputerItem implementation @@ -252,8 +278,7 @@ protected static void setComputerID(ItemStack stack, int computerID) { stack.getOrCreateTag().putInt(NBT_ID, computerID); } - @Nullable - @Override + @Nullable @Override public String getLabel(ItemStack stack) { return IComputerItem.super.getLabel(stack); } @@ -268,8 +293,7 @@ public boolean setLabel(ItemStack stack, @Nullable String label) { return true; } - @Nullable - @Override + @Nullable @Override public IWritableMount createDataMount(@NotNull ItemStack stack, @NotNull Level level) { int id = getComputerID(stack); if (id >= 0) { diff --git a/src/main/java/de/srendi/advancedperipherals/common/items/WeakAutomataCore.java b/src/main/java/de/srendi/advancedperipherals/common/items/WeakAutomataCore.java index 0dd8b101f..64955836f 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/items/WeakAutomataCore.java +++ b/src/main/java/de/srendi/advancedperipherals/common/items/WeakAutomataCore.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.items; import de.srendi.advancedperipherals.common.configuration.APConfig; @@ -43,10 +58,12 @@ public class WeakAutomataCore extends BaseItem implements IFeedableAutomataCore husbandrySouls.put(ForgeRegistries.ENTITY_TYPES.getKey(EntityType.COW).toString(), 3); husbandrySouls.put(ForgeRegistries.ENTITY_TYPES.getKey(EntityType.SHEEP).toString(), 3); husbandrySouls.put(ForgeRegistries.ENTITY_TYPES.getKey(EntityType.CHICKEN).toString(), 3); - WeakAutomataCoreRecord husbandrySoulRecord = new WeakAutomataCoreRecord(husbandrySouls, APItems.HUSBANDRY_AUTOMATA_CORE.get()); + WeakAutomataCoreRecord husbandrySoulRecord = new WeakAutomataCoreRecord(husbandrySouls, + APItems.HUSBANDRY_AUTOMATA_CORE.get()); endSoulRecord.ingredients.keySet().forEach(entityType -> AUTOMATA_CORE_REGISTRY.put(entityType, endSoulRecord)); - husbandrySoulRecord.ingredients.keySet().forEach(entityType -> AUTOMATA_CORE_REGISTRY.put(entityType, husbandrySoulRecord)); + husbandrySoulRecord.ingredients.keySet() + .forEach(entityType -> AUTOMATA_CORE_REGISTRY.put(entityType, husbandrySoulRecord)); } public WeakAutomataCore(Properties properties) { @@ -66,15 +83,18 @@ public void appendHoverText(ItemStack stack, @Nullable Level worldIn, List { WeakAutomataCoreRecord record = AUTOMATA_CORE_REGISTRY.get(key); CompoundTag recordData = consumedData.getCompound(key); - tooltip.add(EnumColor.buildTextComponent(Component.literal(String.format("Consumed: %d/%d %s", recordData.getInt(CONSUMED_ENTITY_COUNT), record.getRequiredCount(key), recordData.getString(CONSUMED_ENTITY_NAME))))); + tooltip.add(EnumColor.buildTextComponent( + Component.literal(String.format("Consumed: %d/%d %s", recordData.getInt(CONSUMED_ENTITY_COUNT), + record.getRequiredCount(key), recordData.getString(CONSUMED_ENTITY_NAME))))); }); } @Override - @NotNull - public InteractionResult interactLivingEntity(@NotNull ItemStack stack, @NotNull Player player, @NotNull LivingEntity entity, @NotNull InteractionHand hand) { + @NotNull public InteractionResult interactLivingEntity(@NotNull ItemStack stack, @NotNull Player player, + @NotNull LivingEntity entity, @NotNull InteractionHand hand) { if (!(player instanceof FakePlayer)) { - player.displayClientMessage(Component.translatable("text.advancedperipherals.automata_core_feed_by_player"), true); + player.displayClientMessage(Component.translatable("text.advancedperipherals.automata_core_feed_by_player"), + true); return InteractionResult.FAIL; } String entityType = EntityType.getKey(entity.getType()).toString(); @@ -86,10 +106,12 @@ public InteractionResult interactLivingEntity(@NotNull ItemStack stack, @NotNull record = AUTOMATA_CORE_REGISTRY.get(entityType); } else { Optional anyKey = consumedData.getAllKeys().stream().findAny(); - if (!anyKey.isPresent()) return InteractionResult.PASS; + if (!anyKey.isPresent()) + return InteractionResult.PASS; record = AUTOMATA_CORE_REGISTRY.get(anyKey.get()); } - if (!record.isSuitable(entityType, consumedData)) return InteractionResult.PASS; + if (!record.isSuitable(entityType, consumedData)) + return InteractionResult.PASS; entity.remove(Entity.RemovalReason.KILLED); CompoundTag entityCompound = consumedData.getCompound(entityType); entityCompound.putInt(CONSUMED_ENTITY_COUNT, entityCompound.getInt(CONSUMED_ENTITY_COUNT) + 1); @@ -119,7 +141,9 @@ public boolean isSuitable(String entityType, CompoundTag consumedData) { } public boolean isFinished(CompoundTag consumedData) { - return ingredients.entrySet().stream().map(entry -> entry.getValue() == consumedData.getCompound(entry.getKey()).getInt(CONSUMED_ENTITY_COUNT)).reduce((a, b) -> a && b).orElse(true); + return ingredients.entrySet().stream().map( + entry -> entry.getValue() == consumedData.getCompound(entry.getKey()).getInt(CONSUMED_ENTITY_COUNT)) + .reduce((a, b) -> a && b).orElse(true); } } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/items/base/BaseBlockItem.java b/src/main/java/de/srendi/advancedperipherals/common/items/base/BaseBlockItem.java index 999618f26..496f93702 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/items/base/BaseBlockItem.java +++ b/src/main/java/de/srendi/advancedperipherals/common/items/base/BaseBlockItem.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.items.base; import de.srendi.advancedperipherals.AdvancedPeripherals; @@ -31,16 +46,20 @@ public BaseBlockItem(Block blockIn) { public void appendHoverText(ItemStack stack, @Nullable Level levelIn, List tooltip, TooltipFlag flagIn) { super.appendHoverText(stack, levelIn, tooltip, flagIn); if (!KeybindUtil.isKeyPressed(KeyBindings.DESCRIPTION_KEYBINDING)) { - tooltip.add(EnumColor.buildTextComponent(Component.translatable("item.advancedperipherals.tooltip.show_desc", KeyBindings.DESCRIPTION_KEYBINDING.getTranslatedKeyMessage()))); + tooltip.add( + EnumColor.buildTextComponent(Component.translatable("item.advancedperipherals.tooltip.show_desc", + KeyBindings.DESCRIPTION_KEYBINDING.getTranslatedKeyMessage()))); } else { tooltip.add(EnumColor.buildTextComponent(getDescription())); } if (!isEnabled()) - tooltip.add(EnumColor.buildTextComponent(Component.translatable("item.advancedperipherals.tooltip.disabled"))); + tooltip.add( + EnumColor.buildTextComponent(Component.translatable("item.advancedperipherals.tooltip.disabled"))); } public @NotNull Component getDescription() { - if (description == null) description = TranslationUtil.itemTooltip(getDescriptionId()); + if (description == null) + description = TranslationUtil.itemTooltip(getDescriptionId()); return description; } diff --git a/src/main/java/de/srendi/advancedperipherals/common/items/base/BaseItem.java b/src/main/java/de/srendi/advancedperipherals/common/items/base/BaseItem.java index bc95f02d1..1f3fddb4c 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/items/base/BaseItem.java +++ b/src/main/java/de/srendi/advancedperipherals/common/items/base/BaseItem.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.items.base; import de.srendi.advancedperipherals.AdvancedPeripherals; @@ -39,7 +54,8 @@ public InteractionResultHolder use(Level worldIn, Player playerIn, In if (this instanceof IInventoryItem inventoryItem) { ServerPlayer serverPlayerEntity = (ServerPlayer) playerIn; ItemStack stack = playerIn.getItemInHand(handIn); - NetworkHooks.openScreen(serverPlayerEntity, inventoryItem.createContainer(playerIn, stack), buf -> buf.writeItem(stack)); + NetworkHooks.openScreen(serverPlayerEntity, inventoryItem.createContainer(playerIn, stack), + buf -> buf.writeItem(stack)); } return super.use(worldIn, playerIn, handIn); } @@ -48,17 +64,20 @@ public InteractionResultHolder use(Level worldIn, Player playerIn, In public void appendHoverText(ItemStack stack, @Nullable Level worldIn, List tooltip, TooltipFlag flagIn) { super.appendHoverText(stack, worldIn, tooltip, flagIn); if (!KeybindUtil.isKeyPressed(KeyBindings.DESCRIPTION_KEYBINDING)) { - tooltip.add(EnumColor.buildTextComponent(Component.translatable("item.advancedperipherals.tooltip.show_desc", KeyBindings.DESCRIPTION_KEYBINDING.getTranslatedKeyMessage()))); + tooltip.add( + EnumColor.buildTextComponent(Component.translatable("item.advancedperipherals.tooltip.show_desc", + KeyBindings.DESCRIPTION_KEYBINDING.getTranslatedKeyMessage()))); } else { tooltip.add(EnumColor.buildTextComponent(getDescription())); } if (!isEnabled()) - tooltip.add(EnumColor.buildTextComponent(Component.translatable("item.advancedperipherals.tooltip.disabled"))); + tooltip.add( + EnumColor.buildTextComponent(Component.translatable("item.advancedperipherals.tooltip.disabled"))); } - public @NotNull Component getDescription() { - if (description == null) description = TranslationUtil.itemTooltip(getDescriptionId()); + if (description == null) + description = TranslationUtil.itemTooltip(getDescriptionId()); return description; } diff --git a/src/main/java/de/srendi/advancedperipherals/common/items/base/IInventoryItem.java b/src/main/java/de/srendi/advancedperipherals/common/items/base/IInventoryItem.java index 7d4ff67f6..a6cd61ca4 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/items/base/IInventoryItem.java +++ b/src/main/java/de/srendi/advancedperipherals/common/items/base/IInventoryItem.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.items.base; import net.minecraft.world.MenuProvider; diff --git a/src/main/java/de/srendi/advancedperipherals/common/items/base/SmartGlassesMaterials.java b/src/main/java/de/srendi/advancedperipherals/common/items/base/SmartGlassesMaterials.java index 071976e3e..99e36ef4a 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/items/base/SmartGlassesMaterials.java +++ b/src/main/java/de/srendi/advancedperipherals/common/items/base/SmartGlassesMaterials.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.items.base; import de.srendi.advancedperipherals.AdvancedPeripherals; @@ -12,8 +27,9 @@ public enum SmartGlassesMaterials implements ArmorMaterial { // We use the same name, so they use the same model texture - CHAIN("smart_glasses", 15, new int[]{1, 4, 5, 2}, 12, SoundEvents.ARMOR_EQUIP_CHAIN, 0.0F, 0.0F, Ingredient.of(Items.IRON_INGOT)), - NETHERITE("smart_glasses", 37, new int[]{3, 6, 8, 3}, 15, SoundEvents.ARMOR_EQUIP_NETHERITE, 3.0F, 0.1F, Ingredient.of(Items.NETHERITE_INGOT)); + CHAIN("smart_glasses", 15, new int[]{1, 4, 5, 2}, 12, SoundEvents.ARMOR_EQUIP_CHAIN, 0.0F, 0.0F, + Ingredient.of(Items.IRON_INGOT)), NETHERITE("smart_glasses", 37, new int[]{3, 6, 8, 3}, 15, + SoundEvents.ARMOR_EQUIP_NETHERITE, 3.0F, 0.1F, Ingredient.of(Items.NETHERITE_INGOT)); private static final int[] HEALTH_PER_SLOT = new int[]{13, 15, 16, 11}; private final String name; @@ -25,7 +41,8 @@ public enum SmartGlassesMaterials implements ArmorMaterial { private final float knockbackResistance; private final Ingredient repairIngredient; - SmartGlassesMaterials(String pName, int pDurabilityMultiplier, int[] pSlotProtections, int pEnchantmentValue, SoundEvent pSound, float pToughness, float pKnockbackResistance, Ingredient pRepairIngredient) { + SmartGlassesMaterials(String pName, int pDurabilityMultiplier, int[] pSlotProtections, int pEnchantmentValue, + SoundEvent pSound, float pToughness, float pKnockbackResistance, Ingredient pRepairIngredient) { this.name = pName; this.durabilityMultiplier = pDurabilityMultiplier; this.slotProtections = pSlotProtections; @@ -48,18 +65,15 @@ public int getEnchantmentValue() { return this.enchantmentValue; } - @NotNull - public SoundEvent getEquipSound() { + @NotNull public SoundEvent getEquipSound() { return this.sound; } - @NotNull - public Ingredient getRepairIngredient() { + @NotNull public Ingredient getRepairIngredient() { return this.repairIngredient; } - @NotNull - public String getName() { + @NotNull public String getName() { return AdvancedPeripherals.MOD_ID + ":" + this.name; } diff --git a/src/main/java/de/srendi/advancedperipherals/common/network/PacketHandler.java b/src/main/java/de/srendi/advancedperipherals/common/network/PacketHandler.java index 77bbd1fb9..d4897a474 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/network/PacketHandler.java +++ b/src/main/java/de/srendi/advancedperipherals/common/network/PacketHandler.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.network; import de.srendi.advancedperipherals.AdvancedPeripherals; @@ -26,9 +41,12 @@ public class PacketHandler { - private static final String PROTOCOL_VERSION = ModLoadingContext.get().getActiveContainer().getModInfo().getVersion().toString(); + private static final String PROTOCOL_VERSION = ModLoadingContext.get().getActiveContainer().getModInfo() + .getVersion().toString(); - public static final SimpleChannel CHANNEL = NetworkRegistry.newSimpleChannel(new ResourceLocation(AdvancedPeripherals.MOD_ID, "main_channel"), () -> PROTOCOL_VERSION, PROTOCOL_VERSION::equals, PROTOCOL_VERSION::equals); + public static final SimpleChannel CHANNEL = NetworkRegistry.newSimpleChannel( + new ResourceLocation(AdvancedPeripherals.MOD_ID, "main_channel"), () -> PROTOCOL_VERSION, + PROTOCOL_VERSION::equals, PROTOCOL_VERSION::equals); private static int index = 0; @@ -38,12 +56,16 @@ public static void init() { registerClientToServer(GlassesHotkeyPacket.class, GlassesHotkeyPacket::decode); } - public static void registerServerToClient(Class packet, Function decode) { - CHANNEL.registerMessage(index++, packet, IPacket::encode, decode, IPacket::handle, Optional.of(NetworkDirection.PLAY_TO_CLIENT)); + public static void registerServerToClient(Class packet, + Function decode) { + CHANNEL.registerMessage(index++, packet, IPacket::encode, decode, IPacket::handle, + Optional.of(NetworkDirection.PLAY_TO_CLIENT)); } - public static void registerClientToServer(Class packet, Function decode) { - CHANNEL.registerMessage(index++, packet, IPacket::encode, decode, IPacket::handle, Optional.of(NetworkDirection.PLAY_TO_SERVER)); + public static void registerClientToServer(Class packet, + Function decode) { + CHANNEL.registerMessage(index++, packet, IPacket::encode, decode, IPacket::handle, + Optional.of(NetworkDirection.PLAY_TO_SERVER)); } public static void sendToClient(Object packet, ServerPlayer player) { @@ -67,9 +89,11 @@ public static void sendToAll(Object packet) { public static void sendToAllTracking(Object packet, Level world, BlockPos pos) { if (world instanceof ServerLevel) { - ((ServerLevel) world).getChunkSource().chunkMap.getPlayers(new ChunkPos(pos), false).forEach(p -> sendTo(packet, p)); + ((ServerLevel) world).getChunkSource().chunkMap.getPlayers(new ChunkPos(pos), false) + .forEach(p -> sendTo(packet, p)); } else { - CHANNEL.send(PacketDistributor.TRACKING_CHUNK.with(() -> world.getChunk(pos.getX() >> 4, pos.getZ() >> 4)), packet); + CHANNEL.send(PacketDistributor.TRACKING_CHUNK.with(() -> world.getChunk(pos.getX() >> 4, pos.getZ() >> 4)), + packet); } } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/network/base/IPacket.java b/src/main/java/de/srendi/advancedperipherals/common/network/base/IPacket.java index 1374f5bff..33ae9aa2b 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/network/base/IPacket.java +++ b/src/main/java/de/srendi/advancedperipherals/common/network/base/IPacket.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.network.base; import net.minecraft.network.FriendlyByteBuf; diff --git a/src/main/java/de/srendi/advancedperipherals/common/network/toclient/DistanceDetectorSyncPacket.java b/src/main/java/de/srendi/advancedperipherals/common/network/toclient/DistanceDetectorSyncPacket.java index 484ec7520..d64831a04 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/network/toclient/DistanceDetectorSyncPacket.java +++ b/src/main/java/de/srendi/advancedperipherals/common/network/toclient/DistanceDetectorSyncPacket.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.network.toclient; import de.srendi.advancedperipherals.AdvancedPeripherals; @@ -35,8 +50,8 @@ public void handle(NetworkEvent.Context context) { BlockEntity tileEntity = level.getBlockEntity(position); if (tileEntity == null) { - AdvancedPeripherals.debug("Could not update distance detector at " + position + " in world " + world.location() - + " because the world or the tile entity couldn't be found. Ignoring it"); + AdvancedPeripherals.debug("Could not update distance detector at " + position + " in world " + + world.location() + " because the world or the tile entity couldn't be found. Ignoring it"); return; } if (tileEntity instanceof DistanceDetectorEntity detector) { @@ -54,6 +69,7 @@ public void encode(FriendlyByteBuf buffer) { } public static DistanceDetectorSyncPacket decode(FriendlyByteBuf buffer) { - return new DistanceDetectorSyncPacket(buffer.readBlockPos(), buffer.readResourceKey(Registry.DIMENSION_REGISTRY), buffer.readFloat(), buffer.readBoolean()); + return new DistanceDetectorSyncPacket(buffer.readBlockPos(), + buffer.readResourceKey(Registry.DIMENSION_REGISTRY), buffer.readFloat(), buffer.readBoolean()); } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/network/toclient/ToastToClientPacket.java b/src/main/java/de/srendi/advancedperipherals/common/network/toclient/ToastToClientPacket.java index 3536d9462..b301b7b8e 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/network/toclient/ToastToClientPacket.java +++ b/src/main/java/de/srendi/advancedperipherals/common/network/toclient/ToastToClientPacket.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.network.toclient; import de.srendi.advancedperipherals.AdvancedPeripherals; diff --git a/src/main/java/de/srendi/advancedperipherals/common/network/toserver/GlassesHotkeyPacket.java b/src/main/java/de/srendi/advancedperipherals/common/network/toserver/GlassesHotkeyPacket.java index c6f5506ed..3fce65041 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/network/toserver/GlassesHotkeyPacket.java +++ b/src/main/java/de/srendi/advancedperipherals/common/network/toserver/GlassesHotkeyPacket.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.network.toserver; import de.srendi.advancedperipherals.common.items.SmartGlassesItem; diff --git a/src/main/java/de/srendi/advancedperipherals/common/setup/APBlockEntityTypes.java b/src/main/java/de/srendi/advancedperipherals/common/setup/APBlockEntityTypes.java index ab760488c..5386162e4 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/setup/APBlockEntityTypes.java +++ b/src/main/java/de/srendi/advancedperipherals/common/setup/APBlockEntityTypes.java @@ -1,8 +1,37 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.setup; import com.google.common.collect.Sets; import de.srendi.advancedperipherals.common.addons.APAddons; -import de.srendi.advancedperipherals.common.blocks.blockentities.*; +import de.srendi.advancedperipherals.common.blocks.blockentities.BlockReaderEntity; +import de.srendi.advancedperipherals.common.blocks.blockentities.ChatBoxEntity; +import de.srendi.advancedperipherals.common.blocks.blockentities.ColonyIntegratorEntity; +import de.srendi.advancedperipherals.common.blocks.blockentities.DistanceDetectorEntity; +import de.srendi.advancedperipherals.common.blocks.blockentities.EnergyDetectorEntity; +import de.srendi.advancedperipherals.common.blocks.blockentities.EnvironmentDetectorEntity; +import de.srendi.advancedperipherals.common.blocks.blockentities.FluidDetectorEntity; +import de.srendi.advancedperipherals.common.blocks.blockentities.GasDetectorEntity; +import de.srendi.advancedperipherals.common.blocks.blockentities.GeoScannerEntity; +import de.srendi.advancedperipherals.common.blocks.blockentities.InventoryManagerEntity; +import de.srendi.advancedperipherals.common.blocks.blockentities.MeBridgeEntity; +import de.srendi.advancedperipherals.common.blocks.blockentities.NBTStorageEntity; +import de.srendi.advancedperipherals.common.blocks.blockentities.PlayerDetectorEntity; +import de.srendi.advancedperipherals.common.blocks.blockentities.RedstoneIntegratorEntity; +import de.srendi.advancedperipherals.common.blocks.blockentities.RsBridgeEntity; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraftforge.registries.RegistryObject; @@ -11,20 +40,54 @@ public class APBlockEntityTypes { protected static void register() { } - public static final RegistryObject> CHAT_BOX = APRegistration.TILE_ENTITIES.register("chat_box", () -> new BlockEntityType<>(ChatBoxEntity::new, Sets.newHashSet(APBlocks.CHAT_BOX.get()), null)); - public static final RegistryObject> ENVIRONMENT_DETECTOR = APRegistration.TILE_ENTITIES.register("environment_detector", () -> new BlockEntityType<>(EnvironmentDetectorEntity::new, Sets.newHashSet(APBlocks.ENVIRONMENT_DETECTOR.get()), null)); - public static final RegistryObject> PLAYER_DETECTOR = APRegistration.TILE_ENTITIES.register("player_detector", () -> new BlockEntityType<>(PlayerDetectorEntity::new, Sets.newHashSet(APBlocks.PLAYER_DETECTOR.get()), null)); - public static final RegistryObject> ME_BRIDGE = APAddons.appliedEnergisticsLoaded ? APRegistration.TILE_ENTITIES.register("me_bridge", () -> new BlockEntityType<>(MeBridgeEntity::new, Sets.newHashSet(APBlocks.ME_BRIDGE.get()), null)) : null; - public static final RegistryObject> RS_BRIDGE = APAddons.refinedStorageLoaded ? APRegistration.TILE_ENTITIES.register("rs_bridge", () -> new BlockEntityType<>(RsBridgeEntity::new, Sets.newHashSet(APBlocks.RS_BRIDGE.get()), null)) : null; - public static final RegistryObject> ENERGY_DETECTOR = APRegistration.TILE_ENTITIES.register("energy_detector", () -> new BlockEntityType<>(EnergyDetectorEntity::new, Sets.newHashSet(APBlocks.ENERGY_DETECTOR.get()), null)); - public static final RegistryObject> FLUID_DETECTOR = APRegistration.TILE_ENTITIES.register("fluid_detector", () -> new BlockEntityType<>(FluidDetectorEntity::new, Sets.newHashSet(APBlocks.FLUID_DETECTOR.get()), null)); - public static final RegistryObject> GAS_DETECTOR = APAddons.mekanismLoaded ? APRegistration.TILE_ENTITIES.register("gas_detector", () -> new BlockEntityType<>(GasDetectorEntity::new, Sets.newHashSet(APBlocks.GAS_DETECTOR.get()), null)) : null; - public static final RegistryObject> INVENTORY_MANAGER = APRegistration.TILE_ENTITIES.register("inventory_manager", () -> new BlockEntityType<>(InventoryManagerEntity::new, Sets.newHashSet(APBlocks.INVENTORY_MANAGER.get()), null)); - public static final RegistryObject> REDSTONE_INTEGRATOR = APRegistration.TILE_ENTITIES.register("redstone_integrator", () -> new BlockEntityType<>(RedstoneIntegratorEntity::new, Sets.newHashSet(APBlocks.REDSTONE_INTEGRATOR.get()), null)); - public static final RegistryObject> BLOCK_READER = APRegistration.TILE_ENTITIES.register("block_reader", () -> new BlockEntityType<>(BlockReaderEntity::new, Sets.newHashSet(APBlocks.BLOCK_READER.get()), null)); - public static final RegistryObject> GEO_SCANNER = APRegistration.TILE_ENTITIES.register("geo_scanner", () -> new BlockEntityType<>(GeoScannerEntity::new, Sets.newHashSet(APBlocks.GEO_SCANNER.get()), null)); - public static final RegistryObject> COLONY_INTEGRATOR = APRegistration.TILE_ENTITIES.register("colony_integrator", () -> new BlockEntityType<>(ColonyIntegratorEntity::new, Sets.newHashSet(APBlocks.COLONY_INTEGRATOR.get()), null)); - public static final RegistryObject> NBT_STORAGE = APRegistration.TILE_ENTITIES.register("nbt_storage", () -> new BlockEntityType<>(NBTStorageEntity::new, Sets.newHashSet(APBlocks.NBT_STORAGE.get()), null)); - public static final RegistryObject> DISTANCE_DETECTOR = APRegistration.TILE_ENTITIES.register("distance_detector", () -> new BlockEntityType<>(DistanceDetectorEntity::new, Sets.newHashSet(APBlocks.DISTANCE_DETECTOR.get()), null)); + public static final RegistryObject> CHAT_BOX = APRegistration.TILE_ENTITIES.register( + "chat_box", + () -> new BlockEntityType<>(ChatBoxEntity::new, Sets.newHashSet(APBlocks.CHAT_BOX.get()), null)); + public static final RegistryObject> ENVIRONMENT_DETECTOR = APRegistration.TILE_ENTITIES + .register("environment_detector", () -> new BlockEntityType<>(EnvironmentDetectorEntity::new, + Sets.newHashSet(APBlocks.ENVIRONMENT_DETECTOR.get()), null)); + public static final RegistryObject> PLAYER_DETECTOR = APRegistration.TILE_ENTITIES + .register("player_detector", () -> new BlockEntityType<>(PlayerDetectorEntity::new, + Sets.newHashSet(APBlocks.PLAYER_DETECTOR.get()), null)); + public static final RegistryObject> ME_BRIDGE = APAddons.appliedEnergisticsLoaded + ? APRegistration.TILE_ENTITIES.register("me_bridge", + () -> new BlockEntityType<>(MeBridgeEntity::new, Sets.newHashSet(APBlocks.ME_BRIDGE.get()), null)) + : null; + public static final RegistryObject> RS_BRIDGE = APAddons.refinedStorageLoaded + ? APRegistration.TILE_ENTITIES.register("rs_bridge", + () -> new BlockEntityType<>(RsBridgeEntity::new, Sets.newHashSet(APBlocks.RS_BRIDGE.get()), null)) + : null; + public static final RegistryObject> ENERGY_DETECTOR = APRegistration.TILE_ENTITIES + .register("energy_detector", () -> new BlockEntityType<>(EnergyDetectorEntity::new, + Sets.newHashSet(APBlocks.ENERGY_DETECTOR.get()), null)); + public static final RegistryObject> FLUID_DETECTOR = APRegistration.TILE_ENTITIES + .register("fluid_detector", () -> new BlockEntityType<>(FluidDetectorEntity::new, + Sets.newHashSet(APBlocks.FLUID_DETECTOR.get()), null)); + public static final RegistryObject> GAS_DETECTOR = APAddons.mekanismLoaded + ? APRegistration.TILE_ENTITIES.register("gas_detector", + () -> new BlockEntityType<>(GasDetectorEntity::new, Sets.newHashSet(APBlocks.GAS_DETECTOR.get()), + null)) + : null; + public static final RegistryObject> INVENTORY_MANAGER = APRegistration.TILE_ENTITIES + .register("inventory_manager", () -> new BlockEntityType<>(InventoryManagerEntity::new, + Sets.newHashSet(APBlocks.INVENTORY_MANAGER.get()), null)); + public static final RegistryObject> REDSTONE_INTEGRATOR = APRegistration.TILE_ENTITIES + .register("redstone_integrator", () -> new BlockEntityType<>(RedstoneIntegratorEntity::new, + Sets.newHashSet(APBlocks.REDSTONE_INTEGRATOR.get()), null)); + public static final RegistryObject> BLOCK_READER = APRegistration.TILE_ENTITIES + .register("block_reader", () -> new BlockEntityType<>(BlockReaderEntity::new, + Sets.newHashSet(APBlocks.BLOCK_READER.get()), null)); + public static final RegistryObject> GEO_SCANNER = APRegistration.TILE_ENTITIES + .register("geo_scanner", () -> new BlockEntityType<>(GeoScannerEntity::new, + Sets.newHashSet(APBlocks.GEO_SCANNER.get()), null)); + public static final RegistryObject> COLONY_INTEGRATOR = APRegistration.TILE_ENTITIES + .register("colony_integrator", () -> new BlockEntityType<>(ColonyIntegratorEntity::new, + Sets.newHashSet(APBlocks.COLONY_INTEGRATOR.get()), null)); + public static final RegistryObject> NBT_STORAGE = APRegistration.TILE_ENTITIES + .register("nbt_storage", () -> new BlockEntityType<>(NBTStorageEntity::new, + Sets.newHashSet(APBlocks.NBT_STORAGE.get()), null)); + public static final RegistryObject> DISTANCE_DETECTOR = APRegistration.TILE_ENTITIES + .register("distance_detector", () -> new BlockEntityType<>(DistanceDetectorEntity::new, + Sets.newHashSet(APBlocks.DISTANCE_DETECTOR.get()), null)); } diff --git a/src/main/java/de/srendi/advancedperipherals/common/setup/APBlocks.java b/src/main/java/de/srendi/advancedperipherals/common/setup/APBlocks.java index aab4cdd0b..26f127d3e 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/setup/APBlocks.java +++ b/src/main/java/de/srendi/advancedperipherals/common/setup/APBlocks.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.setup; import de.srendi.advancedperipherals.common.blocks.PlayerDetectorBlock; @@ -24,28 +39,66 @@ public class APBlocks { protected static void register() { } - public static final RegistryObject ENVIRONMENT_DETECTOR = register("environment_detector", () -> new APBlockEntityBlock<>(APBlockEntityTypes.ENVIRONMENT_DETECTOR, false), () -> new APBlockItem(APBlocks.ENVIRONMENT_DETECTOR.get(), APConfig.PERIPHERALS_CONFIG.enableEnvironmentDetector)); - public static final RegistryObject CHAT_BOX = register("chat_box", () -> new APBlockEntityBlock<>(APBlockEntityTypes.CHAT_BOX, true), () -> new APBlockItem(APBlocks.CHAT_BOX.get(), APConfig.PERIPHERALS_CONFIG.enableChatBox)); - public static final RegistryObject PLAYER_DETECTOR = register("player_detector", PlayerDetectorBlock::new, () -> new APBlockItem(APBlocks.PLAYER_DETECTOR.get(), APConfig.PERIPHERALS_CONFIG.enablePlayerDetector)); - public static final RegistryObject ME_BRIDGE = register("me_bridge", () -> new APBlockEntityBlock<>(ModList.get().isLoaded("ae2") ? APBlockEntityTypes.ME_BRIDGE : null, ModList.get().isLoaded("ae2")), () -> new APBlockItem(APBlocks.ME_BRIDGE.get(), APConfig.PERIPHERALS_CONFIG.enableMEBridge)); - public static final RegistryObject RS_BRIDGE = register("rs_bridge", () -> new APBlockEntityBlock<>(ModList.get().isLoaded("refinedstorage") ? APBlockEntityTypes.RS_BRIDGE : null, false), () -> new APBlockItem(APBlocks.RS_BRIDGE.get(), APConfig.PERIPHERALS_CONFIG.enableRSBridge)); - public static final RegistryObject ENERGY_DETECTOR = register("energy_detector", () -> new APBlockEntityBlock<>(APBlockEntityTypes.ENERGY_DETECTOR, true), () -> new APBlockItem(APBlocks.ENERGY_DETECTOR.get(), APConfig.PERIPHERALS_CONFIG.enableEnergyDetector)); - public static final RegistryObject FLUID_DETECTOR = register("fluid_detector", () -> new APBlockEntityBlock<>(APBlockEntityTypes.FLUID_DETECTOR, true), () -> new APBlockItem(APBlocks.FLUID_DETECTOR.get(), APConfig.PERIPHERALS_CONFIG.enableFluidDetector)); - public static final RegistryObject GAS_DETECTOR = register("gas_detector", () -> new APBlockEntityBlock<>(ModList.get().isLoaded("mekanism") ? APBlockEntityTypes.GAS_DETECTOR : null, true), () -> new APBlockItem(APBlocks.GAS_DETECTOR.get(), APConfig.PERIPHERALS_CONFIG.enableGasDetector)); - public static final RegistryObject PERIPHERAL_CASING = register("peripheral_casing", BaseBlock::new, () -> new APBlockItem(APBlocks.PERIPHERAL_CASING.get(), new Item.Properties().stacksTo(16), () -> true)); - public static final RegistryObject INVENTORY_MANAGER = register("inventory_manager", () -> new APBlockEntityBlock<>(APBlockEntityTypes.INVENTORY_MANAGER, false), () -> new APBlockItem(APBlocks.INVENTORY_MANAGER.get(), APConfig.PERIPHERALS_CONFIG.enableInventoryManager)); - public static final RegistryObject REDSTONE_INTEGRATOR = register("redstone_integrator", RedstoneIntegratorBlock::new, () -> new APBlockItem(APBlocks.REDSTONE_INTEGRATOR.get(), APConfig.PERIPHERALS_CONFIG.enableRedstoneIntegrator)); - public static final RegistryObject BLOCK_READER = register("block_reader", () -> new APBlockEntityBlock<>(APBlockEntityTypes.BLOCK_READER, true), () -> new APBlockItem(APBlocks.BLOCK_READER.get(), APConfig.PERIPHERALS_CONFIG.enableBlockReader)); - public static final RegistryObject GEO_SCANNER = register("geo_scanner", () -> new APBlockEntityBlock<>(APBlockEntityTypes.GEO_SCANNER, false), () -> new APBlockItem(APBlocks.GEO_SCANNER.get(), APConfig.PERIPHERALS_CONFIG.enableGeoScanner)); - public static final RegistryObject COLONY_INTEGRATOR = register("colony_integrator", () -> new APBlockEntityBlock<>(APBlockEntityTypes.COLONY_INTEGRATOR, false), () -> new APBlockItem(APBlocks.COLONY_INTEGRATOR.get(), APConfig.PERIPHERALS_CONFIG.enableColonyIntegrator)); - public static final RegistryObject NBT_STORAGE = register("nbt_storage", () -> new APBlockEntityBlock<>(APBlockEntityTypes.NBT_STORAGE, false), () -> new APBlockItem(APBlocks.NBT_STORAGE.get(), APConfig.PERIPHERALS_CONFIG.enableNBTStorage)); - public static final RegistryObject DISTANCE_DETECTOR = register("distance_detector", () -> new APBlockEntityBlock<>(APBlockEntityTypes.DISTANCE_DETECTOR, BlockBehaviour.Properties.of(Material.METAL).noOcclusion(), true), () -> new APBlockItem(APBlocks.DISTANCE_DETECTOR.get(), APConfig.PERIPHERALS_CONFIG.enableNBTStorage)); + public static final RegistryObject ENVIRONMENT_DETECTOR = register("environment_detector", + () -> new APBlockEntityBlock<>(APBlockEntityTypes.ENVIRONMENT_DETECTOR, false), + () -> new APBlockItem(APBlocks.ENVIRONMENT_DETECTOR.get(), + APConfig.PERIPHERALS_CONFIG.enableEnvironmentDetector)); + public static final RegistryObject CHAT_BOX = register("chat_box", + () -> new APBlockEntityBlock<>(APBlockEntityTypes.CHAT_BOX, true), + () -> new APBlockItem(APBlocks.CHAT_BOX.get(), APConfig.PERIPHERALS_CONFIG.enableChatBox)); + public static final RegistryObject PLAYER_DETECTOR = register("player_detector", PlayerDetectorBlock::new, + () -> new APBlockItem(APBlocks.PLAYER_DETECTOR.get(), APConfig.PERIPHERALS_CONFIG.enablePlayerDetector)); + public static final RegistryObject ME_BRIDGE = register("me_bridge", + () -> new APBlockEntityBlock<>(ModList.get().isLoaded("ae2") ? APBlockEntityTypes.ME_BRIDGE : null, + ModList.get().isLoaded("ae2")), + () -> new APBlockItem(APBlocks.ME_BRIDGE.get(), APConfig.PERIPHERALS_CONFIG.enableMEBridge)); + public static final RegistryObject RS_BRIDGE = register("rs_bridge", + () -> new APBlockEntityBlock<>( + ModList.get().isLoaded("refinedstorage") ? APBlockEntityTypes.RS_BRIDGE : null, false), + () -> new APBlockItem(APBlocks.RS_BRIDGE.get(), APConfig.PERIPHERALS_CONFIG.enableRSBridge)); + public static final RegistryObject ENERGY_DETECTOR = register("energy_detector", + () -> new APBlockEntityBlock<>(APBlockEntityTypes.ENERGY_DETECTOR, true), + () -> new APBlockItem(APBlocks.ENERGY_DETECTOR.get(), APConfig.PERIPHERALS_CONFIG.enableEnergyDetector)); + public static final RegistryObject FLUID_DETECTOR = register("fluid_detector", + () -> new APBlockEntityBlock<>(APBlockEntityTypes.FLUID_DETECTOR, true), + () -> new APBlockItem(APBlocks.FLUID_DETECTOR.get(), APConfig.PERIPHERALS_CONFIG.enableFluidDetector)); + public static final RegistryObject GAS_DETECTOR = register("gas_detector", + () -> new APBlockEntityBlock<>(ModList.get().isLoaded("mekanism") ? APBlockEntityTypes.GAS_DETECTOR : null, + true), + () -> new APBlockItem(APBlocks.GAS_DETECTOR.get(), APConfig.PERIPHERALS_CONFIG.enableGasDetector)); + public static final RegistryObject PERIPHERAL_CASING = register("peripheral_casing", BaseBlock::new, + () -> new APBlockItem(APBlocks.PERIPHERAL_CASING.get(), new Item.Properties().stacksTo(16), () -> true)); + public static final RegistryObject INVENTORY_MANAGER = register("inventory_manager", + () -> new APBlockEntityBlock<>(APBlockEntityTypes.INVENTORY_MANAGER, false), + () -> new APBlockItem(APBlocks.INVENTORY_MANAGER.get(), + APConfig.PERIPHERALS_CONFIG.enableInventoryManager)); + public static final RegistryObject REDSTONE_INTEGRATOR = register("redstone_integrator", + RedstoneIntegratorBlock::new, () -> new APBlockItem(APBlocks.REDSTONE_INTEGRATOR.get(), + APConfig.PERIPHERALS_CONFIG.enableRedstoneIntegrator)); + public static final RegistryObject BLOCK_READER = register("block_reader", + () -> new APBlockEntityBlock<>(APBlockEntityTypes.BLOCK_READER, true), + () -> new APBlockItem(APBlocks.BLOCK_READER.get(), APConfig.PERIPHERALS_CONFIG.enableBlockReader)); + public static final RegistryObject GEO_SCANNER = register("geo_scanner", + () -> new APBlockEntityBlock<>(APBlockEntityTypes.GEO_SCANNER, false), + () -> new APBlockItem(APBlocks.GEO_SCANNER.get(), APConfig.PERIPHERALS_CONFIG.enableGeoScanner)); + public static final RegistryObject COLONY_INTEGRATOR = register("colony_integrator", + () -> new APBlockEntityBlock<>(APBlockEntityTypes.COLONY_INTEGRATOR, false), + () -> new APBlockItem(APBlocks.COLONY_INTEGRATOR.get(), + APConfig.PERIPHERALS_CONFIG.enableColonyIntegrator)); + public static final RegistryObject NBT_STORAGE = register("nbt_storage", + () -> new APBlockEntityBlock<>(APBlockEntityTypes.NBT_STORAGE, false), + () -> new APBlockItem(APBlocks.NBT_STORAGE.get(), APConfig.PERIPHERALS_CONFIG.enableNBTStorage)); + public static final RegistryObject DISTANCE_DETECTOR = register("distance_detector", + () -> new APBlockEntityBlock<>(APBlockEntityTypes.DISTANCE_DETECTOR, + BlockBehaviour.Properties.of(Material.METAL).noOcclusion(), true), + () -> new APBlockItem(APBlocks.DISTANCE_DETECTOR.get(), APConfig.PERIPHERALS_CONFIG.enableNBTStorage)); private static RegistryObject registerNoItem(String name, Supplier block) { return APRegistration.BLOCKS.register(name, block); } - private static RegistryObject register(String name, Supplier block, Supplier blockItem) { + private static RegistryObject register(String name, Supplier block, + Supplier blockItem) { RegistryObject registryObject = registerNoItem(name, block); APRegistration.ITEMS.register(name, blockItem); return registryObject; diff --git a/src/main/java/de/srendi/advancedperipherals/common/setup/APContainerTypes.java b/src/main/java/de/srendi/advancedperipherals/common/setup/APContainerTypes.java index b51d363b3..cbbb39e77 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/setup/APContainerTypes.java +++ b/src/main/java/de/srendi/advancedperipherals/common/setup/APContainerTypes.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.setup; import dan200.computercraft.shared.network.container.ComputerContainerData; @@ -12,15 +27,16 @@ public class APContainerTypes { - public static final RegistryObject> INVENTORY_MANAGER_CONTAINER = APRegistration.CONTAINER_TYPES.register("memory_card_container", () -> IForgeMenuType.create((windowId, inv, data) -> { - BlockPos pos = data.readBlockPos(); - Level level = inv.player.getCommandSenderWorld(); - return new InventoryManagerContainer(windowId, inv, pos, level); - })); + public static final RegistryObject> INVENTORY_MANAGER_CONTAINER = APRegistration.CONTAINER_TYPES + .register("memory_card_container", () -> IForgeMenuType.create((windowId, inv, data) -> { + BlockPos pos = data.readBlockPos(); + Level level = inv.player.getCommandSenderWorld(); + return new InventoryManagerContainer(windowId, inv, pos, level); + })); - public static final RegistryObject> SMART_GLASSES_CONTAINER = APRegistration.CONTAINER_TYPES.register("smart_glasses_container", () -> ContainerData.toType(ComputerContainerData::new, - (id, inv, data) -> new SmartGlassesContainer(id, player -> true, null, data, inv, data.displayStack()) - )); + public static final RegistryObject> SMART_GLASSES_CONTAINER = APRegistration.CONTAINER_TYPES + .register("smart_glasses_container", () -> ContainerData.toType(ComputerContainerData::new, (id, inv, + data) -> new SmartGlassesContainer(id, player -> true, null, data, inv, data.displayStack()))); protected static void register() { } diff --git a/src/main/java/de/srendi/advancedperipherals/common/setup/APItems.java b/src/main/java/de/srendi/advancedperipherals/common/setup/APItems.java index 985a406f8..eb4497ce8 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/setup/APItems.java +++ b/src/main/java/de/srendi/advancedperipherals/common/setup/APItems.java @@ -1,7 +1,26 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.setup; import de.srendi.advancedperipherals.common.configuration.APConfig; -import de.srendi.advancedperipherals.common.items.*; +import de.srendi.advancedperipherals.common.items.APItem; +import de.srendi.advancedperipherals.common.items.MemoryCardItem; +import de.srendi.advancedperipherals.common.items.SmartGlassesInterfaceItem; +import de.srendi.advancedperipherals.common.items.SmartGlassesItem; +import de.srendi.advancedperipherals.common.items.WeakAutomataCore; import de.srendi.advancedperipherals.common.items.base.SmartGlassesMaterials; import de.srendi.advancedperipherals.common.smartglasses.modules.hotkey.HotkeyModuleItem; import de.srendi.advancedperipherals.common.smartglasses.modules.nightvision.NightVisionModuleItem; @@ -11,21 +30,40 @@ public class APItems { - public static final RegistryObject CHUNK_CONTROLLER = APRegistration.ITEMS.register("chunk_controller", () -> new APItem(new Item.Properties().stacksTo(16), APConfig.PERIPHERALS_CONFIG.enableChunkyTurtle)); - public static final RegistryObject SMART_GLASSES = APRegistration.ITEMS.register("smart_glasses", () -> new SmartGlassesItem(SmartGlassesMaterials.CHAIN)); - public static final RegistryObject SMART_GLASSES_NETHERITE = APRegistration.ITEMS.register("smart_glasses_netherite", () -> new SmartGlassesItem(SmartGlassesMaterials.NETHERITE)); - public static final RegistryObject SMART_GLASSES_INTERFACE = APRegistration.ITEMS.register("smart_glasses_interface", SmartGlassesInterfaceItem::new); - public static final RegistryObject OVERLAY_GLASSES = APRegistration.ITEMS.register("overlayglasses", OverlayGlassesItem::new); - public static final RegistryObject HOTKEY_MODULE = APRegistration.ITEMS.register("hotkeymodule", HotkeyModuleItem::new); - public static final RegistryObject NIGHT_VISION_MODULE = APRegistration.ITEMS.register("nightvisionmodule", NightVisionModuleItem::new); - public static final RegistryObject COMPUTER_TOOL = APRegistration.ITEMS.register("computer_tool", () -> new APItem(new Item.Properties().stacksTo(1), () -> true)); - public static final RegistryObject MEMORY_CARD = APRegistration.ITEMS.register("memory_card", MemoryCardItem::new); - public static final RegistryObject END_AUTOMATA_CORE = APRegistration.ITEMS.register("end_automata_core", () -> new APItem(new Item.Properties().stacksTo(1), APConfig.METAPHYSICS_CONFIG.enableEndAutomataCore)); - public static final RegistryObject HUSBANDRY_AUTOMATA_CORE = APRegistration.ITEMS.register("husbandry_automata_core", () -> new APItem(new Item.Properties().stacksTo(1), APConfig.METAPHYSICS_CONFIG.enableHusbandryAutomataCore)); - public static final RegistryObject WEAK_AUTOMATA_CORE = APRegistration.ITEMS.register("weak_automata_core", () -> new WeakAutomataCore(new Item.Properties().stacksTo(1))); - public static final RegistryObject OVERPOWERED_WEAK_AUTOMATA_CORE = APRegistration.ITEMS.register("overpowered_weak_automata_core", () -> new APItem(new Item.Properties().stacksTo(1), APConfig.METAPHYSICS_CONFIG.enableWeakAutomataCore)); - public static final RegistryObject OVERPOWERED_END_AUTOMATA_CORE = APRegistration.ITEMS.register("overpowered_end_automata_core", () -> new APItem(new Item.Properties().stacksTo(1), APConfig.METAPHYSICS_CONFIG.enableEndAutomataCore)); - public static final RegistryObject OVERPOWERED_HUSBANDRY_AUTOMATA_CORE = APRegistration.ITEMS.register("overpowered_husbandry_automata_core", () -> new APItem(new Item.Properties().stacksTo(1), APConfig.METAPHYSICS_CONFIG.enableHusbandryAutomataCore)); + public static final RegistryObject CHUNK_CONTROLLER = APRegistration.ITEMS.register("chunk_controller", + () -> new APItem(new Item.Properties().stacksTo(16), APConfig.PERIPHERALS_CONFIG.enableChunkyTurtle)); + public static final RegistryObject SMART_GLASSES = APRegistration.ITEMS.register("smart_glasses", + () -> new SmartGlassesItem(SmartGlassesMaterials.CHAIN)); + public static final RegistryObject SMART_GLASSES_NETHERITE = APRegistration.ITEMS + .register("smart_glasses_netherite", () -> new SmartGlassesItem(SmartGlassesMaterials.NETHERITE)); + public static final RegistryObject SMART_GLASSES_INTERFACE = APRegistration.ITEMS + .register("smart_glasses_interface", SmartGlassesInterfaceItem::new); + public static final RegistryObject OVERLAY_GLASSES = APRegistration.ITEMS + .register("overlayglasses", OverlayGlassesItem::new); + public static final RegistryObject HOTKEY_MODULE = APRegistration.ITEMS.register("hotkeymodule", + HotkeyModuleItem::new); + public static final RegistryObject NIGHT_VISION_MODULE = APRegistration.ITEMS + .register("nightvisionmodule", NightVisionModuleItem::new); + public static final RegistryObject COMPUTER_TOOL = APRegistration.ITEMS.register("computer_tool", + () -> new APItem(new Item.Properties().stacksTo(1), () -> true)); + public static final RegistryObject MEMORY_CARD = APRegistration.ITEMS.register("memory_card", + MemoryCardItem::new); + public static final RegistryObject END_AUTOMATA_CORE = APRegistration.ITEMS.register("end_automata_core", + () -> new APItem(new Item.Properties().stacksTo(1), APConfig.METAPHYSICS_CONFIG.enableEndAutomataCore)); + public static final RegistryObject HUSBANDRY_AUTOMATA_CORE = APRegistration.ITEMS + .register("husbandry_automata_core", () -> new APItem(new Item.Properties().stacksTo(1), + APConfig.METAPHYSICS_CONFIG.enableHusbandryAutomataCore)); + public static final RegistryObject WEAK_AUTOMATA_CORE = APRegistration.ITEMS.register("weak_automata_core", + () -> new WeakAutomataCore(new Item.Properties().stacksTo(1))); + public static final RegistryObject OVERPOWERED_WEAK_AUTOMATA_CORE = APRegistration.ITEMS.register( + "overpowered_weak_automata_core", + () -> new APItem(new Item.Properties().stacksTo(1), APConfig.METAPHYSICS_CONFIG.enableWeakAutomataCore)); + public static final RegistryObject OVERPOWERED_END_AUTOMATA_CORE = APRegistration.ITEMS.register( + "overpowered_end_automata_core", + () -> new APItem(new Item.Properties().stacksTo(1), APConfig.METAPHYSICS_CONFIG.enableEndAutomataCore)); + public static final RegistryObject OVERPOWERED_HUSBANDRY_AUTOMATA_CORE = APRegistration.ITEMS + .register("overpowered_husbandry_automata_core", () -> new APItem(new Item.Properties().stacksTo(1), + APConfig.METAPHYSICS_CONFIG.enableHusbandryAutomataCore)); protected static void register() { } diff --git a/src/main/java/de/srendi/advancedperipherals/common/setup/APRegistration.java b/src/main/java/de/srendi/advancedperipherals/common/setup/APRegistration.java index f8d25961a..8356cc80a 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/setup/APRegistration.java +++ b/src/main/java/de/srendi/advancedperipherals/common/setup/APRegistration.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.setup; import dan200.computercraft.api.pocket.PocketUpgradeSerialiser; @@ -16,14 +31,22 @@ public class APRegistration { - public static final DeferredRegister BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, AdvancedPeripherals.MOD_ID); - public static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, AdvancedPeripherals.MOD_ID); - public static final DeferredRegister> TILE_ENTITIES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, AdvancedPeripherals.MOD_ID); - public static final DeferredRegister> CONTAINER_TYPES = DeferredRegister.create(ForgeRegistries.MENU_TYPES, AdvancedPeripherals.MOD_ID); - public static final DeferredRegister POI_TYPES = DeferredRegister.create(ForgeRegistries.POI_TYPES, AdvancedPeripherals.MOD_ID); - public static final DeferredRegister VILLAGER_PROFESSIONS = DeferredRegister.create(ForgeRegistries.VILLAGER_PROFESSIONS, AdvancedPeripherals.MOD_ID); - public static final DeferredRegister> TURTLE_SERIALIZER = DeferredRegister.create(TurtleUpgradeSerialiser.REGISTRY_ID, AdvancedPeripherals.MOD_ID); - public static final DeferredRegister> POCKET_SERIALIZER = DeferredRegister.create(PocketUpgradeSerialiser.REGISTRY_ID, AdvancedPeripherals.MOD_ID); + public static final DeferredRegister BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, + AdvancedPeripherals.MOD_ID); + public static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, + AdvancedPeripherals.MOD_ID); + public static final DeferredRegister> TILE_ENTITIES = DeferredRegister + .create(ForgeRegistries.BLOCK_ENTITY_TYPES, AdvancedPeripherals.MOD_ID); + public static final DeferredRegister> CONTAINER_TYPES = DeferredRegister + .create(ForgeRegistries.MENU_TYPES, AdvancedPeripherals.MOD_ID); + public static final DeferredRegister POI_TYPES = DeferredRegister.create(ForgeRegistries.POI_TYPES, + AdvancedPeripherals.MOD_ID); + public static final DeferredRegister VILLAGER_PROFESSIONS = DeferredRegister + .create(ForgeRegistries.VILLAGER_PROFESSIONS, AdvancedPeripherals.MOD_ID); + public static final DeferredRegister> TURTLE_SERIALIZER = DeferredRegister + .create(TurtleUpgradeSerialiser.REGISTRY_ID, AdvancedPeripherals.MOD_ID); + public static final DeferredRegister> POCKET_SERIALIZER = DeferredRegister + .create(PocketUpgradeSerialiser.REGISTRY_ID, AdvancedPeripherals.MOD_ID); public static void register() { IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); diff --git a/src/main/java/de/srendi/advancedperipherals/common/setup/APVillagers.java b/src/main/java/de/srendi/advancedperipherals/common/setup/APVillagers.java index a91c83f7a..943c9f9f1 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/setup/APVillagers.java +++ b/src/main/java/de/srendi/advancedperipherals/common/setup/APVillagers.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.setup; import com.google.common.collect.ImmutableSet; @@ -10,9 +25,19 @@ public class APVillagers { - public static final RegistryObject COMPUTER_SCIENTIST_POI = APRegistration.POI_TYPES.register("computer_scientist", () -> new PoiType(ImmutableSet.copyOf(Registry.ModBlocks.COMPUTER_ADVANCED.get().getStateDefinition().getPossibleStates()), 1, 1)); + public static final RegistryObject COMPUTER_SCIENTIST_POI = APRegistration.POI_TYPES + .register("computer_scientist", + () -> new PoiType(ImmutableSet.copyOf( + Registry.ModBlocks.COMPUTER_ADVANCED.get().getStateDefinition().getPossibleStates()), 1, + 1)); - public static final RegistryObject COMPUTER_SCIENTIST = APRegistration.VILLAGER_PROFESSIONS.register("computer_scientist", () -> new VillagerProfession(AdvancedPeripherals.MOD_ID + ":computer_scientist", holder -> holder.is(COMPUTER_SCIENTIST_POI.getKey()), holder -> holder.is(COMPUTER_SCIENTIST_POI.getKey()), ImmutableSet.of(), ImmutableSet.of(Registry.ModBlocks.COMPUTER_ADVANCED.get()), SoundEvents.VILLAGER_WORK_TOOLSMITH)); + public static final RegistryObject COMPUTER_SCIENTIST = APRegistration.VILLAGER_PROFESSIONS + .register("computer_scientist", + () -> new VillagerProfession(AdvancedPeripherals.MOD_ID + ":computer_scientist", + holder -> holder.is(COMPUTER_SCIENTIST_POI.getKey()), + holder -> holder.is(COMPUTER_SCIENTIST_POI.getKey()), ImmutableSet.of(), + ImmutableSet.of(Registry.ModBlocks.COMPUTER_ADVANCED.get()), + SoundEvents.VILLAGER_WORK_TOOLSMITH)); protected static void register() { } diff --git a/src/main/java/de/srendi/advancedperipherals/common/setup/CCRegistration.java b/src/main/java/de/srendi/advancedperipherals/common/setup/CCRegistration.java index 11962445a..815f345bb 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/setup/CCRegistration.java +++ b/src/main/java/de/srendi/advancedperipherals/common/setup/CCRegistration.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.setup; import dan200.computercraft.api.ForgeComputerCraftAPI; @@ -5,9 +20,23 @@ import dan200.computercraft.api.turtle.TurtleUpgradeSerialiser; import de.srendi.advancedperipherals.AdvancedPeripherals; import de.srendi.advancedperipherals.common.addons.computercraft.integrations.IntegrationPeripheralProvider; -import de.srendi.advancedperipherals.common.addons.computercraft.pocket.*; -import de.srendi.advancedperipherals.common.addons.computercraft.turtles.*; -import de.srendi.advancedperipherals.common.addons.computercraft.turtles.metaphysics.*; +import de.srendi.advancedperipherals.common.addons.computercraft.pocket.PocketChatBoxUpgrade; +import de.srendi.advancedperipherals.common.addons.computercraft.pocket.PocketColonyIntegratorUpgrade; +import de.srendi.advancedperipherals.common.addons.computercraft.pocket.PocketEnvironmentUpgrade; +import de.srendi.advancedperipherals.common.addons.computercraft.pocket.PocketGeoScannerUpgrade; +import de.srendi.advancedperipherals.common.addons.computercraft.pocket.PocketPlayerDetectorUpgrade; +import de.srendi.advancedperipherals.common.addons.computercraft.turtles.TurtleChatBoxUpgrade; +import de.srendi.advancedperipherals.common.addons.computercraft.turtles.TurtleChunkyUpgrade; +import de.srendi.advancedperipherals.common.addons.computercraft.turtles.TurtleCompassUpgrade; +import de.srendi.advancedperipherals.common.addons.computercraft.turtles.TurtleEnvironmentDetectorUpgrade; +import de.srendi.advancedperipherals.common.addons.computercraft.turtles.TurtleGeoScannerUpgrade; +import de.srendi.advancedperipherals.common.addons.computercraft.turtles.TurtlePlayerDetectorUpgrade; +import de.srendi.advancedperipherals.common.addons.computercraft.turtles.metaphysics.EndAutomata; +import de.srendi.advancedperipherals.common.addons.computercraft.turtles.metaphysics.HusbandryAutomata; +import de.srendi.advancedperipherals.common.addons.computercraft.turtles.metaphysics.OverpoweredEndAutomata; +import de.srendi.advancedperipherals.common.addons.computercraft.turtles.metaphysics.OverpoweredHusbandryAutomata; +import de.srendi.advancedperipherals.common.addons.computercraft.turtles.metaphysics.OverpoweredWeakAutomata; +import de.srendi.advancedperipherals.common.addons.computercraft.turtles.metaphysics.WeakAutomata; import net.minecraft.resources.ResourceLocation; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.registries.RegistryObject; @@ -15,24 +44,57 @@ @Mod.EventBusSubscriber(modid = AdvancedPeripherals.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) public class CCRegistration { - public static final RegistryObject> CHAT_BOX_TURTLE = APRegistration.TURTLE_SERIALIZER.register(ID.CHATTY_TURTLE.getPath(), () -> TurtleUpgradeSerialiser.simpleWithCustomItem(TurtleChatBoxUpgrade::new)); - public static final RegistryObject> PLAYER_DETECTOR_TURTLE = APRegistration.TURTLE_SERIALIZER.register(ID.PLAYER_TURTLE.getPath(), () -> TurtleUpgradeSerialiser.simpleWithCustomItem(TurtlePlayerDetectorUpgrade::new)); - public static final RegistryObject> ENVIRONMENT_TURTLE = APRegistration.TURTLE_SERIALIZER.register(ID.ENVIRONMENT_TURTLE.getPath(), () -> TurtleUpgradeSerialiser.simpleWithCustomItem(TurtleEnvironmentDetectorUpgrade::new)); - public static final RegistryObject> CHUNKY_TURTLE = APRegistration.TURTLE_SERIALIZER.register(ID.CHUNKY_TURTLE.getPath(), () -> TurtleUpgradeSerialiser.simpleWithCustomItem(TurtleChunkyUpgrade::new)); - public static final RegistryObject> GEO_SCANNER_TURTLE = APRegistration.TURTLE_SERIALIZER.register(ID.GEOSCANNER_TURTLE.getPath(), () -> TurtleUpgradeSerialiser.simpleWithCustomItem(TurtleGeoScannerUpgrade::new)); - public static final RegistryObject> COMPASS_TURTLE = APRegistration.TURTLE_SERIALIZER.register(ID.COMPASS_TURTLE.getPath(), () -> TurtleUpgradeSerialiser.simpleWithCustomItem(TurtleCompassUpgrade::new)); - public static final RegistryObject> WEAK_TURTLE = APRegistration.TURTLE_SERIALIZER.register(ID.WEAK_AUTOMATA.getPath(), () -> TurtleUpgradeSerialiser.simpleWithCustomItem(WeakAutomata::new)); - public static final RegistryObject> END_TURTLE = APRegistration.TURTLE_SERIALIZER.register(ID.END_AUTOMATA.getPath(), () -> TurtleUpgradeSerialiser.simpleWithCustomItem(EndAutomata::new)); - public static final RegistryObject> HUSBANDRY_TURTLE = APRegistration.TURTLE_SERIALIZER.register(ID.HUSBANDRY_AUTOMATA.getPath(), () -> TurtleUpgradeSerialiser.simpleWithCustomItem(HusbandryAutomata::new)); - public static final RegistryObject> OP_WEAK_TURTLE = APRegistration.TURTLE_SERIALIZER.register(ID.OP_WEAK_AUTOMATA.getPath(), () -> TurtleUpgradeSerialiser.simpleWithCustomItem(OverpoweredWeakAutomata::new)); - public static final RegistryObject> OP_END_TURTLE = APRegistration.TURTLE_SERIALIZER.register(ID.OP_END_AUTOMATA.getPath(), () -> TurtleUpgradeSerialiser.simpleWithCustomItem(OverpoweredEndAutomata::new)); - public static final RegistryObject> OP_HUSBANDRY_TURTLE = APRegistration.TURTLE_SERIALIZER.register(ID.OP_HUSBANDRY_AUTOMATA.getPath(), () -> TurtleUpgradeSerialiser.simpleWithCustomItem(OverpoweredHusbandryAutomata::new)); + public static final RegistryObject> CHAT_BOX_TURTLE = APRegistration.TURTLE_SERIALIZER + .register(ID.CHATTY_TURTLE.getPath(), + () -> TurtleUpgradeSerialiser.simpleWithCustomItem(TurtleChatBoxUpgrade::new)); + public static final RegistryObject> PLAYER_DETECTOR_TURTLE = APRegistration.TURTLE_SERIALIZER + .register(ID.PLAYER_TURTLE.getPath(), + () -> TurtleUpgradeSerialiser.simpleWithCustomItem(TurtlePlayerDetectorUpgrade::new)); + public static final RegistryObject> ENVIRONMENT_TURTLE = APRegistration.TURTLE_SERIALIZER + .register(ID.ENVIRONMENT_TURTLE.getPath(), + () -> TurtleUpgradeSerialiser.simpleWithCustomItem(TurtleEnvironmentDetectorUpgrade::new)); + public static final RegistryObject> CHUNKY_TURTLE = APRegistration.TURTLE_SERIALIZER + .register(ID.CHUNKY_TURTLE.getPath(), + () -> TurtleUpgradeSerialiser.simpleWithCustomItem(TurtleChunkyUpgrade::new)); + public static final RegistryObject> GEO_SCANNER_TURTLE = APRegistration.TURTLE_SERIALIZER + .register(ID.GEOSCANNER_TURTLE.getPath(), + () -> TurtleUpgradeSerialiser.simpleWithCustomItem(TurtleGeoScannerUpgrade::new)); + public static final RegistryObject> COMPASS_TURTLE = APRegistration.TURTLE_SERIALIZER + .register(ID.COMPASS_TURTLE.getPath(), + () -> TurtleUpgradeSerialiser.simpleWithCustomItem(TurtleCompassUpgrade::new)); + public static final RegistryObject> WEAK_TURTLE = APRegistration.TURTLE_SERIALIZER + .register(ID.WEAK_AUTOMATA.getPath(), + () -> TurtleUpgradeSerialiser.simpleWithCustomItem(WeakAutomata::new)); + public static final RegistryObject> END_TURTLE = APRegistration.TURTLE_SERIALIZER + .register(ID.END_AUTOMATA.getPath(), () -> TurtleUpgradeSerialiser.simpleWithCustomItem(EndAutomata::new)); + public static final RegistryObject> HUSBANDRY_TURTLE = APRegistration.TURTLE_SERIALIZER + .register(ID.HUSBANDRY_AUTOMATA.getPath(), + () -> TurtleUpgradeSerialiser.simpleWithCustomItem(HusbandryAutomata::new)); + public static final RegistryObject> OP_WEAK_TURTLE = APRegistration.TURTLE_SERIALIZER + .register(ID.OP_WEAK_AUTOMATA.getPath(), + () -> TurtleUpgradeSerialiser.simpleWithCustomItem(OverpoweredWeakAutomata::new)); + public static final RegistryObject> OP_END_TURTLE = APRegistration.TURTLE_SERIALIZER + .register(ID.OP_END_AUTOMATA.getPath(), + () -> TurtleUpgradeSerialiser.simpleWithCustomItem(OverpoweredEndAutomata::new)); + public static final RegistryObject> OP_HUSBANDRY_TURTLE = APRegistration.TURTLE_SERIALIZER + .register(ID.OP_HUSBANDRY_AUTOMATA.getPath(), + () -> TurtleUpgradeSerialiser.simpleWithCustomItem(OverpoweredHusbandryAutomata::new)); - public static final RegistryObject> CHAT_BOX_POCKET = APRegistration.POCKET_SERIALIZER.register(ID.CHATTY_POCKET.getPath(), () -> PocketUpgradeSerialiser.simpleWithCustomItem(PocketChatBoxUpgrade::new)); - public static final RegistryObject> PLAYER_DETECTOR_POCKET = APRegistration.POCKET_SERIALIZER.register(ID.PLAYER_POCKET.getPath(), () -> PocketUpgradeSerialiser.simpleWithCustomItem(PocketPlayerDetectorUpgrade::new)); - public static final RegistryObject> ENVIRONMENT_POCKET = APRegistration.POCKET_SERIALIZER.register(ID.ENVIRONMENT_POCKET.getPath(), () -> PocketUpgradeSerialiser.simpleWithCustomItem(PocketEnvironmentUpgrade::new)); - public static final RegistryObject> GEO_SCANNER_POCKET = APRegistration.POCKET_SERIALIZER.register(ID.GEOSCANNER_POCKET.getPath(), () -> PocketUpgradeSerialiser.simpleWithCustomItem(PocketGeoScannerUpgrade::new)); - public static final RegistryObject> COLONY_POCKET = APRegistration.POCKET_SERIALIZER.register(ID.COLONY_POCKET.getPath(), () -> PocketUpgradeSerialiser.simpleWithCustomItem(PocketColonyIntegratorUpgrade::new)); + public static final RegistryObject> CHAT_BOX_POCKET = APRegistration.POCKET_SERIALIZER + .register(ID.CHATTY_POCKET.getPath(), + () -> PocketUpgradeSerialiser.simpleWithCustomItem(PocketChatBoxUpgrade::new)); + public static final RegistryObject> PLAYER_DETECTOR_POCKET = APRegistration.POCKET_SERIALIZER + .register(ID.PLAYER_POCKET.getPath(), + () -> PocketUpgradeSerialiser.simpleWithCustomItem(PocketPlayerDetectorUpgrade::new)); + public static final RegistryObject> ENVIRONMENT_POCKET = APRegistration.POCKET_SERIALIZER + .register(ID.ENVIRONMENT_POCKET.getPath(), + () -> PocketUpgradeSerialiser.simpleWithCustomItem(PocketEnvironmentUpgrade::new)); + public static final RegistryObject> GEO_SCANNER_POCKET = APRegistration.POCKET_SERIALIZER + .register(ID.GEOSCANNER_POCKET.getPath(), + () -> PocketUpgradeSerialiser.simpleWithCustomItem(PocketGeoScannerUpgrade::new)); + public static final RegistryObject> COLONY_POCKET = APRegistration.POCKET_SERIALIZER + .register(ID.COLONY_POCKET.getPath(), + () -> PocketUpgradeSerialiser.simpleWithCustomItem(PocketColonyIntegratorUpgrade::new)); public static IntegrationPeripheralProvider integrationPeripheralProvider; @@ -44,24 +106,41 @@ protected static void register() { public static class ID { - public static final ResourceLocation CHATTY_TURTLE = new ResourceLocation(AdvancedPeripherals.MOD_ID, "chatty_turtle"); - public static final ResourceLocation PLAYER_TURTLE = new ResourceLocation(AdvancedPeripherals.MOD_ID, "player_turtle"); - public static final ResourceLocation ENVIRONMENT_TURTLE = new ResourceLocation(AdvancedPeripherals.MOD_ID, "environment_turtle"); - public static final ResourceLocation CHUNKY_TURTLE = new ResourceLocation(AdvancedPeripherals.MOD_ID, "chunky_turtle"); - public static final ResourceLocation GEOSCANNER_TURTLE = new ResourceLocation(AdvancedPeripherals.MOD_ID, "geoscanner_turtle"); - public static final ResourceLocation COMPASS_TURTLE = new ResourceLocation(AdvancedPeripherals.MOD_ID, "compass_turtle"); - public static final ResourceLocation WEAK_AUTOMATA = new ResourceLocation(AdvancedPeripherals.MOD_ID, "weak_automata"); - public static final ResourceLocation END_AUTOMATA = new ResourceLocation(AdvancedPeripherals.MOD_ID, "end_automata"); - public static final ResourceLocation HUSBANDRY_AUTOMATA = new ResourceLocation(AdvancedPeripherals.MOD_ID, "husbandry_automata"); - public static final ResourceLocation OP_WEAK_AUTOMATA = new ResourceLocation(AdvancedPeripherals.MOD_ID, "overpowered_weak_automata"); - public static final ResourceLocation OP_END_AUTOMATA = new ResourceLocation(AdvancedPeripherals.MOD_ID, "overpowered_end_automata"); - public static final ResourceLocation OP_HUSBANDRY_AUTOMATA = new ResourceLocation(AdvancedPeripherals.MOD_ID, "overpowered_husbandry_automata"); + public static final ResourceLocation CHATTY_TURTLE = new ResourceLocation(AdvancedPeripherals.MOD_ID, + "chatty_turtle"); + public static final ResourceLocation PLAYER_TURTLE = new ResourceLocation(AdvancedPeripherals.MOD_ID, + "player_turtle"); + public static final ResourceLocation ENVIRONMENT_TURTLE = new ResourceLocation(AdvancedPeripherals.MOD_ID, + "environment_turtle"); + public static final ResourceLocation CHUNKY_TURTLE = new ResourceLocation(AdvancedPeripherals.MOD_ID, + "chunky_turtle"); + public static final ResourceLocation GEOSCANNER_TURTLE = new ResourceLocation(AdvancedPeripherals.MOD_ID, + "geoscanner_turtle"); + public static final ResourceLocation COMPASS_TURTLE = new ResourceLocation(AdvancedPeripherals.MOD_ID, + "compass_turtle"); + public static final ResourceLocation WEAK_AUTOMATA = new ResourceLocation(AdvancedPeripherals.MOD_ID, + "weak_automata"); + public static final ResourceLocation END_AUTOMATA = new ResourceLocation(AdvancedPeripherals.MOD_ID, + "end_automata"); + public static final ResourceLocation HUSBANDRY_AUTOMATA = new ResourceLocation(AdvancedPeripherals.MOD_ID, + "husbandry_automata"); + public static final ResourceLocation OP_WEAK_AUTOMATA = new ResourceLocation(AdvancedPeripherals.MOD_ID, + "overpowered_weak_automata"); + public static final ResourceLocation OP_END_AUTOMATA = new ResourceLocation(AdvancedPeripherals.MOD_ID, + "overpowered_end_automata"); + public static final ResourceLocation OP_HUSBANDRY_AUTOMATA = new ResourceLocation(AdvancedPeripherals.MOD_ID, + "overpowered_husbandry_automata"); - public static final ResourceLocation CHATTY_POCKET = new ResourceLocation(AdvancedPeripherals.MOD_ID, "chatty_pocket"); - public static final ResourceLocation PLAYER_POCKET = new ResourceLocation(AdvancedPeripherals.MOD_ID, "player_pocket"); - public static final ResourceLocation ENVIRONMENT_POCKET = new ResourceLocation(AdvancedPeripherals.MOD_ID, "environment_pocket"); - public static final ResourceLocation GEOSCANNER_POCKET = new ResourceLocation(AdvancedPeripherals.MOD_ID, "geoscanner_pocket"); - public static final ResourceLocation COLONY_POCKET = new ResourceLocation(AdvancedPeripherals.MOD_ID, "colony_pocket"); + public static final ResourceLocation CHATTY_POCKET = new ResourceLocation(AdvancedPeripherals.MOD_ID, + "chatty_pocket"); + public static final ResourceLocation PLAYER_POCKET = new ResourceLocation(AdvancedPeripherals.MOD_ID, + "player_pocket"); + public static final ResourceLocation ENVIRONMENT_POCKET = new ResourceLocation(AdvancedPeripherals.MOD_ID, + "environment_pocket"); + public static final ResourceLocation GEOSCANNER_POCKET = new ResourceLocation(AdvancedPeripherals.MOD_ID, + "geoscanner_pocket"); + public static final ResourceLocation COLONY_POCKET = new ResourceLocation(AdvancedPeripherals.MOD_ID, + "colony_pocket"); } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/SlotType.java b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/SlotType.java index f5498935a..4336aacfb 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/SlotType.java +++ b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/SlotType.java @@ -1,10 +1,25 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.smartglasses; import net.minecraft.network.chat.Component; public enum SlotType { - PERIPHERALS(Component.translatable("text.advancedperipherals.smart_glasses.peripherals")), - MODULES(Component.translatable("text.advancedperipherals.smart_glasses.modules")); + PERIPHERALS(Component.translatable("text.advancedperipherals.smart_glasses.peripherals")), MODULES( + Component.translatable("text.advancedperipherals.smart_glasses.modules")); private final Component name; diff --git a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/SmartGlassesAPI.java b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/SmartGlassesAPI.java index 04baafc24..d3e0b2226 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/SmartGlassesAPI.java +++ b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/SmartGlassesAPI.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.smartglasses; import dan200.computercraft.api.lua.ILuaAPI; diff --git a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/SmartGlassesAccess.java b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/SmartGlassesAccess.java index 316c7a715..693f1e99b 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/SmartGlassesAccess.java +++ b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/SmartGlassesAccess.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.smartglasses; import dan200.computercraft.api.peripheral.IPeripheral; @@ -17,8 +32,7 @@ public SmartGlassesAccess(SmartGlassesComputer computer) { this.computer = computer; } - @Nullable - @Override + @Nullable @Override public Entity getEntity() { return computer.getEntity(); } diff --git a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/SmartGlassesComputer.java b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/SmartGlassesComputer.java index 21301b954..58408080b 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/SmartGlassesComputer.java +++ b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/SmartGlassesComputer.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.smartglasses; import dan200.computercraft.api.peripheral.IPeripheral; @@ -22,19 +37,23 @@ import org.jetbrains.annotations.NotNull; import javax.annotation.Nullable; -import java.util.*; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; /** - * Basically just a {@link dan200.computercraft.shared.pocket.core.PocketServerComputer} but with some changes + * Basically just a + * {@link dan200.computercraft.shared.pocket.core.PocketServerComputer} but with + * some changes */ public class SmartGlassesComputer extends ServerComputer implements IPocketAccess { - @Nullable - private Entity entity; + @Nullable private Entity entity; private ItemStack stack = ItemStack.EMPTY; private final SmartGlassesAccess smartGlassesAccess = new SmartGlassesAccess(this); - @Nullable - private SmartGlassesItemHandler itemHandler; + @Nullable private SmartGlassesItemHandler itemHandler; private int lightColour = -1; private boolean lightChanged = false; @@ -47,15 +66,15 @@ public SmartGlassesComputer(ServerLevel world, int computerID, @Nullable String super(world, computerID, label, family, 39, 13); } - @Nullable - @Override + @Nullable @Override public Entity getEntity() { if (entity == null || stack.isEmpty() || !entity.isAlive()) return null; if (entity instanceof Player player) { var inventory = player.getInventory(); - return inventory.items.contains(stack) || inventory.armor.contains(stack) || inventory.offhand.contains(stack) ? entity : null; + return inventory.items.contains(stack) || inventory.armor.contains(stack) + || inventory.offhand.contains(stack) ? entity : null; } else if (entity instanceof ItemEntity itemEntity) { return itemEntity.getItem() == stack ? entity : null; } else { @@ -88,7 +107,8 @@ public int getLight() { @Override public void setLight(int colour) { - if (colour < 0 || colour > 0xFFFFFF) colour = -1; + if (colour < 0 || colour > 0xFFFFFF) + colour = -1; if (lightColour == colour) return; @@ -109,8 +129,7 @@ public boolean isDirty() { } @Override - @NotNull - public CompoundTag getUpgradeNBTData() { + @NotNull public CompoundTag getUpgradeNBTData() { return new CompoundTag(); } @@ -125,8 +144,7 @@ public void invalidatePeripheral() { } @Override - @NotNull - public Map getUpgrades() { + @NotNull public Map getUpgrades() { return Collections.emptyMap(); } @@ -148,7 +166,8 @@ public void updatePeripheralsAndModules(IItemHandler itemHandler) { for (int slot = 4; slot < 11; slot++) { ItemStack peripheralItem = itemHandler.getStackInSlot(slot); if (!peripheralItem.isEmpty() && peripheralItem.getItem() instanceof IModuleItem module) { - if (modules.get(slot) != null && modules.get(slot).getName().equals(module.createModule(smartGlassesAccess).getName())) + if (modules.get(slot) != null + && modules.get(slot).getName().equals(module.createModule(smartGlassesAccess).getName())) continue; modules.put(slot, module.createModule(smartGlassesAccess)); @@ -166,10 +185,12 @@ public void updatePeripheralsAndModules(IItemHandler itemHandler) { public void tickServer() { super.tickServer(); - // Find any players which have gone missing and remove them from the tracking list. + // Find any players which have gone missing and remove them from the tracking + // list. tracking.removeIf(player -> !player.isAlive() || player.level != getLevel()); - // And now find any new players, add them to the tracking list, and broadcast state where appropriate. + // And now find any new players, add them to the tracking list, and broadcast + // state where appropriate. var sendState = hasOutputChanged() || lightChanged; lightChanged = false; if (sendState) { @@ -196,9 +217,10 @@ public Map getModules() { protected void onTerminalChanged() { super.onTerminalChanged(); - /*if (entity instanceof ServerPlayer player && entity.isAlive()) { - // Broadcast the terminal to the current player. - }*/ + /* + * if (entity instanceof ServerPlayer player && entity.isAlive()) { // Broadcast + * the terminal to the current player. } + */ } @Override @@ -206,8 +228,7 @@ protected void onRemoved() { super.onRemoved(); } - @NotNull - public SmartGlassesAccess getSmartGlassesAccess() { + @NotNull public SmartGlassesAccess getSmartGlassesAccess() { return smartGlassesAccess; } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/SmartGlassesItemHandler.java b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/SmartGlassesItemHandler.java index 0cfa780a1..4eec68527 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/SmartGlassesItemHandler.java +++ b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/SmartGlassesItemHandler.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.smartglasses; import de.srendi.advancedperipherals.common.setup.APItems; @@ -19,15 +34,14 @@ public class SmartGlassesItemHandler implements IItemHandlerModifiable, INBTSeri private final NonNullList items = NonNullList.withSize(SLOTS, ItemStack.EMPTY); private final ItemStack stack; - @Nullable - private final SmartGlassesComputer computer; + @Nullable private final SmartGlassesComputer computer; public SmartGlassesItemHandler(ItemStack stack, @Nullable SmartGlassesComputer computer) { this.stack = stack; this.computer = computer; deserializeNBT(stack.getOrCreateTagElement("Items")); - if(computer != null) + if (computer != null) computer.setItemHandler(this); } @@ -36,8 +50,7 @@ public int getSlots() { return items.size(); } - @NotNull - @Override + @NotNull @Override public ItemStack getStackInSlot(int slot) { return items.get(slot); } diff --git a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/SmartGlassesMenuProvider.java b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/SmartGlassesMenuProvider.java index bf1fb3b53..182aa1aa7 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/SmartGlassesMenuProvider.java +++ b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/SmartGlassesMenuProvider.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.smartglasses; import dan200.computercraft.shared.computer.core.ServerComputer; @@ -24,20 +39,15 @@ public SmartGlassesMenuProvider(ServerComputer computer, ItemStack stack, IItemH this.glassesContainer = glassesContainer; } - @NotNull - @Override + @NotNull @Override public Component getDisplayName() { return name; } - @Nullable - @Override + @Nullable @Override public AbstractContainerMenu createMenu(int id, @NotNull Inventory inventory, @NotNull Player entity) { - return new SmartGlassesContainer(id, - p -> { - return true; - }, - computer, inventory, glassesContainer, null - ); + return new SmartGlassesContainer(id, p -> { + return true; + }, computer, inventory, glassesContainer, null); } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/SmartGlassesSlot.java b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/SmartGlassesSlot.java index ed8a0752d..9537b0532 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/SmartGlassesSlot.java +++ b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/SmartGlassesSlot.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.smartglasses; import dan200.computercraft.core.computer.ComputerSide; diff --git a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/IModule.java b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/IModule.java index 57376e535..5ad2460b7 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/IModule.java +++ b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/IModule.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.smartglasses.modules; import de.srendi.advancedperipherals.common.smartglasses.SmartGlassesAccess; @@ -9,27 +24,35 @@ public interface IModule { ResourceLocation getName(); /** - * Used to define the available functions of the module. This method only gets called once when indexing the modules + * Used to define the available functions of the module. This method only gets + * called once when indexing the modules *

* Return null if the module does not have any functions * - * @return an object containing lua functions {@link dan200.computercraft.api.lua.LuaFunction} + * @return an object containing lua functions + * {@link dan200.computercraft.api.lua.LuaFunction} */ - @Nullable - IModuleFunctions getFunctions(SmartGlassesAccess smartGlassesAccess); + @Nullable IModuleFunctions getFunctions(SmartGlassesAccess smartGlassesAccess); /** * Classic tick function. *

- * Implementations should check if the entity is not null since the glasses can still tick without belonging to an entity - * @param smartGlassesAccess Contains access to the entity, the computer, the level or the upgrades + * Implementations should check if the entity is not null since the glasses can + * still tick without belonging to an entity + * + * @param smartGlassesAccess + * Contains access to the entity, the computer, the level or the + * upgrades */ - default void tick(SmartGlassesAccess smartGlassesAccess) {} + default void tick(SmartGlassesAccess smartGlassesAccess) { + } - default void onUnequipped(SmartGlassesAccess smartGlassesAccess) {} + default void onUnequipped(SmartGlassesAccess smartGlassesAccess) { + } /** - * ErrorConstants class contains constants for error messages. This is used for easier error handling for users. + * ErrorConstants class contains constants for error messages. This is used for + * easier error handling for users. */ class ErrorConstants { public static final String ALREADY_EXISTS = "ID_ALREADY_EXISTS"; diff --git a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/IModuleFunctions.java b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/IModuleFunctions.java index 3656500eb..18d255482 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/IModuleFunctions.java +++ b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/IModuleFunctions.java @@ -1,13 +1,30 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.smartglasses.modules; import de.srendi.advancedperipherals.lib.peripherals.IPeripheralPlugin; /** - * Used to define the available functions of the module. - * Functions can be defined by creating final public methods annotated with the @{@link dan200.computercraft.api.lua.LuaFunction} annotation + * Used to define the available functions of the module. Functions can be + * defined by creating final public methods annotated with + * the @{@link dan200.computercraft.api.lua.LuaFunction} annotation */ public interface IModuleFunctions extends IPeripheralPlugin { - IModuleFunctions EMPTY = new IModuleFunctions() {}; + IModuleFunctions EMPTY = new IModuleFunctions() { + }; } diff --git a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/IModuleItem.java b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/IModuleItem.java index bed3560a2..bbd88ae44 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/IModuleItem.java +++ b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/IModuleItem.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.smartglasses.modules; import de.srendi.advancedperipherals.common.smartglasses.SmartGlassesAccess; @@ -11,13 +26,16 @@ public interface IModuleItem { IModule createModule(SmartGlassesAccess access); /** - * This method is called every tick the item is in the inventory of the smart glasses - * Runs on the client and server side + * This method is called every tick the item is in the inventory of the smart + * glasses Runs on the client and server side * - * @param access The access to the smart glasses - Null on the client side - * @param module The module - Null on the client side + * @param access + * The access to the smart glasses - Null on the client side + * @param module + * The module - Null on the client side */ - default void inventoryTick(ItemStack itemStack, Level level, Entity entity, int inventorySlot, boolean isCurrentItem, @Nullable SmartGlassesAccess access, @Nullable IModule module) { + default void inventoryTick(ItemStack itemStack, Level level, Entity entity, int inventorySlot, + boolean isCurrentItem, @Nullable SmartGlassesAccess access, @Nullable IModule module) { } diff --git a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/ModulePeripheral.java b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/ModulePeripheral.java index af3c3e237..4199eb41c 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/ModulePeripheral.java +++ b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/ModulePeripheral.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.smartglasses.modules; import dan200.computercraft.api.lua.LuaFunction; @@ -24,6 +39,7 @@ public boolean isEnabled() { @LuaFunction(mainThread = true) public final String[] getModules() { - return getPeripheralOwner().getComputer().getModules().values().stream().map(module -> module.getName().toString()).toArray(String[]::new); + return getPeripheralOwner().getComputer().getModules().values().stream() + .map(module -> module.getName().toString()).toArray(String[]::new); } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/ModulePeripheralOwner.java b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/ModulePeripheralOwner.java index 67bf2b6f0..9e515aa80 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/ModulePeripheralOwner.java +++ b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/ModulePeripheralOwner.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.smartglasses.modules; import de.srendi.advancedperipherals.common.addons.computercraft.owner.BasePeripheralOwner; @@ -19,7 +34,8 @@ public class ModulePeripheralOwner extends BasePeripheralOwner { - //TODO: Think about making our own smart glasses access so we don't have the not used stuff like the color or the light + // TODO: Think about making our own smart glasses access so we don't have the + // not used stuff like the color or the light // We would need to remove the pocket stuff from the SmartGlassesComputer private final SmartGlassesComputer computer; @@ -27,51 +43,44 @@ public ModulePeripheralOwner(SmartGlassesComputer computer) { this.computer = computer; } - @Nullable - @Override + @Nullable @Override public String getCustomName() { return "smartglasses"; } - @Nullable - @Override + @Nullable @Override public Level getLevel() { return computer.getEntity().getLevel(); } - @NotNull - @Override + @NotNull @Override public BlockPos getPos() { return computer.getEntity().getOnPos(); } - @NotNull - @Override + @NotNull @Override public Direction getFacing() { return Direction.NORTH; } - @NotNull - @Override + @NotNull @Override public FrontAndTop getOrientation() { return FrontAndTop.NORTH_UP; } - @NotNull - public SmartGlassesComputer getComputer() { + @NotNull public SmartGlassesComputer getComputer() { return computer; } - @Nullable - @Override + @Nullable @Override public Player getOwner() { Entity owner = computer.getEntity(); - if (owner instanceof Player player) return player; + if (owner instanceof Player player) + return player; return null; } - @NotNull - @Override + @NotNull @Override public CompoundTag getDataStorage() { return computer.getUpgradeNBTData(); } diff --git a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/hotkey/HotkeyModule.java b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/hotkey/HotkeyModule.java index c695a8334..58be44899 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/hotkey/HotkeyModule.java +++ b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/hotkey/HotkeyModule.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.smartglasses.modules.hotkey; import de.srendi.advancedperipherals.AdvancedPeripherals; diff --git a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/hotkey/HotkeyModuleItem.java b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/hotkey/HotkeyModuleItem.java index c2817a9c2..b6e17f2c8 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/hotkey/HotkeyModuleItem.java +++ b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/hotkey/HotkeyModuleItem.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.smartglasses.modules.hotkey; import de.srendi.advancedperipherals.client.KeyBindings; @@ -29,15 +44,17 @@ public IModule createModule(SmartGlassesAccess access) { } @Override - public void inventoryTick(@NotNull ItemStack stack, @NotNull Level level, @NotNull Entity entity, int slot, boolean isSelected) { + public void inventoryTick(@NotNull ItemStack stack, @NotNull Level level, @NotNull Entity entity, int slot, + boolean isSelected) { if (!level.isClientSide() || !(entity instanceof Player player)) return; if (KeybindUtil.isKeyPressed(KeyBindings.GLASSES_HOTKEY_KEYBINDING)) { // Add another 50ms to the duration, one tick setKeyPressDuration(stack, getKeyPressDuration(stack) + 50); - } else if(getKeyPressDuration(stack) > 0) { - // If the key is not pressed, but the duration is greater than 0, we can assume that the key was pressed + } else if (getKeyPressDuration(stack) > 0) { + // If the key is not pressed, but the duration is greater than 0, we can assume + // that the key was pressed // We can now post the event int duration = getKeyPressDuration(stack); diff --git a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/nightvision/NightVisionFunctions.java b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/nightvision/NightVisionFunctions.java index 658ef1ba2..37e96132d 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/nightvision/NightVisionFunctions.java +++ b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/nightvision/NightVisionFunctions.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.smartglasses.modules.nightvision; import dan200.computercraft.api.lua.LuaFunction; diff --git a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/nightvision/NightVisionModule.java b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/nightvision/NightVisionModule.java index b4818a0c9..a65132a74 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/nightvision/NightVisionModule.java +++ b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/nightvision/NightVisionModule.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.smartglasses.modules.nightvision; import de.srendi.advancedperipherals.AdvancedPeripherals; @@ -23,8 +38,7 @@ public ResourceLocation getName() { } @Override - @Nullable - public IModuleFunctions getFunctions(SmartGlassesAccess smartGlassesAccess) { + @Nullable public IModuleFunctions getFunctions(SmartGlassesAccess smartGlassesAccess) { return new NightVisionFunctions(this); } diff --git a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/nightvision/NightVisionModuleItem.java b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/nightvision/NightVisionModuleItem.java index 0e9c0257a..ada76db70 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/nightvision/NightVisionModuleItem.java +++ b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/nightvision/NightVisionModuleItem.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.smartglasses.modules.nightvision; import de.srendi.advancedperipherals.common.items.base.BaseItem; @@ -25,7 +40,8 @@ public IModule createModule(SmartGlassesAccess access) { } @Override - public void inventoryTick(ItemStack itemStack, Level level, Entity entity, int inventorySlot, boolean isCurrentItem, @Nullable SmartGlassesAccess access, @Nullable IModule module) { + public void inventoryTick(ItemStack itemStack, Level level, Entity entity, int inventorySlot, boolean isCurrentItem, + @Nullable SmartGlassesAccess access, @Nullable IModule module) { if (level.isClientSide() || !(entity instanceof Player player)) return; diff --git a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/ObjectProperty.java b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/ObjectProperty.java index 4f332efd5..9c34912a6 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/ObjectProperty.java +++ b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/ObjectProperty.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.smartglasses.modules.overlay; import de.srendi.advancedperipherals.common.smartglasses.modules.overlay.propertyTypes.PropertyType; @@ -8,8 +23,10 @@ import java.lang.annotation.Target; /** - * This annotation is used to mark a field as a property. It is used for the properties of lua objects. - * Fields annotated with @ObjectProperty will be accessible in lua via the arguments/the filter table for the specific object. + * This annotation is used to mark a field as a property. It is used for the + * properties of lua objects. Fields annotated with @ObjectProperty will be + * accessible in lua via the arguments/the filter table for the specific object. + * * @see PropertyType * @see OverlayObject */ diff --git a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/OverlayGlassesFunctions.java b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/OverlayGlassesFunctions.java index 2ad26b3a8..3137fe45c 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/OverlayGlassesFunctions.java +++ b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/OverlayGlassesFunctions.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.smartglasses.modules.overlay; import dan200.computercraft.api.lua.IArguments; @@ -28,7 +43,7 @@ public final String test() { public final MethodResult createPanel(String id, IArguments arguments) throws LuaException { Panel panel = new Panel(id, overlayModule, arguments); Pair success = overlayModule.addObject(panel); - if(!success.getRight()) + if (!success.getRight()) return MethodResult.of(success.getLeft(), IModule.ErrorConstants.ALREADY_EXISTS); return MethodResult.of(success.getLeft(), "SUCCESS"); @@ -36,7 +51,8 @@ public final MethodResult createPanel(String id, IArguments arguments) throws Lu @LuaFunction public final MethodResult getObjects(IArguments arguments) { - return MethodResult.of((Object) overlayModule.getObjects().stream().map(OverlayObject::getId).toArray(String[]::new)); + return MethodResult + .of((Object) overlayModule.getObjects().stream().map(OverlayObject::getId).toArray(String[]::new)); } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/OverlayGlassesItem.java b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/OverlayGlassesItem.java index 20a3bd78b..56cdb8570 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/OverlayGlassesItem.java +++ b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/OverlayGlassesItem.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.smartglasses.modules.overlay; import de.srendi.advancedperipherals.common.items.base.BaseItem; diff --git a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/OverlayModule.java b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/OverlayModule.java index e7b5c9fe9..490c5a74c 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/OverlayModule.java +++ b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/OverlayModule.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.smartglasses.modules.overlay; import de.srendi.advancedperipherals.AdvancedPeripherals; @@ -10,10 +25,11 @@ import java.util.concurrent.CopyOnWriteArraySet; - /** - * We want to support scripts which were made for the plethora classes. So we call this item the same as the overlay item from plethora - * We'll first add our own implementation for a rendering system and then add the API endpoints for plethora scripts + * We want to support scripts which were made for the plethora classes. So we + * call this item the same as the overlay item from plethora We'll first add our + * own implementation for a rendering system and then add the API endpoints for + * plethora scripts */ public class OverlayModule implements IModule { @@ -37,10 +53,10 @@ public IModuleFunctions getFunctions(SmartGlassesAccess smartGlassesAccess) { @Override public void tick(@NotNull SmartGlassesAccess smartGlassesAccess) { /* - Entity entity = smartGlassesAccess.getEntity(); - if (entity != null && entity.getLevel().getGameTime() % 20 == 0) - AdvancedPeripherals.LOGGER.info("I'm an overlay module! And I'm alive!"); - */ + * Entity entity = smartGlassesAccess.getEntity(); if (entity != null && + * entity.getLevel().getGameTime() % 20 == 0) + * AdvancedPeripherals.LOGGER.info("I'm an overlay module! And I'm alive!"); + */ } public SmartGlassesAccess getAccess() { @@ -52,11 +68,15 @@ public CopyOnWriteArraySet getObjects() { } /** - * Adds an object to the module. If the object already exists, it will return the object and stop proceeding + * Adds an object to the module. If the object already exists, it will return + * the object and stop proceeding * - * @param object The object which should be added - * @return A pair of the object and a boolean. The boolean is true if the object was added successfully and false if not. - * The object is the object which was added or the object which already exists(When not successful). + * @param object + * The object which should be added + * @return A pair of the object and a boolean. The boolean is true if the object + * was added successfully and false if not. The object is the object + * which was added or the object which already exists(When not + * successful). */ public Pair addObject(OverlayObject object) { for (OverlayObject overlayObject : objects) { diff --git a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/OverlayObject.java b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/OverlayObject.java index ff584021d..e39570907 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/OverlayObject.java +++ b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/OverlayObject.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.smartglasses.modules.overlay; import dan200.computercraft.api.lua.IArguments; @@ -20,7 +35,6 @@ import java.util.UUID; import java.util.stream.Collectors; - public abstract class OverlayObject { @BooleanProperty @@ -69,17 +83,22 @@ public final boolean isEnabled() { /** * Maps properties from the provided arguments to the fields of this class. *

- * This method uses Java Reflection to map properties from IArguments to the fields of the classes. - * It only maps properties that have the annotation {@link ObjectProperty}. If a field does not have this annotation, - * a warning message is logged and the method returns. + * This method uses Java Reflection to map properties from IArguments to the + * fields of the classes. It only maps properties that have the annotation + * {@link ObjectProperty}. If a field does not have this annotation, a warning + * message is logged and the method returns. *

- * If a property is valid, its value is cast to the field type and set as the new value of the field. - * If a property is not valid, a warning message is logged and the method returns. + * If a property is valid, its value is cast to the field type and set as the + * new value of the field. If a property is not valid, a warning message is + * logged and the method returns. *

- * If an error occurs during the mapping of properties, an exception message is logged and a LuaException is thrown. + * If an error occurs during the mapping of properties, an exception message is + * logged and a LuaException is thrown. * - * @param arguments the IArguments containing properties to be mapped - * @throws LuaException if an error occurs during the mapping of properties + * @param arguments + * the IArguments containing properties to be mapped + * @throws LuaException + * if an error occurs during the mapping of properties * @see IArguments * @see ObjectProperty * @see PropertyType @@ -112,7 +131,8 @@ public void reflectivelyMapProperties(IArguments arguments) throws LuaException } if (objectProperty == null) { - AdvancedPeripherals.debug("The field " + field.getName() + " has no ObjectProperty annotation and can't be changed.", Level.WARN); + AdvancedPeripherals.debug("The field " + field.getName() + + " has no ObjectProperty annotation and can't be changed.", Level.WARN); return; } @@ -130,7 +150,9 @@ public void reflectivelyMapProperties(IArguments arguments) throws LuaException field.set(this, castValueToFieldType(field, value)); } else { - AdvancedPeripherals.debug("The value " + value + " is not valid for the field " + field.getName() + ".", Level.WARN); + AdvancedPeripherals.debug( + "The value " + value + " is not valid for the field " + field.getName() + ".", + Level.WARN); return; } } @@ -143,11 +165,13 @@ public void reflectivelyMapProperties(IArguments arguments) throws LuaException } /** - * Casts the given value to the type of the provided field. - * Can be overwritten if the desired casting is not supported. + * Casts the given value to the type of the provided field. Can be overwritten + * if the desired casting is not supported. * - * @param field the field object representing the type to cast to - * @param value the value to be casted + * @param field + * the field object representing the type to cast to + * @param value + * the value to be casted * @return the casted value */ public Object castValueToFieldType(Field field, Object value) { @@ -170,7 +194,9 @@ public Object castValueToFieldType(Field field, Object value) { } else if (fieldType.equals(Float.TYPE)) { return Float.valueOf(value.toString()); } else { - AdvancedPeripherals.debug("The field type " + fieldType.getName() + " is not supported for the value " + value + ".", Level.WARN); + AdvancedPeripherals.debug( + "The field type " + fieldType.getName() + " is not supported for the value " + value + ".", + Level.WARN); } return value; } @@ -182,7 +208,7 @@ protected void handle(NetworkEvent.Context context) { protected void encode(FriendlyByteBuf buffer) { buffer.writeUtf(id); Entity entity = module.getAccess().getEntity(); - if(entity instanceof Player player) { + if (entity instanceof Player player) { buffer.writeBoolean(true); buffer.writeUUID(player.getUUID()); } else { diff --git a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/Panel.java b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/Panel.java index 562c07f10..f56aa00d8 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/Panel.java +++ b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/Panel.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.smartglasses.modules.overlay; import dan200.computercraft.api.lua.IArguments; @@ -10,7 +25,8 @@ import java.util.UUID; /** - * A panel is the standard panel which can contain multiple render-able objects in it. + * A panel is the standard panel which can contain multiple render-able objects + * in it. */ public class Panel extends RenderableObject { @@ -21,8 +37,10 @@ public Panel(String id, OverlayModule module, IArguments arguments) throws LuaEx /** * constructor for the client side initialization * - * @param id id of the object - * @param player the target player + * @param id + * id of the object + * @param player + * the target player */ public Panel(String id, UUID player) { super(id, player); @@ -35,12 +53,13 @@ protected void encode(FriendlyByteBuf buffer) { buffer.writeDouble(opacity); } - @Nullable - public static Panel decode(FriendlyByteBuf buffer) { + @Nullable public static Panel decode(FriendlyByteBuf buffer) { String id = buffer.readUtf(); boolean hasValidUUID = buffer.readBoolean(); if (!hasValidUUID) { - AdvancedPeripherals.exception("Tried to decode a buffer for an OverlayObject but without a valid player as target.", new IllegalArgumentException()); + AdvancedPeripherals.exception( + "Tried to decode a buffer for an OverlayObject but without a valid player as target.", + new IllegalArgumentException()); return null; } UUID player = buffer.readUUID(); diff --git a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/RenderableObject.java b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/RenderableObject.java index 01cad70a2..b60b3426b 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/RenderableObject.java +++ b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/RenderableObject.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.smartglasses.modules.overlay; import dan200.computercraft.api.lua.IArguments; diff --git a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/propertyTypes/BooleanProperty.java b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/propertyTypes/BooleanProperty.java index dc082c9d8..e6e351c04 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/propertyTypes/BooleanProperty.java +++ b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/propertyTypes/BooleanProperty.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.smartglasses.modules.overlay.propertyTypes; import de.srendi.advancedperipherals.common.smartglasses.modules.overlay.ObjectProperty; diff --git a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/propertyTypes/BooleanType.java b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/propertyTypes/BooleanType.java index 25ab0f531..6ff43999e 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/propertyTypes/BooleanType.java +++ b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/propertyTypes/BooleanType.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.smartglasses.modules.overlay.propertyTypes; public class BooleanType implements PropertyType { @@ -17,4 +32,3 @@ public void init(Object property) { // Nothing to init here, we don't have any filters for booleans } } - diff --git a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/propertyTypes/FixedPointNumberProperty.java b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/propertyTypes/FixedPointNumberProperty.java index a65635363..3d6c108bc 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/propertyTypes/FixedPointNumberProperty.java +++ b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/propertyTypes/FixedPointNumberProperty.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.smartglasses.modules.overlay.propertyTypes; import de.srendi.advancedperipherals.common.smartglasses.modules.overlay.ObjectProperty; diff --git a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/propertyTypes/FixedPointNumberType.java b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/propertyTypes/FixedPointNumberType.java index 04bf3bde7..fa1abb9e6 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/propertyTypes/FixedPointNumberType.java +++ b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/propertyTypes/FixedPointNumberType.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.smartglasses.modules.overlay.propertyTypes; import de.srendi.advancedperipherals.AdvancedPeripherals; @@ -31,4 +46,3 @@ public void init(Object property) { AdvancedPeripherals.debug("Initialized number property with min " + min + " and max " + max); } } - diff --git a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/propertyTypes/FloatingNumberProperty.java b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/propertyTypes/FloatingNumberProperty.java index e377472f3..c0d379fad 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/propertyTypes/FloatingNumberProperty.java +++ b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/propertyTypes/FloatingNumberProperty.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.smartglasses.modules.overlay.propertyTypes; import de.srendi.advancedperipherals.common.smartglasses.modules.overlay.ObjectProperty; diff --git a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/propertyTypes/FloatingNumberType.java b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/propertyTypes/FloatingNumberType.java index 05d6eb8df..645626632 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/propertyTypes/FloatingNumberType.java +++ b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/propertyTypes/FloatingNumberType.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.smartglasses.modules.overlay.propertyTypes; import de.srendi.advancedperipherals.AdvancedPeripherals; @@ -26,4 +41,3 @@ public void init(Object property) { AdvancedPeripherals.debug("Initialized decimal property with min " + min + " and max " + max); } } - diff --git a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/propertyTypes/PropertyType.java b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/propertyTypes/PropertyType.java index bd29944ba..02811f2ea 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/propertyTypes/PropertyType.java +++ b/src/main/java/de/srendi/advancedperipherals/common/smartglasses/modules/overlay/propertyTypes/PropertyType.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.smartglasses.modules.overlay.propertyTypes; import de.srendi.advancedperipherals.AdvancedPeripherals; @@ -6,9 +21,11 @@ import java.lang.reflect.InvocationTargetException; /** - * This interface represents a property type. It is used to check if a value is valid for the property and to map the value to the correct type. + * This interface represents a property type. It is used to check if a value is + * valid for the property and to map the value to the correct type. * - * @param the type of the property value + * @param + * the type of the property value * @see ObjectProperty */ public interface PropertyType { @@ -20,7 +37,8 @@ public interface PropertyType { static PropertyType of(ObjectProperty property) { try { return property.type().getDeclaredConstructor().newInstance(); - } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException exception) { + } catch (InstantiationException | IllegalAccessException | NoSuchMethodException + | InvocationTargetException exception) { AdvancedPeripherals.exception("An error occurred while trying to create the property type", exception); } return null; diff --git a/src/main/java/de/srendi/advancedperipherals/common/util/ChunkManager.java b/src/main/java/de/srendi/advancedperipherals/common/util/ChunkManager.java index 3b338284d..9182ee100 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/util/ChunkManager.java +++ b/src/main/java/de/srendi/advancedperipherals/common/util/ChunkManager.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.util; import de.srendi.advancedperipherals.AdvancedPeripherals; @@ -20,7 +35,11 @@ import java.time.LocalDateTime; import java.time.ZoneOffset; -import java.util.*; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; +import java.util.UUID; @Mod.EventBusSubscriber(modid = AdvancedPeripherals.MOD_ID) public class ChunkManager extends SavedData { @@ -121,7 +140,8 @@ public synchronized boolean removeForceChunk(ServerLevel level, UUID owner) { return true; String dimensionName = level.dimension().location().toString(); if (!chunkRecord.getDimensionName().equals(dimensionName)) - throw new IllegalArgumentException(String.format("Incorrect dimension! Should be %s instead of %s", chunkRecord.getDimensionName(), dimensionName)); + throw new IllegalArgumentException(String.format("Incorrect dimension! Should be %s instead of %s", + chunkRecord.getDimensionName(), dimensionName)); boolean result = unforceChunkRecord(owner, chunkRecord, level); if (result) { forcedChunks.remove(owner); @@ -134,7 +154,9 @@ private synchronized boolean unforceChunkRecord(UUID owner, LoadChunkRecord chun boolean result = true; final ChunkPos pos = chunkRecord.getPos(); final int chunkRadius = chunkRecord.getRadius(); - AdvancedPeripherals.debug(String.format("Trying to unload forced chunk cluster %s at %s with radius %d", owner, pos, chunkRadius), Level.WARN); + AdvancedPeripherals.debug( + String.format("Trying to unload forced chunk cluster %s at %s with radius %d", owner, pos, chunkRadius), + Level.WARN); for (int x = -chunkRadius; x <= chunkRadius; x++) { for (int z = -chunkRadius; z <= chunkRadius; z++) { result &= unforceChunk(owner, level, new ChunkPos(pos.x + x, pos.z + z)); @@ -149,7 +171,8 @@ public synchronized void init() { } initialized = true; - AdvancedPeripherals.debug(String.format("Schedule chunk manager init, forcedChunks = %d", forcedChunks.size()), Level.WARN); + AdvancedPeripherals.debug(String.format("Schedule chunk manager init, forcedChunks = %d", forcedChunks.size()), + Level.WARN); final int chunkRadius = APConfig.PERIPHERALS_CONFIG.chunkyTurtleRadius.get(); final Map levels = getServerLevels(); forcedChunks.forEach((uuid, value) -> { @@ -161,7 +184,9 @@ public synchronized void init() { } final ChunkPos pos = value.getPos(); final int loadedRadius = value.getRadius(); - AdvancedPeripherals.debug(String.format("Recorded chunk in %s at %s with radius %d", dimensionName, pos, loadedRadius), Level.INFO); + AdvancedPeripherals.debug( + String.format("Recorded chunk in %s at %s with radius %d", dimensionName, pos, loadedRadius), + Level.INFO); if (loadedRadius == chunkRadius) { return; } @@ -182,7 +207,8 @@ public synchronized void init() { } } } else if (loadedRadius < chunkRadius) { - // otherwise, only do the changed part to reduce startup time (in case we have a lot chunky turtle) + // otherwise, only do the changed part to reduce startup time (in case we have a + // lot chunky turtle) for (int x = -chunkRadius; x <= chunkRadius; x++) { for (int z = -chunkRadius; z <= chunkRadius; z++) { if (Math.abs(x) > loadedRadius || Math.abs(z) > loadedRadius) { @@ -240,7 +266,8 @@ private static Map getServerLevels() { } private static ServerLevel getServerLevel(String name) { - ResourceKey key = ResourceKey.create(Registry.DIMENSION_REGISTRY, new ResourceLocation(name)); + ResourceKey key = ResourceKey.create(Registry.DIMENSION_REGISTRY, + new ResourceLocation(name)); return ServerLifecycleHooks.getCurrentServer().getLevel(key); } @@ -265,7 +292,8 @@ private static class LoadChunkRecord { public static LoadChunkRecord deserialize(@NotNull CompoundTag tag) { Set keys = tag.getAllKeys(); int radius = keys.contains(RADIUS_TAG) ? tag.getInt(RADIUS_TAG) : -1; - return new LoadChunkRecord(tag.getString(DIMENSION_NAME_TAG), NBTUtil.chunkPosFromNBT(tag.getCompound(POS_TAG)), radius); + return new LoadChunkRecord(tag.getString(DIMENSION_NAME_TAG), + NBTUtil.chunkPosFromNBT(tag.getCompound(POS_TAG)), radius); } public @NotNull ChunkPos getPos() { diff --git a/src/main/java/de/srendi/advancedperipherals/common/util/CoordUtil.java b/src/main/java/de/srendi/advancedperipherals/common/util/CoordUtil.java index 3c8039fd0..74331fd65 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/util/CoordUtil.java +++ b/src/main/java/de/srendi/advancedperipherals/common/util/CoordUtil.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.util; import dan200.computercraft.api.lua.LuaException; @@ -16,8 +31,10 @@ public class CoordUtil { - public static boolean isInRange(@Nullable BlockPos pos, @Nullable Level world, @Nullable Player player, int range, int maxRange) { - // There are rare cases where these can be null. For example if a player detector pocket computer runs while not in a player inventory + public static boolean isInRange(@Nullable BlockPos pos, @Nullable Level world, @Nullable Player player, int range, + int maxRange) { + // There are rare cases where these can be null. For example if a player + // detector pocket computer runs while not in a player inventory // Fixes https://github.com/SirEndii/AdvancedPeripherals/issues/356 if (pos == null || world == null || player == null) return false; @@ -27,7 +44,8 @@ public static boolean isInRange(@Nullable BlockPos pos, @Nullable Level world, @ } // To fix issue #439 - private static boolean isPlayerInBlockRange(@NotNull BlockPos pos, @NotNull Level world, @NotNull Player player, double range) { + private static boolean isPlayerInBlockRange(@NotNull BlockPos pos, @NotNull Level world, @NotNull Player player, + double range) { if (range != -1 && player.getLevel() != world) return false; @@ -37,24 +55,28 @@ private static boolean isPlayerInBlockRange(@NotNull BlockPos pos, @NotNull Leve ey = y; y = tmp; } - double bx = (double)(pos.getX() + 0.5), by = (double)(pos.getY() + 0.5), bz = (double)(pos.getZ() + 0.5); + double bx = (double) (pos.getX() + 0.5), by = (double) (pos.getY() + 0.5), bz = (double) (pos.getZ() + 0.5); return Math.abs(x - bx) <= range && Math.abs(z - bz) <= range && - // check both feet position and eye position, and ensure it will work if player is higher than 2 blocks - ((y <= by && by <= ey) || Math.min(Math.abs(y - by), Math.abs(ey - by)) <= range); + // check both feet position and eye position, and ensure it will work if player + // is higher than 2 blocks + ((y <= by && by <= ey) || Math.min(Math.abs(y - by), Math.abs(ey - by)) <= range); } - public static boolean isInRange(@Nullable BlockPos pos, @Nullable Level world, @Nullable Player player, int x, int y, int z, int maxRange) { + public static boolean isInRange(@Nullable BlockPos pos, @Nullable Level world, @Nullable Player player, int x, + int y, int z, int maxRange) { if (pos == null || world == null || player == null) return false; - // It shouldn't multiply by 2 here, but it should have the same behavior as isInRange when x == y == z == range + // It shouldn't multiply by 2 here, but it should have the same behavior as + // isInRange when x == y == z == range x = Math.min(Math.abs(x), maxRange != -1 ? maxRange : Integer.MAX_VALUE); y = Math.min(Math.abs(y), maxRange != -1 ? maxRange : Integer.MAX_VALUE); z = Math.min(Math.abs(z), maxRange != -1 ? maxRange : Integer.MAX_VALUE); return isPlayerInBlockRangeXYZ(pos, world, player, (double) x, (double) y, (double) z, maxRange); } - private static boolean isPlayerInBlockRangeXYZ(@NotNull BlockPos pos, @NotNull Level world, @NotNull Player player, double dx, double dy, double dz, int maxRange) { + private static boolean isPlayerInBlockRangeXYZ(@NotNull BlockPos pos, @NotNull Level world, @NotNull Player player, + double dx, double dy, double dz, int maxRange) { if (maxRange != -1 && player.getLevel() != world) return false; @@ -64,22 +86,26 @@ private static boolean isPlayerInBlockRangeXYZ(@NotNull BlockPos pos, @NotNull L ey = y; y = tmp; } - double bx = (double)(pos.getX() + 0.5), by = (double)(pos.getY() + 0.5), bz = (double)(pos.getZ() + 0.5); - return Math.abs(x - bx) <= dx && Math.abs(z - bz) <= dz && - ((y <= by && by <= ey) || Math.min(Math.abs(y - by), Math.abs(ey - by)) <= dy); + double bx = (double) (pos.getX() + 0.5), by = (double) (pos.getY() + 0.5), bz = (double) (pos.getZ() + 0.5); + return Math.abs(x - bx) <= dx && Math.abs(z - bz) <= dz + && ((y <= by && by <= ey) || Math.min(Math.abs(y - by), Math.abs(ey - by)) <= dy); } - public static boolean isInRange(@Nullable BlockPos blockPos, @Nullable Player player, @Nullable Level world, @NotNull BlockPos firstPos, @NotNull BlockPos secondPos, int maxRange) { + public static boolean isInRange(@Nullable BlockPos blockPos, @Nullable Player player, @Nullable Level world, + @NotNull BlockPos firstPos, @NotNull BlockPos secondPos, int maxRange) { if (blockPos == null || world == null || player == null) return false; double i = Math.abs(player.getX() - blockPos.getX()); double j = Math.abs(player.getZ() - blockPos.getZ()); - // Check if the distance of the player is within the max range of the player detector - // Use manhattan distance, not euclidean distance to keep same behavior than other `isInRange` functions + // Check if the distance of the player is within the max range of the player + // detector + // Use manhattan distance, not euclidean distance to keep same behavior than + // other `isInRange` functions if (i + j > (maxRange != -1 ? maxRange : Integer.MAX_VALUE)) return false; - return world.getNearbyPlayers(TargetingConditions.forNonCombat(), null, new AABB(firstPos, secondPos)).contains(player); + return world.getNearbyPlayers(TargetingConditions.forNonCombat(), null, new AABB(firstPos, secondPos)) + .contains(player); } public static Direction getDirection(FrontAndTop orientation, String computerSide) throws LuaException { diff --git a/src/main/java/de/srendi/advancedperipherals/common/util/CountingWipingStream.java b/src/main/java/de/srendi/advancedperipherals/common/util/CountingWipingStream.java index fa40e2163..f12663a39 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/util/CountingWipingStream.java +++ b/src/main/java/de/srendi/advancedperipherals/common/util/CountingWipingStream.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.util; import java.io.IOException; diff --git a/src/main/java/de/srendi/advancedperipherals/common/util/DataStorageUtil.java b/src/main/java/de/srendi/advancedperipherals/common/util/DataStorageUtil.java index 0499427cc..d598c9493 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/util/DataStorageUtil.java +++ b/src/main/java/de/srendi/advancedperipherals/common/util/DataStorageUtil.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.util; import dan200.computercraft.api.pocket.IPocketAccess; @@ -23,9 +38,9 @@ public static CompoundTag getDataStorage(@NotNull IPocketAccess pocket) { } /** - * This class is for persistent data sharing between peripherals and another part of systems - * Like, for example, for ModelTransformingTurtle logic, because it's executed on the client where - * aren't any peripherals available + * This class is for persistent data sharing between peripherals and another + * part of systems Like, for example, for ModelTransformingTurtle logic, because + * it's executed on the client where aren't any peripherals available **/ public static class RotationCharge { @@ -52,7 +67,8 @@ public static boolean consume(@NotNull ITurtleAccess access, @NotNull TurtleSide public static void addCycles(IPeripheralOwner owner, int count) { CompoundTag data = owner.getDataStorage(); - data.putInt(ROTATION_CHARGE_SETTING, Math.max(0, data.getInt(ROTATION_CHARGE_SETTING)) + count * ROTATION_STEPS); + data.putInt(ROTATION_CHARGE_SETTING, + Math.max(0, data.getInt(ROTATION_CHARGE_SETTING)) + count * ROTATION_STEPS); owner.markDataStorageDirty(); } diff --git a/src/main/java/de/srendi/advancedperipherals/common/util/EnergyStorageProxy.java b/src/main/java/de/srendi/advancedperipherals/common/util/EnergyStorageProxy.java index 81d7f4a00..7bd9777ab 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/util/EnergyStorageProxy.java +++ b/src/main/java/de/srendi/advancedperipherals/common/util/EnergyStorageProxy.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.util; import de.srendi.advancedperipherals.common.blocks.blockentities.EnergyDetectorEntity; diff --git a/src/main/java/de/srendi/advancedperipherals/common/util/EnumColor.java b/src/main/java/de/srendi/advancedperipherals/common/util/EnumColor.java index 9273fc561..63ec61188 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/util/EnumColor.java +++ b/src/main/java/de/srendi/advancedperipherals/common/util/EnumColor.java @@ -1,25 +1,88 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.util; import net.minecraft.network.chat.Component; public enum EnumColor { - BLACK("\u00a70", "Black", "black", "§0", 0, new float[]{0f, 0f, 0f, 1f}), - DARK_BLUE("\u00a71", "Blue", "blue", "§1", 0xFF0000c9, new float[]{0f, 0f, 0.804f, 1f}), - DARK_GREEN("\u00a72", "Green", "green", "§2", 0xFF0c9400, new float[]{0.048f, 0.592f, 0f, 1f}), - DARK_AQUA("\u00a73", "Cyan", "cyan", "§3", 0xFF009494, new float[]{0f, 0.592f, 0.592f, 1f}), - DARK_RED("\u00a74", "Dark Red", "dark_red", "§4", 0xFF940000, new float[]{0.592f, 0f, 0f, 1f}), - DARK_PURPLE("\u00a75", "Purple", "purple", "§5", 0xFF510094, new float[]{0.324f, 0f, 0.592f, 1f}), - GOLD("\u00a76", "Orange", "orange", "§6", 0xFFb59700, new float[]{1f, 0.407f, 0f, 1f}), - GRAY("\u00a77", "Light Gray", "light_gray", "§7", 0xFF616161, new float[]{0.388f, 0.388f, 0.388f, 1f}), - DARK_GRAY("\u00a78", "Gray", "gray", "§8", 0xFF4a4a4a, new float[]{0.296f, 0.296f, 0.296f, 1f}), - BLUE("\u00a79", "Light Blue", "light_blue", "§9", 0xFF1919ff, new float[]{0.098f, 0.098f, 1f, 1f}), - GREEN("\u00a7a", "Lime", "lime", "§a", 0xFF00e02d, new float[]{0f, 0.878f, 0.176f, 1f}), - AQUA("\u00a7b", "Aqua", "aqua", "§b", 0xFF17ffe4, new float[]{0.090f, 1f, 0.894f, 1f}), - RED("\u00a7c", "Red", "red", "§c", 0xFFff1c1c, new float[]{1f, 0.109f, 0.109f, 1f}), - LIGHT_PURPLE("\u00a7d", "Magenta", "magenta", "§d", 0xFF7424ff, new float[]{0.454f, 0.141f, 1f, 1f}), - YELLOW("\u00a7e", "Yellow", "yellow", "§e", 0xFFc8ff00, new float[]{0.784f, 1f, 0f, 1f}), - WHITE("\u00a7f", "White", "white", "§f", 0xFFffffff, new float[]{1f, 1f, 1f, 1f}); + BLACK("\u00a70", "Black", "black", "§0", 0, new float[]{0f, 0f, 0f, 1f}), DARK_BLUE("\u00a71", "Blue", "blue", "§1", + 0xFF0000c9, new float[]{0f, 0f, 0.804f, 1f}), DARK_GREEN("\u00a72", "Green", "green", "§2", 0xFF0c9400, + new float[]{0.048f, 0.592f, 0f, 1f}), DARK_AQUA("\u00a73", "Cyan", "cyan", "§3", 0xFF009494, + new float[]{0f, 0.592f, 0.592f, 1f}), DARK_RED("\u00a74", "Dark Red", "dark_red", "§4", + 0xFF940000, new float[]{0.592f, 0f, 0f, 1f}), DARK_PURPLE("\u00a75", "Purple", + "purple", "§5", 0xFF510094, + new float[]{0.324f, 0f, 0.592f, 1f}), GOLD("\u00a76", "Orange", "orange", + "§6", 0xFFb59700, new float[]{1f, 0.407f, 0f, 1f}), GRAY("\u00a77", + "Light Gray", "light_gray", "§7", 0xFF616161, + new float[]{0.388f, 0.388f, 0.388f, 1f}), DARK_GRAY( + "\u00a78", "Gray", "gray", "§8", 0xFF4a4a4a, + new float[]{0.296f, 0.296f, 0.296f, 1f}), BLUE( + "\u00a79", "Light Blue", "light_blue", "§9", + 0xFF1919ff, + new float[]{0.098f, 0.098f, 1f, 1f}), GREEN( + "\u00a7a", "Lime", "lime", "§a", + 0xFF00e02d, + new float[]{0f, 0.878f, 0.176f, + 1f}), AQUA("\u00a7b", + "Aqua", "aqua", + "§b", 0xFF17ffe4, + new float[]{0.090f, + 1f, 0.894f, + 1f}), RED( + "\u00a7c", + "Red", + "red", + "§c", + 0xFFff1c1c, + new float[]{ + 1f, + 0.109f, + 0.109f, + 1f}), LIGHT_PURPLE( + "\u00a7d", + "Magenta", + "magenta", + "§d", + 0xFF7424ff, + new float[]{ + 0.454f, + 0.141f, + 1f, + 1f}), YELLOW( + "\u00a7e", + "Yellow", + "yellow", + "§e", + 0xFFc8ff00, + new float[]{ + 0.784f, + 1f, + 0f, + 1f}), WHITE( + "\u00a7f", + "White", + "white", + "§f", + 0xFFffffff, + new float[]{ + 1f, + 1f, + 1f, + 1f}); private final String code; private final String name; diff --git a/src/main/java/de/srendi/advancedperipherals/common/util/FluidStorageProxy.java b/src/main/java/de/srendi/advancedperipherals/common/util/FluidStorageProxy.java index a61361aa0..20faa0552 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/util/FluidStorageProxy.java +++ b/src/main/java/de/srendi/advancedperipherals/common/util/FluidStorageProxy.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.util; import de.srendi.advancedperipherals.common.blocks.blockentities.FluidDetectorEntity; @@ -21,7 +36,6 @@ public FluidStorageProxy(FluidDetectorEntity fluidDetectorEntity, int maxTransfe this.maxTransferRate = maxTransferRate; } - public int getMaxTransferRate() { return maxTransferRate; } @@ -74,7 +88,7 @@ public int fill(FluidStack resource, IFluidHandler.FluidAction action) { if (!action.simulate()) { transferedInThisTick += transferred; fluidDetectorEntity.lastFlowedLiquid = resource.copy(); - //transferedInThisTick = transferred; + // transferedInThisTick = transferred; } return transferred; }).orElse(0); diff --git a/src/main/java/de/srendi/advancedperipherals/common/util/GasStorageProxy.java b/src/main/java/de/srendi/advancedperipherals/common/util/GasStorageProxy.java index d4e514a6d..ebd623902 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/util/GasStorageProxy.java +++ b/src/main/java/de/srendi/advancedperipherals/common/util/GasStorageProxy.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.util; import de.srendi.advancedperipherals.common.blocks.blockentities.GasDetectorEntity; @@ -19,7 +34,6 @@ public GasStorageProxy(GasDetectorEntity fluidDetectorEntity, int maxTransferRat this.maxTransferRate = maxTransferRate; } - public int getMaxTransferRate() { return maxTransferRate; } @@ -44,8 +58,7 @@ public int getTanks() { return 1; } - @NotNull - @Override + @NotNull @Override public GasStack getChemicalInTank(int tank) { Optional out = fluidDetectorEntity.getOutputStorage(); return out.map(outStorage -> outStorage.getChemicalInTank(tank)).orElse(GasStack.EMPTY); @@ -69,8 +82,7 @@ public boolean isValid(int tank, @NotNull GasStack stack) { return out.map(outStorage -> outStorage.isValid(tank, stack)).orElse(false); } - @NotNull - @Override + @NotNull @Override public GasStack insertChemical(@NotNull GasStack stack, @NotNull Action action) { Optional out = fluidDetectorEntity.getOutputStorage(); return out.map(outStorage -> { @@ -85,14 +97,12 @@ public GasStack insertChemical(@NotNull GasStack stack, @NotNull Action action) }).orElse(GasStack.EMPTY); } - @NotNull - @Override + @NotNull @Override public GasStack insertChemical(int tank, @NotNull GasStack stack, @NotNull Action action) { return insertChemical(stack, action); } - @NotNull - @Override + @NotNull @Override public GasStack extractChemical(int tank, long amount, @NotNull Action action) { return GasStack.EMPTY; } diff --git a/src/main/java/de/srendi/advancedperipherals/common/util/HitResultUtil.java b/src/main/java/de/srendi/advancedperipherals/common/util/HitResultUtil.java index 1a9508a1e..4466b18c7 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/util/HitResultUtil.java +++ b/src/main/java/de/srendi/advancedperipherals/common/util/HitResultUtil.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.util; import de.srendi.advancedperipherals.common.addons.computercraft.peripheral.DistanceDetectorPeripheral; @@ -9,7 +24,11 @@ import net.minecraft.world.level.ClipContext; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.phys.*; +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.shapes.CollisionContext; import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; @@ -21,16 +40,22 @@ public class HitResultUtil { /** - * This method is used to get the hit result of an entity from the start position of a block + * This method is used to get the hit result of an entity from the start + * position of a block * - * @param to the target position/max position - * @param from the source position like a block - * @param level the level - * @param ignoreTransparent if transparent blocks should be ignored - * @return the hit result. {@link BlockHitResult#miss(Vec3, Direction, BlockPos)} if nothing found + * @param to + * the target position/max position + * @param from + * the source position like a block + * @param level + * the level + * @param ignoreTransparent + * if transparent blocks should be ignored + * @return the hit result. + * {@link BlockHitResult#miss(Vec3, Direction, BlockPos)} if nothing + * found */ - @NotNull - public static HitResult getHitResult(Vec3 to, Vec3 from, Level level, boolean ignoreTransparent) { + @NotNull public static HitResult getHitResult(Vec3 to, Vec3 from, Level level, boolean ignoreTransparent) { EntityHitResult entityResult = getEntityHitResult(to, from, level); BlockHitResult blockResult = getBlockHitResult(to, from, level, ignoreTransparent); @@ -44,7 +69,8 @@ public static HitResult getHitResult(Vec3 to, Vec3 from, Level level, boolean ig return BlockHitResult.miss(from, blockResult.getDirection(), new BlockPos(to)); double blockDistance = new BlockPos(from).distManhattan(blockResult.getBlockPos()); - double entityDistance = new BlockPos(from).distManhattan(new Vec3i(entityResult.getLocation().x, entityResult.getLocation().y, entityResult.getLocation().z)); + double entityDistance = new BlockPos(from).distManhattan( + new Vec3i(entityResult.getLocation().x, entityResult.getLocation().y, entityResult.getLocation().z)); if (blockDistance < entityDistance) return blockResult; @@ -53,18 +79,22 @@ public static HitResult getHitResult(Vec3 to, Vec3 from, Level level, boolean ig } /** - * This method is used to get the hit result of an entity from the start position of a block - * This could be used to find an entity from the eyes position of another entity but since - * this method uses one AABB made out of the two coordinates, this would also find any entities - * which are not located in the ray you might want. {@link DistanceDetectorPeripheral#getDistance()} + * This method is used to get the hit result of an entity from the start + * position of a block This could be used to find an entity from the eyes + * position of another entity but since this method uses one AABB made out of + * the two coordinates, this would also find any entities which are not located + * in the ray you might want. {@link DistanceDetectorPeripheral#getDistance()} * - * @param to the target position/max position - * @param from the source position like a block - * @param level the world - * @return the entity hit result. An empty HitResult with {@link HitResult.Type#MISS} as type if nothing found + * @param to + * the target position/max position + * @param from + * the source position like a block + * @param level + * the world + * @return the entity hit result. An empty HitResult with + * {@link HitResult.Type#MISS} as type if nothing found */ - @NotNull - public static EntityHitResult getEntityHitResult(Vec3 to, Vec3 from, Level level) { + @NotNull public static EntityHitResult getEntityHitResult(Vec3 to, Vec3 from, Level level) { AABB checkingBox = new AABB(to, from); List entities = level.getEntities((Entity) null, checkingBox, (entity) -> true); @@ -82,7 +112,8 @@ public static EntityHitResult getEntityHitResult(Vec3 to, Vec3 from, Level level } double distance = new BlockPos(from).distManhattan(new Vec3i(entity.getX(), entity.getY(), entity.getZ())); - double nearestDistance = new BlockPos(from).distManhattan(new Vec3i(nearestEntity.getX(), nearestEntity.getY(), nearestEntity.getZ())); + double nearestDistance = new BlockPos(from) + .distManhattan(new Vec3i(nearestEntity.getX(), nearestEntity.getY(), nearestEntity.getZ())); // If it's closer, set it as the nearest entity if (distance < nearestDistance) @@ -93,30 +124,39 @@ public static EntityHitResult getEntityHitResult(Vec3 to, Vec3 from, Level level } /** - * This method is used to get the hit result of a block from the start position of a block + * This method is used to get the hit result of a block from the start position + * of a block * - * @param to the target position/max position - * @param from the source position - * @param level the world - * @param ignoreNoOccluded if true, the method will ignore blocks which are not occluding like glass - * @return the block hit result. {@link BlockHitResult#miss(Vec3, Direction, BlockPos)} if nothing found + * @param to + * the target position/max position + * @param from + * the source position + * @param level + * the world + * @param ignoreNoOccluded + * if true, the method will ignore blocks which are not occluding + * like glass + * @return the block hit result. + * {@link BlockHitResult#miss(Vec3, Direction, BlockPos)} if nothing + * found */ - @NotNull - public static BlockHitResult getBlockHitResult(Vec3 to, Vec3 from, Level level, boolean ignoreNoOccluded) { - return level.clip(new AdvancecClipContext(from, to, ignoreNoOccluded ? IgnoreNoOccludedContext.INSTANCE : ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, null)); + @NotNull public static BlockHitResult getBlockHitResult(Vec3 to, Vec3 from, Level level, boolean ignoreNoOccluded) { + return level.clip(new AdvancecClipContext(from, to, + ignoreNoOccluded ? IgnoreNoOccludedContext.INSTANCE : ClipContext.Block.COLLIDER, + ClipContext.Fluid.NONE, null)); } public static class EmptyEntityHitResult extends EntityHitResult { /** - * The super constructor is a NotNull argument but since this result is empty, we'll just return null + * The super constructor is a NotNull argument but since this result is empty, + * we'll just return null */ public EmptyEntityHitResult() { super(null, null); } - @NotNull - @Override + @NotNull @Override public Type getType() { return Type.MISS; } @@ -129,28 +169,30 @@ private enum IgnoreNoOccludedContext implements ClipContext.ShapeGetter { INSTANCE; - @NotNull - @Override - public VoxelShape get(BlockState pState, @NotNull BlockGetter pBlock, @NotNull BlockPos pPos, @NotNull CollisionContext pCollisionContext) { + @NotNull @Override + public VoxelShape get(BlockState pState, @NotNull BlockGetter pBlock, @NotNull BlockPos pPos, + @NotNull CollisionContext pCollisionContext) { return !pState.canOcclude() ? Shapes.empty() : pState.getCollisionShape(pBlock, pPos, pCollisionContext); } } /** - * A clip context but with a custom shape getter. Used to define another shape getter for the block like {@link IgnoreNoOccludedContext} + * A clip context but with a custom shape getter. Used to define another shape + * getter for the block like {@link IgnoreNoOccludedContext} */ private static class AdvancecClipContext extends ClipContext { private final ShapeGetter blockShapeGetter; - protected AdvancecClipContext(Vec3 from, Vec3 to, ShapeGetter blockShapeGetter, Fluid fluidShapeGetter, @Nullable Entity entity) { + protected AdvancecClipContext(Vec3 from, Vec3 to, ShapeGetter blockShapeGetter, Fluid fluidShapeGetter, + @Nullable Entity entity) { super(from, to, Block.COLLIDER, fluidShapeGetter, entity); this.blockShapeGetter = blockShapeGetter; } - @NotNull - @Override - public VoxelShape getBlockShape(@NotNull BlockState pBlockState, @NotNull BlockGetter pLevel, @NotNull BlockPos pPos) { + @NotNull @Override + public VoxelShape getBlockShape(@NotNull BlockState pBlockState, @NotNull BlockGetter pLevel, + @NotNull BlockPos pPos) { return blockShapeGetter.get(pBlockState, pLevel, pPos, this.collisionContext); } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/util/KeybindUtil.java b/src/main/java/de/srendi/advancedperipherals/common/util/KeybindUtil.java index c0c9f68cd..28ad48412 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/util/KeybindUtil.java +++ b/src/main/java/de/srendi/advancedperipherals/common/util/KeybindUtil.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.util; import com.mojang.blaze3d.platform.InputConstants; @@ -11,7 +26,8 @@ public class KeybindUtil { public static boolean isKeyPressed(KeyMapping keyBinding) { if (keyBinding.isDown()) { return true; - } else if (keyBinding.getKeyConflictContext().isActive() && keyBinding.getKeyModifier().isActive(keyBinding.getKeyConflictContext())) { + } else if (keyBinding.getKeyConflictContext().isActive() + && keyBinding.getKeyModifier().isActive(keyBinding.getKeyConflictContext())) { return isKeyDown(keyBinding); } else { return KeyModifier.isKeyCodeModifier(keyBinding.getKey()) && isKeyDown(keyBinding); @@ -35,5 +51,4 @@ private static boolean isKeyDown(KeyMapping keyBinding) { return false; } - } diff --git a/src/main/java/de/srendi/advancedperipherals/common/util/LuaConverter.java b/src/main/java/de/srendi/advancedperipherals/common/util/LuaConverter.java index e74410111..9d65481a1 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/util/LuaConverter.java +++ b/src/main/java/de/srendi/advancedperipherals/common/util/LuaConverter.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.util; import dan200.computercraft.api.lua.LuaException; @@ -19,9 +34,9 @@ import net.minecraftforge.common.IForgeShearable; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidType; - import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; + import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -47,7 +62,8 @@ public static Map livingEntityToLua(LivingEntity entity) { Map data = entityToLua(entity); data.put("health", entity.getHealth()); data.put("maxHealth", entity.getMaxHealth()); - data.put("lastDamageSource", entity.getLastDamageSource() == null ? null : entity.getLastDamageSource().toString()); + data.put("lastDamageSource", + entity.getLastDamageSource() == null ? null : entity.getLastDamageSource().toString()); return data; } @@ -63,12 +79,15 @@ public static Map animalToLua(Animal animal, ItemStack itemInHan } public static Map completeEntityToLua(Entity entity, ItemStack itemInHand) { - if (entity instanceof Animal animal) return animalToLua(animal, itemInHand); - if (entity instanceof LivingEntity livingEntity) return livingEntityToLua(livingEntity); + if (entity instanceof Animal animal) + return animalToLua(animal, itemInHand); + if (entity instanceof LivingEntity livingEntity) + return livingEntityToLua(livingEntity); return entityToLua(entity); } - public static Map completeEntityWithPositionToLua(Entity entity, ItemStack itemInHand, BlockPos pos) { + public static Map completeEntityWithPositionToLua(Entity entity, ItemStack itemInHand, + BlockPos pos) { Map data = completeEntityToLua(entity, itemInHand); data.put("x", entity.getX() - pos.getX()); data.put("y", entity.getY() - pos.getY()); @@ -79,13 +98,16 @@ public static Map completeEntityWithPositionToLua(Entity entity, /** * Block states to a lua representable object * - * @param blockStateValue block state see {@link net.minecraft.world.level.block.state.BlockState#getValue(Property)} + * @param blockStateValue + * block state see + * {@link net.minecraft.world.level.block.state.BlockState#getValue(Property)} * @return the state cast to a lua representable object */ public static Object stateToObject(Comparable blockStateValue) { if (blockStateValue == null) { return null; - } else if (blockStateValue instanceof Boolean || blockStateValue instanceof Number || blockStateValue instanceof String) { + } else if (blockStateValue instanceof Boolean || blockStateValue instanceof Number + || blockStateValue instanceof String) { // Just return the value since lua can represent them just fine return blockStateValue; } else if (blockStateValue instanceof StringRepresentable stringRepresentable) { @@ -96,7 +118,8 @@ public static Object stateToObject(Comparable blockStateValue) { } public static Object posToObject(BlockPos pos) { - if (pos == null) return null; + if (pos == null) + return null; Map map = new HashMap<>(3); map.put("x", pos.getX()); @@ -105,8 +128,7 @@ public static Object posToObject(BlockPos pos) { return map; } - @Nullable - public static Map itemStackToObject(@NotNull ItemStack stack) { + @Nullable public static Map itemStackToObject(@NotNull ItemStack stack) { if (stack.isEmpty()) { return null; } @@ -121,7 +143,8 @@ public static Map itemStackToObject(@NotNull ItemStack stack) { } public static Map fluidStackToObject(@NotNull FluidStack stack) { - if (stack.isEmpty()) return new HashMap<>(); + if (stack.isEmpty()) + return new HashMap<>(); Map map = fluidToObject(stack.getFluid()); CompoundTag nbt = stack.copy().getOrCreateTag(); map.put("count", stack.getAmount()); @@ -140,13 +163,14 @@ public static Map itemStackToObject(@NotNull ItemStack itemStack /** * Returns the stack but with a slot entry. Used to prevent zero indexed tables * - * @param stack the item stack - * @param slot the slot of the item + * @param stack + * the item stack + * @param slot + * the slot of the item * @return a Map containing proper item stack details * @see InventoryManagerPeripheral#getItems() */ - @Nullable - public static Map stackToObjectWithSlot(@NotNull ItemStack stack, int slot) { + @Nullable public static Map stackToObjectWithSlot(@NotNull ItemStack stack, int slot) { if (stack.isEmpty()) { return null; } @@ -175,7 +199,8 @@ public static Map fluidToObject(@NotNull Fluid fluid) { } public static List tagsToList(@NotNull Supplier>> tags) { - if (tags.get().findAny().isEmpty()) return Collections.emptyList(); + if (tags.get().findAny().isEmpty()) + return Collections.emptyList(); return tags.get().map(LuaConverter::tagToString).toList(); } @@ -187,13 +212,15 @@ public static String tagToString(@NotNull TagKey tag) { public static BlockPos convertToBlockPos(Map table) throws LuaException { if (!table.containsKey("x") || !table.containsKey("y") || !table.containsKey("z")) throw new LuaException("Table should be block position table"); - if (!(table.get("x") instanceof Number x) || !(table.get("y") instanceof Number y) || !(table.get("z") instanceof Number z)) + if (!(table.get("x") instanceof Number x) || !(table.get("y") instanceof Number y) + || !(table.get("z") instanceof Number z)) throw new LuaException("Table should be block position table"); return new BlockPos(x.intValue(), y.intValue(), z.intValue()); } public static BlockPos convertToBlockPos(BlockPos center, Map table) throws LuaException { BlockPos relative = convertToBlockPos(table); - return new BlockPos(center.getX() + relative.getX(), center.getY() + relative.getY(), center.getZ() + relative.getZ()); + return new BlockPos(center.getX() + relative.getX(), center.getY() + relative.getY(), + center.getZ() + relative.getZ()); } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/util/NBTUtil.java b/src/main/java/de/srendi/advancedperipherals/common/util/NBTUtil.java index b8bef9e45..a220c56a9 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/util/NBTUtil.java +++ b/src/main/java/de/srendi/advancedperipherals/common/util/NBTUtil.java @@ -1,10 +1,31 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.util; import com.mojang.brigadier.exceptions.CommandSyntaxException; import de.srendi.advancedperipherals.AdvancedPeripherals; import de.srendi.advancedperipherals.common.configuration.APConfig; import net.minecraft.core.BlockPos; -import net.minecraft.nbt.*; +import net.minecraft.nbt.ByteTag; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.DoubleTag; +import net.minecraft.nbt.IntTag; +import net.minecraft.nbt.StringTag; +import net.minecraft.nbt.Tag; +import net.minecraft.nbt.TagParser; import net.minecraft.world.level.ChunkPos; import org.apache.logging.log4j.Level; @@ -47,7 +68,7 @@ public static CompoundTag fromText(String json) { return json == null ? null : TagParser.parseTag(json); } catch (CommandSyntaxException ex) { AdvancedPeripherals.debug("Could not parse json data to NBT", Level.ERROR); - if(APConfig.GENERAL_CONFIG.enableDebugMode.get()) + if (APConfig.GENERAL_CONFIG.enableDebugMode.get()) ex.printStackTrace(); return null; } diff --git a/src/main/java/de/srendi/advancedperipherals/common/util/Pair.java b/src/main/java/de/srendi/advancedperipherals/common/util/Pair.java index fe2b993dd..5e729286b 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/util/Pair.java +++ b/src/main/java/de/srendi/advancedperipherals/common/util/Pair.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.util; import java.util.function.BiFunction; 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 9acab5e70..e1dd1805e 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/util/Platform.java +++ b/src/main/java/de/srendi/advancedperipherals/common/util/Platform.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.util; import de.srendi.advancedperipherals.AdvancedPeripherals; diff --git a/src/main/java/de/srendi/advancedperipherals/common/util/RawValue.java b/src/main/java/de/srendi/advancedperipherals/common/util/RawValue.java index 6195df726..a054f07f5 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/util/RawValue.java +++ b/src/main/java/de/srendi/advancedperipherals/common/util/RawValue.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.util; import com.google.gson.JsonObject; @@ -11,10 +26,12 @@ import java.util.Collections; /** - * Since Minecolonies/DO uses a library for data generation which we don't have implemented with which I really don't want to deal, - * we need to generate our recipe without minecolonies in the runtime. + * Since Minecolonies/DO uses a library for data generation which we don't have + * implemented with which I really don't want to deal, we need to generate our + * recipe without minecolonies in the runtime. *

- * So we have an Ingredient value which can be parsed to json without the item being registered. + * So we have an Ingredient value which can be parsed to json without the item + * being registered. */ public class RawValue implements Ingredient.Value { private final ResourceLocation item; @@ -23,16 +40,13 @@ public RawValue(ResourceLocation pItem) { this.item = pItem; } - @NotNull - public Collection getItems() { + @NotNull public Collection getItems() { return Collections.singleton(new ItemStack(ForgeRegistries.ITEMS.getValue(this.item))); } - @NotNull - public JsonObject serialize() { + @NotNull public JsonObject serialize() { JsonObject jsonobject = new JsonObject(); jsonobject.addProperty("item", item.toString()); return jsonobject; } } - diff --git a/src/main/java/de/srendi/advancedperipherals/common/util/ScanUtils.java b/src/main/java/de/srendi/advancedperipherals/common/util/ScanUtils.java index 68a51bcd4..500deef64 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/util/ScanUtils.java +++ b/src/main/java/de/srendi/advancedperipherals/common/util/ScanUtils.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.util; import net.minecraft.core.BlockPos; @@ -7,15 +22,18 @@ import java.util.function.BiConsumer; public class ScanUtils { - public static void relativeTraverseBlocks(Level world, BlockPos center, int radius, BiConsumer consumer) { + public static void relativeTraverseBlocks(Level world, BlockPos center, int radius, + BiConsumer consumer) { traverseBlocks(world, center, radius, consumer, true); } - public static void traverseBlocks(Level world, BlockPos center, int radius, BiConsumer consumer) { + public static void traverseBlocks(Level world, BlockPos center, int radius, + BiConsumer consumer) { traverseBlocks(world, center, radius, consumer, false); } - public static void traverseBlocks(Level world, BlockPos center, int radius, BiConsumer consumer, boolean relativePosition) { + public static void traverseBlocks(Level world, BlockPos center, int radius, + BiConsumer consumer, boolean relativePosition) { int x = center.getX(); int y = center.getY(); int z = center.getZ(); diff --git a/src/main/java/de/srendi/advancedperipherals/common/util/ServerWorker.java b/src/main/java/de/srendi/advancedperipherals/common/util/ServerWorker.java index d4c5762ae..ea54d6122 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/util/ServerWorker.java +++ b/src/main/java/de/srendi/advancedperipherals/common/util/ServerWorker.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.util; import de.srendi.advancedperipherals.AdvancedPeripherals; diff --git a/src/main/java/de/srendi/advancedperipherals/common/util/SideHelper.java b/src/main/java/de/srendi/advancedperipherals/common/util/SideHelper.java index 30eed20ce..eb16b3e5f 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/util/SideHelper.java +++ b/src/main/java/de/srendi/advancedperipherals/common/util/SideHelper.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.util; import net.minecraft.client.Minecraft; @@ -8,6 +23,7 @@ public class SideHelper { public static boolean isClientPlayer(@NotNull LivingEntity player) { - return player.level.isClientSide && player instanceof Player && player.level.getServer() == null && player == Minecraft.getInstance().player; + return player.level.isClientSide && player instanceof Player && player.level.getServer() == null + && player == Minecraft.getInstance().player; } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/util/StringUtil.java b/src/main/java/de/srendi/advancedperipherals/common/util/StringUtil.java index dcf2ab95a..9e86ff376 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/util/StringUtil.java +++ b/src/main/java/de/srendi/advancedperipherals/common/util/StringUtil.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.util; public class StringUtil { diff --git a/src/main/java/de/srendi/advancedperipherals/common/util/ToastUtil.java b/src/main/java/de/srendi/advancedperipherals/common/util/ToastUtil.java index 23a12672e..f73ab888f 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/util/ToastUtil.java +++ b/src/main/java/de/srendi/advancedperipherals/common/util/ToastUtil.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.util; import net.minecraft.client.Minecraft; @@ -10,17 +25,19 @@ public class ToastUtil { /** - * Displays a toast on a players screen. - * This is a client side operation! Don't execute this on the server side + * Displays a toast on a players screen. This is a client side operation! Don't + * execute this on the server side * - * @param title the title of the toast - * @param message the message of the toast + * @param title + * the title of the toast + * @param message + * the message of the toast */ public static void displayToast(Component title, Component message) { Minecraft minecraft = Minecraft.getInstance(); - minecraft.getToasts().addToast(SystemToast.multiline(minecraft, - SystemToast.SystemToastIds.PERIODIC_NOTIFICATION, title, message)); + minecraft.getToasts().addToast( + SystemToast.multiline(minecraft, SystemToast.SystemToastIds.PERIODIC_NOTIFICATION, title, message)); } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/util/TranslationUtil.java b/src/main/java/de/srendi/advancedperipherals/common/util/TranslationUtil.java index f2fec11f3..3c757f77a 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/util/TranslationUtil.java +++ b/src/main/java/de/srendi/advancedperipherals/common/util/TranslationUtil.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.util; import de.srendi.advancedperipherals.AdvancedPeripherals; @@ -7,7 +22,9 @@ public class TranslationUtil { public static Component itemTooltip(String descriptionId) { int lastIndex = descriptionId.lastIndexOf('.'); - return Component.translatable(String.format("%s.tooltip.%s", descriptionId.substring(0, lastIndex).replaceFirst("^block", "item"), descriptionId.substring(lastIndex + 1))); + return Component.translatable( + String.format("%s.tooltip.%s", descriptionId.substring(0, lastIndex).replaceFirst("^block", "item"), + descriptionId.substring(lastIndex + 1))); } public static String turtle(String name) { diff --git a/src/main/java/de/srendi/advancedperipherals/common/util/ZeroGasTank.java b/src/main/java/de/srendi/advancedperipherals/common/util/ZeroGasTank.java index 48f81d3b1..f4a0cd766 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/util/ZeroGasTank.java +++ b/src/main/java/de/srendi/advancedperipherals/common/util/ZeroGasTank.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.util; import mekanism.api.Action; @@ -12,8 +27,7 @@ public int getTanks() { return 0; } - @NotNull - @Override + @NotNull @Override public GasStack getChemicalInTank(int tank) { return GasStack.EMPTY; } @@ -33,14 +47,12 @@ public boolean isValid(int tank, @NotNull GasStack stack) { return false; } - @NotNull - @Override + @NotNull @Override public GasStack insertChemical(int tank, @NotNull GasStack stack, @NotNull Action action) { return GasStack.EMPTY; } - @NotNull - @Override + @NotNull @Override public GasStack extractChemical(int tank, long amount, @NotNull Action action) { return GasStack.EMPTY; } 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 405713ddb..41f03c3e0 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 @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.util.fakeplayer; import com.mojang.authlib.GameProfile; @@ -32,7 +47,11 @@ 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.*; +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.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.ForgeMod; import net.minecraftforge.common.util.FakePlayer; @@ -51,9 +70,12 @@ public class APFakePlayer extends FakePlayer { /* - Highly inspired by https://github.com/SquidDev-CC/plethora/blob/minecraft-1.12/src/main/java/org/squiddev/plethora/gameplay/PlethoraFakePlayer.java - */ - public static final GameProfile PROFILE = new GameProfile(UUID.fromString("6e483f02-30db-4454-b612-3a167614b276"), "[" + AdvancedPeripherals.MOD_ID + "]"); + * Highly inspired by + * https://github.com/SquidDev-CC/plethora/blob/minecraft-1.12/src/main/java/org + * /squiddev/plethora/gameplay/PlethoraFakePlayer.java + */ + public static final GameProfile PROFILE = new GameProfile(UUID.fromString("6e483f02-30db-4454-b612-3a167614b276"), + "[" + AdvancedPeripherals.MOD_ID + "]"); private static final Predicate collidablePredicate = EntitySelector.NO_SPECTATORS; private final WeakReference owner; @@ -92,7 +114,6 @@ public boolean canAttack(@NotNull LivingEntity livingEntity) { public void openTextEdit(@NotNull SignBlockEntity sign) { } - @Override public boolean isSilent() { return true; @@ -105,7 +126,8 @@ public void playSound(@NotNull SoundEvent soundIn, float volume, float pitch) { private void setState(Block block, BlockPos pos) { if (digPosition != null) { - gameMode.handleBlockBreakAction(digPosition, ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK, Direction.EAST, 320, 1); + gameMode.handleBlockBreakAction(digPosition, ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK, + Direction.EAST, 320, 1); } digPosition = pos; @@ -118,7 +140,8 @@ public float getEyeHeight(@NotNull Pose pose) { return 0; } - public static Function wrapActionWithRot(float yaw, float pitch, Function action) { + public static Function wrapActionWithRot(float yaw, float pitch, + Function action) { return player -> player.doActionWithRot(yaw, pitch, action); } @@ -132,7 +155,8 @@ public T doActionWithRot(float yaw, float pitch, Function a } } - public static Function wrapActionWithShiftKey(boolean shift, Function action) { + public static Function wrapActionWithShiftKey(boolean shift, + Function action) { return player -> player.doActionWithShiftKey(shift, action); } @@ -148,7 +172,8 @@ public T doActionWithShiftKey(boolean shift, Function actio @Deprecated(forRemoval = true) public Pair digBlock(Direction direction) { - return doActionWithRot(direction.toYRot() - this.getYRot(), direction == Direction.DOWN ? 90 : direction == Direction.UP ? -90 : 0, APFakePlayer::digBlock); + return doActionWithRot(direction.toYRot() - this.getYRot(), + direction == Direction.DOWN ? 90 : direction == Direction.UP ? -90 : 0, APFakePlayer::digBlock); } public Pair digBlock() { @@ -194,7 +219,8 @@ public Pair digBlock() { if (currentDamage > 9) { world.playSound(null, pos, state.getSoundType().getHitSound(), SoundSource.NEUTRAL, .25f, 1); - manager.handleBlockBreakAction(pos, ServerboundPlayerActionPacket.Action.STOP_DESTROY_BLOCK, direction, 320, 1); + manager.handleBlockBreakAction(pos, ServerboundPlayerActionPacket.Action.STOP_DESTROY_BLOCK, direction, + 320, 1); manager.destroyBlock(pos); world.destroyBlockProgress(getId(), pos, -1); setState(null, null); @@ -220,7 +246,8 @@ public InteractionResult useOnFilteredEntity(Predicate filter) { public InteractionResult useOnSpecificEntity(@NotNull Entity entity, HitResult result) { InteractionResult simpleInteraction = interactOn(entity, InteractionHand.MAIN_HAND); - if (simpleInteraction == InteractionResult.SUCCESS) return simpleInteraction; + if (simpleInteraction == InteractionResult.SUCCESS) + return simpleInteraction; if (ForgeHooks.onInteractEntityAt(this, entity, result.getLocation(), InteractionHand.MAIN_HAND) != null) { return InteractionResult.FAIL; } @@ -238,20 +265,23 @@ public InteractionResult use(boolean skipEntity, boolean skipBlock, @Nullable Pr if (hit instanceof BlockHitResult blockHit) { ItemStack stack = getMainHandItem(); BlockPos pos = blockHit.getBlockPos(); - PlayerInteractEvent.RightClickBlock event = ForgeHooks.onRightClickBlock(this, InteractionHand.MAIN_HAND, pos, blockHit); + PlayerInteractEvent.RightClickBlock event = ForgeHooks.onRightClickBlock(this, InteractionHand.MAIN_HAND, + pos, blockHit); if (event.isCanceled()) { return event.getCancellationResult(); } boolean denied = event.getUseItem() == Event.Result.DENY; if (!denied) { - InteractionResult result = stack.onItemUseFirst(new UseOnContext(level, this, InteractionHand.MAIN_HAND, stack, blockHit)); + InteractionResult result = stack + .onItemUseFirst(new UseOnContext(level, this, InteractionHand.MAIN_HAND, stack, blockHit)); if (result != InteractionResult.PASS) { return result; } boolean bypass = getMainHandItem().doesSneakBypassUse(level, pos, this); if (isShiftKeyDown() || bypass || event.getUseBlock() == Event.Result.ALLOW) { - InteractionResult useType = gameMode.useItemOn(this, level, stack, InteractionHand.MAIN_HAND, blockHit); + InteractionResult useType = gameMode.useItemOn(this, level, stack, InteractionHand.MAIN_HAND, + blockHit); if (useType == InteractionResult.SUCCESS) { return InteractionResult.SUCCESS; } @@ -262,7 +292,6 @@ public InteractionResult use(boolean skipEntity, boolean skipBlock, @Nullable Pr return InteractionResult.PASS; } - if (stack.getItem() instanceof BlockItem blockItem) { Block block = blockItem.getBlock(); if (block instanceof CommandBlock || block instanceof StructureBlock) { @@ -275,7 +304,8 @@ public InteractionResult use(boolean skipEntity, boolean skipBlock, @Nullable Pr } ItemStack copyBeforeUse = stack.copy(); - InteractionResult result = stack.useOn(new UseOnContext(level, this, InteractionHand.MAIN_HAND, copyBeforeUse, blockHit)); + InteractionResult result = stack + .useOn(new UseOnContext(level, this, InteractionHand.MAIN_HAND, copyBeforeUse, blockHit)); if (stack.isEmpty()) { ForgeEventFactory.onPlayerDestroyItem(this, copyBeforeUse, InteractionHand.MAIN_HAND); } @@ -290,8 +320,7 @@ public HitResult findHit(boolean skipEntity, boolean skipBlock) { return findHit(skipEntity, skipBlock, null); } - @NotNull - public HitResult findHit(boolean skipEntity, boolean skipBlock, @Nullable Predicate entityFilter) { + @NotNull public HitResult findHit(boolean skipEntity, boolean skipBlock, @Nullable Predicate entityFilter) { AttributeInstance reachAttribute = getAttribute(ForgeMod.REACH_DISTANCE.get()); if (reachAttribute == null) throw new IllegalArgumentException("How did this happened?"); @@ -300,25 +329,31 @@ public HitResult findHit(boolean skipEntity, boolean skipBlock, @Nullable Predic Vec3 origin = new Vec3(getX(), getY(), getZ()); Vec3 look = getLookAngle(); Vec3 target = new Vec3(origin.x + look.x * range, origin.y + look.y * range, origin.z + look.z * range); - ClipContext traceContext = new ClipContext(origin, target, ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, this); + ClipContext traceContext = new ClipContext(origin, target, ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, + this); Vec3 directionVec = traceContext.getFrom().subtract(traceContext.getTo()); Direction traceDirection = Direction.getNearest(directionVec.x, directionVec.y, directionVec.z); HitResult blockHit; if (skipBlock) { blockHit = BlockHitResult.miss(traceContext.getTo(), traceDirection, new BlockPos(traceContext.getTo())); } else { - blockHit = BlockGetter.traverseBlocks(traceContext.getFrom(), traceContext.getTo(), traceContext, (rayTraceContext, blockPos) -> { - if (level.isEmptyBlock(blockPos) || blockPos.equals(blockPosition())) { - return null; - } - return new BlockHitResult(new Vec3(blockPos.getX(), blockPos.getY(), blockPos.getZ()), traceDirection, blockPos, false); - }, rayTraceContext -> BlockHitResult.miss(rayTraceContext.getTo(), traceDirection, new BlockPos(rayTraceContext.getTo()))); + blockHit = BlockGetter.traverseBlocks(traceContext.getFrom(), traceContext.getTo(), traceContext, + (rayTraceContext, blockPos) -> { + if (level.isEmptyBlock(blockPos) || blockPos.equals(blockPosition())) { + return null; + } + return new BlockHitResult(new Vec3(blockPos.getX(), blockPos.getY(), blockPos.getZ()), + traceDirection, blockPos, false); + }, rayTraceContext -> BlockHitResult.miss(rayTraceContext.getTo(), traceDirection, + new BlockPos(rayTraceContext.getTo()))); } if (skipEntity) return blockHit; - List entities = level.getEntities(this, getBoundingBox().expandTowards(look.x * range, look.y * range, look.z * range).inflate(1, 1, 1), collidablePredicate); + List entities = level.getEntities(this, + getBoundingBox().expandTowards(look.x * range, look.y * range, look.z * range).inflate(1, 1, 1), + collidablePredicate); LivingEntity closestEntity = null; Vec3 closestVec = null; @@ -354,7 +389,8 @@ public HitResult findHit(boolean skipEntity, boolean skipBlock, @Nullable Predic } } } - if (closestEntity != null && closestDistance <= range && (blockHit.getType() == HitResult.Type.MISS || distanceToSqr(blockHit.getLocation()) > closestDistance * closestDistance)) { + if (closestEntity != null && closestDistance <= range && (blockHit.getType() == HitResult.Type.MISS + || distanceToSqr(blockHit.getLocation()) > closestDistance * closestDistance)) { return new EntityHitResult(closestEntity, closestVec); } else { return blockHit; diff --git a/src/main/java/de/srendi/advancedperipherals/common/util/fakeplayer/FakePlayerProviderTurtle.java b/src/main/java/de/srendi/advancedperipherals/common/util/fakeplayer/FakePlayerProviderTurtle.java index eaa186d17..8b24c7acb 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/util/fakeplayer/FakePlayerProviderTurtle.java +++ b/src/main/java/de/srendi/advancedperipherals/common/util/fakeplayer/FakePlayerProviderTurtle.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.util.fakeplayer; import com.mojang.authlib.GameProfile; @@ -20,15 +35,18 @@ public final class FakePlayerProviderTurtle { /* - Highly inspired by https://github.com/SquidDev-CC/plethora/blob/minecraft-1.12/src/main/java/org/squiddev/plethora/integration/computercraft/FakePlayerProviderTurtle.java - */ + * Highly inspired by + * https://github.com/SquidDev-CC/plethora/blob/minecraft-1.12/src/main/java/org + * /squiddev/plethora/integration/computercraft/FakePlayerProviderTurtle.java + */ private static final WeakHashMap registeredPlayers = new WeakHashMap<>(); private FakePlayerProviderTurtle() { } public static APFakePlayer getPlayer(ITurtleAccess turtle, GameProfile profile) { - return registeredPlayers.computeIfAbsent(turtle, iTurtleAccess -> new APFakePlayer((ServerLevel) turtle.getLevel(), null, profile)); + return registeredPlayers.computeIfAbsent(turtle, + iTurtleAccess -> new APFakePlayer((ServerLevel) turtle.getLevel(), null, profile)); } public static void load(APFakePlayer player, ITurtleAccess turtle) { @@ -56,7 +74,8 @@ public static void load(APFakePlayer player, ITurtleAccess turtle) { // Add properties ItemStack activeStack = player.getItemInHand(InteractionHand.MAIN_HAND); if (!activeStack.isEmpty()) - player.getAttributes().addTransientAttributeModifiers(activeStack.getAttributeModifiers(EquipmentSlot.MAINHAND)); + player.getAttributes() + .addTransientAttributeModifiers(activeStack.getAttributeModifiers(EquipmentSlot.MAINHAND)); } @@ -86,7 +105,8 @@ public static void unload(APFakePlayer player, ITurtleAccess turtle) { remaining = ItemHandlerHelper.insertItem(turtleInventory, remaining, false); if (!remaining.isEmpty()) { BlockPos position = turtle.getPosition(); - WorldUtil.dropItemStack(remaining, turtle.getLevel(), position, turtle.getDirection().getOpposite()); + WorldUtil.dropItemStack(remaining, turtle.getLevel(), position, + turtle.getDirection().getOpposite()); } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/util/inventory/FluidFilter.java b/src/main/java/de/srendi/advancedperipherals/common/util/inventory/FluidFilter.java index da7510ba0..e00022e0c 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/util/inventory/FluidFilter.java +++ b/src/main/java/de/srendi/advancedperipherals/common/util/inventory/FluidFilter.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.util.inventory; import appeng.api.stacks.AEFluidKey; @@ -113,14 +128,16 @@ public boolean test(FluidStack stack) { return fingerprint.equals(testFingerprint); } - // If the filter does not have nbt values, a tag or a fingerprint, just test if the items are the same + // If the filter does not have nbt values, a tag or a fingerprint, just test if + // the items are the same if (fluid != Fluids.EMPTY) { if (tag == null && nbt == null && fingerprint.isEmpty()) return stack.getFluid().isSame(fluid); } if (tag != null && !stack.getFluid().is(tag)) return false; - if (nbt != null && !stack.getOrCreateTag().equals(nbt) && (fluid == Fluids.EMPTY || stack.getFluid().isSame(fluid))) + if (nbt != null && !stack.getOrCreateTag().equals(nbt) + && (fluid == Fluids.EMPTY || stack.getFluid().isSame(fluid))) return false; return true; @@ -140,12 +157,7 @@ public Tag getNbt() { @Override public String toString() { - return "FluidFilter{" + - "fluid=" + FluidUtil.getRegistryKey(fluid) + - ", tag=" + tag + - ", nbt=" + nbt + - ", count=" + count + - ", fingerprint='" + fingerprint + '\'' + - '}'; + return "FluidFilter{" + "fluid=" + FluidUtil.getRegistryKey(fluid) + ", tag=" + tag + ", nbt=" + nbt + + ", count=" + count + ", fingerprint='" + fingerprint + '\'' + '}'; } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/util/inventory/FluidUtil.java b/src/main/java/de/srendi/advancedperipherals/common/util/inventory/FluidUtil.java index a3d8cdec6..46c610d1d 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/util/inventory/FluidUtil.java +++ b/src/main/java/de/srendi/advancedperipherals/common/util/inventory/FluidUtil.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.util.inventory; import dan200.computercraft.api.lua.LuaException; @@ -31,8 +46,7 @@ public class FluidUtil { private FluidUtil() { } - @Nullable - public static IFluidHandler extractHandler(@Nullable Object object) { + @Nullable public static IFluidHandler extractHandler(@Nullable Object object) { if (object instanceof IFluidHandler fluidHandler) return fluidHandler; @@ -44,8 +58,8 @@ public static IFluidHandler extractHandler(@Nullable Object object) { return null; } - @NotNull - public static IFluidHandler getHandlerFromDirection(@NotNull String direction, @NotNull IPeripheralOwner owner) throws LuaException { + @NotNull public static IFluidHandler getHandlerFromDirection(@NotNull String direction, @NotNull IPeripheralOwner owner) + throws LuaException { Level level = owner.getLevel(); Objects.requireNonNull(level); Direction relativeDirection = CoordUtil.getDirection(owner.getOrientation(), direction); @@ -59,11 +73,11 @@ public static IFluidHandler getHandlerFromDirection(@NotNull String direction, @ return handler; } - @Nullable - public static IFluidHandler getHandlerFromName(@NotNull IComputerAccess access, String name) throws LuaException { + @Nullable public static IFluidHandler getHandlerFromName(@NotNull IComputerAccess access, String name) throws LuaException { IPeripheral location = access.getAvailablePeripheral(name); - // Tanks/Block Entities can't be accessed if the bridge is not exposed to the same network as the target tank/block entity + // Tanks/Block Entities can't be accessed if the bridge is not exposed to the + // same network as the target tank/block entity // This can occur when the bridge was wrapped via a side and not via modems if (location == null) return null; @@ -74,9 +88,9 @@ public static IFluidHandler getHandlerFromName(@NotNull IComputerAccess access, return handler; } - @NotNull - public static String getFingerprint(@NotNull FluidStack stack) { - String fingerprint = stack.getOrCreateTag() + getRegistryKey(stack).toString() + stack.getDisplayName().getString(); + @NotNull public static String getFingerprint(@NotNull FluidStack stack) { + String fingerprint = stack.getOrCreateTag() + getRegistryKey(stack).toString() + + stack.getDisplayName().getString(); try { byte[] bytesOfHash = fingerprint.getBytes(StandardCharsets.UTF_8); MessageDigest md = MessageDigest.getInstance("MD5"); diff --git a/src/main/java/de/srendi/advancedperipherals/common/util/inventory/GenericFilter.java b/src/main/java/de/srendi/advancedperipherals/common/util/inventory/GenericFilter.java index 64d148419..5ab4c02a5 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/util/inventory/GenericFilter.java +++ b/src/main/java/de/srendi/advancedperipherals/common/util/inventory/GenericFilter.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.util.inventory; import appeng.api.stacks.GenericStack; @@ -9,13 +24,14 @@ public abstract class GenericFilter { /** - * Try to parse a raw filter table to any existing filter type. Could be a fluid filter, an item filter, maybe something else - * in the future. + * Try to parse a raw filter table to any existing filter type. Could be a fluid + * filter, an item filter, maybe something else in the future. *

- * If the function can't find a valid type for the given name/resource location, it will return an empty filter with - * a proper error message. + * If the function can't find a valid type for the given name/resource location, + * it will return an empty filter with a proper error message. * - * @param rawFilter The raw filter, which is a map of strings and objects + * @param rawFilter + * The raw filter, which is a map of strings and objects * @return A pair of the parsed filter and an error message, if there is one */ public static Pair parseGeneric(Map rawFilter) { @@ -24,13 +40,14 @@ public static Pair parseGeneric(Map rawFi if (!rawFilter.containsKey("name")) { if (rawFilter.containsKey("type") && rawFilter.get("type") instanceof String type) { switch (type) { - case "item": + case "item" : return ItemFilter.parse(rawFilter); - case "fluid": + case "fluid" : return FluidFilter.parse(rawFilter); } } - // If the filter does not contain a name or a type, which should never happen, but players are players, we will just + // If the filter does not contain a name or a type, which should never happen, + // but players are players, we will just // give the ItemFilter the task to parse the filter return ItemFilter.parse(rawFilter); } @@ -42,7 +59,8 @@ public static Pair parseGeneric(Map rawFi } else if (ItemUtil.getRegistryEntry(name, ForgeRegistries.FLUIDS) != null) { return FluidFilter.parse(rawFilter); } else { - // If the name is in neither of the registries, we will just return an empty filter + // If the name is in neither of the registries, we will just return an empty + // filter return Pair.of(empty(), "NO_VALID_FILTER_TYPE"); } diff --git a/src/main/java/de/srendi/advancedperipherals/common/util/inventory/IStorageSystemFluidHandler.java b/src/main/java/de/srendi/advancedperipherals/common/util/inventory/IStorageSystemFluidHandler.java index 9cc76fbee..5477a05b4 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/util/inventory/IStorageSystemFluidHandler.java +++ b/src/main/java/de/srendi/advancedperipherals/common/util/inventory/IStorageSystemFluidHandler.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.util.inventory; import net.minecraftforge.fluids.FluidStack; @@ -7,16 +22,19 @@ public interface IStorageSystemFluidHandler extends IFluidHandler { /** - * Used to extract an item from the system via a peripheral. - * Uses a filter to find the right item. The amount should never be greater than 64 - * stack sizes greater than 64. + * Used to extract an item from the system via a peripheral. Uses a filter to + * find the right item. The amount should never be greater than 64 stack sizes + * greater than 64. * - * @param filter The parsed filter - * @param simulate Should this action be simulated - * @return extracted from the slot, must be empty if nothing can be extracted. The returned ItemStack can be safely modified after, so item handlers should return a new or copied stack. + * @param filter + * The parsed filter + * @param simulate + * Should this action be simulated + * @return extracted from the slot, must be empty if nothing can be extracted. + * The returned ItemStack can be safely modified after, so item handlers + * should return a new or copied stack. */ - @NotNull - FluidStack drain(FluidFilter filter, FluidAction simulate); + @NotNull FluidStack drain(FluidFilter filter, FluidAction simulate); @Override default int getTanks() { @@ -24,25 +42,23 @@ default int getTanks() { } /* - These 5 methods are ignored in our transferring logic. Storage Systems do not respect tanks directly and to extract we need a filter + * These 5 methods are ignored in our transferring logic. Storage Systems do not + * respect tanks directly and to extract we need a filter */ - @NotNull - @Override + @NotNull @Override default FluidStack drain(int maxDrain, FluidAction action) { return FluidStack.EMPTY; } - @NotNull - @Override + @NotNull @Override default FluidStack drain(FluidStack resource, FluidAction action) { return FluidStack.EMPTY; } - @NotNull - @Override + @NotNull @Override default FluidStack getFluidInTank(int tank) { return FluidStack.EMPTY; } diff --git a/src/main/java/de/srendi/advancedperipherals/common/util/inventory/IStorageSystemItemHandler.java b/src/main/java/de/srendi/advancedperipherals/common/util/inventory/IStorageSystemItemHandler.java index 63ae60a16..7b7c80040 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/util/inventory/IStorageSystemItemHandler.java +++ b/src/main/java/de/srendi/advancedperipherals/common/util/inventory/IStorageSystemItemHandler.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.util.inventory; import net.minecraft.world.item.ItemStack; @@ -7,20 +22,27 @@ public interface IStorageSystemItemHandler extends IItemHandler { /** - * Used to extract an item from the system via a peripheral. - * Uses a filter to find the right item. The amount should never be greater than 64 - * stack sizes greater than 64. + * Used to extract an item from the system via a peripheral. Uses a filter to + * find the right item. The amount should never be greater than 64 stack sizes + * greater than 64. * - * @param filter The parsed filter - * @param filter The parsed filter - * @param count The amount to extract - * @param simulate Should this action be simulated - * @return extracted from the slot, must be empty if nothing can be extracted. The returned ItemStack can be safely modified after, so item handlers should return a new or copied stack. + * @param filter + * The parsed filter + * @param filter + * The parsed filter + * @param count + * The amount to extract + * @param simulate + * Should this action be simulated + * @return extracted from the slot, must be empty if nothing can be extracted. + * The returned ItemStack can be safely modified after, so item handlers + * should return a new or copied stack. */ ItemStack extractItem(ItemFilter filter, int count, boolean simulate); /* - These 5 methods are ignored in our transferring logic. Storage Systems do not respect slots and to extract we need a filter + * These 5 methods are ignored in our transferring logic. Storage Systems do not + * respect slots and to extract we need a filter */ @Override @@ -33,14 +55,12 @@ default int getSlotLimit(int slot) { return 0; } - @NotNull - @Override + @NotNull @Override default ItemStack extractItem(int slot, int amount, boolean simulate) { return ItemStack.EMPTY; } - @NotNull - @Override + @NotNull @Override default ItemStack getStackInSlot(int slot) { return ItemStack.EMPTY; } diff --git a/src/main/java/de/srendi/advancedperipherals/common/util/inventory/IStorageSystemPeripheral.java b/src/main/java/de/srendi/advancedperipherals/common/util/inventory/IStorageSystemPeripheral.java index 39b4fd114..8d280d80c 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/util/inventory/IStorageSystemPeripheral.java +++ b/src/main/java/de/srendi/advancedperipherals/common/util/inventory/IStorageSystemPeripheral.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.util.inventory; import dan200.computercraft.api.lua.IArguments; @@ -6,14 +21,18 @@ import dan200.computercraft.api.peripheral.IComputerAccess; /** - * Implementation for common storage peripheral functions. Used for AE2 {@link de.srendi.advancedperipherals.common.addons.computercraft.peripheral.MeBridgePeripheral} - * and RS {@link de.srendi.advancedperipherals.common.addons.computercraft.peripheral.RsBridgePeripheral} + * Implementation for common storage peripheral functions. Used for AE2 + * {@link de.srendi.advancedperipherals.common.addons.computercraft.peripheral.MeBridgePeripheral} + * and RS + * {@link de.srendi.advancedperipherals.common.addons.computercraft.peripheral.RsBridgePeripheral} *

- * This ensures that these both bridges use the same methods. This makes it easier to support both in the same script - * In case there is a new mod which adds new ways to store and craft items, this ensures that the new peripheral + * This ensures that these both bridges use the same methods. This makes it + * easier to support both in the same script In case there is a new mod which + * adds new ways to store and craft items, this ensures that the new peripheral * has the same functions as the other ones *

- * Implementation needs to override {@link dan200.computercraft.api.lua.LuaFunction} + * Implementation needs to override + * {@link dan200.computercraft.api.lua.LuaFunction} */ public interface IStorageSystemPeripheral { diff --git a/src/main/java/de/srendi/advancedperipherals/common/util/inventory/InventoryUtil.java b/src/main/java/de/srendi/advancedperipherals/common/util/inventory/InventoryUtil.java index 599872d24..11705593b 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/util/inventory/InventoryUtil.java +++ b/src/main/java/de/srendi/advancedperipherals/common/util/inventory/InventoryUtil.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.util.inventory; import dan200.computercraft.api.lua.LuaException; @@ -42,7 +57,8 @@ public static IItemHandler extractHandler(@Nullable Object object) { } public static int moveItem(IItemHandler inventoryFrom, IItemHandler inventoryTo, ItemFilter filter) { - if (inventoryFrom == null) return 0; + if (inventoryFrom == null) + return 0; int fromSlot = filter.getFromSlot(); int toSlot = filter.getToSlot(); @@ -63,7 +79,8 @@ public static int moveItem(IItemHandler inventoryFrom, IItemHandler inventoryTo, inserted = inventoryTo.insertItem(toSlot, extracted, false); } amount -= extracted.getCount() - inserted.getCount(); - transferableAmount += storageSystemHandler.extractItem(filter, extracted.getCount() - inserted.getCount(), false).getCount(); + transferableAmount += storageSystemHandler + .extractItem(filter, extracted.getCount() - inserted.getCount(), false).getCount(); if (transferableAmount >= filter.getCount()) break; } @@ -71,7 +88,9 @@ public static int moveItem(IItemHandler inventoryFrom, IItemHandler inventoryTo, } if (inventoryTo instanceof IStorageSystemItemHandler storageSystemHandler) { - for (int i = fromSlot == -1 ? 0 : fromSlot; i < (fromSlot == -1 ? inventoryFrom.getSlots() : fromSlot + 1); i++) { + for (int i = fromSlot == -1 ? 0 : fromSlot; i < (fromSlot == -1 + ? inventoryFrom.getSlots() + : fromSlot + 1); i++) { if (filter.test(inventoryFrom.getStackInSlot(i))) { ItemStack extracted = inventoryFrom.extractItem(i, amount - transferableAmount, true); if (extracted.isEmpty()) @@ -79,7 +98,8 @@ public static int moveItem(IItemHandler inventoryFrom, IItemHandler inventoryTo, ItemStack inserted = storageSystemHandler.insertItem(toSlot, extracted, false); amount -= inserted.getCount(); - transferableAmount += inventoryFrom.extractItem(i, extracted.getCount() - inserted.getCount(), false).getCount(); + transferableAmount += inventoryFrom + .extractItem(i, extracted.getCount() - inserted.getCount(), false).getCount(); if (transferableAmount >= filter.getCount()) break; } @@ -87,7 +107,9 @@ public static int moveItem(IItemHandler inventoryFrom, IItemHandler inventoryTo, return transferableAmount; } - for (int i = fromSlot == -1 ? 0 : fromSlot; i < (fromSlot == -1 ? inventoryFrom.getSlots() : fromSlot + 1); i++) { + for (int i = fromSlot == -1 ? 0 : fromSlot; i < (fromSlot == -1 + ? inventoryFrom.getSlots() + : fromSlot + 1); i++) { if (filter.test(inventoryFrom.getStackInSlot(i))) { ItemStack extracted = inventoryFrom.extractItem(i, amount - transferableAmount, true); if (extracted.isEmpty()) @@ -99,7 +121,8 @@ public static int moveItem(IItemHandler inventoryFrom, IItemHandler inventoryTo, inserted = inventoryTo.insertItem(toSlot, extracted, false); } amount -= inserted.getCount(); - transferableAmount += inventoryFrom.extractItem(i, extracted.getCount() - inserted.getCount(), false).getCount(); + transferableAmount += inventoryFrom.extractItem(i, extracted.getCount() - inserted.getCount(), false) + .getCount(); if (transferableAmount >= filter.getCount()) break; } @@ -108,7 +131,8 @@ public static int moveItem(IItemHandler inventoryFrom, IItemHandler inventoryTo, } public static int moveFluid(IFluidHandler inventoryFrom, IFluidHandler inventoryTo, FluidFilter filter) { - if (inventoryFrom == null) return 0; + if (inventoryFrom == null) + return 0; int amount = filter.getCount(); int transferableAmount = 0; @@ -118,7 +142,8 @@ public static int moveFluid(IFluidHandler inventoryFrom, IFluidHandler inventory FluidStack extracted = storageSystemHandler.drain(filter, IFluidHandler.FluidAction.SIMULATE); int inserted = inventoryTo.fill(extracted, IFluidHandler.FluidAction.EXECUTE); - transferableAmount += storageSystemHandler.drain(filter.setCount(inserted), IFluidHandler.FluidAction.EXECUTE).getAmount(); + transferableAmount += storageSystemHandler + .drain(filter.setCount(inserted), IFluidHandler.FluidAction.EXECUTE).getAmount(); return transferableAmount; } @@ -142,9 +167,7 @@ public static int moveFluid(IFluidHandler inventoryFrom, IFluidHandler inventory return transferableAmount; } - - @Nullable - public static IItemHandler getHandlerFromName(@NotNull IComputerAccess access, String name) throws LuaException { + @Nullable public static IItemHandler getHandlerFromName(@NotNull IComputerAccess access, String name) throws LuaException { IPeripheral location = access.getAvailablePeripheral(name); if (location == null) return null; @@ -152,8 +175,8 @@ public static IItemHandler getHandlerFromName(@NotNull IComputerAccess access, S return extractHandler(location.getTarget()); } - @Nullable - public static IItemHandler getHandlerFromDirection(@NotNull String direction, @NotNull IPeripheralOwner owner) throws LuaException { + @Nullable public static IItemHandler getHandlerFromDirection(@NotNull String direction, @NotNull IPeripheralOwner owner) + throws LuaException { Level level = owner.getLevel(); Objects.requireNonNull(level); Direction relativeDirection = CoordUtil.getDirection(owner.getOrientation(), direction); diff --git a/src/main/java/de/srendi/advancedperipherals/common/util/inventory/ItemFilter.java b/src/main/java/de/srendi/advancedperipherals/common/util/inventory/ItemFilter.java index f44bb19f9..4297cdff3 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/util/inventory/ItemFilter.java +++ b/src/main/java/de/srendi/advancedperipherals/common/util/inventory/ItemFilter.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.util.inventory; import appeng.api.stacks.AEItemKey; @@ -128,7 +143,8 @@ public boolean test(ItemStack stack) { return fingerprint.equals(testFingerprint); } - // If the filter does not have nbt values, a tag or a fingerprint, just test if the items are the same + // If the filter does not have nbt values, a tag or a fingerprint, just test if + // the items are the same if (item != Items.AIR) { if (tag == null && nbt == null && fingerprint.isEmpty()) return stack.is(item); @@ -163,14 +179,8 @@ public Tag getNbt() { @Override public String toString() { - return "ItemFilter{" + - "item=" + ItemUtil.getRegistryKey(item) + - ", tag=" + tag + - ", nbt=" + nbt + - ", count=" + count + - ", fingerprint='" + fingerprint + '\'' + - ", fromSlot=" + fromSlot + - ", toSlot=" + toSlot + - '}'; + return "ItemFilter{" + "item=" + ItemUtil.getRegistryKey(item) + ", tag=" + tag + ", nbt=" + nbt + ", count=" + + count + ", fingerprint='" + fingerprint + '\'' + ", fromSlot=" + fromSlot + ", toSlot=" + toSlot + + '}'; } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/util/inventory/ItemUtil.java b/src/main/java/de/srendi/advancedperipherals/common/util/inventory/ItemUtil.java index fbd61f7f2..d1f85535d 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/util/inventory/ItemUtil.java +++ b/src/main/java/de/srendi/advancedperipherals/common/util/inventory/ItemUtil.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.util.inventory; import dan200.computercraft.shared.Registry; @@ -35,7 +50,8 @@ public static T getRegistryEntry(String name, IForgeRegistry forgeRegistr } T value; - if (location != null && forgeRegistry.containsKey(location) && (value = forgeRegistry.getValue(location)) != null) { + if (location != null && forgeRegistry.containsKey(location) + && (value = forgeRegistry.getValue(location)) != null) { return value; } else { return null; @@ -43,13 +59,16 @@ public static T getRegistryEntry(String name, IForgeRegistry forgeRegistr } /** - * Fingerprints are MD5 hashes generated out of the nbt tag, the registry name and the display name from item stacks - * Used to filter inventory specific operations. {@link de.srendi.advancedperipherals.common.addons.computercraft.peripheral.InventoryManagerPeripheral} + * Fingerprints are MD5 hashes generated out of the nbt tag, the registry name + * and the display name from item stacks Used to filter inventory specific + * operations. + * {@link de.srendi.advancedperipherals.common.addons.computercraft.peripheral.InventoryManagerPeripheral} * * @return A generated MD5 hash from the item stack */ public static String getFingerprint(ItemStack stack) { - String fingerprint = stack.getOrCreateTag() + getRegistryKey(stack).toString() + stack.getDisplayName().getString(); + String fingerprint = stack.getOrCreateTag() + getRegistryKey(stack).toString() + + stack.getDisplayName().getString(); try { byte[] bytesOfHash = fingerprint.getBytes(StandardCharsets.UTF_8); MessageDigest md = MessageDigest.getInstance("MD5"); @@ -73,7 +92,7 @@ public static ItemStack makePocket(Item turtle, String upgrade) { return stack; } - //Gathers all items in handler and returns them + // Gathers all items in handler and returns them public static List getItemsFromItemHandler(IItemHandler handler) { List items = new ArrayList<>(handler.getSlots()); for (int slot = 0; slot < handler.getSlots(); slot++) { 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 d88dd5f0b..191551503 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/village/VillageStructures.java +++ b/src/main/java/de/srendi/advancedperipherals/common/village/VillageStructures.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.village; import com.mojang.datafixers.util.Pair; @@ -5,7 +20,11 @@ import de.srendi.advancedperipherals.common.configuration.APConfig; import net.minecraft.core.Registry; import net.minecraft.data.BuiltinRegistries; -import net.minecraft.data.worldgen.*; +import net.minecraft.data.worldgen.DesertVillagePools; +import net.minecraft.data.worldgen.PlainVillagePools; +import net.minecraft.data.worldgen.SavannaVillagePools; +import net.minecraft.data.worldgen.SnowyVillagePools; +import net.minecraft.data.worldgen.TaigaVillagePools; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.RandomSource; import net.minecraft.world.level.levelgen.structure.pools.StructurePoolElement; @@ -20,16 +39,18 @@ public class VillageStructures { public static void init() { if (!APConfig.WORLD_CONFIG.enableVillagerStructures.get()) return; - //Ensure the vanilla static init is done + // Ensure the vanilla static init is done PlainVillagePools.bootstrap(); SavannaVillagePools.bootstrap(); TaigaVillagePools.bootstrap(); DesertVillagePools.bootstrap(); SnowyVillagePools.bootstrap(); - //Add the scientist house to each village biome + // Add the scientist house to each village biome for (String biome : new String[]{"desert", "snowy", "plains", "savanna", "taiga"}) { AdvancedPeripherals.debug("Register generating scientist_" + biome + " village house"); - addToPool(new ResourceLocation("village/" + biome + "/houses"), AdvancedPeripherals.MOD_ID + ":villages/scientist_" + biome, APConfig.WORLD_CONFIG.villagerStructureWeight.get()); + addToPool(new ResourceLocation("village/" + biome + "/houses"), + AdvancedPeripherals.MOD_ID + ":villages/scientist_" + biome, + APConfig.WORLD_CONFIG.villagerStructureWeight.get()); } } @@ -40,10 +61,13 @@ private static void addToPool(ResourceLocation pool, String toAdd, int weight) { return; } List shuffled = old.getShuffledTemplates(RandomSource.createNewThreadLocalInstance()); - List> newPieces = shuffled.stream().map(p -> Pair.of(p, 1)).collect(Collectors.toList()); - StructurePoolElement newPiece = StructurePoolElement.legacy(toAdd).apply(StructureTemplatePool.Projection.RIGID); + List> newPieces = shuffled.stream().map(p -> Pair.of(p, 1)) + .collect(Collectors.toList()); + StructurePoolElement newPiece = StructurePoolElement.legacy(toAdd) + .apply(StructureTemplatePool.Projection.RIGID); newPieces.add(Pair.of(newPiece, weight)); - Registry.register(BuiltinRegistries.TEMPLATE_POOL, pool, new StructureTemplatePool(pool, old.getName(), newPieces)); + Registry.register(BuiltinRegistries.TEMPLATE_POOL, pool, + new StructureTemplatePool(pool, old.getName(), newPieces)); AdvancedPeripherals.debug("Finished registration for " + toAdd); } } diff --git a/src/main/java/de/srendi/advancedperipherals/common/village/VillagerTrade.java b/src/main/java/de/srendi/advancedperipherals/common/village/VillagerTrade.java index ce91b0037..1c3ad8c07 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/village/VillagerTrade.java +++ b/src/main/java/de/srendi/advancedperipherals/common/village/VillagerTrade.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.village; import net.minecraft.util.RandomSource; @@ -24,7 +39,8 @@ public class VillagerTrade implements VillagerTrades.ItemListing { private final ItemLike item; private final ItemStack itemStack; - private VillagerTrade(@NotNull Type type, int emeraldAmount, int itemAmount, int maxUses, int xp, ItemLike item, ItemStack itemStack) { + private VillagerTrade(@NotNull Type type, int emeraldAmount, int itemAmount, int maxUses, int xp, ItemLike item, + ItemStack itemStack) { this.type = type; this.emeraldAmount = emeraldAmount; this.itemAmount = itemAmount; @@ -34,28 +50,28 @@ private VillagerTrade(@NotNull Type type, int emeraldAmount, int itemAmount, int this.itemStack = itemStack; } - @Nullable - @Override + @Nullable @Override public MerchantOffer getOffer(@NotNull Entity trader, @NotNull RandomSource rand) { if (type == Type.EMERALD_FOR_ITEM) { if (itemStack != null) return new MerchantOffer(itemStack, new ItemStack(Items.EMERALD, emeraldAmount), maxUses, xp, 1); if (item != null) - return new MerchantOffer(new ItemStack(item, itemAmount), new ItemStack(Items.EMERALD, emeraldAmount), maxUses, xp, 1); + return new MerchantOffer(new ItemStack(item, itemAmount), new ItemStack(Items.EMERALD, emeraldAmount), + maxUses, xp, 1); } if (type == Type.ITEM_FOR_EMERALD) { if (itemStack != null) return new MerchantOffer(new ItemStack(Items.EMERALD, emeraldAmount), itemStack, maxUses, xp, 1); if (item != null) - return new MerchantOffer(new ItemStack(Items.EMERALD, emeraldAmount), new ItemStack(item, itemAmount), maxUses, xp, 1); + return new MerchantOffer(new ItemStack(Items.EMERALD, emeraldAmount), new ItemStack(item, itemAmount), + maxUses, xp, 1); } return null; } public enum Type { - ITEM_FOR_EMERALD, - EMERALD_FOR_ITEM + ITEM_FOR_EMERALD, EMERALD_FOR_ITEM } public static class TradeBuilder { @@ -74,7 +90,8 @@ public static class TradeBuilder { private final ItemLike item; private final ItemStack itemStack; - private TradeBuilder(VillagerTradesEvent event, ItemLike item, Type type, int emeraldAmount, int professionLevel) { + private TradeBuilder(VillagerTradesEvent event, ItemLike item, Type type, int emeraldAmount, + int professionLevel) { this.villagerEvent = event; this.item = item; this.itemStack = null; @@ -83,7 +100,8 @@ private TradeBuilder(VillagerTradesEvent event, ItemLike item, Type type, int em this.professionLevel = professionLevel; } - private TradeBuilder(VillagerTradesEvent event, ItemStack stack, Type type, int emeraldAmount, int professionLevel) { + private TradeBuilder(VillagerTradesEvent event, ItemStack stack, Type type, int emeraldAmount, + int professionLevel) { this.villagerEvent = event; this.itemStack = stack; this.item = null; @@ -92,7 +110,8 @@ private TradeBuilder(VillagerTradesEvent event, ItemStack stack, Type type, int this.professionLevel = professionLevel; } - private TradeBuilder(WandererTradesEvent event, ItemLike item, Type type, int emeraldAmount, int professionLevel) { + private TradeBuilder(WandererTradesEvent event, ItemLike item, Type type, int emeraldAmount, + int professionLevel) { this.wandererEvent = event; this.item = item; this.itemStack = null; @@ -101,7 +120,8 @@ private TradeBuilder(WandererTradesEvent event, ItemLike item, Type type, int em this.professionLevel = professionLevel; } - private TradeBuilder(WandererTradesEvent event, ItemStack stack, Type type, int emeraldAmount, int professionLevel) { + private TradeBuilder(WandererTradesEvent event, ItemStack stack, Type type, int emeraldAmount, + int professionLevel) { this.wandererEvent = event; this.itemStack = stack; this.item = null; @@ -111,72 +131,102 @@ private TradeBuilder(WandererTradesEvent event, ItemStack stack, Type type, int } /** - * Creates a new TradeBuilder instance. Can be used to create villager trades for normal villagers - * This one is for normal villagers with any type of{@link ItemLike}. - * {@link net.minecraft.world.item.Item} or {@link net.minecraft.world.level.block.Block} as example. + * Creates a new TradeBuilder instance. Can be used to create villager trades + * for normal villagers This one is for normal villagers with any type + * of{@link ItemLike}. {@link net.minecraft.world.item.Item} or + * {@link net.minecraft.world.level.block.Block} as example. * - * @param event this should be executed in an event - pass the villager trade event here - * @param itemLike the item for trade - * @param type the trade type - * @param emeraldAmount the emerald amount of the trade - * @param professionLevel the profession level of the villager. 1 to 5 + * @param event + * this should be executed in an event - pass the villager trade + * event here + * @param itemLike + * the item for trade + * @param type + * the trade type + * @param emeraldAmount + * the emerald amount of the trade + * @param professionLevel + * the profession level of the villager. 1 to 5 * @return a builder instance */ - public static TradeBuilder createTrade(VillagerTradesEvent event, ItemLike itemLike, Type type, int emeraldAmount, int professionLevel) { + public static TradeBuilder createTrade(VillagerTradesEvent event, ItemLike itemLike, Type type, + int emeraldAmount, int professionLevel) { return new TradeBuilder(event, itemLike, type, emeraldAmount, professionLevel); } /** - * Creates a new TradeBuilder instance. Can be used to create villager trades for normal villagers - * This one is for normal villagers with item stacks + * Creates a new TradeBuilder instance. Can be used to create villager trades + * for normal villagers This one is for normal villagers with item stacks * - * @param event this should be executed in an event - pass the villager trade event here - * @param itemStack the item for trade - * @param type the trade type - * @param emeraldAmount the emerald amount of the trade - * @param professionLevel the profession level of the villager. 1 to 5 + * @param event + * this should be executed in an event - pass the villager trade + * event here + * @param itemStack + * the item for trade + * @param type + * the trade type + * @param emeraldAmount + * the emerald amount of the trade + * @param professionLevel + * the profession level of the villager. 1 to 5 * @return a builder instance */ - public static TradeBuilder createTrade(VillagerTradesEvent event, ItemStack itemStack, Type type, int emeraldAmount, int professionLevel) { + public static TradeBuilder createTrade(VillagerTradesEvent event, ItemStack itemStack, Type type, + int emeraldAmount, int professionLevel) { return new TradeBuilder(event, itemStack, type, emeraldAmount, professionLevel); } /** - * Creates a new TradeBuilder instance. Can be used to create villager trades for wandering traders. - * This one is for wandering traders with any type of{@link ItemLike}. - * {@link net.minecraft.world.item.Item} or {@link net.minecraft.world.level.block.Block} as example. + * Creates a new TradeBuilder instance. Can be used to create villager trades + * for wandering traders. This one is for wandering traders with any type + * of{@link ItemLike}. {@link net.minecraft.world.item.Item} or + * {@link net.minecraft.world.level.block.Block} as example. * - * @param event this should be executed in an event - pass the villager trade event here - * @param itemLike the item for trade - * @param type the trade type - * @param emeraldAmount the emerald amount of the trade - * @param professionLevel the profession level of the villager. 1 to 5 + * @param event + * this should be executed in an event - pass the villager trade + * event here + * @param itemLike + * the item for trade + * @param type + * the trade type + * @param emeraldAmount + * the emerald amount of the trade + * @param professionLevel + * the profession level of the villager. 1 to 5 * @return a builder instance */ - public static TradeBuilder createTrade(WandererTradesEvent event, ItemLike itemLike, Type type, int emeraldAmount, int professionLevel) { + public static TradeBuilder createTrade(WandererTradesEvent event, ItemLike itemLike, Type type, + int emeraldAmount, int professionLevel) { return new TradeBuilder(event, itemLike, type, emeraldAmount, professionLevel); } /** - * Creates a new TradeBuilder instance. Can be used to create villager trades for wandering traders. - * This one is for normal villagers with item stacks + * Creates a new TradeBuilder instance. Can be used to create villager trades + * for wandering traders. This one is for normal villagers with item stacks * - * @param event this should be executed in an event - pass the villager trade event here - * @param itemStack the item for trade - * @param type the trade type - * @param emeraldAmount the emerald amount of the trade - * @param professionLevel the profession level of the villager. 1 to 5 + * @param event + * this should be executed in an event - pass the villager trade + * event here + * @param itemStack + * the item for trade + * @param type + * the trade type + * @param emeraldAmount + * the emerald amount of the trade + * @param professionLevel + * the profession level of the villager. 1 to 5 * @return a builder instance */ - public static TradeBuilder createTrade(WandererTradesEvent event, ItemStack itemStack, Type type, int emeraldAmount, int professionLevel) { + public static TradeBuilder createTrade(WandererTradesEvent event, ItemStack itemStack, Type type, + int emeraldAmount, int professionLevel) { return new TradeBuilder(event, itemStack, type, emeraldAmount, professionLevel); } /** - * Sets the item amount of the trade - * Normally 1 + * Sets the item amount of the trade Normally 1 * - * @param itemAmount the item amount + * @param itemAmount + * the item amount * @return the current instance of the builder */ public TradeBuilder setItemAmount(int itemAmount) { @@ -185,10 +235,10 @@ public TradeBuilder setItemAmount(int itemAmount) { } /** - * Sets the max uses of the trade - * Normally 2 + * Sets the max uses of the trade Normally 2 * - * @param maxUses the item amount + * @param maxUses + * the item amount * @return the current instance of the builder */ public TradeBuilder setMaxUses(int maxUses) { @@ -197,10 +247,10 @@ public TradeBuilder setMaxUses(int maxUses) { } /** - * Sets the xp of the trade - * Normally 10 + * Sets the xp of the trade Normally 10 * - * @param xp the item amount + * @param xp + * the item amount * @return the current instance of the builder */ public TradeBuilder setXp(int xp) { diff --git a/src/main/java/de/srendi/advancedperipherals/common/village/VillagerTrades.java b/src/main/java/de/srendi/advancedperipherals/common/village/VillagerTrades.java index f0ea18dd3..aff203c8e 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/village/VillagerTrades.java +++ b/src/main/java/de/srendi/advancedperipherals/common/village/VillagerTrades.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.common.village; import dan200.computercraft.shared.Registry; @@ -20,11 +35,10 @@ public class VillagerTrades { @SubscribeEvent public static void registerWanderingTrade(WandererTradesEvent event) { TradeBuilder.createTrade(event, APBlocks.PERIPHERAL_CASING.get(), VillagerTrade.Type.ITEM_FOR_EMERALD, 1, 1) - .setMaxUses(8) - .build(); - TradeBuilder.createTrade(event, Registry.ModBlocks.TURTLE_ADVANCED.get(), VillagerTrade.Type.ITEM_FOR_EMERALD, 2, 1) - .setMaxUses(8) - .build(); + .setMaxUses(8).build(); + TradeBuilder + .createTrade(event, Registry.ModBlocks.TURTLE_ADVANCED.get(), VillagerTrade.Type.ITEM_FOR_EMERALD, 2, 1) + .setMaxUses(8).build(); } @SubscribeEvent @@ -32,76 +46,52 @@ public static void registerVillagerTrades(VillagerTradesEvent event) { if (event.getType() == APVillagers.COMPUTER_SCIENTIST.get()) { TradeBuilder.createTrade(event, APBlocks.PERIPHERAL_CASING.get(), VillagerTrade.Type.ITEM_FOR_EMERALD, 1, 1) - .setXp(1) - .build(); - TradeBuilder.createTrade(event, APBlocks.CHAT_BOX.get(), VillagerTrade.Type.ITEM_FOR_EMERALD, 2, 1) - .build(); - TradeBuilder.createTrade(event, Registry.ModBlocks.MONITOR_NORMAL.get(), VillagerTrade.Type.ITEM_FOR_EMERALD, 2, 1) - .setItemAmount(2) - .build(); + .setXp(1).build(); + TradeBuilder.createTrade(event, APBlocks.CHAT_BOX.get(), VillagerTrade.Type.ITEM_FOR_EMERALD, 2, 1).build(); + TradeBuilder.createTrade(event, Registry.ModBlocks.MONITOR_NORMAL.get(), + VillagerTrade.Type.ITEM_FOR_EMERALD, 2, 1).setItemAmount(2).build(); TradeBuilder.createTrade(event, APBlocks.PERIPHERAL_CASING.get(), VillagerTrade.Type.EMERALD_FOR_ITEM, 1, 1) - .setMaxUses(5) - .build(); + .setMaxUses(5).build(); TradeBuilder.createTrade(event, APBlocks.INVENTORY_MANAGER.get(), VillagerTrade.Type.ITEM_FOR_EMERALD, 2, 2) - .setXp(4) - .build(); - TradeBuilder.createTrade(event, APBlocks.REDSTONE_INTEGRATOR.get(), VillagerTrade.Type.ITEM_FOR_EMERALD, 2, 2) - .setXp(3) - .build(); - TradeBuilder.createTrade(event, Registry.ModBlocks.COMPUTER_ADVANCED.get(), VillagerTrade.Type.ITEM_FOR_EMERALD, 3, 2) - .setXp(4) - .build(); + .setXp(4).build(); + TradeBuilder + .createTrade(event, APBlocks.REDSTONE_INTEGRATOR.get(), VillagerTrade.Type.ITEM_FOR_EMERALD, 2, 2) + .setXp(3).build(); + TradeBuilder.createTrade(event, Registry.ModBlocks.COMPUTER_ADVANCED.get(), + VillagerTrade.Type.ITEM_FOR_EMERALD, 3, 2).setXp(4).build(); - TradeBuilder.createTrade(event, ItemUtil.makeTurtle(ItemUtil.TURTLE_NORMAL, CCRegistration.ID.ENVIRONMENT_TURTLE.toString()), VillagerTrade.Type.ITEM_FOR_EMERALD, 4, 3) - .setMaxUses(4) - .setXp(5) - .build(); - TradeBuilder.createTrade(event, ItemUtil.makePocket(ItemUtil.POCKET_ADVANCED, CCRegistration.ID.PLAYER_POCKET.toString()), VillagerTrade.Type.ITEM_FOR_EMERALD, 4, 3) - .setMaxUses(4) - .setXp(7) - .build(); + TradeBuilder.createTrade(event, + ItemUtil.makeTurtle(ItemUtil.TURTLE_NORMAL, CCRegistration.ID.ENVIRONMENT_TURTLE.toString()), + VillagerTrade.Type.ITEM_FOR_EMERALD, 4, 3).setMaxUses(4).setXp(5).build(); + TradeBuilder.createTrade(event, + ItemUtil.makePocket(ItemUtil.POCKET_ADVANCED, CCRegistration.ID.PLAYER_POCKET.toString()), + VillagerTrade.Type.ITEM_FOR_EMERALD, 4, 3).setMaxUses(4).setXp(7).build(); TradeBuilder.createTrade(event, APItems.CHUNK_CONTROLLER.get(), VillagerTrade.Type.EMERALD_FOR_ITEM, 5, 3) - .setMaxUses(6) - .setXp(8) - .build(); + .setMaxUses(6).setXp(8).build(); TradeBuilder.createTrade(event, APItems.COMPUTER_TOOL.get(), VillagerTrade.Type.ITEM_FOR_EMERALD, 1, 3) - .setMaxUses(1) - .setXp(16) - .build(); - TradeBuilder.createTrade(event, Registry.ModBlocks.MONITOR_ADVANCED.get(), VillagerTrade.Type.ITEM_FOR_EMERALD, 6, 3) - .setXp(7) - .setItemAmount(4) - .build(); + .setMaxUses(1).setXp(16).build(); + TradeBuilder.createTrade(event, Registry.ModBlocks.MONITOR_ADVANCED.get(), + VillagerTrade.Type.ITEM_FOR_EMERALD, 6, 3).setXp(7).setItemAmount(4).build(); TradeBuilder.createTrade(event, APBlocks.ENERGY_DETECTOR.get(), VillagerTrade.Type.ITEM_FOR_EMERALD, 4, 4) - .setXp(6) - .build(); - TradeBuilder.createTrade(event, Registry.ModBlocks.COMPUTER_ADVANCED.get(), VillagerTrade.Type.ITEM_FOR_EMERALD, 4, 4) - .setXp(5) - .setMaxUses(3) - .build(); + .setXp(6).build(); + TradeBuilder.createTrade(event, Registry.ModBlocks.COMPUTER_ADVANCED.get(), + VillagerTrade.Type.ITEM_FOR_EMERALD, 4, 4).setXp(5).setMaxUses(3).build(); TradeBuilder.createTrade(event, APItems.MEMORY_CARD.get(), VillagerTrade.Type.EMERALD_FOR_ITEM, 2, 4) - .setXp(4) - .build(); - TradeBuilder.createTrade(event, ItemUtil.makeTurtle(ItemUtil.TURTLE_ADVANCED, CCRegistration.ID.CHUNKY_TURTLE.toString()), VillagerTrade.Type.ITEM_FOR_EMERALD, 8, 4) - .setXp(7) - .build(); + .setXp(4).build(); + TradeBuilder.createTrade(event, + ItemUtil.makeTurtle(ItemUtil.TURTLE_ADVANCED, CCRegistration.ID.CHUNKY_TURTLE.toString()), + VillagerTrade.Type.ITEM_FOR_EMERALD, 8, 4).setXp(7).build(); TradeBuilder.createTrade(event, APItems.CHUNK_CONTROLLER.get(), VillagerTrade.Type.ITEM_FOR_EMERALD, 6, 4) - .setMaxUses(6) - .setXp(6) - .build(); + .setMaxUses(6).setXp(6).build(); TradeBuilder.createTrade(event, APBlocks.ME_BRIDGE.get(), VillagerTrade.Type.ITEM_FOR_EMERALD, 4, 5) - .setItemAmount(2) - .setXp(4) - .build(); + .setItemAmount(2).setXp(4).build(); TradeBuilder.createTrade(event, Registry.ModBlocks.SPEAKER.get(), VillagerTrade.Type.ITEM_FOR_EMERALD, 3, 5) - .setXp(6) - .build(); - TradeBuilder.createTrade(event, Registry.ModBlocks.WIRELESS_MODEM_ADVANCED.get(), VillagerTrade.Type.ITEM_FOR_EMERALD, 4, 5) - .setXp(8) - .build(); + .setXp(6).build(); + TradeBuilder.createTrade(event, Registry.ModBlocks.WIRELESS_MODEM_ADVANCED.get(), + VillagerTrade.Type.ITEM_FOR_EMERALD, 4, 5).setXp(8).build(); } } diff --git a/src/main/java/de/srendi/advancedperipherals/lib/LibConfig.java b/src/main/java/de/srendi/advancedperipherals/lib/LibConfig.java index 0ca3c3a25..0563490d4 100644 --- a/src/main/java/de/srendi/advancedperipherals/lib/LibConfig.java +++ b/src/main/java/de/srendi/advancedperipherals/lib/LibConfig.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.lib; import net.minecraftforge.common.ForgeConfigSpec; @@ -27,8 +42,11 @@ public static void setTestMode(boolean mode) { } public static void build(final ForgeConfigSpec.Builder builder) { - isInitialCooldownEnabled = builder.comment("Enables initial cooldown on peripheral initialization").define("isInitialCooldownEnabled", true); - initialCooldownSensitiveLevel = builder.comment("Determinates initial cooldown sensitive level, values lower then this value will not trigger initial cooldown").defineInRange("initialCooldownSensitiveLevel", 6_000, 0, Integer.MAX_VALUE); + isInitialCooldownEnabled = builder.comment("Enables initial cooldown on peripheral initialization") + .define("isInitialCooldownEnabled", true); + initialCooldownSensitiveLevel = builder.comment( + "Determinates initial cooldown sensitive level, values lower then this value will not trigger initial cooldown") + .defineInRange("initialCooldownSensitiveLevel", 6_000, 0, Integer.MAX_VALUE); } public static void reloadConfig() { diff --git a/src/main/java/de/srendi/advancedperipherals/lib/integrations/IPeripheralIntegration.java b/src/main/java/de/srendi/advancedperipherals/lib/integrations/IPeripheralIntegration.java index d78494b6e..3ffdf2731 100644 --- a/src/main/java/de/srendi/advancedperipherals/lib/integrations/IPeripheralIntegration.java +++ b/src/main/java/de/srendi/advancedperipherals/lib/integrations/IPeripheralIntegration.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.lib.integrations; import dan200.computercraft.api.peripheral.IPeripheral; diff --git a/src/main/java/de/srendi/advancedperipherals/lib/metaphysics/IAutomataCoreTier.java b/src/main/java/de/srendi/advancedperipherals/lib/metaphysics/IAutomataCoreTier.java index 42ddce4f4..a17afba94 100644 --- a/src/main/java/de/srendi/advancedperipherals/lib/metaphysics/IAutomataCoreTier.java +++ b/src/main/java/de/srendi/advancedperipherals/lib/metaphysics/IAutomataCoreTier.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.lib.metaphysics; import de.srendi.advancedperipherals.lib.misc.IConfigHandler; diff --git a/src/main/java/de/srendi/advancedperipherals/lib/metaphysics/IFeedableAutomataCore.java b/src/main/java/de/srendi/advancedperipherals/lib/metaphysics/IFeedableAutomataCore.java index c8a4586ab..89e6416ee 100644 --- a/src/main/java/de/srendi/advancedperipherals/lib/metaphysics/IFeedableAutomataCore.java +++ b/src/main/java/de/srendi/advancedperipherals/lib/metaphysics/IFeedableAutomataCore.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.lib.metaphysics; public interface IFeedableAutomataCore { diff --git a/src/main/java/de/srendi/advancedperipherals/lib/misc/IConfigHandler.java b/src/main/java/de/srendi/advancedperipherals/lib/misc/IConfigHandler.java index a7f86422e..90b951f10 100644 --- a/src/main/java/de/srendi/advancedperipherals/lib/misc/IConfigHandler.java +++ b/src/main/java/de/srendi/advancedperipherals/lib/misc/IConfigHandler.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.lib.misc; import net.minecraftforge.common.ForgeConfigSpec; @@ -16,7 +31,9 @@ default String settingsPostfix() { default String settingsName() { String name = name(); - String startName = Arrays.stream(name.toLowerCase().split("_")).map(s -> s.substring(0, 1).toUpperCase() + s.substring(1).toLowerCase()).collect(Collectors.joining()) + settingsPostfix(); + String startName = Arrays.stream(name.toLowerCase().split("_")) + .map(s -> s.substring(0, 1).toUpperCase() + s.substring(1).toLowerCase()).collect(Collectors.joining()) + + settingsPostfix(); return startName.substring(0, 1).toLowerCase() + startName.substring(1); } } diff --git a/src/main/java/de/srendi/advancedperipherals/lib/peripherals/AutomataCorePeripheral.java b/src/main/java/de/srendi/advancedperipherals/lib/peripherals/AutomataCorePeripheral.java index 00618d94b..16d10bf6d 100644 --- a/src/main/java/de/srendi/advancedperipherals/lib/peripherals/AutomataCorePeripheral.java +++ b/src/main/java/de/srendi/advancedperipherals/lib/peripherals/AutomataCorePeripheral.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.lib.peripherals; import dan200.computercraft.api.lua.LuaException; @@ -61,15 +76,19 @@ public SingleOperationContext toDistance(BlockPos pos) { return new SingleOperationContext(1, getPos().distManhattan(pos)); } - public MethodResult withOperation(IPeripheralOperation operation, T context, IPeripheralFunction function, IPeripheralCheck check) throws LuaException { + public MethodResult withOperation(IPeripheralOperation operation, T context, + IPeripheralFunction function, IPeripheralCheck check) throws LuaException { return withOperation(operation, context, check, function, ignored -> addRotationCycle()); } - public MethodResult withOperation(SingleOperation operation, IPeripheralFunction function) throws LuaException { + public MethodResult withOperation(SingleOperation operation, + IPeripheralFunction function) throws LuaException { return withOperation(operation, forUnknownDistance(), function, null); } - public MethodResult withOperation(SingleOperation operation, IPeripheralFunction function, IPeripheralCheck check) throws LuaException { + public MethodResult withOperation(SingleOperation operation, + IPeripheralFunction function, + IPeripheralCheck check) throws LuaException { return withOperation(operation, forUnknownDistance(), function, check); } 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 09694d948..12d15a8b3 100644 --- a/src/main/java/de/srendi/advancedperipherals/lib/peripherals/BasePeripheral.java +++ b/src/main/java/de/srendi/advancedperipherals/lib/peripherals/BasePeripheral.java @@ -1,6 +1,25 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.lib.peripherals; -import dan200.computercraft.api.lua.*; +import dan200.computercraft.api.lua.IArguments; +import dan200.computercraft.api.lua.ILuaContext; +import dan200.computercraft.api.lua.LuaException; +import dan200.computercraft.api.lua.LuaFunction; +import dan200.computercraft.api.lua.MethodResult; import dan200.computercraft.api.peripheral.IComputerAccess; import dan200.computercraft.api.peripheral.IDynamicPeripheral; import dan200.computercraft.api.peripheral.IPeripheral; @@ -14,7 +33,14 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.function.BiConsumer; import java.util.function.Consumer; @@ -38,10 +64,11 @@ protected void buildPlugins() { if (!initialized) { initialized = true; this.pluggedMethods.clear(); - if (plugins != null) plugins.forEach(plugin -> { - if (plugin.isSuitable(this)) - pluggedMethods.addAll(plugin.getMethods()); - }); + if (plugins != null) + plugins.forEach(plugin -> { + if (plugin.isSuitable(this)) + pluggedMethods.addAll(plugin.getMethods()); + }); owner.getAbilities().forEach(ability -> { if (ability instanceof IPeripheralPlugin peripheralPlugin) pluggedMethods.addAll(peripheralPlugin.getMethods()); @@ -51,13 +78,15 @@ protected void buildPlugins() { } protected void addPlugin(@NotNull IPeripheralPlugin plugin) { - if (plugins == null) plugins = new LinkedList<>(); + if (plugins == null) + plugins = new LinkedList<>(); plugins.add(plugin); IPeripheralOperation[] operations = plugin.getOperations(); if (operations != null) { OperationAbility operationAbility = owner.getAbility(PeripheralOwnerAbility.OPERATION); if (operationAbility == null) - throw new IllegalArgumentException("This is not possible to attach plugin with operations to not operationable owner"); + throw new IllegalArgumentException( + "This is not possible to attach plugin with operations to not operationable owner"); for (IPeripheralOperation operation : operations) operationAbility.registerOperation(operation); } @@ -68,14 +97,12 @@ public Iterable getConnectedComputers() { return connectedComputers; } - @Nullable - @Override + @Nullable @Override public Object getTarget() { return owner; } - @NotNull - @Override + @NotNull @Override public String getType() { return type; } @@ -129,28 +156,33 @@ protected Direction validateSide(String direction) throws LuaException { } @Override - @NotNull - public String @NotNull [] getMethodNames() { + @NotNull public String @NotNull [] getMethodNames() { if (!initialized) buildPlugins(); return methodNames; } @Override - @NotNull - public MethodResult callMethod(@NotNull IComputerAccess access, @NotNull ILuaContext context, int index, @NotNull IArguments arguments) throws LuaException { + @NotNull public MethodResult callMethod(@NotNull IComputerAccess access, @NotNull ILuaContext context, int index, + @NotNull IArguments arguments) throws LuaException { if (!initialized) buildPlugins(); return pluggedMethods.get(index).apply(access, context, arguments); } - protected MethodResult withOperation(IPeripheralOperation operation, T context, @Nullable IPeripheralCheck check, IPeripheralFunction method, @Nullable Consumer successCallback) throws LuaException { + protected MethodResult withOperation(IPeripheralOperation operation, T context, + @Nullable IPeripheralCheck check, IPeripheralFunction method, + @Nullable Consumer successCallback) throws LuaException { return withOperation(operation, context, check, method, successCallback, null); } - protected MethodResult withOperation(IPeripheralOperation operation, T context, @Nullable IPeripheralCheck check, IPeripheralFunction method, @Nullable Consumer successCallback, @Nullable BiConsumer failCallback) throws LuaException { + protected MethodResult withOperation(IPeripheralOperation operation, T context, + @Nullable IPeripheralCheck check, IPeripheralFunction method, + @Nullable Consumer successCallback, + @Nullable BiConsumer failCallback) throws LuaException { OperationAbility operationAbility = owner.getAbility(PeripheralOwnerAbility.OPERATION); - if (operationAbility == null) throw new IllegalArgumentException("This shouldn't happen at all"); + if (operationAbility == null) + throw new IllegalArgumentException("This shouldn't happen at all"); return operationAbility.performOperation(operation, context, check, method, successCallback, failCallback); } } diff --git a/src/main/java/de/srendi/advancedperipherals/lib/peripherals/BlockEntityIntegrationPeripheral.java b/src/main/java/de/srendi/advancedperipherals/lib/peripherals/BlockEntityIntegrationPeripheral.java index 3863765d9..a23e55393 100644 --- a/src/main/java/de/srendi/advancedperipherals/lib/peripherals/BlockEntityIntegrationPeripheral.java +++ b/src/main/java/de/srendi/advancedperipherals/lib/peripherals/BlockEntityIntegrationPeripheral.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.lib.peripherals; import net.minecraft.world.level.block.entity.BlockEntity; @@ -12,8 +27,7 @@ protected BlockEntityIntegrationPeripheral(BlockEntity entity) { this.blockEntity = (T) entity; } - @Nullable - @Override + @Nullable @Override public Object getTarget() { return blockEntity; } diff --git a/src/main/java/de/srendi/advancedperipherals/lib/peripherals/BlockIntegrationPeripheral.java b/src/main/java/de/srendi/advancedperipherals/lib/peripherals/BlockIntegrationPeripheral.java index c04df5e9c..c06f200ee 100644 --- a/src/main/java/de/srendi/advancedperipherals/lib/peripherals/BlockIntegrationPeripheral.java +++ b/src/main/java/de/srendi/advancedperipherals/lib/peripherals/BlockIntegrationPeripheral.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.lib.peripherals; import net.minecraft.core.BlockPos; @@ -20,8 +35,7 @@ public Block getBlock() { return world.getBlockState(pos).getBlock(); } - @Nullable - @Override + @Nullable @Override public Object getTarget() { return world.getBlockState(pos).getBlock(); } diff --git a/src/main/java/de/srendi/advancedperipherals/lib/peripherals/BoundMethod.java b/src/main/java/de/srendi/advancedperipherals/lib/peripherals/BoundMethod.java index bbfc053c1..30960dcc8 100644 --- a/src/main/java/de/srendi/advancedperipherals/lib/peripherals/BoundMethod.java +++ b/src/main/java/de/srendi/advancedperipherals/lib/peripherals/BoundMethod.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.lib.peripherals; import dan200.computercraft.api.lua.IArguments; @@ -22,20 +37,21 @@ public BoundMethod(@NotNull Object target, @NotNull NamedMethod first, IPeripheralCheck @Override public @Nullable MethodResult check(T1 context) { MethodResult firstCheck = first.check(context); - if (firstCheck != null) return firstCheck; + if (firstCheck != null) + return firstCheck; return second.check(context); } } diff --git a/src/main/java/de/srendi/advancedperipherals/lib/peripherals/IPeripheralFunction.java b/src/main/java/de/srendi/advancedperipherals/lib/peripherals/IPeripheralFunction.java index 0d21220ed..757fdb65d 100644 --- a/src/main/java/de/srendi/advancedperipherals/lib/peripherals/IPeripheralFunction.java +++ b/src/main/java/de/srendi/advancedperipherals/lib/peripherals/IPeripheralFunction.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.lib.peripherals; import dan200.computercraft.api.lua.LuaException; diff --git a/src/main/java/de/srendi/advancedperipherals/lib/peripherals/IPeripheralOperation.java b/src/main/java/de/srendi/advancedperipherals/lib/peripherals/IPeripheralOperation.java index 4dfe11fea..90f59dcad 100644 --- a/src/main/java/de/srendi/advancedperipherals/lib/peripherals/IPeripheralOperation.java +++ b/src/main/java/de/srendi/advancedperipherals/lib/peripherals/IPeripheralOperation.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.lib.peripherals; import de.srendi.advancedperipherals.lib.misc.IConfigHandler; diff --git a/src/main/java/de/srendi/advancedperipherals/lib/peripherals/IPeripheralPlugin.java b/src/main/java/de/srendi/advancedperipherals/lib/peripherals/IPeripheralPlugin.java index da1659e49..75d4973da 100644 --- a/src/main/java/de/srendi/advancedperipherals/lib/peripherals/IPeripheralPlugin.java +++ b/src/main/java/de/srendi/advancedperipherals/lib/peripherals/IPeripheralPlugin.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.lib.peripherals; import dan200.computercraft.api.peripheral.IPeripheral; @@ -9,7 +24,8 @@ public interface IPeripheralPlugin { default List getMethods() { - return PeripheralMethod.GENERATOR.getMethods(this.getClass()).stream().map(named -> new BoundMethod(this, named)).collect(Collectors.toList()); + return PeripheralMethod.GENERATOR.getMethods(this.getClass()).stream() + .map(named -> new BoundMethod(this, named)).collect(Collectors.toList()); } default @Nullable IPeripheralOperation[] getOperations() { diff --git a/src/main/java/de/srendi/advancedperipherals/lib/peripherals/IPeripheralTileEntity.java b/src/main/java/de/srendi/advancedperipherals/lib/peripherals/IPeripheralTileEntity.java index 47c526faa..6ee91a3f7 100644 --- a/src/main/java/de/srendi/advancedperipherals/lib/peripherals/IPeripheralTileEntity.java +++ b/src/main/java/de/srendi/advancedperipherals/lib/peripherals/IPeripheralTileEntity.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.lib.peripherals; import net.minecraft.nbt.CompoundTag; 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 b9369189b..956e5afb3 100644 --- a/src/main/java/de/srendi/advancedperipherals/lib/peripherals/IntegrationPeripheral.java +++ b/src/main/java/de/srendi/advancedperipherals/lib/peripherals/IntegrationPeripheral.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.lib.peripherals; import dan200.computercraft.api.lua.IArguments; @@ -27,20 +42,23 @@ protected void buildPlugins() { if (!initialized) { initialized = true; this.pluggedMethods.clear(); - if (plugins != null) plugins.forEach(plugin -> { - if (plugin.isSuitable(this)) - pluggedMethods.addAll(plugin.getMethods()); - }); + if (plugins != null) + plugins.forEach(plugin -> { + if (plugin.isSuitable(this)) + pluggedMethods.addAll(plugin.getMethods()); + }); this.methodNames = pluggedMethods.stream().map(BoundMethod::getName).toArray(String[]::new); } } protected void addPlugin(@NotNull IPeripheralPlugin plugin) { - if (plugins == null) plugins = new LinkedList<>(); + if (plugins == null) + plugins = new LinkedList<>(); plugins.add(plugin); IPeripheralOperation[] operations = plugin.getOperations(); if (operations != null) { - throw new IllegalArgumentException("This is not possible to attach plugin with operations to not operationable owner"); + throw new IllegalArgumentException( + "This is not possible to attach plugin with operations to not operationable owner"); } } @@ -64,16 +82,15 @@ public boolean equals(@Nullable IPeripheral iPeripheral) { } @Override - @NotNull - public String @NotNull [] getMethodNames() { + @NotNull public String @NotNull [] getMethodNames() { if (!initialized) buildPlugins(); return methodNames; } @Override - @NotNull - public MethodResult callMethod(@NotNull IComputerAccess access, @NotNull ILuaContext context, int index, @NotNull IArguments arguments) throws LuaException { + @NotNull public MethodResult callMethod(@NotNull IComputerAccess access, @NotNull ILuaContext context, int index, + @NotNull IArguments arguments) throws LuaException { if (!initialized) buildPlugins(); return pluggedMethods.get(index).apply(access, context, arguments); diff --git a/src/main/java/de/srendi/advancedperipherals/lib/pocket/BasePocketUpgrade.java b/src/main/java/de/srendi/advancedperipherals/lib/pocket/BasePocketUpgrade.java index 291a333de..155839c6f 100644 --- a/src/main/java/de/srendi/advancedperipherals/lib/pocket/BasePocketUpgrade.java +++ b/src/main/java/de/srendi/advancedperipherals/lib/pocket/BasePocketUpgrade.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.lib.pocket; import dan200.computercraft.api.peripheral.IPeripheral; @@ -21,11 +36,11 @@ protected BasePocketUpgrade(ResourceLocation id, ItemStack stack) { protected abstract T getPeripheral(IPocketAccess access); - @Nullable - @Override + @Nullable @Override public IPeripheral createPeripheral(@NotNull IPocketAccess access) { peripheral = getPeripheral(access); - if (!peripheral.isEnabled()) return DisabledPeripheral.INSTANCE; + if (!peripheral.isEnabled()) + return DisabledPeripheral.INSTANCE; return peripheral; } } 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 0c8391873..c960c75df 100644 --- a/src/main/java/de/srendi/advancedperipherals/lib/turtle/ClockwiseAnimatedTurtleUpgrade.java +++ b/src/main/java/de/srendi/advancedperipherals/lib/turtle/ClockwiseAnimatedTurtleUpgrade.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.lib.turtle; import dan200.computercraft.api.turtle.ITurtleAccess; @@ -14,28 +29,22 @@ protected ClockwiseAnimatedTurtleUpgrade(ResourceLocation id, ItemStack item) { super(id, item); } - /*@NotNull - @Override - public TransformedModel getModel(@Nullable ITurtleAccess turtle, @NotNull TurtleSide side) { - if (getLeftModel() == null) { - PoseStack stack = new PoseStack(); - stack.pushPose(); - stack.translate(0.0f, 0.5f, 0.5f); - if (turtle != null) { - int rotationStep = DataStorageUtil.RotationCharge.get(turtle, side); - stack.mulPose(Vector3f.XN.rotationDegrees(-10 * rotationStep)); - } - stack.translate(0.0f, -0.5f, -0.5f); - stack.mulPose(Vector3f.YN.rotationDegrees(90)); - if (side == TurtleSide.LEFT) { - stack.translate(0, 0, -0.6); - } else { - stack.translate(0, 0, -1.4); - } - return TransformedModel.of(getCraftingItem(), new Transformation(stack.last().pose())); - } - return TransformedModel.of(side == TurtleSide.LEFT ? getLeftModel() : getRightModel()); - }*/ + /* + * @NotNull + * + * @Override public TransformedModel getModel(@Nullable ITurtleAccess + * turtle, @NotNull TurtleSide side) { if (getLeftModel() == null) { PoseStack + * stack = new PoseStack(); stack.pushPose(); stack.translate(0.0f, 0.5f, 0.5f); + * if (turtle != null) { int rotationStep = + * DataStorageUtil.RotationCharge.get(turtle, side); + * stack.mulPose(Vector3f.XN.rotationDegrees(-10 * rotationStep)); } + * stack.translate(0.0f, -0.5f, -0.5f); + * stack.mulPose(Vector3f.YN.rotationDegrees(90)); if (side == TurtleSide.LEFT) + * { stack.translate(0, 0, -0.6); } else { stack.translate(0, 0, -1.4); } return + * TransformedModel.of(getCraftingItem(), new + * Transformation(stack.last().pose())); } return TransformedModel.of(side == + * TurtleSide.LEFT ? getLeftModel() : getRightModel()); } + */ // Optional callbacks for addons based on AP public void chargeConsumingCallback() { diff --git a/src/main/java/de/srendi/advancedperipherals/lib/turtle/PeripheralTurtleUpgrade.java b/src/main/java/de/srendi/advancedperipherals/lib/turtle/PeripheralTurtleUpgrade.java index 2c1488eb0..01b383c17 100644 --- a/src/main/java/de/srendi/advancedperipherals/lib/turtle/PeripheralTurtleUpgrade.java +++ b/src/main/java/de/srendi/advancedperipherals/lib/turtle/PeripheralTurtleUpgrade.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.lib.turtle; import dan200.computercraft.api.peripheral.IPeripheral; @@ -21,15 +36,14 @@ protected PeripheralTurtleUpgrade(ResourceLocation id, ItemStack item) { super(id, TurtleUpgradeType.PERIPHERAL, TranslationUtil.turtle(id.getPath()), item); } - //TODO: Do we still need this with the new modeller system? + // TODO: Do we still need this with the new modeller system? public abstract ModelResourceLocation getLeftModel(); public abstract ModelResourceLocation getRightModel(); protected abstract T buildPeripheral(@NotNull ITurtleAccess turtle, @NotNull TurtleSide side); - @Nullable - @Override + @Nullable @Override public IPeripheral createPeripheral(@NotNull ITurtleAccess turtle, @NotNull TurtleSide side) { T peripheral = buildPeripheral(turtle, side); if (!peripheral.isEnabled()) { diff --git a/src/test/java/de/srendi/advancedperipherals/lib/peripherals/owner/OperationAbilityTest.java b/src/test/java/de/srendi/advancedperipherals/lib/peripherals/owner/OperationAbilityTest.java index a2781aa68..0b54ede12 100644 --- a/src/test/java/de/srendi/advancedperipherals/lib/peripherals/owner/OperationAbilityTest.java +++ b/src/test/java/de/srendi/advancedperipherals/lib/peripherals/owner/OperationAbilityTest.java @@ -1,77 +1,69 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.lib.peripherals.owner; public class OperationAbilityTest { - //Commented out until we port ttoolkit to 1.18 - /*@Test - public void testCooldownLong() { - DummyPeripheralOwner owner = new DummyPeripheralOwner(); - owner.attachOperation(DummyOperations.LONG); - OperationAbility operationAbility = owner.getAbility(PeripheralOwnerAbility.OPERATION); - assertNotNull(operationAbility); - int abilityCooldown = operationAbility.getCurrentCooldown(DummyOperations.LONG); - assertTrue(operationAbility.isOnCooldown(DummyOperations.LONG)); - assertTrue(abilityCooldown > 10_000); - assertTrue(abilityCooldown < 20_001); - } - - @Test - public void testCooldownShort() { - DummyPeripheralOwner owner = new DummyPeripheralOwner(); - assertTrue(LibConfig.initialCooldownSensetiveLevel > DummyOperations.SHORT.cooldown); - owner.attachOperation(DummyOperations.LONG); - OperationAbility operationAbility = owner.getAbility(PeripheralOwnerAbility.OPERATION); - assertNotNull(operationAbility); - int abilityCooldown = operationAbility.getCurrentCooldown(DummyOperations.SHORT); - assertFalse(operationAbility.isOnCooldown(DummyOperations.SHORT)); - assertEquals(0, abilityCooldown); - } - - @Test - public void testCooldownWithoutInitialCooldown() { - DummyPeripheralOwner owner = new DummyPeripheralOwner(); - LibConfig.setTestMode(true); - owner.attachOperation(DummyOperations.LONG); - OperationAbility operationAbility = owner.getAbility(PeripheralOwnerAbility.OPERATION); - assertNotNull(operationAbility); - int abilityCooldown = operationAbility.getCurrentCooldown(DummyOperations.LONG); - assertFalse(operationAbility.isOnCooldown(DummyOperations.LONG)); - assertEquals(0, abilityCooldown); - LibConfig.setTestMode(false); - } - - public enum DummyOperations implements IPeripheralOperation { - LONG(20_000), SHORT(3_000); - - private final int cooldown; - - DummyOperations(int cooldown) { - this.cooldown = cooldown; - } - - @Override - public void addToConfig(ForgeConfigSpec.Builder builder) { - } - - @Override - public int getInitialCooldown() { - return cooldown; - } - - @Override - public int getCooldown(Object context) { - return cooldown; - } - - @Override - public int getCost(Object context) { - return 3; - } - - @Override - public Map computerDescription() { - return new HashMap<>(); - } - }*/ + // Commented out until we port ttoolkit to 1.18 + /* + * @Test public void testCooldownLong() { DummyPeripheralOwner owner = new + * DummyPeripheralOwner(); owner.attachOperation(DummyOperations.LONG); + * OperationAbility operationAbility = + * owner.getAbility(PeripheralOwnerAbility.OPERATION); + * assertNotNull(operationAbility); int abilityCooldown = + * operationAbility.getCurrentCooldown(DummyOperations.LONG); + * assertTrue(operationAbility.isOnCooldown(DummyOperations.LONG)); + * assertTrue(abilityCooldown > 10_000); assertTrue(abilityCooldown < 20_001); } + * + * @Test public void testCooldownShort() { DummyPeripheralOwner owner = new + * DummyPeripheralOwner(); assertTrue(LibConfig.initialCooldownSensetiveLevel > + * DummyOperations.SHORT.cooldown); owner.attachOperation(DummyOperations.LONG); + * OperationAbility operationAbility = + * owner.getAbility(PeripheralOwnerAbility.OPERATION); + * assertNotNull(operationAbility); int abilityCooldown = + * operationAbility.getCurrentCooldown(DummyOperations.SHORT); + * assertFalse(operationAbility.isOnCooldown(DummyOperations.SHORT)); + * assertEquals(0, abilityCooldown); } + * + * @Test public void testCooldownWithoutInitialCooldown() { DummyPeripheralOwner + * owner = new DummyPeripheralOwner(); LibConfig.setTestMode(true); + * owner.attachOperation(DummyOperations.LONG); OperationAbility + * operationAbility = owner.getAbility(PeripheralOwnerAbility.OPERATION); + * assertNotNull(operationAbility); int abilityCooldown = + * operationAbility.getCurrentCooldown(DummyOperations.LONG); + * assertFalse(operationAbility.isOnCooldown(DummyOperations.LONG)); + * assertEquals(0, abilityCooldown); LibConfig.setTestMode(false); } + * + * public enum DummyOperations implements IPeripheralOperation { + * LONG(20_000), SHORT(3_000); + * + * private final int cooldown; + * + * DummyOperations(int cooldown) { this.cooldown = cooldown; } + * + * @Override public void addToConfig(ForgeConfigSpec.Builder builder) { } + * + * @Override public int getInitialCooldown() { return cooldown; } + * + * @Override public int getCooldown(Object context) { return cooldown; } + * + * @Override public int getCost(Object context) { return 3; } + * + * @Override public Map computerDescription() { return new + * HashMap<>(); } } + */ } diff --git a/src/test/java/de/srendi/advancedperipherals/test/DummyPeripheralOwner.java b/src/test/java/de/srendi/advancedperipherals/test/DummyPeripheralOwner.java index 66390a63a..0b1af4134 100644 --- a/src/test/java/de/srendi/advancedperipherals/test/DummyPeripheralOwner.java +++ b/src/test/java/de/srendi/advancedperipherals/test/DummyPeripheralOwner.java @@ -1,79 +1,69 @@ +/* + * Copyright 2024 Intelligence Modding @ https://intelligence-modding.de + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package de.srendi.advancedperipherals.test; -public class DummyPeripheralOwner /*extends BasePeripheralOwner*/ { - - /* private final CompoundTag dataStorage = new CompoundTag(); - - @Override - @Nullable - public String getCustomName() { - return null; - } - - @Override - @Nullable - public Level getLevel() { - return null; - } - - @Override - @NotNull - public BlockPos getPos() { - return new BlockPos(0, 0, 0); - } - - @Override - @NotNull - public Direction getFacing() { - return Direction.NORTH; - } - - @Override - @Nullable - public Player getOwner() { - return null; - } - - @Override - @NotNull - public CompoundTag getDataStorage() { - return dataStorage; - } - - @Override - public void markDataStorageDirty() { - - } - - @Override - public T withPlayer(Function function) { - throw new RuntimeException("Not implemented"); - } - - @Override - public ItemStack getToolInMainHand() { - return ItemStack.EMPTY; - } - - @Override - public ItemStack storeItem(ItemStack stored) { - return stored; - } - - @Override - public void destroyUpgrade() { - - } - - @Override - public boolean isMovementPossible(@NotNull Level level, @NotNull BlockPos pos) { - return false; - } - - @Override - public boolean move(@NotNull Level level, @NotNull BlockPos pos) { - return false; - } - */ +public class DummyPeripheralOwner /* extends BasePeripheralOwner */ { + + /* + * private final CompoundTag dataStorage = new CompoundTag(); + * + * @Override + * + * @Nullable public String getCustomName() { return null; } + * + * @Override + * + * @Nullable public Level getLevel() { return null; } + * + * @Override + * + * @NotNull public BlockPos getPos() { return new BlockPos(0, 0, 0); } + * + * @Override + * + * @NotNull public Direction getFacing() { return Direction.NORTH; } + * + * @Override + * + * @Nullable public Player getOwner() { return null; } + * + * @Override + * + * @NotNull public CompoundTag getDataStorage() { return dataStorage; } + * + * @Override public void markDataStorageDirty() { + * + * } + * + * @Override public T withPlayer(Function function) { throw + * new RuntimeException("Not implemented"); } + * + * @Override public ItemStack getToolInMainHand() { return ItemStack.EMPTY; } + * + * @Override public ItemStack storeItem(ItemStack stored) { return stored; } + * + * @Override public void destroyUpgrade() { + * + * } + * + * @Override public boolean isMovementPossible(@NotNull Level level, @NotNull + * BlockPos pos) { return false; } + * + * @Override public boolean move(@NotNull Level level, @NotNull BlockPos pos) { + * return false; } + */ }