├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── src ├── main │ ├── resources │ │ ├── assets │ │ │ └── plethora │ │ │ │ ├── textures │ │ │ │ ├── misc │ │ │ │ │ ├── flare.png.mcmeta │ │ │ │ │ └── flare.png │ │ │ │ ├── gui │ │ │ │ │ ├── xnet.png │ │ │ │ │ └── neural_interface.png │ │ │ │ ├── items │ │ │ │ │ ├── keyboard.png │ │ │ │ │ ├── module_chat.png │ │ │ │ │ ├── module_laser.png │ │ │ │ │ ├── module_glasses.png │ │ │ │ │ ├── module_kinetic.png │ │ │ │ │ ├── module_scanner.png │ │ │ │ │ ├── module_sensor.png │ │ │ │ │ ├── module_unknown.png │ │ │ │ │ ├── neural_connector.png │ │ │ │ │ ├── neural_interface.png │ │ │ │ │ ├── module_chat_creative.png │ │ │ │ │ └── module_introspection.png │ │ │ │ ├── blocks │ │ │ │ │ ├── manipulator.png │ │ │ │ │ ├── manipulator_side.png │ │ │ │ │ ├── manipulator_top1.png │ │ │ │ │ ├── manipulator_top2.png │ │ │ │ │ ├── manipulator_bottom.png │ │ │ │ │ └── redstone_integrator.png │ │ │ │ └── models │ │ │ │ │ └── neural_interface.png │ │ │ │ ├── models │ │ │ │ ├── item │ │ │ │ │ ├── keyboard.json │ │ │ │ │ ├── module.json │ │ │ │ │ ├── module_chat.json │ │ │ │ │ ├── module_sensor.json │ │ │ │ │ ├── module_glasses.json │ │ │ │ │ ├── module_kinetic.json │ │ │ │ │ ├── module_scanner.json │ │ │ │ │ ├── neural_connector.json │ │ │ │ │ ├── neural_interface.json │ │ │ │ │ ├── module_chat_creative.json │ │ │ │ │ ├── module_introspection.json │ │ │ │ │ ├── manipulator.mark_1.json │ │ │ │ │ ├── redstone_integrator.json │ │ │ │ │ ├── manipulator.mark_2.json │ │ │ │ │ └── module_laser.json │ │ │ │ └── block │ │ │ │ │ ├── redstone_integrator.json │ │ │ │ │ ├── manipulator.mark_1.json │ │ │ │ │ └── manipulator.mark_2.json │ │ │ │ ├── blockstates │ │ │ │ ├── redstone_integrator.json │ │ │ │ └── manipulator.json │ │ │ │ ├── recipes │ │ │ │ ├── module_sensor_upgrade.json │ │ │ │ ├── module_scanner_upgrade.json │ │ │ │ ├── keyboard.json │ │ │ │ ├── _factories.json │ │ │ │ ├── module_introspection.json │ │ │ │ ├── neural_connector.json │ │ │ │ ├── redstone_integrator.json │ │ │ │ ├── module_sensor.json │ │ │ │ ├── module_scanner.json │ │ │ │ ├── module_glasses.json │ │ │ │ ├── manipulator.mark_2.json │ │ │ │ ├── module_chat.json │ │ │ │ ├── module_kinetic.json │ │ │ │ ├── neural_interface.json │ │ │ │ ├── manipulator.mark_1.json │ │ │ │ ├── module_laser.json │ │ │ │ └── _constants.json │ │ │ │ ├── advancements │ │ │ │ └── recipes │ │ │ │ │ ├── keyboard.json │ │ │ │ │ ├── module_chat.json │ │ │ │ │ ├── module_laser.json │ │ │ │ │ ├── module_sensor.json │ │ │ │ │ ├── module_glasses.json │ │ │ │ │ ├── module_kinetic.json │ │ │ │ │ ├── module_scanner.json │ │ │ │ │ ├── redstone_integrator.json │ │ │ │ │ ├── neural_connector.json │ │ │ │ │ ├── neural_interface.json │ │ │ │ │ ├── manipulator.mark_1.json │ │ │ │ │ ├── module_introspection.json │ │ │ │ │ └── manipulator.mark_2.json │ │ │ │ └── footer.html │ │ ├── pack.mcmeta │ │ ├── META-INF │ │ │ └── Plethora_at.cfg │ │ └── mcmod.info │ └── java │ │ └── org │ │ └── squiddev │ │ └── plethora │ │ ├── utils │ │ ├── Vec2i.java │ │ ├── LoadedCache.java │ │ ├── EntityPlayerDummy.java │ │ ├── Vec2d.java │ │ ├── ByteBufUtils.java │ │ ├── TinySlot.java │ │ └── CapabilityWrapper.java │ │ ├── api │ │ ├── method │ │ │ ├── TypedLuaObject.java │ │ │ ├── ITransferMethod.java │ │ │ ├── IConverterExcludeMethod.java │ │ │ ├── wrapper │ │ │ │ ├── FromTarget.java │ │ │ │ ├── FromContext.java │ │ │ │ ├── Optional.java │ │ │ │ └── FromSubtarget.java │ │ │ ├── MarkerInterfaces.java │ │ │ ├── IMethodRegistry.java │ │ │ ├── BasicMethod.java │ │ │ ├── IMethodCollection.java │ │ │ ├── CostHelpers.java │ │ │ ├── IContextBuilder.java │ │ │ ├── IUnbakedContext.java │ │ │ └── IResultExecutor.java │ │ ├── reference │ │ │ ├── ConstantReference.java │ │ │ ├── DynamicReference.java │ │ │ ├── IdentityReference.java │ │ │ ├── IReference.java │ │ │ ├── TileReference.java │ │ │ └── EntityReference.java │ │ ├── CoreNotFoundException.java │ │ ├── meta │ │ │ ├── TypedMeta.java │ │ │ ├── IMetaRegistry.java │ │ │ ├── SimpleMetaProvider.java │ │ │ ├── BasicMetaProvider.java │ │ │ └── BaseMetaProvider.java │ │ ├── converter │ │ │ ├── DynamicConverter.java │ │ │ ├── ConstantConverter.java │ │ │ ├── IConverterRegistry.java │ │ │ ├── IConverter.java │ │ │ └── Converters.java │ │ ├── IPlayerOwnable.java │ │ ├── module │ │ │ ├── AbstractModuleHandler.java │ │ │ ├── IModuleContainer.java │ │ │ ├── ModuleContainerMethod.java │ │ │ ├── SingletonModuleContainer.java │ │ │ └── IModuleHandler.java │ │ ├── IAttachable.java │ │ ├── neural │ │ │ └── INeuralRegistry.java │ │ ├── vehicle │ │ │ ├── IVehicleAccess.java │ │ │ └── IVehicleUpgradeHandler.java │ │ ├── Injects.java │ │ ├── IPeripheralHandler.java │ │ ├── PlethoraGameplayAPI.java │ │ └── IWorldLocation.java │ │ ├── integration │ │ ├── PlethoraIntegration.java │ │ ├── buildcraft │ │ │ ├── TileHasWork.java │ │ │ └── TileHeatable.java │ │ ├── vanilla │ │ │ ├── FakePlayerProviderLocation.java │ │ │ ├── method │ │ │ │ └── MethodsEnergyHandler.java │ │ │ ├── meta │ │ │ │ ├── MetaFluidTank.java │ │ │ │ ├── MetaFluidTankProperties.java │ │ │ │ ├── MetaMaterial.java │ │ │ │ ├── MetaItemOreDict.java │ │ │ │ ├── MetaBlock.java │ │ │ │ ├── MetaItemMaterial.java │ │ │ │ └── MetaItemArmor.java │ │ │ ├── transfer │ │ │ │ ├── TransferEntityLivingBaseEquipment.java │ │ │ │ ├── TransferEntityPlayerInventory.java │ │ │ │ └── TransferItemHandlerSlot.java │ │ │ └── converter │ │ │ │ └── ConverterTileModule.java │ │ ├── ExtendedArgumentTypes.java │ │ ├── jei │ │ │ └── IntegrationJEI.java │ │ ├── forestry │ │ │ ├── MethodsErrorLogicSource.java │ │ │ ├── MetaButterfly.java │ │ │ ├── MetaBee.java │ │ │ └── MetaItemGenetic.java │ │ ├── rf │ │ │ ├── MetaEnergyContainerItem.java │ │ │ ├── MetaEnergyStorage.java │ │ │ └── MetaEnergyProvider.java │ │ ├── baubles │ │ │ ├── TransferBaublesInventory.java │ │ │ └── MethodIntrospectionBaublesInventory.java │ │ ├── xnet │ │ │ └── NetworkConnectorSettings.java │ │ ├── refinedstorage │ │ │ ├── ItemIdentity.java │ │ │ ├── IntegrationRefinedStorage.java │ │ │ ├── MetaCraftingTask.java │ │ │ ├── MetaCraftingRequestInfo.java │ │ │ └── MetaCraftingPreviewElement.java │ │ ├── ic2 │ │ │ ├── MetaEnergyStorage.java │ │ │ ├── MetaReactor.java │ │ │ └── MetaEnergyItem.java │ │ ├── computercraft │ │ │ ├── TransferComputerAccess.java │ │ │ ├── MetaTileComputer.java │ │ │ └── MethodsIntrospectionTurtle.java │ │ ├── mcmultipart │ │ │ └── ReferenceMultipart.java │ │ ├── cbmp │ │ │ ├── IntegrationMultipart.java │ │ │ └── ReferenceMultipart.java │ │ ├── appliedenergistics │ │ │ ├── MetaItemPattern.java │ │ │ └── ConverterAppliedEnergistics.java │ │ ├── MethodMeta.java │ │ ├── plethora │ │ │ └── MetaItemModule.java │ │ ├── storagedrawers │ │ │ └── MethodsIDrawer.java │ │ └── MetaWrapper.java │ │ ├── core │ │ ├── docdump │ │ │ ├── IDocWriter.java │ │ │ └── DocumentedMetaProvider.java │ │ ├── wrapper │ │ │ └── BadWrapperException.java │ │ ├── client │ │ │ └── gui │ │ │ │ ├── GuiConfigFactory.java │ │ │ │ ├── GuiConfigCore.java │ │ │ │ └── GuiConfigBase.java │ │ ├── capabilities │ │ │ ├── DefaultStorage.java │ │ │ ├── EmptyCostHandler.java │ │ │ ├── DefaultVehicleUpgradeHandler.java │ │ │ └── DefaultModuleHandler.java │ │ ├── MethodCollection.java │ │ ├── RegisteredValue.java │ │ ├── modules │ │ │ ├── VehicleModuleHandlerTransform.java │ │ │ ├── BasicModuleHandlerTransform.java │ │ │ └── ModuleHandlerTransform.java │ │ ├── API.java │ │ ├── executor │ │ │ ├── NeverExecutor.java │ │ │ └── TaskRunner.java │ │ ├── collections │ │ │ ├── SortedMultimap.java │ │ │ └── ClassIteratorIterable.java │ │ ├── MethodWrapperLuaObject.java │ │ ├── TargetedRegisteredValue.java │ │ └── ConverterReference.java │ │ └── gameplay │ │ ├── API.java │ │ ├── client │ │ ├── gui │ │ │ ├── GuiMinecartComputer.java │ │ │ └── GuiConfigGameplay.java │ │ └── LayerBaublesInterface.java │ │ ├── registry │ │ └── BasicMessage.java │ │ ├── keyboard │ │ └── ListenMessage.java │ │ ├── modules │ │ ├── glasses │ │ │ ├── objects │ │ │ │ ├── object3d │ │ │ │ │ ├── DepthTestable.java │ │ │ │ │ ├── Positionable3D.java │ │ │ │ │ └── Rotatable3D.java │ │ │ │ ├── Scalable.java │ │ │ │ ├── ObjectGroup.java │ │ │ │ ├── object2d │ │ │ │ │ ├── Positionable2D.java │ │ │ │ │ └── MultiPoint2D.java │ │ │ │ ├── ColourableObject.java │ │ │ │ └── ItemObject.java │ │ │ └── MessageCanvasRemove.java │ │ ├── ModulePeripheral.java │ │ └── RangeInfo.java │ │ ├── ItemBlockBase.java │ │ ├── minecart │ │ └── ContainerMinecartComputer.java │ │ ├── neural │ │ └── NeuralRegistry.java │ │ └── ItemBase.java └── test │ ├── resources │ ├── pack.mcmeta │ ├── mcmod.info │ └── assets │ │ └── plethora-test │ │ └── test-rom │ │ └── spec │ │ └── vanilla │ │ └── inventory_spec.lua │ └── java │ └── org │ └── squiddev │ └── plethora │ └── core │ └── RegistryTest.java ├── gradle.properties ├── .editorconfig ├── .github ├── ISSUE_TEMPLATE │ ├── question.md │ ├── feature_request.md │ ├── bug_report.md │ └── mod_integration.md └── workflows │ └── main-ci.yml ├── LICENSE └── .gitignore /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'plethora' 2 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SquidDev-CC/plethora/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/textures/misc/flare.png.mcmeta: -------------------------------------------------------------------------------- 1 | { 2 | "texture": { 3 | "blur": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/main/resources/pack.mcmeta: -------------------------------------------------------------------------------- 1 | { 2 | "pack":{ 3 | "pack_format":1, 4 | "description":"Plethora" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/test/resources/pack.mcmeta: -------------------------------------------------------------------------------- 1 | { 2 | "pack":{ 3 | "pack_format":1, 4 | "description":"Plethora" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/textures/gui/xnet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SquidDev-CC/plethora/HEAD/src/main/resources/assets/plethora/textures/gui/xnet.png -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/models/item/keyboard.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "item/generated", 3 | "textures": { 4 | "layer0": "plethora:items/keyboard" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/textures/misc/flare.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SquidDev-CC/plethora/HEAD/src/main/resources/assets/plethora/textures/misc/flare.png -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/models/item/module.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "item/generated", 3 | "textures": { 4 | "layer0": "plethora:items/module_unknown" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/blockstates/redstone_integrator.json: -------------------------------------------------------------------------------- 1 | { 2 | "variants": { 3 | "normal": { 4 | "model": "plethora:redstone_integrator" 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/models/item/module_chat.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "item/generated", 3 | "textures": { 4 | "layer0": "plethora:items/module_chat" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/models/item/module_sensor.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "item/generated", 3 | "textures": { 4 | "layer0": "plethora:items/module_sensor" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/textures/items/keyboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SquidDev-CC/plethora/HEAD/src/main/resources/assets/plethora/textures/items/keyboard.png -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/models/item/module_glasses.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "item/generated", 3 | "textures": { 4 | "layer0": "plethora:items/module_glasses" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/models/item/module_kinetic.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "item/generated", 3 | "textures": { 4 | "layer0": "plethora:items/module_kinetic" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/models/item/module_scanner.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "item/generated", 3 | "textures": { 4 | "layer0": "plethora:items/module_scanner" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/textures/blocks/manipulator.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SquidDev-CC/plethora/HEAD/src/main/resources/assets/plethora/textures/blocks/manipulator.png -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/textures/items/module_chat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SquidDev-CC/plethora/HEAD/src/main/resources/assets/plethora/textures/items/module_chat.png -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/textures/items/module_laser.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SquidDev-CC/plethora/HEAD/src/main/resources/assets/plethora/textures/items/module_laser.png -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/models/item/neural_connector.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "item/generated", 3 | "textures": { 4 | "layer0": "plethora:items/neural_connector" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/models/item/neural_interface.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "item/generated", 3 | "textures": { 4 | "layer0": "plethora:items/neural_interface" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/textures/gui/neural_interface.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SquidDev-CC/plethora/HEAD/src/main/resources/assets/plethora/textures/gui/neural_interface.png -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/textures/items/module_glasses.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SquidDev-CC/plethora/HEAD/src/main/resources/assets/plethora/textures/items/module_glasses.png -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/textures/items/module_kinetic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SquidDev-CC/plethora/HEAD/src/main/resources/assets/plethora/textures/items/module_kinetic.png -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/textures/items/module_scanner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SquidDev-CC/plethora/HEAD/src/main/resources/assets/plethora/textures/items/module_scanner.png -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/textures/items/module_sensor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SquidDev-CC/plethora/HEAD/src/main/resources/assets/plethora/textures/items/module_sensor.png -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/textures/items/module_unknown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SquidDev-CC/plethora/HEAD/src/main/resources/assets/plethora/textures/items/module_unknown.png -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/models/block/redstone_integrator.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "block/cube_all", 3 | "textures": { 4 | "all": "plethora:blocks/redstone_integrator" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/models/item/module_chat_creative.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "item/generated", 3 | "textures": { 4 | "layer0": "plethora:items/module_chat_creative" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/models/item/module_introspection.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "item/generated", 3 | "textures": { 4 | "layer0": "plethora:items/module_introspection" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/textures/blocks/manipulator_side.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SquidDev-CC/plethora/HEAD/src/main/resources/assets/plethora/textures/blocks/manipulator_side.png -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/textures/blocks/manipulator_top1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SquidDev-CC/plethora/HEAD/src/main/resources/assets/plethora/textures/blocks/manipulator_top1.png -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/textures/blocks/manipulator_top2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SquidDev-CC/plethora/HEAD/src/main/resources/assets/plethora/textures/blocks/manipulator_top2.png -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/textures/items/neural_connector.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SquidDev-CC/plethora/HEAD/src/main/resources/assets/plethora/textures/items/neural_connector.png -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/textures/items/neural_interface.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SquidDev-CC/plethora/HEAD/src/main/resources/assets/plethora/textures/items/neural_interface.png -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/textures/models/neural_interface.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SquidDev-CC/plethora/HEAD/src/main/resources/assets/plethora/textures/models/neural_interface.png -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/textures/blocks/manipulator_bottom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SquidDev-CC/plethora/HEAD/src/main/resources/assets/plethora/textures/blocks/manipulator_bottom.png -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/textures/blocks/redstone_integrator.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SquidDev-CC/plethora/HEAD/src/main/resources/assets/plethora/textures/blocks/redstone_integrator.png -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/textures/items/module_chat_creative.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SquidDev-CC/plethora/HEAD/src/main/resources/assets/plethora/textures/items/module_chat_creative.png -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/textures/items/module_introspection.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SquidDev-CC/plethora/HEAD/src/main/resources/assets/plethora/textures/items/module_introspection.png -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Mod properties 2 | mod_version=1.2.3 3 | cct_version=1.86.2 4 | 5 | # Minecraft properties (update mods.toml when changing) 6 | mc_version=1.12.2 7 | forge_version=14.23.5.2768 8 | mappings_version=20200429-1.15.1 -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-bin.zip 6 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/utils/Vec2i.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.utils; 2 | 3 | public class Vec2i { 4 | public final int x; 5 | public final int y; 6 | 7 | public Vec2i(int x, int y) { 8 | this.x = x; 9 | this.y = y; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/test/resources/mcmod.info: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "modid": "plethora-test", 4 | "description": "Test runner for Plethora", 5 | "credits": "Dan200, Forge team", 6 | "authorList": [ "SquidDev" ], 7 | "dependencies": [ "plethora", "plethora-core" ] 8 | } 9 | ] 10 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/recipes/module_sensor_upgrade.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "plethora:module_level", 3 | "ingredients": [ 4 | { "item": "plethora:module", "data": 3 }, 5 | { "item": "minecraft:nether_star" } 6 | ], 7 | "result": { "item": "plethora:module", "data": 3, "nbt": { "level": 1 } } 8 | } 9 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = tab 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | 14 | [*.properties] 15 | insert_final_newline = false 16 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/models/item/manipulator.mark_1.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "plethora:block/manipulator.mark_1", 3 | "display": { 4 | "thirdperson": { 5 | "rotation": [ 10, -45, 170 ], 6 | "translation": [ 0, 1.5, -2.75 ], 7 | "scale": [ 0.375, 0.375, 0.375 ] 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/models/item/redstone_integrator.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "plethora:block/redstone_integrator", 3 | "display": { 4 | "thirdperson": { 5 | "rotation": [ 10, -45, 170 ], 6 | "translation": [ 0, 1.5, -2.75 ], 7 | "scale": [ 0.375, 0.375, 0.375 ] 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/recipes/module_scanner_upgrade.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "plethora:module_level", 3 | "ingredients": [ 4 | { "item": "plethora:module", "data": 2 }, 5 | { "item": "minecraft:nether_star" } 6 | ], 7 | "result": { "item": "plethora:module", "data": 2, "nbt": { "level": 1 } } 8 | } 9 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/question.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Question 3 | labels: question 4 | 5 | --- 6 | 7 | 11 | 12 | ## Useful information to include: 13 | - Minecraft, CC: Tweaked, and Plethora version (if related to using Plethora in-game) 14 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/models/item/manipulator.mark_2.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "plethora:block/manipulator.mark_2", 3 | "display": { 4 | "thirdperson": { 5 | "rotation": [ 6 | 10, 7 | -45, 8 | 170 9 | ], 10 | "translation": [ 11 | 0, 12 | 1.5, 13 | -2.75 14 | ], 15 | "scale": [ 16 | 0.375, 17 | 0.375, 18 | 0.375 19 | ] 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /.github/workflows/main-ci.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build: 7 | runs-on: ubuntu-latest 8 | 9 | steps: 10 | - uses: actions/checkout@v1 11 | 12 | - name: Set up JDK 1.8 13 | uses: actions/setup-java@v1 14 | with: 15 | java-version: 1.8 16 | 17 | - name: Build with Gradle 18 | run: ./gradlew build --no-daemon 19 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/api/method/TypedLuaObject.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.api.method; 2 | 3 | import dan200.computercraft.api.lua.ILuaObject; 4 | 5 | /** 6 | * A {@link ILuaObject} which targets a specific type. 7 | * 8 | * @param The type this object targets 9 | * @see IContext#getObject() 10 | */ 11 | public interface TypedLuaObject extends ILuaObject { 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/integration/PlethoraIntegration.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.integration; 2 | 3 | import org.apache.logging.log4j.LogManager; 4 | import org.apache.logging.log4j.Logger; 5 | 6 | public final class PlethoraIntegration { 7 | public static final Logger LOG = LogManager.getLogger("plethora-integration"); 8 | 9 | private PlethoraIntegration() { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/api/reference/ConstantReference.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.api.reference; 2 | 3 | /** 4 | * A reference which always returns the same value (or a value which is equivalent). 5 | * 6 | * @see IReference#isConstant() 7 | */ 8 | public interface ConstantReference extends IReference { 9 | @Override 10 | default boolean isConstant() { 11 | return true; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/api/reference/DynamicReference.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.api.reference; 2 | 3 | /** 4 | * A reference which always returns the same value (or a value which is equivalent). 5 | * 6 | * @see IReference#isConstant() 7 | */ 8 | public interface DynamicReference extends IReference { 9 | @Override 10 | default boolean isConstant() { 11 | return false; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/api/CoreNotFoundException.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.api; 2 | 3 | /** 4 | * Thrown when the Plethora API cannot be loaded 5 | */ 6 | public class CoreNotFoundException extends RuntimeException { 7 | private static final long serialVersionUID = -2084056436955095940L; 8 | 9 | CoreNotFoundException(String message, Throwable cause) { 10 | super(message, cause); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/api/meta/TypedMeta.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.api.meta; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | * A typed collection of metadata about an object. 7 | * 8 | * @param The type about which we are capturing metadata. 9 | * @param The value type for this metadata, conventionally {@code ?}. 10 | */ 11 | public interface TypedMeta extends Map { 12 | } 13 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/recipes/keyboard.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "minecraft:crafting_shaped", 3 | "pattern": [ 4 | " M", 5 | "SSI", 6 | "SSS" 7 | ], 8 | "key": { 9 | "S": { "type": "forge:ore_dict", "ore": "stone" }, 10 | "I": { "type": "forge:ore_dict", "ore": "ingotIron" }, 11 | "M": { "item": "computercraft:peripheral", "data": 1 } 12 | }, 13 | "result": { 14 | "item": "plethora:keyboard" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/api/converter/DynamicConverter.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.api.converter; 2 | 3 | /** 4 | * A converter which may return a different value for the same input. 5 | * 6 | * @see IConverter#isConstant() 7 | */ 8 | @FunctionalInterface 9 | public interface DynamicConverter extends IConverter { 10 | @Override 11 | default boolean isConstant() { 12 | return false; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/api/method/ITransferMethod.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.api.method; 2 | 3 | /** 4 | * Marker interface stating this method requires transfer sources. 5 | * 6 | * You must put this on any method which consumes transfer sources: 7 | * otherwise things may not work as expected. 8 | * 9 | * Use {@link MarkerInterfaces} if attaching to a method. 10 | */ 11 | public interface ITransferMethod { 12 | } 13 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/recipes/_factories.json: -------------------------------------------------------------------------------- 1 | { 2 | "recipes": { 3 | "neural_interface": "org.squiddev.plethora.gameplay.neural.CraftingNeuralInterface$Factory", 4 | "module_level": "org.squiddev.plethora.gameplay.modules.ModuleLevelRecipe$Factory" 5 | }, 6 | "ingredients": { 7 | "enchanted": "org.squiddev.plethora.utils.IngredientEnchanted$Factory", 8 | "brew": "org.squiddev.plethora.utils.IngredientBrew$Factory" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/recipes/module_introspection.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "minecraft:crafting_shaped", 3 | "pattern": [ 4 | "GCG", 5 | "CHC", 6 | "GCG" 7 | ], 8 | "key": { 9 | "C": { "type": "forge:ore_dict", "ore": "chestEnder" }, 10 | "G": { "type": "forge:ore_dict", "ore": "ingotGold" }, 11 | "H": { "item": "minecraft:diamond_helmet" } 12 | }, 13 | "result": { 14 | "item": "plethora:module", 15 | "data": 0 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/recipes/neural_connector.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "minecraft:crafting_shaped", 3 | "pattern": [ 4 | " R", 5 | "IIR", 6 | "IEI" 7 | ], 8 | "key": { 9 | "R": { "type": "forge:ore_dict", "ore": "dustRedstone" }, 10 | "E": { "type": "forge:ore_dict", "ore": "enderpearl" }, 11 | "I": { "type": "forge:ore_dict", "ore": "ingotIron" } 12 | }, 13 | "result": { 14 | "item": "plethora:neuralconnector" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/api/converter/ConstantConverter.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.api.converter; 2 | 3 | /** 4 | * A converter which always returns the same value (or a value which is equivalent). 5 | * 6 | * @see IConverter#isConstant() 7 | */ 8 | @FunctionalInterface 9 | public interface ConstantConverter extends IConverter { 10 | @Override 11 | default boolean isConstant() { 12 | return true; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/core/docdump/IDocWriter.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.core.docdump; 2 | 3 | import java.io.Closeable; 4 | import java.io.IOException; 5 | 6 | /** 7 | * An output format for documentation 8 | */ 9 | public interface IDocWriter extends Closeable { 10 | default void writeHeader() throws IOException { 11 | } 12 | 13 | default void writeFooter() throws IOException { 14 | } 15 | 16 | void write() throws IOException; 17 | } 18 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/recipes/redstone_integrator.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "minecraft:crafting_shaped", 3 | "pattern": [ 4 | "SRS", 5 | "RCR", 6 | "SRS" 7 | ], 8 | "key": { 9 | "S": { "type": "forge:ore_dict", "ore": "stone" }, 10 | "C": { "item": "computercraft:cable", "data": 0 }, 11 | "R": { "type": "forge:ore_dict", "ore": "dustRedstone" } 12 | }, 13 | "result": { 14 | "item": "plethora:redstone_integrator", 15 | "data": 0 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/recipes/module_sensor.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "minecraft:crafting_shaped", 3 | "pattern": [ 4 | "ERE", 5 | "IOI", 6 | "III" 7 | ], 8 | "key": { 9 | "R": { "item": "minecraft:rotten_flesh" }, 10 | "E": { "item": "minecraft:ender_eye" }, 11 | "O": { "item": "minecraft:observer" }, 12 | "I": { "type": "forge:ore_dict", "ore": "ingotIron" } 13 | }, 14 | "result": { 15 | "item": "plethora:module", 16 | "data": 3 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/api/method/IConverterExcludeMethod.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.api.method; 2 | 3 | /** 4 | * Marker interface stating this method should not consume converted objects. 5 | * 6 | * This will only target the original class, and not converted objects. This is useful if you will 7 | * do conversion yourself. 8 | * 9 | * Use {@link MarkerInterfaces} if attaching to a method. 10 | */ 11 | public interface IConverterExcludeMethod { 12 | } 13 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/recipes/module_scanner.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "minecraft:crafting_shaped", 3 | "pattern": [ 4 | "EDE", 5 | "IOI", 6 | "III" 7 | ], 8 | "key": { 9 | "D": { "type": "forge:ore_dict", "ore": "dirt" }, 10 | "E": { "item": "minecraft:ender_eye" }, 11 | "O": { "item": "minecraft:observer" }, 12 | "I": { "type": "forge:ore_dict", "ore": "ingotIron" } 13 | }, 14 | "result": { 15 | "item": "plethora:module", 16 | "data": 2 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/core/wrapper/BadWrapperException.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.core.wrapper; 2 | 3 | final class BadWrapperException extends RuntimeException { 4 | public static final BadWrapperException INSTANCE = new BadWrapperException("Error generating method wrapper"); 5 | 6 | private static final long serialVersionUID = -1429222867771289808L; 7 | 8 | private BadWrapperException(String message) { 9 | super(message, null, true, false); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/gameplay/API.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.gameplay; 2 | 3 | import org.squiddev.plethora.api.PlethoraGameplayAPI; 4 | import org.squiddev.plethora.api.neural.INeuralRegistry; 5 | import org.squiddev.plethora.gameplay.neural.NeuralRegistry; 6 | 7 | public final class API implements PlethoraGameplayAPI.IPlethoraGameplayAPI { 8 | @Override 9 | public INeuralRegistry neuralRegistry() { 10 | return NeuralRegistry.instance; 11 | } 12 | } 13 | 14 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/api/converter/IConverterRegistry.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.api.converter; 2 | 3 | import javax.annotation.Nonnull; 4 | 5 | /** 6 | * A registry for implicitly converting objects 7 | */ 8 | public interface IConverterRegistry { 9 | /** 10 | * Convert an object to all convertible objects 11 | * 12 | * @param in The object to convert from 13 | * @return All converted values 14 | */ 15 | @Nonnull 16 | Iterable convertAll(@Nonnull Object in); 17 | } 18 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/recipes/module_glasses.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "minecraft:crafting_shaped", 3 | "pattern": [ 4 | "MIM", 5 | "GGG", 6 | "IAI" 7 | ], 8 | "key": { 9 | "M": { "item": "computercraft:peripheral", "data": 1 }, 10 | "I": { "type": "forge:ore_dict", "ore": "ingotIron" }, 11 | "G": { "item": "computercraft:peripheral", "data": 4 }, 12 | "A": { "item": "minecraft:iron_helmet" } 13 | }, 14 | "result": { 15 | "item": "plethora:module", 16 | "data": 6 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea or improvement 4 | labels: enhancement 5 | 6 | --- 7 | 8 | 12 | 13 | ## Useful information to include: 14 | - Explanation of how the feature/change should work. 15 | - Some rationale/use case for a feature. Everything takes time to implement, so I like to have a solid justification for each feature. 16 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/recipes/manipulator.mark_2.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "minecraft:crafting_shaped", 3 | "pattern": [ 4 | "CCC", 5 | "RMR", 6 | "III" 7 | ], 8 | "key": { 9 | "R": { "type": "forge:ore_dict", "ore": "dustRedstone" }, 10 | "C": { "type": "forge:ore_dict", "ore": "ingotGold" }, 11 | "I": { "type": "forge:ore_dict", "ore": "ingotIron" }, 12 | "M": { "item": "plethora:manipulator", "data": 0 } 13 | }, 14 | "result": { 15 | "item": "plethora:manipulator", 16 | "data": 1 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/recipes/module_chat.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "minecraft:crafting_shaped", 3 | "pattern": [ 4 | " RS", 5 | "WRN", 6 | "IIS" 7 | ], 8 | "key": { 9 | "R": { "type": "forge:ore_dict", "ore": "dustRedstone" }, 10 | "S": { "type": "forge:ore_dict", "ore": "stone" }, 11 | "W": { "item": "#WOOL" }, 12 | "I": { "type": "forge:ore_dict", "ore": "ingotIron" }, 13 | "N": { "item": "minecraft:noteblock" } 14 | }, 15 | "result": { 16 | "item": "plethora:module", 17 | "data": 5 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/recipes/module_kinetic.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "minecraft:crafting_shaped", 3 | "pattern": [ 4 | "RGR", 5 | "PBP", 6 | "RGR" 7 | ], 8 | "key": { 9 | "P": { "item": "minecraft:piston" }, 10 | "R": { "type": "forge:ore_dict", "ore": "dustRedstone" }, 11 | "B": { "type": "plethora:brew", "potion": "minecraft:leaping", "effect": "minecraft:jump_boost" }, 12 | "G": { "type": "forge:ore_dict", "ore": "ingotGold" } 13 | }, 14 | "result": { 15 | "item": "plethora:module", 16 | "data": 4 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/api/IPlayerOwnable.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.api; 2 | 3 | import com.mojang.authlib.GameProfile; 4 | 5 | import javax.annotation.Nullable; 6 | 7 | /** 8 | * An object (such as a tile entity, entity, turtle, etc...) which can be 9 | * owned by a player. This is used for constructing fake players. 10 | */ 11 | public interface IPlayerOwnable { 12 | /** 13 | * Get the profile for this player 14 | * 15 | * @return The profile for this player 16 | */ 17 | @Nullable 18 | GameProfile getOwningProfile(); 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/api/meta/IMetaRegistry.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.api.meta; 2 | 3 | import javax.annotation.Nonnull; 4 | import java.util.List; 5 | 6 | /** 7 | * A registry for metadata providers. 8 | * 9 | * @see IMetaProvider 10 | */ 11 | public interface IMetaRegistry { 12 | /** 13 | * An list of all valid providers for a class 14 | * 15 | * @param target The class to get data about 16 | * @return List of valid providers 17 | */ 18 | @Nonnull 19 | List> getMetaProviders(@Nonnull Class target); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/api/method/wrapper/FromTarget.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.api.method.wrapper; 2 | 3 | import org.squiddev.plethora.api.method.ContextKeys; 4 | 5 | import java.lang.annotation.*; 6 | 7 | /** 8 | * Extract this value from the context's target, rather than taking it as an argument. 9 | * 10 | * This is just equivalent to {@link FromContext} with a context key of {@link ContextKeys#TARGET}. 11 | */ 12 | @Documented 13 | @Retention(RetentionPolicy.RUNTIME) 14 | @Target(ElementType.PARAMETER) 15 | public @interface FromTarget { 16 | } 17 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/recipes/neural_interface.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "plethora:neural_interface", 3 | "pattern": [ 4 | " G", 5 | "IPR", 6 | " GM" 7 | ], 8 | "key": { 9 | "P": { "item": "computercraft:pocket_computer", "data": 1 }, 10 | "R": { "type": "forge:ore_dict", "ore": "dustRedstone" }, 11 | "G": { "type": "forge:ore_dict", "ore": "ingotGold" }, 12 | "I": { "type": "forge:ore_dict", "ore": "ingotIron" }, 13 | "M": { "item": "computercraft:cable", "data": 1 } 14 | }, 15 | "result": { 16 | "item": "plethora:neuralinterface" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/recipes/manipulator.mark_1.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "minecraft:crafting_shaped", 3 | "pattern": [ 4 | "GCG", 5 | "RMR", 6 | "III" 7 | ], 8 | "key": { 9 | "R": { "type": "forge:ore_dict", "ore": "dustRedstone" }, 10 | "C": { "type": "forge:ore_dict", "ore": "ingotGold" }, 11 | "G": { "type": "forge:ore_dict", "ore": "blockGlass" }, 12 | "I": { "type": "forge:ore_dict", "ore": "ingotIron" }, 13 | "M": { "item": "computercraft:cable", "data": 1 } 14 | }, 15 | "result": { 16 | "item": "plethora:manipulator", 17 | "data": 0 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/api/method/MarkerInterfaces.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.api.method; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * A list of marker interfaces which should be added to the method. 10 | * 11 | * This should be used on methods injected through builders. 12 | */ 13 | @Retention(RetentionPolicy.RUNTIME) 14 | @Target(ElementType.METHOD) 15 | public @interface MarkerInterfaces { 16 | Class[] value(); 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/api/reference/IdentityReference.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.api.reference; 2 | 3 | import javax.annotation.Nonnull; 4 | 5 | /** 6 | * A reference that returns its value 7 | */ 8 | public final class IdentityReference implements ConstantReference { 9 | private final T object; 10 | 11 | IdentityReference(@Nonnull T object) { 12 | this.object = object; 13 | } 14 | 15 | @Nonnull 16 | @Override 17 | public T get() { 18 | return object; 19 | } 20 | 21 | @Nonnull 22 | @Override 23 | public T safeGet() { 24 | return object; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/core/client/gui/GuiConfigFactory.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.core.client.gui; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraftforge.fml.client.IModGuiFactory; 5 | 6 | import java.util.Set; 7 | 8 | public abstract class GuiConfigFactory implements IModGuiFactory { 9 | @Override 10 | public void initialize(Minecraft minecraft) { 11 | } 12 | 13 | @Override 14 | public Set runtimeGuiCategories() { 15 | return null; 16 | } 17 | 18 | @Override 19 | public boolean hasConfigGui() { 20 | return true; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/recipes/module_laser.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "minecraft:crafting_shaped", 3 | "pattern": [ 4 | "III", 5 | "GDF", 6 | " I" 7 | ], 8 | "key": { 9 | "F": [ 10 | { "type": "plethora:enchanted", "id": "minecraft:flame" }, 11 | { "type": "plethora:enchanted", "id": "minecraft:fire_aspect" } 12 | ], 13 | "D": { "type": "forge:ore_dict", "ore": "gemDiamond" }, 14 | "G": { "type": "forge:ore_dict", "ore": "blockGlass" }, 15 | "I": { "type": "forge:ore_dict", "ore": "ingotIron" } 16 | }, 17 | "result": { 18 | "item": "plethora:module", 19 | "data": 1 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/integration/buildcraft/TileHasWork.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.integration.buildcraft; 2 | 3 | import buildcraft.api.tiles.IHasWork; 4 | import buildcraft.core.BCCore; 5 | import org.squiddev.plethora.api.Injects; 6 | import org.squiddev.plethora.api.method.wrapper.FromTarget; 7 | import org.squiddev.plethora.api.method.wrapper.PlethoraMethod; 8 | 9 | public final class TileHasWork { 10 | 11 | @PlethoraMethod(modId = BCCore.MODID, doc = "-- Reports true if the Block has work to do.") 12 | public static boolean hasWork(@FromTarget IHasWork hasWork) { 13 | return hasWork.hasWork(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/Plethora_at.cfg: -------------------------------------------------------------------------------- 1 | # Methods 2 | public net.minecraft.entity.monster.EntityCreeper func_146077_cc()V # explode 3 | public net.minecraft.entity.monster.EntityEnderman func_70825_j(DDD)Z # teleportTo 4 | 5 | # Fake player 6 | # public net.minecraft.entity.player.EntityPlayer field_71074_e # itemInUse 7 | public net.minecraft.server.management.PlayerInteractionManager field_73094_o # durabilityRemainingOnBlock 8 | 9 | # Player flying 10 | public net.minecraft.network.NetHandlerPlayServer field_147365_f # floatingTickCount 11 | 12 | # Tile entity lookup 13 | public net.minecraft.tileentity.TileEntity field_190562_f # REGISTRY 14 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/integration/vanilla/FakePlayerProviderLocation.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.integration.vanilla; 2 | 3 | import net.minecraft.util.math.Vec3d; 4 | import org.squiddev.plethora.api.IWorldLocation; 5 | import org.squiddev.plethora.gameplay.PlethoraFakePlayer; 6 | 7 | public final class FakePlayerProviderLocation { 8 | private FakePlayerProviderLocation() { 9 | } 10 | 11 | public static void load(PlethoraFakePlayer player, IWorldLocation location) { 12 | Vec3d vec = location.getLoc(); 13 | player.setWorld(location.getWorld()); 14 | player.setPositionAndRotation(vec.x, vec.y, vec.z, 0, 0); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/api/method/wrapper/FromContext.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.api.method.wrapper; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * Extract this value from the context, rather than taking it as an argument. 7 | * 8 | * One can use {@link javax.annotation.Nullable} in order to mark this as optional. 9 | */ 10 | @Documented 11 | @Retention(RetentionPolicy.RUNTIME) 12 | @Target(ElementType.PARAMETER) 13 | public @interface FromContext { 14 | /** 15 | * The context key to extract from. Leave blank to take from any of them 16 | * 17 | * @return The context key to use. 18 | */ 19 | String[] value() default {}; 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/gameplay/client/gui/GuiMinecartComputer.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.gameplay.client.gui; 2 | 3 | import dan200.computercraft.client.gui.GuiComputer; 4 | import dan200.computercraft.shared.computer.core.ClientComputer; 5 | import org.squiddev.plethora.gameplay.minecart.ContainerMinecartComputer; 6 | import org.squiddev.plethora.gameplay.minecart.EntityMinecartComputer; 7 | 8 | public class GuiMinecartComputer extends GuiComputer { 9 | public GuiMinecartComputer(EntityMinecartComputer minecart, ClientComputer computer) { 10 | super(new ContainerMinecartComputer(minecart), minecart.getFamily(), computer, 51, 19); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/gameplay/registry/BasicMessage.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.gameplay.registry; 2 | 3 | import net.minecraftforge.fml.common.network.simpleimpl.IMessage; 4 | import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; 5 | 6 | /** 7 | * Extension to {@link IMessage} which can be handled by {@link #defaultHandler(BasicMessage, MessageContext)}. 8 | */ 9 | public interface BasicMessage extends IMessage { 10 | void onMessage(MessageContext context); 11 | 12 | static IMessage defaultHandler(T message, MessageContext context) { 13 | message.onMessage(context); 14 | return null; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/advancements/recipes/keyboard.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "minecraft:recipes/root", 3 | "rewards": { 4 | "recipes": [ 5 | "plethora:keyboard" 6 | ] 7 | }, 8 | "criteria": { 9 | "has_computer": { 10 | "trigger": "minecraft:inventory_changed", 11 | "conditions": { 12 | "items": [ 13 | { 14 | "item": "computercraft:computer" 15 | } 16 | ] 17 | } 18 | }, 19 | "has_the_recipe": { 20 | "trigger": "minecraft:recipe_unlocked", 21 | "conditions": { 22 | "recipe": "plethora:keyboard" 23 | } 24 | } 25 | }, 26 | "requirements": [ 27 | [ 28 | "has_computer", 29 | "has_the_recipe" 30 | ] 31 | ] 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/core/capabilities/DefaultStorage.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.core.capabilities; 2 | 3 | import net.minecraft.nbt.NBTBase; 4 | import net.minecraft.util.EnumFacing; 5 | import net.minecraftforge.common.capabilities.Capability; 6 | 7 | /** 8 | * Default capability storage. Doesn't read or write anything to NBT 9 | */ 10 | public final class DefaultStorage implements Capability.IStorage { 11 | @Override 12 | public NBTBase writeNBT(Capability capability, T t, EnumFacing enumFacing) { 13 | return null; 14 | } 15 | 16 | @Override 17 | public void readNBT(Capability capability, T t, EnumFacing enumFacing, NBTBase nbtBase) { 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/advancements/recipes/module_chat.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "minecraft:recipes/root", 3 | "rewards": { 4 | "recipes": [ 5 | "plethora:module_chat" 6 | ] 7 | }, 8 | "criteria": { 9 | "has_manipulator": { 10 | "trigger": "minecraft:inventory_changed", 11 | "conditions": { 12 | "items": [ 13 | { 14 | "item": "plethora:manipulator" 15 | } 16 | ] 17 | } 18 | }, 19 | "has_the_recipe": { 20 | "trigger": "minecraft:recipe_unlocked", 21 | "conditions": { 22 | "recipe": "plethora:module_chat" 23 | } 24 | } 25 | }, 26 | "requirements": [ 27 | [ 28 | "has_manipulator", 29 | "has_the_recipe" 30 | ] 31 | ] 32 | } 33 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/advancements/recipes/module_laser.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "minecraft:recipes/root", 3 | "rewards": { 4 | "recipes": [ 5 | "plethora:module_laser" 6 | ] 7 | }, 8 | "criteria": { 9 | "has_manipulator": { 10 | "trigger": "minecraft:inventory_changed", 11 | "conditions": { 12 | "items": [ 13 | { 14 | "item": "plethora:manipulator" 15 | } 16 | ] 17 | } 18 | }, 19 | "has_the_recipe": { 20 | "trigger": "minecraft:recipe_unlocked", 21 | "conditions": { 22 | "recipe": "plethora:module_laser" 23 | } 24 | } 25 | }, 26 | "requirements": [ 27 | [ 28 | "has_manipulator", 29 | "has_the_recipe" 30 | ] 31 | ] 32 | } 33 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/advancements/recipes/module_sensor.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "minecraft:recipes/root", 3 | "rewards": { 4 | "recipes": [ 5 | "plethora:module_sensor" 6 | ] 7 | }, 8 | "criteria": { 9 | "has_manipulator": { 10 | "trigger": "minecraft:inventory_changed", 11 | "conditions": { 12 | "items": [ 13 | { 14 | "item": "plethora:manipulator" 15 | } 16 | ] 17 | } 18 | }, 19 | "has_the_recipe": { 20 | "trigger": "minecraft:recipe_unlocked", 21 | "conditions": { 22 | "recipe": "plethora:module_sensor" 23 | } 24 | } 25 | }, 26 | "requirements": [ 27 | [ 28 | "has_manipulator", 29 | "has_the_recipe" 30 | ] 31 | ] 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/core/MethodCollection.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.core; 2 | 3 | import com.google.common.collect.Lists; 4 | import org.squiddev.plethora.api.method.IMethod; 5 | import org.squiddev.plethora.api.method.IMethodCollection; 6 | 7 | import javax.annotation.Nonnull; 8 | import java.util.List; 9 | 10 | public class MethodCollection implements IMethodCollection { 11 | private final List> methods; 12 | 13 | public MethodCollection(List> methods) { 14 | this.methods = Lists.transform(methods, RegisteredMethod::method); 15 | } 16 | 17 | @Nonnull 18 | @Override 19 | public List> methods() { 20 | return methods; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/advancements/recipes/module_glasses.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "minecraft:recipes/root", 3 | "rewards": { 4 | "recipes": [ 5 | "plethora:module_glasses" 6 | ] 7 | }, 8 | "criteria": { 9 | "has_manipulator": { 10 | "trigger": "minecraft:inventory_changed", 11 | "conditions": { 12 | "items": [ 13 | { 14 | "item": "plethora:manipulator" 15 | } 16 | ] 17 | } 18 | }, 19 | "has_the_recipe": { 20 | "trigger": "minecraft:recipe_unlocked", 21 | "conditions": { 22 | "recipe": "plethora:module_glasses" 23 | } 24 | } 25 | }, 26 | "requirements": [ 27 | [ 28 | "has_manipulator", 29 | "has_the_recipe" 30 | ] 31 | ] 32 | } 33 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/advancements/recipes/module_kinetic.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "minecraft:recipes/root", 3 | "rewards": { 4 | "recipes": [ 5 | "plethora:module_kinetic" 6 | ] 7 | }, 8 | "criteria": { 9 | "has_manipulator": { 10 | "trigger": "minecraft:inventory_changed", 11 | "conditions": { 12 | "items": [ 13 | { 14 | "item": "plethora:manipulator" 15 | } 16 | ] 17 | } 18 | }, 19 | "has_the_recipe": { 20 | "trigger": "minecraft:recipe_unlocked", 21 | "conditions": { 22 | "recipe": "plethora:module_kinetic" 23 | } 24 | } 25 | }, 26 | "requirements": [ 27 | [ 28 | "has_manipulator", 29 | "has_the_recipe" 30 | ] 31 | ] 32 | } 33 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/advancements/recipes/module_scanner.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "minecraft:recipes/root", 3 | "rewards": { 4 | "recipes": [ 5 | "plethora:module_scanner" 6 | ] 7 | }, 8 | "criteria": { 9 | "has_manipulator": { 10 | "trigger": "minecraft:inventory_changed", 11 | "conditions": { 12 | "items": [ 13 | { 14 | "item": "plethora:manipulator" 15 | } 16 | ] 17 | } 18 | }, 19 | "has_the_recipe": { 20 | "trigger": "minecraft:recipe_unlocked", 21 | "conditions": { 22 | "recipe": "plethora:module_scanner" 23 | } 24 | } 25 | }, 26 | "requirements": [ 27 | [ 28 | "has_manipulator", 29 | "has_the_recipe" 30 | ] 31 | ] 32 | } 33 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/advancements/recipes/redstone_integrator.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "minecraft:recipes/root", 3 | "rewards": { 4 | "recipes": [ 5 | "plethora:redstone_integrator" 6 | ] 7 | }, 8 | "criteria": { 9 | "has_cable": { 10 | "trigger": "minecraft:inventory_changed", 11 | "conditions": { 12 | "items": [ 13 | { 14 | "item": "computercraft:cable" 15 | } 16 | ] 17 | } 18 | }, 19 | "has_the_recipe": { 20 | "trigger": "minecraft:recipe_unlocked", 21 | "conditions": { 22 | "recipe": "plethora:redstone_integrator" 23 | } 24 | } 25 | }, 26 | "requirements": [ 27 | [ 28 | "has_cable", 29 | "has_the_recipe" 30 | ] 31 | ] 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/core/client/gui/GuiConfigCore.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.core.client.gui; 2 | 3 | import net.minecraft.client.gui.GuiScreen; 4 | import org.squiddev.plethora.core.ConfigCore; 5 | import org.squiddev.plethora.core.PlethoraCore; 6 | import org.squiddev.plethora.gameplay.Plethora; 7 | 8 | public class GuiConfigCore extends GuiConfigFactory { 9 | @Override 10 | public GuiScreen createConfigGui(GuiScreen screen) { 11 | return new GuiConfigImpl(screen); 12 | } 13 | 14 | private static class GuiConfigImpl extends GuiConfigBase { 15 | GuiConfigImpl(GuiScreen screen) { 16 | super(screen, ConfigCore.configuration, PlethoraCore.ID, Plethora.NAME); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/advancements/recipes/neural_connector.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "minecraft:recipes/root", 3 | "rewards": { 4 | "recipes": [ 5 | "plethora:neural_connector" 6 | ] 7 | }, 8 | "criteria": { 9 | "has_connector": { 10 | "trigger": "minecraft:inventory_changed", 11 | "conditions": { 12 | "items": [ 13 | { 14 | "item": "plethora:neuralinterface" 15 | } 16 | ] 17 | } 18 | }, 19 | "has_the_recipe": { 20 | "trigger": "minecraft:recipe_unlocked", 21 | "conditions": { 22 | "recipe": "plethora:neural_connector" 23 | } 24 | } 25 | }, 26 | "requirements": [ 27 | [ 28 | "has_connector", 29 | "has_the_recipe" 30 | ] 31 | ] 32 | } 33 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/advancements/recipes/neural_interface.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "minecraft:recipes/root", 3 | "rewards": { 4 | "recipes": [ 5 | "plethora:neural_interface" 6 | ] 7 | }, 8 | "criteria": { 9 | "has_pocket": { 10 | "trigger": "minecraft:inventory_changed", 11 | "conditions": { 12 | "items": [ 13 | { 14 | "item": "computercraft:pocket_computer" 15 | } 16 | ] 17 | } 18 | }, 19 | "has_the_recipe": { 20 | "trigger": "minecraft:recipe_unlocked", 21 | "conditions": { 22 | "recipe": "plethora:neural_interface" 23 | } 24 | } 25 | }, 26 | "requirements": [ 27 | [ 28 | "has_pocket", 29 | "has_the_recipe" 30 | ] 31 | ] 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/api/module/AbstractModuleHandler.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.api.module; 2 | 3 | import org.squiddev.plethora.api.method.IContextBuilder; 4 | 5 | import javax.annotation.Nonnull; 6 | 7 | /** 8 | * Some default implementations for {@link IModuleHandler} methods. 9 | * 10 | * It is recommended that all implementations extend this class: it allows additional methods 11 | * to be added to the module handler without introducing abstract method errors occurring. 12 | */ 13 | public abstract class AbstractModuleHandler implements IModuleHandler { 14 | @Override 15 | public void getAdditionalContext(@Nonnull IModuleAccess access, @Nonnull IContextBuilder builder) { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/advancements/recipes/manipulator.mark_1.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "minecraft:recipes/root", 3 | "rewards": { 4 | "recipes": [ 5 | "plethora:manipulator.mark_1" 6 | ] 7 | }, 8 | "criteria": { 9 | "has_computer": { 10 | "trigger": "minecraft:inventory_changed", 11 | "conditions": { 12 | "items": [ 13 | { 14 | "item": "computercraft:computer" 15 | } 16 | ] 17 | } 18 | }, 19 | "has_the_recipe": { 20 | "trigger": "minecraft:recipe_unlocked", 21 | "conditions": { 22 | "recipe": "plethora:manipulator.mark_1" 23 | } 24 | } 25 | }, 26 | "requirements": [ 27 | [ 28 | "has_computer", 29 | "has_the_recipe" 30 | ] 31 | ] 32 | } 33 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Report some misbehaviour in the mod 4 | labels: bug 5 | 6 | --- 7 | 8 | 12 | 13 | ## Useful information to include: 14 | - Minecraft version 15 | - CC: Tweaked version 16 | - Plethora version 17 | - Detailed reproduction steps: sometimes I can spot a bug pretty easily, but often it's much more obscure. The more information I have to help reproduce it, the quicker it'll get fixed. 18 | 19 | 22 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/advancements/recipes/module_introspection.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "minecraft:recipes/root", 3 | "rewards": { 4 | "recipes": [ 5 | "plethora:module_introspection" 6 | ] 7 | }, 8 | "criteria": { 9 | "has_manipulator": { 10 | "trigger": "minecraft:inventory_changed", 11 | "conditions": { 12 | "items": [ 13 | { 14 | "item": "plethora:manipulator" 15 | } 16 | ] 17 | } 18 | }, 19 | "has_the_recipe": { 20 | "trigger": "minecraft:recipe_unlocked", 21 | "conditions": { 22 | "recipe": "plethora:module_introspection" 23 | } 24 | } 25 | }, 26 | "requirements": [ 27 | [ 28 | "has_manipulator", 29 | "has_the_recipe" 30 | ] 31 | ] 32 | } 33 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/advancements/recipes/manipulator.mark_2.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "minecraft:recipes/root", 3 | "rewards": { 4 | "recipes": [ 5 | "plethora:manipulator.mark_2" 6 | ] 7 | }, 8 | "criteria": { 9 | "has_mark_1": { 10 | "trigger": "minecraft:inventory_changed", 11 | "conditions": { 12 | "items": [ 13 | { 14 | "item": "plethora:manipulator", 15 | "data": 0 16 | } 17 | ] 18 | } 19 | }, 20 | "has_the_recipe": { 21 | "trigger": "minecraft:recipe_unlocked", 22 | "conditions": { 23 | "recipe": "plethora:manipulator.mark_2" 24 | } 25 | } 26 | }, 27 | "requirements": [ 28 | [ 29 | "has_mark_1", 30 | "has_the_recipe" 31 | ] 32 | ] 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/api/IAttachable.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.api; 2 | 3 | /** 4 | * An object which can be "attached" and "detached" from something. 5 | * 6 | * This "something" is normally a computer. Unlike {@link dan200.computercraft.api.peripheral.IPeripheral}'s 7 | * methods, this is only attached to one object at a time. 8 | */ 9 | public interface IAttachable { 10 | /** 11 | * Called when this object is attached to something. Will not be 12 | * called twice without {@link #detach()} being called in between. 13 | */ 14 | void attach(); 15 | 16 | /** 17 | * Called when an object is detached from something. Will only be called 18 | * after {@link #attach()}. 19 | */ 20 | void detach(); 21 | } 22 | -------------------------------------------------------------------------------- /src/main/resources/mcmod.info: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "modid": "plethora-core", 4 | "name": "Plethora Core", 5 | "description": "Peripheral provider for ComputerCraft", 6 | "version": "${mod_version}", 7 | "mcversion": "${mc_version}", 8 | "credits": "Dan200, Forge team", 9 | "authorList": [ 10 | "SquidDev" 11 | ], 12 | "dependencies": [ 13 | "computercraft" 14 | ] 15 | }, 16 | { 17 | "modid": "plethora", 18 | "name": "Plethora", 19 | "description": "Adds gameplay related items to Plethora", 20 | "version": "${mod_version}", 21 | "mcversion": "${mc_version}", 22 | "credits": "Dan200, Forge team", 23 | "authorList": [ 24 | "SquidDev" 25 | ], 26 | "dependencies": [ 27 | "computercraft" 28 | ] 29 | } 30 | ] 31 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/api/method/IMethodRegistry.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.api.method; 2 | 3 | import net.minecraft.util.EnumFacing; 4 | import net.minecraftforge.common.capabilities.ICapabilityProvider; 5 | 6 | import javax.annotation.Nonnull; 7 | import javax.annotation.Nullable; 8 | 9 | /** 10 | * A registry for metadata providers. 11 | * 12 | * @see IMethod 13 | */ 14 | public interface IMethodRegistry { 15 | /** 16 | * Get the cost handler for this object 17 | * 18 | * @param object The cost handler's owner 19 | * @param side The side to get the cost handler from 20 | * @return The associated cost handler 21 | */ 22 | @Nonnull 23 | ICostHandler getCostHandler(@Nonnull ICapabilityProvider object, @Nullable EnumFacing side); 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/api/method/wrapper/Optional.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.api.method.wrapper; 2 | 3 | import javax.annotation.Nonnull; 4 | import javax.annotation.Nullable; 5 | import javax.annotation.meta.TypeQualifierNickname; 6 | import javax.annotation.meta.When; 7 | import java.lang.annotation.*; 8 | 9 | /** 10 | * Provide a default value for primitives. 11 | */ 12 | @Documented 13 | @Nullable 14 | @TypeQualifierNickname 15 | @Retention(RetentionPolicy.RUNTIME) 16 | @Target({ ElementType.PARAMETER, ElementType.METHOD }) 17 | @Nonnull(when = When.UNKNOWN) 18 | public @interface Optional { 19 | long defLong() default -1; 20 | 21 | int defInt() default -1; 22 | 23 | double defDoub() default -1; 24 | 25 | boolean defBool() default false; 26 | } 27 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/mod_integration.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Mod integration 3 | about: Suggest an integration for a mod 4 | labels: enhancement, integration 5 | 6 | --- 7 | 8 | 13 | 14 | ## Useful information to include: 15 | - Explanation of how the feature/change should work. 16 | - Some rationale/use case for a feature. I'd like to keep Plethora as minimal as possible, so I like to have a solid justification for each feature. 17 | - Detailed use cases, possibly with example code help make it easier to see the sort of things you'd like to interact with. This makes it much easier to implement your suggestion! 18 | -------------------------------------------------------------------------------- /src/test/java/org/squiddev/plethora/core/RegistryTest.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.core; 2 | 3 | import net.minecraft.tileentity.TileEntity; 4 | import net.minecraft.tileentity.TileEntityFurnace; 5 | import org.junit.Test; 6 | import org.squiddev.plethora.integration.vanilla.transfer.TransferTileEntity; 7 | 8 | import java.util.ArrayList; 9 | 10 | import static org.junit.Assert.assertEquals; 11 | 12 | public class RegistryTest { 13 | 14 | @Test 15 | public void registerInstanceClass() { 16 | ConfigCore.Blacklist.blacklistProviders = new ArrayList<>(); 17 | Registry.register(TransferTileEntity.class, null); 18 | PlethoraCore.buildRegistries(); 19 | 20 | TileEntity te = new TileEntityFurnace(); 21 | assertEquals(te, TransferRegistry.instance.getTransferLocation(te, "self")); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/api/meta/SimpleMetaProvider.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.api.meta; 2 | 3 | import org.squiddev.plethora.api.method.IPartialContext; 4 | 5 | import javax.annotation.Nonnull; 6 | import java.util.Map; 7 | 8 | /** 9 | * An interface-based version of {@link IMetaProvider}. One consumes the object directly, rather than needing 10 | * to use {@link IPartialContext#getTarget()}. 11 | * 12 | * @param The type of object this provider handles. 13 | */ 14 | @FunctionalInterface 15 | public interface SimpleMetaProvider extends IMetaProvider { 16 | @Nonnull 17 | @Override 18 | default Map getMeta(@Nonnull IPartialContext context) { 19 | return getMeta(context.getTarget()); 20 | } 21 | 22 | @Nonnull 23 | Map getMeta(@Nonnull T target); 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/gameplay/client/gui/GuiConfigGameplay.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.gameplay.client.gui; 2 | 3 | import net.minecraft.client.gui.GuiScreen; 4 | import org.squiddev.plethora.core.client.gui.GuiConfigBase; 5 | import org.squiddev.plethora.core.client.gui.GuiConfigFactory; 6 | import org.squiddev.plethora.gameplay.ConfigGameplay; 7 | import org.squiddev.plethora.gameplay.Plethora; 8 | 9 | public class GuiConfigGameplay extends GuiConfigFactory { 10 | @Override 11 | public GuiScreen createConfigGui(GuiScreen parentScreen) { 12 | return new GuiConfigImpl(parentScreen); 13 | } 14 | 15 | private static class GuiConfigImpl extends GuiConfigBase { 16 | GuiConfigImpl(GuiScreen screen) { 17 | super(screen, ConfigGameplay.configuration, Plethora.ID, Plethora.NAME); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/utils/LoadedCache.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.utils; 2 | 3 | import baubles.common.Baubles; 4 | import net.minecraftforge.fml.common.Loader; 5 | import vazkii.botania.common.lib.LibMisc; 6 | 7 | public final class LoadedCache { 8 | private static boolean loaded; 9 | private static boolean hasBotania; 10 | private static boolean hasBaubles; 11 | 12 | private LoadedCache() { 13 | } 14 | 15 | private static void load() { 16 | hasBotania = Loader.isModLoaded(LibMisc.MOD_ID); 17 | hasBaubles = Loader.isModLoaded(Baubles.MODID); 18 | loaded = true; 19 | } 20 | 21 | public static boolean hasBotania() { 22 | if (!loaded) load(); 23 | return hasBotania; 24 | } 25 | 26 | public static boolean hasBaubles() { 27 | if (!loaded) load(); 28 | return hasBaubles; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/api/neural/INeuralRegistry.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.api.neural; 2 | 3 | import net.minecraft.entity.EntityLivingBase; 4 | 5 | import javax.annotation.Nonnull; 6 | import java.util.function.Predicate; 7 | 8 | /** 9 | * Various methods for controlling interactions with the neural interface. 10 | */ 11 | public interface INeuralRegistry { 12 | /** 13 | * Add an predicate which controls whether an entity can have 14 | * the neural interface attached to it. 15 | * 16 | * @param predicate The predicate which will receive an entity. If {@code false} is returned then the neural 17 | * interface will be blocked from connecting, otherwise the remaining predicates will be checked. 18 | */ 19 | void addEquipPredicate(@Nonnull Predicate predicate); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/integration/ExtendedArgumentTypes.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.integration; 2 | 3 | import dan200.computercraft.api.lua.LuaException; 4 | import org.squiddev.plethora.api.Injects; 5 | import org.squiddev.plethora.api.method.wrapper.ArgumentType; 6 | 7 | import javax.annotation.Nonnull; 8 | 9 | @Injects 10 | public final class ExtendedArgumentTypes { 11 | public static final ArgumentType FINGERPRINT = new ArgumentType() { 12 | @Override 13 | public String name() { 14 | return "string|table"; 15 | } 16 | 17 | @Nonnull 18 | @Override 19 | public ItemFingerprint get(@Nonnull Object[] args, int index) throws LuaException { 20 | return ItemFingerprint.fromLua(args, index); 21 | } 22 | }; 23 | 24 | private ExtendedArgumentTypes() { 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/integration/vanilla/method/MethodsEnergyHandler.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.integration.vanilla.method; 2 | 3 | import net.minecraftforge.energy.IEnergyStorage; 4 | import org.squiddev.plethora.api.method.wrapper.FromTarget; 5 | import org.squiddev.plethora.api.method.wrapper.PlethoraMethod; 6 | 7 | public final class MethodsEnergyHandler { 8 | private MethodsEnergyHandler() { 9 | } 10 | 11 | @PlethoraMethod(doc = "-- The amount of energy currently stored") 12 | public static int getEnergyStored(@FromTarget IEnergyStorage storage) { 13 | return storage.getEnergyStored(); 14 | } 15 | 16 | @PlethoraMethod(doc = "-- The maximum amount of energy that can be stored") 17 | public static int getEnergyCapacity(@FromTarget IEnergyStorage storage) { 18 | return storage.getMaxEnergyStored(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/utils/EntityPlayerDummy.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.utils; 2 | 3 | import com.mojang.authlib.GameProfile; 4 | import net.minecraft.entity.player.EntityPlayer; 5 | import net.minecraft.world.World; 6 | 7 | import java.util.UUID; 8 | 9 | public class EntityPlayerDummy extends EntityPlayer { 10 | /** 11 | * A UUID for demonstration purposes. It's a wee bit vain, but nice to have a "real" player here. 12 | */ 13 | private static final GameProfile PROFILE = new GameProfile(UUID.fromString("d3156e4b-c712-4fd3-87b0-b24b8ca94209"), "SquidDev"); 14 | 15 | public EntityPlayerDummy(World worldIn) { 16 | super(worldIn, PROFILE); 17 | } 18 | 19 | @Override 20 | public boolean isSpectator() { 21 | return true; 22 | } 23 | 24 | @Override 25 | public boolean isCreative() { 26 | return false; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/core/docdump/DocumentedMetaProvider.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.core.docdump; 2 | 3 | import org.squiddev.plethora.api.meta.IMetaProvider; 4 | import org.squiddev.plethora.core.MetaRegistry; 5 | 6 | import javax.annotation.Nonnull; 7 | 8 | class DocumentedMetaProvider extends DocumentedItem> { 9 | private final Class target; 10 | 11 | DocumentedMetaProvider(@Nonnull Class target, @Nonnull IMetaProvider provider) { 12 | super(provider, MetaRegistry.instance.getName(provider), MetaRegistry.instance.getName(provider), provider.getDescription()); 13 | this.target = target; 14 | } 15 | 16 | /** 17 | * The class this meta provider targets 18 | * 19 | * @return This meta provider's target 20 | */ 21 | @Nonnull 22 | public Class getTarget() { 23 | return target; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/integration/jei/IntegrationJEI.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.integration.jei; 2 | 3 | import mezz.jei.api.IModPlugin; 4 | import mezz.jei.api.IModRegistry; 5 | import mezz.jei.api.JEIPlugin; 6 | import mezz.jei.api.recipe.IRecipeCategoryRegistration; 7 | 8 | import javax.annotation.Nonnull; 9 | 10 | /** 11 | * Adds a usage handler which tells you where peripherals/modules can be used 12 | */ 13 | @JEIPlugin 14 | public class IntegrationJEI implements IModPlugin { 15 | @Override 16 | public void register(@Nonnull IModRegistry registry) { 17 | ModulesWrapper.setup(registry); 18 | PeripheralsWrapper.setup(registry); 19 | } 20 | 21 | @Override 22 | public void registerCategories(IRecipeCategoryRegistration registry) { 23 | ModulesWrapper.setup(registry); 24 | PeripheralsWrapper.setup(registry); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/integration/forestry/MethodsErrorLogicSource.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.integration.forestry; 2 | 3 | import forestry.api.core.IErrorLogicSource; 4 | import forestry.api.core.IErrorState; 5 | import forestry.core.config.Constants; 6 | import org.squiddev.plethora.api.method.wrapper.FromTarget; 7 | import org.squiddev.plethora.api.method.wrapper.PlethoraMethod; 8 | import org.squiddev.plethora.utils.Helpers; 9 | 10 | import java.util.List; 11 | 12 | public final class MethodsErrorLogicSource { 13 | private MethodsErrorLogicSource() { 14 | } 15 | 16 | @PlethoraMethod(modId = Constants.MOD_ID, doc = "-- Get any errors preventing operation") 17 | public static List getErrors(@FromTarget IErrorLogicSource source) { 18 | return Helpers.map(source.getErrorLogic().getErrorStates(), IErrorState::getUniqueName); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/gameplay/keyboard/ListenMessage.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.gameplay.keyboard; 2 | 3 | import io.netty.buffer.ByteBuf; 4 | import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; 5 | import org.squiddev.plethora.gameplay.registry.BasicMessage; 6 | 7 | public class ListenMessage implements BasicMessage { 8 | private boolean listening; 9 | 10 | public ListenMessage() { 11 | } 12 | 13 | public ListenMessage(boolean listening) { 14 | this.listening = listening; 15 | } 16 | 17 | @Override 18 | public void fromBytes(ByteBuf buf) { 19 | listening = buf.readBoolean(); 20 | } 21 | 22 | @Override 23 | public void toBytes(ByteBuf buf) { 24 | buf.writeBoolean(listening); 25 | } 26 | 27 | @Override 28 | public void onMessage(MessageContext context) { 29 | ClientKeyListener.listening = listening; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/recipes/_constants.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "WOOL", 4 | "ingredient": [ 5 | { "item": "minecraft:wool", "data": 0}, 6 | { "item": "minecraft:wool", "data": 1}, 7 | { "item": "minecraft:wool", "data": 2}, 8 | { "item": "minecraft:wool", "data": 3}, 9 | { "item": "minecraft:wool", "data": 4}, 10 | { "item": "minecraft:wool", "data": 5}, 11 | { "item": "minecraft:wool", "data": 6}, 12 | { "item": "minecraft:wool", "data": 7}, 13 | { "item": "minecraft:wool", "data": 8}, 14 | { "item": "minecraft:wool", "data": 9}, 15 | { "item": "minecraft:wool", "data": 10}, 16 | { "item": "minecraft:wool", "data": 11}, 17 | { "item": "minecraft:wool", "data": 12}, 18 | { "item": "minecraft:wool", "data": 13}, 19 | { "item": "minecraft:wool", "data": 14}, 20 | { "item": "minecraft:wool", "data": 15} 21 | ] 22 | } 23 | ] 24 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/api/method/wrapper/FromSubtarget.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.api.method.wrapper; 2 | 3 | import org.squiddev.plethora.api.method.ContextKeys; 4 | 5 | import java.lang.annotation.*; 6 | 7 | /** 8 | * Extract this value from the context's target, rather than taking it as an argument. 9 | * 10 | * This is largely similar to {@link FromContext}, though is more selective in where it extracts the entry, and the 11 | * type will be used as a {@link org.squiddev.plethora.api.method.IMethod#getSubTarget()}. 12 | */ 13 | @Documented 14 | @Retention(RetentionPolicy.RUNTIME) 15 | @Target(ElementType.PARAMETER) 16 | public @interface FromSubtarget { 17 | /** 18 | * The context key to extract from. When blank, this will be equivalent to {@link ContextKeys#ORIGIN} and then 19 | * all modules you may be attached to. 20 | */ 21 | String[] value() default {}; 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/gameplay/modules/glasses/objects/object3d/DepthTestable.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.gameplay.modules.glasses.objects.object3d; 2 | 3 | import org.squiddev.plethora.api.method.wrapper.FromTarget; 4 | import org.squiddev.plethora.api.method.wrapper.PlethoraMethod; 5 | 6 | public interface DepthTestable { 7 | boolean hasDepthTest(); 8 | 9 | void setDepthTest(boolean depthTest); 10 | 11 | @PlethoraMethod(doc = "-- Determine whether depth testing is enabled for this object.", worldThread = false) 12 | static boolean isDepthTested(@FromTarget DepthTestable object) { 13 | return object.hasDepthTest(); 14 | } 15 | 16 | @PlethoraMethod(doc = "-- Set whether depth testing is enabled for this object.", worldThread = false) 17 | static void setDepthTested(@FromTarget DepthTestable object, boolean depthTest) { 18 | object.setDepthTest(depthTest); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/footer.html: -------------------------------------------------------------------------------- 1 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/api/meta/BasicMetaProvider.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.api.meta; 2 | 3 | import org.squiddev.plethora.api.method.IPartialContext; 4 | 5 | import javax.annotation.Nonnull; 6 | import java.util.Map; 7 | 8 | /** 9 | * Basic wrapper for meta-providers 10 | */ 11 | public abstract class BasicMetaProvider extends BaseMetaProvider implements SimpleMetaProvider { 12 | public BasicMetaProvider(int priority, String description) { 13 | super(priority, description); 14 | } 15 | 16 | public BasicMetaProvider(String description) { 17 | super(description); 18 | } 19 | 20 | public BasicMetaProvider(int priority) { 21 | super(priority); 22 | } 23 | 24 | public BasicMetaProvider() { 25 | } 26 | 27 | @Nonnull 28 | @Override 29 | public final Map getMeta(@Nonnull IPartialContext context) { 30 | return getMeta(context.getTarget()); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/gameplay/ItemBlockBase.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.gameplay; 2 | 3 | import net.minecraft.block.Block; 4 | import net.minecraft.item.ItemBlock; 5 | import net.minecraft.item.ItemStack; 6 | 7 | import javax.annotation.Nonnull; 8 | import java.util.Objects; 9 | 10 | public class ItemBlockBase extends ItemBlock { 11 | public ItemBlockBase(Block block) { 12 | super(block); 13 | 14 | setRegistryName(Objects.requireNonNull(block.getRegistryName())); 15 | setHasSubtypes(true); 16 | setMaxDamage(0); 17 | } 18 | 19 | @Override 20 | public int getMetadata(int meta) { 21 | return meta; 22 | } 23 | 24 | @Nonnull 25 | @Override 26 | public String getTranslationKey(ItemStack stack) { 27 | if (block instanceof BlockBase) { 28 | return ((BlockBase) block).getTranslationKey(stack.getItemDamage()); 29 | } else { 30 | return block.getTranslationKey(); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/api/meta/BaseMetaProvider.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.api.meta; 2 | 3 | import javax.annotation.Nonnull; 4 | 5 | /** 6 | * Basic wrapper for meta-providers 7 | */ 8 | public abstract class BaseMetaProvider implements IMetaProvider { 9 | private final int priority; 10 | private final String description; 11 | 12 | public BaseMetaProvider(int priority, String description) { 13 | this.priority = priority; 14 | this.description = description; 15 | } 16 | 17 | public BaseMetaProvider(String description) { 18 | this(0, description); 19 | } 20 | 21 | public BaseMetaProvider(int priority) { 22 | this(priority, null); 23 | } 24 | 25 | public BaseMetaProvider() { 26 | this(0, null); 27 | } 28 | 29 | @Override 30 | public int getPriority() { 31 | return priority; 32 | } 33 | 34 | @Nonnull 35 | @Override 36 | public String getDescription() { 37 | return description; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/models/block/manipulator.mark_1.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "block/block", 3 | "textures": { 4 | "particle": "plethora:blocks/manipulator_side", 5 | "bottom": "plethora:blocks/manipulator_bottom", 6 | "top": "plethora:blocks/manipulator_top1", 7 | "side": "plethora:blocks/manipulator_side" 8 | }, 9 | "elements": [ 10 | { 11 | "from": [ 0, 0, 0 ], 12 | "to": [ 16, 10, 16 ], 13 | "faces": { 14 | "down": { "uv": [ 0, 0, 16, 16 ], "texture": "#bottom", "cullface": "down" }, 15 | "up": { "uv": [ 0, 0, 16, 16 ], "texture": "#top" }, 16 | "north": { "uv": [ 0, 6, 16, 16 ], "texture": "#side", "cullface": "north" }, 17 | "south": { "uv": [ 0, 6, 16, 16 ], "texture": "#side", "cullface": "south" }, 18 | "west": { "uv": [ 0, 6, 16, 16 ], "texture": "#side", "cullface": "west" }, 19 | "east": { "uv": [ 0, 6, 16, 16 ], "texture": "#side", "cullface": "east" } 20 | } 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/models/block/manipulator.mark_2.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "block/block", 3 | "textures": { 4 | "particle": "plethora:blocks/manipulator_side", 5 | "bottom": "plethora:blocks/manipulator_bottom", 6 | "top": "plethora:blocks/manipulator_top2", 7 | "side": "plethora:blocks/manipulator_side" 8 | }, 9 | "elements": [ 10 | { 11 | "from": [ 0, 0, 0 ], 12 | "to": [ 16, 10, 16 ], 13 | "faces": { 14 | "down": { "uv": [ 0, 0, 16, 16 ], "texture": "#bottom", "cullface": "down" }, 15 | "up": { "uv": [ 0, 0, 16, 16 ], "texture": "#top" }, 16 | "north": { "uv": [ 0, 6, 16, 16 ], "texture": "#side", "cullface": "north" }, 17 | "south": { "uv": [ 0, 6, 16, 16 ], "texture": "#side", "cullface": "south" }, 18 | "west": { "uv": [ 0, 6, 16, 16 ], "texture": "#side", "cullface": "west" }, 19 | "east": { "uv": [ 0, 6, 16, 16 ], "texture": "#side", "cullface": "east" } 20 | } 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/integration/vanilla/meta/MetaFluidTank.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.integration.vanilla.meta; 2 | 3 | import net.minecraftforge.fluids.IFluidTank; 4 | import net.minecraftforge.fluids.capability.templates.EmptyFluidHandler; 5 | import org.squiddev.plethora.api.Injects; 6 | import org.squiddev.plethora.api.meta.BasicMetaProvider; 7 | 8 | import javax.annotation.Nonnull; 9 | import java.util.Collections; 10 | import java.util.Map; 11 | 12 | @Injects 13 | public final class MetaFluidTank extends BasicMetaProvider { 14 | @Nonnull 15 | @Override 16 | public Map getMeta(@Nonnull IFluidTank tank) { 17 | return Collections.singletonMap("capacity", tank.getCapacity()); 18 | } 19 | 20 | @Nonnull 21 | @Override 22 | public IFluidTank getExample() { 23 | return new EmptyFluidHandler() { 24 | @Override 25 | public int getCapacity() { 26 | return 1000; 27 | } 28 | }; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/gameplay/minecart/ContainerMinecartComputer.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.gameplay.minecart; 2 | 3 | import dan200.computercraft.shared.computer.core.IComputer; 4 | import dan200.computercraft.shared.computer.core.IContainerComputer; 5 | import net.minecraft.entity.player.EntityPlayer; 6 | import net.minecraft.inventory.Container; 7 | 8 | import javax.annotation.Nonnull; 9 | import javax.annotation.Nullable; 10 | 11 | public class ContainerMinecartComputer extends Container implements IContainerComputer { 12 | private final EntityMinecartComputer minecart; 13 | 14 | public ContainerMinecartComputer(EntityMinecartComputer minecart) { 15 | this.minecart = minecart; 16 | } 17 | 18 | @Override 19 | public boolean canInteractWith(@Nonnull EntityPlayer player) { 20 | return minecart.isUsable(player); 21 | } 22 | 23 | @Nullable 24 | @Override 25 | public IComputer getComputer() { 26 | return minecart.getServerComputer(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/gameplay/modules/glasses/MessageCanvasRemove.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.gameplay.modules.glasses; 2 | 3 | import io.netty.buffer.ByteBuf; 4 | import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; 5 | import org.squiddev.plethora.gameplay.registry.BasicMessage; 6 | 7 | public class MessageCanvasRemove implements BasicMessage { 8 | private int canvasId; 9 | 10 | public MessageCanvasRemove(int canvasId) { 11 | this.canvasId = canvasId; 12 | } 13 | 14 | public MessageCanvasRemove() { 15 | } 16 | 17 | @Override 18 | public void fromBytes(ByteBuf buf) { 19 | canvasId = buf.readInt(); 20 | } 21 | 22 | @Override 23 | public void toBytes(ByteBuf buf) { 24 | buf.writeInt(canvasId); 25 | } 26 | 27 | @Override 28 | public void onMessage(MessageContext context) { 29 | CanvasClient canvas = CanvasHandler.getClient(canvasId); 30 | if (canvas == null) return; 31 | 32 | CanvasHandler.removeClient(canvas); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/core/RegisteredValue.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.core; 2 | 3 | import org.squiddev.plethora.utils.Helpers; 4 | 5 | import javax.annotation.Nonnull; 6 | import javax.annotation.Nullable; 7 | import java.util.Objects; 8 | 9 | /** 10 | * A node which can be registered and enabled and disabled at runtime. 11 | */ 12 | public class RegisteredValue { 13 | @Nonnull 14 | private final String name; 15 | 16 | @Nullable 17 | private final String mod; 18 | 19 | RegisteredValue(@Nonnull String name, @Nullable String mod) { 20 | this.name = Objects.requireNonNull(name); 21 | this.mod = mod; 22 | } 23 | 24 | @Nonnull 25 | public final String name() { 26 | return name; 27 | } 28 | 29 | @Nullable 30 | public final String mod() { 31 | return mod; 32 | } 33 | 34 | public final boolean enabled() { 35 | return !Helpers.blacklisted(ConfigCore.Blacklist.blacklistProviders, name) 36 | && (mod == null || !Helpers.modBlacklisted(mod)); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/core/capabilities/EmptyCostHandler.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.core.capabilities; 2 | 3 | import dan200.computercraft.api.lua.LuaException; 4 | import org.squiddev.plethora.api.method.ICostHandler; 5 | import org.squiddev.plethora.api.method.MethodResult; 6 | 7 | import java.util.concurrent.Callable; 8 | 9 | public class EmptyCostHandler implements ICostHandler { 10 | public static final ICostHandler INSTANCE = new EmptyCostHandler(); 11 | 12 | private EmptyCostHandler() { 13 | } 14 | 15 | @Override 16 | public double get() { 17 | return 0; 18 | } 19 | 20 | @Override 21 | public boolean consume(double amount) { 22 | if (amount < 0) throw new IllegalArgumentException("amount must be >= 0"); 23 | return amount == 0; 24 | } 25 | 26 | @Override 27 | public MethodResult await(double amount, Callable next) throws LuaException { 28 | throw new LuaException("Insufficient energy (requires " + amount + ", has 0)."); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/api/converter/IConverter.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.api.converter; 2 | 3 | import javax.annotation.Nonnull; 4 | import javax.annotation.Nullable; 5 | 6 | /** 7 | * An implicit converter: takes an object and converts it into something else 8 | */ 9 | public interface IConverter { 10 | /** 11 | * Convert an object from one object into another. 12 | * Used to provide additional objects from one 13 | * 14 | * @param from The object to convert from 15 | * @return The converted object 16 | */ 17 | @Nullable 18 | TOut convert(@Nonnull TIn from); 19 | 20 | /** 21 | * Whether this converter will always return the same object for a given 22 | * input. 23 | * 24 | * Note, you may make some assumptions about the conversion, 25 | * such that the block and tile will not change. 26 | * 27 | * @return If this converter is constant. 28 | * @see ConstantConverter 29 | * @see DynamicConverter 30 | */ 31 | boolean isConstant(); 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/gameplay/modules/glasses/objects/Scalable.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.gameplay.modules.glasses.objects; 2 | 3 | import dan200.computercraft.api.lua.LuaException; 4 | import org.squiddev.plethora.api.method.wrapper.FromTarget; 5 | import org.squiddev.plethora.api.method.wrapper.PlethoraMethod; 6 | 7 | /** 8 | * An object which can be scaled. This includes point side, text size and line thickness. 9 | */ 10 | public interface Scalable { 11 | float getScale(); 12 | 13 | void setScale(float scale); 14 | 15 | @PlethoraMethod(doc = "-- Get the scale for this object.", worldThread = false) 16 | static double getScale(@FromTarget Scalable object) { 17 | return object.getScale(); 18 | } 19 | 20 | @PlethoraMethod(doc = "-- Set the scale for this object.", worldThread = false) 21 | static void setScale(@FromTarget Scalable object, float scale) throws LuaException { 22 | if (scale <= 0) throw new LuaException("Scale must be > 0"); 23 | object.setScale(scale); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/integration/vanilla/meta/MetaFluidTankProperties.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.integration.vanilla.meta; 2 | 3 | import net.minecraftforge.fluids.FluidRegistry; 4 | import net.minecraftforge.fluids.capability.FluidTankProperties; 5 | import net.minecraftforge.fluids.capability.IFluidTankProperties; 6 | import org.squiddev.plethora.api.Injects; 7 | import org.squiddev.plethora.api.meta.BasicMetaProvider; 8 | 9 | import javax.annotation.Nonnull; 10 | import java.util.Collections; 11 | import java.util.Map; 12 | 13 | @Injects 14 | public final class MetaFluidTankProperties extends BasicMetaProvider { 15 | @Nonnull 16 | @Override 17 | public Map getMeta(@Nonnull IFluidTankProperties tank) { 18 | return Collections.singletonMap("capacity", tank.getCapacity()); 19 | } 20 | 21 | @Nonnull 22 | @Override 23 | public IFluidTankProperties getExample() { 24 | return new FluidTankProperties(FluidRegistry.getFluidStack("water", 1000), 1000); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/integration/rf/MetaEnergyContainerItem.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.integration.rf; 2 | 3 | import cofh.redstoneflux.RedstoneFluxProps; 4 | import cofh.redstoneflux.api.IEnergyContainerItem; 5 | import net.minecraft.item.ItemStack; 6 | import org.squiddev.plethora.api.Injects; 7 | import org.squiddev.plethora.api.meta.ItemStackMetaProvider; 8 | 9 | import javax.annotation.Nonnull; 10 | import java.util.HashMap; 11 | import java.util.Map; 12 | 13 | @Injects(RedstoneFluxProps.MOD_ID) 14 | public final class MetaEnergyContainerItem extends ItemStackMetaProvider { 15 | public MetaEnergyContainerItem() { 16 | super("rf", IEnergyContainerItem.class); 17 | } 18 | 19 | @Nonnull 20 | @Override 21 | public Map getMeta(@Nonnull ItemStack object, @Nonnull IEnergyContainerItem handler) { 22 | Map out = new HashMap<>(2); 23 | out.put("stored", handler.getEnergyStored(object)); 24 | out.put("capacity", handler.getMaxEnergyStored(object)); 25 | return out; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/core/modules/VehicleModuleHandlerTransform.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.core.modules; 2 | 3 | import net.minecraft.item.Item; 4 | import net.minecraft.util.ResourceLocation; 5 | import org.squiddev.plethora.api.PlethoraAPI; 6 | import org.squiddev.plethora.api.vehicle.IVehicleUpgradeHandler; 7 | import org.squiddev.plethora.api.vehicle.VehicleModuleHandler; 8 | 9 | import javax.vecmath.Matrix4f; 10 | 11 | /** 12 | * A version of {@link VehicleModuleHandler} which allows specifying a minecart specific matrix transformation. 13 | */ 14 | public class VehicleModuleHandlerTransform extends VehicleModuleHandler { 15 | private final Matrix4f transform; 16 | 17 | public VehicleModuleHandlerTransform(ResourceLocation id, Item item, Matrix4f transform) { 18 | super(id, item); 19 | this.transform = transform; 20 | } 21 | 22 | @Override 23 | protected IVehicleUpgradeHandler createVehicle() { 24 | return PlethoraAPI.instance().moduleRegistry().toVehicleUpgrade(new ModuleHandlerTransform(this, transform)); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/core/client/gui/GuiConfigBase.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.core.client.gui; 2 | 3 | import net.minecraft.client.gui.GuiScreen; 4 | import net.minecraftforge.common.config.ConfigElement; 5 | import net.minecraftforge.common.config.Configuration; 6 | import net.minecraftforge.fml.client.config.GuiConfig; 7 | import net.minecraftforge.fml.client.config.IConfigElement; 8 | 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | public abstract class GuiConfigBase extends GuiConfig { 13 | public GuiConfigBase(GuiScreen screen, Configuration config, String id, String name) { 14 | super(screen, getConfigElements(config), id, false, false, name); 15 | } 16 | 17 | private static List getConfigElements(Configuration config) { 18 | ArrayList elements = new ArrayList<>(); 19 | for (String category : config.getCategoryNames()) { 20 | if (!category.contains(".")) { 21 | elements.add(new ConfigElement(config.getCategory(category))); 22 | } 23 | } 24 | return elements; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/integration/rf/MetaEnergyStorage.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.integration.rf; 2 | 3 | import cofh.redstoneflux.RedstoneFluxProps; 4 | import cofh.redstoneflux.api.IEnergyStorage; 5 | import cofh.redstoneflux.impl.EnergyStorage; 6 | import org.squiddev.plethora.api.Injects; 7 | import org.squiddev.plethora.api.meta.BasicMetaProvider; 8 | 9 | import javax.annotation.Nonnull; 10 | import java.util.Collections; 11 | import java.util.HashMap; 12 | import java.util.Map; 13 | 14 | @Injects(RedstoneFluxProps.MOD_ID) 15 | public final class MetaEnergyStorage extends BasicMetaProvider { 16 | @Nonnull 17 | @Override 18 | public Map getMeta(@Nonnull IEnergyStorage object) { 19 | Map out = new HashMap<>(2); 20 | out.put("stored", object.getEnergyStored()); 21 | out.put("capacity", object.getMaxEnergyStored()); 22 | return Collections.singletonMap("rf", out); 23 | } 24 | 25 | @Nonnull 26 | @Override 27 | public IEnergyStorage getExample() { 28 | return new EnergyStorage(1000); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/api/converter/Converters.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.api.converter; 2 | 3 | import net.minecraftforge.common.capabilities.Capability; 4 | import net.minecraftforge.common.capabilities.ICapabilityProvider; 5 | 6 | import java.util.function.Supplier; 7 | 8 | public final class Converters { 9 | private Converters() { 10 | } 11 | 12 | /** 13 | * Build a converter from some {@link ICapabilityProvider} to a target type using a capability. 14 | * 15 | * @param capSource A supplier for the capability. We need this to be lazy, as the capability may not have been 16 | * registered when constructing this. 17 | * @param The type we target. 18 | * @return The dynamic converter for this capability. 19 | */ 20 | public static DynamicConverter ofCapability(Supplier> capSource) { 21 | return from -> { 22 | Capability cap = capSource.get(); 23 | return cap != null && from.hasCapability(cap, null) ? from.getCapability(cap, null) : null; 24 | }; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/core/API.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.core; 2 | 3 | import org.squiddev.plethora.api.PlethoraAPI; 4 | import org.squiddev.plethora.api.converter.IConverterRegistry; 5 | import org.squiddev.plethora.api.meta.IMetaRegistry; 6 | import org.squiddev.plethora.api.method.IMethodRegistry; 7 | import org.squiddev.plethora.api.module.IModuleRegistry; 8 | import org.squiddev.plethora.api.transfer.ITransferRegistry; 9 | 10 | public final class API implements PlethoraAPI.IPlethoraAPI { 11 | @Override 12 | public IMethodRegistry methodRegistry() { 13 | return MethodRegistry.instance; 14 | } 15 | 16 | @Override 17 | public IMetaRegistry metaRegistry() { 18 | return MetaRegistry.instance; 19 | } 20 | 21 | @Override 22 | public IConverterRegistry converterRegistry() { 23 | return ConverterRegistry.instance; 24 | } 25 | 26 | @Override 27 | public ITransferRegistry transferRegistry() { 28 | return TransferRegistry.instance; 29 | } 30 | 31 | @Override 32 | public IModuleRegistry moduleRegistry() { 33 | return ModuleRegistry.instance; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/integration/baubles/TransferBaublesInventory.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.integration.baubles; 2 | 3 | import baubles.api.BaublesApi; 4 | import baubles.common.Baubles; 5 | import net.minecraft.entity.player.EntityPlayer; 6 | import org.squiddev.plethora.api.Injects; 7 | import org.squiddev.plethora.api.transfer.ITransferProvider; 8 | 9 | import javax.annotation.Nonnull; 10 | import javax.annotation.Nullable; 11 | import java.util.Collections; 12 | import java.util.Set; 13 | 14 | /** 15 | * Provides an inventory called "baubles" for players 16 | */ 17 | @Injects(Baubles.MODID) 18 | public final class TransferBaublesInventory implements ITransferProvider { 19 | @Nullable 20 | @Override 21 | public Object getTransferLocation(@Nonnull EntityPlayer object, @Nonnull String key) { 22 | return key.equals("baubles") ? BaublesApi.getBaublesHandler(object) : null; 23 | } 24 | 25 | @Nonnull 26 | @Override 27 | public Set getTransferLocations(@Nonnull EntityPlayer object) { 28 | return Collections.singleton("baubles"); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/gameplay/modules/glasses/objects/ObjectGroup.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.gameplay.modules.glasses.objects; 2 | 3 | import org.squiddev.plethora.gameplay.modules.glasses.BaseObject; 4 | import org.squiddev.plethora.gameplay.modules.glasses.CanvasHandler; 5 | 6 | /** 7 | * Represents a holder for {@link BaseObject}s. 8 | */ 9 | public interface ObjectGroup { 10 | /** 11 | * @return The ID for this group. 12 | */ 13 | int id(); 14 | 15 | /** 16 | * A group for 2D objects 17 | */ 18 | interface Group2D extends ObjectGroup { 19 | } 20 | 21 | /** 22 | * A group for 2D objects with a fixed side 23 | */ 24 | interface Frame2D extends Group2D { 25 | default int getWidth() { 26 | return CanvasHandler.WIDTH; 27 | } 28 | 29 | default int getHeight() { 30 | return CanvasHandler.HEIGHT; 31 | } 32 | } 33 | 34 | /** 35 | * A group for 3D objects 36 | */ 37 | interface Group3D extends ObjectGroup { 38 | } 39 | 40 | /** 41 | * The "origin" for all 3D objects 42 | */ 43 | interface Origin3D extends ObjectGroup { 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/integration/forestry/MetaButterfly.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.integration.forestry; 2 | 3 | import forestry.api.lepidopterology.IButterfly; 4 | import forestry.core.config.Constants; 5 | import forestry.lepidopterology.genetics.ButterflyDefinition; 6 | import org.squiddev.plethora.api.Injects; 7 | import org.squiddev.plethora.api.meta.BasicMetaProvider; 8 | 9 | import javax.annotation.Nonnull; 10 | import java.util.Collections; 11 | import java.util.Map; 12 | 13 | @Injects(Constants.MOD_ID) 14 | public final class MetaButterfly extends BasicMetaProvider { 15 | @Nonnull 16 | @Override 17 | public Map getMeta(@Nonnull IButterfly butterfly) { 18 | if (!butterfly.isAnalyzed()) return Collections.emptyMap(); 19 | 20 | return Collections.singletonMap("butterfly", Collections.singletonMap("size", butterfly.getSize())); 21 | } 22 | 23 | @Nonnull 24 | @Override 25 | public IButterfly getExample() { 26 | IButterfly butterfly = ButterflyDefinition.Batesia.getIndividual(); 27 | butterfly.analyze(); 28 | return butterfly; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/integration/xnet/NetworkConnectorSettings.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.integration.xnet; 2 | 3 | import mcjty.xnet.api.gui.IEditorGui; 4 | import mcjty.xnet.api.gui.IndicatorIcon; 5 | import mcjty.xnet.api.helper.AbstractConnectorSettings; 6 | import net.minecraft.util.EnumFacing; 7 | 8 | import javax.annotation.Nonnull; 9 | import javax.annotation.Nullable; 10 | 11 | class NetworkConnectorSettings extends AbstractConnectorSettings { 12 | NetworkConnectorSettings(@Nonnull EnumFacing side) { 13 | super(side); 14 | } 15 | 16 | @Nullable 17 | @Override 18 | public IndicatorIcon getIndicatorIcon() { 19 | return NetworkChannelType.CONNECTOR_ICON; 20 | } 21 | 22 | @Nullable 23 | @Override 24 | public String getIndicator() { 25 | return null; 26 | } 27 | 28 | @Override 29 | public boolean isEnabled(String tag) { 30 | if (tag.equals(TAG_FACING)) return advanced; 31 | return true; 32 | } 33 | 34 | @Override 35 | public void createGui(IEditorGui gui) { 36 | advanced = gui.isAdvanced(); 37 | sideGui(gui); 38 | colorsGui(gui); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/api/method/BasicMethod.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.api.method; 2 | 3 | import com.google.common.base.Strings; 4 | 5 | import javax.annotation.Nonnull; 6 | 7 | /** 8 | * A basic wrapper for methods 9 | */ 10 | public abstract class BasicMethod implements IMethod { 11 | private final String name; 12 | private final String docs; 13 | private final int priority; 14 | 15 | public BasicMethod(String name, String docs) { 16 | this(name, 0, docs); 17 | } 18 | 19 | public BasicMethod(String name, int priority, String docs) { 20 | this.name = name; 21 | this.priority = priority; 22 | this.docs = Strings.isNullOrEmpty(docs) ? null : docs; 23 | } 24 | 25 | @Nonnull 26 | @Override 27 | public final String getName() { 28 | return name; 29 | } 30 | 31 | @Override 32 | public boolean canApply(@Nonnull IPartialContext context) { 33 | return true; 34 | } 35 | 36 | @Override 37 | public final int getPriority() { 38 | return priority; 39 | } 40 | 41 | @Nonnull 42 | @Override 43 | public String getDocString() { 44 | return docs; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/integration/vanilla/transfer/TransferEntityLivingBaseEquipment.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.integration.vanilla.transfer; 2 | 3 | import net.minecraft.entity.EntityLivingBase; 4 | import org.squiddev.plethora.api.Injects; 5 | import org.squiddev.plethora.api.transfer.ITransferProvider; 6 | import org.squiddev.plethora.utils.EquipmentInvWrapper; 7 | 8 | import javax.annotation.Nonnull; 9 | import javax.annotation.Nullable; 10 | import java.util.Collections; 11 | import java.util.Set; 12 | 13 | /** 14 | * Provides inventory for {@link EntityLivingBase}'s equipment 15 | */ 16 | @Injects 17 | public final class TransferEntityLivingBaseEquipment implements ITransferProvider { 18 | @Nullable 19 | @Override 20 | public Object getTransferLocation(@Nonnull EntityLivingBase object, @Nonnull String key) { 21 | return key.equals("equipment") ? new EquipmentInvWrapper(object) : null; 22 | } 23 | 24 | @Nonnull 25 | @Override 26 | public Set getTransferLocations(@Nonnull EntityLivingBase object) { 27 | return Collections.singleton("equipment"); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/gameplay/modules/glasses/objects/object3d/Positionable3D.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.gameplay.modules.glasses.objects.object3d; 2 | 3 | import net.minecraft.util.math.Vec3d; 4 | import org.squiddev.plethora.api.method.MethodResult; 5 | import org.squiddev.plethora.api.method.wrapper.FromTarget; 6 | import org.squiddev.plethora.api.method.wrapper.PlethoraMethod; 7 | 8 | import javax.annotation.Nonnull; 9 | 10 | public interface Positionable3D { 11 | @Nonnull 12 | Vec3d getPosition(); 13 | 14 | void setPosition(@Nonnull Vec3d position); 15 | 16 | @PlethoraMethod(doc = "function():number, number, number -- Get the position for this object.", worldThread = false) 17 | static MethodResult getPosition(@FromTarget Positionable3D object) { 18 | Vec3d pos = object.getPosition(); 19 | return MethodResult.result(pos.x, pos.y, pos.z); 20 | } 21 | 22 | @PlethoraMethod(doc = "-- Set the position for this object.", worldThread = false) 23 | static void setPosition(@FromTarget Positionable3D object, double x, double y, double z) { 24 | object.setPosition(new Vec3d(x, y, z)); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/api/method/IMethodCollection.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.api.method; 2 | 3 | import javax.annotation.Nonnull; 4 | import java.util.List; 5 | 6 | /** 7 | * A special context object that is created if an object has any methods. 8 | * 9 | * This can be used to add special methods, such as documentation providers. An empty context 10 | * is created with this object as the target. 11 | */ 12 | public interface IMethodCollection { 13 | /** 14 | * All gathered methods for this object 15 | * 16 | * @return A read only list of all gathered methods 17 | */ 18 | @Nonnull 19 | List> methods(); 20 | 21 | /** 22 | * See if any method implements an interface or class. 23 | * 24 | * This is used to see if a marker interface is present. 25 | * 26 | * @param iface The interface or class to check 27 | * @return If any method implements this interface (or extends this class) 28 | */ 29 | default boolean has(@Nonnull Class iface) { 30 | for (IMethod method : methods()) { 31 | if (method.has(iface)) return true; 32 | } 33 | 34 | return false; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/integration/refinedstorage/ItemIdentity.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.integration.refinedstorage; 2 | 3 | import net.minecraft.item.ItemStack; 4 | 5 | import java.util.Objects; 6 | 7 | public class ItemIdentity { 8 | private final ItemStack stack; 9 | 10 | public ItemIdentity(ItemStack stack) { 11 | this.stack = stack; 12 | } 13 | 14 | public ItemStack getStack() { 15 | return stack; 16 | } 17 | 18 | @Override 19 | public boolean equals(Object o) { 20 | if (this == o) return true; 21 | if (o == null || getClass() != o.getClass()) return false; 22 | 23 | ItemIdentity that = (ItemIdentity) o; 24 | return equals(getStack(), that.getStack()); 25 | } 26 | 27 | @Override 28 | public int hashCode() { 29 | return stack.getItem().hashCode() << 4 + stack.getItemDamage(); 30 | } 31 | 32 | public static boolean equals(ItemStack left, ItemStack right) { 33 | return left.getItem() == right.getItem() 34 | && left.getItemDamage() == right.getItemDamage() 35 | && Objects.equals(left.getTagCompound(), right.getTagCompound()) 36 | && left.areCapsCompatible(right); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/utils/Vec2d.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.utils; 2 | 3 | public class Vec2d { 4 | public static final Vec2d ZERO = new Vec2d(0.0d, 0.0d); 5 | 6 | /** 7 | * X coordinate of Vec2D 8 | */ 9 | public final double x; 10 | 11 | /** 12 | * Y coordinate of Vec2D 13 | */ 14 | public final double y; 15 | 16 | public Vec2d(double x, double y) { 17 | if (x == -0.0D) x = 0.0D; 18 | if (y == -0.0D) y = 0.0D; 19 | 20 | this.x = x; 21 | this.y = y; 22 | } 23 | 24 | public boolean equals(Object object) { 25 | if (this == object) { 26 | return true; 27 | } else if (!(object instanceof Vec2d)) { 28 | return false; 29 | } else { 30 | Vec2d other = (Vec2d) object; 31 | 32 | return Double.compare(other.x, x) == 0 && Double.compare(other.y, y) == 0; 33 | } 34 | } 35 | 36 | public int hashCode() { 37 | long j = Double.doubleToLongBits(x); 38 | int i = (int) (j ^ j >>> 32); 39 | j = Double.doubleToLongBits(y); 40 | i = 31 * i + (int) (j ^ j >>> 32); 41 | return i; 42 | } 43 | 44 | public String toString() { 45 | return "(" + x + ", " + y + ")"; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/api/module/IModuleContainer.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.api.module; 2 | 3 | import net.minecraft.util.ResourceLocation; 4 | 5 | import javax.annotation.Nonnull; 6 | import java.util.Set; 7 | 8 | /** 9 | * An object representing a root level container for modules. This should be used 10 | * as a target for {@link org.squiddev.plethora.api.method.IMethod} when module methods 11 | * do not target a specific object. 12 | */ 13 | public interface IModuleContainer { 14 | /** 15 | * Check whether this module container has a given module. 16 | * 17 | * This will not change over the course of the container's lifetime. 18 | * 19 | * @param module The module to check 20 | * @return Whether this container has a the specified module 21 | */ 22 | boolean hasModule(@Nonnull ResourceLocation module); 23 | 24 | /** 25 | * Get a collection of all modules in this container.. 26 | * 27 | * This will not change over the course of the containers's lifetime. 28 | * 29 | * @return A read-only set of all available modules. 30 | */ 31 | @Nonnull 32 | Set getModules(); 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/api/vehicle/IVehicleAccess.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.api.vehicle; 2 | 3 | import net.minecraft.entity.Entity; 4 | import net.minecraft.nbt.NBTTagCompound; 5 | 6 | import javax.annotation.Nonnull; 7 | 8 | /** 9 | * An access object for a computer mounted on some vehicle, usable by {@link IVehicleUpgradeHandler}. 10 | */ 11 | public interface IVehicleAccess { 12 | /** 13 | * Get the vehicle this access object represents. 14 | * 15 | * @return The access's vehicle. 16 | */ 17 | @Nonnull 18 | Entity getVehicle(); 19 | 20 | /** 21 | * Get data specific to this stack. This can be written 22 | * to and shared with the client. It is not bound to the item 23 | * stack however and is discarded when the upgrade is removed. 24 | * 25 | * If you change this data, you should mark it as dirty with {@link #markDataDirty()}. 26 | * 27 | * @return The module specific data 28 | * @see #markDataDirty() 29 | */ 30 | @Nonnull 31 | NBTTagCompound getData(); 32 | 33 | /** 34 | * Mark the module specific data as dirty 35 | * 36 | * @see #getData() 37 | */ 38 | void markDataDirty(); 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/integration/refinedstorage/IntegrationRefinedStorage.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.integration.refinedstorage; 2 | 3 | import com.raoulvdberge.refinedstorage.RS; 4 | import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode; 5 | import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeProxy; 6 | import com.raoulvdberge.refinedstorage.capability.CapabilityNetworkNodeProxy; 7 | import net.minecraftforge.common.capabilities.ICapabilityProvider; 8 | import org.squiddev.plethora.api.Injects; 9 | import org.squiddev.plethora.api.converter.DynamicConverter; 10 | 11 | import static org.squiddev.plethora.api.converter.Converters.ofCapability; 12 | 13 | @Injects(RS.ID) 14 | public final class IntegrationRefinedStorage { 15 | private IntegrationRefinedStorage() { 16 | } 17 | 18 | public static final DynamicConverter PROXY_TO_NODE = INetworkNodeProxy::getNode; 19 | 20 | public static final DynamicConverter NETWORK_NODE_CAP = ofCapability( 21 | () -> CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY 22 | ); 23 | } 24 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016-2018 SquidDev 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/integration/ic2/MetaEnergyStorage.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.integration.ic2; 2 | 3 | import ic2.api.tile.IEnergyStorage; 4 | import ic2.core.IC2; 5 | import ic2.core.block.wiring.TileEntityChargepadBatBox; 6 | import org.squiddev.plethora.api.Injects; 7 | import org.squiddev.plethora.api.meta.BasicMetaProvider; 8 | 9 | import javax.annotation.Nonnull; 10 | import java.util.Collections; 11 | import java.util.HashMap; 12 | import java.util.Map; 13 | 14 | /** 15 | * Provider for EU storage 16 | */ 17 | @Injects(IC2.MODID) 18 | public final class MetaEnergyStorage extends BasicMetaProvider { 19 | @Nonnull 20 | @Override 21 | public Map getMeta(@Nonnull IEnergyStorage object) { 22 | Map out = new HashMap<>(3); 23 | out.put("stored", object.getStored()); 24 | out.put("capacity", object.getCapacity()); 25 | out.put("output", object.getOutputEnergyUnitsPerTick()); 26 | return Collections.singletonMap("eu_storage", out); 27 | } 28 | 29 | @Nonnull 30 | @Override 31 | public IEnergyStorage getExample() { 32 | return new TileEntityChargepadBatBox(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/api/Injects.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.api; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Injects a class into the various Plethora registries. 10 | * 11 | * This may either be used on an implementation of a registerable interface, or on a class with several public static 12 | * fields whose values should be registered. 13 | * 14 | * @see org.squiddev.plethora.api.transfer.ITransferProvider 15 | * @see org.squiddev.plethora.api.converter.IConverter 16 | * @see org.squiddev.plethora.api.method.IMethod 17 | * @see org.squiddev.plethora.api.meta.IMetaProvider 18 | */ 19 | @Retention(RetentionPolicy.RUNTIME) 20 | @Target(ElementType.TYPE) 21 | public @interface Injects { 22 | /** 23 | * The mod id that this injection registry depends on. This class will not be loaded, and so the dependencies not 24 | * registered, if it is not specified. 25 | * 26 | * @return The dependent mod id, or empty if none is required. 27 | */ 28 | String value() default ""; 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/gameplay/modules/glasses/objects/object2d/Positionable2D.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.gameplay.modules.glasses.objects.object2d; 2 | 3 | import org.squiddev.plethora.api.method.MethodResult; 4 | import org.squiddev.plethora.api.method.wrapper.FromTarget; 5 | import org.squiddev.plethora.api.method.wrapper.PlethoraMethod; 6 | import org.squiddev.plethora.utils.Vec2d; 7 | 8 | import javax.annotation.Nonnull; 9 | 10 | /** 11 | * An object which can be positioned in 2D. 12 | */ 13 | public interface Positionable2D { 14 | @Nonnull 15 | Vec2d getPosition(); 16 | 17 | void setPosition(@Nonnull Vec2d position); 18 | 19 | @PlethoraMethod(doc = "function():number, number -- Get the position for this object.", worldThread = false) 20 | static MethodResult getPosition(@FromTarget Positionable2D object) { 21 | Vec2d pos = object.getPosition(); 22 | return MethodResult.result(pos.x, pos.y); 23 | } 24 | 25 | @PlethoraMethod(doc = "-- Set the position for this object.", worldThread = false) 26 | static void setPosition(@FromTarget Positionable2D object, double x, double y) { 27 | object.setPosition(new Vec2d(x, y)); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/integration/forestry/MetaBee.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.integration.forestry; 2 | 3 | import forestry.api.apiculture.IBee; 4 | import forestry.apiculture.genetics.BeeDefinition; 5 | import forestry.core.config.Constants; 6 | import org.squiddev.plethora.api.Injects; 7 | import org.squiddev.plethora.api.meta.BasicMetaProvider; 8 | 9 | import javax.annotation.Nonnull; 10 | import java.util.Collections; 11 | import java.util.HashMap; 12 | import java.util.Map; 13 | 14 | @Injects(Constants.MOD_ID) 15 | public final class MetaBee extends BasicMetaProvider { 16 | @Nonnull 17 | @Override 18 | public Map getMeta(@Nonnull IBee bee) { 19 | if (!bee.isAnalyzed()) return Collections.emptyMap(); 20 | 21 | Map out = new HashMap<>(3); 22 | out.put("canSpawn", bee.canSpawn()); 23 | out.put("generation", bee.getGeneration()); 24 | out.put("pristine", bee.isNatural()); 25 | return Collections.singletonMap("bee", out); 26 | } 27 | 28 | @Nonnull 29 | @Override 30 | public IBee getExample() { 31 | IBee bee = BeeDefinition.FOREST.getIndividual(); 32 | bee.analyze(); 33 | return bee; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/api/IPeripheralHandler.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.api; 2 | 3 | import dan200.computercraft.api.peripheral.IPeripheral; 4 | import net.minecraft.entity.EntityLivingBase; 5 | import net.minecraft.util.math.Vec3d; 6 | import net.minecraft.world.World; 7 | 8 | import javax.annotation.Nonnull; 9 | import javax.annotation.Nullable; 10 | 11 | /** 12 | * A capability for peripherals which require additional handling. This is intended for objects which require an update 13 | * such as turtle upgrades or neural interface modules. 14 | * 15 | * @see Constants#PERIPHERAL_HANDLER_CAPABILITY 16 | */ 17 | public interface IPeripheralHandler { 18 | /** 19 | * Get the peripheral this handler provides 20 | * 21 | * @return This handler's peripheral 22 | */ 23 | @Nonnull 24 | IPeripheral getPeripheral(); 25 | 26 | /** 27 | * Update this peripheral 28 | * 29 | * @param world The world this peripheral exists in 30 | * @param position The position this peripheral exists at 31 | * @param entity The owning entity 32 | */ 33 | void update(@Nonnull World world, @Nonnull Vec3d position, @Nullable EntityLivingBase entity); 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/core/modules/BasicModuleHandlerTransform.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.core.modules; 2 | 3 | import net.minecraft.client.renderer.block.model.IBakedModel; 4 | import net.minecraft.item.Item; 5 | import net.minecraft.util.ResourceLocation; 6 | import net.minecraftforge.fml.relauncher.Side; 7 | import net.minecraftforge.fml.relauncher.SideOnly; 8 | import org.apache.commons.lang3.tuple.Pair; 9 | import org.squiddev.plethora.api.module.BasicModuleHandler; 10 | 11 | import javax.annotation.Nonnull; 12 | import javax.vecmath.Matrix4f; 13 | 14 | /** 15 | * A version of {@link BasicModuleHandler} which allows specifying a custom transformation matrix. 16 | */ 17 | public class BasicModuleHandlerTransform extends BasicModuleHandler { 18 | private final Matrix4f transform; 19 | 20 | public BasicModuleHandlerTransform(ResourceLocation id, Item item, Matrix4f transform) { 21 | super(id, item); 22 | this.transform = transform; 23 | } 24 | 25 | @Nonnull 26 | @Override 27 | @SideOnly(Side.CLIENT) 28 | public Pair getModel(float delta) { 29 | return Pair.of(super.getModel(delta).getLeft(), transform); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/core/executor/NeverExecutor.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.core.executor; 2 | 3 | import dan200.computercraft.api.lua.ILuaContext; 4 | import dan200.computercraft.api.lua.LuaException; 5 | import org.squiddev.plethora.api.method.IResultExecutor; 6 | import org.squiddev.plethora.api.method.MethodResult; 7 | 8 | import javax.annotation.Nonnull; 9 | import javax.annotation.Nullable; 10 | 11 | /** 12 | * A result executor which should never be used. 13 | * 14 | * This is intended for cases where you will replace the executor before evaluating it (such as on peripherals). 15 | */ 16 | public final class NeverExecutor implements IResultExecutor { 17 | public static final IResultExecutor INSTANCE = new NeverExecutor(); 18 | 19 | private NeverExecutor() { 20 | } 21 | 22 | @Nullable 23 | @Override 24 | public Object[] execute(@Nonnull MethodResult result, @Nonnull ILuaContext context) throws LuaException { 25 | throw new LuaException("Cannot execute method"); 26 | } 27 | 28 | @Override 29 | public void executeAsync(@Nonnull MethodResult result) throws LuaException { 30 | throw new LuaException("Cannot execute method"); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/test/resources/assets/plethora-test/test-rom/spec/vanilla/inventory_spec.lua: -------------------------------------------------------------------------------- 1 | describe("inventories", function() 2 | local function setup() 3 | commands.wait { 4 | commands.async.setblock("~", "~1", "~", "minecraft:air"), 5 | commands.async.setblock("~", "~1", "~", "minecraft:chest", 0, "replace", { 6 | Items = { { Slot = 0, id = "minecraft:stick", Count = 50 } } 7 | }), 8 | } 9 | 10 | return peripheral.wrap("top") 11 | end 12 | 13 | it("size", function() 14 | local inv = setup() 15 | expect(inv.size()):eq(27) 16 | end) 17 | 18 | it("list", function() 19 | local inv = setup() 20 | expect(inv.list()):same { { name = "minecraft:stick", damage = 0, count = 50 } } 21 | end) 22 | 23 | describe("getItemMetdata", function() 24 | it("on an empty slot", function() 25 | local inv = setup() 26 | expect(inv.getItemMeta(2)):eq(nil) 27 | end) 28 | 29 | it("on a stick", function() 30 | local inv = setup() 31 | expect(inv.getItemMeta(1)):matches { 32 | name = "minecraft:stick", displayName = "Stick", rawName = "item.stick", 33 | damage = 0, maxDamage = 0, count = 50, maxCount = 64, 34 | ores = { stickWood = true } 35 | } 36 | end) 37 | end) 38 | end) 39 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/integration/computercraft/TransferComputerAccess.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.integration.computercraft; 2 | 3 | import dan200.computercraft.ComputerCraft; 4 | import dan200.computercraft.api.peripheral.IComputerAccess; 5 | import dan200.computercraft.api.peripheral.IPeripheral; 6 | import org.squiddev.plethora.api.Injects; 7 | import org.squiddev.plethora.api.transfer.ITransferProvider; 8 | 9 | import javax.annotation.Nonnull; 10 | import javax.annotation.Nullable; 11 | import java.util.Set; 12 | 13 | /** 14 | * Transfer providers for CC: Tweaked's (and hopefully CC's) wired networks. 15 | */ 16 | @Injects(ComputerCraft.MOD_ID) 17 | public final class TransferComputerAccess implements ITransferProvider { 18 | @Nullable 19 | @Override 20 | public Object getTransferLocation(@Nonnull IComputerAccess object, @Nonnull String key) { 21 | IPeripheral peripheral = object.getAvailablePeripheral(key); 22 | return peripheral == null ? null : peripheral.getTarget(); 23 | } 24 | 25 | @Nonnull 26 | @Override 27 | public Set getTransferLocations(@Nonnull IComputerAccess object) { 28 | return object.getAvailablePeripherals().keySet(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/gameplay/modules/ModulePeripheral.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.gameplay.modules; 2 | 3 | import dan200.computercraft.api.peripheral.IPeripheral; 4 | import org.apache.commons.lang3.tuple.Pair; 5 | import org.squiddev.plethora.api.IAttachable; 6 | import org.squiddev.plethora.core.AttachableWrapperPeripheral; 7 | import org.squiddev.plethora.core.RegisteredMethod; 8 | import org.squiddev.plethora.core.UnbakedContext; 9 | import org.squiddev.plethora.core.executor.TaskRunner; 10 | 11 | import java.util.Collection; 12 | import java.util.List; 13 | 14 | public class ModulePeripheral extends AttachableWrapperPeripheral { 15 | private final int stackHash; 16 | 17 | public ModulePeripheral( 18 | String name, Object owner, Pair>, List>> methods, 19 | TaskRunner runner, Collection attachments, 20 | int stackHash 21 | ) { 22 | super(name, owner, methods, runner, attachments); 23 | this.stackHash = stackHash; 24 | } 25 | 26 | @Override 27 | public boolean equals(IPeripheral other) { 28 | return super.equals(other) && other instanceof ModulePeripheral && stackHash == ((ModulePeripheral) other).stackHash; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/integration/refinedstorage/MetaCraftingTask.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.integration.refinedstorage; 2 | 3 | import com.raoulvdberge.refinedstorage.RS; 4 | import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingRequestInfo; 5 | import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingTask; 6 | import org.squiddev.plethora.api.Injects; 7 | import org.squiddev.plethora.api.meta.BaseMetaProvider; 8 | import org.squiddev.plethora.api.method.IPartialContext; 9 | 10 | import javax.annotation.Nonnull; 11 | import java.util.HashMap; 12 | import java.util.Map; 13 | 14 | @Injects(RS.ID) 15 | public final class MetaCraftingTask extends BaseMetaProvider { 16 | @Nonnull 17 | @Override 18 | public Map getMeta(@Nonnull IPartialContext context) { 19 | ICraftingTask task = context.getTarget(); 20 | Map out = new HashMap<>(); 21 | 22 | ICraftingRequestInfo requested = task.getRequested(); 23 | if (requested != null) out.put("requested", context.makePartialChild(requested)); 24 | out.put("quantity", task.getQuantity()); 25 | out.put("valid", !task.hasMissing()); 26 | 27 | return out; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/models/item/module_laser.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "item/generated", 3 | "textures": { 4 | "layer0": "plethora:items/module_laser" 5 | }, 6 | "display": { 7 | "thirdperson_righthand": { 8 | "rotation": [ 9 | -80, 10 | 260, 11 | -40 12 | ], 13 | "translation": [ 14 | -2, 15 | 2, 16 | -2 17 | ], 18 | "scale": [ 19 | 0.7, 20 | 0.7, 21 | 0.7 22 | ] 23 | }, 24 | "thirdperson_lefthand": { 25 | "rotation": [ 26 | -80, 27 | -280, 28 | 40 29 | ], 30 | "translation": [ 31 | -2, 32 | 2, 33 | -2 34 | ], 35 | "scale": [ 36 | 0.7, 37 | 0.7, 38 | 0.7 39 | ] 40 | }, 41 | "firstperson_righthand": { 42 | "rotation": [ 43 | 0, 44 | -90, 45 | 25 46 | ], 47 | "translation": [ 48 | 1.13, 49 | 3.2, 50 | 1.13 51 | ], 52 | "scale": [ 53 | 0.68, 54 | 0.68, 55 | 0.68 56 | ] 57 | }, 58 | "firstperson_lefthand": { 59 | "rotation": [ 60 | 0, 61 | 90, 62 | -25 63 | ], 64 | "translation": [ 65 | 1.13, 66 | 3.2, 67 | 1.13 68 | ], 69 | "scale": [ 70 | 0.68, 71 | 0.68, 72 | 0.68 73 | ] 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/integration/vanilla/meta/MetaMaterial.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.integration.vanilla.meta; 2 | 3 | import net.minecraft.block.material.Material; 4 | import org.squiddev.plethora.api.Injects; 5 | import org.squiddev.plethora.api.meta.BasicMetaProvider; 6 | 7 | import javax.annotation.Nonnull; 8 | import javax.annotation.Nullable; 9 | import java.util.HashMap; 10 | import java.util.Map; 11 | 12 | @Injects 13 | public final class MetaMaterial extends BasicMetaProvider { 14 | @Nonnull 15 | @Override 16 | public Map getMeta(@Nonnull Material material) { 17 | Map data = new HashMap<>(); 18 | 19 | data.put("replaceable", material.isReplaceable()); 20 | data.put("liquid", material.isLiquid()); 21 | data.put("opaque", material.isOpaque()); 22 | data.put("solid", material.isSolid()); 23 | data.put("blocksMovement", material.blocksMovement()); 24 | data.put("blocksLight", material.blocksMovement()); 25 | data.put("requiresTool", !material.isToolNotRequired()); 26 | data.put("burns", material.getCanBurn()); 27 | 28 | return data; 29 | } 30 | 31 | @Nullable 32 | @Override 33 | public Material getExample() { 34 | return Material.ROCK; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/integration/buildcraft/TileHeatable.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.integration.buildcraft; 2 | 3 | import buildcraft.api.tiles.IHeatable; 4 | import buildcraft.core.BCCore; 5 | import org.squiddev.plethora.api.Injects; 6 | import org.squiddev.plethora.api.method.wrapper.FromTarget; 7 | import org.squiddev.plethora.api.method.wrapper.PlethoraMethod; 8 | 9 | public final class TileHeatable { 10 | 11 | @PlethoraMethod(modId = BCCore.MODID, doc = "-- Get the minimal heat.") 12 | public static double getMinHeat(@FromTarget IHeatable heatable) { 13 | return heatable.getMinHeatValue(); 14 | } 15 | 16 | @PlethoraMethod(modId = BCCore.MODID, doc = "-- Get the maximal heat.") 17 | public static double getMaxHeat(@FromTarget IHeatable heatable) { 18 | return heatable.getMaxHeatValue(); 19 | } 20 | 21 | @PlethoraMethod(modId = BCCore.MODID, doc = "-- Get the current heat.") 22 | public static double getCurrentHeat(@FromTarget IHeatable heatable) { 23 | return heatable.getCurrentHeatValue(); 24 | } 25 | 26 | @PlethoraMethod(modId = BCCore.MODID, doc = "-- Get the ideal heat.") 27 | public static double getIdealHeat(@FromTarget IHeatable heatable) { 28 | return heatable.getIdealHeatValue(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/gameplay/neural/NeuralRegistry.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.gameplay.neural; 2 | 3 | import com.google.common.collect.Lists; 4 | import net.minecraft.entity.EntityLivingBase; 5 | import net.minecraft.entity.player.EntityPlayer; 6 | import org.squiddev.plethora.api.neural.INeuralRegistry; 7 | 8 | import javax.annotation.Nonnull; 9 | import java.util.List; 10 | import java.util.Objects; 11 | import java.util.function.Predicate; 12 | 13 | public final class NeuralRegistry implements INeuralRegistry { 14 | public static final NeuralRegistry instance = new NeuralRegistry(); 15 | 16 | private final List> predicates = Lists.newArrayList(); 17 | 18 | private NeuralRegistry() { 19 | } 20 | 21 | @Override 22 | public void addEquipPredicate(@Nonnull Predicate predicate) { 23 | Objects.requireNonNull(predicate, "predicates cannot be null"); 24 | predicates.add(predicate); 25 | } 26 | 27 | public boolean canEquip(@Nonnull EntityLivingBase entity) { 28 | if (entity.isChild() || entity instanceof EntityPlayer) return false; 29 | 30 | for (Predicate pred : predicates) { 31 | if (!pred.test(entity)) return false; 32 | } 33 | 34 | return true; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/integration/computercraft/MetaTileComputer.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.integration.computercraft; 2 | 3 | import com.google.common.base.Strings; 4 | import dan200.computercraft.ComputerCraft; 5 | import dan200.computercraft.shared.computer.blocks.ComputerProxy; 6 | import dan200.computercraft.shared.computer.blocks.TileComputerBase; 7 | import org.squiddev.plethora.api.Injects; 8 | import org.squiddev.plethora.api.meta.BasicMetaProvider; 9 | 10 | import javax.annotation.Nonnull; 11 | import java.util.Collections; 12 | import java.util.HashMap; 13 | import java.util.Map; 14 | 15 | @Injects(ComputerCraft.MOD_ID) 16 | public final class MetaTileComputer extends BasicMetaProvider { 17 | @Nonnull 18 | @Override 19 | public Map getMeta(@Nonnull TileComputerBase tile) { 20 | ComputerProxy computer = tile.createProxy(); 21 | 22 | Map out = new HashMap<>(); 23 | out.put("family", tile.getFamily().toString()); 24 | out.put("id", computer.assignID()); 25 | 26 | String label = computer.getLabel(); 27 | if (!Strings.isNullOrEmpty(label)) out.put("label", label); 28 | 29 | out.put("isOn", computer.isOn()); 30 | 31 | return Collections.singletonMap("computer", out); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/integration/mcmultipart/ReferenceMultipart.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.integration.mcmultipart; 2 | 3 | import dan200.computercraft.api.lua.LuaException; 4 | import mcmultipart.api.container.IMultipartContainer; 5 | import mcmultipart.api.container.IPartInfo; 6 | import mcmultipart.api.slot.IPartSlot; 7 | import org.squiddev.plethora.api.reference.DynamicReference; 8 | 9 | import javax.annotation.Nonnull; 10 | 11 | public class ReferenceMultipart implements DynamicReference { 12 | private final IPartSlot slot; 13 | private final IMultipartContainer container; 14 | 15 | public ReferenceMultipart(IMultipartContainer container, IPartSlot slot) { 16 | this.slot = slot; 17 | this.container = container; 18 | } 19 | 20 | public ReferenceMultipart(IMultipartContainer container, IPartInfo slot) { 21 | this(container, slot.getSlot()); 22 | } 23 | 24 | @Nonnull 25 | @Override 26 | public IPartInfo get() throws LuaException { 27 | IPartInfo part = container.get(slot).orElse(null); 28 | if (part == null) throw new LuaException("Part is no longer there"); 29 | 30 | return part; 31 | } 32 | 33 | @Nonnull 34 | @Override 35 | public IPartInfo safeGet() throws LuaException { 36 | return get(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/integration/ic2/MetaReactor.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.integration.ic2; 2 | 3 | import ic2.api.reactor.IReactor; 4 | import ic2.core.IC2; 5 | import ic2.core.block.reactor.tileentity.TileEntityNuclearReactorElectric; 6 | import org.squiddev.plethora.api.Injects; 7 | import org.squiddev.plethora.api.meta.BasicMetaProvider; 8 | 9 | import javax.annotation.Nonnull; 10 | import java.util.Collections; 11 | import java.util.HashMap; 12 | import java.util.Map; 13 | 14 | @Injects(IC2.MODID) 15 | public final class MetaReactor extends BasicMetaProvider { 16 | @Nonnull 17 | @Override 18 | public Map getMeta(@Nonnull IReactor object) { 19 | Map out = new HashMap<>(); 20 | 21 | out.put("heat", object.getHeat()); 22 | out.put("heatModifier", object.getHeatEffectModifier()); 23 | out.put("maxHeat", object.getMaxHeat()); 24 | 25 | out.put("euOutput", object.getReactorEUEnergyOutput()); 26 | out.put("active", object.produceEnergy()); 27 | out.put("fluidCooled", object.isFluidCooled()); 28 | 29 | return Collections.singletonMap("reactor", out); 30 | } 31 | 32 | @Nonnull 33 | @Override 34 | public IReactor getExample() { 35 | return new TileEntityNuclearReactorElectric(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/integration/vanilla/meta/MetaItemOreDict.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.integration.vanilla.meta; 2 | 3 | import net.minecraft.init.Blocks; 4 | import net.minecraft.item.ItemStack; 5 | import net.minecraftforge.oredict.OreDictionary; 6 | import org.squiddev.plethora.api.Injects; 7 | import org.squiddev.plethora.api.meta.BasicMetaProvider; 8 | 9 | import javax.annotation.Nonnull; 10 | import java.util.Collections; 11 | import java.util.HashMap; 12 | import java.util.Map; 13 | 14 | /** 15 | * Provides Ore Dictionary lookup for items 16 | */ 17 | @Injects 18 | public final class MetaItemOreDict extends BasicMetaProvider { 19 | @Nonnull 20 | @Override 21 | public Map getMeta(@Nonnull ItemStack stack) { 22 | if (stack.isEmpty()) return Collections.emptyMap(); 23 | 24 | int[] oreIds = OreDictionary.getOreIDs(stack); 25 | if (oreIds.length <= 0) return Collections.emptyMap(); 26 | 27 | HashMap list = new HashMap<>(oreIds.length); 28 | for (int id : oreIds) list.put(OreDictionary.getOreName(id), true); 29 | return Collections.singletonMap("ores", list); 30 | } 31 | 32 | @Nonnull 33 | @Override 34 | public ItemStack getExample() { 35 | return new ItemStack(Blocks.GLASS); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/gameplay/modules/glasses/objects/ColourableObject.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.gameplay.modules.glasses.objects; 2 | 3 | import io.netty.buffer.ByteBuf; 4 | import org.squiddev.plethora.gameplay.modules.glasses.BaseObject; 5 | 6 | public abstract class ColourableObject extends BaseObject implements Colourable { 7 | private int colour = DEFAULT_COLOUR; 8 | 9 | public ColourableObject(int id, int parent, byte type) { 10 | super(id, parent, type); 11 | } 12 | 13 | @Override 14 | public final int getColour() { 15 | return colour; 16 | } 17 | 18 | @Override 19 | public final void setColour(int colour) { 20 | if (this.colour != colour) { 21 | this.colour = colour; 22 | setDirty(); 23 | } 24 | } 25 | 26 | protected int getRed() { 27 | return (colour >> 24) & 0xFF; 28 | } 29 | 30 | protected int getGreen() { 31 | return (colour >> 16) & 0xFF; 32 | } 33 | 34 | protected int getBlue() { 35 | return (colour >> 8) & 0xFF; 36 | } 37 | 38 | protected int getAlpha() { 39 | return colour & 0xFF; 40 | } 41 | 42 | @Override 43 | public void writeInitial(ByteBuf buf) { 44 | buf.writeInt(colour); 45 | } 46 | 47 | @Override 48 | public void readInitial(ByteBuf buf) { 49 | colour = buf.readInt(); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/integration/ic2/MetaEnergyItem.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.integration.ic2; 2 | 3 | import ic2.api.item.IElectricItemManager; 4 | import ic2.core.IC2; 5 | import ic2.core.ref.ItemName; 6 | import net.minecraft.item.ItemStack; 7 | import org.squiddev.plethora.api.Injects; 8 | import org.squiddev.plethora.api.meta.BasicMetaProvider; 9 | 10 | import javax.annotation.Nonnull; 11 | import javax.annotation.Nullable; 12 | import java.util.Collections; 13 | import java.util.HashMap; 14 | import java.util.Map; 15 | 16 | @Injects(IC2.MODID) 17 | public final class MetaEnergyItem extends BasicMetaProvider { 18 | @Nonnull 19 | @Override 20 | public Map getMeta(@Nonnull ItemStack object) { 21 | IElectricItemManager manager = IntegrationIc2.getManager(object); 22 | if (manager == null) return Collections.emptyMap(); 23 | 24 | Map map = new HashMap<>(3); 25 | map.put("stored", manager.getCharge(object)); 26 | map.put("capacity", manager.getMaxCharge(object)); 27 | map.put("tier", manager.getTier(object)); 28 | 29 | return Collections.singletonMap("eu", map); 30 | } 31 | 32 | @Nullable 33 | @Override 34 | public ItemStack getExample() { 35 | return ItemName.batpack.getItemStack(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/integration/refinedstorage/MetaCraftingRequestInfo.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.integration.refinedstorage; 2 | 3 | import com.raoulvdberge.refinedstorage.RS; 4 | import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingRequestInfo; 5 | import net.minecraft.item.ItemStack; 6 | import net.minecraftforge.fluids.FluidStack; 7 | import org.squiddev.plethora.api.Injects; 8 | import org.squiddev.plethora.api.meta.BaseMetaProvider; 9 | import org.squiddev.plethora.api.method.IPartialContext; 10 | 11 | import javax.annotation.Nonnull; 12 | import java.util.HashMap; 13 | import java.util.Map; 14 | 15 | @Injects(RS.ID) 16 | public final class MetaCraftingRequestInfo extends BaseMetaProvider { 17 | @Nonnull 18 | @Override 19 | public Map getMeta(@Nonnull IPartialContext context) { 20 | ICraftingRequestInfo info = context.getTarget(); 21 | Map out = new HashMap<>(); 22 | 23 | ItemStack item = info.getItem(); 24 | if (item != null) out.put("item", context.makePartialChild(item).getMeta()); 25 | 26 | FluidStack fluid = info.getFluid(); 27 | if (fluid != null) out.put("fluid", context.makePartialChild(fluid).getMeta()); 28 | 29 | return out; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/integration/computercraft/MethodsIntrospectionTurtle.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.integration.computercraft; 2 | 3 | import dan200.computercraft.api.turtle.ITurtleAccess; 4 | import net.minecraftforge.items.IItemHandler; 5 | import org.squiddev.plethora.api.method.ContextKeys; 6 | import org.squiddev.plethora.api.method.IContext; 7 | import org.squiddev.plethora.api.method.TypedLuaObject; 8 | import org.squiddev.plethora.api.method.wrapper.FromSubtarget; 9 | import org.squiddev.plethora.api.method.wrapper.PlethoraMethod; 10 | import org.squiddev.plethora.api.module.IModuleContainer; 11 | import org.squiddev.plethora.gameplay.modules.PlethoraModules; 12 | 13 | /** 14 | * Provide access to a turtle's inventory via an introspection module 15 | */ 16 | public final class MethodsIntrospectionTurtle { 17 | private MethodsIntrospectionTurtle() { 18 | } 19 | 20 | @PlethoraMethod( 21 | module = PlethoraModules.INTROSPECTION_S, worldThread = false, 22 | doc = "-- Get this turtle's inventory" 23 | ) 24 | public static TypedLuaObject getInventory(IContext context, @FromSubtarget(ContextKeys.ORIGIN) ITurtleAccess turtle) { 25 | return context.makeChildId((IItemHandler) turtle.getItemHandler()).getObject(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/integration/vanilla/transfer/TransferEntityPlayerInventory.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.integration.vanilla.transfer; 2 | 3 | import com.google.common.collect.Sets; 4 | import net.minecraft.entity.player.EntityPlayer; 5 | import net.minecraftforge.items.wrapper.InvWrapper; 6 | import net.minecraftforge.items.wrapper.PlayerMainInvWrapper; 7 | import org.squiddev.plethora.api.Injects; 8 | import org.squiddev.plethora.api.transfer.ITransferProvider; 9 | 10 | import javax.annotation.Nonnull; 11 | import javax.annotation.Nullable; 12 | import java.util.Set; 13 | 14 | /** 15 | * Provides the inventory and ender chest of a player 16 | */ 17 | @Injects 18 | public final class TransferEntityPlayerInventory implements ITransferProvider { 19 | @Nullable 20 | @Override 21 | public Object getTransferLocation(@Nonnull EntityPlayer object, @Nonnull String key) { 22 | if (key.equals("inventory")) return new PlayerMainInvWrapper(object.inventory); 23 | if (key.equals("ender_chest")) return new InvWrapper(object.getInventoryEnderChest()); 24 | return null; 25 | } 26 | 27 | @Nonnull 28 | @Override 29 | public Set getTransferLocations(@Nonnull EntityPlayer object) { 30 | return Sets.newHashSet("inventory", "ender_chest"); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/integration/cbmp/IntegrationMultipart.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.integration.cbmp; 2 | 3 | import codechicken.multipart.PartMap; 4 | import codechicken.multipart.TMultiPart; 5 | import codechicken.multipart.TSlottedPart; 6 | import org.squiddev.plethora.api.Injects; 7 | import org.squiddev.plethora.api.meta.SimpleMetaProvider; 8 | 9 | import javax.annotation.Nonnull; 10 | import java.util.*; 11 | import java.util.stream.Collectors; 12 | 13 | @Injects("forgemultipartcbe") 14 | public final class IntegrationMultipart { 15 | public static final SimpleMetaProvider META_MULTIPART = IntegrationMultipart::getBasicMeta; 16 | 17 | public static final SimpleMetaProvider META_SLOTTED_PART = object -> { 18 | int slots = object.getSlotMask(); 19 | 20 | List maps = Arrays.stream(PartMap.values()) 21 | .filter(x -> (slots & x.mask) != 0) 22 | .map(x -> x.name().toLowerCase(Locale.ENGLISH)) 23 | .collect(Collectors.toList()); 24 | return Collections.singletonMap("slots", maps); 25 | }; 26 | 27 | private IntegrationMultipart() { 28 | } 29 | 30 | @Nonnull 31 | public static Map getBasicMeta(@Nonnull TMultiPart part) { 32 | return Collections.singletonMap("name", part.getType().toString()); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/gameplay/modules/glasses/objects/ItemObject.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.gameplay.modules.glasses.objects; 2 | 3 | import net.minecraft.item.Item; 4 | import org.squiddev.plethora.api.method.MethodResult; 5 | import org.squiddev.plethora.api.method.wrapper.FromTarget; 6 | import org.squiddev.plethora.api.method.wrapper.Optional; 7 | import org.squiddev.plethora.api.method.wrapper.PlethoraMethod; 8 | 9 | import javax.annotation.Nonnull; 10 | 11 | /** 12 | * An object which contains an item. 13 | */ 14 | public interface ItemObject { 15 | @Nonnull 16 | Item getItem(); 17 | 18 | void setItem(@Nonnull Item item); 19 | 20 | int getDamage(); 21 | 22 | void setDamage(int damage); 23 | 24 | @PlethoraMethod(doc = "function(): string, number -- Get the item and damage value for this object.", worldThread = false) 25 | static MethodResult getItem(@FromTarget ItemObject object) { 26 | return MethodResult.result(object.getItem().getRegistryName().toString(), object.getDamage()); 27 | } 28 | 29 | @PlethoraMethod(doc = "-- Set the item and damage value for this object.", worldThread = false) 30 | static void setItem(@FromTarget ItemObject object, Item item, @Optional(defInt = 0) int damage) { 31 | object.setItem(item); 32 | object.setDamage(damage); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/integration/vanilla/meta/MetaBlock.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.integration.vanilla.meta; 2 | 3 | import net.minecraft.block.Block; 4 | import net.minecraft.init.Blocks; 5 | import net.minecraft.util.ResourceLocation; 6 | import org.squiddev.plethora.api.Injects; 7 | import org.squiddev.plethora.api.meta.BasicMetaProvider; 8 | 9 | import javax.annotation.Nonnull; 10 | import java.util.HashMap; 11 | import java.util.Map; 12 | 13 | @Injects 14 | public final class MetaBlock extends BasicMetaProvider { 15 | public MetaBlock() { 16 | super("Provide the registry name, display name and translation key of a block."); 17 | } 18 | 19 | @Nonnull 20 | @Override 21 | public Map getMeta(@Nonnull Block block) { 22 | return getBasicMeta(block); 23 | } 24 | 25 | public static Map getBasicMeta(@Nonnull Block block) { 26 | HashMap data = new HashMap<>(3); 27 | 28 | ResourceLocation name = block.getRegistryName(); 29 | data.put("name", name == null ? "unknown" : name.toString()); 30 | 31 | data.put("displayName", block.getLocalizedName()); 32 | data.put("translationKey", block.getTranslationKey()); 33 | 34 | return data; 35 | } 36 | 37 | @Override 38 | public Block getExample() { 39 | return Blocks.DIRT; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/integration/appliedenergistics/MetaItemPattern.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.integration.appliedenergistics; 2 | 3 | import appeng.api.implementations.ICraftingPatternItem; 4 | import appeng.core.AppEng; 5 | import net.minecraft.item.ItemStack; 6 | import org.squiddev.plethora.api.IWorldLocation; 7 | import org.squiddev.plethora.api.Injects; 8 | import org.squiddev.plethora.api.meta.ItemStackContextMetaProvider; 9 | import org.squiddev.plethora.api.method.ContextKeys; 10 | import org.squiddev.plethora.api.method.IPartialContext; 11 | 12 | import javax.annotation.Nonnull; 13 | import java.util.Collections; 14 | import java.util.Map; 15 | 16 | @Injects(AppEng.MOD_ID) 17 | public final class MetaItemPattern extends ItemStackContextMetaProvider { 18 | public MetaItemPattern() { 19 | super("pattern", ICraftingPatternItem.class); 20 | } 21 | 22 | @Nonnull 23 | @Override 24 | public Map getMeta(@Nonnull IPartialContext context, @Nonnull ICraftingPatternItem pattern) { 25 | IWorldLocation position = context.getContext(ContextKeys.ORIGIN, IWorldLocation.class); 26 | return position != null 27 | ? context.makePartialChild(pattern.getPatternForItem(context.getTarget(), position.getWorld())).getMeta() 28 | : Collections.emptyMap(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/utils/ByteBufUtils.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.utils; 2 | 3 | import io.netty.buffer.ByteBuf; 4 | import net.minecraft.util.math.Vec3d; 5 | 6 | import javax.annotation.Nonnull; 7 | import javax.annotation.Nullable; 8 | 9 | public class ByteBufUtils extends net.minecraftforge.fml.common.network.ByteBufUtils { 10 | public static void writeVec3d(ByteBuf buf, @Nonnull Vec3d vec) { 11 | buf.writeFloat((float) vec.x); 12 | buf.writeFloat((float) vec.y); 13 | buf.writeFloat((float) vec.z); 14 | } 15 | 16 | @Nonnull 17 | public static Vec3d readVec3d(ByteBuf buf) { 18 | return new Vec3d(buf.readFloat(), buf.readFloat(), buf.readFloat()); 19 | } 20 | 21 | public static void writeOptVec3d(ByteBuf buf, @Nullable Vec3d vec) { 22 | if (vec == null) { 23 | buf.writeBoolean(false); 24 | } else { 25 | buf.writeBoolean(true); 26 | writeVec3d(buf, vec); 27 | } 28 | } 29 | 30 | @Nullable 31 | public static Vec3d readOptVec3d(ByteBuf buf) { 32 | return buf.readBoolean() ? readVec3d(buf) : null; 33 | } 34 | 35 | public static void writeVec2d(ByteBuf buf, Vec2d vec) { 36 | buf.writeFloat((float) vec.x); 37 | buf.writeFloat((float) vec.y); 38 | } 39 | 40 | public static Vec2d readVec2d(ByteBuf buf) { 41 | return new Vec2d(buf.readFloat(), buf.readFloat()); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/core/collections/SortedMultimap.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.core.collections; 2 | 3 | import java.util.*; 4 | 5 | public final class SortedMultimap { 6 | private final Comparator comparator; 7 | private final HashMap> items = new HashMap<>(); 8 | 9 | public SortedMultimap(Comparator comparator) { 10 | this.comparator = comparator; 11 | } 12 | 13 | public void clear() { 14 | items.clear(); 15 | } 16 | 17 | public void put(K key, V value) { 18 | SortedCollection targetItems = items.get(key); 19 | if (targetItems == null) { 20 | targetItems = SortedCollection.create(comparator); 21 | items.put(key, targetItems); 22 | } 23 | 24 | targetItems.add(value); 25 | } 26 | 27 | public Collection get(K key) { 28 | Collection result = items.get(key); 29 | return result == null ? Collections.emptyList() : result; 30 | } 31 | 32 | public static SortedMultimap create(Comparator comparator) { 33 | return new SortedMultimap<>(comparator); 34 | } 35 | 36 | public Map> items() { 37 | return Collections.unmodifiableMap(items); 38 | } 39 | 40 | public int size() { 41 | int size = 0; 42 | for (SortedCollection collection : items.values()) size += collection.size(); 43 | return size; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/gameplay/modules/RangeInfo.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.gameplay.modules; 2 | 3 | import org.squiddev.plethora.api.reference.ConstantReference; 4 | 5 | import javax.annotation.Nonnull; 6 | import java.util.function.IntUnaryOperator; 7 | 8 | /** 9 | * Provides the range for a {@link PlethoraModules#SENSOR} or {@link PlethoraModules#SCANNER} 10 | */ 11 | public interface RangeInfo extends ConstantReference { 12 | /** 13 | * The maximum range this module operates at. 14 | * 15 | * @return This module's range. 16 | */ 17 | int getRange(); 18 | 19 | /** 20 | * The cost for some bulk operation (sense/scan). 21 | * 22 | * @return The cost of a bulk operation. 23 | * @see org.squiddev.plethora.api.method.ICostHandler 24 | */ 25 | int getBulkCost(); 26 | 27 | @Nonnull 28 | @Override 29 | default RangeInfo get() { 30 | return this; 31 | } 32 | 33 | @Nonnull 34 | @Override 35 | default RangeInfo safeGet() { 36 | return this; 37 | } 38 | 39 | static RangeInfo of(int level, IntUnaryOperator cost, IntUnaryOperator range) { 40 | return new RangeInfo() { 41 | @Override 42 | public int getRange() { 43 | return range.applyAsInt(level); 44 | } 45 | 46 | @Override 47 | public int getBulkCost() { 48 | return cost.applyAsInt(level); 49 | } 50 | }; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/api/reference/IReference.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.api.reference; 2 | 3 | import dan200.computercraft.api.lua.LuaException; 4 | 5 | import javax.annotation.Nonnull; 6 | 7 | /** 8 | * A reference to an object 9 | */ 10 | public interface IReference { 11 | /** 12 | * Get the object if it still exists. 13 | * 14 | * Note, this method is NOT thread safe and MUST be called from the server thread. Use {@link #safeGet()} if 15 | * you need a safe version. 16 | * 17 | * @return The object if it still exists 18 | * @throws LuaException if the object doesn't exist 19 | */ 20 | @Nonnull 21 | T get() throws LuaException; 22 | 23 | /** 24 | * Get the object if it still exists. 25 | * 26 | * This method MUST be thread safe, though the result object may not be safe to use on any thread. You should 27 | * always use {@link #get()} if calling from the server thread. 28 | * 29 | * @return The object if it still exists 30 | * @throws LuaException if the object doesn't exist 31 | */ 32 | @Nonnull 33 | T safeGet() throws LuaException; 34 | 35 | /** 36 | * Whether this reference will always return the same object (or an equivalent one). 37 | * 38 | * @return If this reference is constant. 39 | * @see ConstantReference 40 | * @see DynamicReference 41 | */ 42 | boolean isConstant(); 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/integration/cbmp/ReferenceMultipart.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.integration.cbmp; 2 | 3 | import codechicken.multipart.TMultiPart; 4 | import codechicken.multipart.TileMultipart; 5 | import dan200.computercraft.api.lua.LuaException; 6 | import net.minecraft.util.math.BlockPos; 7 | import net.minecraft.world.World; 8 | import org.squiddev.plethora.api.reference.DynamicReference; 9 | 10 | import javax.annotation.Nonnull; 11 | 12 | public class ReferenceMultipart implements DynamicReference { 13 | private final TMultiPart part; 14 | private final TileMultipart container; 15 | 16 | public ReferenceMultipart(TileMultipart container, TMultiPart part) { 17 | this.container = container; 18 | this.part = part; 19 | } 20 | 21 | @Nonnull 22 | @Override 23 | public TMultiPart get() throws LuaException { 24 | TileMultipart tile = part.tile(); 25 | if (tile != container) throw new LuaException("Part is no longer there"); 26 | 27 | World world = tile.getWorld(); 28 | BlockPos pos = tile.getPos(); 29 | 30 | if (world == null || pos == null || !world.isBlockLoaded(pos) || world.getTileEntity(pos) != tile) { 31 | throw new LuaException("Part is no longer there"); 32 | } 33 | 34 | return part; 35 | } 36 | 37 | @Nonnull 38 | @Override 39 | public TMultiPart safeGet() { 40 | return part; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/api/method/CostHelpers.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.api.method; 2 | 3 | import net.minecraft.util.EnumFacing; 4 | import net.minecraftforge.common.capabilities.ICapabilityProvider; 5 | import org.squiddev.plethora.api.PlethoraAPI; 6 | 7 | import javax.annotation.Nonnull; 8 | import javax.annotation.Nullable; 9 | 10 | /** 11 | * Various helper methods for costs 12 | */ 13 | public final class CostHelpers { 14 | private CostHelpers() { 15 | throw new IllegalStateException("Cannot instantiate singleton " + getClass().getName()); 16 | } 17 | 18 | /** 19 | * Get the cost handler for this object 20 | * 21 | * @param object The cost handler's owner 22 | * @return The associated cost handler 23 | */ 24 | @Nonnull 25 | public static ICostHandler getCostHandler(@Nonnull ICapabilityProvider object) { 26 | return PlethoraAPI.instance().methodRegistry().getCostHandler(object, null); 27 | } 28 | 29 | /** 30 | * Get the cost handler for this object 31 | * 32 | * @param object The cost handler's owner 33 | * @param side The side to get the cost handler from. 34 | * @return The associated cost handler 35 | */ 36 | @Nonnull 37 | public static ICostHandler getCostHandler(@Nonnull ICapabilityProvider object, @Nullable EnumFacing side) { 38 | return PlethoraAPI.instance().methodRegistry().getCostHandler(object, side); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/api/module/ModuleContainerMethod.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.api.module; 2 | 3 | import com.google.common.base.Preconditions; 4 | import net.minecraft.util.ResourceLocation; 5 | import org.squiddev.plethora.api.method.BasicMethod; 6 | import org.squiddev.plethora.api.method.IPartialContext; 7 | 8 | import javax.annotation.Nonnull; 9 | import java.util.Collection; 10 | import java.util.Set; 11 | 12 | /** 13 | * A method that requires a module to execute. 14 | */ 15 | public abstract class ModuleContainerMethod extends BasicMethod { 16 | private final Set modules; 17 | 18 | public ModuleContainerMethod(String name, Set modules, int priority, String doc) { 19 | super(name, priority, doc); 20 | Preconditions.checkArgument(!modules.isEmpty(), "modules must be non-empty"); 21 | this.modules = modules; 22 | } 23 | 24 | @Override 25 | public boolean canApply(@Nonnull IPartialContext context) { 26 | if (!super.canApply(context)) return false; 27 | 28 | IModuleContainer container = context.getTarget(); 29 | for (ResourceLocation module : modules) { 30 | if (!container.hasModule(module)) return false; 31 | } 32 | 33 | return true; 34 | } 35 | 36 | @Nonnull 37 | @Override 38 | public Collection getModules() { 39 | return modules; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/integration/MethodMeta.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.integration; 2 | 3 | import org.squiddev.plethora.api.Injects; 4 | import org.squiddev.plethora.api.PlethoraAPI; 5 | import org.squiddev.plethora.api.meta.IMetaRegistry; 6 | import org.squiddev.plethora.api.method.*; 7 | 8 | import javax.annotation.Nonnull; 9 | 10 | @Injects 11 | public final class MethodMeta extends BasicMethod implements IConverterExcludeMethod { 12 | public MethodMeta() { 13 | super("getMetadata", Integer.MIN_VALUE, "function():table -- Get metadata about this object"); 14 | } 15 | 16 | @Override 17 | public boolean canApply(@Nonnull IPartialContext context) { 18 | IMetaRegistry registry = PlethoraAPI.instance().metaRegistry(); 19 | Object target = context.getTarget(); 20 | 21 | if (!registry.getMetaProviders(target.getClass()).isEmpty()) return true; 22 | 23 | // Convert all and check if any matches 24 | for (Object converted : PlethoraAPI.instance().converterRegistry().convertAll(target)) { 25 | if (!registry.getMetaProviders(converted.getClass()).isEmpty()) return true; 26 | } 27 | 28 | return false; 29 | } 30 | 31 | @Nonnull 32 | @Override 33 | public MethodResult apply(@Nonnull IUnbakedContext context, @Nonnull Object[] args) { 34 | return MethodResult.nextTick(() -> MethodResult.result(context.bake().getMeta())); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/core/capabilities/DefaultVehicleUpgradeHandler.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.core.capabilities; 2 | 3 | import dan200.computercraft.api.peripheral.IPeripheral; 4 | import net.minecraft.client.renderer.block.model.IBakedModel; 5 | import net.minecraftforge.fml.relauncher.Side; 6 | import net.minecraftforge.fml.relauncher.SideOnly; 7 | import org.apache.commons.lang3.tuple.Pair; 8 | import org.squiddev.plethora.api.vehicle.IVehicleAccess; 9 | import org.squiddev.plethora.api.vehicle.IVehicleUpgradeHandler; 10 | 11 | import javax.annotation.Nonnull; 12 | import javax.annotation.Nullable; 13 | import javax.vecmath.Matrix4f; 14 | 15 | import static org.squiddev.plethora.gameplay.client.RenderHelpers.getIdentity; 16 | import static org.squiddev.plethora.gameplay.client.RenderHelpers.getMesher; 17 | 18 | public class DefaultVehicleUpgradeHandler implements IVehicleUpgradeHandler { 19 | @Nonnull 20 | @Override 21 | @SideOnly(Side.CLIENT) 22 | public Pair getModel(@Nonnull IVehicleAccess access) { 23 | return Pair.of(getMesher().getModelManager().getMissingModel(), getIdentity()); 24 | } 25 | 26 | @Override 27 | public void update(@Nonnull IVehicleAccess vehicle, @Nonnull IPeripheral peripheral) { 28 | } 29 | 30 | @Nullable 31 | @Override 32 | public IPeripheral create(@Nonnull IVehicleAccess vehicle) { 33 | return null; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/integration/vanilla/meta/MetaItemMaterial.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.integration.vanilla.meta; 2 | 3 | import net.minecraft.init.Items; 4 | import net.minecraft.item.*; 5 | import org.squiddev.plethora.api.Injects; 6 | import org.squiddev.plethora.api.meta.BasicMetaProvider; 7 | 8 | import javax.annotation.Nonnull; 9 | import java.util.Collections; 10 | import java.util.Map; 11 | 12 | /** 13 | * Displays tool's material 14 | */ 15 | @Injects 16 | public final class MetaItemMaterial extends BasicMetaProvider { 17 | @Nonnull 18 | @Override 19 | public Map getMeta(@Nonnull ItemStack stack) { 20 | String name = getName(stack); 21 | return name != null ? Collections.singletonMap("material", name) : Collections.emptyMap(); 22 | 23 | } 24 | 25 | private static String getName(@Nonnull ItemStack stack) { 26 | Item item = stack.getItem(); 27 | if (item instanceof ItemTool) { 28 | return ((ItemTool) item).getToolMaterialName(); 29 | } else if (item instanceof ItemSword) { 30 | return ((ItemSword) item).getToolMaterialName(); 31 | } else if (item instanceof ItemArmor) { 32 | return ((ItemArmor) item).getArmorMaterial().toString(); 33 | } else { 34 | return null; 35 | } 36 | } 37 | 38 | @Nonnull 39 | @Override 40 | public ItemStack getExample() { 41 | return new ItemStack(Items.DIAMOND_PICKAXE); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/integration/rf/MetaEnergyProvider.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.integration.rf; 2 | 3 | import cofh.redstoneflux.RedstoneFluxProps; 4 | import cofh.redstoneflux.api.IEnergyHandler; 5 | import net.minecraft.util.EnumFacing; 6 | import org.squiddev.plethora.api.Injects; 7 | import org.squiddev.plethora.api.meta.BasicMetaProvider; 8 | 9 | import javax.annotation.Nonnull; 10 | import java.util.Collections; 11 | import java.util.HashMap; 12 | import java.util.Map; 13 | 14 | @Injects(RedstoneFluxProps.MOD_ID) 15 | public final class MetaEnergyProvider extends BasicMetaProvider { 16 | @Nonnull 17 | @Override 18 | public Map getMeta(@Nonnull IEnergyHandler object) { 19 | Map out = new HashMap<>(2); 20 | out.put("stored", object.getEnergyStored(null)); 21 | out.put("capacity", object.getMaxEnergyStored(null)); 22 | return Collections.singletonMap("rf", out); 23 | } 24 | 25 | @Nonnull 26 | @Override 27 | public IEnergyHandler getExample() { 28 | return new IEnergyHandler() { 29 | @Override 30 | public int getEnergyStored(EnumFacing from) { 31 | return 0; 32 | } 33 | 34 | @Override 35 | public int getMaxEnergyStored(EnumFacing from) { 36 | return 1000; 37 | } 38 | 39 | @Override 40 | public boolean canConnectEnergy(EnumFacing from) { 41 | return false; 42 | } 43 | }; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/api/PlethoraGameplayAPI.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.api; 2 | 3 | import org.squiddev.plethora.api.neural.INeuralRegistry; 4 | 5 | /** 6 | * API entry point for Plethora 7 | */ 8 | public final class PlethoraGameplayAPI { 9 | private PlethoraGameplayAPI() { 10 | } 11 | 12 | public interface IPlethoraGameplayAPI { 13 | INeuralRegistry neuralRegistry(); 14 | } 15 | 16 | private static final IPlethoraGameplayAPI API; 17 | 18 | /** 19 | * Get the main API entry point 20 | * 21 | * @return Main API entry point 22 | */ 23 | public static IPlethoraGameplayAPI instance() { 24 | return API; 25 | } 26 | 27 | static { 28 | IPlethoraGameplayAPI api; 29 | final String name = "org.squiddev.plethora.gameplay.API"; 30 | try { 31 | Class registryClass = Class.forName(name); 32 | api = (IPlethoraGameplayAPI) registryClass.newInstance(); 33 | } catch (ClassNotFoundException e) { 34 | throw new CoreNotFoundException("Cannot load Plethora Gameplay API as " + name + " cannot be found", e); 35 | } catch (InstantiationException e) { 36 | throw new CoreNotFoundException("Cannot load Plethora Gameplay API as " + name + " cannot be created", e); 37 | } catch (IllegalAccessException e) { 38 | throw new CoreNotFoundException("Cannot load Plethora Gameplay API as " + name + " cannot be accessed", e); 39 | } 40 | API = api; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/api/module/SingletonModuleContainer.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.api.module; 2 | 3 | import net.minecraft.util.ResourceLocation; 4 | 5 | import javax.annotation.Nonnull; 6 | import java.util.Collections; 7 | import java.util.Objects; 8 | import java.util.Set; 9 | 10 | /** 11 | * A module container which only contains one item. 12 | */ 13 | public class SingletonModuleContainer implements IModuleContainer { 14 | private final ResourceLocation thisModule; 15 | private final Set modules; 16 | 17 | public SingletonModuleContainer(@Nonnull ResourceLocation module) { 18 | Objects.requireNonNull(module, "module cannot be null"); 19 | thisModule = module; 20 | modules = Collections.singleton(module); 21 | } 22 | 23 | @Override 24 | public boolean hasModule(@Nonnull ResourceLocation module) { 25 | return thisModule.equals(module); 26 | } 27 | 28 | @Nonnull 29 | @Override 30 | public Set getModules() { 31 | return modules; 32 | } 33 | 34 | @Override 35 | public boolean equals(Object o) { 36 | if (this == o) return true; 37 | if (o == null || getClass() != o.getClass()) return false; 38 | 39 | SingletonModuleContainer that = (SingletonModuleContainer) o; 40 | 41 | return thisModule.equals(that.thisModule); 42 | } 43 | 44 | @Override 45 | public int hashCode() { 46 | return thisModule.hashCode(); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/integration/vanilla/meta/MetaItemArmor.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.integration.vanilla.meta; 2 | 3 | import net.minecraft.init.Items; 4 | import net.minecraft.item.ItemArmor; 5 | import net.minecraft.item.ItemStack; 6 | import org.squiddev.plethora.api.Injects; 7 | import org.squiddev.plethora.api.meta.ItemStackMetaProvider; 8 | 9 | import javax.annotation.Nonnull; 10 | import java.util.HashMap; 11 | import java.util.Map; 12 | 13 | /** 14 | * Meta provider for amour properties. Material is handled in {@link MetaItemMaterial}. 15 | */ 16 | @Injects 17 | public final class MetaItemArmor extends ItemStackMetaProvider { 18 | public MetaItemArmor() { 19 | super(ItemArmor.class, "Provides type and colour of amour."); 20 | } 21 | 22 | @Nonnull 23 | @Override 24 | public Map getMeta(@Nonnull ItemStack stack, @Nonnull ItemArmor armor) { 25 | HashMap data = new HashMap<>(3); 26 | data.put("armorType", armor.armorType.getName()); 27 | 28 | int color = armor.getColor(stack); 29 | if (color >= 0) { 30 | data.put("color", color); 31 | data.put("colour", color); 32 | } 33 | 34 | return data; 35 | } 36 | 37 | @Nonnull 38 | @Override 39 | public ItemStack getExample() { 40 | ItemStack stack = new ItemStack(Items.LEATHER_CHESTPLATE); 41 | Items.LEATHER_CHESTPLATE.setColor(stack, 0xFF0000); 42 | return stack; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/integration/baubles/MethodIntrospectionBaublesInventory.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.integration.baubles; 2 | 3 | import baubles.api.BaublesApi; 4 | import baubles.common.Baubles; 5 | import dan200.computercraft.api.lua.LuaException; 6 | import net.minecraftforge.items.IItemHandler; 7 | import org.squiddev.plethora.api.method.IContext; 8 | import org.squiddev.plethora.api.method.TypedLuaObject; 9 | import org.squiddev.plethora.api.method.wrapper.FromSubtarget; 10 | import org.squiddev.plethora.api.method.wrapper.PlethoraMethod; 11 | import org.squiddev.plethora.api.module.IModuleContainer; 12 | import org.squiddev.plethora.gameplay.modules.PlethoraModules; 13 | import org.squiddev.plethora.integration.EntityIdentifier; 14 | 15 | /** 16 | * Allows getting the player's baubles inventory 17 | */ 18 | public final class MethodIntrospectionBaublesInventory { 19 | private MethodIntrospectionBaublesInventory() { 20 | } 21 | 22 | @PlethoraMethod( 23 | module = PlethoraModules.INTROSPECTION_S, modId = Baubles.MODID, 24 | doc = "-- Get this player's baubles inventory" 25 | ) 26 | public static TypedLuaObject getBaubles(IContext context, @FromSubtarget EntityIdentifier.Player player) throws LuaException { 27 | IItemHandler inventory = BaublesApi.getBaublesHandler(player.getPlayer()); 28 | return context.makeChildId(inventory).getObject(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/integration/vanilla/converter/ConverterTileModule.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.integration.vanilla.converter; 2 | 3 | import net.minecraft.tileentity.TileEntity; 4 | import org.squiddev.plethora.api.Constants; 5 | import org.squiddev.plethora.api.Injects; 6 | import org.squiddev.plethora.api.converter.DynamicConverter; 7 | import org.squiddev.plethora.api.module.IModuleContainer; 8 | import org.squiddev.plethora.api.module.IModuleHandler; 9 | import org.squiddev.plethora.api.module.SingletonModuleContainer; 10 | import org.squiddev.plethora.core.ConfigCore; 11 | 12 | import javax.annotation.Nonnull; 13 | import javax.annotation.Nullable; 14 | 15 | @Injects 16 | public final class ConverterTileModule implements DynamicConverter { 17 | @Nullable 18 | @Override 19 | public IModuleContainer convert(@Nonnull TileEntity from) { 20 | if (!from.hasCapability(Constants.MODULE_HANDLER_CAPABILITY, null)) return null; 21 | 22 | IModuleHandler handler = from.getCapability(Constants.MODULE_HANDLER_CAPABILITY, null); 23 | if (handler == null) return null; 24 | 25 | String moduleName = handler.getModule().toString(); 26 | if (ConfigCore.Blacklist.blacklistModules.contains(moduleName) || ConfigCore.Blacklist.blacklistModulesTile.contains(moduleName)) { 27 | return null; 28 | } 29 | 30 | return new SingletonModuleContainer(handler.getModule()); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/core/capabilities/DefaultModuleHandler.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.core.capabilities; 2 | 3 | import net.minecraft.client.renderer.block.model.IBakedModel; 4 | import net.minecraft.util.ResourceLocation; 5 | import net.minecraftforge.fml.relauncher.Side; 6 | import net.minecraftforge.fml.relauncher.SideOnly; 7 | import org.apache.commons.lang3.tuple.Pair; 8 | import org.squiddev.plethora.api.module.AbstractModuleHandler; 9 | import org.squiddev.plethora.gameplay.Plethora; 10 | 11 | import javax.annotation.Nonnull; 12 | import javax.vecmath.Matrix4f; 13 | 14 | import static org.squiddev.plethora.gameplay.client.RenderHelpers.getIdentity; 15 | import static org.squiddev.plethora.gameplay.client.RenderHelpers.getMesher; 16 | 17 | /** 18 | * The default module handler: named "plethora:default_module". Uses a missing model. 19 | * 20 | * This is just a stub for the capability. 21 | */ 22 | public final class DefaultModuleHandler extends AbstractModuleHandler { 23 | private static final ResourceLocation name = new ResourceLocation(Plethora.ID, "default_module"); 24 | 25 | @Nonnull 26 | @Override 27 | public ResourceLocation getModule() { 28 | return name; 29 | } 30 | 31 | @Nonnull 32 | @Override 33 | @SideOnly(Side.CLIENT) 34 | public Pair getModel(float delta) { 35 | return Pair.of(getMesher().getModelManager().getMissingModel(), getIdentity()); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/api/vehicle/IVehicleUpgradeHandler.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.api.vehicle; 2 | 3 | import dan200.computercraft.api.peripheral.IPeripheral; 4 | import net.minecraft.client.renderer.block.model.IBakedModel; 5 | import net.minecraft.item.ItemStack; 6 | import net.minecraftforge.fml.relauncher.Side; 7 | import net.minecraftforge.fml.relauncher.SideOnly; 8 | import org.apache.commons.lang3.tuple.Pair; 9 | 10 | import javax.annotation.Nonnull; 11 | import javax.annotation.Nullable; 12 | import javax.vecmath.Matrix4f; 13 | 14 | /** 15 | * A capability which provides an upgrade to various vehicles. 16 | */ 17 | public interface IVehicleUpgradeHandler { 18 | /** 19 | * Get a model from this stack 20 | * 21 | * @param access The vehicle access 22 | * @return A baked model and its transformation 23 | * @see net.minecraft.client.renderer.ItemModelMesher#getItemModel(ItemStack) 24 | */ 25 | @Nonnull 26 | @SideOnly(Side.CLIENT) 27 | Pair getModel(@Nonnull IVehicleAccess access); 28 | 29 | /** 30 | * Update the vehicle handler for the specific 31 | */ 32 | void update(@Nonnull IVehicleAccess vehicle, @Nonnull IPeripheral peripheral); 33 | 34 | /** 35 | * Create a peripheral from the given vehicle 36 | * 37 | * @return The peripheral to create, or {@code null} if none should be created. 38 | */ 39 | @Nullable 40 | IPeripheral create(@Nonnull IVehicleAccess vehicle); 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/integration/plethora/MetaItemModule.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.integration.plethora; 2 | 3 | import com.mojang.authlib.GameProfile; 4 | import net.minecraft.item.ItemStack; 5 | import org.squiddev.plethora.api.Injects; 6 | import org.squiddev.plethora.api.meta.ItemStackMetaProvider; 7 | import org.squiddev.plethora.gameplay.Plethora; 8 | import org.squiddev.plethora.gameplay.modules.ItemModule; 9 | import org.squiddev.plethora.gameplay.registry.Registration; 10 | 11 | import javax.annotation.Nonnull; 12 | import java.util.HashMap; 13 | import java.util.Map; 14 | 15 | @Injects(Plethora.ID) 16 | public final class MetaItemModule extends ItemStackMetaProvider { 17 | public MetaItemModule() { 18 | super(ItemModule.class); 19 | } 20 | 21 | @Nonnull 22 | @Override 23 | public Map getMeta(@Nonnull ItemStack stack, @Nonnull ItemModule module) { 24 | Map result = new HashMap<>(); 25 | 26 | GameProfile profile = ItemModule.getProfile(stack); 27 | if (profile != null) { 28 | Map bound = new HashMap<>(); 29 | result.put("bound", bound); 30 | 31 | if (profile.getId() != null) bound.put("id", profile.getId().toString()); 32 | bound.put("name", profile.getName()); 33 | } 34 | 35 | return result; 36 | } 37 | 38 | @Nonnull 39 | @Override 40 | public ItemStack getExample() { 41 | return new ItemStack(Registration.itemModule); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/utils/TinySlot.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.utils; 2 | 3 | import baubles.api.cap.IBaublesItemHandler; 4 | import net.minecraft.inventory.IInventory; 5 | import net.minecraft.item.ItemStack; 6 | 7 | import javax.annotation.Nonnull; 8 | import java.util.Objects; 9 | 10 | public class TinySlot { 11 | private final ItemStack stack; 12 | 13 | public TinySlot(@Nonnull ItemStack stack) { 14 | Objects.requireNonNull(stack, "stack cannot be null"); 15 | this.stack = stack; 16 | } 17 | 18 | @Nonnull 19 | public ItemStack getStack() { 20 | return stack; 21 | } 22 | 23 | public void markDirty() { 24 | } 25 | 26 | public static class InventorySlot extends TinySlot { 27 | private final IInventory inventory; 28 | 29 | public InventorySlot(@Nonnull ItemStack stack, @Nonnull IInventory inventory) { 30 | super(stack); 31 | this.inventory = inventory; 32 | } 33 | 34 | @Override 35 | public void markDirty() { 36 | inventory.markDirty(); 37 | } 38 | } 39 | 40 | public static class BaublesSlot extends TinySlot { 41 | private final IBaublesItemHandler handler; 42 | private final int slot; 43 | 44 | public BaublesSlot(@Nonnull ItemStack stack, @Nonnull IBaublesItemHandler handler, int slot) { 45 | super(stack); 46 | this.handler = handler; 47 | this.slot = slot; 48 | } 49 | 50 | @Override 51 | public void markDirty() { 52 | handler.setChanged(slot, true); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/api/method/IContextBuilder.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.api.method; 2 | 3 | import org.squiddev.plethora.api.IAttachable; 4 | import org.squiddev.plethora.api.reference.IReference; 5 | 6 | import javax.annotation.Nonnull; 7 | 8 | /** 9 | * Methods to "augment" the current context 10 | */ 11 | public interface IContextBuilder { 12 | /** 13 | * Add an additional object to the current context. 14 | * 15 | * @param key The context key to insert under. 16 | * @param baked The object that this reference will return 17 | * @param reference A reference to this object 18 | * @return The current {@link IContextBuilder}. 19 | */ 20 | @Nonnull 21 | IContextBuilder addContext(@Nonnull String key, @Nonnull T baked, @Nonnull IReference reference); 22 | 23 | /** 24 | * Add an additional object to the current context. 25 | * 26 | * @param key The context key to insert under. 27 | * @param object The object 28 | * @return The current {@link IContextFactory}. 29 | */ 30 | @Nonnull 31 | > IContextBuilder addContext(@Nonnull String key, @Nonnull T object); 32 | 33 | /** 34 | * Add an an attachment listener 35 | * 36 | * @param attachable An attachable object which listens to when the resulting object is attached. 37 | * @return The current {@link IContextBuilder}. 38 | */ 39 | @Nonnull 40 | IContextBuilder addAttachable(@Nonnull IAttachable attachable); 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/core/MethodWrapperLuaObject.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.core; 2 | 3 | import dan200.computercraft.api.lua.ILuaContext; 4 | import dan200.computercraft.api.lua.ILuaObject; 5 | import dan200.computercraft.api.lua.LuaException; 6 | import org.apache.commons.lang3.tuple.Pair; 7 | import org.squiddev.plethora.api.method.IUnbakedContext; 8 | import org.squiddev.plethora.api.method.MethodResult; 9 | import org.squiddev.plethora.api.method.TypedLuaObject; 10 | 11 | import javax.annotation.Nonnull; 12 | import java.util.List; 13 | 14 | /** 15 | * Handles integration with a {@link ILuaObject}. 16 | */ 17 | public class MethodWrapperLuaObject extends MethodWrapper implements TypedLuaObject { 18 | public MethodWrapperLuaObject(List> methods, List> contexts) { 19 | super(methods, contexts); 20 | } 21 | 22 | public MethodWrapperLuaObject(Pair>, List>> contexts) { 23 | super(contexts.getLeft(), contexts.getRight()); 24 | } 25 | 26 | @Override 27 | public Object[] callMethod(@Nonnull ILuaContext luaContext, int method, @Nonnull final Object[] args) throws LuaException, InterruptedException { 28 | UnbakedContext context = getContext(method); 29 | @SuppressWarnings("unchecked") 30 | MethodResult result = getMethod(method).call((IUnbakedContext) context, args); 31 | return context.getExecutor().execute(result, luaContext); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/gameplay/ItemBase.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.gameplay; 2 | 3 | import net.minecraft.client.util.ITooltipFlag; 4 | import net.minecraft.item.Item; 5 | import net.minecraft.item.ItemStack; 6 | import net.minecraft.nbt.NBTTagCompound; 7 | import net.minecraft.util.ResourceLocation; 8 | import net.minecraft.world.World; 9 | import net.minecraftforge.fml.relauncher.Side; 10 | import net.minecraftforge.fml.relauncher.SideOnly; 11 | import org.squiddev.plethora.utils.Helpers; 12 | 13 | import java.util.List; 14 | 15 | public abstract class ItemBase extends Item { 16 | 17 | public ItemBase(String itemName, int stackSize) { 18 | setTranslationKey(Plethora.RESOURCE_DOMAIN + "." + itemName); 19 | setRegistryName(new ResourceLocation(Plethora.ID, itemName)); 20 | 21 | setCreativeTab(Plethora.getCreativeTab()); 22 | setMaxStackSize(stackSize); 23 | } 24 | 25 | public ItemBase(String itemName) { 26 | this(itemName, 64); 27 | } 28 | 29 | public static NBTTagCompound getTag(ItemStack stack) { 30 | NBTTagCompound tag = stack.getTagCompound(); 31 | if (tag == null) stack.setTagCompound(tag = new NBTTagCompound()); 32 | return tag; 33 | } 34 | 35 | @Override 36 | @SideOnly(Side.CLIENT) 37 | public void addInformation(ItemStack stack, World world, List out, ITooltipFlag flag) { 38 | super.addInformation(stack, world, out, flag); 39 | out.add(Helpers.translateToLocal(getTranslationKey(stack) + ".desc")); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/api/module/IModuleHandler.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.api.module; 2 | 3 | import net.minecraft.client.renderer.block.model.IBakedModel; 4 | import net.minecraft.item.ItemStack; 5 | import net.minecraft.util.ResourceLocation; 6 | import net.minecraftforge.fml.relauncher.Side; 7 | import net.minecraftforge.fml.relauncher.SideOnly; 8 | import org.apache.commons.lang3.tuple.Pair; 9 | import org.squiddev.plethora.api.method.IContextBuilder; 10 | 11 | import javax.annotation.Nonnull; 12 | import javax.vecmath.Matrix4f; 13 | 14 | /** 15 | * A capability which provides a module 16 | */ 17 | public interface IModuleHandler { 18 | /** 19 | * Get the module from this item 20 | * 21 | * @return The module. 22 | */ 23 | @Nonnull 24 | ResourceLocation getModule(); 25 | 26 | /** 27 | * Used to get additional context from a stack 28 | * 29 | * @param access The module access we are using. 30 | * @param builder The builder to add additional context to. 31 | */ 32 | void getAdditionalContext(@Nonnull IModuleAccess access, @Nonnull IContextBuilder builder); 33 | 34 | /** 35 | * Get a model from this stack 36 | * 37 | * @param delta A tick based offset. Can used to animate the model. 38 | * @return A baked model and its transformation 39 | * @see net.minecraft.client.renderer.ItemModelMesher#getItemModel(ItemStack) 40 | */ 41 | @Nonnull 42 | @SideOnly(Side.CLIENT) 43 | Pair getModel(float delta); 44 | } 45 | -------------------------------------------------------------------------------- /src/main/resources/assets/plethora/blockstates/manipulator.json: -------------------------------------------------------------------------------- 1 | { 2 | "variants": { 3 | "facing=down,type=mark_1": { 4 | "model": "plethora:manipulator.mark_1" 5 | }, 6 | "facing=down,type=mark_2": { 7 | "model": "plethora:manipulator.mark_2" 8 | }, 9 | "facing=up,type=mark_1": { 10 | "model": "plethora:manipulator.mark_1", 11 | "x": 180 12 | }, 13 | "facing=up,type=mark_2": { 14 | "model": "plethora:manipulator.mark_2", 15 | "x": 180 16 | }, 17 | "facing=east,type=mark_1": { 18 | "model": "plethora:manipulator.mark_1", 19 | "x": 90, 20 | "y": 270 21 | }, 22 | "facing=east,type=mark_2": { 23 | "model": "plethora:manipulator.mark_2", 24 | "x": 90, 25 | "y": 270 26 | }, 27 | "facing=west,type=mark_1": { 28 | "model": "plethora:manipulator.mark_1", 29 | "x": 90, 30 | "y": 90 31 | }, 32 | "facing=west,type=mark_2": { 33 | "model": "plethora:manipulator.mark_2", 34 | "x": 90, 35 | "y": 90 36 | }, 37 | "facing=north,type=mark_1": { 38 | "model": "plethora:manipulator.mark_1", 39 | "x": 90, 40 | "y": 180 41 | }, 42 | "facing=north,type=mark_2": { 43 | "model": "plethora:manipulator.mark_2", 44 | "x": 90, 45 | "y": 180 46 | }, 47 | "facing=south,type=mark_1": { 48 | "model": "plethora:manipulator.mark_1", 49 | "x": 90, 50 | "y": 0 51 | }, 52 | "facing=south,type=mark_2": { 53 | "model": "plethora:manipulator.mark_2", 54 | "x": 90, 55 | "y": 0 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/core/collections/ClassIteratorIterable.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.core.collections; 2 | 3 | import com.google.common.collect.Queues; 4 | 5 | import javax.annotation.Nonnull; 6 | import java.util.HashSet; 7 | import java.util.Iterator; 8 | import java.util.Queue; 9 | 10 | /** 11 | * A iterator which loops through all the subclasses/subinterfaces of an object. 12 | */ 13 | public class ClassIteratorIterable implements Iterable>, Iterator> { 14 | private final HashSet> visited = new HashSet<>(); 15 | private final Queue> toVisit = Queues.newArrayDeque(); 16 | 17 | public ClassIteratorIterable(Class root) { 18 | visited.add(root); 19 | toVisit.add(root); 20 | } 21 | 22 | 23 | @Nonnull 24 | @Override 25 | public Iterator> iterator() { 26 | return this; 27 | } 28 | 29 | @Override 30 | public boolean hasNext() { 31 | return !toVisit.isEmpty(); 32 | } 33 | 34 | @Override 35 | public Class next() { 36 | Class klass = toVisit.remove(); 37 | 38 | Class parent = klass.getSuperclass(); 39 | if (parent != null && visited.add(parent)) { 40 | toVisit.add(parent); 41 | } 42 | 43 | for (Class iface : klass.getInterfaces()) { 44 | if (iface != null && visited.add(iface)) { 45 | toVisit.add(iface); 46 | } 47 | } 48 | 49 | return klass; 50 | } 51 | 52 | @Override 53 | public void remove() { 54 | throw new UnsupportedOperationException(); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/integration/forestry/MetaItemGenetic.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.integration.forestry; 2 | 3 | import forestry.api.apiculture.EnumBeeType; 4 | import forestry.api.genetics.AlleleManager; 5 | import forestry.api.genetics.IIndividual; 6 | import forestry.apiculture.genetics.BeeDefinition; 7 | import forestry.core.config.Constants; 8 | import net.minecraft.item.ItemStack; 9 | import org.squiddev.plethora.api.Injects; 10 | import org.squiddev.plethora.api.meta.BaseMetaProvider; 11 | import org.squiddev.plethora.api.method.IPartialContext; 12 | 13 | import javax.annotation.Nonnull; 14 | import java.util.Collections; 15 | import java.util.Map; 16 | 17 | @Injects(Constants.MOD_ID) 18 | public final class MetaItemGenetic extends BaseMetaProvider { 19 | @Nonnull 20 | @Override 21 | public Map getMeta(@Nonnull IPartialContext context) { 22 | ItemStack stack = context.getTarget(); 23 | 24 | IIndividual individual = AlleleManager.alleleRegistry.getIndividual(stack); 25 | return individual != null 26 | ? Collections.singletonMap("individual", context.makePartialChild(individual).getMeta()) 27 | : Collections.emptyMap(); 28 | } 29 | 30 | @Nonnull 31 | @Override 32 | public ItemStack getExample() { 33 | IIndividual individual = BeeDefinition.FOREST.getIndividual(); 34 | individual.analyze(); 35 | return BeeDefinition.FOREST.getGenome().getSpeciesRoot().getMemberStack(individual, EnumBeeType.PRINCESS); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/integration/storagedrawers/MethodsIDrawer.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.integration.storagedrawers; 2 | 3 | import com.jaquadro.minecraft.storagedrawers.StorageDrawers; 4 | import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer; 5 | import net.minecraft.item.ItemStack; 6 | import org.squiddev.plethora.api.meta.TypedMeta; 7 | import org.squiddev.plethora.api.method.IContext; 8 | import org.squiddev.plethora.api.method.wrapper.FromTarget; 9 | import org.squiddev.plethora.api.method.wrapper.Optional; 10 | import org.squiddev.plethora.api.method.wrapper.PlethoraMethod; 11 | 12 | public final class MethodsIDrawer { 13 | private MethodsIDrawer() { 14 | } 15 | 16 | @PlethoraMethod(modId = StorageDrawers.MOD_ID, doc = "-- The maximum number of items in this drawer.") 17 | public static int getCapacity(@FromTarget IDrawer drawer) { 18 | return drawer.getMaxCapacity(); 19 | } 20 | 21 | @PlethoraMethod(modId = StorageDrawers.MOD_ID, doc = "-- The number of items in this drawer.") 22 | public static int getCount(@FromTarget IDrawer drawer) { 23 | return drawer.getStoredItemCount(); 24 | } 25 | 26 | @Optional 27 | @PlethoraMethod(modId = StorageDrawers.MOD_ID, doc = "-- The metadata of the item in this drawer.") 28 | public static TypedMeta getItemMeta(IContext context) { 29 | ItemStack stack = context.getTarget().getStoredItemPrototype(); 30 | return stack.isEmpty() ? null : context.makePartialChild(stack).getMeta(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/api/method/IUnbakedContext.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.api.method; 2 | 3 | import dan200.computercraft.api.lua.LuaException; 4 | import org.squiddev.plethora.api.reference.IReference; 5 | 6 | import javax.annotation.Nonnull; 7 | 8 | /** 9 | * A context whose references haven't been resolved 10 | */ 11 | public interface IUnbakedContext { 12 | /** 13 | * Bake a context, ensuring all references are valid 14 | * 15 | * Note, this method is NOT thread safe and MUST be called from the server thread. Use {@link #safeBake()} if 16 | * you need a safe version. 17 | * 18 | * @return The baked context 19 | * @throws LuaException If 20 | * @see IReference#get() 21 | */ 22 | @Nonnull 23 | IContext bake() throws LuaException; 24 | 25 | /** 26 | * Bake a context, ensuring all references are valid. 27 | * 28 | * This method is thread safe, though the result object may not be safe to use on any thread. 29 | * 30 | * @return The baked context 31 | * @throws LuaException If 32 | * @see IReference#safeGet() 33 | */ 34 | @Nonnull 35 | IContext safeBake() throws LuaException; 36 | 37 | /** 38 | * Get the cost handler associated with this object 39 | * 40 | * @return The parent's cost handler 41 | */ 42 | @Nonnull 43 | ICostHandler getCostHandler(); 44 | 45 | /** 46 | * Get the result executor for this context 47 | * 48 | * @return The context's result executor 49 | */ 50 | @Nonnull 51 | IResultExecutor getExecutor(); 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/core/TargetedRegisteredValue.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.core; 2 | 3 | import com.google.common.collect.Multimap; 4 | import org.squiddev.plethora.core.collections.SortedMultimap; 5 | 6 | import javax.annotation.Nonnull; 7 | import javax.annotation.Nullable; 8 | 9 | /** 10 | * A {@link RegisteredValue} which holds a single target class and value. 11 | * 12 | * @param The type of this registration entry. 13 | */ 14 | class TargetedRegisteredValue extends RegisteredValue { 15 | private final Class target; 16 | private final T value; 17 | 18 | TargetedRegisteredValue(@Nonnull String name, @Nullable String mod, @Nonnull Class target, @Nonnull T value) { 19 | super(name, mod); 20 | this.target = target; 21 | this.value = value; 22 | } 23 | 24 | @Nonnull 25 | final Class target() { 26 | return target; 27 | } 28 | 29 | @Nonnull 30 | final T value() { 31 | return value; 32 | } 33 | 34 | static void buildCache(Iterable> all, Multimap, T> cache) { 35 | cache.clear(); 36 | for (TargetedRegisteredValue item : all) { 37 | if (item.enabled()) cache.put(item.target(), item.value()); 38 | } 39 | } 40 | 41 | static void buildCache(Iterable> all, SortedMultimap, T> cache) { 42 | cache.clear(); 43 | for (TargetedRegisteredValue item : all) { 44 | if (item.enabled()) cache.put(item.target(), item.value()); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | .shelf 3 | 4 | # Mobile Tools for Java (J2ME) 5 | .mtj.tmp/ 6 | 7 | # Package Files # 8 | *.jar 9 | *.war 10 | *.ear 11 | 12 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 13 | hs_err_pid* 14 | 15 | # ========================= 16 | # Operating System Files 17 | # ========================= 18 | 19 | # OSX 20 | # ========================= 21 | 22 | .DS_Store 23 | .AppleDouble 24 | .LSOverride 25 | 26 | # Icon must ends with two \r. 27 | Icon 28 | 29 | 30 | # Thumbnails 31 | ._* 32 | 33 | # Files that might appear on external disk 34 | .Spotlight-V100 35 | .Trashes 36 | 37 | # Windows 38 | # ========================= 39 | 40 | # Windows image file caches 41 | Thumbs.db 42 | ehthumbs.db 43 | 44 | # Folder config file 45 | Desktop.ini 46 | 47 | # Recycle Bin used on file shares 48 | $RECYCLE.BIN/ 49 | 50 | # Windows Installer files 51 | *.cab 52 | *.msi 53 | *.msm 54 | *.msp 55 | 56 | # ========================= 57 | # Forge Files 58 | # ========================= 59 | /run-*/ 60 | /build-*/ 61 | /bin/ 62 | /lib/ # Include libs manually 63 | /lib-*/ 64 | /test-files 65 | 66 | # Gradle 67 | # ========================= 68 | /.gradle 69 | /build/ 70 | /run/ 71 | !gradle/wrapper/gradle-wrapper.jar 72 | 73 | # Idea 74 | # ========================= 75 | *.iml 76 | *.ipr 77 | *.iws 78 | .idea 79 | /classes 80 | 81 | # Eclipse 82 | # ========================= 83 | /eclipse/ 84 | /.classpath 85 | /.project 86 | /.settings/ 87 | /debug/ 88 | *.lock 89 | /.metadata/ 90 | out 91 | logs/ 92 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/gameplay/client/LayerBaublesInterface.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.gameplay.client; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraft.client.renderer.GlStateManager; 5 | import net.minecraft.client.renderer.entity.layers.LayerRenderer; 6 | import net.minecraft.entity.player.EntityPlayer; 7 | import net.minecraft.init.MobEffects; 8 | import org.squiddev.plethora.gameplay.neural.NeuralHelpers; 9 | import org.squiddev.plethora.utils.TinySlot; 10 | 11 | import javax.annotation.Nonnull; 12 | 13 | public class LayerBaublesInterface implements LayerRenderer { 14 | @Override 15 | public void doRenderLayer(@Nonnull EntityPlayer player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { 16 | if (player.isPotionActive(MobEffects.INVISIBILITY)) { 17 | return; 18 | } 19 | 20 | TinySlot stack = NeuralHelpers.getBauble(player); 21 | if (stack == null) return; 22 | 23 | GlStateManager.pushMatrix(); 24 | GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); 25 | Minecraft.getMinecraft().getTextureManager().bindTexture(ModelInterface.TEXTURE_RESOURCE); 26 | 27 | ModelInterface iface = ModelInterface.getNormal(); 28 | iface.isSneak = player.isSneaking(); 29 | iface.render(player, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale); 30 | 31 | GlStateManager.popMatrix(); 32 | } 33 | 34 | @Override 35 | public boolean shouldCombineTextures() { 36 | return false; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/integration/MetaWrapper.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.integration; 2 | 3 | import org.squiddev.plethora.api.Injects; 4 | import org.squiddev.plethora.api.meta.BaseMetaProvider; 5 | import org.squiddev.plethora.api.method.IPartialContext; 6 | import org.squiddev.plethora.api.reference.ConstantReference; 7 | 8 | import javax.annotation.Nonnull; 9 | import java.util.Map; 10 | import java.util.Objects; 11 | 12 | public class MetaWrapper implements ConstantReference> { 13 | private final T value; 14 | 15 | public MetaWrapper(@Nonnull T value) { 16 | Objects.requireNonNull(value, "value cannot be null"); 17 | this.value = value; 18 | } 19 | 20 | @Nonnull 21 | public T value() { 22 | return value; 23 | } 24 | 25 | public static MetaWrapper of(@Nonnull T value) { 26 | return new MetaWrapper<>(value); 27 | } 28 | 29 | @Nonnull 30 | @Override 31 | public MetaWrapper get() { 32 | return this; 33 | } 34 | 35 | @Nonnull 36 | @Override 37 | public MetaWrapper safeGet() { 38 | return this; 39 | } 40 | 41 | @Injects 42 | public static final class MetaProvider extends BaseMetaProvider { 43 | public MetaProvider() { 44 | super("Simply wraps an object and exposes metadata for that. You can happily ignore this."); 45 | } 46 | 47 | @Nonnull 48 | @Override 49 | public Map getMeta(@Nonnull IPartialContext context) { 50 | return context.makePartialChild(context.getTarget().value()).getMeta(); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/api/reference/TileReference.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.api.reference; 2 | 3 | import dan200.computercraft.api.lua.LuaException; 4 | import net.minecraft.tileentity.TileEntity; 5 | import net.minecraft.util.math.BlockPos; 6 | import net.minecraft.world.World; 7 | 8 | import javax.annotation.Nonnull; 9 | import java.lang.ref.WeakReference; 10 | 11 | /** 12 | * An reference to a tile. Ensures it is there. 13 | */ 14 | public class TileReference implements ConstantReference { 15 | private final WeakReference tile; 16 | private final BlockPos pos; 17 | private final World world; 18 | private boolean valid = true; 19 | 20 | TileReference(@Nonnull T tile) { 21 | this.tile = new WeakReference<>(tile); 22 | pos = tile.getPos(); 23 | world = tile.getWorld(); 24 | } 25 | 26 | @Nonnull 27 | @Override 28 | public T get() throws LuaException { 29 | T value = tile.get(); 30 | if (value == null || world.getTileEntity(pos) != value) { 31 | valid = false; 32 | throw new LuaException("The block is no longer there"); 33 | } 34 | 35 | valid = true; 36 | return value; 37 | } 38 | 39 | @Nonnull 40 | @Override 41 | public T safeGet() throws LuaException { 42 | if (!valid) throw new LuaException("The block is no longer there"); 43 | T value = tile.get(); 44 | 45 | if (value == null) throw new LuaException("The block is no longer there"); 46 | if (value.isInvalid()) throw new LuaException("The block is no longer there"); 47 | 48 | return value; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/gameplay/modules/glasses/objects/object3d/Rotatable3D.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.gameplay.modules.glasses.objects.object3d; 2 | 3 | import dan200.computercraft.api.lua.LuaException; 4 | import net.minecraft.util.math.Vec3d; 5 | import org.squiddev.plethora.api.method.MethodResult; 6 | import org.squiddev.plethora.api.method.wrapper.FromTarget; 7 | import org.squiddev.plethora.api.method.wrapper.PlethoraMethod; 8 | 9 | import javax.annotation.Nullable; 10 | 11 | import static org.squiddev.plethora.api.method.ArgumentHelper.getFloat; 12 | 13 | public interface Rotatable3D { 14 | @Nullable 15 | Vec3d getRotation(); 16 | 17 | void setRotation(@Nullable Vec3d rotation); 18 | 19 | @PlethoraMethod(doc = "function():nil|number, number, number -- Get the rotation for this object, or nil if it faces the player.", worldThread = false) 20 | static MethodResult getRotation(@FromTarget Rotatable3D object) { 21 | Vec3d pos = object.getRotation(); 22 | return pos == null ? MethodResult.empty() : MethodResult.result(pos.x, pos.y, pos.z); 23 | } 24 | 25 | @PlethoraMethod(doc = "function([x:number, y:number, z:number]) -- Set the rotation for this object, passing nothing if it should face the player.", worldThread = false) 26 | static void setRotation(@FromTarget Rotatable3D object, Object[] args) throws LuaException { 27 | object.setRotation(args.length == 0 || (args.length == 1 && args[0] == null) 28 | ? null 29 | : new Vec3d(getFloat(args, 0), getFloat(args, 1), getFloat(args, 2)) 30 | ); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/integration/refinedstorage/MetaCraftingPreviewElement.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.integration.refinedstorage; 2 | 3 | import com.raoulvdberge.refinedstorage.RS; 4 | import com.raoulvdberge.refinedstorage.api.autocrafting.preview.ICraftingPreviewElement; 5 | import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.preview.CraftingPreviewElementItemStack; 6 | import net.minecraft.init.Items; 7 | import net.minecraft.item.ItemStack; 8 | import org.squiddev.plethora.api.Injects; 9 | import org.squiddev.plethora.api.meta.BaseMetaProvider; 10 | import org.squiddev.plethora.api.method.IPartialContext; 11 | 12 | import javax.annotation.Nonnull; 13 | import java.util.HashMap; 14 | import java.util.Map; 15 | 16 | @Injects(RS.ID) 17 | public final class MetaCraftingPreviewElement extends BaseMetaProvider> { 18 | @Nonnull 19 | @Override 20 | public Map getMeta(@Nonnull IPartialContext> context) { 21 | ICraftingPreviewElement preview = context.getTarget(); 22 | 23 | Map out = new HashMap<>(); 24 | out.put("id", preview.getId()); 25 | out.put("available", preview.getAvailable()); 26 | out.put("toCraft", preview.getToCraft()); 27 | out.put("component", context.makePartialChild(preview.getElement()).getMeta()); 28 | 29 | return out; 30 | } 31 | 32 | @Nonnull 33 | @Override 34 | public ICraftingPreviewElement getExample() { 35 | return new CraftingPreviewElementItemStack(new ItemStack(Items.STICK, 4)); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/core/executor/TaskRunner.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.core.executor; 2 | 3 | import net.minecraft.util.ITickable; 4 | 5 | import java.util.Collections; 6 | import java.util.Iterator; 7 | import java.util.Set; 8 | import java.util.concurrent.ConcurrentHashMap; 9 | 10 | /** 11 | * This is a system capable of running a series of {@link Task}s. 12 | * 13 | * This can be created for a particular object (a tile entity, upgrade, etc...) or one can use the global 14 | * {@link #SHARED} instance. One should prefer the former, as this ensures execution is associated with that tile 15 | * (which is helpful for profiling and Forge tracking). However this is not always feasible (such as when you do not 16 | * have control over the object you are wrapping). 17 | */ 18 | public class TaskRunner implements ITickable { 19 | public static final TaskRunner SHARED = new TaskRunner(); 20 | 21 | private static final int MAX_TASKS_TOTAL = 5000; 22 | private static final int MAX_TASKS_TICK = 50; 23 | 24 | private final Set tasks = Collections.newSetFromMap(new ConcurrentHashMap<>()); 25 | 26 | @Override 27 | public void update() { 28 | Iterator tasks = this.tasks.iterator(); 29 | 30 | int i = 0; 31 | while (tasks.hasNext()) { 32 | if (tasks.next().update()) tasks.remove(); 33 | if (i++ > MAX_TASKS_TICK) break; 34 | } 35 | } 36 | 37 | boolean submit(Task task) { 38 | return tasks.size() <= MAX_TASKS_TOTAL && tasks.add(task); 39 | } 40 | 41 | public void reset() { 42 | tasks.clear(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/integration/appliedenergistics/ConverterAppliedEnergistics.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.integration.appliedenergistics; 2 | 3 | import appeng.api.networking.IGrid; 4 | import appeng.api.networking.IGridBlock; 5 | import appeng.api.networking.IGridHost; 6 | import appeng.api.networking.IGridNode; 7 | import appeng.api.storage.data.IAEFluidStack; 8 | import appeng.api.storage.data.IAEItemStack; 9 | import appeng.api.util.AEPartLocation; 10 | import appeng.core.AppEng; 11 | import net.minecraft.item.ItemStack; 12 | import net.minecraftforge.fluids.FluidStack; 13 | import org.squiddev.plethora.api.Injects; 14 | import org.squiddev.plethora.api.converter.ConstantConverter; 15 | import org.squiddev.plethora.api.converter.DynamicConverter; 16 | 17 | @Injects(AppEng.MOD_ID) 18 | public final class ConverterAppliedEnergistics { 19 | private ConverterAppliedEnergistics() { 20 | } 21 | 22 | public static final DynamicConverter GET_AE_FLUID_STACK = IAEFluidStack::getFluidStack; 23 | 24 | public static final DynamicConverter GET_AE_ITEM_STACK = 25 | from -> from.getStackSize() == 0 ? from.getDefinition() : from.createItemStack(); 26 | 27 | public static final DynamicConverter GET_NODE_GRID = IGridNode::getGrid; 28 | 29 | public static final ConstantConverter GET_NODE_BLOCK = IGridNode::getGridBlock; 30 | 31 | public static final DynamicConverter GET_GRID_NODE = from -> from.getGridNode(AEPartLocation.INTERNAL); 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/core/ConverterReference.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.core; 2 | 3 | import com.google.common.base.Strings; 4 | import dan200.computercraft.api.lua.LuaException; 5 | import org.squiddev.plethora.api.converter.ConstantConverter; 6 | import org.squiddev.plethora.api.converter.IConverter; 7 | 8 | public class ConverterReference { 9 | private static final ConstantConverter identity = x -> x; 10 | 11 | private final int index; 12 | private final Class tIn; 13 | private final IConverter converter; 14 | 15 | public ConverterReference(int index, Class tIn, IConverter converter) { 16 | this.index = index; 17 | this.tIn = tIn; 18 | this.converter = converter; 19 | } 20 | 21 | public static ConverterReference identity(int index) { 22 | return new ConverterReference<>(index, Object.class, identity); 23 | } 24 | 25 | public boolean isIdentity() { 26 | return converter == identity; 27 | } 28 | 29 | @SuppressWarnings("unchecked") 30 | public Object tryConvert(Object[] values) throws LuaException { 31 | Object value = values[index]; 32 | if (value != null && tIn.isAssignableFrom(value.getClass())) { 33 | Object converted = converter.convert((T) value); 34 | if (converted != null) return converted; 35 | } 36 | 37 | // TODO: Some improved exception method? 38 | String name = converter.getClass().getSimpleName(); 39 | if (Strings.isNullOrEmpty(name)) name = converter.getClass().getName(); 40 | throw new LuaException("Cannot find object for " + name); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/core/modules/ModuleHandlerTransform.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.core.modules; 2 | 3 | import net.minecraft.client.renderer.block.model.IBakedModel; 4 | import net.minecraft.util.ResourceLocation; 5 | import net.minecraftforge.fml.relauncher.Side; 6 | import net.minecraftforge.fml.relauncher.SideOnly; 7 | import org.apache.commons.lang3.tuple.Pair; 8 | import org.squiddev.plethora.api.method.IContextBuilder; 9 | import org.squiddev.plethora.api.module.IModuleAccess; 10 | import org.squiddev.plethora.api.module.IModuleHandler; 11 | 12 | import javax.annotation.Nonnull; 13 | import javax.vecmath.Matrix4f; 14 | 15 | /** 16 | * A module handler which proxies another module handler, applying a custom transformation. 17 | */ 18 | public class ModuleHandlerTransform implements IModuleHandler { 19 | private final IModuleHandler proxy; 20 | private final Matrix4f transform; 21 | 22 | public ModuleHandlerTransform(IModuleHandler proxy, Matrix4f transform) { 23 | this.proxy = proxy; 24 | this.transform = transform; 25 | } 26 | 27 | @Nonnull 28 | @Override 29 | public ResourceLocation getModule() { 30 | return proxy.getModule(); 31 | } 32 | 33 | @Override 34 | public void getAdditionalContext(@Nonnull IModuleAccess access, @Nonnull IContextBuilder builder) { 35 | proxy.getAdditionalContext(access, builder); 36 | } 37 | 38 | @Nonnull 39 | @Override 40 | @SideOnly(Side.CLIENT) 41 | public Pair getModel(float delta) { 42 | return Pair.of(proxy.getModel(delta).getLeft(), transform); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/api/reference/EntityReference.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.api.reference; 2 | 3 | import dan200.computercraft.api.lua.LuaException; 4 | import net.minecraft.entity.Entity; 5 | import net.minecraft.server.MinecraftServer; 6 | 7 | import javax.annotation.Nonnull; 8 | import java.lang.ref.WeakReference; 9 | import java.util.UUID; 10 | 11 | /** 12 | * An reference to an entity. Ensures it is still alive. 13 | */ 14 | public class EntityReference implements ConstantReference { 15 | private final MinecraftServer server; 16 | private final UUID id; 17 | private WeakReference entity; 18 | 19 | EntityReference(T entity) { 20 | server = entity.getServer(); 21 | id = entity.getUniqueID(); 22 | this.entity = new WeakReference<>(entity); 23 | } 24 | 25 | @SuppressWarnings("unchecked") 26 | @Nonnull 27 | @Override 28 | public T get() throws LuaException { 29 | T entity = this.entity.get(); 30 | 31 | if (entity == null || entity.isDead || entity.getEntityWorld().getEntityByID(entity.getEntityId()) != entity) { 32 | entity = (T) server.getEntityFromUuid(id); 33 | if (entity == null || entity.isDead) throw new LuaException("The entity is no longer there"); 34 | 35 | this.entity = new WeakReference<>(entity); 36 | } 37 | 38 | return entity; 39 | } 40 | 41 | @Nonnull 42 | @Override 43 | public T safeGet() throws LuaException { 44 | T value = entity.get(); 45 | if (value == null || value.isDead) throw new LuaException("The entity is no longer there"); 46 | 47 | return value; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/gameplay/modules/glasses/objects/object2d/MultiPoint2D.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.gameplay.modules.glasses.objects.object2d; 2 | 3 | import dan200.computercraft.api.lua.LuaException; 4 | import org.squiddev.plethora.api.method.MethodResult; 5 | import org.squiddev.plethora.api.method.wrapper.FromTarget; 6 | import org.squiddev.plethora.api.method.wrapper.PlethoraMethod; 7 | import org.squiddev.plethora.utils.Vec2d; 8 | 9 | import javax.annotation.Nonnull; 10 | 11 | import static org.squiddev.plethora.api.method.ArgumentHelper.assertBetween; 12 | 13 | /** 14 | * A polygon for which you can set multiple points. 15 | */ 16 | public interface MultiPoint2D { 17 | @Nonnull 18 | Vec2d getPoint(int idx); 19 | 20 | void setVertex(int idx, @Nonnull Vec2d point); 21 | 22 | int getVertices(); 23 | 24 | @PlethoraMethod(doc = "function(idx:int):number, number -- Get the specified vertex of this object.", worldThread = false) 25 | static MethodResult getPoint(@FromTarget MultiPoint2D object, int idx) throws LuaException { 26 | assertBetween(idx, 1, object.getVertices(), "Index out of range (%s)"); 27 | 28 | Vec2d point = object.getPoint(idx - 1); 29 | return MethodResult.result(point.x, point.y); 30 | } 31 | 32 | @PlethoraMethod(doc = "-- Set the specified vertex of this object.", worldThread = false) 33 | static void setPoint(@FromTarget MultiPoint2D object, int idx, double x, double y) throws LuaException { 34 | assertBetween(idx, 1, object.getVertices(), "Index out of range (%s)"); 35 | object.setVertex(idx - 1, new Vec2d(x, y)); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/utils/CapabilityWrapper.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.utils; 2 | 3 | import net.minecraft.util.EnumFacing; 4 | import net.minecraftforge.common.capabilities.Capability; 5 | import net.minecraftforge.common.capabilities.ICapabilityProvider; 6 | 7 | import javax.annotation.Nonnull; 8 | import javax.annotation.Nullable; 9 | 10 | /** 11 | * A capability provider which always restricts access to a specific side. 12 | */ 13 | public final class CapabilityWrapper implements ICapabilityProvider { 14 | private final ICapabilityProvider child; 15 | private final EnumFacing side; 16 | 17 | public CapabilityWrapper(ICapabilityProvider child, EnumFacing side) { 18 | this.child = child; 19 | this.side = side; 20 | } 21 | 22 | @Override 23 | public boolean hasCapability(@Nonnull Capability capability, @Nullable EnumFacing facing) { 24 | return (facing == null || facing == side) && child.hasCapability(capability, side); 25 | } 26 | 27 | @Nullable 28 | @Override 29 | public T getCapability(@Nonnull Capability capability, @Nullable EnumFacing facing) { 30 | return facing == null || facing == side ? child.getCapability(capability, side) : null; 31 | } 32 | 33 | @Override 34 | public boolean equals(Object o) { 35 | if (this == o) return true; 36 | if (!(o instanceof CapabilityWrapper)) return false; 37 | CapabilityWrapper that = (CapabilityWrapper) o; 38 | return child.equals(that.child) && side == that.side; 39 | 40 | } 41 | 42 | @Override 43 | public int hashCode() { 44 | return 31 * child.hashCode() + side.hashCode(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/integration/vanilla/transfer/TransferItemHandlerSlot.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.integration.vanilla.transfer; 2 | 3 | import net.minecraftforge.items.IItemHandler; 4 | import org.squiddev.plethora.api.Injects; 5 | import org.squiddev.plethora.api.transfer.ITransferProvider; 6 | 7 | import javax.annotation.Nonnull; 8 | import javax.annotation.Nullable; 9 | import java.util.Collections; 10 | import java.util.HashSet; 11 | import java.util.Set; 12 | 13 | /** 14 | * Transfer location that allows accessing child slots 15 | * 16 | * We block primary accesses as they end up being rather noisy 17 | */ 18 | @Injects 19 | public final class TransferItemHandlerSlot implements ITransferProvider { 20 | @Nullable 21 | @Override 22 | public Object getTransferLocation(@Nonnull IItemHandler object, @Nonnull String key) { 23 | try { 24 | int value = Integer.parseInt(key) - 1; 25 | if (value >= 0 && value < object.getSlots()) { 26 | return object.getStackInSlot(value); 27 | } 28 | } catch (NumberFormatException ignored) { 29 | } 30 | 31 | return null; 32 | } 33 | 34 | @Nonnull 35 | @Override 36 | public Set getTransferLocations(@Nonnull IItemHandler object) { 37 | final int size = object.getSlots(); 38 | if (size == 0) return Collections.emptySet(); 39 | Set slots = new HashSet<>(); 40 | for (int i = 0; i < size; i++) { 41 | if (!object.getStackInSlot(i).isEmpty()) slots.add(Integer.toString(i)); 42 | } 43 | return slots; 44 | } 45 | 46 | @Override 47 | public boolean primary() { 48 | return false; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/api/IWorldLocation.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.api; 2 | 3 | import net.minecraft.util.math.AxisAlignedBB; 4 | import net.minecraft.util.math.BlockPos; 5 | import net.minecraft.util.math.Vec3d; 6 | import net.minecraft.world.World; 7 | import org.squiddev.plethora.api.reference.IReference; 8 | 9 | import javax.annotation.Nonnull; 10 | 11 | /** 12 | * The location within a world. 13 | * This is exposed in method contexts from a tile entity 14 | * 15 | * @see org.squiddev.plethora.api.method.IContext 16 | */ 17 | public interface IWorldLocation extends IReference { 18 | /** 19 | * Get the world this location refers to. 20 | * 21 | * @return The world for for this location. 22 | */ 23 | @Nonnull 24 | World getWorld(); 25 | 26 | /** 27 | * Get the block position of this object. 28 | * 29 | * This will be the block's position for blocks and nearest block for entities. 30 | * 31 | * @return The position for this location 32 | */ 33 | @Nonnull 34 | BlockPos getPos(); 35 | 36 | /** 37 | * Get the position vector for this location. 38 | * 39 | * This will be the centre of the block for blocks. 40 | * 41 | * @return The decimal position for this location 42 | */ 43 | @Nonnull 44 | Vec3d getLoc(); 45 | 46 | /** 47 | * Get the bounding box of this location. 48 | * 49 | * This represents the entire area this location represents. Both {@link #getPos()} and {@link #getLoc()} should be 50 | * contained within it. 51 | * 52 | * @return This location's bounding box. 53 | */ 54 | @Nonnull 55 | AxisAlignedBB getBounds(); 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/org/squiddev/plethora/api/method/IResultExecutor.java: -------------------------------------------------------------------------------- 1 | package org.squiddev.plethora.api.method; 2 | 3 | import dan200.computercraft.api.lua.ILuaContext; 4 | import dan200.computercraft.api.lua.ILuaTask; 5 | import dan200.computercraft.api.lua.LuaException; 6 | 7 | import javax.annotation.Nonnull; 8 | import javax.annotation.Nullable; 9 | 10 | /** 11 | * An object which evaluates a {@link MethodResult}. 12 | * 13 | * 14 | * By default this uses {@link ILuaContext#executeMainThreadTask(ILuaTask)} to execute the task, 15 | * but some instances will execute on the TileEntity's tick instead 16 | */ 17 | public interface IResultExecutor { 18 | /** 19 | * Execute a task and wait for the result. 20 | * 21 | * This should immediately return {@link MethodResult#getResult()} if the result is final, 22 | * otherwise defer for the specified delay and wait til that task has finished. 23 | * 24 | * @param result The method result to evaluate 25 | * @param context The context to evaluate under 26 | * @return The final result 27 | * @throws LuaException If something went wrong 28 | * @throws InterruptedException If the code was interrupted 29 | */ 30 | @Nullable 31 | Object[] execute(@Nonnull MethodResult result, @Nonnull ILuaContext context) throws LuaException, InterruptedException; 32 | 33 | /** 34 | * Execute a task, without waiting for the result to execute. 35 | * 36 | * @param result The method result to evaluate 37 | * @throws LuaException If something went wrong when queueing the task 38 | */ 39 | void executeAsync(@Nonnull MethodResult result) throws LuaException; 40 | } 41 | --------------------------------------------------------------------------------