Skip to content

Commit

Permalink
clean
Browse files Browse the repository at this point in the history
  • Loading branch information
TexBlock committed Apr 20, 2024
1 parent a46da56 commit 99c1a48
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 43 deletions.
4 changes: 1 addition & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
## Changelog
- remove the mixin for embeddium (only forge)
- remove architectury dependency
- add keybind (press and hold the key)
- code clean
4 changes: 1 addition & 3 deletions fabric/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
## Changelog
- remove the mixin for embeddium (only forge)
- remove architectury dependency
- add keybind (press and hold the key)
- code clean
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.thinkingstudio.ryoamiclights.fabric;

import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents;
import net.minecraft.client.MinecraftClient;
import org.thinkingstudio.ryoamiclights.RyoamicLights;

public class FabricEventHandler {
public static void registerEvents() {
WorldRenderEvents.START.register(context -> {
MinecraftClient.getInstance().getProfiler().swap("dynamic_lighting");
RyoamicLights.get().updateAll(context.worldRenderer());
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
import net.minecraft.resource.ResourceType;
import net.minecraft.util.Identifier;
import org.thinkingstudio.ryoamiclights.RyoamicLights;
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents;
import net.minecraft.client.MinecraftClient;
import org.thinkingstudio.ryoamiclights.api.item.ItemLightSources;
import org.thinkingstudio.ryoamiclights.fabric.api.DynamicLightsInitializer;

Expand All @@ -48,9 +46,6 @@ public void reload(ResourceManager manager) {
}
});

WorldRenderEvents.START.register(context -> {
MinecraftClient.getInstance().getProfiler().swap("dynamic_lighting");
RyoamicLights.get().updateAll(context.worldRenderer());
});
FabricEventHandler.registerEvents();
}
}
4 changes: 1 addition & 3 deletions forge/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
## Changelog
- remove the mixin for embeddium (only forge)
- remove architectury dependency
- add keybind (press and hold the key)
- code clean
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.thinkingstudio.ryoamiclights.forge;

import net.minecraft.client.MinecraftClient;
import net.minecraft.resource.SynchronousResourceReloader;
import net.minecraftforge.client.event.RegisterClientReloadListenersEvent;
import net.minecraftforge.client.event.RenderLevelStageEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.EventPriority;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import org.thinkingstudio.ryoamiclights.RyoamicLights;
import org.thinkingstudio.ryoamiclights.api.item.ItemLightSources;
import org.thinkingstudio.ryoamiclights.forge.api.DynamicLightsInitializerEvent;

public class ForgeEventHandler {
public static void registerEvents() {
IEventBus forgeEventBus = MinecraftForge.EVENT_BUS;
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();

forgeEventBus.<RenderLevelStageEvent>addListener(EventPriority.HIGHEST, event -> {
if (event.getStage() == RenderLevelStageEvent.Stage.AFTER_TRIPWIRE_BLOCKS) {
MinecraftClient.getInstance().getProfiler().swap("dynamic_lighting");
RyoamicLights.get().updateAll(event.getLevelRenderer());
}
});
modEventBus.<RegisterClientReloadListenersEvent>addListener(EventPriority.HIGHEST, event -> {
event.registerReloadListener((SynchronousResourceReloader) ItemLightSources::load);
});

forgeEventBus.post(new DynamicLightsInitializerEvent());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,14 @@

package org.thinkingstudio.ryoamiclights.forge;

import net.minecraft.client.MinecraftClient;
import net.minecraft.resource.SynchronousResourceReloader;
import net.minecraftforge.client.ClientRegistry;
import net.minecraftforge.client.ConfigGuiHandler;
import net.minecraftforge.client.event.RegisterClientReloadListenersEvent;
import net.minecraftforge.client.event.RenderLevelStageEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.EventPriority;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.IExtensionPoint;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.fml.loading.FMLLoader;
import net.minecraftforge.network.NetworkConstants;
import org.jetbrains.annotations.NotNull;
import org.thinkingstudio.ryoamiclights.RyoamicLights;
import org.thinkingstudio.ryoamiclights.api.item.ItemLightSources;
import org.thinkingstudio.ryoamiclights.forge.api.DynamicLightsInitializerEvent;
import org.thinkingstudio.ryoamiclights.gui.SettingsScreen;

@Mod(RyoamicLights.NAMESPACE)
Expand All @@ -41,28 +30,14 @@ public RyoamicLightsForge() {

public void onInitializeClient() {
ModLoadingContext context = ModLoadingContext.get();
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();

RyoamicLights.get().clientInit();

ClientRegistry.registerKeyBinding(RyoamicLights.get().keyBinding);

context.registerExtensionPoint(IExtensionPoint.DisplayTest.class, () -> new IExtensionPoint.DisplayTest(() -> NetworkConstants.IGNORESERVERONLY, (a, b) -> true));
context.registerExtensionPoint(ConfigGuiHandler.ConfigGuiFactory.class, () -> new ConfigGuiHandler.ConfigGuiFactory((client, screen) -> new SettingsScreen(screen)));
modEventBus.addListener(EventPriority.HIGHEST, this::renderWorldLast);
modEventBus.addListener(EventPriority.HIGHEST, this::registerClientReloadListeners);

MinecraftForge.EVENT_BUS.post(new DynamicLightsInitializerEvent());
}

public void renderWorldLast(@NotNull RenderLevelStageEvent event) {
if (event.getStage() == RenderLevelStageEvent.Stage.AFTER_TRIPWIRE_BLOCKS) {
MinecraftClient.getInstance().getProfiler().swap("dynamic_lighting");
RyoamicLights.get().updateAll(event.getLevelRenderer());
}
}

public void registerClientReloadListeners(RegisterClientReloadListenersEvent event) {
event.registerReloadListener((SynchronousResourceReloader) ItemLightSources::load);
ForgeEventHandler.registerEvents();
}
}
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ enabled_platforms=fabric,forge
quilt_mappings=1.18.2+build.26

archives_base_name=RyoamicLights
mod_version=0.2.1
mod_version=0.2.2
maven_group=org.thinkingstudio.ryoamiclights

fabric_loader_version=0.15.2
fabric_api_version=0.77.0+1.18.2
mod_menu_version=3.2.5

forge_version=1.18.2-40.2.17
forge_version=1.18.2-40.2.18

obsidianui_version=0.2.0+mc1.18.2

Expand Down

0 comments on commit 99c1a48

Please sign in to comment.