Rename and validate Mixin class names. ()

And update loom.
This commit is contained in:
modmuss50 2022-08-15 18:59:19 +01:00 committed by GitHub
parent 42d99c329d
commit aeb40ebeab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
121 changed files with 236 additions and 338 deletions
build.gradle
deprecated
fabric-containers-v0/src/main
java/net/fabricmc/fabric/mixin/container
resources
fabric-events-lifecycle-v0/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle
fabric-loot-tables-v1/src/main
java/net/fabricmc/fabric/mixin/loot/table
resources
fabric-biome-api-v1/src/main
fabric-blockrenderlayer-v1/src/client
java/net/fabricmc/fabric/mixin/blockrenderlayer
resources
fabric-content-registries-v0/src/main
fabric-crash-report-info-v1/src/main
java/net/fabricmc/fabric/mixin/crash/report/info
resources
fabric-dimensions-v1/src/main
java/net/fabricmc/fabric/mixin/dimension
resources
fabric-events-interaction-v0/src
fabric-game-rule-api-v1/src
fabric-item-groups-v0/src
client
main
java/net/fabricmc/fabric/mixin/item/group
resources
fabric-key-binding-api-v1/src/client
fabric-lifecycle-events-v1/src
client
java/net/fabricmc/fabric/mixin/event/lifecycle/client
resources
main
java/net/fabricmc/fabric/mixin/event/lifecycle
resources
fabric-models-v0/src/client
java/net/fabricmc/fabric/mixin/client/model
resources
fabric-object-builder-api-v1
fabric-particles-v1
build.gradle
src/client
java/net/fabricmc/fabric/mixin/client/particle
resources
fabric-registry-sync-v0/src
fabric-renderer-api-v1/src/client
fabric-renderer-indigo/src/client

View file

@ -9,7 +9,7 @@ plugins {
id "eclipse"
id "idea"
id "maven-publish"
id "fabric-loom" version "0.13.6" apply false
id "fabric-loom" version "0.13.12" apply false
id "com.diffplug.spotless" version "6.5.1"
id "org.ajoberstar.grgit" version "3.1.0"
id "com.matthewprenger.cursegradle" version "1.4.0"
@ -254,6 +254,12 @@ allprojects {
addNestedDependencies = false
}
build.dependsOn remapTestmodJar
task validateMixinNames(type: net.fabricmc.loom.task.ValidateMixinNameTask) {
source(sourceSets.main.output)
source(sourceSets.client.output)
source(sourceSets.testmod.output)
}
}
remapTestmodJar {

View file

@ -24,7 +24,7 @@ import net.minecraft.server.network.ServerPlayerEntity;
import net.fabricmc.fabric.impl.container.ServerPlayerEntitySyncHook;
@Mixin(ServerPlayerEntity.class)
public abstract class MixinServerPlayerEntity implements ServerPlayerEntitySyncHook {
public abstract class ServerPlayerEntityMixin implements ServerPlayerEntitySyncHook {
@Shadow
private int screenHandlerSyncId;

View file

@ -3,7 +3,7 @@
"package": "net.fabricmc.fabric.mixin.container",
"compatibilityLevel": "JAVA_16",
"mixins": [
"MixinServerPlayerEntity"
"ServerPlayerEntityMixin"
],
"injectors": {
"defaultRequire": 1

View file

@ -1,48 +0,0 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.fabricmc.fabric.mixin.event.lifecycle;
import java.util.function.BooleanSupplier;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import net.minecraft.server.MinecraftServer;
import net.fabricmc.fabric.api.event.server.ServerStartCallback;
import net.fabricmc.fabric.api.event.server.ServerStopCallback;
import net.fabricmc.fabric.api.event.server.ServerTickCallback;
@Mixin(MinecraftServer.class)
public class MixinMinecraftServer {
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;setFavicon(Lnet/minecraft/server/ServerMetadata;)V", ordinal = 0), method = "method_29741")
public void afterSetupServer(CallbackInfo info) {
ServerStartCallback.EVENT.invoker().onStartServer((MinecraftServer) (Object) this);
}
@Inject(at = @At("HEAD"), method = "shutdown")
public void beforeShutdownServer(CallbackInfo info) {
ServerStopCallback.EVENT.invoker().onStopServer((MinecraftServer) (Object) this);
}
@Inject(at = @At("RETURN"), method = "tick")
protected void tick(BooleanSupplier var1, CallbackInfo info) {
ServerTickCallback.EVENT.invoker().tick((MinecraftServer) (Object) this);
}
}

View file

@ -32,7 +32,7 @@ import net.minecraft.loot.provider.number.LootNumberProvider;
import net.fabricmc.fabric.api.loot.v1.FabricLootPool;
@Mixin(LootPool.class)
public abstract class MixinLootPool implements FabricLootPool {
public abstract class LootPoolMixin implements FabricLootPool {
@Shadow
@Final
LootPoolEntry[] entries;

View file

@ -30,7 +30,7 @@ import net.minecraft.loot.function.LootFunction;
import net.fabricmc.fabric.api.loot.v1.FabricLootSupplier;
@Mixin(LootTable.class)
public abstract class MixinLootSupplier implements FabricLootSupplier {
public abstract class LootTableMixin implements FabricLootSupplier {
@Shadow
@Final
LootPool[] pools;

View file

@ -3,8 +3,8 @@
"package": "net.fabricmc.fabric.mixin.loot.table",
"compatibilityLevel": "JAVA_16",
"mixins": [
"MixinLootPool",
"MixinLootSupplier"
"LootPoolMixin",
"LootTableMixin"
],
"injectors": {
"defaultRequire": 1

View file

@ -23,12 +23,11 @@ import java.util.Set;
import java.util.WeakHashMap;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import com.google.common.base.Preconditions;
import org.jetbrains.annotations.ApiStatus;
import it.unimi.dsi.fastutil.Hash;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenCustomHashMap;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import net.minecraft.util.math.noise.PerlinNoiseSampler;
import net.minecraft.util.registry.Registry;

View file

@ -29,7 +29,7 @@ import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.source.BiomeSource;
@Mixin(BiomeSource.class)
public class MixinBiomeSource {
public class BiomeSourceMixin {
// Not marked as @Final because of AW
@Shadow
public Set<RegistryEntry<Biome>> biomes;

View file

@ -38,7 +38,7 @@ import net.minecraft.world.gen.noise.NoiseRouter;
import net.fabricmc.fabric.impl.biome.MultiNoiseSamplerHooks;
@Mixin(ChunkNoiseSampler.class)
public class MixinChunkNoiseSampler {
public class ChunkNoiseSamplerMixin {
@Unique
private long seed;

View file

@ -32,7 +32,7 @@ import net.minecraft.world.SaveProperties;
import net.fabricmc.fabric.impl.biome.NetherBiomeData;
@Mixin(MinecraftServer.class)
public class MixinMinecraftServer {
public class MinecraftServerMixin {
@Shadow
@Final
protected SaveProperties saveProperties;

View file

@ -24,7 +24,7 @@ import net.minecraft.world.biome.source.MultiNoiseBiomeSource;
import net.fabricmc.fabric.impl.biome.BiomeSourceAccess;
@Mixin(MultiNoiseBiomeSource.class)
public class MixinMultiNoiseBiomeSource implements BiomeSourceAccess {
public class MultiNoiseBiomeSourceMixin implements BiomeSourceAccess {
@Unique
private boolean modifyBiomeEntries = true;

View file

@ -28,7 +28,7 @@ import net.minecraft.world.biome.source.util.MultiNoiseUtil;
import net.fabricmc.fabric.impl.biome.MultiNoiseSamplerHooks;
@Mixin(MultiNoiseUtil.MultiNoiseSampler.class)
public class MixinMultiNoiseSampler implements MultiNoiseSamplerHooks {
public class MultiNoiseUtilMultiNoiseSamplerMixin implements MultiNoiseSamplerHooks {
@Unique
private Long seed = null;

View file

@ -31,7 +31,7 @@ import net.minecraft.world.gen.noise.NoiseConfig;
import net.fabricmc.fabric.impl.biome.MultiNoiseSamplerHooks;
@Mixin(NoiseConfig.class)
public class MixinNoiseConfig {
public class NoiseConfigMixin {
@Shadow
@Final
private MultiNoiseUtil.MultiNoiseSampler multiNoiseSampler;

View file

@ -36,7 +36,7 @@ import net.minecraft.world.biome.source.util.MultiNoiseUtil;
import net.fabricmc.fabric.impl.biome.TheEndBiomeData;
@Mixin(TheEndBiomeSource.class)
public class MixinTheEndBiomeSource extends MixinBiomeSource {
public class TheEndBiomeSourceMixin extends BiomeSourceMixin {
@Unique
private Supplier<TheEndBiomeData.Overrides> overrides;

View file

@ -28,7 +28,7 @@ import net.fabricmc.fabric.impl.biome.modification.BiomeModificationMarker;
* {@link net.fabricmc.fabric.impl.biome.modification.BiomeModificationImpl} on a per-DynamicRegistryManager basis.
*/
@Mixin(DynamicRegistryManager.ImmutableImpl.class)
public class DynamicRegistryManagerImplMixin implements BiomeModificationMarker {
public class DynamicRegistryManagerImmutableImplMixin implements BiomeModificationMarker {
@Unique
private boolean modified;

View file

@ -3,15 +3,14 @@
"package": "net.fabricmc.fabric.mixin.biome",
"compatibilityLevel": "JAVA_16",
"mixins": [
"MixinMinecraftServer",
"MixinBiomeSource",
"MixinChunkNoiseSampler",
"MixinMultiNoiseBiomeSource",
"MixinMultiNoiseSampler",
"MixinNoiseConfig",
"MixinTheEndBiomeSource",
"modification.DynamicRegistryManagerImplMixin",
"MinecraftServerMixin",
"BiomeSourceMixin",
"ChunkNoiseSamplerMixin",
"MultiNoiseBiomeSourceMixin",
"MultiNoiseUtilMultiNoiseSamplerMixin",
"NoiseConfigMixin",
"TheEndBiomeSourceMixin",
"modification.DynamicRegistryManagerImmutableImplMixin",
"modification.MinecraftServerMixin"
],
"injectors": {

View file

@ -32,7 +32,7 @@ import net.minecraft.fluid.Fluid;
import net.fabricmc.fabric.impl.blockrenderlayer.BlockRenderLayerMapImpl;
@Mixin(RenderLayers.class)
public class MixinBlockRenderLayer {
public class RenderLayersMixin {
@Shadow private static Map<Block, RenderLayer> BLOCKS;
@Shadow private static Map<Fluid, RenderLayer> FLUIDS;

View file

@ -3,7 +3,7 @@
"package": "net.fabricmc.fabric.mixin.blockrenderlayer",
"compatibilityLevel": "JAVA_16",
"client": [
"MixinBlockRenderLayer"
"RenderLayersMixin"
],
"injectors": {
"defaultRequire": 1

View file

@ -31,7 +31,7 @@ import net.fabricmc.fabric.api.registry.FuelRegistry;
import net.fabricmc.fabric.impl.content.registry.FuelRegistryImpl;
@Mixin(AbstractFurnaceBlockEntity.class)
public class MixinAbstractFurnaceBlockEntity {
public class AbstractFurnaceBlockEntityMixin {
@Inject(at = @At("RETURN"), method = "createFuelTimeMap")
private static void fuelTimeMapHook(CallbackInfoReturnable<Map<Item, Integer>> info) {
((FuelRegistryImpl) FuelRegistry.INSTANCE).apply(info.getReturnValue());

View file

@ -33,7 +33,7 @@ import net.fabricmc.fabric.impl.content.registry.FireBlockHooks;
import net.fabricmc.fabric.impl.content.registry.FlammableBlockRegistryImpl;
@Mixin(FireBlock.class)
public class MixinFireBlock implements FireBlockHooks {
public class FireBlockMixin implements FireBlockHooks {
private FlammableBlockRegistryImpl fabric_registry;
@Shadow

View file

@ -9,8 +9,8 @@
"GiveGiftsToHeroTaskAccessor",
"HoeItemAccessor",
"HoneycombItemMixin",
"MixinAbstractFurnaceBlockEntity",
"MixinFireBlock",
"AbstractFurnaceBlockEntityMixin",
"FireBlockMixin",
"OxidizableMixin",
"SculkSensorBlockMixin",
"ShovelItemAccessor",

View file

@ -32,7 +32,7 @@ import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.ModContainer;
@Mixin(SystemDetails.class)
public abstract class MixinCrashReport {
public abstract class SystemDetailsMixin {
@Shadow
public abstract void addSection(String string, Supplier<String> supplier);

View file

@ -3,7 +3,7 @@
"package": "net.fabricmc.fabric.mixin.crash.report.info",
"compatibilityLevel": "JAVA_16",
"mixins": [
"MixinCrashReport"
"SystemDetailsMixin"
],
"injectors": {
"defaultRequire": 1

View file

@ -44,7 +44,7 @@ import net.minecraft.world.level.storage.LevelStorage;
* With this Mixin, custom dimensions will be removed when its datapack is removed.
*/
@Mixin(LevelStorage.class)
public class LevelStorageBugfixMixin {
public class LevelStorageMixin {
@SuppressWarnings("unchecked")
@Inject(method = "readGeneratorProperties", at = @At("HEAD"))
private static <T> void onReadGeneratorProperties(

View file

@ -51,7 +51,7 @@ import net.minecraft.world.level.storage.LevelStorage;
* the testmod's commands), then the bug is fixed and this Mixin can be removed.
*/
@Mixin(value = Main.class)
public class ServerBugfixMixin {
public class MainMixin {
@Unique
private static LevelStorage.Session session;

View file

@ -4,8 +4,8 @@
"compatibilityLevel": "JAVA_16",
"mixins": [
"EntityMixin",
"LevelStorageBugfixMixin",
"ServerBugfixMixin",
"LevelStorageMixin",
"MainMixin",
"ServerPlayerEntityMixin"
],
"injectors": {

View file

@ -54,7 +54,7 @@ import net.fabricmc.fabric.api.event.player.UseEntityCallback;
import net.fabricmc.fabric.api.event.player.UseItemCallback;
@Mixin(ClientPlayerInteractionManager.class)
public abstract class MixinClientPlayerInteractionManager {
public abstract class ClientPlayerInteractionManagerMixin {
@Shadow
private MinecraftClient client;
@Shadow

View file

@ -37,7 +37,7 @@ import net.fabricmc.fabric.api.event.client.player.ClientPickBlockCallback;
import net.fabricmc.fabric.api.event.client.player.ClientPickBlockGatherCallback;
@Mixin(MinecraftClient.class)
public abstract class MixinMinecraftClient {
public abstract class MinecraftClientMixin {
private boolean fabric_itemPickCancelled;
@SuppressWarnings("deprecation")

View file

@ -3,8 +3,8 @@
"package": "net.fabricmc.fabric.mixin.event.interaction.client",
"compatibilityLevel": "JAVA_16",
"client": [
"MixinClientPlayerInteractionManager",
"MixinMinecraftClient"
"ClientPlayerInteractionManagerMixin",
"MinecraftClientMixin"
],
"injectors": {
"defaultRequire": 1

View file

@ -35,7 +35,7 @@ import net.minecraft.world.World;
import net.fabricmc.fabric.api.event.player.UseEntityCallback;
@Mixin(targets = "net/minecraft/server/network/ServerPlayNetworkHandler$1")
public abstract class MixinServerPlayNetworkHandler implements PlayerInteractEntityC2SPacket.Handler {
public abstract class ServerPlayNetworkHandlerMixin implements PlayerInteractEntityC2SPacket.Handler {
@Shadow
public ServerPlayNetworkHandler field_28963;

View file

@ -29,7 +29,7 @@ import net.minecraft.util.Hand;
import net.fabricmc.fabric.api.event.player.AttackEntityCallback;
@Mixin(ServerPlayerEntity.class)
public class MixinServerPlayerEntity {
public class ServerPlayerEntityMixin {
@Inject(method = "attack", at = @At("HEAD"), cancellable = true)
public void onPlayerInteractEntity(Entity target, CallbackInfo info) {
ServerPlayerEntity player = (ServerPlayerEntity) (Object) this;

View file

@ -49,7 +49,7 @@ import net.fabricmc.fabric.api.event.player.UseBlockCallback;
import net.fabricmc.fabric.api.event.player.UseItemCallback;
@Mixin(ServerPlayerInteractionManager.class)
public class MixinServerPlayerInteractionManager {
public class ServerPlayerInteractionManagerMixin {
@Shadow
public ServerWorld world;
@Shadow

View file

@ -3,9 +3,9 @@
"package": "net.fabricmc.fabric.mixin.event.interaction",
"compatibilityLevel": "JAVA_16",
"mixins": [
"MixinServerPlayerEntity",
"MixinServerPlayerInteractionManager",
"MixinServerPlayNetworkHandler"
"ServerPlayerEntityMixin",
"ServerPlayerInteractionManagerMixin",
"ServerPlayNetworkHandlerMixin"
],
"injectors": {
"defaultRequire": 1

View file

@ -35,11 +35,11 @@ import net.fabricmc.fabric.api.gamerule.v1.CustomGameRuleCategory;
// For any future maintainers who wonder why this class does not compile because of jsr305, please reload gradle using `--refresh-dependencies`.
@Mixin(EditGameRulesScreen.RuleListWidget.class)
public abstract class RuleListWidgetMixin extends net.minecraft.client.gui.widget.EntryListWidget<EditGameRulesScreen.AbstractRuleWidget> {
public abstract class EditGameRulesScreenRuleListWidgetMixin extends net.minecraft.client.gui.widget.EntryListWidget<EditGameRulesScreen.AbstractRuleWidget> {
@Unique
private final Map<CustomGameRuleCategory, List<EditGameRulesScreen.AbstractRuleWidget>> fabricCategories = new HashMap<>();
public RuleListWidgetMixin(MinecraftClient client, int width, int height, int top, int bottom, int itemHeight) {
public EditGameRulesScreenRuleListWidgetMixin(MinecraftClient client, int width, int height, int top, int bottom, int itemHeight) {
super(client, width, height, top, bottom, itemHeight);
}

View file

@ -4,7 +4,7 @@
"compatibilityLevel": "JAVA_16",
"client": [
"EditGameRulesScreenAccessor",
"RuleListWidgetMixin",
"EditGameRulesScreenRuleListWidgetMixin",
"RuleListWidgetVisitorMixin"
],
"injectors": {

View file

@ -31,7 +31,7 @@ import net.fabricmc.fabric.api.gamerule.v1.rule.DoubleRule;
import net.fabricmc.fabric.api.gamerule.v1.rule.EnumRule;
import net.fabricmc.fabric.impl.gamerule.EnumRuleType;
import net.fabricmc.fabric.impl.gamerule.rule.BoundedIntRule;
import net.fabricmc.fabric.mixin.gamerule.BooleanRuleAccessor;
import net.fabricmc.fabric.mixin.gamerule.GameRulesBooleanRuleAccessor;
/**
* A utility class containing factory methods to create game rule types.
@ -70,7 +70,7 @@ public final class GameRuleFactory {
* @return a boolean rule type
*/
public static GameRules.Type<GameRules.BooleanRule> createBooleanRule(boolean defaultValue, BiConsumer<MinecraftServer, GameRules.BooleanRule> changedCallback) {
return BooleanRuleAccessor.invokeCreate(defaultValue, changedCallback);
return GameRulesBooleanRuleAccessor.invokeCreate(defaultValue, changedCallback);
}
/**

View file

@ -24,7 +24,7 @@ import net.minecraft.world.GameRules;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.gamerule.v1.GameRuleRegistry;
import net.fabricmc.fabric.mixin.gamerule.IntRuleAccessor;
import net.fabricmc.fabric.mixin.gamerule.GameRulesIntRuleAccessor;
public final class BoundedIntRule extends GameRules.IntRule {
private static final Logger LOGGER = LoggerFactory.getLogger(GameRuleRegistry.class);
@ -47,7 +47,7 @@ public final class BoundedIntRule extends GameRules.IntRule {
return;
}
((IntRuleAccessor) (Object) this).setValue(i);
((GameRulesIntRuleAccessor) (Object) this).setValue(i);
}
@Override
@ -60,7 +60,7 @@ public final class BoundedIntRule extends GameRules.IntRule {
return false;
}
((IntRuleAccessor) (Object) this).setValue(value);
((GameRulesIntRuleAccessor) (Object) this).setValue(value);
return true;
} catch (NumberFormatException var3) {
return false;
@ -69,7 +69,7 @@ public final class BoundedIntRule extends GameRules.IntRule {
@Override
protected GameRules.IntRule copy() {
return new BoundedIntRule(this.type, ((IntRuleAccessor) (Object) this).getValue(), this.minimumValue, this.maximumValue);
return new BoundedIntRule(this.type, ((GameRulesIntRuleAccessor) (Object) this).getValue(), this.minimumValue, this.maximumValue);
}
private static int parseInt(String input) {

View file

@ -25,7 +25,7 @@ import net.minecraft.server.MinecraftServer;
import net.minecraft.world.GameRules;
@Mixin(GameRules.BooleanRule.class)
public interface BooleanRuleAccessor {
public interface GameRulesBooleanRuleAccessor {
@Invoker
static GameRules.Type<GameRules.BooleanRule> invokeCreate(boolean initialValue, BiConsumer<MinecraftServer, GameRules.BooleanRule> changeCallback) {
throw new AssertionError("This shouldn't happen!");

View file

@ -22,7 +22,7 @@ import org.spongepowered.asm.mixin.gen.Accessor;
import net.minecraft.world.GameRules;
@Mixin(GameRules.IntRule.class)
public interface IntRuleAccessor {
public interface GameRulesIntRuleAccessor {
@Accessor
int getValue();

View file

@ -26,7 +26,7 @@ import net.fabricmc.fabric.api.gamerule.v1.CustomGameRuleCategory;
import net.fabricmc.fabric.impl.gamerule.RuleKeyExtensions;
@Mixin(GameRules.Key.class)
public abstract class RuleKeyMixin implements RuleKeyExtensions {
public abstract class GameRulesKeyMixin implements RuleKeyExtensions {
@Unique
@Nullable
private CustomGameRuleCategory customCategory;

View file

@ -3,12 +3,12 @@
"package": "net.fabricmc.fabric.mixin.gamerule",
"compatibilityLevel": "JAVA_16",
"mixins": [
"BooleanRuleAccessor",
"GameRulesBooleanRuleAccessor",
"GameRuleCommandAccessor",
"GameRuleCommandVisitorMixin",
"GameRulesAccessor",
"IntRuleAccessor",
"RuleKeyMixin"
"GameRulesIntRuleAccessor",
"GameRulesKeyMixin"
],
"injectors": {
"defaultRequire": 1

View file

@ -35,8 +35,8 @@ import net.fabricmc.fabric.impl.item.group.CreativeGuiExtensions;
import net.fabricmc.fabric.impl.item.group.FabricCreativeGuiComponents;
@Mixin(CreativeInventoryScreen.class)
public abstract class MixinCreativePlayerInventoryGui extends AbstractInventoryScreen implements CreativeGuiExtensions {
public MixinCreativePlayerInventoryGui(ScreenHandler container_1, PlayerInventory playerInventory_1, Text textComponent_1) {
public abstract class CreativeInventoryScreenMixin extends AbstractInventoryScreen implements CreativeGuiExtensions {
public CreativeInventoryScreenMixin(ScreenHandler container_1, PlayerInventory playerInventory_1, Text textComponent_1) {
super(container_1, playerInventory_1, textComponent_1);
}

View file

@ -27,7 +27,7 @@ import net.minecraft.item.ItemGroup;
import net.fabricmc.fabric.impl.item.group.FabricCreativeGuiComponents;
@Mixin(ItemGroup.class)
public abstract class MixinItemGroup {
public abstract class ItemGroupMixin {
@Shadow
public abstract int getIndex();

View file

@ -3,8 +3,8 @@
"package": "net.fabricmc.fabric.mixin.item.group.client",
"compatibilityLevel": "JAVA_16",
"client": [
"MixinItemGroup",
"MixinCreativePlayerInventoryGui"
"ItemGroupMixin",
"CreativeInventoryScreenMixin"
],
"injectors": {
"defaultRequire": 1

View file

@ -26,7 +26,7 @@ import net.minecraft.item.ItemGroup;
import net.fabricmc.fabric.impl.item.group.ItemGroupExtensions;
@Mixin(ItemGroup.class)
public abstract class MixinItemGroup implements ItemGroupExtensions {
public abstract class ItemGroupMixin implements ItemGroupExtensions {
@Shadow
@Final
@Mutable

View file

@ -3,7 +3,7 @@
"package": "net.fabricmc.fabric.mixin.item.group",
"compatibilityLevel": "JAVA_16",
"mixins": [
"MixinItemGroup"
"ItemGroupMixin"
],
"injectors": {
"defaultRequire": 1

View file

@ -20,7 +20,7 @@ import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.util.InputUtil;
import net.fabricmc.fabric.impl.client.keybinding.KeyBindingRegistryImpl;
import net.fabricmc.fabric.mixin.client.keybinding.KeyCodeAccessor;
import net.fabricmc.fabric.mixin.client.keybinding.KeyBindingAccessor;
/**
* Helper for registering key bindings.
@ -53,6 +53,6 @@ public final class KeyBindingHelper {
* @return configured KeyCode
*/
public static InputUtil.Key getBoundKeyOf(KeyBinding keyBinding) {
return ((KeyCodeAccessor) keyBinding).fabric_getBoundKey();
return ((KeyBindingAccessor) keyBinding).fabric_getBoundKey();
}
}

View file

@ -30,7 +30,7 @@ import net.minecraft.client.option.KeyBinding;
import net.fabricmc.fabric.impl.client.keybinding.KeyBindingRegistryImpl;
@Mixin(GameOptions.class)
public class MixinGameOptions {
public class GameOptionsMixin {
@Mutable
@Final
@Shadow

View file

@ -22,6 +22,7 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.util.InputUtil;
@Mixin(KeyBinding.class)
public interface KeyBindingAccessor {
@ -29,4 +30,7 @@ public interface KeyBindingAccessor {
static Map<String, Integer> fabric_getCategoryMap() {
throw new AssertionError();
}
@Accessor("boundKey")
InputUtil.Key fabric_getBoundKey();
}

View file

@ -1,29 +0,0 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.fabricmc.fabric.mixin.client.keybinding;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.util.InputUtil;
@Mixin(KeyBinding.class)
public interface KeyCodeAccessor {
@Accessor("boundKey")
InputUtil.Key fabric_getBoundKey();
}

View file

@ -4,8 +4,7 @@
"compatibilityLevel": "JAVA_16",
"client": [
"KeyBindingAccessor",
"KeyCodeAccessor",
"MixinGameOptions"
"GameOptionsMixin"
],
"injectors": {
"defaultRequire": 1

View file

@ -32,7 +32,7 @@ import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientEntityEvents;
@Environment(EnvType.CLIENT)
@Mixin(targets = "net/minecraft/client/world/ClientWorld$ClientEntityHandler")
abstract class ClientWorldEntityLoaderMixin {
abstract class ClientWorldClientEntityHandlerMixin {
// final synthetic Lnet/minecraft/client/world/ClientWorld; field_27735
@SuppressWarnings("ShadowTarget")
@Shadow

View file

@ -5,7 +5,7 @@
"client": [
"ClientChunkManagerMixin",
"ClientPlayNetworkHandlerMixin",
"ClientWorldEntityLoaderMixin",
"ClientWorldClientEntityHandlerMixin",
"ClientWorldMixin",
"MinecraftClientMixin",
"WorldChunkMixin"

View file

@ -29,7 +29,7 @@ import net.minecraft.server.world.ServerWorld;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerEntityEvents;
@Mixin(targets = "net/minecraft/server/world/ServerWorld$ServerEntityHandler")
abstract class ServerWorldEntityLoaderMixin {
abstract class ServerWorldServerEntityHandlerMixin {
// final synthetic Lnet/minecraft/server/world/ServerWorld; field_26936
@SuppressWarnings("ShadowTarget")
@Shadow

View file

@ -6,7 +6,7 @@
"DataPackContentsMixin",
"MinecraftServerMixin",
"PlayerManagerMixin",
"ServerWorldEntityLoaderMixin",
"ServerWorldServerEntityHandlerMixin",
"ServerWorldMixin",
"ThreadedAnvilChunkStorageMixin",
"WorldMixin"

View file

@ -28,7 +28,7 @@ import net.minecraft.util.Identifier;
import net.fabricmc.fabric.impl.client.model.BakedModelManagerHooks;
@Mixin(BakedModelManager.class)
public class MixinBakedModelManager implements BakedModelManagerHooks {
public class BakedModelManagerMixin implements BakedModelManagerHooks {
@Shadow
private Map<Identifier, BakedModel> models;

View file

@ -36,7 +36,7 @@ import net.fabricmc.fabric.impl.client.model.ModelLoaderHooks;
import net.fabricmc.fabric.impl.client.model.ModelLoadingRegistryImpl;
@Mixin(ModelLoader.class)
public abstract class MixinModelLoader implements ModelLoaderHooks {
public abstract class ModelLoaderMixin implements ModelLoaderHooks {
// this is the first one
@Shadow
public static ModelIdentifier MISSING_ID;

View file

@ -3,8 +3,8 @@
"package": "net.fabricmc.fabric.mixin.client.model",
"compatibilityLevel": "JAVA_16",
"client": [
"MixinBakedModelManager",
"MixinModelLoader"
"BakedModelManagerMixin",
"ModelLoaderMixin"
],
"injectors": {
"defaultRequire": 1

View file

@ -13,3 +13,7 @@ testDependencies(project, [
loom {
accessWidenerPath = file("src/main/resources/fabric-object-builder-api-v1.accesswidener")
}
validateMixinNames {
exclude "**/ModelPredicateProviderRegistrySpecificAccessor.class"
}

View file

@ -27,12 +27,13 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.random.Random;
import net.minecraft.util.registry.DefaultedRegistry;
import net.minecraft.village.TradeOffer;
import net.minecraft.util.math.random.Random;
import net.minecraft.village.TradeOffers;
@Mixin(targets = "net/minecraft/village/TradeOffers$TypeAwareBuyForOneEmeraldFactory")
public abstract class TypeAwareTradeMixin {
@Mixin(TradeOffers.TypeAwareBuyForOneEmeraldFactory.class)
public abstract class TradeOffersTypeAwareBuyForOneEmeraldFactoryMixin {
/**
* Vanilla will check the "VillagerType -> Item" map in the stream and throw an exception for villager types not specified in the map.
* This breaks any and all custom villager types.

View file

@ -6,6 +6,7 @@ accessible field net/minecraft/world/poi/PointOfInterestTypes POI_STAT
accessible method net/minecraft/world/poi/PointOfInterestTypes register (Lnet/minecraft/util/registry/Registry;Lnet/minecraft/util/registry/RegistryKey;Ljava/util/Set;II)Lnet/minecraft/world/poi/PointOfInterestType;
extendable class net/minecraft/block/entity/BlockEntityType$BlockEntityFactory
accessible class net/minecraft/village/TradeOffers$TypeAwareBuyForOneEmeraldFactory
accessible method net/minecraft/entity/SpawnRestriction register (Lnet/minecraft/entity/EntityType;Lnet/minecraft/entity/SpawnRestriction$Location;Lnet/minecraft/world/Heightmap$Type;Lnet/minecraft/entity/SpawnRestriction$SpawnPredicate;)V

View file

@ -10,7 +10,7 @@
"DefaultAttributeRegistryMixin",
"DetectorRailBlockMixin",
"MaterialBuilderAccessor",
"TypeAwareTradeMixin"
"TradeOffersTypeAwareBuyForOneEmeraldFactoryMixin"
],
"injectors": {
"defaultRequire": 1

View file

@ -9,3 +9,8 @@ moduleDependencies(project, [
'fabric-api-base',
'fabric-textures-v0'
])
validateMixinNames {
// Loom needs to handle inner mixins better
exclude "**/ParticleManagerAccessor\$SimpleSpriteProviderAccessor.class"
}

View file

@ -26,7 +26,7 @@ import net.minecraft.client.particle.ParticleManager;
import net.fabricmc.fabric.impl.client.particle.ParticleFactoryRegistryImpl;
@Mixin(ParticleManager.class)
public abstract class MixinParticleManager {
public abstract class ParticleManagerMixin {
@Inject(method = "registerDefaultFactories()V", at = @At("RETURN"))
private void onRegisterDefaultFactories(CallbackInfo info) {
ParticleFactoryRegistryImpl.INSTANCE.initialize((ParticleManager) (Object) this);

View file

@ -3,7 +3,7 @@
"package": "net.fabricmc.fabric.mixin.client.particle",
"compatibilityLevel": "JAVA_16",
"client": [
"MixinParticleManager",
"ParticleManagerMixin",
"ParticleManagerAccessor",
"ParticleManagerAccessor$SimpleSpriteProviderAccessor"
],

View file

@ -30,7 +30,7 @@ import net.minecraft.util.registry.Registry;
import net.fabricmc.fabric.impl.registry.sync.trackers.IdListTracker;
@Mixin(BlockColors.class)
public class MixinBlockColorMap {
public class BlockColorsMixin {
@Shadow
private IdList<BlockColorProvider> providers;

View file

@ -30,7 +30,7 @@ import net.minecraft.util.registry.Registry;
import net.fabricmc.fabric.impl.registry.sync.trackers.IdListTracker;
@Mixin(ItemColors.class)
public class MixinItemColorMap {
public class ItemColorsMixin {
@Shadow
private IdList<ItemColorProvider> providers;

View file

@ -32,7 +32,7 @@ import net.minecraft.util.registry.Registry;
import net.fabricmc.fabric.impl.registry.sync.trackers.Int2ObjectMapTracker;
@Mixin(ItemModels.class)
public class MixinItemModelMap {
public class ItemModelsMixin {
@Shadow
public Int2ObjectMap<ModelIdentifier> modelIds;
@Shadow

View file

@ -33,9 +33,9 @@ import net.fabricmc.fabric.impl.registry.sync.RemapException;
import net.fabricmc.fabric.impl.registry.sync.trackers.vanilla.BlockInitTracker;
@Mixin(MinecraftClient.class)
public class MixinMinecraftClient {
public class MinecraftClientMixin {
@Unique
private static Logger FABRIC_LOGGER = LoggerFactory.getLogger(MixinMinecraftClient.class);
private static Logger FABRIC_LOGGER = LoggerFactory.getLogger(MinecraftClientMixin.class);
// Unmap the registry before loading a new SP/MP setup.
@Inject(at = @At("RETURN"), method = "disconnect(Lnet/minecraft/client/gui/screen/Screen;)V")

View file

@ -32,7 +32,7 @@ import net.minecraft.client.world.ClientWorld;
import net.fabricmc.fabric.impl.registry.sync.trackers.Int2ObjectMapTracker;
@Mixin(ParticleManager.class)
public class MixinParticleManager {
public class ParticleManagerMixin {
@Shadow
private Int2ObjectMap<ParticleFactory<?>> factories;

View file

@ -3,11 +3,11 @@
"package": "net.fabricmc.fabric.mixin.registry.sync.client",
"compatibilityLevel": "JAVA_16",
"client": [
"MixinBlockColorMap",
"MixinItemColorMap",
"MixinItemModelMap",
"MixinMinecraftClient",
"MixinParticleManager"
"BlockColorsMixin",
"ItemColorsMixin",
"ItemModelsMixin",
"MinecraftClientMixin",
"ParticleManagerMixin"
],
"injectors": {
"defaultRequire": 1

View file

@ -27,7 +27,7 @@ import net.minecraft.util.registry.SimpleRegistry;
import net.minecraft.util.registry.RegistryKey;
import net.fabricmc.fabric.impl.registry.sync.FabricRegistry;
import net.fabricmc.fabric.mixin.registry.sync.AccessorRegistry;
import net.fabricmc.fabric.mixin.registry.sync.RegistryAccessor;
/**
* Used to create custom registries, with specified registry attributes.
@ -107,7 +107,7 @@ public final class FabricRegistryBuilder<T, R extends MutableRegistry<T>> {
fabricRegistry.build(attributes);
//noinspection unchecked
AccessorRegistry.getROOT().add(((AccessorRegistry) registry).getRegistryKey(), registry, Lifecycle.stable());
RegistryAccessor.getROOT().add(((RegistryAccessor) registry).getRegistryKey(), registry, Lifecycle.stable());
return registry;
}

View file

@ -27,7 +27,7 @@ import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.RegistryKey;
import net.fabricmc.fabric.api.event.registry.RegistryEntryAddedCallback;
import net.fabricmc.fabric.mixin.registry.sync.AccessorRegistry;
import net.fabricmc.fabric.mixin.registry.sync.RegistryAccessor;
/**
* Handles synchronising changes to the built-in registries into the dynamic registry manager's template manager,
@ -51,7 +51,7 @@ public class DynamicRegistrySync {
* are also added to the template for dynamic registry managers.
*/
private static <T> void setupSync(Registry<T> source, DynamicRegistryManager template) {
@SuppressWarnings("unchecked") AccessorRegistry<T> sourceAccessor = (AccessorRegistry<T>) source;
@SuppressWarnings("unchecked") RegistryAccessor<T> sourceAccessor = (RegistryAccessor<T>) source;
RegistryKey<? extends Registry<T>> sourceKey = source.getKey();
MutableRegistry<T> target = (MutableRegistry<T>) template.get(sourceKey);

View file

@ -25,7 +25,7 @@ import net.minecraft.util.math.MathHelper;
import net.minecraft.util.registry.Registry;
import net.fabricmc.fabric.api.event.registry.RegistryEntryAddedCallback;
import net.fabricmc.fabric.mixin.registry.sync.AccessorDebugChunkGenerator;
import net.fabricmc.fabric.mixin.registry.sync.DebugChunkGeneratorAccessor;
public final class BlockInitTracker implements RegistryEntryAddedCallback<Block> {
private final Registry<Block> registry;
@ -55,8 +55,8 @@ public final class BlockInitTracker implements RegistryEntryAddedCallback<Block>
final int xLength = MathHelper.ceil(MathHelper.sqrt(blockStateList.size()));
final int zLength = MathHelper.ceil(blockStateList.size() / (float) xLength);
AccessorDebugChunkGenerator.setBLOCK_STATES(blockStateList);
AccessorDebugChunkGenerator.setX_SIDE_LENGTH(xLength);
AccessorDebugChunkGenerator.setZ_SIDE_LENGTH(zLength);
DebugChunkGeneratorAccessor.setBLOCK_STATES(blockStateList);
DebugChunkGeneratorAccessor.setX_SIDE_LENGTH(xLength);
DebugChunkGeneratorAccessor.setZ_SIDE_LENGTH(zLength);
}
}

View file

@ -37,7 +37,7 @@ import net.fabricmc.fabric.impl.registry.sync.trackers.vanilla.BlockInitTracker;
import net.fabricmc.fabric.impl.registry.sync.trackers.vanilla.BlockItemTracker;
@Mixin(Bootstrap.class)
public class MixinBootstrap {
public class BootstrapMixin {
@Inject(method = "setOutputStreams", at = @At("RETURN"))
private static void initialize(CallbackInfo info) {
// These seemingly pointless accesses are done to make sure each

View file

@ -24,7 +24,7 @@ import org.spongepowered.asm.mixin.injection.Redirect;
import net.minecraft.world.ChunkSerializer;
@Mixin(ChunkSerializer.class)
public class MixinChunkSerializer {
public class ChunkSerializerMixin {
@Redirect(method = "readStructureReferences", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V"))
private static void log(Logger logger, String msg, Object identifier, Object chunkPos) {
// Drop to debug log level.

View file

@ -26,7 +26,7 @@ import net.minecraft.block.BlockState;
import net.minecraft.world.gen.chunk.DebugChunkGenerator;
@Mixin(DebugChunkGenerator.class)
public interface AccessorDebugChunkGenerator {
public interface DebugChunkGeneratorAccessor {
@Accessor
@Mutable
static void setBLOCK_STATES(List<BlockState> blockStates) {

View file

@ -28,7 +28,7 @@ import net.fabricmc.fabric.api.event.registry.DynamicRegistrySetupCallback;
import net.fabricmc.fabric.impl.registry.sync.DynamicRegistrySync;
@Mixin(DynamicRegistryManager.class)
public interface MixinDynamicRegistryManager {
public interface DynamicRegistryManagerMixin {
@Inject(method = "createAndLoad", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/dynamic/EntryLoader$Impl;<init>()V"), locals = LocalCapture.CAPTURE_FAILHARD)
private static void onCreateImpl(CallbackInfoReturnable<DynamicRegistryManager.Mutable> cir, DynamicRegistryManager.Mutable registryManager) {
DynamicRegistrySetupCallback.EVENT.invoker().onRegistrySetup(registryManager);

View file

@ -31,7 +31,7 @@ import net.minecraft.util.collection.IdList;
import net.fabricmc.fabric.impl.registry.sync.RemovableIdList;
@Mixin(IdList.class)
public class MixinIdList<T> implements RemovableIdList<T> {
public class IdListMixin<T> implements RemovableIdList<T> {
@Shadow
private int nextId;
@Shadow

View file

@ -49,7 +49,7 @@ import net.fabricmc.fabric.impl.registry.sync.RemapException;
import net.fabricmc.fabric.impl.registry.sync.RemappableRegistry;
@Mixin(LevelStorage.Session.class)
public class MixinLevelStorageSession {
public class LevelStorageSessionMixin {
@Unique
private static final int FABRIC_ID_REGISTRY_BACKUPS = 3;
@Unique

View file

@ -32,9 +32,9 @@ import net.fabricmc.fabric.impl.registry.sync.trackers.vanilla.BlockInitTracker;
import net.fabricmc.loader.api.FabricLoader;
@Mixin(MinecraftServer.class)
public class MixinMinecraftServer {
public class MinecraftServerMixin {
@Unique
private static Logger FABRIC_LOGGER = LoggerFactory.getLogger(MixinMinecraftServer.class);
private static Logger FABRIC_LOGGER = LoggerFactory.getLogger(MinecraftServerMixin.class);
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;setupServer()Z"), method = "runServer")
private void beforeSetupServer(CallbackInfo info) {

View file

@ -1,75 +0,0 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.fabricmc.fabric.mixin.registry.sync;
import java.util.Set;
import com.mojang.serialization.Lifecycle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.util.registry.SimpleRegistry;
import net.fabricmc.fabric.api.event.registry.RegistryAttribute;
import net.fabricmc.fabric.api.event.registry.RegistryAttributeHolder;
import net.fabricmc.fabric.impl.registry.sync.RegistrySyncManager;
@Mixin(SimpleRegistry.class)
public abstract class MixinSimpleRegistry<T> extends Registry<T> {
@Unique
private static final Logger FARBIC_LOGGER = LoggerFactory.getLogger("FabricRegistrySync");
// Namespaces used by the vanilla game. "brigadier" is used by command argument type registry.
// While Realms use "realms" namespace, it is irrelevant for Registry Sync.
@Unique
private static final Set<String> VANILLA_NAMESPACES = Set.of("minecraft", "brigadier");
protected MixinSimpleRegistry(RegistryKey<Registry<T>> arg, Lifecycle lifecycle) {
super(arg, lifecycle);
}
@Inject(method = "add", at = @At("RETURN"))
private <V extends T> void add(RegistryKey<Registry<T>> registryKey, V entry, Lifecycle lifecycle, CallbackInfoReturnable<V> info) {
onChange(registryKey);
}
@Inject(method = "set", at = @At("RETURN"))
private <V extends T> void set(int rawId, RegistryKey<Registry<T>> registryKey, V entry, Lifecycle lifecycle, CallbackInfoReturnable<V> info) {
onChange(registryKey);
}
@Unique
private void onChange(RegistryKey<Registry<T>> registryKey) {
if (RegistrySyncManager.postBootstrap || !VANILLA_NAMESPACES.contains(registryKey.getValue().getNamespace())) {
RegistryAttributeHolder holder = RegistryAttributeHolder.get(this);
if (!holder.hasAttribute(RegistryAttribute.MODDED)) {
Identifier id = getKey().getValue();
FARBIC_LOGGER.debug("Registry {} has been marked as modded, registry entry {} was changed", id, registryKey.getValue());
RegistryAttributeHolder.get(this).addAttribute(RegistryAttribute.MODDED);
}
}
}
}

View file

@ -26,7 +26,7 @@ import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.RegistryKey;
@Mixin(Registry.class)
public interface AccessorRegistry<T> {
public interface RegistryAccessor<T> {
@Accessor()
static MutableRegistry<MutableRegistry<?>> getROOT() {
throw new UnsupportedOperationException();

View file

@ -29,7 +29,7 @@ import net.fabricmc.fabric.api.event.registry.RegistryAttributeHolder;
import net.fabricmc.fabric.impl.registry.sync.FabricRegistry;
@Mixin(Registry.class)
public abstract class MixinRegistry<T> implements RegistryAttributeHolder, FabricRegistry {
public abstract class RegistryMixin<T> implements RegistryAttributeHolder, FabricRegistry {
@Unique
private final EnumSet<RegistryAttribute> attributes = EnumSet.noneOf(RegistryAttribute.class);

View file

@ -21,6 +21,7 @@ import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
@ -43,24 +44,32 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import net.minecraft.util.registry.RegistryEntry;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.RegistryEntry;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.util.registry.SimpleRegistry;
import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;
import net.fabricmc.fabric.api.event.registry.RegistryAttribute;
import net.fabricmc.fabric.api.event.registry.RegistryAttributeHolder;
import net.fabricmc.fabric.api.event.registry.RegistryEntryAddedCallback;
import net.fabricmc.fabric.api.event.registry.RegistryEntryRemovedCallback;
import net.fabricmc.fabric.api.event.registry.RegistryIdRemapCallback;
import net.fabricmc.fabric.impl.registry.sync.ListenableRegistry;
import net.fabricmc.fabric.impl.registry.sync.RegistrySyncManager;
import net.fabricmc.fabric.impl.registry.sync.RemapException;
import net.fabricmc.fabric.impl.registry.sync.RemapStateImpl;
import net.fabricmc.fabric.impl.registry.sync.RemappableRegistry;
@Mixin(SimpleRegistry.class)
public abstract class MixinIdRegistry<T> extends Registry<T> implements RemappableRegistry, ListenableRegistry<T> {
public abstract class SimpleRegistryMixin<T> extends Registry<T> implements RemappableRegistry, ListenableRegistry<T> {
// Namespaces used by the vanilla game. "brigadier" is used by command argument type registry.
// While Realms use "realms" namespace, it is irrelevant for Registry Sync.
@Unique
private static final Set<String> VANILLA_NAMESPACES = Set.of("minecraft", "brigadier");
@Shadow
@Final
private ObjectList<RegistryEntry.Reference<T>> rawIdToEntry;
@ -83,9 +92,9 @@ public abstract class MixinIdRegistry<T> extends Registry<T> implements Remappab
public abstract @Nullable T get(@Nullable Identifier id);
@Unique
private static Logger FABRIC_LOGGER = LoggerFactory.getLogger(MixinIdRegistry.class);
private static final Logger FABRIC_LOGGER = LoggerFactory.getLogger(SimpleRegistryMixin.class);
public MixinIdRegistry(RegistryKey<? extends Registry<T>> key, Lifecycle lifecycle) {
public SimpleRegistryMixin(RegistryKey<? extends Registry<T>> key, Lifecycle lifecycle) {
super(key, lifecycle);
}
@ -140,6 +149,29 @@ public abstract class MixinIdRegistry<T> extends Registry<T> implements Remappab
@Unique
private boolean fabric_isObjectNew = false;
@Inject(method = "add", at = @At("RETURN"))
private <V extends T> void add(RegistryKey<Registry<T>> registryKey, V entry, Lifecycle lifecycle, CallbackInfoReturnable<V> info) {
onChange(registryKey);
}
@Inject(method = "set", at = @At("RETURN"))
private <V extends T> void set(int rawId, RegistryKey<Registry<T>> registryKey, V entry, Lifecycle lifecycle, CallbackInfoReturnable<V> info) {
onChange(registryKey);
}
@Unique
private void onChange(RegistryKey<Registry<T>> registryKey) {
if (RegistrySyncManager.postBootstrap || !VANILLA_NAMESPACES.contains(registryKey.getValue().getNamespace())) {
RegistryAttributeHolder holder = RegistryAttributeHolder.get(this);
if (!holder.hasAttribute(RegistryAttribute.MODDED)) {
Identifier id = getKey().getValue();
FABRIC_LOGGER.debug("Registry {} has been marked as modded, registry entry {} was changed", id, registryKey.getValue());
RegistryAttributeHolder.get(this).addAttribute(RegistryAttribute.MODDED);
}
}
}
@Inject(method = "set(ILnet/minecraft/util/registry/RegistryKey;Ljava/lang/Object;Lcom/mojang/serialization/Lifecycle;Z)Lnet/minecraft/util/registry/RegistryEntry;", at = @At("HEAD"))
public void setPre(int id, RegistryKey<T> registryId, T object, Lifecycle lifecycle, boolean checkDuplicateKeys, CallbackInfoReturnable<T> info) {
int indexedEntriesId = entryToRawId.getInt(object);

View file

@ -30,7 +30,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import net.minecraft.datafixer.fix.StructuresToConfiguredStructuresFix;
@Mixin(StructuresToConfiguredStructuresFix.class)
public class MixinStructuresToConfiguredStructuresFix {
public class StructuresToConfiguredStructuresFixMixin {
private static final Logger LOGGER = LoggerFactory.getLogger("MixinStructuresToConfiguredStructuresFix");
/**

View file

@ -3,18 +3,18 @@
"package": "net.fabricmc.fabric.mixin.registry.sync",
"compatibilityLevel": "JAVA_16",
"mixins": [
"AccessorDebugChunkGenerator",
"AccessorRegistry",
"MixinBootstrap",
"MixinChunkSerializer",
"MixinDynamicRegistryManager",
"MixinIdList",
"MixinIdRegistry",
"MixinLevelStorageSession",
"MixinRegistry",
"MixinMinecraftServer",
"MixinSimpleRegistry",
"MixinStructuresToConfiguredStructuresFix"
"DebugChunkGeneratorAccessor",
"RegistryAccessor",
"BootstrapMixin",
"ChunkSerializerMixin",
"DynamicRegistryManagerMixin",
"IdListMixin",
"SimpleRegistryMixin",
"LevelStorageSessionMixin",
"RegistryMixin",
"MinecraftServerMixin",
"SimpleRegistryMixin",
"StructuresToConfiguredStructuresFixMixin"
],
"injectors": {
"defaultRequire": 1

View file

@ -34,7 +34,7 @@ import net.fabricmc.fabric.api.renderer.v1.render.RenderContext;
* Avoids instanceof checks and enables consistent code path for all baked models.
*/
@Mixin(BakedModel.class)
public interface MixinBakedModel extends FabricBakedModel {
public interface BakedModelMixin extends FabricBakedModel {
@Override
default boolean isVanillaAdapter() {
return true;

View file

@ -43,7 +43,7 @@ import net.fabricmc.fabric.api.renderer.v1.model.FabricBakedModel;
import net.fabricmc.fabric.api.renderer.v1.render.RenderContext;
@Mixin(MultipartBakedModel.class)
public class MixinMultipartBakedModel implements FabricBakedModel {
public class MultipartBakedModelMixin implements FabricBakedModel {
@Shadow
@Final
private List<Pair<Predicate<BlockState>, BakedModel>> components;

View file

@ -31,7 +31,7 @@ import net.minecraft.util.Identifier;
import net.fabricmc.fabric.impl.renderer.SpriteFinderImpl;
@Mixin(SpriteAtlasTexture.class)
public class MixinSpriteAtlasTexture implements SpriteFinderImpl.SpriteFinderAccess {
public class SpriteAtlasTextureMixin implements SpriteFinderImpl.SpriteFinderAccess {
@Shadow
private Map<Identifier, Sprite> sprites;

View file

@ -41,7 +41,7 @@ import net.fabricmc.fabric.api.renderer.v1.model.FabricBakedModel;
import net.fabricmc.fabric.api.renderer.v1.render.RenderContext;
@Mixin(WeightedBakedModel.class)
public class MixinWeightedBakedModel implements FabricBakedModel {
public class WeightedBakedModelMixin implements FabricBakedModel {
@Shadow
@Final
private int totalWeight;

View file

@ -28,7 +28,7 @@ import net.minecraft.client.gui.hud.DebugHud;
import net.fabricmc.fabric.api.renderer.v1.RendererAccess;
@Mixin(DebugHud.class)
public class MixinDebugHud {
public class DebugHudMixin {
@Inject(at = @At("RETURN"), method = "getLeftText")
protected void getLeftText(CallbackInfoReturnable<List<String>> info) {
if (RendererAccess.INSTANCE.hasRenderer()) {

View file

@ -3,7 +3,7 @@
"package": "net.fabricmc.fabric.mixin.renderer.client.debughud",
"compatibilityLevel": "JAVA_16",
"client": [
"MixinDebugHud"
"DebugHudMixin"
],
"injectors": {
"defaultRequire": 1

View file

@ -3,10 +3,10 @@
"package": "net.fabricmc.fabric.mixin.renderer",
"compatibilityLevel": "JAVA_16",
"client": [
"client.MixinBakedModel",
"client.MixinMultipartBakedModel",
"client.MixinWeightedBakedModel",
"client.MixinSpriteAtlasTexture"
"client.BakedModelMixin",
"client.MultipartBakedModelMixin",
"client.WeightedBakedModelMixin",
"client.SpriteAtlasTextureMixin"
],
"injectors": {
"defaultRequire": 1

View file

@ -36,7 +36,7 @@ import net.fabricmc.fabric.impl.client.indigo.renderer.aocalc.VanillaAoHelper;
import net.fabricmc.fabric.impl.client.indigo.renderer.render.BlockRenderContext;
@Mixin(BlockModelRenderer.class)
public abstract class MixinBlockModelRenderer {
public abstract class BlockModelRendererMixin {
@Unique
private final ThreadLocal<BlockRenderContext> fabric_contexts = ThreadLocal.withInitial(BlockRenderContext::new);

View file

@ -66,7 +66,7 @@ import net.fabricmc.fabric.impl.client.indigo.renderer.render.TerrainRenderConte
* (Though they can use these as an example if they wish.)
*/
@Mixin(BuiltChunk.RebuildTask.class)
public abstract class MixinChunkRebuildTask {
public abstract class ChunkBuilderBuiltChunkRebuildTaskMixin {
@Final
@Shadow
BuiltChunk field_20839;

View file

@ -25,7 +25,7 @@ import net.fabricmc.fabric.impl.client.indigo.renderer.accessor.AccessChunkRende
import net.fabricmc.fabric.impl.client.indigo.renderer.render.TerrainRenderContext;
@Mixin(ChunkRendererRegion.class)
public abstract class MixinChunkRendererRegion implements AccessChunkRendererRegion {
public abstract class ChunkRendererRegionMixin implements AccessChunkRendererRegion {
@Unique
private TerrainRenderContext fabric_renderer;

View file

@ -38,7 +38,7 @@ import net.fabricmc.fabric.impl.client.indigo.renderer.render.ItemRenderContext;
import net.fabricmc.fabric.impl.client.indigo.renderer.render.ItemRenderContext.VanillaQuadHandler;
@Mixin(ItemRenderer.class)
public abstract class MixinItemRenderer {
public abstract class ItemRendererMixin {
@Final
@Shadow
private ItemColors colors;

View file

@ -6,10 +6,10 @@
"mixins": [
],
"client": [
"MixinBlockModelRenderer",
"MixinChunkRebuildTask",
"MixinChunkRendererRegion",
"MixinItemRenderer"
"BlockModelRendererMixin",
"ChunkBuilderBuiltChunkRebuildTaskMixin",
"ChunkRendererRegionMixin",
"ItemRendererMixin"
],
"injectors": {
"defaultRequire": 1

Some files were not shown because too many files have changed in this diff Show more