Port forge and finally fix build scripts

This commit is contained in:
2023-09-25 20:18:35 +02:00
parent ec5fa726a0
commit aef4992cf5
22 changed files with 156 additions and 141 deletions

2
.idea/misc.xml generated
View File

@@ -12,7 +12,7 @@
<component name="FrameworkDetectionExcludesConfiguration">
<file type="web" url="file://$PROJECT_DIR$" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="temurin-17" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="corretto-17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

View File

@@ -1,24 +1,27 @@
plugins {
id 'java'
id 'fabric-loom' version '0.12-SNAPSHOT'
id 'maven-publish'
id 'com.github.johnrengelman.shadow' version '7.0.0'
id 'org.quiltmc.loom' version '1.3.+'
}
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'maven-publish'
archivesBaseName = "${mod_name}-common-${minecraft_version}"
loom {
shareCaches()
accessWidenerPath = project.file("src/main/resources/craterlib.aw")
remapArchives = false
mixin {
useLegacyMixinAp = false
}
runConfigs.configureEach {
ideConfigGenerated = false
}
}
dependencies {
minecraft "com.mojang:minecraft:${minecraft_version}"
mappings loom.officialMojangMappings()
modImplementation "org.quiltmc:quilt-loader:0.19.4"
compileOnly group: 'org.spongepowered', name: 'mixin', version: '0.8.5'
implementation "com.hypherionmc:rpcsdk:1.0"
}
@@ -31,19 +34,31 @@ processResources {
}
}
/**
* Shadowjar Config
*/
shadowJar {
exclude 'mappings/*'
dependencies {
include(dependency("me.hypherionmc.moon-config:core:${moon_config}"))
include(dependency("me.hypherionmc.moon-config:toml:${moon_config}"))
relocate 'me.hypherionmc.moonconfig', 'shadow.hypherionmc.moonconfig'
}
setArchiveClassifier('')
setArchiveClassifier('dev-shadow')
}
build.dependsOn shadowJar
reg.configureJarTask(shadowJar)
remapJar {
input.set shadowJar.archiveFile
dependsOn shadowJar
setArchiveClassifier(null)
}
//reg.configureJarTask(shadowJar)
/**
* Publishing Config
*/
publishing {
publications {
mavenJava(MavenPublication) {

2
Common/gradle.properties Normal file
View File

@@ -0,0 +1,2 @@
# We don't need the common jar to be remapped
fabric.loom.dontRemap = true

View File

@@ -19,9 +19,9 @@ import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.joml.Matrix4f;
import javax.annotation.Nullable;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.math.BigDecimal;

View File

@@ -6,8 +6,8 @@ import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.events.AbstractContainerEventHandler;
import net.minecraft.client.gui.components.events.GuiEventListener;
import net.minecraft.network.chat.Component;
import org.jetbrains.annotations.Nullable;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

View File

@@ -1,15 +1,7 @@
package com.hypherionmc.craterlib.client.registry;
import com.hypherionmc.craterlib.api.rendering.DyableBlock;
import com.hypherionmc.craterlib.api.rendering.ItemDyable;
import com.hypherionmc.craterlib.client.rendering.ItemColorHandler;
import com.hypherionmc.craterlib.core.platform.ClientPlatform;
import com.hypherionmc.craterlib.core.systems.reg.RegistrationProvider;
import net.minecraft.client.color.block.BlockColors;
import net.minecraft.client.color.item.ItemColors;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import org.jetbrains.annotations.NotNull;
@@ -26,13 +18,13 @@ public class ClientRegistry {
* @param colors Existing block colors obtained from {@link com.hypherionmc.craterlib.api.event.client.ColorRegistrationEvent}
* @param blocks The blocks registered for the module
*/
public static void registerBlockColors(@NotNull BlockColors colors, @NotNull RegistrationProvider<Block> blocks) {
/*public static void registerBlockColors(@NotNull BlockColors colors, @NotNull RegistrationProvider<Block> blocks) {
blocks.getEntries().forEach(blockRegistryObject -> {
if (blockRegistryObject.get() instanceof DyableBlock dyableBlock) {
colors.register(dyableBlock.dyeHandler(), (Block) dyableBlock);
}
});
}
}*/
/**
* Register Item Color Handlers
@@ -40,13 +32,13 @@ public class ClientRegistry {
* @param colors Existing item colors obtained from {@link com.hypherionmc.craterlib.api.event.client.ColorRegistrationEvent}
* @param items The items registered for the module
*/
public static void registerItemColors(@NotNull ItemColors colors, @NotNull RegistrationProvider<Item> items) {
/*public static void registerItemColors(@NotNull ItemColors colors, @NotNull RegistrationProvider<Item> items) {
items.getEntries().forEach(itemRegistryObject -> {
if (itemRegistryObject.get() instanceof ItemDyable itemDyable) {
colors.register(new ItemColorHandler(), (Item) itemDyable);
}
});
}
}*/
/**
* Register a {@link net.minecraft.client.renderer.blockentity.BlockEntityRenderer} for a BlockEntity

View File

@@ -1,20 +1,16 @@
package com.hypherionmc.craterlib.core.platform;
import com.hypherionmc.craterlib.common.item.BlockItemDyable;
import com.hypherionmc.craterlib.core.systems.reg.RegistryObject;
import com.hypherionmc.craterlib.util.ServiceUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
import net.minecraft.network.Connection;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
/**
* @author HypherionSA
*/
@@ -24,7 +20,7 @@ public interface ClientPlatform {
void registerItemProperty(@NotNull BlockItemDyable item, @NotNull String property);
void registerCustomRenderTypes(@NotNull Collection<RegistryObject<Block>> blocks);
//void registerCustomRenderTypes(@NotNull Collection<RegistryObject<Block>> blocks);
Minecraft getClientInstance();

View File

@@ -13,8 +13,8 @@ import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.inventory.MenuType;
import net.minecraft.world.level.block.entity.BlockEntity;
import org.apache.commons.lang3.function.TriFunction;
import org.jetbrains.annotations.Nullable;
import javax.annotation.Nullable;
import java.util.Optional;
import java.util.function.Consumer;

View File

@@ -3,7 +3,6 @@ package com.hypherionmc.craterlib.mixin.events.client;
import com.hypherionmc.craterlib.api.event.client.CraterSinglePlayerEvent;
import com.hypherionmc.craterlib.core.event.CraterEventBus;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.player.AbstractClientPlayer;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import org.spongepowered.asm.mixin.Mixin;

View File

@@ -4,18 +4,18 @@ import com.hypherionmc.craterlib.api.event.client.ScreenEvent;
import com.hypherionmc.craterlib.core.event.CraterEventBus;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.Screen;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import javax.annotation.Nullable;
@Mixin(Minecraft.class)
public class MinecraftMixin {
@Shadow @Nullable public Screen screen;
@Shadow @Nullable
public Screen screen;
@Inject(method = "setScreen", at = @At(value = "TAIL"))
private void injectScreenOpeningEvent(Screen screen, CallbackInfo ci) {

View File

@@ -1,4 +1,3 @@
accessWidener v1 named
accessible class net/minecraft/client/renderer/LevelRenderer$RenderChunkInfo
accessible method net/minecraft/client/renderer/item/ItemProperties register (Lnet/minecraft/world/item/Item;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/client/renderer/item/ClampedItemPropertyFunction;)V

View File

@@ -1,16 +1,16 @@
plugins {
id 'fabric-loom' version '0.12-SNAPSHOT'
id 'maven-publish'
id 'fabric-loom' version '1.3-SNAPSHOT'
id 'idea'
id 'com.github.johnrengelman.shadow' version '7.0.0'
id "me.hypherionmc.modutils.modpublisher" version "1.0.+"
}
apply plugin: 'me.hypherionmc.modutils.modpublisher'
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'maven-publish'
archivesBaseName = "${mod_name}-fabric-${minecraft_version}"
configurations {
shade
implementation.extendsFrom shade
}
dependencies {
@@ -30,7 +30,6 @@ dependencies {
}
loom {
shareCaches()
accessWidenerPath = project(":Common").file("src/main/resources/craterlib.aw")
runs {
client {
@@ -48,7 +47,6 @@ loom {
}
}
processResources {
from project(":Common").sourceSets.main.resources
inputs.property "version", project.version
@@ -72,23 +70,28 @@ jar {
}
}
/**
* Shadowjar Config
*/
shadowJar {
from sourceSets.main.output
configurations = [project.configurations.shade]
dependencies {
relocate 'me.hypherionmc.moonconfig', 'shadow.hypherionmc.moonconfig'
}
setArchiveClassifier("dev-shadow")
}
remapJar {
dependsOn(shadowJar)
shouldRunAfter(shadowJar)
input.set shadowJar.archiveFile.get()
input.set shadowJar.archiveFile
dependsOn shadowJar
setArchiveClassifier(null)
}
reg.configureJarTask(shadowJar)
//reg.configureJarTask(shadowJar)
/**
* Publishing Config
*/
publishing {
publications {
mavenJava(MavenPublication) {
@@ -125,24 +128,6 @@ publishing {
}
}
task delDevJar {
doLast {
def tree = fileTree('build/libs')
tree.include '**/*-dev.jar'
tree.include '**/*-all.jar'
tree.each { it.delete() }
}
}
build.finalizedBy delDevJar
task copyAllArtifacts(type: Copy) {
from "$buildDir/libs"
into "$rootDir/artifacts"
include("*.jar")
}
build.finalizedBy(copyAllArtifacts)
publisher {
apiKeys {
modrinth = System.getenv("MODRINTH_TOKEN")
@@ -168,4 +153,5 @@ publisher {
}
}
publishMod.dependsOn(build)
publishMod.dependsOn(build)

View File

@@ -1,12 +1,9 @@
package com.hypherionmc.craterlib.client;
import com.hypherionmc.craterlib.api.rendering.CustomRenderType;
import com.hypherionmc.craterlib.common.item.BlockItemDyable;
import com.hypherionmc.craterlib.core.platform.ClientPlatform;
import com.hypherionmc.craterlib.core.systems.reg.RegistryObject;
import com.hypherionmc.craterlib.util.ColorPropertyFunction;
import net.fabricmc.api.EnvType;
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
@@ -16,13 +13,10 @@ import net.minecraft.network.Connection;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
/**
* @author HypherionSA
*/
@@ -35,14 +29,14 @@ public class FabricClientPlatform implements ClientPlatform {
}
}
@Override
/*@Override
public void registerCustomRenderTypes(Collection<RegistryObject<Block>> blocks) {
blocks.forEach(blk -> {
if (blk.get() instanceof CustomRenderType type) {
BlockRenderLayerMap.INSTANCE.putBlock(blk.get(), type.getCustomRenderType());
}
});
}
}*/
@Override
public Minecraft getClientInstance() {

View File

@@ -1,7 +1,6 @@
package com.hypherionmc.craterlib.network.impl;
import com.hypherionmc.craterlib.core.network.CraterPacket;
import com.hypherionmc.craterlib.network.FabricNetworkHelper;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
import net.fabricmc.fabric.api.networking.v1.PacketSender;
import net.minecraft.client.Minecraft;

View File

@@ -1,22 +1,10 @@
buildscript {
repositories {
maven { url = 'https://mcentral.firstdark.dev/releases' }
mavenCentral()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT'
}
}
plugins {
id 'com.github.johnrengelman.shadow' version '7.0.0'
id "me.hypherionmc.modutils.modpublisher" version "1.0.+"
}
apply plugin: 'java'
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse'
apply plugin: 'org.spongepowered.mixin'
apply plugin: 'maven-publish'
apply plugin: 'me.hypherionmc.modutils.modpublisher'
apply plugin: 'com.github.johnrengelman.shadow'
archivesBaseName = "${mod_name}-forge-${minecraft_version}"
@@ -31,8 +19,6 @@ minecraft {
mappings channel: 'official', version: minecraft_version
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
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
project.logger.debug('Forge Access Transformers are enabled for this project.')
}
@@ -109,23 +95,28 @@ processResources {
}
}
/**
* Shadowjar Config
*/
shadowJar {
configurations = [project.configurations.shade]
dependencies {
relocate 'me.hypherionmc.moonconfig', 'shadow.hypherionmc.moonconfig'
}
classifier = ''
setArchiveClassifier('')
}
assemble.dependsOn(shadowJar)
reobf {
shadowJar {}
}
build.dependsOn reobfShadowJar
reg.configureJarTask(shadowJar)
jar.finalizedBy('reobfJar')
//reg.configureJarTask(shadowJar)
/**
* Publishing Config
*/
publishing {
publications {
mavenJava(MavenPublication) {
@@ -156,14 +147,6 @@ publishing {
}
}
task copyAllArtifacts(type: Copy) {
from "$buildDir/libs"
into "$rootDir/artifacts"
include("*.jar")
}
build.finalizedBy(copyAllArtifacts)
publisher {
apiKeys {
modrinth = System.getenv("MODRINTH_TOKEN")
@@ -181,4 +164,5 @@ publisher {
artifact = jar
}
publishMod.dependsOn(build)
publishMod.dependsOn(build)
jar.finalizedBy('reobfJar')

View File

@@ -1,12 +1,9 @@
package com.hypherionmc.craterlib.client;
import com.hypherionmc.craterlib.api.rendering.CustomRenderType;
import com.hypherionmc.craterlib.common.item.BlockItemDyable;
import com.hypherionmc.craterlib.core.platform.ClientPlatform;
import com.hypherionmc.craterlib.core.systems.reg.RegistryObject;
import com.hypherionmc.craterlib.util.ColorPropertyFunction;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ItemBlockRenderTypes;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
import net.minecraft.client.renderer.item.ItemProperties;
@@ -14,12 +11,10 @@ import net.minecraft.network.Connection;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraftforge.fml.loading.FMLEnvironment;
import java.util.Collection;
import java.util.Objects;
/**
@@ -37,14 +32,14 @@ public class ForgeClientHelper implements ClientPlatform {
}
}
@Override
/*@Override
public void registerCustomRenderTypes(Collection<RegistryObject<Block>> blocks) {
blocks.forEach(blk -> {
if (blk.get() instanceof CustomRenderType type) {
ItemBlockRenderTypes.setRenderLayer(blk.get(), type.getCustomRenderType());
}
});
}
}*/
@Override
public Minecraft getClientInstance() {

View File

@@ -21,7 +21,6 @@ import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraftforge.common.capabilities.ForgeCapabilities;
import net.minecraftforge.common.extensions.IForgeMenuType;
import net.minecraftforge.network.NetworkHooks;
import net.minecraftforge.server.ServerLifecycleHooks;
import org.apache.commons.lang3.function.TriFunction;
import org.jetbrains.annotations.Nullable;
@@ -54,9 +53,9 @@ public class ForgeCommonHelper implements CommonPlatform {
@Override
public void openMenu(ServerPlayer player, MenuProvider menu, @Nullable Consumer<FriendlyByteBuf> initialData) {
if (initialData != null) {
NetworkHooks.openScreen(player, menu, initialData);
player.openMenu(menu, initialData);
} else {
NetworkHooks.openScreen(player, menu, player.getOnPos());
player.openMenu(menu, player.getOnPos());
}
}

View File

@@ -5,17 +5,21 @@ import com.hypherionmc.craterlib.core.network.CraterNetworkHandler;
import com.hypherionmc.craterlib.core.network.CraterPacket;
import com.hypherionmc.craterlib.core.network.PacketDirection;
import com.hypherionmc.craterlib.core.platform.ClientPlatform;
import io.netty.buffer.Unpooled;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.protocol.Packet;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Player;
import net.minecraftforge.common.util.LogicalSidedProvider;
import net.minecraftforge.event.network.CustomPayloadEvent;
import net.minecraftforge.fml.LogicalSide;
import net.minecraftforge.network.Channel;
import net.minecraftforge.network.ChannelBuilder;
import net.minecraftforge.network.NetworkDirection;
import net.minecraftforge.network.NetworkEvent;
import net.minecraftforge.network.NetworkRegistry;
import net.minecraftforge.network.simple.SimpleChannel;
import net.minecraftforge.network.SimpleChannel;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.BiConsumer;
@@ -29,7 +33,6 @@ import java.util.function.Supplier;
public class ForgeNetworkHandler implements CraterNetworkHandler {
private static final Map<String, ForgeNetworkHandler> NETWORK_HANDLERS = Maps.newConcurrentMap();
private static final String PROTOCOL = Integer.toString(1);
private final SimpleChannel channel;
@@ -39,6 +42,8 @@ public class ForgeNetworkHandler implements CraterNetworkHandler {
private final AtomicInteger packetID = new AtomicInteger();
private HashMap<Class<?>, Integer> packetMap = new LinkedHashMap<>();
private ForgeNetworkHandler(SimpleChannel channel, boolean clientRequired, boolean serverRequired) {
this.channel = channel;
this.clientRequired = clientRequired;
@@ -54,37 +59,47 @@ public class ForgeNetworkHandler implements CraterNetworkHandler {
return packet;
};
BiConsumer<T, Supplier<NetworkEvent.Context>> handler = (packet, sup) -> {
NetworkEvent.Context context = sup.get();
BiConsumer<T, CustomPayloadEvent.Context> handler = (packet, sup) -> {
LogicalSide expectedSide = getSideFromDirection(packetDirection);
LogicalSide currentSide = context.getDirection().getReceptionSide();
LogicalSide currentSide = sup.getDirection().getReceptionSide();
if (expectedSide != currentSide) {
throw new IllegalStateException(String.format("Received message on wrong side, expected %s, was %s", expectedSide, currentSide));
}
context.enqueueWork(() -> {
sup.enqueueWork(() -> {
Player player;
if (packetDirection == PacketDirection.TO_CLIENT) {
player = ClientPlatform.INSTANCE.getClientPlayer();
} else {
player = context.getSender();
player = sup.getSender();
}
packet.handle(player, LogicalSidedProvider.WORKQUEUE.get(expectedSide));
});
context.setPacketHandled(true);
sup.setPacketHandled(true);
};
this.channel.registerMessage(this.packetID.getAndIncrement(), (Class<T>) clazz, encoder, decoder, handler);
int id = packetID.getAndIncrement();
packetMap.put(clazz, id);
this.channel
.messageBuilder((Class<T>) clazz, id)
.encoder(encoder)
.decoder(decoder)
.consumerNetworkThread(handler)
.add();
}
@Override
public Packet<?> toServerBound(CraterPacket<?> packet) {
return this.channel.toVanillaPacket(packet, NetworkDirection.PLAY_TO_SERVER);
return NetworkDirection.PLAY_TO_SERVER.buildPacket(toBuffer(packet), channel.getName()).getThis();
//return this.channel.toVanillaPacket(packet, NetworkDirection.PLAY_TO_SERVER);
}
@Override
public Packet<?> toClientBound(CraterPacket<?> packet) {
return this.channel.toVanillaPacket(packet, NetworkDirection.PLAY_TO_CLIENT);
return NetworkDirection.PLAY_TO_CLIENT.buildPacket(toBuffer(packet), channel.getName()).getThis();
//return this.channel.toVanillaPacket(packet, NetworkDirection.PLAY_TO_CLIENT);
}
@Override
@@ -100,15 +115,24 @@ public class ForgeNetworkHandler implements CraterNetworkHandler {
}
private static SimpleChannel buildSimpleChannel(String modId, boolean clientAcceptsVanillaOrMissing, boolean serverAcceptsVanillaOrMissing) {
return NetworkRegistry.ChannelBuilder
return ChannelBuilder
.named(new ResourceLocation(modId, "crater_network"))
.networkProtocolVersion(() -> PROTOCOL)
.clientAcceptedVersions(clientAcceptsVanillaOrMissing ? NetworkRegistry.acceptMissingOr(PROTOCOL) : PROTOCOL::equals)
.serverAcceptedVersions(serverAcceptsVanillaOrMissing ? NetworkRegistry.acceptMissingOr(PROTOCOL) : PROTOCOL::equals)
.networkProtocolVersion(1)
.clientAcceptedVersions(clientAcceptsVanillaOrMissing ? Channel.VersionTest.ACCEPT_MISSING : Channel.VersionTest.exact(1))
.serverAcceptedVersions(serverAcceptsVanillaOrMissing ? Channel.VersionTest.ACCEPT_MISSING : Channel.VersionTest.exact(1))
.simpleChannel();
}
private LogicalSide getSideFromDirection(PacketDirection direction) {
return direction == PacketDirection.TO_CLIENT ? LogicalSide.CLIENT : LogicalSide.SERVER;
}
protected FriendlyByteBuf toBuffer(CraterPacket<?> message) {
var msg = packetMap.get(message.getClass());
var ret = new FriendlyByteBuf(Unpooled.buffer());
ret.writeVarInt(msg);
message.write(ret);
return ret;
}
}

View File

@@ -1,17 +1,21 @@
plugins {
id 'java'
id 'com.matyrobbrt.mc.registrationutils' version '1.20-1.1.0'
//id 'com.matyrobbrt.mc.registrationutils' version '1.20.1-1.0.0'
id 'maven-publish'
id 'net.minecraftforge.gradle' version '[6.0,6.2)' apply false
id 'org.spongepowered.mixin' version '0.7-SNAPSHOT' apply false
id 'com.github.johnrengelman.shadow' version '7.0.0' apply false
id "me.hypherionmc.modutils.modpublisher" version "1.0.+" apply false
}
registrationUtils {
/*registrationUtils {
group 'com.hypherionmc.craterlib.core.systems.reg'
projects {
Common { type 'common'; project ':Common' }
Fabric { type 'fabric'; project ':Fabric' }
//Forge { type 'forge'; project ':Forge' }
Forge { type 'forge'; project ':Forge' }
}
}
}*/
ext {
release = project.properties['release'] ?: false
@@ -38,6 +42,8 @@ subprojects {
//java.withJavadocJar()
jar {
archiveClassifier = 'slim'
manifest {
attributes([
'Specification-Title' : mod_name,
@@ -86,6 +92,28 @@ subprojects {
clean {
delete "$rootDir/artifacts"
}
if (project.name !== 'Common') {
task delDevJar {
doLast {
def tree = fileTree('build/libs')
tree.include '**/*-dev.jar'
tree.include '**/*-dev-shadow.jar'
tree.include '**/*-all.jar'
tree.include '**/*-slim.jar'
tree.each { it.delete() }
}
}
build.finalizedBy delDevJar
task copyAllArtifacts(type: Copy) {
from "$buildDir/libs"
into "$rootDir/artifacts"
include("*.jar")
}
build.finalizedBy(copyAllArtifacts)
}
}
// Standalone or Module JARS

View File

@@ -1,3 +1,6 @@
# Gradle
fabric.loom.multiProjectOptimisation = true
# Project
version_major=1
version_minor=0
@@ -11,7 +14,7 @@ common_client_run_name=Common Client
common_server_run_name=Common Server
# Forge
forge_version=46.0.1
forge_version=48.0.6
forge_ats_enabled=true
# Fabric
@@ -28,7 +31,7 @@ org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
# Dependencies
mod_menu_version=7.0.0-beta.2
mod_menu_version=8.0.0-beta.2
moon_config=1.0.9
# Publishing

View File

@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@@ -11,4 +11,4 @@ pluginManagement {
}
rootProject.name = 'CraterLib'
include("Common", "Fabric"/*, "Forge"*/)
include("Common", "Fabric", "Forge")