mirror of
https://github.com/FabricMC/fabric.git
synced 2024-11-14 19:25:23 -05:00
22w46a
This commit is contained in:
parent
49abcf7e64
commit
fbde993d15
18 changed files with 27 additions and 244 deletions
|
@ -147,13 +147,13 @@ abstract class LivingEntityMixin {
|
|||
}
|
||||
|
||||
@Dynamic("method_18404: Synthetic lambda body for Optional.ifPresent in wakeUp")
|
||||
@Redirect(method = "method_18404", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BedBlock;findWakeUpPosition(Lnet/minecraft/entity/EntityType;Lnet/minecraft/world/CollisionView;Lnet/minecraft/util/math/BlockPos;F)Ljava/util/Optional;"))
|
||||
private Optional<Vec3d> modifyWakeUpPosition(EntityType<?> type, CollisionView world, BlockPos pos, float yaw) {
|
||||
@Redirect(method = "method_18404", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BedBlock;findWakeUpPosition(Lnet/minecraft/entity/EntityType;Lnet/minecraft/world/CollisionView;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/Direction;F)Ljava/util/Optional;"))
|
||||
private Optional<Vec3d> modifyWakeUpPosition(EntityType<?> type, CollisionView world, BlockPos pos, Direction direction, float yaw) {
|
||||
Optional<Vec3d> original = Optional.empty();
|
||||
BlockState bedState = world.getBlockState(pos);
|
||||
|
||||
if (bedState.getBlock() instanceof BedBlock) {
|
||||
original = BedBlock.findWakeUpPosition(type, world, pos, yaw);
|
||||
original = BedBlock.findWakeUpPosition(type, world, pos, direction, yaw);
|
||||
}
|
||||
|
||||
Vec3d newPos = EntitySleepEvents.MODIFY_WAKE_UP_POSITION.invoker().modifyWakeUpPosition((LivingEntity) (Object) this, pos, bedState, original.orElse(null));
|
||||
|
|
|
@ -16,8 +16,10 @@
|
|||
|
||||
package net.fabricmc.fabric.mixin.itemgroup;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
@ -30,7 +32,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemGroups;
|
||||
import net.minecraft.item.ItemStackSet;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.resource.featuretoggle.FeatureSet;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
|
@ -44,11 +46,11 @@ import net.fabricmc.fabric.impl.itemgroup.MinecraftItemGroups;
|
|||
|
||||
@Mixin(ItemGroup.class)
|
||||
abstract class ItemGroupMixin implements IdentifiableItemGroup, FabricItemGroup {
|
||||
@Shadow(aliases = "field_40859")
|
||||
private ItemStackSet displayStacks;
|
||||
@Shadow
|
||||
private Collection<ItemStack> displayStacks;
|
||||
|
||||
@Shadow(aliases = "field_40860")
|
||||
private ItemStackSet searchTabStacks;
|
||||
@Shadow
|
||||
private Set<ItemStack> searchTabStacks;
|
||||
|
||||
@Unique
|
||||
private int fabric_page = -1;
|
||||
|
|
|
@ -24,10 +24,10 @@ import net.minecraft.item.ItemGroup;
|
|||
import net.minecraft.item.ItemGroups;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup;
|
||||
|
@ -44,6 +44,7 @@ public class ItemGroupTest implements ModInitializer {
|
|||
.entries((enabledFeatures, entries, operatorEnabled) -> {
|
||||
entries.addAll(Registries.ITEM.stream()
|
||||
.map(ItemStack::new)
|
||||
.filter(input -> !input.isEmpty())
|
||||
.toList());
|
||||
})
|
||||
.build();
|
||||
|
@ -80,7 +81,11 @@ public class ItemGroupTest implements ModInitializer {
|
|||
.displayName(Text.literal("Test Item Group: " + i))
|
||||
.icon((Supplier<ItemStack>) () -> new ItemStack(Registries.BLOCK.get(index)))
|
||||
.entries((enabledFeatures, entries, operatorEnabled) -> {
|
||||
entries.add(new ItemStack(Registries.ITEM.get(index)));
|
||||
var itemStack = new ItemStack(Registries.ITEM.get(index));
|
||||
|
||||
if (!itemStack.isEmpty()) {
|
||||
entries.add(itemStack);
|
||||
}
|
||||
})
|
||||
.build();
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ abstract class ClientPlayNetworkHandlerMixin {
|
|||
}
|
||||
|
||||
// Called when the client disconnects from a server.
|
||||
@Inject(method = "clearWorld", at = @At("HEAD"))
|
||||
@Inject(method = "method_47658", at = @At("HEAD"))
|
||||
private void onClearWorld(CallbackInfo ci) {
|
||||
// If a world already exists, we need to unload all (block)entities in the world.
|
||||
if (this.world != null) {
|
||||
|
|
|
@ -6,8 +6,7 @@ loom {
|
|||
}
|
||||
|
||||
moduleDependencies(project, [
|
||||
'fabric-api-base',
|
||||
'fabric-textures-v0'
|
||||
'fabric-api-base'
|
||||
])
|
||||
|
||||
validateMixinNames {
|
||||
|
|
|
@ -2,10 +2,5 @@ archivesBaseName = "fabric-rendering-fluids-v1"
|
|||
version = getSubprojectVersion(project)
|
||||
|
||||
moduleDependencies(project, [
|
||||
'fabric-api-base',
|
||||
'fabric-textures-v0'
|
||||
])
|
||||
|
||||
testDependencies(project, [
|
||||
':fabric-textures-v0'
|
||||
'fabric-api-base'
|
||||
])
|
||||
|
|
|
@ -17,14 +17,11 @@
|
|||
package net.fabricmc.fabric.test.client.rendering.fluid;
|
||||
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.client.texture.SpriteLoader;
|
||||
import net.minecraft.screen.PlayerScreenHandler;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandlerRegistry;
|
||||
import net.fabricmc.fabric.api.client.render.fluid.v1.SimpleFluidRenderHandler;
|
||||
import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback;
|
||||
|
||||
public class FabricFluidRenderingTestModClient implements ClientModInitializer {
|
||||
@Override
|
||||
|
@ -59,12 +56,5 @@ public class FabricFluidRenderingTestModClient implements ClientModInitializer {
|
|||
FluidRenderHandlerRegistry.INSTANCE.register(TestFluids.CUSTOM, TestFluids.CUSTOM_FLOWING, new CustomizedFluidRenderer(
|
||||
new Identifier("fabric-rendering-fluids-v1-testmod:block/test_fluid_overlay")
|
||||
));
|
||||
|
||||
// TODO: this looks useless - vanilla should load every sprite in the block folder already; double check
|
||||
ClientSpriteRegistryCallback.event(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE).register((resourceManager, sprites) -> {
|
||||
SpriteLoader.addResource(resourceManager, new Identifier("fabric-rendering-fluids-v1-testmod:block/test_fluid_still"), sprites::put);
|
||||
SpriteLoader.addResource(resourceManager, new Identifier("fabric-rendering-fluids-v1-testmod:block/test_fluid_flowing"), sprites::put);
|
||||
SpriteLoader.addResource(resourceManager, new Identifier("fabric-rendering-fluids-v1-testmod:block/test_fluid_overlay"), sprites::put);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ import net.fabricmc.fabric.api.client.screen.v1.ScreenKeyboardEvents;
|
|||
abstract class KeyboardMixin {
|
||||
// private synthetic method_1454(ILnet/minecraft/client/gui/screen/Screen;[ZIII)V
|
||||
@Inject(method = "method_1454(ILnet/minecraft/client/gui/screen/Screen;[ZIII)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;keyPressed(III)Z"), cancellable = true)
|
||||
private void beforeKeyPressedEvent(int code, Screen screen, boolean[] resultHack, int key, int scancode, int modifiers, CallbackInfo ci) {
|
||||
private static void beforeKeyPressedEvent(int code, Screen screen, boolean[] resultHack, int key, int scancode, int modifiers, CallbackInfo ci) {
|
||||
if (!ScreenKeyboardEvents.allowKeyPress(screen).invoker().allowKeyPress(screen, key, scancode, modifiers)) {
|
||||
resultHack[0] = true; // Set this press action as handled.
|
||||
ci.cancel(); // Exit the lambda
|
||||
|
@ -42,13 +42,13 @@ abstract class KeyboardMixin {
|
|||
|
||||
// private synthetic method_1454(ILnet/minecraft/client/gui/screen/Screen;[ZIII)V
|
||||
@Inject(method = "method_1454(ILnet/minecraft/client/gui/screen/Screen;[ZIII)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;keyPressed(III)Z", shift = At.Shift.AFTER))
|
||||
private void afterKeyPressedEvent(int code, Screen screen, boolean[] resultHack, int key, int scancode, int modifiers, CallbackInfo ci) {
|
||||
private static void afterKeyPressedEvent(int code, Screen screen, boolean[] resultHack, int key, int scancode, int modifiers, CallbackInfo ci) {
|
||||
ScreenKeyboardEvents.afterKeyPress(screen).invoker().afterKeyPress(screen, key, scancode, modifiers);
|
||||
}
|
||||
|
||||
// private synthetic method_1454(ILnet/minecraft/client/gui/screen/Screen;[ZIII)V
|
||||
@Inject(method = "method_1454(ILnet/minecraft/client/gui/screen/Screen;[ZIII)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;keyReleased(III)Z"), cancellable = true)
|
||||
private void beforeKeyReleasedEvent(int code, Screen screen, boolean[] resultHack, int key, int scancode, int modifiers, CallbackInfo ci) {
|
||||
private static void beforeKeyReleasedEvent(int code, Screen screen, boolean[] resultHack, int key, int scancode, int modifiers, CallbackInfo ci) {
|
||||
if (!ScreenKeyboardEvents.allowKeyRelease(screen).invoker().allowKeyRelease(screen, key, scancode, modifiers)) {
|
||||
resultHack[0] = true; // Set this press action as handled.
|
||||
ci.cancel(); // Exit the lambda
|
||||
|
@ -60,7 +60,7 @@ abstract class KeyboardMixin {
|
|||
|
||||
// private synthetic method_1454(ILnet/minecraft/client/gui/screen/Screen;[ZIII)V
|
||||
@Inject(method = "method_1454(ILnet/minecraft/client/gui/screen/Screen;[ZIII)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;keyReleased(III)Z", shift = At.Shift.AFTER))
|
||||
private void afterKeyReleasedEvent(int code, Screen screen, boolean[] resultHack, int key, int scancode, int modifiers, CallbackInfo ci) {
|
||||
private static void afterKeyReleasedEvent(int code, Screen screen, boolean[] resultHack, int key, int scancode, int modifiers, CallbackInfo ci) {
|
||||
ScreenKeyboardEvents.afterKeyRelease(screen).invoker().afterKeyRelease(screen, key, scancode, modifiers);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
archivesBaseName = "fabric-textures-v0"
|
||||
version = getSubprojectVersion(project)
|
||||
|
||||
moduleDependencies(project, [
|
||||
'fabric-api-base'
|
||||
])
|
|
@ -1,52 +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.api.event.client;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
import net.minecraft.client.texture.SpriteLoader;
|
||||
import net.minecraft.resource.Resource;
|
||||
import net.minecraft.resource.ResourceManager;
|
||||
import net.minecraft.screen.PlayerScreenHandler;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import net.fabricmc.fabric.api.event.Event;
|
||||
import net.fabricmc.fabric.impl.client.texture.SpriteRegistryCallbackHolder;
|
||||
|
||||
public interface ClientSpriteRegistryCallback {
|
||||
/**
|
||||
* Add sprites to the map of sprites that will be baked into the sprite atlas.
|
||||
*
|
||||
* @see SpriteLoader#addResources(ResourceManager, String, BiConsumer) For adding textures from a folder recursively.
|
||||
* @see SpriteLoader#addResource(ResourceManager, Identifier, BiConsumer) For adding a single texture.
|
||||
*/
|
||||
void registerSprites(ResourceManager resourceManager, Map<Identifier, Resource> sprites);
|
||||
|
||||
/**
|
||||
* Get an event instance for a given atlas path.
|
||||
*
|
||||
* @param atlasId The atlas texture ID you want to register to.
|
||||
* @return The event for a given atlas path.
|
||||
* @since 0.1.1
|
||||
*
|
||||
* @see PlayerScreenHandler#BLOCK_ATLAS_TEXTURE
|
||||
*/
|
||||
static Event<ClientSpriteRegistryCallback> event(Identifier atlasId) {
|
||||
return SpriteRegistryCallbackHolder.eventLocal(atlasId);
|
||||
}
|
||||
}
|
|
@ -1,46 +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.impl.client.texture;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import net.fabricmc.fabric.api.event.Event;
|
||||
import net.fabricmc.fabric.api.event.EventFactory;
|
||||
import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback;
|
||||
|
||||
public final class SpriteRegistryCallbackHolder {
|
||||
private static final Map<Identifier, Event<ClientSpriteRegistryCallback>> eventMap = new ConcurrentHashMap<>();
|
||||
|
||||
private SpriteRegistryCallbackHolder() { }
|
||||
|
||||
public static Event<ClientSpriteRegistryCallback> eventLocal(Identifier key) {
|
||||
return eventMap.computeIfAbsent(key, (a) -> createEvent());
|
||||
}
|
||||
|
||||
private static Event<ClientSpriteRegistryCallback> createEvent() {
|
||||
return EventFactory.createArrayBacked(ClientSpriteRegistryCallback.class,
|
||||
(listeners) -> (atlasTexture, registry) -> {
|
||||
for (ClientSpriteRegistryCallback callback : listeners) {
|
||||
callback.registerSprites(atlasTexture, registry);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,61 +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.texture;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||
|
||||
import net.minecraft.client.render.model.SpriteAtlasManager;
|
||||
import net.minecraft.resource.Resource;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import net.fabricmc.fabric.impl.client.texture.SpriteRegistryCallbackHolder;
|
||||
|
||||
/**
|
||||
* Mix in to where texture atlases discover the files they should bake.
|
||||
*/
|
||||
@Mixin(SpriteAtlasManager.class)
|
||||
public class SpriteAtlasManagerMixin {
|
||||
@ModifyVariable(method = "<init>", at = @At("HEAD"))
|
||||
private static Map<Identifier, SpriteAtlasManager.SpriteResourceLoader> initAtlases(Map<Identifier, SpriteAtlasManager.SpriteResourceLoader> atlases) {
|
||||
// Make modifiable
|
||||
atlases = new HashMap<>(atlases);
|
||||
|
||||
for (Map.Entry<Identifier, SpriteAtlasManager.SpriteResourceLoader> entry : atlases.entrySet()) {
|
||||
SpriteAtlasManager.SpriteResourceLoader resourceFinder = entry.getValue();
|
||||
|
||||
entry.setValue(resourceManager -> {
|
||||
// First run vanilla logic
|
||||
Map<Identifier, Resource> resources = resourceFinder.apply(resourceManager);
|
||||
|
||||
// Then invoke event
|
||||
SpriteRegistryCallbackHolder
|
||||
.eventLocal(entry.getKey())
|
||||
.invoker()
|
||||
.registerSprites(resourceManager, resources);
|
||||
|
||||
return resources;
|
||||
});
|
||||
}
|
||||
|
||||
return atlases;
|
||||
}
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 1.5 KiB |
|
@ -1,11 +0,0 @@
|
|||
{
|
||||
"required": true,
|
||||
"package": "net.fabricmc.fabric.mixin.client.texture",
|
||||
"compatibilityLevel": "JAVA_16",
|
||||
"client": [
|
||||
"SpriteAtlasManagerMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "fabric-textures-v0",
|
||||
"name": "Fabric Textures (v0)",
|
||||
"version": "${version}",
|
||||
"environment": "client",
|
||||
"license": "Apache-2.0",
|
||||
"icon": "assets/fabric-textures-v0/icon.png",
|
||||
"contact": {
|
||||
"homepage": "https://fabricmc.net",
|
||||
"irc": "irc://irc.esper.net:6667/fabric",
|
||||
"issues": "https://github.com/FabricMC/fabric/issues",
|
||||
"sources": "https://github.com/FabricMC/fabric"
|
||||
},
|
||||
"authors": [
|
||||
"FabricMC"
|
||||
],
|
||||
"depends": {
|
||||
"fabricloader": ">=0.4.0",
|
||||
"fabric-api-base": "*"
|
||||
},
|
||||
"description": "Hooks for texture loading and registration.",
|
||||
"mixins": [
|
||||
"fabric-textures-v0.mixins.json"
|
||||
],
|
||||
"custom": {
|
||||
"fabric-api:module-lifecycle": "stable"
|
||||
}
|
||||
}
|
|
@ -6,7 +6,6 @@ moduleDependencies(project, [
|
|||
'fabric-api-lookup-api-v1',
|
||||
'fabric-lifecycle-events-v1', // transitive dependency of API Lookup
|
||||
'fabric-rendering-fluids-v1',
|
||||
'fabric-textures-v0' // transitive dependency of Rendering Fluids
|
||||
])
|
||||
|
||||
testDependencies(project, [
|
||||
|
|
|
@ -2,8 +2,8 @@ org.gradle.jvmargs=-Xmx2560M
|
|||
org.gradle.parallel=true
|
||||
|
||||
version=0.66.2
|
||||
minecraft_version=22w45a
|
||||
yarn_version=+build.18
|
||||
minecraft_version=22w46a
|
||||
yarn_version=+build.1
|
||||
loader_version=0.14.10
|
||||
|
||||
prerelease=true
|
||||
|
@ -54,7 +54,6 @@ fabric-resource-loader-v0-version=0.9.3
|
|||
fabric-screen-api-v1-version=1.0.31
|
||||
fabric-screen-handler-api-v1-version=1.3.5
|
||||
fabric-sound-api-v1-version=1.0.4
|
||||
fabric-textures-v0-version=2.0.3
|
||||
fabric-transfer-api-v1-version=2.1.5
|
||||
fabric-transitive-access-wideners-v1-version=2.0.2
|
||||
fabric-convention-tags-v1-version=1.1.6
|
||||
|
|
|
@ -49,7 +49,6 @@ include 'fabric-resource-loader-v0'
|
|||
include 'fabric-screen-api-v1'
|
||||
include 'fabric-screen-handler-api-v1'
|
||||
include 'fabric-sound-api-v1'
|
||||
include 'fabric-textures-v0'
|
||||
include 'fabric-transfer-api-v1'
|
||||
include 'fabric-convention-tags-v1'
|
||||
include 'fabric-client-tags-api-v1'
|
||||
|
|
Loading…
Reference in a new issue