Updated to 1.20.4, added NeoForge

This commit is contained in:
Tschipp 2024-02-25 17:53:24 +01:00
parent 0d9e6cf32e
commit aa6ba82ae5
40 changed files with 1330 additions and 335 deletions

1
.gitignore vendored
View File

@ -21,3 +21,4 @@ build
# other
eclipse
run
runs

View File

@ -1,23 +1,19 @@
plugins {
id 'idea'
id 'java'
id 'org.spongepowered.gradle.vanilla' version '0.2.1-SNAPSHOT'
id 'maven-publish'
id 'org.spongepowered.gradle.vanilla' version '0.2.1-SNAPSHOT'
}
archivesBaseName = "${mod_id}-common-${minecraft_version}"
base {
archivesName = "${mod_id}-common-${minecraft_version}"
}
minecraft {
version(minecraft_version)
runs {
if (project.hasProperty('common_runs_enabled') ? project.findProperty('common_runs_enabled').toBoolean() : true) {
server(project.hasProperty('common_server_run_name') ? project.findProperty('common_server_run_name') : 'vanilla_server') {
workingDirectory(this.file("run"))
}
client(project.hasProperty('common_client_run_name') ? project.findProperty('common_client_run_name') : 'vanilla_client') {
workingDirectory(this.file("run"))
}
}
if(file("src/main/resources/${mod_id}.accesswidener").exists()){
accessWideners(file("src/main/resources/${mod_id}.accesswidener"))
}
}
@ -26,10 +22,10 @@ repositories {
}
dependencies {
compileOnly group:'org.spongepowered', name:'mixin', version:'0.8.5'
implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.1'
implementation("com.github.llamalad7.mixinextras:mixinextras-common:${mixinextras_version}")
annotationProcessor("com.github.llamalad7.mixinextras:mixinextras-common:${mixinextras_version}")
compileOnly group:'org.spongepowered', name:'mixin', version:'0.8.5'
implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.1'
implementation("io.github.llamalad7:mixinextras-common:${mixinextras_version}")
annotationProcessor("io.github.llamalad7:mixinextras-common:${mixinextras_version}")
}
processResources {
@ -46,7 +42,7 @@ publishing {
publications {
mavenJava(MavenPublication) {
groupId project.group
artifactId project.archivesBaseName
artifactId base.archivesName .get()
version project.version
from components.java
}

View File

@ -22,36 +22,39 @@ import tschipp.carryon.platform.Services;
public class CarryOnCommon
{
public static void registerServerPackets()
public static void registerServerPackets(Object... args)
{
Services.PLATFORM.registerServerboundPacket(
Constants.PACKET_ID_KEY_PRESSED,
0,
ServerboundCarryKeyPressedPacket.class,
ServerboundCarryKeyPressedPacket::toBytes,
ServerboundCarryKeyPressedPacket::write,
ServerboundCarryKeyPressedPacket::new,
ServerboundCarryKeyPressedPacket::handle
ServerboundCarryKeyPressedPacket::handle,
args
);
}
public static void registerClientPackets()
public static void registerClientPackets(Object... args)
{
Services.PLATFORM.registerClientboundPacket(
Constants.PACKET_ID_START_RIDING,
1,
ClientboundStartRidingPacket.class,
ClientboundStartRidingPacket::toBytes,
ClientboundStartRidingPacket::write,
ClientboundStartRidingPacket::new,
ClientboundStartRidingPacket::handle
ClientboundStartRidingPacket::handle,
args
);
Services.PLATFORM.registerClientboundPacket(
Constants.PACKET_ID_SYNC_SCRIPTS,
2,
ClientboundSyncScriptsPacket.class,
ClientboundSyncScriptsPacket::toBytes,
ClientboundSyncScriptsPacket::write,
ClientboundSyncScriptsPacket::new,
ClientboundSyncScriptsPacket::handle
ClientboundSyncScriptsPacket::handle,
args
);
}

View File

@ -221,7 +221,7 @@ public class CarryConfig
description = "Blocks that cannot be picked up"
)
public String[] forbiddenTiles = {
"#forge:immovable", "#forge:relocation_not_supported", "minecraft:end_portal", "minecraft:piston_head",
"#forge:immovable", "#forge:relocation_not_supported", "#neoforge:immovable", "#neoforge:relocation_not_supported", "minecraft:end_portal", "minecraft:piston_head",
"minecraft:end_gateway", "minecraft:tall_grass", "minecraft:large_fern", "minecraft:peony",
"minecraft:rose_bush", "minecraft:lilac", "minecraft:sunflower", "minecraft:*_bed",
"minecraft:*_door", "minecraft:big_dripleaf_stem", "minecraft:waterlily", "minecraft:cake",

View File

@ -1,7 +1,9 @@
package tschipp.carryon.common.scripting;
import com.mojang.serialization.Codec;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import net.minecraft.advancements.Advancement;
import net.minecraft.advancements.AdvancementHolder;
import net.minecraft.core.BlockPos;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.nbt.CompoundTag;
@ -106,7 +108,7 @@ public final class Matchables
public boolean matches(ServerPlayer player)
{
ServerAdvancementManager manager = player.server.getAdvancements();
Advancement adv = manager.getAdvancement(new ResourceLocation(advancement.isEmpty() ? "" : advancement));
AdvancementHolder adv = manager.get(new ResourceLocation(advancement.isEmpty() ? "" : advancement));
boolean achievement = adv == null ? true : player.getAdvancements().getOrStartProgress(adv).isDone();
return achievement;
@ -160,19 +162,10 @@ public final class Matchables
numb = cond.substring(iL);
scorename = cond.replace(numb, "");
Map<Objective, Score> o = score.getPlayerScores(player.getGameProfile().getName());
if (o != null)
{
Score sc = o.get(score.getObjective(scorename));
if (sc != null)
{
int points = sc.getScore();
Object2IntMap<Objective> scores = score.listPlayerScores(player);
int scoreVal = scores.getInt(score.getObjective(scorename));
return new NumberBoundCondition(numb).matches(points);
}
}
return false;
return new NumberBoundCondition(numb).matches(scoreVal);
}
}

View File

@ -1,11 +1,14 @@
package tschipp.carryon.networking;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Player;
public abstract class PacketBase
public interface PacketBase
{
public abstract void toBytes(FriendlyByteBuf buf);
void write(FriendlyByteBuf buf);
public abstract void handle(Player player);
void handle(Player player);
ResourceLocation id();
}

View File

@ -1,42 +1,39 @@
package tschipp.carryon.networking.clientbound;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import tschipp.carryon.Constants;
import tschipp.carryon.networking.PacketBase;
public class ClientboundStartRidingPacket extends PacketBase
public record ClientboundStartRidingPacket(int iden, boolean ride) implements PacketBase
{
int entityId;
boolean ride;
public ClientboundStartRidingPacket(FriendlyByteBuf buf)
{
this.entityId = buf.readInt();
this.ride = buf.readBoolean();
}
public ClientboundStartRidingPacket(int id, boolean ride)
{
this.entityId = id;
this.ride = ride;
this(buf.readInt(), buf.readBoolean());
}
@Override
public void toBytes(FriendlyByteBuf buf)
public void write(FriendlyByteBuf buf)
{
buf.writeInt(entityId);
buf.writeInt(iden);
buf.writeBoolean(ride);
}
@Override
public void handle(Player player)
{
Entity otherPlayer = player.level().getEntity(this.entityId);
Entity otherPlayer = player.level().getEntity(this.iden);
if(otherPlayer != null)
if(ride)
otherPlayer.startRiding(player);
else
otherPlayer.stopRiding();
}
@Override
public ResourceLocation id() {
return Constants.PACKET_ID_START_RIDING;
}
}

View File

@ -6,29 +6,24 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtOps;
import net.minecraft.nbt.Tag;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Player;
import tschipp.carryon.Constants;
import tschipp.carryon.common.scripting.CarryOnScript;
import tschipp.carryon.common.scripting.ScriptManager;
import tschipp.carryon.networking.PacketBase;
import java.util.List;
public class ClientboundSyncScriptsPacket extends PacketBase
public record ClientboundSyncScriptsPacket(Tag serialized) implements PacketBase
{
private Tag serialized;
public ClientboundSyncScriptsPacket(FriendlyByteBuf buf)
{
this.serialized = buf.readNbt().get("data");
}
public ClientboundSyncScriptsPacket(Tag serialized)
{
this.serialized = serialized;
this(buf.readNbt().get("data"));
}
@Override
public void toBytes(FriendlyByteBuf buf)
public void write(FriendlyByteBuf buf)
{
CompoundTag tag = new CompoundTag();
tag.put("data", serialized);
@ -43,4 +38,9 @@ public class ClientboundSyncScriptsPacket extends PacketBase
ScriptManager.SCRIPTS.clear();
ScriptManager.SCRIPTS.addAll(scripts);
}
@Override
public ResourceLocation id() {
return Constants.PACKET_ID_SYNC_SCRIPTS;
}
}

View File

@ -1,28 +1,23 @@
package tschipp.carryon.networking.serverbound;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.player.Player;
import tschipp.carryon.Constants;
import tschipp.carryon.common.carry.CarryOnData;
import tschipp.carryon.common.carry.CarryOnDataManager;
import tschipp.carryon.networking.PacketBase;
public class ServerboundCarryKeyPressedPacket extends PacketBase
public record ServerboundCarryKeyPressedPacket(boolean pressed) implements PacketBase
{
boolean pressed;
public ServerboundCarryKeyPressedPacket(FriendlyByteBuf buf)
{
this.pressed = buf.readBoolean();
}
public ServerboundCarryKeyPressedPacket(boolean pressed)
{
this.pressed = pressed;
this(buf.readBoolean());
}
@Override
public void toBytes(FriendlyByteBuf buf)
public void write(FriendlyByteBuf buf)
{
buf.writeBoolean(pressed);
}
@ -34,4 +29,9 @@ public class ServerboundCarryKeyPressedPacket extends PacketBase
carry.setKeyPressed(this.pressed);
CarryOnDataManager.setCarryData(player, carry);
}
@Override
public ResourceLocation id() {
return Constants.PACKET_ID_KEY_PRESSED;
}
}

View File

@ -36,9 +36,9 @@ public interface IPlatformHelper {
void registerConfig(BuiltConfig cfg);
<T extends PacketBase> void registerServerboundPacket(ResourceLocation id, int numericalId, Class<T> clazz, BiConsumer<T, FriendlyByteBuf> writer, Function<FriendlyByteBuf, T> reader, BiConsumer<T, Player> handler);
<T extends PacketBase> void registerServerboundPacket(ResourceLocation id, int numericalId, Class<T> clazz, BiConsumer<T, FriendlyByteBuf> writer, Function<FriendlyByteBuf, T> reader, BiConsumer<T, Player> handler, Object... args);
<T extends PacketBase> void registerClientboundPacket(ResourceLocation id, int numericalId, Class<T> clazz, BiConsumer<T, FriendlyByteBuf> writer, Function<FriendlyByteBuf, T> reader, BiConsumer<T, Player> handler);
<T extends PacketBase> void registerClientboundPacket(ResourceLocation id, int numericalId, Class<T> clazz, BiConsumer<T, FriendlyByteBuf> writer, Function<FriendlyByteBuf, T> reader, BiConsumer<T, Player> handler, Object... args);
void sendPacketToServer(ResourceLocation id, PacketBase packet);

View File

@ -1,21 +1,26 @@
plugins {
id 'fabric-loom' version '1.0-SNAPSHOT'
id 'java'
id 'maven-publish'
id 'idea'
id 'fabric-loom' version '1.5-SNAPSHOT'
}
base {
archivesName = "${mod_id}-fabric-${minecraft_version}"
}
archivesBaseName = "${mod_id}-fabric-${minecraft_version}"
/*
apply from: 'https://raw.githubusercontent.com/MinecraftModDevelopment/Gradle-Collection/22e7d543a18cd30675277fbfa3669e3d9e206010/generic/secrets.gradle'
if (project.hasProperty('secretFile')) {
loadSecrets(new File((String) findProperty('secretFile')))
}
*/
if (System.getenv('BUILD_NUMBER') != null) {
version += "." + System.getenv('BUILD_NUMBER')
}
repositories {
maven { url 'https://jitpack.io' }
maven {
url "https://maven.siphalor.de/"
name "Siphalor's Maven"
@ -33,13 +38,17 @@ dependencies {
modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_version}"
implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.1'
implementation project(":Common")
include implementation("com.github.llamalad7.mixinextras:mixinextras-fabric:${mixinextras_version}")
annotationProcessor("com.github.llamalad7.mixinextras:mixinextras-fabric:${mixinextras_version}")
modRuntimeOnly "de.siphalor:amecsapi-1.20:1.5.0+mc1.20-pre1"
modRuntimeOnly "de.siphalor:amecsapi-1.20:1.5.6+mc1.20.2"
}
loom {
if (project(":Common").file("src/main/resources/${mod_id}.accesswidener").exists()) {
accessWidenerPath.set(project(":Common").file("src/main/resources/${mod_id}.accesswidener"))
}
mixin {
defaultRefmapName.set("${mod_id}.refmap.json")
}
runs {
client {
client()
@ -56,37 +65,27 @@ loom {
}
}
var refmap_target = archivesBaseName + "-"
tasks.withType(JavaCompile).configureEach {
source(project(":Common").sourceSets.main.allSource)
}
tasks.withType(Javadoc).configureEach {
source(project(":Common").sourceSets.main.allJava)
}
tasks.named("sourcesJar", Jar) {
from(project(":Common").sourceSets.main.allSource)
}
processResources {
from project(":Common").sourceSets.main.resources
inputs.property "version", project.version
inputs.property "refmap_target", refmap_target
filesMatching("fabric.mod.json") {
expand "version": project.version
}
filesMatching("carryon.mixins.json") {
expand "refmap_target": refmap_target
}
}
tasks.withType(JavaCompile) {
source(project(":Common").sourceSets.main.allSource)
}
publishing {
publications {
mavenJava(MavenPublication) {
groupId project.group
artifactId project.archivesBaseName
version project.version
artifactId base.archivesName.get()
from components.java
}
}
repositories {
maven {
url "file://" + System.getenv("local_maven")

View File

@ -27,7 +27,7 @@ public class CarryOnFabricClientMod implements ClientModInitializer
public static void sendPacketToServer(ResourceLocation id, PacketBase packet)
{
FriendlyByteBuf buf = PacketByteBufs.create();
packet.toBytes(buf);
packet.write(buf);
ClientPlayNetworking.send(id, buf);
}

View File

@ -41,7 +41,7 @@ public class FabricPlatformHelper implements IPlatformHelper {
}
@Override
public <T extends PacketBase> void registerServerboundPacket(ResourceLocation id, int numericalId, Class<T> clazz, BiConsumer<T, FriendlyByteBuf> writer, Function<FriendlyByteBuf, T> reader, BiConsumer<T, Player> handler)
public <T extends PacketBase> void registerServerboundPacket(ResourceLocation id, int numericalId, Class<T> clazz, BiConsumer<T, FriendlyByteBuf> writer, Function<FriendlyByteBuf, T> reader, BiConsumer<T, Player> handler, Object... args)
{
ServerPlayNetworking.registerGlobalReceiver(id, (server, player, packetHandler, buf, responseSender) -> {
T packet = reader.apply(buf);
@ -52,7 +52,7 @@ public class FabricPlatformHelper implements IPlatformHelper {
}
@Override
public <T extends PacketBase> void registerClientboundPacket(ResourceLocation id, int numericalId, Class<T> clazz, BiConsumer<T, FriendlyByteBuf> writer, Function<FriendlyByteBuf, T> reader, BiConsumer<T, Player> handler)
public <T extends PacketBase> void registerClientboundPacket(ResourceLocation id, int numericalId, Class<T> clazz, BiConsumer<T, FriendlyByteBuf> writer, Function<FriendlyByteBuf, T> reader, BiConsumer<T, Player> handler, Object... args)
{
CarryOnFabricClientMod.registerClientboundPacket(id, reader, handler);
}
@ -67,7 +67,7 @@ public class FabricPlatformHelper implements IPlatformHelper {
public void sendPacketToPlayer(ResourceLocation id, PacketBase packet, ServerPlayer player)
{
FriendlyByteBuf buf = PacketByteBufs.create();
packet.toBytes(buf);
packet.write(buf);
ServerPlayNetworking.send(player, id, buf);
}
}

View File

@ -1,11 +1,11 @@
{
"schemaVersion": 1,
"id": "carryon",
"id": "${mod_id}",
"version": "${version}",
"name": "Carry On",
"description": "Carry On is a simple mod that improves game interaction by allowing players to pick up, carry, and place single block Tile Entities using only their empty hands.",
"name": "${mod_name}",
"description": "${description}",
"authors": [
"Tschipp", "Purplicious_Cow", "cy4n"
"Tschipp", "Purplicious_Cow"
],
"contact": {
"homepage": "https://tschipp.ch/",
@ -13,7 +13,7 @@
"issues": "https://github.com/Tschipp/CarryOn/issues"
},
"license": "GNU LGPLv3",
"license": "${license}",
"icon": "logo.png",
"environment": "*",
@ -31,9 +31,9 @@
],
"depends": {
"fabricloader": ">=0.14",
"fabricloader": ">=${fabric_loader_version}",
"fabric-api": "*",
"minecraft": ">=1.20",
"minecraft": "${minecraft_version}",
"java": ">=17"
}
}

View File

@ -1,38 +1,29 @@
buildscript {
repositories {
maven { url = 'https://maven.minecraftforge.net' }
maven { url = 'https://repo.spongepowered.org/repository/maven-public/' }
maven { url = 'https://maven.parchmentmc.org' }
mavenCentral()
gradlePluginPortal()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT'
classpath 'org.parchmentmc:librarian:1.+'
classpath 'gradle.plugin.com.github.johnrengelman:shadow:7.1.2'
}
plugins {
id 'idea'
id 'java'
id 'maven-publish'
id 'net.minecraftforge.gradle' version '[6.0,6.2)'
id 'org.spongepowered.mixin' version '0.7-SNAPSHOT'
id 'org.parchmentmc.librarian.forgegradle' version '1.+'
}
apply plugin: 'java'
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse'
apply plugin: 'org.spongepowered.mixin'
apply plugin: 'maven-publish'
apply plugin: 'org.parchmentmc.librarian.forgegradle'
apply plugin: 'com.github.johnrengelman.shadow'
/*
apply from: 'https://raw.githubusercontent.com/MinecraftModDevelopment/Gradle-Collection/22e7d543a18cd30675277fbfa3669e3d9e206010/generic/secrets.gradle'
if (project.hasProperty('secretFile')) {
loadSecrets(new File((String) findProperty('secretFile')))
}
*/
if (System.getenv('BUILD_NUMBER') != null) {
version += "." + System.getenv('BUILD_NUMBER')
}
jarJar.enable()
archivesBaseName = "${mod_id}-forge-${minecraft_version}"
base {
archivesName = "${mod_id}-forge-${minecraft_version}"
}
mixin {
add sourceSets.main, "${mod_id}.refmap.json"
@ -43,12 +34,10 @@ mixin {
minecraft {
mappings channel: 'parchment', version: "${parchment_mappings}"
if (project.hasProperty('forge_ats_enabled') && project.findProperty('forge_ats_enabled').toBoolean()) {
// This location is hardcoded in Forge and can not be changed.
// https://github.com/MinecraftForge/MinecraftForge/blob/be1698bb1554f9c8fa2f58e32b9ab70bc4385e60/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFile.java#L123
copyIdeResources = true
if (file('src/main/resources/META-INF/accesstransformer.cfg').exists()) {
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
project.logger.debug('Forge Access Transformers are enabled for this project.')
}
runs {
@ -58,7 +47,7 @@ minecraft {
taskName 'Client'
property 'mixin.env.remapRefMap', 'true'
property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
args "-mixin.config=${mod_id}.mixins.json", "-mixin.config=${mod_id}.forge.mixins.json"
//args "-mixin.config=${mod_id}.mixins.json", "-mixin.config=${mod_id}.forge.mixins.json"
mods {
modClientRun {
source sourceSets.main
@ -73,7 +62,7 @@ minecraft {
taskName 'Server'
property 'mixin.env.remapRefMap', 'true'
property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
args "-mixin.config=${mod_id}.mixins.json", "-mixin.config=${mod_id}.forge.mixins.json"
//args "-mixin.config=${mod_id}.mixins.json", "-mixin.config=${mod_id}.forge.mixins.json"
mods {
modServerRun {
source sourceSets.main
@ -89,7 +78,7 @@ minecraft {
taskName 'Data'
property 'mixin.env.remapRefMap', 'true'
property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
args "-mixin.config=${mod_id}.mixins.json", "-mixin.config=${mod_id}.forge.mixins.json"
//args "-mixin.config=${mod_id}.mixins.json", "-mixin.config=${mod_id}.forge.mixins.json"
mods {
modDataRun {
source sourceSets.main
@ -103,9 +92,6 @@ minecraft {
sourceSets.main.resources.srcDir 'src/generated/resources'
repositories {
maven {
url 'https://maven.blamejared.com'
}
flatDir {
dirs 'libs'
}
@ -116,13 +102,13 @@ repositories {
dependencies {
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
compileOnly project(":Common")
implementation(annotationProcessor("com.github.llamalad7.mixinextras:mixinextras-common:${mixinextras_version}"))
implementation(jarJar("com.github.llamalad7.mixinextras:mixinextras-forge:${mixinextras_version}")) {
compileOnly(annotationProcessor("io.github.llamalad7:mixinextras-common:${mixinextras_version}"))
implementation(jarJar("io.github.llamalad7:mixinextras-forge:${mixinextras_version}")) {
jarJar.ranged(it, "[${mixinextras_version},)")
}
//implementation fg.deobf("net.darkhax.gamestages:GameStages-Forge-1.19.2:11.0.2")
//implementation fg.deobf("net.darkhax.bookshelf:Bookshelf-Forge-1.19.3:17.0.2")
annotationProcessor 'org.spongepowered:mixin:0.8.4-SNAPSHOT:processor'
annotationProcessor 'org.spongepowered:mixin:0.8.5-SNAPSHOT:processor'
fileTree("libs").matching {
include "*.jar"
@ -135,32 +121,28 @@ dependencies {
}
}
reobf {
jarJar {}
}
tasks.withType(JavaCompile) {
tasks.withType(JavaCompile).configureEach {
source(project(":Common").sourceSets.main.allSource)
}
tasks.withType(Javadoc).configureEach {
source(project(":Common").sourceSets.main.allJava)
}
tasks.named("sourcesJar", Jar) {
from(project(":Common").sourceSets.main.allSource)
}
processResources {
from project(":Common").sourceSets.main.resources
filesMatching('*.mixins.json') {
expand "refmap_target": "${mod_id}."
}
}
jar.finalizedBy('reobfJar')
publishing {
publications {
mavenJava(MavenPublication) {
groupId project.group
artifactId project.archivesBaseName
version project.version
artifact jar
artifactId base.archivesName.get()
from components.java
fg.component(it)
}
}
repositories {
@ -169,3 +151,13 @@ publishing {
}
}
}
// Merge the resources and classes into the same directory.
// This is done because java expects modules to be in a single directory.
// And if we have it in multiple we have to do performance intensive hacks like having the UnionFileSystem
// This will eventually be migrated to ForgeGradle so modders don't need to manually do it. But that is later.
sourceSets.each {
def dir = layout.buildDirectory.dir("sourcesSets/$it.name")
it.output.resourcesDir = dir
it.java.destinationDirectory = dir
}

View File

@ -1,13 +1,12 @@
package tschipp.carryon;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.fml.InterModComms;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.network.NetworkRegistry;
import net.minecraftforge.network.simple.SimpleChannel;
import net.minecraftforge.network.ChannelBuilder;
import net.minecraftforge.network.SimpleChannel;
import tschipp.carryon.config.forge.ConfigLoaderImpl;
@Mod(Constants.MOD_ID)
@ -31,7 +30,7 @@ public class CarryOnForge {
private void setup(final FMLCommonSetupEvent event)
{
network = NetworkRegistry.newSimpleChannel(new ResourceLocation(Constants.MOD_ID, "carryonpackets"), () -> "1.0", "1.0"::equals, "1.0"::equals);
network = ChannelBuilder.named(new ResourceLocation(Constants.MOD_ID, "carryonpackets")).simpleChannel();
CarryOnCommon.registerServerPackets();
CarryOnCommon.registerClientPackets();

View File

@ -4,10 +4,10 @@ import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.player.Player;
import net.minecraftforge.event.network.CustomPayloadEvent;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.loading.FMLLoader;
import net.minecraftforge.network.NetworkDirection;
import net.minecraftforge.network.NetworkEvent.Context;
import net.minecraftforge.network.PacketDistributor;
import tschipp.carryon.CarryOnCommonClient;
import tschipp.carryon.CarryOnForge;
@ -16,10 +16,8 @@ import tschipp.carryon.config.forge.ConfigLoaderImpl;
import tschipp.carryon.networking.PacketBase;
import tschipp.carryon.platform.services.IPlatformHelper;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Function;
import java.util.function.Supplier;
public class ForgePlatformHelper implements IPlatformHelper {
@ -47,47 +45,55 @@ public class ForgePlatformHelper implements IPlatformHelper {
}
@Override
public <T extends PacketBase> void registerServerboundPacket(ResourceLocation id, int numericalId, Class<T> clazz, BiConsumer<T, FriendlyByteBuf> writer, Function<FriendlyByteBuf, T> reader, BiConsumer<T, Player> handler)
public <T extends PacketBase> void registerServerboundPacket(ResourceLocation id, int numericalId, Class<T> clazz, BiConsumer<T, FriendlyByteBuf> writer, Function<FriendlyByteBuf, T> reader, BiConsumer<T, Player> handler, Object... args)
{
BiConsumer<T, Supplier<Context>> serverHandler = (packet, ctx) -> {
if(ctx.get().getDirection().getReceptionSide().isServer())
BiConsumer<T, CustomPayloadEvent.Context> serverHandler = (packet, ctx) -> {
if(ctx.getDirection().getReceptionSide().isServer())
{
ctx.get().setPacketHandled(true);
ctx.get().enqueueWork(() -> {
handler.accept(packet, ctx.get().getSender());
ctx.setPacketHandled(true);
ctx.enqueueWork(() -> {
handler.accept(packet, ctx.getSender());
});
}
};
CarryOnForge.network.registerMessage(numericalId, clazz, writer, reader, serverHandler, Optional.of(NetworkDirection.PLAY_TO_SERVER));
CarryOnForge.network.messageBuilder(clazz, numericalId, NetworkDirection.PLAY_TO_SERVER)
.encoder(writer)
.decoder(reader)
.consumerMainThread(serverHandler)
.add();
}
@Override
public <T extends PacketBase> void registerClientboundPacket(ResourceLocation id, int numericalId, Class<T> clazz, BiConsumer<T, FriendlyByteBuf> writer, Function<FriendlyByteBuf, T> reader, BiConsumer<T, Player> handler)
public <T extends PacketBase> void registerClientboundPacket(ResourceLocation id, int numericalId, Class<T> clazz, BiConsumer<T, FriendlyByteBuf> writer, Function<FriendlyByteBuf, T> reader, BiConsumer<T, Player> handler, Object... args)
{
BiConsumer<T, Supplier<Context>> clientHandler = (packet, ctx) -> {
if(ctx.get().getDirection().getReceptionSide().isClient())
BiConsumer<T, CustomPayloadEvent.Context> clientHandler = (packet, ctx) -> {
if(ctx.getDirection().getReceptionSide().isClient())
{
ctx.get().setPacketHandled(true);
ctx.get().enqueueWork(() -> {
ctx.setPacketHandled(true);
ctx.enqueueWork(() -> {
handler.accept(packet, CarryOnCommonClient.getPlayer());
});
}
};
CarryOnForge.network.registerMessage(numericalId, clazz, writer, reader, clientHandler, Optional.of(NetworkDirection.PLAY_TO_CLIENT));
CarryOnForge.network.messageBuilder(clazz, numericalId, NetworkDirection.PLAY_TO_CLIENT)
.encoder(writer)
.decoder(reader)
.consumerMainThread(clientHandler)
.add();
}
@Override
public void sendPacketToServer(ResourceLocation id, PacketBase packet)
{
CarryOnForge.network.sendToServer(packet);
CarryOnForge.network.send(packet, PacketDistributor.SERVER.noArg());
}
@Override
public void sendPacketToPlayer(ResourceLocation id, PacketBase packet, ServerPlayer player)
{
CarryOnForge.network.send(PacketDistributor.PLAYER.with(() -> player), packet);
CarryOnForge.network.send(packet, PacketDistributor.PLAYER.with(player));
}
}

View File

@ -1,33 +1,33 @@
modLoader="javafml" #mandatory
loaderVersion="[46,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
license="GNU LGPLv3"
loaderVersion="${forge_loader_version_range}" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
license="${license}"
issueTrackerURL="https://github.com/Tschipp/CarryOn/issues"
[[mods]] #mandatory
modId="carryon" #mandatory
version="${file.jarVersion}" #mandatory
displayName="Carry On" #mandatory
modId="${mod_id}" #mandatory
version="${version}" #mandatory
displayName="${mod_name}" #mandatory
displayURL="https://tschipp.ch" #optional
logoFile="logo.png" #optional
authors="Tschipp, Purplicious_Cow, cy4n" #optional
description='''Carry On is a simple mod that improves game interaction by allowing players to pick up, carry, and place single block Tile Entities using only their empty hands.'''
authors="${mod_author}" #optional
description='''${description}'''
[[dependencies.carryon]] #optional
[[dependencies.${mod_id}]] #optional
# the modid of the dependency
modId="forge" #mandatory
# Does this dependency have to exist - if not, ordering below must be specified
mandatory=true #mandatory
# The version range of the dependency
versionRange="[46,47.1.3],[47.1.43,)" #mandatory
versionRange="${forge_version_range}" #mandatory
# An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory
ordering="NONE"
# Side this dependency is applied on - BOTH, CLIENT or SERVER
side="BOTH"
# Here's another dependency
[[dependencies.carryon]]
[[dependencies.${mod_id}]]
modId="minecraft"
mandatory=true
versionRange="[1.20,1.21)"
versionRange="${minecraft_version_range}"
ordering="NONE"
side="BOTH"

106
NeoForge/build.gradle Normal file
View File

@ -0,0 +1,106 @@
plugins {
id 'idea'
id 'maven-publish'
id 'net.neoforged.gradle.userdev' version '7.0.81'
id 'java-library'
}
if (System.getenv('BUILD_NUMBER') != null) {
version += "." + System.getenv('BUILD_NUMBER')
}
base {
archivesName = "${mod_id}-neoforge-${minecraft_version}"
}
//jarJar.enable()
//archivesBaseName = "${mod_id}-neoforge-${minecraft_version}"
/*
mixin {
add sourceSets.main, "${mod_id}.refmap.json"
config "${mod_id}.mixins.json"
config "${mod_id}.forge.mixins.json"
}
*/
if (file('src/main/resources/META-INF/accesstransformer.cfg').exists()) {
minecraft.accessTransformers.file file('src/main/resources/META-INF/accesstransformer.cfg')
}
runs {
// applies to all the run configs below
configureEach {
modSource project.sourceSets.main
}
client {
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
}
server {
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
programArgument '--nogui'
}
// This run config launches GameTestServer and runs all registered gametests, then exits.
// By default, the server will crash when no gametests are provided.
// The gametest system is also enabled by default for other run configs under the /test command.
gameTestServer {
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
}
data {
// example of overriding the workingDirectory set in configureEach above, uncomment if you want to use it
// workingDirectory project.file('run-data')
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
}
}
sourceSets.main.resources.srcDir 'src/generated/resources'
dependencies {
implementation "net.neoforged:neoforge:${neoforge_version}"
compileOnly project(":Common")
//implementation fg.deobf("net.darkhax.gamestages:GameStages-Forge-1.19.2:11.0.2")
//implementation fg.deobf("net.darkhax.bookshelf:Bookshelf-Forge-1.19.3:17.0.2")
}
// NeoGradle compiles the game, but we don't want to add our common code to the game's code
Spec<Task> notNeoTask = { Task it -> !it.name.startsWith("neo") } as Spec<Task>
tasks.withType(JavaCompile).matching(notNeoTask).configureEach {
source(project(":Common").sourceSets.main.allSource)
}
tasks.withType(Javadoc).matching(notNeoTask).configureEach {
source(project(":Common").sourceSets.main.allJava)
}
tasks.named("sourcesJar", Jar) {
from(project(":Common").sourceSets.main.allSource)
}
tasks.withType(ProcessResources).matching(notNeoTask).configureEach {
from project(":Common").sourceSets.main.resources
}
publishing {
publications {
mavenJava(MavenPublication) {
artifactId base.archivesName.get()
from components.java
}
}
repositories {
maven {
url "file://" + System.getenv("local_maven")
}
}
}

View File

@ -0,0 +1,41 @@
package tschipp.carryon;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.Mod;
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
import net.neoforged.neoforge.common.NeoForge;
import net.neoforged.neoforge.network.event.RegisterPayloadHandlerEvent;
import net.neoforged.neoforge.network.registration.IPayloadRegistrar;
import tschipp.carryon.config.neoforge.ConfigLoaderImpl;
@Mod(Constants.MOD_ID)
public class CarryOnNeoForge {
public CarryOnNeoForge(IEventBus bus) {
// This method is invoked by the Forge mod loader when it is ready
// to load your mod. You can access Forge and Common code in this
// project.
// Use Forge to bootstrap the Common mod.
CarryOnCommon.registerConfig();
bus.addListener(this::setup);
bus.addListener(this::registerPackets);
ConfigLoaderImpl.initialize();
}
private void setup(final FMLCommonSetupEvent event)
{
}
public void registerPackets(final RegisterPayloadHandlerEvent event) {
final IPayloadRegistrar registrar = event.registrar(Constants.MOD_ID)
.versioned("1.0.0");
CarryOnCommon.registerServerPackets(registrar);
CarryOnCommon.registerClientPackets(registrar);
}
}

View File

@ -0,0 +1,34 @@
package tschipp.carryon.compat;
import net.minecraft.world.entity.player.Player;
import tschipp.carryon.Constants;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class GamestageCompat
{
private static Method hasStage;
static {
try {
Class<?> gamestageHelper = Class.forName("net.darkhax.gamestages.GameStageHelper");
hasStage = gamestageHelper.getMethod("hasStage", Player.class, String.class);
} catch (Exception e) {
Constants.LOG.info("Gamestages not found. Disabling.");
}
}
public static boolean hasStage(Player player, String stage)
{
if(hasStage == null)
return true;
try {
return (boolean) hasStage.invoke(null, player, stage);
} catch (IllegalAccessException | InvocationTargetException e) {
}
return true;
}
}

View File

@ -0,0 +1,108 @@
package tschipp.carryon.config.neoforge;
import com.electronwill.nightconfig.core.AbstractConfig;
import com.electronwill.nightconfig.core.UnmodifiableConfig;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.ModLoadingContext;
import net.neoforged.fml.common.Mod;
import net.neoforged.fml.config.IConfigSpec;
import net.neoforged.fml.config.ModConfig;
import net.neoforged.fml.event.config.ModConfigEvent;
import net.neoforged.neoforge.common.ModConfigSpec;
import net.neoforged.neoforge.common.NeoForge;
import tschipp.carryon.Constants;
import tschipp.carryon.config.*;
import java.util.*;
@Mod.EventBusSubscriber(modid = Constants.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
public class ConfigLoaderImpl {
public static final Map<ModConfigSpec, BuiltConfig> CONFIGS = new HashMap<>();
public static void initialize() {
ConfigLoaderImpl.CONFIGS.forEach((spec, config) -> {
if(config.fileName.contains("client"))
ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, spec, config.fileName+".toml");
else
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, spec, config.fileName+".toml");
});
}
@SubscribeEvent
public static void onConfigLoad(ModConfigEvent.Loading loading) {
loadConfig(loading.getConfig().getSpec());
ConfigLoader.onConfigLoaded();
}
@SubscribeEvent
public static void onConfigReload(ModConfigEvent.Reloading loading) {
loadConfig(loading.getConfig().getSpec());
ConfigLoader.onConfigLoaded();
}
private static void loadConfig(IConfigSpec<ModConfigSpec> spec) {
BuiltConfig builtConfig = CONFIGS.get(spec.self());
if (builtConfig == null) return;
loadConfig(builtConfig, spec.self().getValues());
}
private static void loadConfig(BuiltCategory category, UnmodifiableConfig config) {
config.valueMap().forEach((id, value) -> {
if (value instanceof ModConfigSpec.ConfigValue<?> configValue) {
category.getProperty(id).ifPresent(data -> {
if (configValue instanceof ModConfigSpec.BooleanValue booleanValue)
data.setBoolean(booleanValue.get());
if (configValue instanceof ModConfigSpec.IntValue intValue)
data.setInt(intValue.get());
if (configValue instanceof ModConfigSpec.DoubleValue doubleValue)
data.setDouble(doubleValue.get());
if(configValue.get() instanceof List<?> listVal)
data.setStringArray(listVal.toArray(new String[listVal.size()]));
});
} else if (value instanceof AbstractConfig subConfig) {
category.getCategory(id).ifPresent(cat -> loadConfig(cat, subConfig));
}
});
}
public static void registerConfig(BuiltConfig config) {
try {
ModConfigSpec.Builder builder = new ModConfigSpec.Builder();
for (PropertyData property : config.properties) buildProperty(builder, property);
for (BuiltCategory category : config.categories) buildCategory(builder, category);
CONFIGS.put(builder.build(), config);
}catch (Exception e) {
e.printStackTrace();
}
}
private static void buildCategory(ModConfigSpec.Builder builder, BuiltCategory category) throws IllegalAccessException {
builder.push(category.category);
if (category.categoryDesc != null) builder.comment(category.categoryDesc);
for (PropertyData property : category.properties) buildProperty(builder, property);
for (BuiltCategory builtCategory : category.categories) buildCategory(builder, builtCategory);
builder.pop();
}
private static void buildProperty(ModConfigSpec.Builder builder, PropertyData data) throws IllegalAccessException {
AnnotationData annotationData = data.data();
builder.comment(annotationData.description());
switch (annotationData.type()) {
case BOOLEAN -> builder.define(data.getId(), data.getBoolean());
case INT -> builder.defineInRange(data.getId(), data.getInt(), annotationData.min(), annotationData.max());
case DOUBLE -> builder.defineInRange(data.getId(), data.getDouble(), annotationData.minD(), annotationData.maxD());
case STRING_ARRAY -> builder.defineListAllowEmpty(List.of(data.getId()), () -> {
try {
return Arrays.asList(data.getStringArray());
} catch (IllegalAccessException e) {
e.printStackTrace();
}
return new ArrayList<>();
}, obj -> obj instanceof String);
default -> throw new IllegalAccessException("Unknown property type.");
}
}
}

View File

@ -0,0 +1,83 @@
package tschipp.carryon.events;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.world.entity.player.Player;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.api.distmarker.OnlyIn;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.Mod;
import net.neoforged.neoforge.client.event.RenderHandEvent;
import net.neoforged.neoforge.client.event.RenderLevelStageEvent;
import net.neoforged.neoforge.client.event.ScreenEvent;
import net.neoforged.neoforge.event.TickEvent;
import tschipp.carryon.CarryOnCommonClient;
import tschipp.carryon.Constants;
import tschipp.carryon.client.render.CarriedObjectRender;
import tschipp.carryon.client.render.CarryRenderHelper;
import tschipp.carryon.common.carry.CarryOnData;
import tschipp.carryon.common.carry.CarryOnDataManager;
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.FORGE, modid = Constants.MOD_ID, value = Dist.CLIENT)
public class ClientEvents {
@OnlyIn(Dist.CLIENT)
@SubscribeEvent
public static void renderHand(RenderHandEvent event)
{
Player player = Minecraft.getInstance().player;
MultiBufferSource buffer = event.getMultiBufferSource();
PoseStack matrix = event.getPoseStack();
int light = event.getPackedLight();
float partialTicks = event.getPartialTick();
if(CarriedObjectRender.drawFirstPerson(player, buffer, matrix, light, partialTicks) && CarryRenderHelper.getPerspective() == 0)
event.setCanceled(true);
}
@OnlyIn(Dist.CLIENT)
@SubscribeEvent
public static void onRenderLevel(RenderLevelStageEvent event)
{
if(event.getStage() == RenderLevelStageEvent.Stage.AFTER_PARTICLES)
CarriedObjectRender.drawThirdPerson(event.getPartialTick(), event.getPoseStack());
}
@OnlyIn(Dist.CLIENT)
@SubscribeEvent
public static void onGuiInit(ScreenEvent.Init.Pre event)
{
if (event.getScreen() != null)
{
boolean inventory = event.getScreen() instanceof AbstractContainerScreen;
Minecraft mc = Minecraft.getInstance();
Player player = mc.player;
if (player != null && inventory)
{
CarryOnData carry = CarryOnDataManager.getCarryData(player);
if (carry.isCarrying())
{
mc.player.closeContainer();
mc.screen = null;
mc.mouseHandler.grabMouse();
event.setCanceled(true);
}
}
}
}
@OnlyIn(Dist.CLIENT)
@SubscribeEvent
public static void onClientTick(TickEvent.ClientTickEvent event)
{
if(event.phase == TickEvent.Phase.END)
{
CarryOnCommonClient.checkForKeybinds();
CarryOnCommonClient.onCarryClientTick();
}
}
}

View File

@ -0,0 +1,193 @@
package tschipp.carryon.events;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.MobSpawnType;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.ServerLevelAccessor;
import net.neoforged.bus.api.Event;
import net.neoforged.bus.api.EventPriority;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.Mod;
import net.neoforged.neoforge.common.NeoForge;
import net.neoforged.neoforge.common.util.BlockSnapshot;
import net.neoforged.neoforge.event.*;
import net.neoforged.neoforge.event.entity.living.LivingAttackEvent;
import net.neoforged.neoforge.event.entity.living.MobSpawnEvent;
import net.neoforged.neoforge.event.entity.player.AttackEntityEvent;
import net.neoforged.neoforge.event.entity.player.PlayerEvent;
import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent;
import net.neoforged.neoforge.event.level.BlockEvent;
import tschipp.carryon.CarryOnCommon;
import tschipp.carryon.Constants;
import tschipp.carryon.common.carry.CarryOnData;
import tschipp.carryon.common.carry.CarryOnData.CarryType;
import tschipp.carryon.common.carry.CarryOnDataManager;
import tschipp.carryon.common.carry.PickupHandler;
import tschipp.carryon.common.carry.PlacementHandler;
import tschipp.carryon.common.scripting.ScriptReloadListener;
import tschipp.carryon.config.ConfigLoader;
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.FORGE, modid = Constants.MOD_ID)
public class CommonEvents
{
@SubscribeEvent(priority = EventPriority.HIGH)
public static void onBlockClick(PlayerInteractEvent.RightClickBlock event)
{
if (event.isCanceled())
return;
Player player = event.getEntity();
Level level = event.getLevel();
BlockPos pos = event.getPos();
if (level.isClientSide)
return;
boolean success = false;
CarryOnData carry = CarryOnDataManager.getCarryData(player);
if (!carry.isCarrying()) {
if (PickupHandler.tryPickUpBlock((ServerPlayer) player, pos, level, (pState, pPos) -> {
BlockEvent.BreakEvent breakEvent = new BlockEvent.BreakEvent(level, pPos, pState, player);
NeoForge.EVENT_BUS.post(breakEvent);
return !breakEvent.isCanceled();
})) {
success = true;
}
} else {
if (carry.isCarrying(CarryType.BLOCK)) {
PlacementHandler.tryPlaceBlock((ServerPlayer) player, pos, event.getFace(), (pos2, state) -> {
BlockSnapshot snapshot = BlockSnapshot.create(level.dimension(), level, pos2);
BlockEvent.EntityPlaceEvent event1 = new BlockEvent.EntityPlaceEvent(snapshot, level.getBlockState(pos), player);
NeoForge.EVENT_BUS.post(event1);
return !event1.isCanceled();
});
} else {
PlacementHandler.tryPlaceEntity((ServerPlayer) player, pos, event.getFace(), (pPos, toPlace) -> {
if (toPlace instanceof Mob mob) {
MobSpawnEvent.FinalizeSpawn checkSpawn = new MobSpawnEvent.FinalizeSpawn(mob, (ServerLevelAccessor) level, pPos.x, pPos.y, pPos.z, level.getCurrentDifficultyAt(new BlockPos((int) pPos.x, (int) pPos.y, (int) pPos.z)), MobSpawnType.EVENT, null, null, null);
NeoForge.EVENT_BUS.post(checkSpawn);
return event.getResult() != Event.Result.DENY;
}
return true;
});
}
success = true;
}
if (success) {
event.setUseBlock(Event.Result.DENY);
event.setUseItem(Event.Result.DENY);
event.setCancellationResult(InteractionResult.SUCCESS);
event.setCanceled(true);
}
}
@SubscribeEvent(priority = EventPriority.HIGH)
public static void onEntityRightClick(PlayerInteractEvent.EntityInteract event)
{
if (event.isCanceled())
return;
Player player = event.getEntity();
Level level = event.getLevel();
Entity target = event.getTarget();
if (level.isClientSide)
return;
CarryOnData carry = CarryOnDataManager.getCarryData(player);
if (!carry.isCarrying()) {
if (PickupHandler.tryPickupEntity((ServerPlayer) player, target, (toPickup) -> {
EntityPickupEvent pickupEvent = new EntityPickupEvent((ServerPlayer) player, toPickup);
NeoForge.EVENT_BUS.post(pickupEvent);
return !pickupEvent.isCanceled();
})) {
event.setCancellationResult(InteractionResult.SUCCESS);
event.setCanceled(true);
return;
}
} else if (carry.isCarrying(CarryType.ENTITY) || carry.isCarrying(CarryType.PLAYER)) {
PlacementHandler.tryStackEntity((ServerPlayer) player, target);
}
}
@SubscribeEvent
public static void onRegisterCommands(RegisterCommandsEvent event)
{
CarryOnCommon.registerCommands(event.getDispatcher());
}
@SubscribeEvent
public static void onDatapackRegister(AddReloadListenerEvent event)
{
event.addListener(new ScriptReloadListener());
}
@SubscribeEvent
public static void onDatapackSync(OnDatapackSyncEvent event)
{
ServerPlayer player = event.getPlayer();
if (player == null) {
for (ServerPlayer p : event.getPlayerList().getPlayers())
ScriptReloadListener.syncScriptsWithClient(p);
} else
ScriptReloadListener.syncScriptsWithClient(player);
}
@SubscribeEvent
public static void onTagsUpdate(TagsUpdatedEvent event)
{
ConfigLoader.onConfigLoaded();
}
@SubscribeEvent
public static void onServerTick(TickEvent.ServerTickEvent event)
{
if (event.phase == TickEvent.Phase.END)
for (ServerPlayer player : event.getServer().getPlayerList().getPlayers())
CarryOnCommon.onCarryTick(player);
}
@SubscribeEvent
public static void onClone(PlayerEvent.Clone event)
{
if (!event.getOriginal().level().isClientSide)
PlacementHandler.placeCarriedOnDeath((ServerPlayer) event.getOriginal(), (ServerPlayer) event.getEntity(), event.isWasDeath());
}
@SubscribeEvent
public static void harvestSpeed(PlayerEvent.BreakSpeed event)
{
if (!CarryOnCommon.onTryBreakBlock(event.getEntity()))
event.setNewSpeed(0);
}
@SubscribeEvent
public static void attackEntity(AttackEntityEvent event)
{
if(!CarryOnCommon.onAttackedByPlayer(event.getEntity()))
event.setCanceled(true);
}
@SubscribeEvent
public static void onBreakBlock(BlockEvent.BreakEvent event)
{
if (!CarryOnCommon.onTryBreakBlock(event.getPlayer())) {
event.setCanceled(true);
}
}
@SubscribeEvent
public static void playerAttack(LivingAttackEvent event)
{
if(event.getEntity() instanceof Player player)
CarryOnCommon.onPlayerAttacked(player);
}
}

View File

@ -0,0 +1,17 @@
package tschipp.carryon.events;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity;
import net.neoforged.bus.api.Event;
import net.neoforged.bus.api.ICancellableEvent;
public class EntityPickupEvent extends Event implements ICancellableEvent {
public final ServerPlayer player;
public final Entity target;
public EntityPickupEvent(ServerPlayer player, Entity target) {
this.player = player;
this.target = target;
}
}

View File

@ -0,0 +1,58 @@
package tschipp.carryon.events;
import net.neoforged.bus.api.EventPriority;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.InterModComms;
import net.neoforged.fml.common.Mod;
import net.neoforged.fml.event.lifecycle.InterModProcessEvent;
import tschipp.carryon.Constants;
import tschipp.carryon.client.modeloverride.ModelOverrideHandler;
import tschipp.carryon.common.config.ListHandler;
import java.util.stream.Stream;
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD, modid = Constants.MOD_ID)
public class ModBusEvents {
@SubscribeEvent(priority = EventPriority.LOW)
public static void serverLoad(InterModProcessEvent event)
{
Stream<InterModComms.IMCMessage> messages = InterModComms.getMessages(Constants.MOD_ID);
messages.forEach(msg -> {
String method = msg.method();
Object obj = msg.messageSupplier().get();
if (!(obj instanceof String str))
return;
switch (method) {
case "blacklistBlock":
ListHandler.addForbiddenTiles(str);
break;
case "blacklistEntity":
ListHandler.addForbiddenEntities(str);
break;
case "whitelistBlock":
ListHandler.addAllowedTiles(str);
break;
case "whitelistEntity":
ListHandler.addAllowedEntities(str);
break;
case "blacklistStacking":
ListHandler.addForbiddenStacking(str);
break;
case "whitelistStacking":
ListHandler.addAllowedStacking(str);
break;
case "addModelOverride":
ModelOverrideHandler.addFromString(str);
break;
}
});
}
}

View File

@ -0,0 +1,20 @@
package tschipp.carryon.events;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.api.distmarker.OnlyIn;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.Mod;
import net.neoforged.neoforge.client.event.RegisterKeyMappingsEvent;
import tschipp.carryon.Constants;
import tschipp.carryon.client.keybinds.CarryOnKeybinds;
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD, modid = Constants.MOD_ID, value = Dist.CLIENT)
public class ModClientEvents
{
@OnlyIn(Dist.CLIENT)
@SubscribeEvent
public static void registerKeybinds(RegisterKeyMappingsEvent event)
{
CarryOnKeybinds.registerKeybinds(event::register);
}
}

View File

@ -0,0 +1,46 @@
package tschipp.carryon.mixin;
import com.llamalad7.mixinextras.MixinExtrasBootstrap;
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
import java.util.List;
import java.util.Set;
public class CarryOnMixinConfigPlugin implements IMixinConfigPlugin {
@Override
public void onLoad(String mixinPackage) {
MixinExtrasBootstrap.init();
}
@Override
public String getRefMapperConfig() {
return null;
}
@Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
return true;
}
@Override
public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) {
}
@Override
public List<String> getMixins() {
return null;
}
@Override
public void postApply(String targetClassName, org.objectweb.asm.tree.ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
}
@Override
public void preApply(String targetClassName, org.objectweb.asm.tree.ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
}
}

View File

@ -0,0 +1,17 @@
package tschipp.carryon.platform;
import net.minecraft.world.entity.player.Player;
import tschipp.carryon.compat.GamestageCompat;
import tschipp.carryon.platform.services.IGamestagePlatformHelper;
public class NeoForgeGamestagesHelper implements IGamestagePlatformHelper
{
@Override
public boolean hasStage(Player player, String stage)
{
if(!Services.PLATFORM.isModLoaded("gamestages"))
return true;
return GamestageCompat.hasStage(player, stage);
}
}

View File

@ -0,0 +1,104 @@
package tschipp.carryon.platform;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.player.Player;
import net.neoforged.fml.ModList;
import net.neoforged.fml.loading.FMLLoader;
import net.neoforged.neoforge.network.PacketDistributor;
import net.neoforged.neoforge.network.handling.IPlayPayloadHandler;
import net.neoforged.neoforge.network.registration.IPayloadRegistrar;
import tschipp.carryon.CarryOnCommonClient;
import tschipp.carryon.config.BuiltConfig;
import tschipp.carryon.config.neoforge.ConfigLoaderImpl;
import tschipp.carryon.networking.PacketBase;
import tschipp.carryon.platform.services.IPlatformHelper;
import java.util.function.BiConsumer;
import java.util.function.Function;
public class NeoForgePlatformHelper implements IPlatformHelper {
@Override
public String getPlatformName() {
return "NeoForge";
}
@Override
public boolean isModLoaded(String modId) {
return ModList.get().isLoaded(modId);
}
@Override
public boolean isDevelopmentEnvironment() {
return !FMLLoader.isProduction();
}
@Override
public void registerConfig(BuiltConfig cfg) {
ConfigLoaderImpl.registerConfig(cfg);
}
private record PacketBridge<T extends PacketBase>(T packet) implements CustomPacketPayload {
@Override
public void write(FriendlyByteBuf pBuffer) {
packet.write(pBuffer);
}
@Override
public ResourceLocation id() {
return packet.id();
}
public T original() {
return packet;
}
}
@Override
public <T extends PacketBase> void registerServerboundPacket(ResourceLocation id, int numericalId, Class<T> clazz, BiConsumer<T, FriendlyByteBuf> writer, Function<FriendlyByteBuf, T> reader, BiConsumer<T, Player> handler, Object... args) {
IPayloadRegistrar registrar = (IPayloadRegistrar) args[0];
IPlayPayloadHandler<PacketBridge<T>> serverHandler = (packet, ctx) -> {
ctx.workHandler().submitAsync(() -> {
handler.accept(packet.original(), ctx.player().get());
});
};
FriendlyByteBuf.Reader<PacketBridge<T>> modifiedReader = (buf) -> new PacketBridge<T>(reader.apply(buf));
registrar.play(id, modifiedReader, han -> han.server(serverHandler));
}
@Override
public <T extends PacketBase> void registerClientboundPacket(ResourceLocation id, int numericalId, Class<T> clazz, BiConsumer<T, FriendlyByteBuf> writer, Function<FriendlyByteBuf, T> reader, BiConsumer<T, Player> handler, Object... args) {
IPayloadRegistrar registrar = (IPayloadRegistrar) args[0];
IPlayPayloadHandler<PacketBridge<T>> clientHandler = (packet, ctx) -> {
ctx.workHandler().submitAsync(() -> {
handler.accept(packet.original(), CarryOnCommonClient.getPlayer());
});
};
FriendlyByteBuf.Reader<PacketBridge<T>> modifiedReader = (buf) -> new PacketBridge<T>(reader.apply(buf));
registrar.play(id, modifiedReader, han -> han.client(clientHandler));
}
@Override
public void sendPacketToServer(ResourceLocation id, PacketBase packet) {
PacketDistributor.SERVER.noArg().send(new PacketBridge(packet));
}
@Override
public void sendPacketToPlayer(ResourceLocation id, PacketBase packet, ServerPlayer player) {
PacketDistributor.PLAYER.with(player).send(new PacketBridge(packet));
}
}

View File

@ -0,0 +1,30 @@
modLoader = "javafml" #mandatory
loaderVersion = "${neoforge_loader_version_range}" #mandatory
license = "${license}" # Review your options at https://choosealicense.com/.
#issueTrackerURL="https://change.me.to.your.issue.tracker.example.invalid/" #optional
[[mods]] #mandatory
modId = "${mod_id}" #mandatory
version = "${version}" #mandatory
displayName = "${mod_name}" #mandatory
#updateJSONURL="https://change.me.example.invalid/updates.json" #optional (see https://docs.neoforged.net/docs/misc/updatechecker/)
#displayURL="https://change.me.to.your.mods.homepage.example.invalid/" #optional (displayed in the mod UI)
logoFile="logo.png" #optional
credits="${credits}" #optional
authors = "${mod_author}" #optional
description = '''${description}''' #mandatory (Supports multiline text)
[[mixins]]
config = "${mod_id}.mixins.json"
[[mixins]]
config = "${mod_id}.neoforge.mixins.json"
[[dependencies.${mod_id}]] #optional
modId = "neoforge" #mandatory
type="required" #mandatory (Can be one of "required", "optional", "incompatible" or "discouraged")
versionRange = "${neoforge_loader_version_range}" #mandatory
ordering = "NONE" # The order that this dependency should load in relation to your mod, required to be either 'BEFORE' or 'AFTER' if the dependency is not mandatory
side = "BOTH" # Side this dependency is applied on - 'BOTH', 'CLIENT' or 'SERVER'
[[dependencies.${mod_id}]]
modId = "minecraft"
type="required" #mandatory (Can be one of "required", "optional", "incompatible" or "discouraged")
versionRange = "${minecraft_version_range}"
ordering = "NONE"
side = "BOTH"

View File

@ -0,0 +1 @@
tschipp.carryon.platform.NeoForgeGamestagesHelper

View File

@ -0,0 +1 @@
tschipp.carryon.platform.NeoForgePlatformHelper

View File

@ -0,0 +1,16 @@
{
"required": true,
"minVersion": "0.8",
"package": "tschipp.carryon.mixin",
"compatibilityLevel": "JAVA_17",
"mixins": [
],
"client": [
],
"server": [
],
"injectors": {
"defaultRequire": 1
}
//"refmap": "${refmap_target}refmap.json"
}

View File

@ -1,3 +1,8 @@
plugins {
// Required for NeoGradle
id "org.jetbrains.gradle.plugin.idea-ext" version "1.1.7"
}
subprojects {
apply plugin: 'java'
@ -53,6 +58,34 @@ subprojects {
it.options.release = 17
}
processResources {
def expandProps = [
"version": version,
"group": project.group, //Else we target the task's group.
"minecraft_version": minecraft_version,
"forge_version": forge_version,
"forge_loader_version_range": forge_loader_version_range,
"forge_version_range": forge_version_range,
"minecraft_version_range": minecraft_version_range,
"fabric_version": fabric_version,
"fabric_loader_version": fabric_loader_version,
"mod_name": mod_name,
"mod_author": mod_author,
"mod_id": mod_id,
"license": license,
"description": project.description,
"neoforge_version": neoforge_version,
"neoforge_loader_version_range": neoforge_loader_version_range,
"credits": credits,
"refmap_target": "${mod_id}."
]
filesMatching(['pack.mcmeta', 'fabric.mod.json', 'META-INF/mods.toml', '*.mixins.json']) {
expand expandProps
}
inputs.properties(expandProps)
}
// Disables Gradle's custom module metadata from being published to maven. The
// metadata includes mapped dependencies which are not reasonably consumable by
// other mod developers.

View File

@ -1,30 +1,37 @@
# Project
version=2.1.2
version=2.1.3
group=tschipp.carryon
# Common
minecraft_version=1.20.1
common_runs_enabled=false
common_client_run_name=Common Client
common_server_run_name=Common Server
# Forge
forge_version=47.0.49
parchment_mappings=2023.07.02-1.20.1
//forge_ats_enabled=true
# Fabric
fabric_version=0.85.0+1.20.1
fabric_loader_version=0.14.21
parchment_mappings_fabric=1.20.1:2023.07.02
# Mod options
minecraft_version=1.20.4
mod_name=Carry On
mod_author=Tschipp, PurpliciousCow
mod_id=carryon
license=GNU LGPLv3
credits=
description=Carry On is a simple mod that improves game interaction by allowing players to pick up, carry, and place single block Tile Entities using only their empty hands.
minecraft_version_range=[1.20.4, 1.21)
# Forge
forge_version=49.0.30
forge_loader_version_range=[49,)
forge_version_range=[49,)
parchment_mappings=1.20.3-2023.12.31-1.20.4
//forge_ats_enabled=true
# Fabric
fabric_version=0.96.3+1.20.4
fabric_loader_version=0.15.7
parchment_mappings_fabric=1.20.3:2023.12.31
# Neoforge
neoforge_version=20.4.163-beta
neoforge_loader_version_range=[2,)
neogradle.subsystems.parchment.minecraftVersion=1.20.3
neogradle.subsystems.parchment.mappingsVersion=2023.12.31
# Gradle
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
mixinextras_version=0.2.0-beta.6
mixinextras_version=0.3.5

View File

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

294
gradlew vendored
View File

@ -1,7 +1,7 @@
#!/usr/bin/env bash
#!/bin/sh
#
# Copyright 2015 the original author or authors.
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@ -17,67 +17,99 @@
#
##############################################################################
##
## Gradle start up script for UN*X
##
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# 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"'
# This is normally unused
# shellcheck disable=SC2034
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:-./}" > /dev/null && pwd -P ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
MAX_FD=maximum
warn () {
echo "$*"
}
} >&2
die () {
echo
echo "$*"
echo
exit 1
}
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MSYS* | MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
@ -87,9 +119,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD="$JAVA_HOME/bin/java"
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
@ -98,86 +130,120 @@ Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
JAVACMD=java
if ! command -v java >/dev/null 2>&1
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
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=`expr $i + 1`
done
case $i in
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
ARGV=("$@")
eval set -- $DEFAULT_JVM_OPTS
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
IFS=$'
' read -rd '' -a JAVA_OPTS_ARR <<< "$(echo $JAVA_OPTS | xargs -n1)"
IFS=$'
' read -rd '' -a GRADLE_OPTS_ARR <<< "$(echo $GRADLE_OPTS | xargs -n1)"
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
exec "$JAVACMD" "$@" "${JAVA_OPTS_ARR[@]}" "${GRADLE_OPTS_ARR[@]}" "-Dorg.gradle.appname=$APP_BASE_NAME" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "${ARGV[@]}"
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# 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"'
# Collect all arguments for the java command:
# * 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 -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"

1
gradlew.bat vendored
View File

@ -26,6 +26,7 @@ if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

View File

@ -1,10 +1,13 @@
pluginManagement {
repositories {
gradlePluginPortal()
mavenLocal()
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
maven {
name = 'Sponge Snapshots'
url = 'https://repo.spongepowered.org/repository/maven-public/'
@ -16,8 +19,27 @@ pluginManagement {
name = 'ParchmentMC'
url = 'https://maven.parchmentmc.org'
}
maven {
name = 'Forge'
url = 'https://maven.minecraftforge.net/'
}
maven {
name = 'NeoForge'
url = 'https://maven.neoforged.net/releases/'
}
maven {
url 'https://maven.blamejared.com'
}
}
}
plugins {
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0'
}
rootProject.name = 'CarryOn'
include("Common", "Fabric", "Forge")
include("Common", "Fabric", "Forge", "NeoForge")