Migrate to transitive access wideners (#146)

* Migrate to transitive access wideners

* Fix invalid AW

* Bump minor version, changes to gradle buildscript

Co-authored-by: Max <maxh2709@gmail.com>
This commit is contained in:
shedaniel
2021-12-08 22:13:12 +08:00
parent b0a80e0c73
commit 0a64ecda1d
20 changed files with 84 additions and 145 deletions

View File

@@ -1,7 +1,7 @@
plugins {
id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "0.7.3-SNAPSHOT" apply false
id "org.cadixdev.licenser" version "0.5.0"
id "org.cadixdev.licenser" version "0.6.1"
id "com.matthewprenger.cursegradle" version "1.4.0" apply false
id "maven-publish"
}

View File

@@ -1,5 +1,5 @@
loom {
accessWidener = file("src/main/resources/architectury.accessWidener")
accessWidener = file("src/main/resources/architectury-common.accessWidener")
}
dependencies {
@@ -15,11 +15,6 @@ architectury {
common()
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = "sources"
from sourceSets.main.allSource
}
publishing {
publications {
mavenCommon(MavenPublication) {

View File

@@ -22,15 +22,20 @@ package me.shedaniel.architectury.hooks;
import dev.architectury.injectables.annotations.ExpectPlatform;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.phys.shapes.CollisionContext;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
public final class EntityHooks {
private EntityHooks() {
}
@ExpectPlatform
/**
* @deprecated Use the field directly.
*/
@Deprecated
@ApiStatus.ScheduledForRemoval
public static String getEncodeId(Entity entity) {
throw new AssertionError();
return entity.getEncodeId();
}
@Nullable

View File

@@ -23,6 +23,7 @@ import dev.architectury.injectables.annotations.ExpectPlatform;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.Explosion;
import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
public final class ExplosionHooks {
@@ -34,19 +35,31 @@ public final class ExplosionHooks {
throw new AssertionError();
}
/**
* @deprecated Use the field directly.
*/
@Nullable
@ExpectPlatform
@Deprecated
@ApiStatus.ScheduledForRemoval
public static Entity getSource(Explosion explosion) {
throw new AssertionError();
return explosion.source;
}
@ExpectPlatform
/**
* @deprecated Use the field directly.
*/
@Deprecated
@ApiStatus.ScheduledForRemoval
public static float getRadius(Explosion explosion) {
throw new AssertionError();
return explosion.radius;
}
@ExpectPlatform
/**
* @deprecated Use the field directly.
*/
@Deprecated
@ApiStatus.ScheduledForRemoval
public static void setRadius(Explosion explosion, float radius) {
throw new AssertionError();
explosion.radius = radius;
}
}

View File

@@ -20,11 +20,17 @@
package me.shedaniel.architectury.hooks;
import net.minecraft.world.level.storage.LevelResource;
import org.jetbrains.annotations.ApiStatus;
public class LevelResourceHooks {
private LevelResourceHooks() {
}
/**
* @deprecated Use the constructor directly.
*/
@Deprecated
@ApiStatus.ScheduledForRemoval
public static LevelResource create(String id) {
return new LevelResource(id);
}

View File

@@ -21,6 +21,8 @@ package me.shedaniel.architectury.hooks;
import dev.architectury.injectables.annotations.ExpectPlatform;
import net.minecraft.world.entity.player.Player;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
public final class PlayerHooks {
private PlayerHooks() {
@@ -31,8 +33,12 @@ public final class PlayerHooks {
throw new AssertionError();
}
@ExpectPlatform
/**
* @deprecated Use the method directly.
*/
@Deprecated
@ApiStatus.ScheduledForRemoval
public static void closeContainer(Player player) {
throw new AssertionError();
player.closeContainer();
}
}

View File

@@ -1,4 +1,4 @@
accessWidener v1 named
accessWidener v2 named
accessible method net/minecraft/world/level/block/state/BlockBehaviour$Properties <init> (Lnet/minecraft/world/level/material/Material;Ljava/util/function/Function;)V
accessible field net/minecraft/world/level/biome/Biome climateSettings Lnet/minecraft/world/level/biome/Biome$ClimateSettings;
accessible field net/minecraft/world/level/biome/Biome depth F
@@ -39,13 +39,19 @@ accessible field net/minecraft/world/level/biome/BiomeSpecialEffects ambientAddi
mutable field net/minecraft/world/level/biome/BiomeSpecialEffects ambientAdditionsSettings Ljava/util/Optional;
accessible field net/minecraft/world/level/biome/BiomeSpecialEffects backgroundMusic Ljava/util/Optional;
mutable field net/minecraft/world/level/biome/BiomeSpecialEffects backgroundMusic Ljava/util/Optional;
accessible method net/minecraft/world/level/storage/LevelResource <init> (Ljava/lang/String;)V
accessible field net/minecraft/world/item/AxeItem STRIPABLES Ljava/util/Map;
transitive-accessible method net/minecraft/world/entity/Entity getEncodeId ()Ljava/lang/String;
transitive-accessible method net/minecraft/world/level/storage/LevelResource <init> (Ljava/lang/String;)V
transitive-accessible field net/minecraft/world/item/AxeItem STRIPABLES Ljava/util/Map;
mutable field net/minecraft/world/item/AxeItem STRIPABLES Ljava/util/Map;
accessible field net/minecraft/world/item/ShovelItem FLATTENABLES Ljava/util/Map;
mutable field net/minecraft/world/item/ShovelItem FLATTENABLES Ljava/util/Map;
accessible field net/minecraft/world/item/HoeItem TILLABLES Ljava/util/Map;
mutable field net/minecraft/world/item/HoeItem TILLABLES Ljava/util/Map;
transitive-accessible field net/minecraft/world/level/Explosion source Lnet/minecraft/world/entity/Entity;
transitive-mutable field net/minecraft/world/level/Explosion source Lnet/minecraft/world/entity/Entity;
transitive-accessible field net/minecraft/world/level/Explosion radius F
transitive-mutable field net/minecraft/world/level/Explosion radius F
transitive-accessible method net/minecraft/world/entity/player/Player closeContainer ()V
accessible field net/minecraft/world/item/trading/MerchantOffer baseCostA Lnet/minecraft/world/item/ItemStack;
mutable field net/minecraft/world/item/trading/MerchantOffer baseCostA Lnet/minecraft/world/item/ItemStack;

View File

@@ -0,0 +1,3 @@
{
"accessWidener": "architectury-common.accessWidener"
}

View File

@@ -8,12 +8,11 @@ loom {
}
configurations {
shadowCommon
dev
}
artifacts {
dev(jar)
common
shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
compileClasspath.extendsFrom common
runtimeClasspath.extendsFrom common
developmentFabric.extendsFrom common
}
architectury {
@@ -34,15 +33,8 @@ dependencies {
implementation "net.jodah:typetools:0.6.2"
shadowCommon "net.jodah:typetools:0.6.2"
implementation(project(path: ":common")) {
transitive = false
}
developmentFabric(project(path: ":common")) {
transitive = false
}
shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) {
transitive = false
}
common(project(path: ":common", configuration: "namedElements")) { transitive false }
shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false }
}
processResources {
@@ -53,6 +45,9 @@ processResources {
}
shadowJar {
exclude "architectury-common.accessWidener"
exclude "architectury.common.json"
relocate "net.jodah.typetools", "me.shedaniel.architectury.shadowed.impl.net.jodah.typetools"
configurations = [project.configurations.shadowCommon]
classifier "shadow"

View File

@@ -19,7 +19,6 @@
package me.shedaniel.architectury.hooks.fabric;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.Explosion;
import net.minecraft.world.phys.Vec3;
@@ -28,25 +27,7 @@ public class ExplosionHooksImpl {
return ((ExplosionExtensions) explosion).architectury_getPosition();
}
public static Entity getSource(Explosion explosion) {
return ((ExplosionExtensions) explosion).architectury_getSource();
}
public static float getRadius(Explosion explosion) {
return ((ExplosionExtensions) explosion).architectury_getRadius();
}
public static void setRadius(Explosion explosion, float radius) {
((ExplosionExtensions) explosion).architectury_setRadius(radius);
}
public interface ExplosionExtensions {
Vec3 architectury_getPosition();
Entity architectury_getSource();
float architectury_getRadius();
void architectury_setRadius(float v);
}
}

View File

@@ -25,8 +25,4 @@ public class PlayerHooksImpl {
public static boolean isFake(Player player) {
return false;
}
public static void closeContainer(Player player) {
player.closeContainer();
}
}

View File

@@ -50,14 +50,6 @@ public class MixinExplosion implements ExplosionHooksImpl.ExplosionExtensions {
@Shadow
@Final
private double z;
@Shadow
@Final
@Nullable
private Entity source;
@Shadow
@Final
@Mutable
private float radius;
@Unique
Vec3 position;
@@ -74,19 +66,4 @@ public class MixinExplosion implements ExplosionHooksImpl.ExplosionExtensions {
}
return position;
}
@Override
public Entity architectury_getSource() {
return source;
}
@Override
public float architectury_getRadius() {
return radius;
}
@Override
public void architectury_setRadius(float v) {
radius = v;
}
}

View File

@@ -1,4 +1,4 @@
accessWidener v1 named
accessWidener v2 named
accessible method net/minecraft/client/gui/screens/Screen addButton (Lnet/minecraft/client/gui/components/AbstractWidget;)Lnet/minecraft/client/gui/components/AbstractWidget;
accessible method net/minecraft/client/gui/screens/Screen addWidget (Lnet/minecraft/client/gui/components/events/GuiEventListener;)Lnet/minecraft/client/gui/components/events/GuiEventListener;
accessible field net/minecraft/client/gui/screens/Screen buttons Ljava/util/List;
@@ -114,3 +114,7 @@ accessible field net/minecraft/world/item/trading/MerchantOffer priceMultiplier
accessible field net/minecraft/world/item/trading/MerchantOffer xp I
accessible method net/minecraft/client/renderer/item/ItemProperties registerGeneric (Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/client/renderer/item/ItemPropertyFunction;)Lnet/minecraft/client/renderer/item/ItemPropertyFunction;
accessible method net/minecraft/client/renderer/item/ItemProperties register (Lnet/minecraft/world/item/Item;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/client/renderer/item/ItemPropertyFunction;)V
accessible field net/minecraft/world/level/Explosion source Lnet/minecraft/world/entity/Entity;
mutable field net/minecraft/world/level/Explosion source Lnet/minecraft/world/entity/Entity;
accessible field net/minecraft/world/level/Explosion radius F
mutable field net/minecraft/world/level/Explosion radius F

View File

@@ -8,12 +8,11 @@ loom {
}
configurations {
shadowCommon
dev
}
artifacts {
dev(jar)
common
shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
compileClasspath.extendsFrom common
runtimeClasspath.extendsFrom common
developmentForge.extendsFrom common
}
architectury {
@@ -28,15 +27,8 @@ dependencies {
implementation "net.jodah:typetools:0.6.2"
shadowCommon "net.jodah:typetools:0.6.2"
implementation(project(path: ":common")) {
transitive = false
}
developmentForge(project(path: ":common")) {
transitive = false
}
shadowCommon(project(path: ":common", configuration: "transformProductionForge")) {
transitive = false
}
common(project(path: ":common", configuration: "namedElements")) { transitive false }
shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive false }
}
processResources {
@@ -50,6 +42,7 @@ shadowJar {
relocate "net.jodah.typetools", "me.shedaniel.architectury.shadowed.impl.net.jodah.typetools"
exclude "fabric.mod.json"
exclude "architectury-common.accessWidener"
exclude "architectury.common.json"
configurations = [project.configurations.shadowCommon]
classifier "shadow"

View File

@@ -24,10 +24,6 @@ import net.minecraft.world.phys.shapes.CollisionContext;
import org.jetbrains.annotations.Nullable;
public class EntityHooksImpl {
public static String getEncodeId(Entity entity) {
return entity.getEncodeId();
}
@Nullable
public static Entity fromCollision(CollisionContext ctx) {
return ctx.getEntity();

View File

@@ -19,7 +19,6 @@
package me.shedaniel.architectury.hooks.forge;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.Explosion;
import net.minecraft.world.phys.Vec3;
@@ -27,16 +26,4 @@ public class ExplosionHooksImpl {
public static Vec3 getPosition(Explosion explosion) {
return explosion.getPosition();
}
public static Entity getSource(Explosion explosion) {
return explosion.getExploder();
}
public static float getRadius(Explosion explosion) {
return explosion.radius;
}
public static void setRadius(Explosion explosion, float v) {
explosion.radius = v;
}
}

View File

@@ -26,8 +26,4 @@ public class PlayerHooksImpl {
public static boolean isFake(Player playerEntity) {
return playerEntity instanceof FakePlayer;
}
public static void closeContainer(Player playerEntity) {
playerEntity.closeContainer();
}
}

View File

@@ -6,7 +6,7 @@ supported_version=1.16.4/5
archives_base_name=architectury
archives_base_name_snapshot=architectury-snapshot
base_version=1.25
base_version=1.26
maven_group=me.shedaniel
fabric_loader_version=0.11.1

View File

@@ -14,17 +14,7 @@ dependencies {
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}"
implementation project(path: ":fabric", configuration: "dev")
implementation(project(path: ":common")) {
transitive = false
}
developmentFabric(project(path: ":common")) {
transitive = false
}
implementation(project(path: ":testmod-common")) {
transitive = false
}
developmentFabric(project(path: ":testmod-common")) {
transitive = false
}
implementation project(path: ":fabric", configuration: "namedElements")
common(project(path: ":common", configuration: "namedElements")) { transitive false }
common(project(path: ":testmod-common", configuration: "namedElements")) { transitive false }
}

View File

@@ -21,17 +21,7 @@ dependencies {
mappings loom.officialMojangMappings()
forge "net.minecraftforge:forge:${gradle.rootProject.architectury.minecraft}-${rootProject.forge_version}"
implementation project(path: ":forge", configuration: "dev")
implementation(project(path: ":common")) {
transitive = false
}
developmentForge(project(path: ":common")) {
transitive = false
}
implementation(project(path: ":testmod-common")) {
transitive = false
}
developmentForge(project(path: ":testmod-common")) {
transitive = false
}
implementation project(path: ":forge", configuration: "namedElements")
common(project(path: ":common", configuration: "namedElements")) { transitive false }
common(project(path: ":testmod-common", configuration: "namedElements")) { transitive false }
}