Compare commits

..

1 Commits

Author SHA1 Message Date
813f710455
correct maven for morered 2025-04-08 01:24:47 +03:00
13 changed files with 213 additions and 178 deletions

7
.gitignore vendored
View File

@ -20,9 +20,6 @@ build
# other # other
eclipse eclipse
run run
runs
run-data
repo # Files from Forge MDK
forge*changelog.txt
.DS_Store

View File

@ -1,135 +1,127 @@
plugins { plugins {
id 'java-library' id 'eclipse'
id 'maven-publish'
id 'idea' id 'idea'
id 'net.neoforged.moddev' version '2.0.77' id 'maven-publish'
id 'net.minecraftforge.gradle' version '[6.0,6.2)'
} }
version = "${minecraft_version}-${mod_version}" version = "${minecraft_version}-${mod_version}"
group = mod_group_id group = mod_group_id
repositories {
mavenLocal()
}
base { base {
archivesName = archive_base_name archivesName = archive_base_name
} }
java.toolchain.languageVersion = JavaLanguageVersion.of(21) java.toolchain.languageVersion = JavaLanguageVersion.of(17)
neoForge { minecraft {
// Specify the version of NeoForge to use. mappings channel: mapping_channel, version: mapping_version
version = project.neo_version
parchment { copyIdeResources = true
mappingsVersion = project.parchment_mappings_version
minecraftVersion = project.parchment_minecraft_version
}
runs { runs {
configureEach {
workingDirectory project.file('run')
property 'forge.logging.console.level', 'debug'
mods {
"${mod_id}" {
source sourceSets.main
}
}
}
client { client {
client() property 'forge.enabledGameTestNamespaces', mod_id
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
} }
server { server {
server() property 'forge.enabledGameTestNamespaces', mod_id
programArgument '--nogui' args '--nogui'
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
}
gameTestServer {
type = "gameTestServer"
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
}
data {
data()
programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
}
configureEach {
systemProperty 'forge.logging.markers', 'REGISTRIES'
logLevel = org.slf4j.event.Level.DEBUG
}
}
mods {
"${mod_id}" {
sourceSet(sourceSets.main)
} }
} }
} }
sourceSets.main.resources { srcDir 'src/generated/resources' }
repositories { repositories {
maven { maven {
url 'https://maven.squiddev.cc' url 'https://squiddev.cc/maven/'
content { content {
includeGroup 'cc.tweaked' includeGroup 'cc.tweaked'
includeModule('org.squiddev', 'Cobalt')
} }
} }
maven { maven {
url 'https://commoble.net/maven/' url 'https://commoble.net/maven/'
content { content {
includeGroup 'net.commoble.morered' includeGroup 'commoble.morered'
} }
} }
mavenLocal()
} }
dependencies { dependencies {
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
compileOnly "cc.tweaked:cc-tweaked-${minecraft_version}-forge-api:${cctweaked_version}" compileOnly("cc.tweaked:cc-tweaked-${minecraft_version}-core-api:${cctweaked_version}")
implementation "cc.tweaked:cc-tweaked-${minecraft_version}-forge:${cctweaked_version}" compileOnly(fg.deobf("cc.tweaked:cc-tweaked-${minecraft_version}-forge-api:${cctweaked_version}"))
implementation(fg.deobf("cc.tweaked:cc-tweaked-${minecraft_version}-forge:${cctweaked_version}"))
implementation "net.commoble.morered:morered-${minecraft_version_major}:${morered_version}" implementation fg.deobf("commoble.morered:morered-${minecraft_version}:${morered_version}")
} }
var generateModMetadata = tasks.register("generateModMetadata", ProcessResources) { tasks.named('processResources', ProcessResources).configure {
var replaceProperties = [minecraft_version : minecraft_version, var replaceProperties = [
minecraft_version_range: minecraft_version_range, minecraft_version: minecraft_version, minecraft_version_range: minecraft_version_range,
neo_version : neo_version, forge_version: forge_version, forge_version_range: forge_version_range,
neo_version_range : neo_version_range, loader_version_range: loader_version_range,
loader_version_range : loader_version_range, mod_id: mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version,
mod_id : mod_id, mod_authors: mod_authors, mod_description: mod_description,
mod_name : mod_name, mod_issue_tracker_url: mod_issue_tracker_url, mod_display_url: mod_display_url,
mod_license : mod_license, cctweaked_version_range: cctweaked_version_range, morered_version_range: morered_version_range,
mod_version : mod_version, ]
mod_authors : mod_authors,
mod_description : mod_description,
mod_issue_tracker_url : mod_issue_tracker_url,
mod_display_url : mod_display_url,
cctweaked_version_range: cctweaked_version_range,
morered_version_range : morered_version_range]
inputs.properties replaceProperties inputs.properties replaceProperties
expand replaceProperties
from "src/main/templates" filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) {
into "build/generated/sources/modMetadata" expand replaceProperties + [project: project]
}
} }
sourceSets.main.resources.srcDir generateModMetadata // Example for how to get properties into the manifest for reading at runtime.
tasks.named('jar', Jar).configure {
manifest {
attributes([
'Specification-Title' : mod_id,
'Specification-Vendor' : mod_authors,
'Specification-Version' : '1', // We are version 1 of ourselves
'Implementation-Title' : project.name,
'Implementation-Version' : project.jar.archiveVersion,
'Implementation-Vendor' : mod_authors,
'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
neoForge.ideSyncTask generateModMetadata // This is the preferred method to reobfuscate your jar file
finalizedBy 'reobfJar'
}
// However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing:
// tasks.named('publish').configure {
// dependsOn 'reobfJar'
// }
// Example configuration to allow publishing using the maven-publish plugin
publishing { publishing {
publications { publications {
register('mavenJava', MavenPublication) { register('mavenJava', MavenPublication) {
from components.java artifact jar
} }
} }
repositories { repositories {
maven { maven {
url "file://${project.projectDir}/repo" url "file://${project.projectDir}/mcmodsrepo"
} }
} }
} }
idea { tasks.withType(JavaCompile).configureEach {
module { options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
downloadSources = true
downloadJavadoc = true
}
} }

View File

@ -1,27 +1,45 @@
# Sets default memory used for gradle commands. Can be overridden by user or command line properties. # Sets default memory used for gradle commands. Can be overridden by user or command line properties.
org.gradle.jvmargs=-Xmx2G # This is required to provide enough memory for the Minecraft decompilation process.
org.gradle.daemon=true org.gradle.jvmargs=-Xmx3G
org.gradle.parallel=true org.gradle.daemon=false
org.gradle.caching=true
org.gradle.configuration-cache=true
## Environment Properties ## Environment Properties
# You can find the latest versions here: https://projects.neoforged.net/neoforged/neoforge
# The Minecraft version must agree with the Neo version to get a valid artifact # The Minecraft version must agree with the Forge version to get a valid artifact
minecraft_version=1.21.1 minecraft_version=1.20.1
minecraft_version_major=1.21
# The Minecraft version range can use any release version of Minecraft as bounds. # The Minecraft version range can use any release version of Minecraft as bounds.
# Snapshots, pre-releases, and release candidates are not guaranteed to sort properly # Snapshots, pre-releases, and release candidates are not guaranteed to sort properly
# as they do not follow standard versioning conventions. # as they do not follow standard versioning conventions.
minecraft_version_range=[1.21.1,1.22) minecraft_version_range=[1.20.1,1.21)
# The Neo version must agree with the Minecraft version to get a valid artifact # The Forge version must agree with the Minecraft version to get a valid artifact
neo_version=21.1.9 forge_version=47.1.0
# The Neo version range can use any version of Neo as bounds # The Forge version range can use any version of Forge as bounds or match the loader version range
neo_version_range=[21,) forge_version_range=[47.1.0,)
# The loader version range can only use the major version of FML as bounds # The loader version range can only use the major version of Forge/FML as bounds
loader_version_range=[4,) loader_version_range=[47,)
parchment_minecraft_version=1.21.1 # The mapping channel to use for mappings.
parchment_mappings_version=2024.11.17 # The default set of supported mapping channels are ["official", "snapshot", "snapshot_nodoc", "stable", "stable_nodoc"].
# Additional mapping channels can be registered through the "channelProviders" extension in a Gradle plugin.
#
# | Channel | Version | |
# |-----------|----------------------|--------------------------------------------------------------------------------|
# | official | MCVersion | Official field/method names from Mojang mapping files |
# | parchment | YYYY.MM.DD-MCVersion | Open community-sourced parameter names and javadocs layered on top of official |
#
# You must be aware of the Mojang license when using the 'official' or 'parchment' mappings.
# See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
#
# Parchment is an unofficial project maintained by ParchmentMC, separate from Minecraft Forge.
# Additional setup is needed to use their mappings, see https://parchmentmc.org/docs/getting-started
mapping_channel=official
# The mapping version to query from the mapping channel.
# This must match the format required by the mapping channel.
mapping_version=1.20.1
## Mod Properties ## Mod Properties
# The unique mod identifier for the mod. Must be lowercase in English locale. Must fit the regex [a-z][a-z0-9_]{1,63} # The unique mod identifier for the mod. Must be lowercase in English locale. Must fit the regex [a-z][a-z0-9_]{1,63}
# Must match the String constant located in the main mod class annotated with @Mod. # Must match the String constant located in the main mod class annotated with @Mod.
mod_id=moreredxcctcompat mod_id=moreredxcctcompat
@ -30,7 +48,7 @@ mod_name=More Red x CC:Tweaked Compat
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default. # The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=MIT mod_license=MIT
# The mod version. See https://semver.org/ # The mod version. See https://semver.org/
mod_version=1.3.0 mod_version=1.0.0
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository. # The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
# This should match the base package used for the mod sources. # This should match the base package used for the mod sources.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html # See https://maven.apache.org/guides/mini/guide-naming-conventions.html
@ -50,8 +68,8 @@ archive_base_name=MoreRed-CCT-Compat
## Mod Dependencies Properties ## Mod Dependencies Properties
# CC:Tweaked version # CC:Tweaked version
cctweaked_version=1.114.4 cctweaked_version=1.106.1
cctweaked_version_range=[1.114.4,) cctweaked_version_range=[1.106.1,)
# More Red version # More Red version
morered_version=6.0.0.2 morered_version=4.0.0.0
morered_version_range=[6.0.0.2,) morered_version_range=[4.0.0.0,)

Binary file not shown.

View File

@ -1,7 +1,6 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
networkTimeout=10000 networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

31
gradlew vendored Executable file → Normal file
View File

@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop. # Darwin, MinGW, and NonStop.
# #
# (3) This script is generated from the Groovy template # (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project. # within the Gradle project.
# #
# You can find Gradle at https://github.com/gradle/gradle/. # You can find Gradle at https://github.com/gradle/gradle/.
@ -83,8 +83,10 @@ done
# This is normally unused # This is normally unused
# shellcheck disable=SC2034 # shellcheck disable=SC2034
APP_BASE_NAME=${0##*/} APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum MAX_FD=maximum
@ -131,13 +133,10 @@ location of your Java installation."
fi fi
else else
JAVACMD=java JAVACMD=java
if ! command -v java >/dev/null 2>&1 which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the Please set the JAVA_HOME variable in your environment to match the
location of your Java installation." location of your Java installation."
fi
fi fi
# Increase the maximum file descriptors if we can. # Increase the maximum file descriptors if we can.
@ -145,7 +144,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #( case $MAX_FD in #(
max*) max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045 # shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) || MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit" warn "Could not query maximum file descriptor limit"
esac esac
@ -153,7 +152,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
'' | soft) :;; #( '' | soft) :;; #(
*) *)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045 # shellcheck disable=SC3045
ulimit -n "$MAX_FD" || ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD" warn "Could not set maximum file descriptor limit to $MAX_FD"
esac esac
@ -198,15 +197,11 @@ if "$cygwin" || "$msys" ; then
done done
fi fi
# Collect all arguments for the java command;
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# Collect all arguments for the java command: # * put everything else in single quotes, so that it's not re-expanded.
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \ set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \ "-Dorg.gradle.appname=$APP_BASE_NAME" \

22
gradlew.bat vendored
View File

@ -13,8 +13,6 @@
@rem See the License for the specific language governing permissions and @rem See the License for the specific language governing permissions and
@rem limitations under the License. @rem limitations under the License.
@rem @rem
@rem SPDX-License-Identifier: Apache-2.0
@rem
@if "%DEBUG%"=="" @echo off @if "%DEBUG%"=="" @echo off
@rem ########################################################################## @rem ##########################################################################
@ -45,11 +43,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1 %JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute if %ERRORLEVEL% equ 0 goto execute
echo. 1>&2 echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo. 1>&2 echo.
echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation. 1>&2 echo location of your Java installation.
goto fail goto fail
@ -59,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute if exist "%JAVA_EXE%" goto execute
echo. 1>&2 echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo. 1>&2 echo.
echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation. 1>&2 echo location of your Java installation.
goto fail goto fail

View File

@ -1,11 +1,13 @@
pluginManagement { pluginManagement {
repositories { repositories {
mavenLocal()
gradlePluginPortal() gradlePluginPortal()
maven { url = 'https://maven.neoforged.net/releases' } maven {
name = 'MinecraftForge'
url = 'https://maven.minecraftforge.net/'
}
} }
} }
plugins { plugins {
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0' id 'org.gradle.toolchains.foojay-resolver-convention' version '0.5.0'
} }

View File

@ -3,55 +3,49 @@ package ru.yurannnzzz.moreredcccompat;
import commoble.morered.api.MoreRedAPI; import commoble.morered.api.MoreRedAPI;
import commoble.morered.api.WireConnector; import commoble.morered.api.WireConnector;
import dan200.computercraft.api.ComputerCraftAPI; import dan200.computercraft.api.ComputerCraftAPI;
import dan200.computercraft.shared.common.IBundledRedstoneBlock; import dan200.computercraft.shared.ModRegistry;
import net.minecraft.core.registries.BuiltInRegistries; import dan200.computercraft.shared.computer.blocks.AbstractComputerBlockEntity;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.entity.BlockEntity;
import net.neoforged.bus.api.IEventBus; import net.minecraftforge.common.MinecraftForge;
import net.neoforged.fml.common.Mod; import net.minecraftforge.event.AttachCapabilitiesEvent;
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent; import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import ru.yurannnzzz.moreredcccompat.cc.MoreRedBundledRedstoneProvider; import ru.yurannnzzz.moreredcccompat.cc.MoreRedBundledRedstoneProvider;
import ru.yurannnzzz.moreredcccompat.morered.ComputerChanneledPowerCapability; import ru.yurannnzzz.moreredcccompat.morered.ComputerChanneledPowerCapability;
import ru.yurannnzzz.moreredcccompat.morered.ComputerWireConnector; import ru.yurannnzzz.moreredcccompat.morered.ComputerWireConnector;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Optional;
@Mod(MoreRedCCCompatMod.MOD_ID) @Mod(MoreRedCCCompatMod.MOD_ID)
public class MoreRedCCCompatMod { public class MoreRedCCCompatMod {
public static final String MOD_ID = "moreredxcctcompat"; public static final String MOD_ID = "moreredxcctcompat";
public MoreRedCCCompatMod(IEventBus modEventBus) { public MoreRedCCCompatMod() {
modEventBus.addListener(this::registerConnectors); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::registerConnectors);
modEventBus.addListener(this::registerCapabilities);
MinecraftForge.EVENT_BUS.register(this);
ComputerCraftAPI.registerBundledRedstoneProvider(new MoreRedBundledRedstoneProvider()); ComputerCraftAPI.registerBundledRedstoneProvider(new MoreRedBundledRedstoneProvider());
} }
private static final Map<Block, BlockEntityType<?>> BLOCKS = new HashMap<>();
private void registerConnectors(final FMLCommonSetupEvent event) { private void registerConnectors(final FMLCommonSetupEvent event) {
ComputerWireConnector connector = new ComputerWireConnector(); ComputerWireConnector connector = new ComputerWireConnector();
Map<Block, WireConnector> registry = MoreRedAPI.getCableConnectabilityRegistry(); Map<Block, WireConnector> registry = MoreRedAPI.getCableConnectabilityRegistry();
for (Block block : BuiltInRegistries.BLOCK) { registry.put(ModRegistry.Blocks.COMPUTER_NORMAL.get(), connector);
if (block instanceof IBundledRedstoneBlock) { registry.put(ModRegistry.Blocks.COMPUTER_ADVANCED.get(), connector);
Optional<BlockEntityType<?>> filter = BuiltInRegistries.BLOCK_ENTITY_TYPE.stream().filter(it -> it.isValid(block.defaultBlockState())).findFirst(); registry.put(ModRegistry.Blocks.COMPUTER_COMMAND.get(), connector);
registry.put(ModRegistry.Blocks.TURTLE_NORMAL.get(), connector);
filter.ifPresent(blockEntityType -> BLOCKS.put(block, blockEntityType)); registry.put(ModRegistry.Blocks.TURTLE_ADVANCED.get(), connector);
}
}
for (Map.Entry<Block, BlockEntityType<?>> entry : BLOCKS.entrySet()) {
registry.put(entry.getKey(), connector);
}
} }
private void registerCapabilities(RegisterCapabilitiesEvent event) { @SubscribeEvent
for (Map.Entry<Block, BlockEntityType<?>> entry : BLOCKS.entrySet()) { public void attachCapability(AttachCapabilitiesEvent<BlockEntity> event) {
event.registerBlockEntity(MoreRedAPI.CHANNELED_POWER_CAPABILITY, entry.getValue(), (be, side) -> new ComputerChanneledPowerCapability(side)); if (event.getObject() instanceof AbstractComputerBlockEntity) {
event.addCapability(ComputerChanneledPowerCapability.LOCATION, new ComputerChanneledPowerCapability.Provider());
} }
} }
} }

View File

@ -7,6 +7,7 @@ import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraftforge.common.util.LazyOptional;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
public class MoreRedBundledRedstoneProvider implements BundledRedstoneProvider { public class MoreRedBundledRedstoneProvider implements BundledRedstoneProvider {
@ -15,9 +16,11 @@ public class MoreRedBundledRedstoneProvider implements BundledRedstoneProvider {
BlockEntity blockEntity = world.getBlockEntity(pos); BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null) { if (blockEntity != null) {
ChanneledPowerSupplier channeledPowerSupplier = world.getCapability(MoreRedAPI.CHANNELED_POWER_CAPABILITY, blockEntity.getBlockPos(), side); LazyOptional<ChanneledPowerSupplier> capability = blockEntity.getCapability(MoreRedAPI.CHANNELED_POWER_CAPABILITY, side);
if (capability.isPresent()) {
ChanneledPowerSupplier channeledPowerSupplier = capability.orElseThrow(NullPointerException::new);
if (channeledPowerSupplier != null) {
int result = 0; int result = 0;
for (int i = 0; i < 16; i++) { for (int i = 0; i < 16; i++) {

View File

@ -1,15 +1,27 @@
package ru.yurannnzzz.moreredcccompat.morered; package ru.yurannnzzz.moreredcccompat.morered;
import commoble.morered.api.ChanneledPowerSupplier; import commoble.morered.api.ChanneledPowerSupplier;
import commoble.morered.api.MoreRedAPI;
import dan200.computercraft.api.ComputerCraftAPI; import dan200.computercraft.api.ComputerCraftAPI;
import net.minecraft.Util;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import net.minecraftforge.common.util.LazyOptional;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import ru.yurannnzzz.moreredcccompat.MoreRedCCCompatMod;
import java.util.EnumMap;
import java.util.Map;
public class ComputerChanneledPowerCapability implements ChanneledPowerSupplier { public class ComputerChanneledPowerCapability implements ChanneledPowerSupplier {
public static final ResourceLocation LOCATION = new ResourceLocation(MoreRedCCCompatMod.MOD_ID, "bundled_redstone");
private final Direction side; private final Direction side;
public ComputerChanneledPowerCapability(Direction side) { public ComputerChanneledPowerCapability(Direction side) {
@ -28,4 +40,21 @@ public class ComputerChanneledPowerCapability implements ChanneledPowerSupplier
int expected = 1 << channel; int expected = 1 << channel;
return ((output & expected) == expected) ? 31 : 0; return ((output & expected) == expected) ? 31 : 0;
} }
public static class Provider implements ICapabilityProvider {
private final Map<Direction, LazyOptional<ChanneledPowerSupplier>> sidedPowerSuppliers = Util.make(new EnumMap<>(Direction.class), map -> {
for (Direction side : Direction.values()) {
map.put(side, LazyOptional.of(() -> new ComputerChanneledPowerCapability(side)));
}
});
@Override
public @NotNull <T> LazyOptional<T> getCapability(@NotNull Capability<T> cap, @Nullable Direction side) {
if (cap == MoreRedAPI.CHANNELED_POWER_CAPABILITY && side != null) {
return sidedPowerSuppliers.get(side).cast();
}
return LazyOptional.empty();
}
}
} }

View File

@ -12,29 +12,29 @@ authors="${mod_authors}"
description='''${mod_description}''' description='''${mod_description}'''
[[dependencies.${mod_id}]] [[dependencies.${mod_id}]]
modId="neoforge" modId="forge"
type="required" mandatory=true
versionRange="${neo_version_range}" versionRange="${forge_version_range}"
ordering="NONE" ordering="NONE"
side="BOTH" side="BOTH"
[[dependencies.${mod_id}]] [[dependencies.${mod_id}]]
modId="minecraft" modId="minecraft"
type="required" mandatory=true
versionRange="${minecraft_version_range}" versionRange="${minecraft_version_range}"
ordering="NONE" ordering="NONE"
side="BOTH" side="BOTH"
[[dependencies.${mod_id}]] [[dependencies.${mod_id}]]
modId="computercraft" modId="computercraft"
type="required" mandatory=true
versionRange="${cctweaked_version_range}" versionRange="${cctweaked_version_range}"
ordering="NONE" ordering="NONE"
side="BOTH" side="BOTH"
[[dependencies.${mod_id}]] [[dependencies.${mod_id}]]
modId="morered" modId="morered"
type="required" mandatory=true
versionRange="${morered_version_range}" versionRange="${morered_version_range}"
ordering="NONE" ordering="NONE"
side="BOTH" side="BOTH"

View File

@ -0,0 +1,8 @@
{
"pack": {
"description": {
"text": "${mod_id} resources"
},
"pack_format": 15
}
}