Skip to content

Commit

Permalink
Attempt at Wizcraft hud compatibility
Browse files Browse the repository at this point in the history
REFACTOR: Removed the "Hello Fabric World" print line in FlutterAndFlounderMain (ahhhhhhhhh)
COMPAT: Attempted to add compatibility between the FlounderFestHud and Wizcraft's hud
BUILD: Added LibHudCompat
  • Loading branch information
Superkat32 committed Jan 3, 2024
1 parent ba3ef33 commit 42b42f3
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 4 deletions.
8 changes: 8 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ repositories {
name = 'GeckoLib'
url 'https://dl.cloudsmith.io/public/geckolib3/geckolib/maven/'
}
maven {
url "https://jitpack.io"
content {
includeGroup "com.github.falseresync"
}
}
}

dependencies {
Expand All @@ -47,6 +53,8 @@ dependencies {
modApi "com.terraformersmc:modmenu:${modmenu_version}"

modImplementation "software.bernie.geckolib:${geckolib_version}"

modImplementation include("com.github.falseresync:libhudcompat:${libhudcompat_version}")
}

processResources {
Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ archives_base_name=flutterandflounder
# Dependencies
fabric_version=0.91.3+1.20.4
modmenu_version=9.0.0-pre.1
geckolib_version=geckolib-fabric-1.20.1:4.3.1
geckolib_version=geckolib-fabric-1.20.1:4.3.1
libhudcompat_version=1.0.2
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ public void onInitialize() {
//frogmobile
FabricDefaultAttributeRegistry.register(FlutterAndFlounderEntities.FROGMOBILE, FrogmobileEntity.createAttributes());


CommandRegistrationCallback.EVENT.register(((dispatcher, registryAccess, environment) -> FlounderFestCommand.register(dispatcher)));

LOGGER.info("Hello Fabric world!");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public static void registerPackets() {
int quotaProgress = buf.readInt();
int maxQuota = buf.readInt();
BlockPos startingPos = buf.readBlockPos();
FlutterAndFlounderRendering.occupyHudRegion();
FlutterAndFlounderRendering.flounderFestHud = new FlounderFestHud(waveNum, maxWaves, secondsLeft, quotaProgress, maxQuota);
FlutterAndFlounderRendering.flounderFestCenterRenderer = new FlounderFestCenterRenderer(startingPos);
});
Expand Down Expand Up @@ -85,6 +86,7 @@ public static void registerPackets() {

ClientPlayNetworking.registerGlobalReceiver(FLOUNDERFEST_REMOVE_HUD_ID, (((client, handler, buf, responseSender) -> {
client.execute(() -> {
FlutterAndFlounderRendering.freeHudRegion();
FlutterAndFlounderRendering.flounderFestHud = null;
FlutterAndFlounderRendering.flounderFestCenterRenderer = null;
LOGGER.info("Removing FlounderFest hud!");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.superkat.flutterandflounder.rendering;

import com.mojang.blaze3d.systems.RenderSystem;
import dev.falseresync.libhudcompat.LibHudCompat;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents;
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext;
Expand Down Expand Up @@ -295,6 +296,24 @@ public static void playBossAlertAnim() {
ticksSinceBossAnim = 0;
}

public static void occupyHudRegion() {
MinecraftClient client = MinecraftClient.getInstance();
int windowWidth = client.getWindow().getScaledWidth();
Text title = Text.translatable("flutterandflounder.flounderfest.title");
int titleTextWidth = client.textRenderer.getWidth(title);
Text quotaTitle = Text.translatable("flutterandflounder.flounderfest.quota");

int x = windowWidth / 2 - titleTextWidth / 2 - titleTextWidth / 4;
int y = 3;
int xLimit = windowWidth / 2 + titleTextWidth / 4 + client.textRenderer.getWidth(quotaTitle);
int yLimit = client.textRenderer.getWrappedLinesHeight(title, 114) * 4;
LibHudCompat.forceOccupyRegion(Identifier.tryParse(MOD_ID), x, y, xLimit, yLimit);
}

public static void freeHudRegion() {
LibHudCompat.freeRegion(Identifier.tryParse(MOD_ID));
}

public void setFlounderFestHud(@Nullable FlounderFestHud flounderFestHud) {
FlutterAndFlounderRendering.flounderFestHud = flounderFestHud;
shouldChangeSky = flounderFestHud != null;
Expand Down

0 comments on commit 42b42f3

Please sign in to comment.