Skip to content

Commit

Permalink
Remove Arch environment checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaming32 committed Apr 18, 2024
1 parent e41529e commit ca3b9a3
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
5 changes: 2 additions & 3 deletions common/src/main/java/io/github/gaming32/bingo/Bingo.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

import com.demonwav.mcdev.annotations.Translatable;
import com.mojang.logging.LogUtils;
import dev.architectury.platform.Platform;
import dev.architectury.registry.ReloadListenerRegistry;
import dev.architectury.registry.registries.RegistrarManager;
import dev.architectury.utils.Env;
import io.github.gaming32.bingo.client.BingoClient;
import io.github.gaming32.bingo.conditions.BingoConditions;
import io.github.gaming32.bingo.conditions.BingoParamSets;
Expand All @@ -18,6 +16,7 @@
import io.github.gaming32.bingo.game.BingoGame;
import io.github.gaming32.bingo.mixin.common.ExplosionAccessor;
import io.github.gaming32.bingo.multiloader.Event;
import io.github.gaming32.bingo.multiloader.MultiLoaderInterface;
import io.github.gaming32.bingo.network.BingoNetworking;
import io.github.gaming32.bingo.network.messages.c2s.KeyPressedPacket;
import io.github.gaming32.bingo.network.messages.s2c.InitBoardPacket;
Expand Down Expand Up @@ -173,7 +172,7 @@ public static void init() {
registrar.register(PacketFlow.SERVERBOUND, KeyPressedPacket.ID, KeyPressedPacket::new);
});

if (Platform.getEnvironment() == Env.CLIENT) {
if (MultiLoaderInterface.instance.isClient()) {
BingoClient.init();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ public abstract class MultiLoaderInterface {
public static MultiLoaderInterface instance;

public abstract BingoNetworking getNetworking();

public abstract boolean isClient();
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ public BingoNetworking getNetworking() {
return networking;
}

@Override
public boolean isClient() {
return FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT;
}

private void registerEvents() {
Event.REGISTER_COMMANDS.setRegistrar(handler -> CommandRegistrationCallback.EVENT.register(handler::register));
Event.PLAYER_JOIN.setRegistrar(FabricEvents.PLAYER_JOIN::register);
Expand All @@ -45,7 +50,7 @@ private void registerEvents() {
Event.EXPLOSION_START.setRegistrar(FabricEvents.EXPLOSION::register);
Event.SERVER_TICK_END.setRegistrar(handler -> ServerTickEvents.END_SERVER_TICK.register(handler::accept));

if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) {
if (isClient()) {
ClientEvents.RENDER_HUD.setRegistrar(handler -> HudRenderCallback.EVENT.register(handler::renderHud));
ClientEvents.KEY_RELEASED_PRE.setRegistrar(handler -> ScreenEvents.BEFORE_INIT.register(
(client, screen, scaledWidth, scaledHeight) ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ public BingoNetworking getNetworking() {
return networking;
}

@Override
public boolean isClient() {
return Environment.get().getDist().isClient();
}

private void registerEvents() {
final IEventBus bus = NeoForge.EVENT_BUS;
Event.REGISTER_COMMANDS.setRegistrar(handler -> bus.addListener((RegisterCommandsEvent event) ->
Expand Down Expand Up @@ -70,7 +75,7 @@ private void registerEvents() {
}
}));

if (Environment.get().getDist().isClient()) {
if (isClient()) {
ClientEvents.RENDER_HUD.setRegistrar(handler -> bus.addListener((RenderGuiEvent.Post event) ->
handler.renderHud(event.getGuiGraphics(), event.getPartialTick())
));
Expand Down

0 comments on commit ca3b9a3

Please sign in to comment.