diff --git a/neoforge/src/accessors/java/org/spongepowered/neoforge/accessor/neoforge/registries/RegistrySnapshotAccessor_Neo.java b/neoforge/src/accessors/java/org/spongepowered/neoforge/accessor/neoforge/registries/RegistrySnapshotAccessor_Neo.java new file mode 100644 index 00000000000..a3c22d65967 --- /dev/null +++ b/neoforge/src/accessors/java/org/spongepowered/neoforge/accessor/neoforge/registries/RegistrySnapshotAccessor_Neo.java @@ -0,0 +1,38 @@ +/* + * This file is part of Sponge, licensed under the MIT License (MIT). + * + * Copyright (c) SpongePowered + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.spongepowered.neoforge.accessor.neoforge.registries; + +import it.unimi.dsi.fastutil.ints.Int2ObjectSortedMap; +import net.minecraft.resources.ResourceLocation; +import net.neoforged.neoforge.registries.RegistrySnapshot; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(RegistrySnapshot.class) +public interface RegistrySnapshotAccessor_Neo { + + @Accessor("ids") + Int2ObjectSortedMap accessor$ids(); +} diff --git a/neoforge/src/accessors/resources/mixins.spongeneo.accessors.json b/neoforge/src/accessors/resources/mixins.spongeneo.accessors.json index 6ba9a7e6f0c..92a1833be67 100644 --- a/neoforge/src/accessors/resources/mixins.spongeneo.accessors.json +++ b/neoforge/src/accessors/resources/mixins.spongeneo.accessors.json @@ -3,5 +3,6 @@ "parent": "mixins.sponge.parent.json", "package": "org.spongepowered.neoforge.accessor", "mixins": [ + "neoforge.registries.RegistrySnapshotAccessor_Neo" ] } \ No newline at end of file diff --git a/neoforge/src/mixins/java/org/spongepowered/neoforge/mixin/core/neoforge/registries/RegistryManagerMixin_Neo.java b/neoforge/src/mixins/java/org/spongepowered/neoforge/mixin/core/neoforge/registries/RegistryManagerMixin_Neo.java new file mode 100644 index 00000000000..43896153bfb --- /dev/null +++ b/neoforge/src/mixins/java/org/spongepowered/neoforge/mixin/core/neoforge/registries/RegistryManagerMixin_Neo.java @@ -0,0 +1,52 @@ +/* + * This file is part of Sponge, licensed under the MIT License (MIT). + * + * Copyright (c) SpongePowered + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.spongepowered.neoforge.mixin.core.neoforge.registries; + +import net.minecraft.resources.ResourceLocation; +import net.neoforged.neoforge.registries.RegistryManager; +import net.neoforged.neoforge.registries.RegistrySnapshot; +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.CallbackInfoReturnable; +import org.spongepowered.neoforge.accessor.neoforge.registries.RegistrySnapshotAccessor_Neo; + +import java.util.Map; + +@SuppressWarnings("UnstableApiUsage") +@Mixin(RegistryManager.class) +public class RegistryManagerMixin_Neo { + + @Inject(method = "takeSnapshot", at = @At("RETURN")) + private static void forge$dontSendSpongeDataToClient(RegistryManager.SnapshotType snapshotType, CallbackInfoReturnable> cir) { + if (snapshotType != RegistryManager.SnapshotType.SYNC_TO_CLIENT) { + return; + } + + for (RegistrySnapshot snapshot : cir.getReturnValue().values()) { + ((RegistrySnapshotAccessor_Neo) snapshot).accessor$ids().values().removeIf(loc -> loc.getNamespace().equals("sponge")); + } + } +} diff --git a/neoforge/src/mixins/resources/mixins.spongeneo.core.json b/neoforge/src/mixins/resources/mixins.spongeneo.core.json index 28648e71bb6..366ac2ce67a 100644 --- a/neoforge/src/mixins/resources/mixins.spongeneo.core.json +++ b/neoforge/src/mixins/resources/mixins.spongeneo.core.json @@ -17,6 +17,7 @@ "neoforge.event.world.BlockEvent_BreakEventMixin_Neo", "neoforge.event.world.BlockEventMixin_Neo", "neoforge.internal.BrandingControlMixin_Neo", + "neoforge.registries.RegistryManagerMixin_Neo", "network.ConnectionMixin_Neo", "server.BootstrapMixin_Neo", "server.MinecraftServerMixin_Neo",