mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2024-11-21 11:46:49 +01:00
More workaround code for registry validation
This commit is contained in:
parent
f8cfb25ae3
commit
b7975b6544
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
||||
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and RK_01/RaphiMC
|
||||
* Copyright (C) 2023-2024 contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.network;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator;
|
||||
import net.minecraft.registry.entry.RegistryEntry;
|
||||
import net.minecraft.registry.entry.RegistryEntryList;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(RegistryEntryList.Named.class)
|
||||
public abstract class MixinRegistryEntryList_Named {
|
||||
|
||||
@Shadow
|
||||
private @Nullable List<RegistryEntry> entries;
|
||||
|
||||
@Shadow
|
||||
abstract void setEntries(List<RegistryEntry> entries);
|
||||
|
||||
@Inject(method = "getEntries", at = @At("HEAD"))
|
||||
public void preventNullableEntries(CallbackInfoReturnable<List<RegistryEntry<?>>> cir) {
|
||||
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_21)) {
|
||||
// Previoulsy didn't had unbounded entries
|
||||
if (this.entries == null) {
|
||||
this.setEntries(List.of());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "isBound", at = @At("HEAD"), cancellable = true)
|
||||
public void alwaysBound(CallbackInfoReturnable<Boolean> cir) {
|
||||
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_21)) {
|
||||
// Previously didn't exist
|
||||
cir.setReturnValue(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -155,6 +155,7 @@
|
||||
"fixes.minecraft.network.MixinNetworkStateTransitionHandler",
|
||||
"fixes.minecraft.network.MixinNetworkStateTransitions",
|
||||
"fixes.minecraft.network.MixinPlayerListEntry",
|
||||
"fixes.minecraft.network.MixinRegistryEntryListCodec",
|
||||
"fixes.minecraft.network.MixinUpdatePlayerAbilitiesC2SPacket",
|
||||
"fixes.minecraft.screen.MixinAbstractCommandBlockScreen",
|
||||
"fixes.minecraft.screen.MixinAbstractSignEditScreen",
|
||||
@ -215,7 +216,7 @@
|
||||
"viabedrock.MixinJoinPackets",
|
||||
"vialegacy.MixinExtensionProtocolMetadataStorage",
|
||||
"vialegacy.MixinViaLegacyConfig",
|
||||
"fixes.minecraft.network.MixinRegistryEntryListCodec"
|
||||
"fixes.minecraft.network.MixinRegistryEntryList_Named"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
Loading…
Reference in New Issue
Block a user