mod skeleton 1
this commit adds some skeleton using fabric-api for later implementation: - renderer - hypixel mod api - timer
This commit is contained in:
parent
17bad49074
commit
0c258f8680
5 changed files with 87 additions and 10 deletions
10
build.gradle
10
build.gradle
|
@ -11,11 +11,7 @@ base {
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
// Add repositories to retrieve artifacts from in here.
|
maven { url 'https://repo.hypixel.net/repository/Hypixel/' }
|
||||||
// You should only use this when depending on other mods because
|
|
||||||
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
|
|
||||||
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
|
|
||||||
// for more information about repositories.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
loom {
|
loom {
|
||||||
|
@ -38,7 +34,7 @@ dependencies {
|
||||||
|
|
||||||
// Fabric API. This is technically optional, but you probably want it anyway.
|
// Fabric API. This is technically optional, but you probably want it anyway.
|
||||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
||||||
|
modImplementation 'net.hypixel:mod-api:1.0.1'
|
||||||
}
|
}
|
||||||
|
|
||||||
processResources {
|
processResources {
|
||||||
|
@ -87,4 +83,4 @@ publishing {
|
||||||
// The repositories here will be used for publishing your artifact, not for
|
// The repositories here will be used for publishing your artifact, not for
|
||||||
// retrieving dependencies.
|
// retrieving dependencies.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,24 @@
|
||||||
package xyz.stachel.zombiesutils;
|
package xyz.stachel.zombiesutils;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import net.fabricmc.api.ClientModInitializer;
|
import net.fabricmc.api.ClientModInitializer;
|
||||||
|
import net.fabricmc.fabric.api.client.rendering.v1.HudLayerRegistrationCallback;
|
||||||
|
import net.hypixel.modapi.HypixelModAPI;
|
||||||
|
import net.hypixel.modapi.packet.impl.clientbound.event.ClientboundLocationPacket;
|
||||||
|
import xyz.stachel.zombiesutils.handlers.Renderer;
|
||||||
|
|
||||||
public class ZombiesUtilsClient implements ClientModInitializer {
|
public class ZombiesUtilsClient implements ClientModInitializer {
|
||||||
|
public static final String MOD_ID = "zombies-utils";
|
||||||
|
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInitializeClient() {
|
public void onInitializeClient() {
|
||||||
// This entrypoint is suitable for setting up client-specific logic, such as rendering.
|
HypixelModAPI.getInstance().subscribeToEventPacket(ClientboundLocationPacket.class);
|
||||||
System.out.println("Hello, Zombies!");
|
//TODO: HypixelModAPI.getInstance().createHandler(ClientboundLocationPacket.class, todo);
|
||||||
|
LOGGER.info("initializing...");
|
||||||
|
HudLayerRegistrationCallback.EVENT.register(new Renderer());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
38
src/client/java/xyz/stachel/zombiesutils/game/Timer.java
Normal file
38
src/client/java/xyz/stachel/zombiesutils/game/Timer.java
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
package xyz.stachel.zombiesutils.game;
|
||||||
|
|
||||||
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
import xyz.stachel.zombiesutils.ZombiesUtilsClient;
|
||||||
|
|
||||||
|
class Timer {
|
||||||
|
// world-absolute tick the game started on
|
||||||
|
private long startTick;
|
||||||
|
// amount of ticks elapsed between startTick and last split
|
||||||
|
private long roundStart;
|
||||||
|
|
||||||
|
public Timer() {
|
||||||
|
this.startTick = worldTick();
|
||||||
|
}
|
||||||
|
|
||||||
|
public long roundTime() {
|
||||||
|
return gameTime() - roundStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long gameTime() {
|
||||||
|
return worldTick() - startTick;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long split() {
|
||||||
|
final long rt = roundTime();
|
||||||
|
this.roundStart = gameTime();
|
||||||
|
return rt;
|
||||||
|
}
|
||||||
|
|
||||||
|
private long worldTick() {
|
||||||
|
MinecraftClient mc = MinecraftClient.getInstance();
|
||||||
|
if (mc == null || mc.world == null) {
|
||||||
|
ZombiesUtilsClient.LOGGER.warn("Timer is running, but the player is not in game.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return mc.world.getTime();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
package xyz.stachel.zombiesutils.handlers;
|
||||||
|
|
||||||
|
import net.fabricmc.fabric.api.client.rendering.v1.HudLayerRegistrationCallback;
|
||||||
|
import net.fabricmc.fabric.api.client.rendering.v1.IdentifiedLayer;
|
||||||
|
import net.fabricmc.fabric.api.client.rendering.v1.LayeredDrawerWrapper;
|
||||||
|
import net.minecraft.client.gui.DrawContext;
|
||||||
|
import net.minecraft.client.render.RenderTickCounter;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
|
public class Renderer implements HudLayerRegistrationCallback {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void register(LayeredDrawerWrapper layeredDrawer) {
|
||||||
|
layeredDrawer.attachLayerAfter(IdentifiedLayer.OVERLAY_MESSAGE, new ZombiesUtilsLayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
class ZombiesUtilsLayer implements IdentifiedLayer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(DrawContext context, RenderTickCounter tickCounter) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Identifier id() {
|
||||||
|
return Identifier.of("zombies-utils", "main");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -29,7 +29,8 @@
|
||||||
"fabricloader": ">=0.16.14",
|
"fabricloader": ">=0.16.14",
|
||||||
"minecraft": "~1.21.5",
|
"minecraft": "~1.21.5",
|
||||||
"java": ">=21",
|
"java": ">=21",
|
||||||
"fabric-api": "*"
|
"fabric-api": "*",
|
||||||
|
"hypixel-mod-api": ">=1.0.1"
|
||||||
},
|
},
|
||||||
"suggests": {}
|
"suggests": {}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue