mirror of
https://github.com/FabricMC/fabric.git
synced 2025-09-06 11:24:23 +00:00
24w06a porting fixes (#3578)
* Bump yarn * Fix TagsLoaded event again * Resource Loader: internal refactor (name to ID) * More refactors * Reset ignoreFallDamageAboveY when using custom elytra * fix checkstyle
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
package net.fabricmc.fabric.mixin.entity.event.elytra;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -40,6 +41,10 @@ abstract class PlayerEntityMixin extends LivingEntity {
|
||||
@Shadow
|
||||
public abstract void startFallFlying();
|
||||
|
||||
@Shadow
|
||||
@Nullable
|
||||
public Double ignoreFallDamageAboveY;
|
||||
|
||||
/**
|
||||
* Allow the server-side and client-side elytra checks to fail when {@link EntityElytraEvents#ALLOW} blocks flight,
|
||||
* and otherwise to succeed for elytra flight through {@link EntityElytraEvents#CUSTOM}.
|
||||
@@ -56,6 +61,7 @@ abstract class PlayerEntityMixin extends LivingEntity {
|
||||
|
||||
if (EntityElytraEvents.CUSTOM.invoker().useCustomElytra(self, false)) {
|
||||
startFallFlying();
|
||||
this.ignoreFallDamageAboveY = null;
|
||||
cir.setReturnValue(true);
|
||||
}
|
||||
}
|
||||
|
@@ -86,7 +86,7 @@ public abstract class MinecraftClientMixin {
|
||||
// I don't like that we clone vanilla logic here, but it's our best bet for now.
|
||||
PlayerInventory playerInventory = client.player.getInventory();
|
||||
|
||||
if (client.player.getAbilities().creativeMode && Screen.hasControlDown() && client.crosshairTarget.getType() == HitResult.Type.BLOCK) {
|
||||
if (client.player.isInCreativeMode() && Screen.hasControlDown() && client.crosshairTarget.getType() == HitResult.Type.BLOCK) {
|
||||
BlockEntity be = client.world.getBlockEntity(((BlockHitResult) client.crosshairTarget).getBlockPos());
|
||||
|
||||
if (be != null) {
|
||||
@@ -100,7 +100,7 @@ public abstract class MinecraftClientMixin {
|
||||
return;
|
||||
}
|
||||
|
||||
if (client.player.getAbilities().creativeMode) {
|
||||
if (client.player.isInCreativeMode()) {
|
||||
playerInventory.addPickBlock(stack);
|
||||
client.interactionManager.clickCreativeStack(client.player.getStackInHand(Hand.MAIN_HAND), 36 + playerInventory.selectedSlot);
|
||||
} else {
|
||||
|
@@ -32,7 +32,6 @@ import net.minecraft.world.chunk.WorldChunk;
|
||||
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientBlockEntityEvents;
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientEntityEvents;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.CommonLifecycleEvents;
|
||||
import net.fabricmc.fabric.impl.event.lifecycle.LoadedChunksCache;
|
||||
|
||||
@Mixin(ClientPlayNetworkHandler.class)
|
||||
@@ -94,14 +93,4 @@ abstract class ClientPlayNetworkHandlerMixin {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Also invoked during GameJoin, but before Networking API fires the Ready event.
|
||||
*/
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@Inject(method = "onSynchronizeTags", at = @At("RETURN"))
|
||||
private void hookOnSynchronizeTags(CallbackInfo ci) {
|
||||
ClientPlayNetworkHandler self = (ClientPlayNetworkHandler) (Object) this;
|
||||
CommonLifecycleEvents.TAGS_LOADED.invoker().onTagsLoaded(self.getRegistryManager(), true);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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.client;
|
||||
|
||||
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.client.network.ClientTagLoader;
|
||||
import net.minecraft.registry.DynamicRegistryManager;
|
||||
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.CommonLifecycleEvents;
|
||||
|
||||
@Mixin(ClientTagLoader.class)
|
||||
public class ClientTagLoaderMixin {
|
||||
@Inject(method = "load(Lnet/minecraft/registry/DynamicRegistryManager;Z)V", at = @At("TAIL"))
|
||||
private void invokeTagsLoaded(DynamicRegistryManager registryManager, boolean local, CallbackInfo ci) {
|
||||
CommonLifecycleEvents.TAGS_LOADED.invoker().onTagsLoaded(registryManager, true);
|
||||
}
|
||||
}
|
@@ -5,6 +5,7 @@
|
||||
"client": [
|
||||
"ClientChunkManagerMixin",
|
||||
"ClientPlayNetworkHandlerMixin",
|
||||
"ClientTagLoaderMixin",
|
||||
"ClientWorldClientEntityHandlerMixin",
|
||||
"ClientWorldMixin",
|
||||
"MinecraftClientMixin",
|
||||
|
@@ -24,9 +24,11 @@ import net.minecraft.world.World;
|
||||
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.CommonLifecycleEvents;
|
||||
import net.fabricmc.fabric.test.event.lifecycle.ServerLifecycleTests;
|
||||
|
||||
public final class ClientTickTests implements ClientModInitializer {
|
||||
private boolean tagsLoadedCalled;
|
||||
private final Map<RegistryKey<World>, Integer> tickTracker = new HashMap<>();
|
||||
private int ticks;
|
||||
|
||||
@@ -40,7 +42,15 @@ public final class ClientTickTests implements ClientModInitializer {
|
||||
}
|
||||
});
|
||||
|
||||
CommonLifecycleEvents.TAGS_LOADED.register((registries, client) -> {
|
||||
if (client) tagsLoadedCalled = true;
|
||||
});
|
||||
|
||||
ClientTickEvents.END_WORLD_TICK.register(world -> {
|
||||
if (!tagsLoadedCalled) {
|
||||
throw new IllegalStateException("TAGS_LOADED was not invoked during configuration!");
|
||||
}
|
||||
|
||||
final int worldTicks = this.tickTracker.computeIfAbsent(world.getRegistryKey(), k -> 0);
|
||||
|
||||
if (worldTicks % 200 == 0) { // Log every 200 ticks to verify the tick callback works on the client world
|
||||
|
@@ -57,7 +57,7 @@ public class ChatTest implements ModInitializer {
|
||||
|
||||
// Basic styling phase testing
|
||||
ServerMessageDecoratorEvent.EVENT.register(ServerMessageDecoratorEvent.STYLING_PHASE, (sender, message) -> {
|
||||
if (sender != null && sender.getAbilities().creativeMode) {
|
||||
if (sender != null && sender.isInCreativeMode()) {
|
||||
return message.copy().styled(style -> style.withColor(0xFFA500));
|
||||
}
|
||||
|
||||
|
@@ -20,13 +20,13 @@ import java.util.EnumSet;
|
||||
|
||||
import com.mojang.serialization.Lifecycle;
|
||||
|
||||
import net.minecraft.class_9248;
|
||||
import net.minecraft.registry.DefaultedRegistry;
|
||||
import net.minecraft.registry.MutableRegistry;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.SimpleDefaultedRegistry;
|
||||
import net.minecraft.registry.SimpleRegistry;
|
||||
import net.minecraft.registry.entry.RegistryEntryInfo;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import net.fabricmc.fabric.mixin.registry.sync.RegistriesAccessor;
|
||||
@@ -146,7 +146,7 @@ public final class FabricRegistryBuilder<T, R extends MutableRegistry<T>> {
|
||||
}
|
||||
|
||||
//noinspection unchecked
|
||||
RegistriesAccessor.getROOT().add((RegistryKey<MutableRegistry<?>>) key, registry, class_9248.field_49136);
|
||||
RegistriesAccessor.getROOT().add((RegistryKey<MutableRegistry<?>>) key, registry, RegistryEntryInfo.DEFAULT);
|
||||
|
||||
return registry;
|
||||
}
|
||||
|
@@ -46,12 +46,12 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import net.minecraft.class_9248;
|
||||
import net.minecraft.registry.MutableRegistry;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.SimpleRegistry;
|
||||
import net.minecraft.registry.entry.RegistryEntry;
|
||||
import net.minecraft.registry.entry.RegistryEntryInfo;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import net.fabricmc.fabric.api.event.Event;
|
||||
@@ -151,7 +151,7 @@ public abstract class SimpleRegistryMixin<T> implements MutableRegistry<T>, Rema
|
||||
}
|
||||
|
||||
@Inject(method = "add", at = @At("RETURN"))
|
||||
private void set(RegistryKey<T> key, T entry, class_9248 arg, CallbackInfoReturnable<RegistryEntry.Reference<T>> info) {
|
||||
private void set(RegistryKey<T> key, T entry, RegistryEntryInfo arg, CallbackInfoReturnable<RegistryEntry.Reference<T>> info) {
|
||||
// We need to restore the 1.19 behavior of binding the value to references immediately.
|
||||
// Unfrozen registries cannot be interacted with otherwise, because the references would throw when
|
||||
// trying to access their values.
|
||||
|
@@ -99,17 +99,17 @@ public class GameOptionsMixin {
|
||||
|
||||
for (ResourcePackProfile profile : profiles) {
|
||||
// Always add "Fabric Mods" pack to enabled resource packs.
|
||||
if (profile.getName().equals(ModResourcePackCreator.FABRIC)) {
|
||||
resourcePacks.add(profile.getName());
|
||||
if (profile.getId().equals(ModResourcePackCreator.FABRIC)) {
|
||||
resourcePacks.add(profile.getId());
|
||||
continue;
|
||||
}
|
||||
|
||||
try (ResourcePack pack = profile.createResourcePack()) {
|
||||
if (pack instanceof ModNioResourcePack builtinPack && builtinPack.getActivationType().isEnabledByDefault()) {
|
||||
if (trackedPacks.add(builtinPack.getName())) {
|
||||
resourcePacks.add(profile.getName());
|
||||
if (trackedPacks.add(builtinPack.getId())) {
|
||||
resourcePacks.add(profile.getId());
|
||||
} else {
|
||||
removedPacks.remove(builtinPack.getName());
|
||||
removedPacks.remove(builtinPack.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -42,10 +42,10 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import net.minecraft.class_9224;
|
||||
import net.minecraft.resource.AbstractFileResourcePack;
|
||||
import net.minecraft.resource.InputSupplier;
|
||||
import net.minecraft.resource.ResourcePack;
|
||||
import net.minecraft.resource.ResourcePackInfo;
|
||||
import net.minecraft.resource.ResourceType;
|
||||
import net.minecraft.resource.metadata.ResourceMetadataReader;
|
||||
import net.minecraft.text.Text;
|
||||
@@ -68,7 +68,7 @@ public class ModNioResourcePack implements ResourcePack, ModResourcePack {
|
||||
private final ResourceType type;
|
||||
private final ResourcePackActivationType activationType;
|
||||
private final Map<ResourceType, Set<String>> namespaces;
|
||||
private final class_9224 metadata;
|
||||
private final ResourcePackInfo metadata;
|
||||
/**
|
||||
* Whether the pack is bundled and loaded by default, as opposed to registered built-in packs.
|
||||
* @see ModResourcePackUtil#appendModResourcePacks(List, ResourceType, String)
|
||||
@@ -102,7 +102,7 @@ public class ModNioResourcePack implements ResourcePack, ModResourcePack {
|
||||
Text displayName = subPath == null
|
||||
? Text.translatable("pack.name.fabricMod", mod.getMetadata().getName())
|
||||
: Text.translatable("pack.name.fabricMod.subPack", mod.getMetadata().getName(), Text.translatable("resourcePack." + subPath + ".name"));
|
||||
class_9224 metadata = new class_9224(
|
||||
ResourcePackInfo metadata = new ResourcePackInfo(
|
||||
packId,
|
||||
displayName,
|
||||
ModResourcePackCreator.RESOURCE_PACK_SOURCE,
|
||||
@@ -113,7 +113,7 @@ public class ModNioResourcePack implements ResourcePack, ModResourcePack {
|
||||
return ret.getNamespaces(type).isEmpty() ? null : ret;
|
||||
}
|
||||
|
||||
private ModNioResourcePack(String id, ModContainer mod, List<Path> paths, ResourceType type, ResourcePackActivationType activationType, boolean modBundled, class_9224 metadata) {
|
||||
private ModNioResourcePack(String id, ModContainer mod, List<Path> paths, ResourceType type, ResourcePackActivationType activationType, boolean modBundled, ResourcePackInfo metadata) {
|
||||
this.id = id;
|
||||
this.mod = mod;
|
||||
this.basePaths = paths;
|
||||
@@ -285,7 +285,7 @@ public class ModNioResourcePack implements ResourcePack, ModResourcePack {
|
||||
}
|
||||
|
||||
@Override
|
||||
public class_9224 method_56926() {
|
||||
public ResourcePackInfo getInfo() {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
@@ -303,7 +303,7 @@ public class ModNioResourcePack implements ResourcePack, ModResourcePack {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
@@ -26,8 +26,8 @@ import java.util.function.Predicate;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.VisibleForTesting;
|
||||
|
||||
import net.minecraft.class_9224;
|
||||
import net.minecraft.class_9225;
|
||||
import net.minecraft.resource.ResourcePackInfo;
|
||||
import net.minecraft.resource.ResourcePackPosition;
|
||||
import net.minecraft.resource.ResourcePackProfile;
|
||||
import net.minecraft.resource.ResourcePackProvider;
|
||||
import net.minecraft.resource.ResourcePackSource;
|
||||
@@ -68,7 +68,7 @@ public class ModResourcePackCreator implements ResourcePackProvider {
|
||||
}
|
||||
};
|
||||
public static final ModResourcePackCreator CLIENT_RESOURCE_PACK_PROVIDER = new ModResourcePackCreator(ResourceType.CLIENT_RESOURCES);
|
||||
private static final class_9225 ACTIVATION_INFO = new class_9225(true, ResourcePackProfile.InsertionPosition.TOP, false);
|
||||
private static final ResourcePackPosition ACTIVATION_INFO = new ResourcePackPosition(true, ResourcePackProfile.InsertionPosition.TOP, false);
|
||||
|
||||
private final ResourceType type;
|
||||
|
||||
@@ -95,7 +95,7 @@ public class ModResourcePackCreator implements ResourcePackProvider {
|
||||
4. User resource packs
|
||||
*/
|
||||
|
||||
class_9224 metadata = new class_9224(
|
||||
ResourcePackInfo metadata = new ResourcePackInfo(
|
||||
FABRIC,
|
||||
Text.translatable("pack.name.fabricMods"),
|
||||
RESOURCE_PACK_SOURCE,
|
||||
@@ -128,7 +128,7 @@ public class ModResourcePackCreator implements ResourcePackProvider {
|
||||
|
||||
for (ModResourcePack pack : packs) {
|
||||
ResourcePackProfile profile = ResourcePackProfile.create(
|
||||
pack.method_56926(),
|
||||
pack.getInfo(),
|
||||
new ModResourcePackFactory(pack),
|
||||
this.type,
|
||||
ACTIVATION_INFO
|
||||
|
@@ -19,21 +19,21 @@ package net.fabricmc.fabric.impl.resource.loader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.class_9224;
|
||||
import net.minecraft.resource.OverlayResourcePack;
|
||||
import net.minecraft.resource.ResourcePack;
|
||||
import net.minecraft.resource.ResourcePackInfo;
|
||||
import net.minecraft.resource.ResourcePackProfile;
|
||||
|
||||
import net.fabricmc.fabric.api.resource.ModResourcePack;
|
||||
|
||||
public record ModResourcePackFactory(ModResourcePack pack) implements ResourcePackProfile.PackFactory {
|
||||
@Override
|
||||
public ResourcePack open(class_9224 var1) {
|
||||
public ResourcePack open(ResourcePackInfo var1) {
|
||||
return pack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourcePack openWithOverlays(class_9224 var1, ResourcePackProfile.Metadata metadata) {
|
||||
public ResourcePack openWithOverlays(ResourcePackInfo var1, ResourcePackProfile.Metadata metadata) {
|
||||
if (metadata.overlays().isEmpty()) {
|
||||
return pack;
|
||||
} else {
|
||||
|
@@ -87,27 +87,27 @@ public final class ModResourcePackUtil {
|
||||
}
|
||||
|
||||
public static void refreshAutoEnabledPacks(List<ResourcePackProfile> enabledProfiles, Map<String, ResourcePackProfile> allProfiles) {
|
||||
LOGGER.debug("[Fabric] Starting internal pack sorting with: {}", enabledProfiles.stream().map(ResourcePackProfile::getName).toList());
|
||||
LOGGER.debug("[Fabric] Starting internal pack sorting with: {}", enabledProfiles.stream().map(ResourcePackProfile::getId).toList());
|
||||
enabledProfiles.removeIf(profile -> ((FabricResourcePackProfile) profile).fabric_isHidden());
|
||||
LOGGER.debug("[Fabric] Removed all internal packs, result: {}", enabledProfiles.stream().map(ResourcePackProfile::getName).toList());
|
||||
LOGGER.debug("[Fabric] Removed all internal packs, result: {}", enabledProfiles.stream().map(ResourcePackProfile::getId).toList());
|
||||
ListIterator<ResourcePackProfile> it = enabledProfiles.listIterator();
|
||||
Set<String> seen = new LinkedHashSet<>();
|
||||
|
||||
while (it.hasNext()) {
|
||||
ResourcePackProfile profile = it.next();
|
||||
seen.add(profile.getName());
|
||||
seen.add(profile.getId());
|
||||
|
||||
for (ResourcePackProfile p : allProfiles.values()) {
|
||||
FabricResourcePackProfile fp = (FabricResourcePackProfile) p;
|
||||
|
||||
if (fp.fabric_isHidden() && fp.fabric_parentsEnabled(seen) && seen.add(p.getName())) {
|
||||
if (fp.fabric_isHidden() && fp.fabric_parentsEnabled(seen) && seen.add(p.getId())) {
|
||||
it.add(p);
|
||||
LOGGER.debug("[Fabric] cur @ {}, auto-enabled {}, currently enabled: {}", profile.getName(), p.getName(), seen);
|
||||
LOGGER.debug("[Fabric] cur @ {}, auto-enabled {}, currently enabled: {}", profile.getId(), p.getId(), seen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LOGGER.debug("[Fabric] Final sorting result: {}", enabledProfiles.stream().map(ResourcePackProfile::getName).toList());
|
||||
LOGGER.debug("[Fabric] Final sorting result: {}", enabledProfiles.stream().map(ResourcePackProfile::getId).toList());
|
||||
}
|
||||
|
||||
public static boolean containsDefault(String filename, boolean modBundled) {
|
||||
@@ -129,7 +129,7 @@ public final class ModResourcePackUtil {
|
||||
public static InputStream openDefault(ModContainer container, ResourceType type, String filename) throws IOException {
|
||||
switch (filename) {
|
||||
case "pack.mcmeta":
|
||||
String description = Objects.requireNonNullElse(container.getMetadata().getName(), "");
|
||||
String description = Objects.requireNonNullElse(container.getMetadata().getId(), "");
|
||||
String metadata = serializeMetadata(SharedConstants.getGameVersion().getResourceVersion(type), description);
|
||||
return IOUtils.toInputStream(metadata, Charsets.UTF_8);
|
||||
case "pack.png":
|
||||
@@ -162,8 +162,8 @@ public final class ModResourcePackUtil {
|
||||
}
|
||||
|
||||
public static Text getName(ModMetadata info) {
|
||||
if (info.getName() != null) {
|
||||
return Text.literal(info.getName());
|
||||
if (info.getId() != null) {
|
||||
return Text.literal(info.getId());
|
||||
} else {
|
||||
return Text.translatable("pack.name.fabricMod", info.getId());
|
||||
}
|
||||
@@ -186,15 +186,15 @@ public final class ModResourcePackUtil {
|
||||
// as the data pack screen automatically put any data pack as disabled except the Default data pack.
|
||||
for (ResourcePackProfile profile : moddedResourcePacks) {
|
||||
if (profile.getSource() == ModResourcePackCreator.RESOURCE_PACK_SOURCE) {
|
||||
enabled.add(profile.getName());
|
||||
enabled.add(profile.getId());
|
||||
continue;
|
||||
}
|
||||
|
||||
try (ResourcePack pack = profile.createResourcePack()) {
|
||||
if (pack instanceof ModNioResourcePack && ((ModNioResourcePack) pack).getActivationType().isEnabledByDefault()) {
|
||||
enabled.add(profile.getName());
|
||||
enabled.add(profile.getId());
|
||||
} else {
|
||||
disabled.add(profile.getName());
|
||||
disabled.add(profile.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -214,7 +214,7 @@ public final class ModResourcePackUtil {
|
||||
// Collect modded profiles
|
||||
Set<String> moddedProfiles = new HashSet<>();
|
||||
ModResourcePackCreator modResourcePackCreator = new ModResourcePackCreator(ResourceType.SERVER_DATA);
|
||||
modResourcePackCreator.register(profile -> moddedProfiles.add(profile.getName()));
|
||||
modResourcePackCreator.register(profile -> moddedProfiles.add(profile.getId()));
|
||||
|
||||
// Remove them from the enabled list
|
||||
List<String> moveToTheEnd = new ArrayList<>();
|
||||
|
@@ -25,9 +25,9 @@ import org.apache.commons.io.IOUtils;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.class_9224;
|
||||
import net.minecraft.resource.InputSupplier;
|
||||
import net.minecraft.resource.ResourcePack;
|
||||
import net.minecraft.resource.ResourcePackInfo;
|
||||
import net.minecraft.resource.ResourcePackProfile;
|
||||
import net.minecraft.resource.ResourceType;
|
||||
import net.minecraft.resource.metadata.PackResourceMetadata;
|
||||
@@ -36,7 +36,7 @@ import net.minecraft.resource.metadata.ResourceMetadataReader;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public record PlaceholderResourcePack(ResourceType type, class_9224 metadata) implements ResourcePack {
|
||||
public record PlaceholderResourcePack(ResourceType type, ResourcePackInfo metadata) implements ResourcePack {
|
||||
private static final Text DESCRIPTION_TEXT = Text.translatable("pack.description.modResources");
|
||||
|
||||
public PackResourceMetadata getMetadata() {
|
||||
@@ -89,12 +89,12 @@ public record PlaceholderResourcePack(ResourceType type, class_9224 metadata) im
|
||||
}
|
||||
|
||||
@Override
|
||||
public class_9224 method_56926() {
|
||||
public ResourcePackInfo getInfo() {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
public String getId() {
|
||||
return ModResourcePackCreator.FABRIC;
|
||||
}
|
||||
|
||||
@@ -102,14 +102,14 @@ public record PlaceholderResourcePack(ResourceType type, class_9224 metadata) im
|
||||
public void close() {
|
||||
}
|
||||
|
||||
public record Factory(ResourceType type, class_9224 metadata) implements ResourcePackProfile.PackFactory {
|
||||
public record Factory(ResourceType type, ResourcePackInfo metadata) implements ResourcePackProfile.PackFactory {
|
||||
@Override
|
||||
public ResourcePack open(class_9224 var1) {
|
||||
public ResourcePack open(ResourcePackInfo var1) {
|
||||
return new PlaceholderResourcePack(this.type, metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourcePack openWithOverlays(class_9224 var1, ResourcePackProfile.Metadata metadata) {
|
||||
public ResourcePack openWithOverlays(ResourcePackInfo var1, ResourcePackProfile.Metadata metadata) {
|
||||
return open(var1);
|
||||
}
|
||||
}
|
||||
|
@@ -33,9 +33,9 @@ import com.google.common.collect.Lists;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import net.minecraft.class_9224;
|
||||
import net.minecraft.class_9225;
|
||||
import net.minecraft.resource.ResourcePack;
|
||||
import net.minecraft.resource.ResourcePackInfo;
|
||||
import net.minecraft.resource.ResourcePackPosition;
|
||||
import net.minecraft.resource.ResourcePackProfile;
|
||||
import net.minecraft.resource.ResourceReloader;
|
||||
import net.minecraft.resource.ResourceType;
|
||||
@@ -115,26 +115,26 @@ public class ResourceManagerHelperImpl implements ResourceManagerHelper {
|
||||
// Add the built-in pack only if namespaces for the specified resource type are present.
|
||||
if (!pack.getNamespaces(resourceType).isEmpty()) {
|
||||
// Make the resource pack profile for built-in pack, should never be always enabled.
|
||||
class_9224 info = new class_9224(
|
||||
entry.getRight().getName(),
|
||||
ResourcePackInfo info = new ResourcePackInfo(
|
||||
entry.getRight().getId(),
|
||||
entry.getLeft(),
|
||||
new BuiltinModResourcePackSource(pack.getFabricModMetadata().getName()),
|
||||
Optional.empty()
|
||||
);
|
||||
class_9225 info2 = new class_9225(
|
||||
ResourcePackPosition info2 = new ResourcePackPosition(
|
||||
pack.getActivationType() == ResourcePackActivationType.ALWAYS_ENABLED,
|
||||
ResourcePackProfile.InsertionPosition.TOP,
|
||||
false // TODO check me
|
||||
false
|
||||
);
|
||||
|
||||
ResourcePackProfile profile = ResourcePackProfile.create(info, new ResourcePackProfile.PackFactory() {
|
||||
@Override
|
||||
public ResourcePack open(class_9224 var1) {
|
||||
public ResourcePack open(ResourcePackInfo var1) {
|
||||
return entry.getRight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourcePack openWithOverlays(class_9224 var1, ResourcePackProfile.Metadata metadata) {
|
||||
public ResourcePack openWithOverlays(ResourcePackInfo var1, ResourcePackProfile.Metadata metadata) {
|
||||
// Don't support overlays in builtin res packs.
|
||||
return entry.getRight();
|
||||
}
|
||||
|
@@ -51,9 +51,9 @@ public class DatapackCommandMixin {
|
||||
private static final DynamicCommandExceptionType INTERNAL_PACK_EXCEPTION = new DynamicCommandExceptionType(
|
||||
packName -> Text.stringifiedTranslatable("commands.datapack.fabric.internal", packName));
|
||||
|
||||
@Redirect(method = "method_13136", at = @At(value = "INVOKE", target = "Lnet/minecraft/resource/ResourcePackManager;getEnabledNames()Ljava/util/Collection;"))
|
||||
@Redirect(method = "method_13136", at = @At(value = "INVOKE", target = "Lnet/minecraft/resource/ResourcePackManager;getEnabledIds()Ljava/util/Collection;"))
|
||||
private static Collection<String> filterEnabledPackSuggestions(ResourcePackManager dataPackManager) {
|
||||
return dataPackManager.getEnabledProfiles().stream().filter(profile -> !((FabricResourcePackProfile) profile).fabric_isHidden()).map(ResourcePackProfile::getName).toList();
|
||||
return dataPackManager.getEnabledProfiles().stream().filter(profile -> !((FabricResourcePackProfile) profile).fabric_isHidden()).map(ResourcePackProfile::getId).toList();
|
||||
}
|
||||
|
||||
@WrapOperation(method = "method_13120", at = @At(value = "INVOKE", target = "Ljava/util/stream/Stream;filter(Ljava/util/function/Predicate;)Ljava/util/stream/Stream;", ordinal = 0))
|
||||
@@ -63,6 +63,6 @@ public class DatapackCommandMixin {
|
||||
|
||||
@Inject(method = "getPackContainer", at = @At(value = "INVOKE", target = "Ljava/util/Collection;contains(Ljava/lang/Object;)Z", shift = At.Shift.BEFORE))
|
||||
private static void errorOnInternalPack(CommandContext<ServerCommandSource> context, String name, boolean enable, CallbackInfoReturnable<ResourcePackProfile> cir, @Local ResourcePackProfile profile) throws CommandSyntaxException {
|
||||
if (((FabricResourcePackProfile) profile).fabric_isHidden()) throw INTERNAL_PACK_EXCEPTION.create(profile.getName());
|
||||
if (((FabricResourcePackProfile) profile).fabric_isHidden()) throw INTERNAL_PACK_EXCEPTION.create(profile.getId());
|
||||
}
|
||||
}
|
||||
|
@@ -34,14 +34,14 @@ import net.fabricmc.fabric.impl.resource.loader.ModNioResourcePack;
|
||||
public class MinecraftServerMixin {
|
||||
@Redirect(method = "loadDataPacks", at = @At(value = "INVOKE", target = "Ljava/util/List;contains(Ljava/lang/Object;)Z"))
|
||||
private static boolean onCheckDisabled(List<String> list, Object o, ResourcePackManager resourcePackManager) {
|
||||
String profileName = (String) o;
|
||||
boolean contains = list.contains(profileName);
|
||||
String profileId = (String) o;
|
||||
boolean contains = list.contains(profileId);
|
||||
|
||||
if (contains) {
|
||||
return true;
|
||||
}
|
||||
|
||||
ResourcePackProfile profile = resourcePackManager.getProfile(profileName);
|
||||
ResourcePackProfile profile = resourcePackManager.getProfile(profileId);
|
||||
|
||||
if (profile.getSource() instanceof BuiltinModResourcePackSource) {
|
||||
try (ResourcePack pack = profile.createResourcePack()) {
|
||||
|
@@ -98,9 +98,9 @@ public abstract class ResourcePackManagerMixin {
|
||||
@Inject(method = "disable", at = @At(value = "INVOKE", target = "Ljava/util/List;remove(Ljava/lang/Object;)Z"))
|
||||
private void handleAutoDisable(String profile, CallbackInfoReturnable<Boolean> cir, @Local List<ResourcePackProfile> enabled) {
|
||||
if (ModResourcePackCreator.POST_CHANGE_HANDLE_REQUIRED.contains(profile)) {
|
||||
Set<String> currentlyEnabled = enabled.stream().map(ResourcePackProfile::getName).collect(Collectors.toSet());
|
||||
Set<String> currentlyEnabled = enabled.stream().map(ResourcePackProfile::getId).collect(Collectors.toSet());
|
||||
enabled.removeIf(p -> !((FabricResourcePackProfile) p).fabric_parentsEnabled(currentlyEnabled));
|
||||
LOGGER.debug("[Fabric] Internal pack auto-removed upon disabling {}, result: {}", profile, enabled.stream().map(ResourcePackProfile::getName).toList());
|
||||
LOGGER.debug("[Fabric] Internal pack auto-removed upon disabling {}, result: {}", profile, enabled.stream().map(ResourcePackProfile::getId).toList());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -26,8 +26,8 @@ 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.class_9224;
|
||||
import net.minecraft.resource.ResourcePack;
|
||||
import net.minecraft.resource.ResourcePackInfo;
|
||||
import net.minecraft.resource.ResourcePackProfile;
|
||||
import net.minecraft.resource.ResourcePackSource;
|
||||
|
||||
@@ -49,11 +49,11 @@ abstract class ResourcePackProfileMixin implements FabricResourcePackProfile {
|
||||
private Predicate<Set<String>> parentsPredicate = DEFAULT_PARENT_PREDICATE;
|
||||
|
||||
@Shadow
|
||||
public abstract class_9224 method_56933();
|
||||
public abstract ResourcePackInfo getInfo();
|
||||
|
||||
@Inject(method = "createResourcePack", at = @At("RETURN"))
|
||||
private void onCreateResourcePack(CallbackInfoReturnable<ResourcePack> info) {
|
||||
ResourcePackSourceTracker.setSource(info.getReturnValue(), method_56933().source());
|
||||
ResourcePackSourceTracker.setSource(info.getReturnValue(), getInfo().source());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -36,8 +36,8 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import net.minecraft.Bootstrap;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.class_9224;
|
||||
import net.minecraft.class_9225;
|
||||
import net.minecraft.resource.ResourcePackInfo;
|
||||
import net.minecraft.resource.ResourcePackPosition;
|
||||
import net.minecraft.resource.ResourcePackProfile;
|
||||
|
||||
import net.fabricmc.fabric.impl.resource.loader.FabricResourcePackProfile;
|
||||
@@ -207,7 +207,7 @@ public class ModResourcePackUtilTests {
|
||||
|
||||
private ResourcePackProfile mockProfile(Map<String, ResourcePackProfile> profiles, String id, @Nullable Predicate<Set<String>> parents) {
|
||||
ResourcePackProfile profile = new ResourcePackProfile(
|
||||
new class_9224(
|
||||
new ResourcePackInfo(
|
||||
id,
|
||||
null,
|
||||
null,
|
||||
@@ -215,7 +215,7 @@ public class ModResourcePackUtilTests {
|
||||
),
|
||||
null,
|
||||
null,
|
||||
new class_9225(
|
||||
new ResourcePackPosition(
|
||||
false,
|
||||
null,
|
||||
false)
|
||||
@@ -231,9 +231,9 @@ public class ModResourcePackUtilTests {
|
||||
List<ResourcePackProfile> processed = new ArrayList<>(before);
|
||||
ModResourcePackUtil.refreshAutoEnabledPacks(processed, profiles);
|
||||
assertEquals(
|
||||
after.stream().map(ResourcePackProfile::getName).toList(),
|
||||
processed.stream().map(ResourcePackProfile::getName).toList(),
|
||||
() -> "Testing %s; input %s".formatted(reason, before.stream().map(ResourcePackProfile::getName).toList())
|
||||
after.stream().map(ResourcePackProfile::getId).toList(),
|
||||
processed.stream().map(ResourcePackProfile::getId).toList(),
|
||||
() -> "Testing %s; input %s".formatted(reason, before.stream().map(ResourcePackProfile::getId).toList())
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -93,7 +93,7 @@ public interface ContainerItemContext {
|
||||
* This matches the behavior of {@link ItemUsage#exchangeStack}.
|
||||
*/
|
||||
static ContainerItemContext forPlayerInteraction(PlayerEntity player, Hand hand) {
|
||||
if (player.getAbilities().creativeMode) {
|
||||
if (player.isInCreativeMode()) {
|
||||
return forCreativeInteraction(player, player.getStackInHand(hand));
|
||||
} else {
|
||||
return ofPlayerHand(player, hand);
|
||||
|
@@ -4,7 +4,7 @@ fabric.loom.multiProjectOptimisation=true
|
||||
|
||||
version=0.95.6
|
||||
minecraft_version=24w06a
|
||||
yarn_version=+build.1
|
||||
yarn_version=+build.6
|
||||
loader_version=0.15.6
|
||||
installer_version=0.11.1
|
||||
|
||||
|
Reference in New Issue
Block a user