Skip to content

Commit

Permalink
Port to Architectury Loom
Browse files Browse the repository at this point in the history
Mixin plugin transforms are refactored to use annotations.

Include fixes to (#1211).

Co-authored-by: 秋雨落 <i@rain.cx>
  • Loading branch information
IzzelAliz and qyl27 committed Feb 3, 2024
1 parent 5f2c00f commit db09e93
Show file tree
Hide file tree
Showing 384 changed files with 7,603 additions and 2,950 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ jobs:
run: chmod +x gradlew
- name: Build
run: |
./gradlew cleanBuild remapSpigotJar idea --no-daemon -i --stacktrace --refresh-dependencies
./gradlew build collect --no-daemon -i --stacktrace
./gradlew cleanBuild build collect --no-daemon -i --stacktrace
- name: Upload Artifact
uses: actions/upload-artifact@v2
with:
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/.gradle/
.gradle/
/.settings/
build/
/bin/
/.project
/.settings/
.idea
*.log
129 changes: 28 additions & 101 deletions arclight-common/build.gradle
Original file line number Diff line number Diff line change
@@ -1,49 +1,31 @@
buildscript {
repositories {
maven { url = 'https://maven.minecraftforge.net' }
maven { url = 'https://repo.spongepowered.org/maven' }
mavenCentral()
maven { url = 'https://maven.izzel.io/releases' }
// maven { url = 'https://maven.parchmentmc.org' }
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: "${forge_gradle_version}", changing: true
// classpath 'org.parchmentmc:librarian:1.+'
classpath 'org.spongepowered:mixingradle:0.7.2-SNAPSHOT'
classpath "io.izzel.arclight:arclight-gradle-plugin:$agpVersion"
}
plugins {
id "architectury-plugin" version "3.4-SNAPSHOT"
id 'java'
id 'idea'
}

apply plugin: 'net.minecraftforge.gradle'
// apply plugin: 'org.parchmentmc.librarian.forgegradle'
apply plugin: 'org.spongepowered.mixin'
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'io.izzel.arclight'
apply plugin: io.izzel.arclight.gradle.ArclightGradlePlugin

architectury {
minecraft = minecraftVersion
common("forge")
}

loom {
silentMojangMappingsLicense()
accessWidenerPath = file("src/main/resources/arclight.accesswidener")
}

arclight {
mcVersion = minecraftVersion
forgeVersion = project.ext.forgeVersion
bukkitVersion = 'v1_20_R3'
wipeVersion = true
reobfVersion = true
accessTransformer = project.file('bukkit.at')
// packageName = 'spigot'
}

configurations {
embed
extraMapping = project(':arclight-common').file('extra_mapping.tsrg')
}

java.toolchain.languageVersion = JavaLanguageVersion.of(17)

minecraft {
//mappings channel: 'parchment', version: "2021.08.22-$minecraftVersion"
mappings channel: 'official', version: minecraftVersion
// copyIdeResources = true
accessTransformer = project.file('src/main/resources/META-INF/accesstransformer.cfg')
}

repositories {
maven { url = 'https://repo.spongepowered.org/maven' }
maven { url = 'https://oss.sonatype.org/content/repositories/snapshots/' }
Expand All @@ -55,86 +37,31 @@ repositories {
}

dependencies {
minecraft "net.minecraftforge:forge:$minecraftVersion-$forgeVersion"
minecraft "com.mojang:minecraft:$minecraftVersion"
mappings loom.officialMojangMappings()
modImplementation "net.fabricmc:fabric-loader:$fabricLoaderVersion"

compileOnly "io.izzel.arclight.generated:spigot:${minecraftVersion}:deobf"

implementation "org.spigotmc:spigot-api:$minecraftVersion-R0.1-SNAPSHOT@jar"
implementation 'org.jetbrains:annotations:23.0.0'

implementation "org.spongepowered:mixin:$mixinVersion"
annotationProcessor 'org.spongepowered:mixin:0.8.3:processor'

implementation 'com.github.ArclightTeam:mixin-tools:1.0.0'
annotationProcessor 'com.github.ArclightTeam:mixin-tools:1.0.0'
implementation ('io.izzel.arclight:mixin-tools:1.1.0') { transitive = false }
annotationProcessor ('io.izzel.arclight:mixin-tools:1.1.0') { transitive = false }

implementation 'jline:jline:2.12.1'
implementation 'net.md-5:SpecialSource:1.11.0'
implementation 'org.apache.logging.log4j:log4j-jul:2.15.0'
implementation 'net.md-5:bungeecord-chat:1.16-R0.4'
implementation 'mysql:mysql-connector-java:5.1.49'
implementation 'net.md-5:bungeecord-chat:1.20-R0.1'
implementation 'mysql:mysql-connector-java:8.0.28'
implementation 'org.yaml:snakeyaml:2.0'
implementation "io.izzel:tools:$toolsVersion"
implementation "io.izzel.arclight:arclight-api:$apiVersion"
implementation project(':i18n-config')
embed 'net.md-5:bungeecord-chat:1.16-R0.4@jar'
embed "org.spigotmc:spigot-api:$minecraftVersion-R0.1-SNAPSHOT@jar"
}

jar {
manifest.attributes 'MixinConnector': 'io.izzel.arclight.common.mod.ArclightConnector'
manifest.attributes 'Implementation-Title': 'Arclight'
manifest.attributes 'Implementation-Version': "arclight-$minecraftVersion-${project.version}-$gitHash"
manifest.attributes 'Implementation-Vendor': 'Arclight Team'
manifest.attributes 'Implementation-Timestamp': new Date().format("yyyy-MM-dd HH:mm:ss")
from { configurations.embed.collect { it.isDirectory() ? it : zipTree(it) } } {
exclude "META-INF/MANIFEST.MF"
exclude "META-INF/*.SF"
exclude "META-INF/*.DSA"
exclude "META-INF/*.RSA"
exclude "LICENSE.txt"
exclude "META-INF/services/**"
exclude "org/apache/commons/lang/enum/**"
}
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}

tasks.register('srgJar', Jar) {
from(tasks.jar.outputs.files.collect { it.isDirectory() ? it : zipTree(it) }) {
include 'io/izzel/**'
exclude 'io/izzel/arclight/common/mixin/**'
}
archiveClassifier.set('srg')
}

tasks.register('spigotJar', Jar) {
with tasks.srgJar
doLast {
def task = tasks.create('renameSpigotJar', net.minecraftforge.gradle.userdev.tasks.RenameJarInPlace)
task.input.set(archiveFile.get().asFile)
task.hasLog = false
task.mappings.set(project.file('build/arclight_cache/tmp_srg/bukkit_srg.srg'))
task.args.add('--reverse')
task.apply()
}
archiveClassifier.set('spigot')
}

afterEvaluate {
tasks.reobfJar.configure {
it.extraMappings.from(project.files('extra_mapping.tsrg'))
}
}

processResources {
filesMatching("**/mods.toml") {
expand 'version': "$minecraftVersion-${project.version}-$gitHash"
}
}

remapSpigotJar {
includes.add('net/minecraft/world/level/block/ChestBlock$DoubleInventory')
}

mixin {
add sourceSets.main, 'mixins.arclight.refmap.json'
java {
withSourcesJar()
}

compileJava {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.izzel.arclight.common.bridge.bukkit;

import io.izzel.arclight.i18n.conf.MaterialPropertySpec;
import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity;
import org.bukkit.block.BlockState;
import org.bukkit.craftbukkit.v.block.CraftBlock;
import org.bukkit.craftbukkit.v.inventory.CraftMetaItem;
Expand Down Expand Up @@ -38,4 +39,21 @@ public interface MaterialBridge {
void bridge$setBlockStateFactory(Function<CraftBlock, BlockState> func);

boolean bridge$shouldApplyStateFactory();

default Item bridge$getCraftRemainingItem(Item item) {
return item.getCraftingRemainingItem();
}

default int bridge$forge$getMaxStackSize(Item item) {
return item.getMaxStackSize();
}

default int bridge$forge$getDurability(Item item) {
return item.getMaxDamage();
}

default int bridge$forge$getBurnTime(Item item) {
var result = AbstractFurnaceBlockEntity.getFuel().get(item);
return result != null ? result : 0;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package io.izzel.arclight.common.bridge.core.command;

import com.mojang.brigadier.Command;
import com.mojang.brigadier.suggestion.SuggestionProvider;
import com.mojang.brigadier.tree.CommandNode;

import java.util.Map;
import java.util.function.Function;

public interface CommandsBridge {
<S, T> void bridge$forge$mergeNode(CommandNode<S> sourceNode, CommandNode<T> resultNode,
Map<CommandNode<S>, CommandNode<T>> sourceToResult,
S canUse, Command<T> execute,
Function<SuggestionProvider<S>, SuggestionProvider<T>> sourceToResultSuggestion);
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
package io.izzel.arclight.common.bridge.core.entity;

import io.izzel.arclight.common.bridge.core.command.ICommandSourceBridge;
import io.izzel.arclight.common.bridge.inject.InjectEntityBridge;
import io.izzel.tools.product.Product;
import io.izzel.tools.product.Product4;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.boss.EnderDragonPart;
import net.minecraft.world.entity.boss.enderdragon.EnderDragon;
import net.minecraft.world.phys.Vec3;
import org.bukkit.craftbukkit.v.entity.CraftEntity;
import org.bukkit.projectiles.ProjectileSource;

import java.util.List;

public interface EntityBridge extends ICommandSourceBridge {
public interface EntityBridge extends ICommandSourceBridge, InjectEntityBridge {

Entity bridge$teleportTo(ServerLevel world, Vec3 blockPos);

Expand Down Expand Up @@ -56,4 +62,31 @@ public interface EntityBridge extends ICommandSourceBridge {
int bridge$getRideCooldown();

boolean bridge$canCollideWith(Entity entity);

void bridge$setLastLavaContact(BlockPos pos);

Vec3 bridge$getLastTpPos();

void bridge$revive();

default boolean bridge$forge$isPartEntity() {
return this instanceof EnderDragonPart;
}

default Entity bridge$forge$getParent() {
return this instanceof EnderDragonPart part ? part.parentMob : null;
}

default Entity[] bridge$forge$getParts() {
return this instanceof EnderDragon dragon ? dragon.subEntities : null;
}

default Product4<Boolean /* Cancelled */, Double /* X */, Double /* Y */, Double /* Z */>
bridge$onEntityTeleportCommand(double x, double y, double z) {
return Product.of(false, x, y, z);
}

default boolean bridge$forge$canUpdate() {
return true;
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
package io.izzel.arclight.common.bridge.core.entity;

import io.izzel.tools.product.Product;
import io.izzel.tools.product.Product3;
import net.minecraft.core.BlockPos;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import org.bukkit.craftbukkit.v.entity.CraftLivingEntity;
import org.bukkit.event.entity.EntityPotionEffectEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent;

import javax.annotation.Nullable;
import java.util.Collection;
import java.util.Optional;

public interface LivingEntityBridge extends EntityBridge {
Expand Down Expand Up @@ -40,8 +53,68 @@ public interface LivingEntityBridge extends EntityBridge {

Optional<EntityPotionEffectEvent.Cause> bridge$getEffectCause();

EntityPotionEffectEvent.Action bridge$getAndResetAction();

@Override
CraftLivingEntity bridge$getBukkitEntity();

default int bridge$forge$getExperienceDrop(LivingEntity entity, Player attackingPlayer, int originalExperience) {
return originalExperience;
}

default boolean bridge$forge$mobEffectExpired(MobEffectInstance effect) {
return false;
}

default boolean bridge$forge$mobEffectAdded(MobEffectInstance old, MobEffectInstance effect, Entity entity) {
return false;
}

default float bridge$forge$onLivingHurt(LivingEntity entity, DamageSource src, float amount) {
return amount;
}

default Product3<Boolean /*cancelled*/, Float /*block damage*/, Boolean /*shield take damage*/> bridge$forge$onShieldBlock(
LivingEntity blocker, DamageSource source, float blocked) {
return Product.of(false, blocked, true);
}

default float bridge$forge$onLivingDamage(LivingEntity entity, DamageSource src, float amount) {
return amount;
}

default boolean bridge$forge$onLivingUseTotem(LivingEntity entity, DamageSource damageSource, ItemStack totem, InteractionHand hand) {
return true;
}

enum LivingTargetType {
BEHAVIOR_TARGET,
MOB_TARGET
}

default @Nullable LivingEntity bridge$forge$onLivingChangeTarget(LivingEntity entity, LivingEntity originalTarget, LivingTargetType targetType) {
return originalTarget;
}

default BlockPos bridge$forge$onEnderTeleport(LivingEntity entity, double targetX, double targetY, double targetZ) {
return BlockPos.containing(targetX, targetY, targetZ);
}

default void bridge$forge$onLivingConvert(LivingEntity entity, LivingEntity outcome) {}

default boolean bridge$forge$canEntityDestroy(Level level, BlockPos pos, LivingEntity entity) {
return true;
}

default boolean bridge$forge$onEntityDestroyBlock(LivingEntity entity, BlockPos pos, BlockState state) {
return true;
}

void bridge$common$startCaptureDrops();

boolean bridge$common$isCapturingDrops();

void bridge$common$captureDrop(ItemEntity itemEntity);

Collection<ItemEntity> bridge$common$getCapturedDrops();

void bridge$common$finishCaptureAndFireEvent();
}
Loading

0 comments on commit db09e93

Please sign in to comment.