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 7d745d612c
commit 7857615bfc
23 changed files with 78 additions and 152 deletions

View File

@@ -1,5 +1,5 @@
loom {
accessWidenerPath = file("src/main/resources/architectury.accessWidener")
accessWidenerPath = file("src/main/resources/architectury-common.accessWidener")
}
dependencies {
@@ -12,20 +12,6 @@ architectury {
common(rootProject.forgeEnabled.toBoolean())
}
afterEvaluate {
remapJar {
remapAccessWidener = false
}
}
configurations {
dev
}
artifacts {
dev(jar)
}
publishing {
publications {
mavenCommon(MavenPublication) {

View File

@@ -20,11 +20,17 @@
package dev.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

@@ -27,6 +27,7 @@ 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.minecraft.world.level.block.state.BlockState;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import java.util.Set;
@@ -35,6 +36,11 @@ public class BlockEntityHooks {
private BlockEntityHooks() {
}
/**
* @deprecated Use the Builder from vanilla directly.
*/
@Deprecated
@ApiStatus.ScheduledForRemoval
public static <T extends BlockEntity> TypeBuilder<T> builder(Constructor<? extends T> constructor, Block... blocks) {
return new TypeBuilder<>(constructor, ImmutableSet.copyOf(blocks));
}

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

@@ -23,15 +23,20 @@ import dev.architectury.injectables.annotations.ExpectPlatform;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.EntityCollisionContext;
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

@@ -21,6 +21,8 @@ package dev.architectury.hooks.level.entity;
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 biomeCategory Lnet/minecraft/world/level/biome/Biome$BiomeCategory;
@@ -35,11 +35,17 @@ 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 class net/minecraft/world/level/block/entity/BlockEntityType$BlockEntitySupplier
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 class net/minecraft/world/level/block/entity/BlockEntityType$BlockEntitySupplier
accessible field net/minecraft/world/item/AxeItem STRIPPABLES Ljava/util/Map;
mutable field net/minecraft/world/item/AxeItem STRIPPABLES 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

View File

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

View File

@@ -18,11 +18,6 @@ configurations {
compileClasspath.extendsFrom common
runtimeClasspath.extendsFrom common
developmentFabric.extendsFrom common
dev
}
artifacts {
dev(jar)
}
repositories {
@@ -34,7 +29,7 @@ dependencies {
modImplementation "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}"
modCompileOnly("com.terraformersmc:modmenu:${rootProject.mod_menu_version}") { transitive false }
common(project(path: ":common", configuration: "dev")) { transitive false }
common(project(path: ":common", configuration: "namedElements")) { transitive false }
shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false }
}
@@ -46,6 +41,9 @@ processResources {
}
shadowJar {
exclude "architectury-common.accessWidener"
exclude "architectury.common.json"
configurations = [project.configurations.shadowCommon]
classifier "dev-shadow"
}

View File

@@ -25,10 +25,6 @@ import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.entity.EntityInLevelCallback;
public class EntityHooksImpl {
public static String getEncodeId(Entity entity) {
return entity.getEncodeId();
}
public static EntityInLevelCallback wrapEntityInLevelCallback(Entity entity, EntityInLevelCallback callback) {
if (callback == EntityInLevelCallback.NULL) return callback;
if (callback == null) return callback;

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

@@ -19,7 +19,6 @@
package dev.architectury.hooks.level.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

@@ -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 addRenderableWidget (Lnet/minecraft/client/gui/components/events/GuiEventListener;)Lnet/minecraft/client/gui/components/events/GuiEventListener;
accessible method net/minecraft/client/gui/screens/Screen addRenderableOnly (Lnet/minecraft/client/gui/components/Widget;)Lnet/minecraft/client/gui/components/Widget;
accessible method net/minecraft/client/gui/screens/Screen addWidget (Lnet/minecraft/client/gui/components/events/GuiEventListener;)Lnet/minecraft/client/gui/components/events/GuiEventListener;
@@ -102,3 +102,7 @@ accessible field net/minecraft/world/item/HoeItem TILLABLES Ljava/util/Map;
mutable field net/minecraft/world/item/HoeItem TILLABLES Ljava/util/Map;
accessible method net/minecraft/client/renderer/item/ItemProperties registerGeneric (Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/client/renderer/item/ClampedItemPropertyFunction;)Lnet/minecraft/client/renderer/item/ClampedItemPropertyFunction;
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
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

@@ -21,17 +21,12 @@ configurations {
compileClasspath.extendsFrom common
runtimeClasspath.extendsFrom common
developmentForge.extendsFrom common
dev
}
artifacts {
dev(jar)
}
dependencies {
forge "net.minecraftforge:forge:${rootProject.architectury.minecraft}-${rootProject.forge_version}"
common(project(path: ":common", configuration: "dev")) { transitive false }
common(project(path: ":common", configuration: "namedElements")) { transitive false }
shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive false }
}
@@ -45,6 +40,7 @@ processResources {
shadowJar {
exclude "fabric.mod.json"
exclude "architectury-common.accessWidener"
exclude "architectury.common.json"
configurations = [project.configurations.shadowCommon]
classifier "dev-shadow"

View File

@@ -1,28 +0,0 @@
/*
* This file is part of architectury.
* Copyright (C) 2020, 2021 architectury
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package dev.architectury.hooks.level.entity.forge;
import net.minecraft.world.entity.Entity;
public class EntityHooksImpl {
public static String getEncodeId(Entity entity) {
return entity.getEncodeId();
}
}

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

@@ -19,7 +19,6 @@
package dev.architectury.hooks.level.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

@@ -11,7 +11,7 @@ cf_type=release
archives_base_name=architectury
archives_base_name_snapshot=architectury-snapshot
base_version=3.1
base_version=3.2
maven_group=dev.architectury
fabric_loader_version=0.12.5

View File

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

View File

@@ -8,11 +8,3 @@ dependencies {
architectury {
common(rootProject.forgeEnabled.toBoolean())
}
configurations {
dev
}
artifacts {
dev(jar)
}

View File

@@ -23,7 +23,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")
common(project(path: ":common", configuration: "dev")) { transitive = false }
common(project(path: ":testmod-common", configuration: "dev")) { 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

@@ -30,7 +30,7 @@ configurations {
dependencies {
forge "net.minecraftforge:forge:${gradle.rootProject.architectury.minecraft}-${rootProject.forge_version}"
implementation project(path: ":forge", configuration: "dev")
common(project(path: ":common", configuration: "dev")) { transitive false }
common(project(path: ":testmod-common", configuration: "dev")) { 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 }
}