mirror of
https://github.com/architectury/architectury-api.git
synced 2026-03-28 03:56:59 -05:00
@@ -36,7 +36,7 @@ import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraftforge.client.IFluidTypeRenderProperties;
|
||||
import net.minecraftforge.client.extensions.common.IClientFluidTypeExtensions;
|
||||
import net.minecraftforge.common.SoundAction;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidType;
|
||||
@@ -75,10 +75,10 @@ class ArchitecturyFluidAttributesForge extends FluidType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializeClient(Consumer<IFluidTypeRenderProperties> consumer) {
|
||||
consumer.accept(new IFluidTypeRenderProperties() {
|
||||
public void initializeClient(Consumer<IClientFluidTypeExtensions> consumer) {
|
||||
consumer.accept(new IClientFluidTypeExtensions() {
|
||||
@Override
|
||||
public int getColorTint() {
|
||||
public int getTintColor() {
|
||||
return attributes.getColor();
|
||||
}
|
||||
|
||||
@@ -115,12 +115,12 @@ class ArchitecturyFluidAttributesForge extends FluidType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColorTint(FluidState state, BlockAndTintGetter getter, BlockPos pos) {
|
||||
public int getTintColor(FluidState state, BlockAndTintGetter getter, BlockPos pos) {
|
||||
return attributes.getColor(state, getter, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColorTint(FluidStack stack) {
|
||||
public int getTintColor(FluidStack stack) {
|
||||
return attributes.getColor(convertSafe(stack));
|
||||
}
|
||||
|
||||
|
||||
@@ -59,40 +59,39 @@ public class EventHandlerImplClient {
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public static void eventRenderGameOverlayEvent(RenderGameOverlayEvent.Post event) {
|
||||
if (event.getType() == RenderGameOverlayEvent.ElementType.ALL)
|
||||
ClientGuiEvent.RENDER_HUD.invoker().renderHud(event.getPoseStack(), event.getPartialTick());
|
||||
public static void eventRenderGameOverlayEvent(RenderGuiEvent.Post event) {
|
||||
ClientGuiEvent.RENDER_HUD.invoker().renderHud(event.getPoseStack(), event.getPartialTick());
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public static void event(ClientPlayerNetworkEvent.LoggedInEvent event) {
|
||||
public static void event(ClientPlayerNetworkEvent.LoggingIn event) {
|
||||
ClientPlayerEvent.CLIENT_PLAYER_JOIN.invoker().join(event.getPlayer());
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public static void event(ClientPlayerNetworkEvent.LoggedOutEvent event) {
|
||||
public static void event(ClientPlayerNetworkEvent.LoggingOut event) {
|
||||
ClientPlayerEvent.CLIENT_PLAYER_QUIT.invoker().quit(event.getPlayer());
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public static void event(ClientPlayerNetworkEvent.RespawnEvent event) {
|
||||
public static void event(ClientPlayerNetworkEvent.Clone event) {
|
||||
ClientPlayerEvent.CLIENT_PLAYER_RESPAWN.invoker().respawn(event.getOldPlayer(), event.getNewPlayer());
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public static void eventInitScreenEvent(ScreenEvent.InitScreenEvent.Pre event) {
|
||||
public static void eventInitScreenEvent(ScreenEvent.Init.Pre event) {
|
||||
if (ClientGuiEvent.INIT_PRE.invoker().init(event.getScreen(), new ScreenAccessImpl(event.getScreen())).isFalse()) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public static void eventInitScreenEvent(ScreenEvent.InitScreenEvent.Post event) {
|
||||
public static void eventInitScreenEvent(ScreenEvent.Init.Post event) {
|
||||
ClientGuiEvent.INIT_POST.invoker().init(event.getScreen(), new ScreenAccessImpl(event.getScreen()));
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public static void eventRenderGameOverlayEvent(RenderGameOverlayEvent.Text event) {
|
||||
public static void eventRenderGameOverlayEvent(CustomizeGuiOverlayEvent.DebugText event) {
|
||||
if (Minecraft.getInstance().options.renderDebug) {
|
||||
ClientGuiEvent.DEBUG_TEXT_LEFT.invoker().gatherText(event.getLeft());
|
||||
ClientGuiEvent.DEBUG_TEXT_RIGHT.invoker().gatherText(event.getRight());
|
||||
@@ -136,35 +135,35 @@ public class EventHandlerImplClient {
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public static void event(ScreenOpenEvent event) {
|
||||
public static void event(ScreenEvent.Opening event) {
|
||||
CompoundEventResult<Screen> result = ClientGuiEvent.SET_SCREEN.invoker().modifyScreen(event.getScreen());
|
||||
if (result.isPresent()) {
|
||||
if (result.isFalse())
|
||||
event.setCanceled(true);
|
||||
else if (result.object() != null)
|
||||
event.setScreen(result.object());
|
||||
event.setNewScreen(result.object());
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public static void eventDrawScreenEvent(ScreenEvent.DrawScreenEvent.Pre event) {
|
||||
public static void eventDrawScreenEvent(ScreenEvent.Render.Pre event) {
|
||||
if (ClientGuiEvent.RENDER_PRE.invoker().render(event.getScreen(), event.getPoseStack(), event.getMouseX(), event.getMouseY(), event.getPartialTick()).isFalse()) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public static void eventDrawScreenEvent(ScreenEvent.DrawScreenEvent.Post event) {
|
||||
public static void eventDrawScreenEvent(ScreenEvent.Render.Post event) {
|
||||
ClientGuiEvent.RENDER_POST.invoker().render(event.getScreen(), event.getPoseStack(), event.getMouseX(), event.getMouseY(), event.getPartialTick());
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public static void eventContainerScreenEvent(ContainerScreenEvent.DrawBackground event) {
|
||||
public static void eventContainerScreenEvent(ContainerScreenEvent.Render.Background event) {
|
||||
ClientGuiEvent.RENDER_CONTAINER_BACKGROUND.invoker().render(event.getContainerScreen(), event.getPoseStack(), event.getMouseX(), event.getMouseY(), Minecraft.getInstance().getDeltaFrameTime());
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public static void eventContainerScreenEvent(ContainerScreenEvent.DrawForeground event) {
|
||||
public static void eventContainerScreenEvent(ContainerScreenEvent.Render.Foreground event) {
|
||||
ClientGuiEvent.RENDER_CONTAINER_FOREGROUND.invoker().render(event.getContainerScreen(), event.getPoseStack(), event.getMouseX(), event.getMouseY(), Minecraft.getInstance().getDeltaFrameTime());
|
||||
}
|
||||
|
||||
@@ -228,110 +227,110 @@ public class EventHandlerImplClient {
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public static void eventMouseScrollEvent(ScreenEvent.MouseScrollEvent.Pre event) {
|
||||
public static void eventMouseScrollEvent(ScreenEvent.MouseScrolled.Pre event) {
|
||||
if (ClientScreenInputEvent.MOUSE_SCROLLED_PRE.invoker().mouseScrolled(Minecraft.getInstance(), event.getScreen(), event.getMouseX(), event.getMouseY(), event.getScrollDelta()).isFalse()) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public static void eventMouseScrollEvent(ScreenEvent.MouseScrollEvent.Post event) {
|
||||
public static void eventMouseScrollEvent(ScreenEvent.MouseScrolled.Post event) {
|
||||
ClientScreenInputEvent.MOUSE_SCROLLED_POST.invoker().mouseScrolled(Minecraft.getInstance(), event.getScreen(), event.getMouseX(), event.getMouseY(), event.getScrollDelta());
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public static void eventMouseClickedEvent(ScreenEvent.MouseClickedEvent.Pre event) {
|
||||
public static void eventMouseClickedEvent(ScreenEvent.MouseButtonPressed.Pre event) {
|
||||
if (ClientScreenInputEvent.MOUSE_CLICKED_PRE.invoker().mouseClicked(Minecraft.getInstance(), event.getScreen(), event.getMouseX(), event.getMouseY(), event.getButton()).isFalse()) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public static void eventMouseClickedEvent(ScreenEvent.MouseClickedEvent.Post event) {
|
||||
public static void eventMouseClickedEvent(ScreenEvent.MouseButtonPressed.Post event) {
|
||||
ClientScreenInputEvent.MOUSE_CLICKED_POST.invoker().mouseClicked(Minecraft.getInstance(), event.getScreen(), event.getMouseX(), event.getMouseY(), event.getButton());
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public static void eventMouseDragEvent(ScreenEvent.MouseDragEvent.Pre event) {
|
||||
public static void eventMouseDragEvent(ScreenEvent.MouseDragged.Pre event) {
|
||||
if (ClientScreenInputEvent.MOUSE_DRAGGED_PRE.invoker().mouseDragged(Minecraft.getInstance(), event.getScreen(), event.getMouseX(), event.getMouseY(), event.getMouseButton(), event.getDragX(), event.getDragY()).isFalse()) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public static void eventMouseDragEvent(ScreenEvent.MouseDragEvent.Post event) {
|
||||
public static void eventMouseDragEvent(ScreenEvent.MouseDragged.Post event) {
|
||||
ClientScreenInputEvent.MOUSE_DRAGGED_POST.invoker().mouseDragged(Minecraft.getInstance(), event.getScreen(), event.getMouseX(), event.getMouseY(), event.getMouseButton(), event.getDragX(), event.getDragY());
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public static void eventMouseReleasedEvent(ScreenEvent.MouseReleasedEvent.Pre event) {
|
||||
public static void eventMouseReleasedEvent(ScreenEvent.MouseButtonReleased.Pre event) {
|
||||
if (ClientScreenInputEvent.MOUSE_RELEASED_PRE.invoker().mouseReleased(Minecraft.getInstance(), event.getScreen(), event.getMouseX(), event.getMouseY(), event.getButton()).isFalse()) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public static void eventMouseReleasedEvent(ScreenEvent.MouseReleasedEvent.Post event) {
|
||||
public static void eventMouseReleasedEvent(ScreenEvent.MouseButtonReleased.Post event) {
|
||||
ClientScreenInputEvent.MOUSE_RELEASED_PRE.invoker().mouseReleased(Minecraft.getInstance(), event.getScreen(), event.getMouseX(), event.getMouseY(), event.getButton());
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public static void eventKeyboardCharTypedEvent(ScreenEvent.KeyboardCharTypedEvent.Pre event) {
|
||||
public static void eventKeyboardCharTypedEvent(ScreenEvent.CharacterTyped.Pre event) {
|
||||
if (ClientScreenInputEvent.CHAR_TYPED_PRE.invoker().charTyped(Minecraft.getInstance(), event.getScreen(), event.getCodePoint(), event.getModifiers()).isFalse()) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public static void eventKeyboardCharTypedEvent(ScreenEvent.KeyboardCharTypedEvent.Post event) {
|
||||
public static void eventKeyboardCharTypedEvent(ScreenEvent.CharacterTyped.Post event) {
|
||||
ClientScreenInputEvent.CHAR_TYPED_POST.invoker().charTyped(Minecraft.getInstance(), event.getScreen(), event.getCodePoint(), event.getModifiers());
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public static void eventKeyboardKeyPressedEvent(ScreenEvent.KeyboardKeyPressedEvent.Pre event) {
|
||||
public static void eventKeyboardKeyPressedEvent(ScreenEvent.KeyPressed.Pre event) {
|
||||
if (ClientScreenInputEvent.KEY_PRESSED_PRE.invoker().keyPressed(Minecraft.getInstance(), event.getScreen(), event.getKeyCode(), event.getScanCode(), event.getModifiers()).isFalse()) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public static void eventKeyboardKeyPressedEvent(ScreenEvent.KeyboardKeyPressedEvent.Post event) {
|
||||
public static void eventKeyboardKeyPressedEvent(ScreenEvent.KeyPressed.Post event) {
|
||||
ClientScreenInputEvent.KEY_PRESSED_POST.invoker().keyPressed(Minecraft.getInstance(), event.getScreen(), event.getKeyCode(), event.getScanCode(), event.getModifiers());
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public static void eventKeyboardKeyReleasedEvent(ScreenEvent.KeyboardKeyReleasedEvent.Pre event) {
|
||||
public static void eventKeyboardKeyReleasedEvent(ScreenEvent.KeyReleased.Pre event) {
|
||||
if (ClientScreenInputEvent.KEY_RELEASED_PRE.invoker().keyReleased(Minecraft.getInstance(), event.getScreen(), event.getKeyCode(), event.getScanCode(), event.getModifiers()).isFalse()) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public static void eventKeyboardKeyReleasedEvent(ScreenEvent.KeyboardKeyReleasedEvent.Post event) {
|
||||
public static void eventKeyboardKeyReleasedEvent(ScreenEvent.KeyReleased.Post event) {
|
||||
ClientScreenInputEvent.KEY_RELEASED_POST.invoker().keyReleased(Minecraft.getInstance(), event.getScreen(), event.getKeyCode(), event.getScanCode(), event.getModifiers());
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public static void eventInputEvent(InputEvent.MouseScrollEvent event) {
|
||||
public static void eventInputEvent(InputEvent.MouseScrollingEvent event) {
|
||||
if (ClientRawInputEvent.MOUSE_SCROLLED.invoker().mouseScrolled(Minecraft.getInstance(), event.getScrollDelta()).isFalse()) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public static void eventInputEvent(InputEvent.RawMouseEvent event) {
|
||||
public static void eventInputEvent(InputEvent.MouseButton.Pre event) {
|
||||
if (ClientRawInputEvent.MOUSE_CLICKED_PRE.invoker().mouseClicked(Minecraft.getInstance(), event.getButton(), event.getAction(), event.getModifiers()).isFalse()) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public static void eventInputEvent(InputEvent.MouseInputEvent event) {
|
||||
public static void eventInputEvent(InputEvent.MouseButton.Post event) {
|
||||
ClientRawInputEvent.MOUSE_CLICKED_POST.invoker().mouseClicked(Minecraft.getInstance(), event.getButton(), event.getAction(), event.getModifiers());
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public static void eventInputEvent(InputEvent.KeyInputEvent event) {
|
||||
public static void eventInputEvent(InputEvent.Key event) {
|
||||
ClientRawInputEvent.KEY_PRESSED.invoker().keyPressed(Minecraft.getInstance(), event.getKey(), event.getScanCode(), event.getAction(), event.getModifiers());
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.level.material.Fluids;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.client.RenderProperties;
|
||||
import net.minecraftforge.client.extensions.common.IClientFluidTypeExtensions;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class FluidStackHooksImpl {
|
||||
@@ -71,7 +71,7 @@ public class FluidStackHooksImpl {
|
||||
@Nullable
|
||||
public static TextureAtlasSprite getStillTexture(@Nullable BlockAndTintGetter level, @Nullable BlockPos pos, FluidState state) {
|
||||
if (state.getType() == Fluids.EMPTY) return null;
|
||||
ResourceLocation texture = RenderProperties.get(state).getStillTexture(state, level, pos);
|
||||
ResourceLocation texture = IClientFluidTypeExtensions.of(state).getStillTexture(state, level, pos);
|
||||
return Minecraft.getInstance().getTextureAtlas(TextureAtlas.LOCATION_BLOCKS).apply(texture);
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ public class FluidStackHooksImpl {
|
||||
@Nullable
|
||||
public static TextureAtlasSprite getStillTexture(FluidStack stack) {
|
||||
if (stack.getFluid() == Fluids.EMPTY) return null;
|
||||
ResourceLocation texture = RenderProperties.get(stack.getFluid()).getStillTexture(FluidStackHooksForge.toForge(stack));
|
||||
ResourceLocation texture = IClientFluidTypeExtensions.of(stack.getFluid()).getStillTexture(FluidStackHooksForge.toForge(stack));
|
||||
return Minecraft.getInstance().getTextureAtlas(TextureAtlas.LOCATION_BLOCKS).apply(texture);
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ public class FluidStackHooksImpl {
|
||||
@Nullable
|
||||
public static TextureAtlasSprite getStillTexture(Fluid fluid) {
|
||||
if (fluid == Fluids.EMPTY) return null;
|
||||
ResourceLocation texture = RenderProperties.get(fluid).getStillTexture();
|
||||
ResourceLocation texture = IClientFluidTypeExtensions.of(fluid).getStillTexture();
|
||||
return Minecraft.getInstance().getTextureAtlas(TextureAtlas.LOCATION_BLOCKS).apply(texture);
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ public class FluidStackHooksImpl {
|
||||
@Nullable
|
||||
public static TextureAtlasSprite getFlowingTexture(@Nullable BlockAndTintGetter level, @Nullable BlockPos pos, FluidState state) {
|
||||
if (state.getType() == Fluids.EMPTY) return null;
|
||||
ResourceLocation texture = RenderProperties.get(state).getFlowingTexture(state, level, pos);
|
||||
ResourceLocation texture = IClientFluidTypeExtensions.of(state).getFlowingTexture(state, level, pos);
|
||||
return Minecraft.getInstance().getTextureAtlas(TextureAtlas.LOCATION_BLOCKS).apply(texture);
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ public class FluidStackHooksImpl {
|
||||
@Nullable
|
||||
public static TextureAtlasSprite getFlowingTexture(FluidStack stack) {
|
||||
if (stack.getFluid() == Fluids.EMPTY) return null;
|
||||
ResourceLocation texture = RenderProperties.get(stack.getFluid()).getFlowingTexture(FluidStackHooksForge.toForge(stack));
|
||||
ResourceLocation texture = IClientFluidTypeExtensions.of(stack.getFluid()).getFlowingTexture(FluidStackHooksForge.toForge(stack));
|
||||
return Minecraft.getInstance().getTextureAtlas(TextureAtlas.LOCATION_BLOCKS).apply(texture);
|
||||
}
|
||||
|
||||
@@ -111,26 +111,26 @@ public class FluidStackHooksImpl {
|
||||
@Nullable
|
||||
public static TextureAtlasSprite getFlowingTexture(Fluid fluid) {
|
||||
if (fluid == Fluids.EMPTY) return null;
|
||||
ResourceLocation texture = RenderProperties.get(fluid).getFlowingTexture();
|
||||
ResourceLocation texture = IClientFluidTypeExtensions.of(fluid).getFlowingTexture();
|
||||
return Minecraft.getInstance().getTextureAtlas(TextureAtlas.LOCATION_BLOCKS).apply(texture);
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static int getColor(@Nullable BlockAndTintGetter level, @Nullable BlockPos pos, FluidState state) {
|
||||
if (state.getType() == Fluids.EMPTY) return -1;
|
||||
return RenderProperties.get(state).getColorTint(state, level, pos);
|
||||
return IClientFluidTypeExtensions.of(state).getTintColor(state, level, pos);
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static int getColor(FluidStack stack) {
|
||||
if (stack.getFluid() == Fluids.EMPTY) return -1;
|
||||
return RenderProperties.get(stack.getFluid()).getColorTint(FluidStackHooksForge.toForge(stack));
|
||||
return IClientFluidTypeExtensions.of(stack.getFluid()).getTintColor(FluidStackHooksForge.toForge(stack));
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static int getColor(Fluid fluid) {
|
||||
if (fluid == Fluids.EMPTY) return -1;
|
||||
return RenderProperties.get(fluid).getColorTint();
|
||||
return IClientFluidTypeExtensions.of(fluid).getTintColor();
|
||||
}
|
||||
|
||||
public static int getLuminosity(FluidStack fluid, @Nullable Level level, @Nullable BlockPos pos) {
|
||||
|
||||
@@ -55,7 +55,7 @@ public class ClientNetworkingManager {
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void loggedOut(ClientPlayerNetworkEvent.LoggedOutEvent event) {
|
||||
public static void loggedOut(ClientPlayerNetworkEvent.LoggingOut event) {
|
||||
NetworkManagerImpl.serverReceivables.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,11 +19,40 @@
|
||||
|
||||
package dev.architectury.registry.client.keymappings.forge;
|
||||
|
||||
import dev.architectury.forge.ArchitecturyForge;
|
||||
import net.minecraft.client.KeyMapping;
|
||||
import net.minecraftforge.client.ClientRegistry;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.Options;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.RegisterKeyMappingsEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = ArchitecturyForge.MOD_ID, value = Dist.CLIENT)
|
||||
public class KeyMappingRegistryImpl {
|
||||
public static void register(KeyMapping keyBinding) {
|
||||
ClientRegistry.registerKeyBinding(keyBinding);
|
||||
private static final Logger LOGGER = LogManager.getLogger(KeyMappingRegistryImpl.class);
|
||||
private static final List<KeyMapping> MAPPINGS = new ArrayList<>();
|
||||
private static boolean eventCalled = false;
|
||||
|
||||
public static void register(KeyMapping mapping) {
|
||||
if (eventCalled) {
|
||||
Options options = Minecraft.getInstance().options;
|
||||
options.keyMappings = ArrayUtils.add(options.keyMappings, mapping);
|
||||
LOGGER.warn("Key mapping %s registered after event".formatted(mapping.getName()), new RuntimeException());
|
||||
} else {
|
||||
MAPPINGS.add(mapping);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void event(RegisterKeyMappingsEvent event) {
|
||||
MAPPINGS.forEach(event::register);
|
||||
eventCalled = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,13 +31,13 @@ import net.minecraft.core.particles.ParticleOptions;
|
||||
import net.minecraft.core.particles.ParticleType;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.ParticleFactoryRegisterEvent;
|
||||
import net.minecraftforge.client.event.RegisterParticleProvidersEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = ArchitecturyForge.MOD_ID, value = Dist.CLIENT)
|
||||
public class ParticleProviderRegistryImpl {
|
||||
@@ -71,42 +71,77 @@ public class ParticleProviderRegistryImpl {
|
||||
}
|
||||
}
|
||||
|
||||
private static ArrayList<Runnable> deferred = new ArrayList<>();
|
||||
private static List<Consumer<ParticleProviderRegistrar>> deferred = new ArrayList<>();
|
||||
|
||||
private static <T extends ParticleOptions> void _register(ParticleType<T> type, ParticleProvider<T> provider) {
|
||||
Minecraft.getInstance().particleEngine.register(type, provider);
|
||||
private static <T extends ParticleOptions> void _register(ParticleProviderRegistrar registrar, ParticleType<T> type, ParticleProvider<T> provider) {
|
||||
registrar.register(type, provider);
|
||||
}
|
||||
|
||||
private static <T extends ParticleOptions> void _register(ParticleType<T> type, ParticleProviderRegistry.DeferredParticleProvider<T> provider) {
|
||||
Minecraft.getInstance().particleEngine.register(type, sprites ->
|
||||
private static <T extends ParticleOptions> void _register(ParticleProviderRegistrar registrar, ParticleType<T> type, ParticleProviderRegistry.DeferredParticleProvider<T> provider) {
|
||||
registrar.register(type, sprites ->
|
||||
provider.create(new ExtendedSpriteSetImpl(Minecraft.getInstance().particleEngine, sprites)));
|
||||
}
|
||||
|
||||
public static <T extends ParticleOptions> void register(ParticleType<T> type, ParticleProvider<T> provider) {
|
||||
if (deferred == null) {
|
||||
_register(type, provider);
|
||||
_register(ParticleProviderRegistrar.ofFallback(), type, provider);
|
||||
} else {
|
||||
deferred.add(() -> _register(type, provider));
|
||||
deferred.add(registrar -> _register(registrar, type, provider));
|
||||
}
|
||||
}
|
||||
|
||||
public static <T extends ParticleOptions> void register(ParticleType<T> type, ParticleProviderRegistry.DeferredParticleProvider<T> provider) {
|
||||
if (deferred == null) {
|
||||
_register(type, provider);
|
||||
_register(ParticleProviderRegistrar.ofFallback(), type, provider);
|
||||
} else {
|
||||
deferred.add(() -> _register(type, provider));
|
||||
deferred.add(registrar -> _register(registrar, type, provider));
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onParticleFactoryRegister(ParticleFactoryRegisterEvent unused) {
|
||||
public static void onParticleFactoryRegister(RegisterParticleProvidersEvent event) {
|
||||
if (deferred != null) {
|
||||
ParticleProviderRegistrar registrar = ParticleProviderRegistrar.ofForge(event);
|
||||
// run all deferred registrations
|
||||
for (Runnable runnable : deferred) {
|
||||
runnable.run();
|
||||
for (Consumer<ParticleProviderRegistrar> consumer : deferred) {
|
||||
consumer.accept(registrar);
|
||||
}
|
||||
// yeet deferred list - register immediately from now on
|
||||
deferred = null;
|
||||
}
|
||||
}
|
||||
|
||||
private interface ParticleProviderRegistrar {
|
||||
<T extends ParticleOptions> void register(ParticleType<T> type, ParticleProvider<T> provider);
|
||||
|
||||
<T extends ParticleOptions> void register(ParticleType<T> type, ParticleEngine.SpriteParticleRegistration<T> registration);
|
||||
|
||||
static ParticleProviderRegistrar ofForge(RegisterParticleProvidersEvent event) {
|
||||
return new ParticleProviderRegistrar() {
|
||||
@Override
|
||||
public <T extends ParticleOptions> void register(ParticleType<T> type, ParticleProvider<T> provider) {
|
||||
event.register(type, provider);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends ParticleOptions> void register(ParticleType<T> type, ParticleEngine.SpriteParticleRegistration<T> registration) {
|
||||
event.register(type, registration);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
static ParticleProviderRegistrar ofFallback() {
|
||||
return new ParticleProviderRegistrar() {
|
||||
@Override
|
||||
public <T extends ParticleOptions> void register(ParticleType<T> type, ParticleProvider<T> provider) {
|
||||
Minecraft.getInstance().particleEngine.register(type, provider);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends ParticleOptions> void register(ParticleType<T> type, ParticleEngine.SpriteParticleRegistration<T> registration) {
|
||||
Minecraft.getInstance().particleEngine.register(type, registration);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,14 +20,14 @@
|
||||
package dev.architectury.registry.client.rendering.forge;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import dev.architectury.platform.forge.EventBuses;
|
||||
import dev.architectury.forge.ArchitecturyForge;
|
||||
import dev.architectury.platform.forge.EventBuses;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.color.block.BlockColor;
|
||||
import net.minecraft.client.color.item.ItemColor;
|
||||
import net.minecraft.world.level.ItemLike;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraftforge.client.event.ColorHandlerEvent;
|
||||
import net.minecraftforge.client.event.RegisterColorHandlersEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
@@ -46,16 +46,16 @@ public class ColorHandlerRegistryImpl {
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onItemColorEvent(ColorHandlerEvent.Item event) {
|
||||
public static void onItemColorEvent(RegisterColorHandlersEvent.Item event) {
|
||||
for (Pair<ItemColor, Supplier<? extends ItemLike>[]> pair : ITEM_COLORS) {
|
||||
event.getItemColors().register(pair.getLeft(), unpackItems(pair.getRight()));
|
||||
event.register(pair.getLeft(), unpackItems(pair.getRight()));
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onBlockColorEvent(ColorHandlerEvent.Block event) {
|
||||
public static void onBlockColorEvent(RegisterColorHandlersEvent.Block event) {
|
||||
for (Pair<BlockColor, Supplier<? extends Block>[]> pair : BLOCK_COLORS) {
|
||||
event.getBlockColors().register(pair.getLeft(), unpackBlocks(pair.getRight()));
|
||||
event.register(pair.getLeft(), unpackBlocks(pair.getRight()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,6 @@ side = "BOTH"
|
||||
[[dependencies.architectury]]
|
||||
modId = "forge"
|
||||
mandatory = true
|
||||
versionRange = "[41.0.30,)"
|
||||
versionRange = "[41.0.64,)"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
||||
|
||||
@@ -10,14 +10,14 @@ artifact_type=release
|
||||
|
||||
archives_base_name=architectury
|
||||
archives_base_name_snapshot=architectury-snapshot
|
||||
base_version=5.7
|
||||
base_version=5.8
|
||||
maven_group=dev.architectury
|
||||
|
||||
fabric_loader_version=0.14.6
|
||||
fabric_api_version=0.55.1+1.19
|
||||
mod_menu_version=3.1.0
|
||||
|
||||
forge_version=41.0.30
|
||||
forge_version=41.0.64
|
||||
|
||||
curseforge_id=419699
|
||||
modrinth_id=lhGA9TYQ
|
||||
Reference in New Issue
Block a user