mirror of
https://github.com/FabricMC/fabric.git
synced 2025-04-05 19:47:00 -04:00
rearrange mixins, document more client stuff
This commit is contained in:
parent
0594469b69
commit
435f1e6433
24 changed files with 110 additions and 54 deletions
src/main
java/net/fabricmc/fabric
block
client
render
texture
events/client
mixin
block
client
render
texture
events
objectbuilder
playerinteraction
MixinClientPlayerInteractionManager.javaMixinServerPlayNetworkHandler.javaMixinServerPlayerEntity.javaMixinServerPlayerInteractionManager.java
server
tick
tools
resources
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.helpers;
|
||||
package net.fabricmc.fabric.block;
|
||||
|
||||
import net.fabricmc.fabric.tools.ToolManager;
|
||||
import net.minecraft.block.Block;
|
|
@ -23,6 +23,9 @@ import net.minecraft.client.render.block.entity.BlockEntityRenderer;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Helper class for registering BlockEntityRenderers.
|
||||
*/
|
||||
public class BlockEntityRendererRegistry {
|
||||
public static final BlockEntityRendererRegistry INSTANCE = new BlockEntityRendererRegistry();
|
||||
private Map<Class<? extends BlockEntity>, BlockEntityRenderer<? extends BlockEntity>> renderers;
|
||||
|
|
|
@ -27,6 +27,9 @@ import java.util.Map;
|
|||
import java.util.WeakHashMap;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Helper class for registering EntityRenderers.
|
||||
*/
|
||||
public class EntityRendererRegistry {
|
||||
@FunctionalInterface
|
||||
public interface Factory {
|
||||
|
|
|
@ -24,8 +24,11 @@ import java.util.Set;
|
|||
* Implement this interface on a Sprite to declare additional dependencies
|
||||
* that should be processed prior to this sprite.
|
||||
*
|
||||
* TODO: Implement this!
|
||||
* Best used in conjunction with {@link CustomSpriteLoader}.
|
||||
*/
|
||||
public interface DependentSprite {
|
||||
/**
|
||||
* @return A set of all sprites that should be loaded before this sprite.
|
||||
*/
|
||||
Set<Identifier> getDependencies();
|
||||
}
|
||||
|
|
|
@ -22,6 +22,9 @@ import net.minecraft.util.Identifier;
|
|||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* Helper class for registering Sprites during loading.
|
||||
*/
|
||||
public class SpriteRegistry {
|
||||
private final Map<Identifier, Sprite> spriteMap;
|
||||
private final Consumer<Identifier> defaultSpriteRegister;
|
||||
|
@ -31,10 +34,20 @@ public class SpriteRegistry {
|
|||
this.defaultSpriteRegister = defaultSpriteRegister;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a sprite to be loaded using the default implementation.
|
||||
*
|
||||
* @param id The sprite identifier.
|
||||
*/
|
||||
public void register(Identifier id) {
|
||||
this.defaultSpriteRegister.accept(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a custom sprite to be added and loaded.
|
||||
*
|
||||
* @param sprite The sprite to be added.
|
||||
*/
|
||||
public void register(Sprite sprite) {
|
||||
this.spriteMap.put(sprite.getId(), sprite);
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.client.texture;
|
||||
package net.fabricmc.fabric.client.texture.impl;
|
||||
|
||||
import net.minecraft.class_1050;
|
||||
import net.minecraft.client.resource.metadata.AnimationResourceMetadata;
|
|
@ -14,17 +14,17 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.client.texture;
|
||||
package net.fabricmc.fabric.events.client;
|
||||
|
||||
import net.fabricmc.fabric.client.texture.SpriteRegistry;
|
||||
import net.fabricmc.fabric.util.HandlerList;
|
||||
import net.fabricmc.fabric.util.HandlerRegistry;
|
||||
|
||||
/**
|
||||
* Use this interface to register providers for your own custom atlas sprites.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface SpriteProvider {
|
||||
final HandlerRegistry<SpriteProvider> HANDLER = new HandlerList<>();
|
||||
public class SpriteEvent {
|
||||
@FunctionalInterface
|
||||
public interface Provider {
|
||||
void registerSprites(SpriteRegistry registry);
|
||||
}
|
||||
|
||||
void registerSprites(SpriteRegistry registry);
|
||||
public static final HandlerRegistry<Provider> PROVIDE = new HandlerList<>();
|
||||
}
|
|
@ -14,9 +14,9 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.mixin.helpers;
|
||||
package net.fabricmc.fabric.mixin.block;
|
||||
|
||||
import net.fabricmc.fabric.helpers.FabricBlockBuilder;
|
||||
import net.fabricmc.fabric.block.FabricBlockBuilder;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.block.MaterialColor;
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.mixin.render;
|
||||
package net.fabricmc.fabric.mixin.client.render;
|
||||
|
||||
import net.fabricmc.fabric.client.render.BlockEntityRendererRegistry;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.mixin.render;
|
||||
package net.fabricmc.fabric.mixin.client.render;
|
||||
|
||||
import net.fabricmc.fabric.client.render.EntityRendererRegistry;
|
||||
import net.minecraft.client.render.entity.EntityRenderDispatcher;
|
|
@ -14,12 +14,12 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.mixin.render;
|
||||
package net.fabricmc.fabric.mixin.client.texture;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import net.fabricmc.fabric.client.texture.*;
|
||||
import net.fabricmc.fabric.client.texture.impl.FabricSprite;
|
||||
import net.fabricmc.fabric.events.client.SpriteEvent;
|
||||
import net.fabricmc.fabric.util.HandlerList;
|
||||
import net.minecraft.class_1050;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
|
@ -31,8 +31,6 @@ import net.minecraft.util.Identifier;
|
|||
import net.minecraft.util.crash.CrashException;
|
||||
import net.minecraft.util.crash.CrashReport;
|
||||
import net.minecraft.util.crash.CrashReportElement;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
@ -87,8 +85,8 @@ public abstract class MixinSpriteAtlasTexture {
|
|||
//noinspection RedundantCast,ConstantConditions
|
||||
if ((SpriteAtlasTexture) (Object) this == MinecraftClient.getInstance().getSpriteAtlas()) {
|
||||
SpriteRegistry registry = new SpriteRegistry(sprites, (id) -> addSpriteToLoad(manager, id));
|
||||
for (Object provider : ((HandlerList<SpriteProvider>) SpriteProvider.HANDLER).getBackingArray()) {
|
||||
((SpriteProvider) provider).registerSprites(registry);
|
||||
for (Object provider : ((HandlerList<SpriteEvent.Provider>) SpriteEvent.PROVIDE).getBackingArray()) {
|
||||
((SpriteEvent.Provider) provider).registerSprites(registry);
|
||||
}
|
||||
}
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.mixin.helpers;
|
||||
package net.fabricmc.fabric.mixin.events.objectbuilder;
|
||||
|
||||
import net.fabricmc.fabric.events.ObjectBuilderEvent;
|
||||
import net.fabricmc.fabric.util.HandlerList;
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.mixin.helpers;
|
||||
package net.fabricmc.fabric.mixin.events.objectbuilder;
|
||||
|
||||
import net.fabricmc.fabric.events.ObjectBuilderEvent;
|
||||
import net.fabricmc.fabric.util.HandlerList;
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.mixin.events;
|
||||
package net.fabricmc.fabric.mixin.events.playerinteraction;
|
||||
|
||||
import net.fabricmc.fabric.events.PlayerInteractionEvent;
|
||||
import net.fabricmc.fabric.util.HandlerList;
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.mixin.events;
|
||||
package net.fabricmc.fabric.mixin.events.playerinteraction;
|
||||
|
||||
import net.fabricmc.fabric.events.PlayerInteractionEvent;
|
||||
import net.fabricmc.fabric.util.HandlerList;
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.mixin.events;
|
||||
package net.fabricmc.fabric.mixin.events.playerinteraction;
|
||||
|
||||
import net.fabricmc.fabric.events.PlayerInteractionEvent;
|
||||
import net.fabricmc.fabric.util.HandlerList;
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.mixin.events;
|
||||
package net.fabricmc.fabric.mixin.events.playerinteraction;
|
||||
|
||||
import net.fabricmc.fabric.events.PlayerInteractionEvent;
|
||||
import net.fabricmc.fabric.util.HandlerList;
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.mixin.events;
|
||||
package net.fabricmc.fabric.mixin.events.server;
|
||||
|
||||
import net.fabricmc.fabric.events.ServerEvent;
|
||||
import net.fabricmc.fabric.events.TickEvent;
|
||||
|
@ -32,9 +32,6 @@ import java.util.function.Consumer;
|
|||
|
||||
@Mixin(MinecraftServer.class)
|
||||
public class MixinMinecraftServer {
|
||||
@Shadow
|
||||
private class_3689 profiler;
|
||||
|
||||
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;method_3791(Lnet/minecraft/server/ServerMetadata;)V", ordinal = 0), method = "run")
|
||||
public void afterSetupServer(CallbackInfo info) {
|
||||
for (Object handler : ((HandlerList<Consumer<MinecraftServer>>) ServerEvent.START).getBackingArray()) {
|
||||
|
@ -42,9 +39,4 @@ public class MixinMinecraftServer {
|
|||
((Consumer) handler).accept((Object) this);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(at = @At("RETURN"), method = "method_3813")
|
||||
protected void method_3813(BooleanSupplier var1, CallbackInfo info) {
|
||||
TickEvent.tick(TickEvent.SERVER, (MinecraftServer) (Object) this, this.profiler);
|
||||
}
|
||||
}
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.mixin.events;
|
||||
package net.fabricmc.fabric.mixin.events.tick;
|
||||
|
||||
import net.fabricmc.fabric.events.TickEvent;
|
||||
import net.fabricmc.fabric.events.client.ClientTickEvent;
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright (c) 2016, 2017, 2018 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.events.tick;
|
||||
|
||||
import net.fabricmc.fabric.events.ServerEvent;
|
||||
import net.fabricmc.fabric.events.TickEvent;
|
||||
import net.fabricmc.fabric.util.HandlerList;
|
||||
import net.minecraft.class_3689;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
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.CallbackInfo;
|
||||
|
||||
import java.util.function.BooleanSupplier;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@Mixin(MinecraftServer.class)
|
||||
public class MixinMinecraftServer {
|
||||
@Shadow
|
||||
private class_3689 profiler;
|
||||
|
||||
@Inject(at = @At("RETURN"), method = "method_3813")
|
||||
protected void method_3813(BooleanSupplier var1, CallbackInfo info) {
|
||||
TickEvent.tick(TickEvent.SERVER, (MinecraftServer) (Object) this, this.profiler);
|
||||
}
|
||||
}
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.mixin.events;
|
||||
package net.fabricmc.fabric.mixin.events.tick;
|
||||
|
||||
import net.fabricmc.fabric.events.PlayerInteractionEvent;
|
||||
import net.fabricmc.fabric.events.TickEvent;
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
package net.fabricmc.fabric.tools;
|
||||
|
||||
import net.fabricmc.fabric.block.FabricBlockBuilder;
|
||||
import net.fabricmc.fabric.events.ObjectBuilderEvent;
|
||||
import net.fabricmc.fabric.util.TriState;
|
||||
import net.minecraft.block.Block;
|
||||
|
@ -93,7 +94,7 @@ public final class ToolManager {
|
|||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link net.fabricmc.fabric.helpers.FabricBlockBuilder FabricBlockBuilder} for your own blocks.
|
||||
* @deprecated Use {@link FabricBlockBuilder FabricBlockBuilder} for your own blocks.
|
||||
* TODO: Add a way to manipulate the values for non-owned blocks.
|
||||
*/
|
||||
@Deprecated
|
||||
|
@ -102,7 +103,7 @@ public final class ToolManager {
|
|||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link net.fabricmc.fabric.helpers.FabricBlockBuilder FabricBlockBuilder} for your own blocks.
|
||||
* @deprecated Use {@link FabricBlockBuilder FabricBlockBuilder} for your own blocks.
|
||||
* TODO: Add a way to manipulate the values for non-owned blocks.
|
||||
*/
|
||||
@Deprecated
|
||||
|
|
|
@ -4,15 +4,15 @@
|
|||
"compatibilityLevel": "JAVA_8",
|
||||
"mixins": [
|
||||
"block.entity.MixinClientPlayNetworkHandler",
|
||||
"events.MixinClientPlayerInteractionManager",
|
||||
"events.MixinMinecraftClient",
|
||||
"client.render.MixinBlockEntityRenderManager",
|
||||
"client.render.MixinEntityRenderManager",
|
||||
"client.texture.MixinSpriteAtlasTexture",
|
||||
"events.playerinteraction.MixinClientPlayerInteractionManager",
|
||||
"events.tick.MixinMinecraftClient",
|
||||
"networking.MixinClientPlayNetworkHandler",
|
||||
"registry.client.MixinBlockColorMap",
|
||||
"registry.client.MixinItemColorMap",
|
||||
"registry.client.MixinItemModelMap",
|
||||
"render.MixinBlockEntityRenderManager",
|
||||
"render.MixinEntityRenderManager",
|
||||
"render.MixinSpriteAtlasTexture",
|
||||
"resources.MixinMinecraftGame"
|
||||
],
|
||||
"injectors": {
|
||||
|
|
|
@ -3,16 +3,17 @@
|
|||
"package": "net.fabricmc.fabric.mixin",
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"mixins": [
|
||||
"block.MixinBlockBuilder",
|
||||
"block.entity.MixinBlockEntity",
|
||||
"commands.MixinServerCommandManager",
|
||||
"events.MixinMinecraftServer",
|
||||
"events.MixinServerPlayNetworkHandler",
|
||||
"events.MixinServerPlayerEntity",
|
||||
"events.MixinServerPlayerInteractionManager",
|
||||
"events.MixinWorld",
|
||||
"helpers.MixinBlock",
|
||||
"helpers.MixinBlockBuilder",
|
||||
"helpers.MixinItem",
|
||||
"events.objectbuilder.MixinBlock",
|
||||
"events.objectbuilder.MixinItem",
|
||||
"events.playerinteraction.MixinServerPlayNetworkHandler",
|
||||
"events.playerinteraction.MixinServerPlayerEntity",
|
||||
"events.playerinteraction.MixinServerPlayerInteractionManager",
|
||||
"events.server.MixinMinecraftServer",
|
||||
"events.tick.MixinMinecraftServer",
|
||||
"events.tick.MixinWorld",
|
||||
"networking.MixinServerPlayNetworkHandler",
|
||||
"networking.MixinSPacketCustomPayload",
|
||||
"registry.MixinBootstrap",
|
||||
|
|
Loading…
Add table
Reference in a new issue