Skip to content

Commit

Permalink
Sketch of computercraft support.
Browse files Browse the repository at this point in the history
  • Loading branch information
tomprince committed Jan 27, 2025
1 parent 73b67a9 commit 46853c9
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 1 deletion.
6 changes: 6 additions & 0 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ dependencies {
modCompileOnly(forge.journeymap.api)
modCompileOnly(forge.journeymap.forge)

// CC: Tweaked
modCompileOnly(forge.cc.tweaked.core.api)
modCompileOnly(forge.cc.tweaked.forge.api)

// Standard runtime mods //
modRuntimeOnly(forge.jade)
modRuntimeOnly(forge.ae2)
Expand Down Expand Up @@ -109,6 +113,8 @@ dependencies {
modExtraRuntimeOnly(forge.ftbteams)
modExtraRuntimeOnly(forge.ftbchunks)

modExtraRuntimeOnly(forge.cc.tweaked.forge.impl)

modExtraRuntimeOnly("top.theillusivec4.curios:curios-forge:${forge.versions.curios.get()}")
modExtraRuntimeOnly("curse.maven:spark-361579:4738952")
modExtraRuntimeOnly("curse.maven:observable-509575:5643037")
Expand Down
7 changes: 7 additions & 0 deletions gradle/scripts/repositories.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ repositories {
includeGroup "thedarkcolour"
}
}
maven {
name = "CC: Tweaked"
url = "https://maven.squiddev.cc"
content {
includeGroup "cc.tweaked"
}
}
maven { url "https://maven.architectury.dev/" }
maven { url = "https://maven.jamieswhiteshirt.com/libs-release" } // Reach Entity Attributes
maven { url 'https://jitpack.io' } // Mixin Extras, Fabric ASM
Expand Down
6 changes: 6 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ dependencyResolutionManagement {
def argonautsForgeFile = "5263580"
def resourcefulForgeFile = "5659871"
def kffVersion = "4.11.0"
def cctVersion = "1.114.3"

// Libs
def quiltMappingsVersion = "5" // https://lambdaurora.dev/tools/import_quilt.html
Expand Down Expand Up @@ -147,6 +148,11 @@ dependencyResolutionManagement {

def kotlinForForge = version("kotlinForForge", kffVersion)
library("kotlinforforge", "thedarkcolour", "kotlinforforge").versionRef(kotlinForForge)

def ccTweaked = version("cc-tweaked", cctVersion)
library("cc-tweaked-core-api", "cc.tweaked", "cc-tweaked-${minecraftVersion}-core-api").versionRef(ccTweaked)
library("cc-tweaked-forge-api", "cc.tweaked", "cc-tweaked-${minecraftVersion}-forge-api").versionRef(ccTweaked)
library("cc-tweaked-forge-impl", "cc.tweaked", "cc-tweaked-${minecraftVersion}-forge").versionRef(ccTweaked)
}

libs {
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/gregtechceu/gtceu/GTCEu.java
Original file line number Diff line number Diff line change
Expand Up @@ -188,5 +188,9 @@ public static boolean isFTBTeamsLoaded() {
public static boolean isArgonautsLoaded() {
return isModLoaded(GTValues.MODID_ARGONAUTS);
}

public static boolean isCCTweakedLoaded() {
return isModLoaded(GTValues.MODID_CCTWEAKED);
}
}
}
3 changes: 2 additions & 1 deletion src/main/java/com/gregtechceu/gtceu/api/GTValues.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ public static int[] tiersBetween(int minInclusive, int maxInclusive) {
MODID_FTB_CHUNKS = "ftbchunks",
MODID_JAVD = "javd",
MODID_FTB_TEAMS = "ftbteams",
MODID_ARGONAUTS = "argonauts";
MODID_ARGONAUTS = "argonauts",
MODID_CCTWEAKED = "computercraft";

/**
* Spray painting compat modids
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/gregtechceu/gtceu/common/CommonProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import com.gregtechceu.gtceu.data.pack.GTDynamicResourcePack;
import com.gregtechceu.gtceu.data.pack.GTPackSource;
import com.gregtechceu.gtceu.forge.AlloyBlastPropertyAddition;
import com.gregtechceu.gtceu.integration.cctweaked.CCTweakedPlugin;
import com.gregtechceu.gtceu.integration.kjs.GTCEuStartupEvents;
import com.gregtechceu.gtceu.integration.kjs.GTRegistryInfo;
import com.gregtechceu.gtceu.integration.kjs.events.MaterialModificationEventJS;
Expand Down Expand Up @@ -235,6 +236,11 @@ public void commonSetup(FMLCommonSetupEvent event) {
CraftingHelper.register(IntCircuitIngredient.TYPE, IntCircuitIngredient.SERIALIZER);
CraftingHelper.register(IntProviderIngredient.TYPE, IntProviderIngredient.SERIALIZER);
CraftingHelper.register(FluidContainerIngredient.TYPE, FluidContainerIngredient.SERIALIZER);

if (GTCEu.Mods.isCCTweakedLoaded()) {
GTCEu.LOGGER.info("CC: Tweaked found. Enabling integration...");
CCTweakedPlugin.init();
}
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.gregtechceu.gtceu.integration.cctweaked;

import com.gregtechceu.gtceu.api.capability.forge.GTCapability;

import dan200.computercraft.api.ComputerCraftAPI;
import dan200.computercraft.api.ForgeComputerCraftAPI;

public class CCTweakedPlugin {

public static void init() {
ComputerCraftAPI.registerGenericSource(new PowerStationPeripheral());
ForgeComputerCraftAPI.registerGenericCapability(GTCapability.CAPABILITY_ENERGY_INFO_PROVIDER);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.gregtechceu.gtceu.integration.cctweaked;

import com.gregtechceu.gtceu.api.capability.IEnergyInfoProvider;

import dan200.computercraft.api.lua.LuaFunction;
import dan200.computercraft.api.peripheral.GenericPeripheral;

import java.math.BigInteger;

public class PowerStationPeripheral implements GenericPeripheral {

public String id() {
return "energy_info";
}

@LuaFunction
static public long getEnergyStored(IEnergyInfoProvider infoProvider) {
return infoProvider.getEnergyInfo().stored().min(BigInteger.valueOf(Long.MAX_VALUE)).longValue();
}

@LuaFunction
static public long getEnergyCapacity(IEnergyInfoProvider infoProvider) {
return infoProvider.getEnergyInfo().capacity().min(BigInteger.valueOf(Long.MAX_VALUE)).longValue();
}

/*
* .mainThreadMethod("getEnergyStored", metaMachineWrapper((machine) => {
* return machine.energyContainer.energyStored
* }))
* .mainThreadMethod("getEnergyCapacity", metaMachineWrapper((machine) => {
* return machine.energyContainer.energyCapacity
* }))
* .mainThreadMethod("getOutputPerSec", metaMachineWrapper((machine) => {
* return machine.energyContainer.getOutputPerSec()
* }))
* .mainThreadMethod("getInputPerSec", metaMachineWrapper((machine) => {
* return machine.energyContainer.getInputPerSec()
* }))
*/
}

0 comments on commit 46853c9

Please sign in to comment.