Some minor 1.19 migrations

This commit is contained in:
Frank 2022-05-10 19:08:05 +02:00
parent 50f623477f
commit 4ba3a71a68
14 changed files with 60 additions and 55 deletions

View file

@ -2,11 +2,15 @@ package ru.bclib.mixin.common;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.MultiPackResourceManager;
import net.minecraft.server.packs.resources.Resource;
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 java.util.Optional;
@Mixin(MultiPackResourceManager.class)
public class MultiPackResourceManagerMixin {
private static final String[] BCLIB_MISSING_RESOURCES = new String[] {
@ -16,12 +20,13 @@ public class MultiPackResourceManagerMixin {
"dimension_type/the_nether.json"
};
@Inject(method = "hasResource", at = @At("HEAD"), cancellable = true)
private void bclib_hasResource(ResourceLocation resourceLocation, CallbackInfoReturnable<Boolean> info) {
@Inject(method = "getResource", at = @At("HEAD"), cancellable = true)
private void bclib_hasResource(ResourceLocation resourceLocation, CallbackInfoReturnable<Optional<Resource>> info) {
if (resourceLocation.getNamespace().equals("minecraft")) {
for (String key: BCLIB_MISSING_RESOURCES) {
if (resourceLocation.getPath().equals(key)) {
info.setReturnValue(false);
info.setReturnValue(Optional.empty());
info.cancel();
return;
}
}