Added Player Visibility and Utils.
This commit is contained in:
parent
207a43135b
commit
047dfcab72
14 changed files with 93 additions and 53 deletions
|
@ -11,16 +11,14 @@ base {
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
maven { url 'https://repo.hypixel.net/repository/Hypixel/' }
|
maven { url 'https://repo.hypixel.net/repository/Hypixel/' }
|
||||||
}
|
}
|
||||||
|
|
||||||
loom {
|
loom {
|
||||||
splitEnvironmentSourceSets()
|
|
||||||
|
|
||||||
mods {
|
mods {
|
||||||
"zombies-utils" {
|
"zombies-utils" {
|
||||||
sourceSet sourceSets.main
|
sourceSet sourceSets.main
|
||||||
sourceSet sourceSets.client
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +32,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'
|
modImplementation 'net.hypixel:mod-api:1.0.1'
|
||||||
}
|
}
|
||||||
|
|
||||||
processResources {
|
processResources {
|
||||||
|
@ -83,4 +81,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,20 +0,0 @@
|
||||||
package xyz.stachel.zombiesutils;
|
|
||||||
|
|
||||||
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.Location;
|
|
||||||
import xyz.stachel.zombiesutils.handlers.Renderer;
|
|
||||||
|
|
||||||
public class ZombiesUtilsClient implements ClientModInitializer {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onInitializeClient() {
|
|
||||||
HypixelModAPI.getInstance().subscribeToEventPacket(ClientboundLocationPacket.class);
|
|
||||||
HypixelModAPI.getInstance().createHandler(ClientboundLocationPacket.class, Location::onLocation);
|
|
||||||
ZombiesUtils.LOGGER.info("initializing...");
|
|
||||||
HudLayerRegistrationCallback.EVENT.register(new Renderer());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,11 +0,0 @@
|
||||||
{
|
|
||||||
"required": true,
|
|
||||||
"package": "xyz.stachel.zombiesutils.mixin.client",
|
|
||||||
"compatibilityLevel": "JAVA_21",
|
|
||||||
"client": [
|
|
||||||
"ClientPlayNetworkHandlerMixin"
|
|
||||||
],
|
|
||||||
"injectors": {
|
|
||||||
"defaultRequire": 1
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,9 +1,13 @@
|
||||||
package xyz.stachel.zombiesutils;
|
package xyz.stachel.zombiesutils;
|
||||||
|
|
||||||
|
import net.fabricmc.api.ModInitializer;
|
||||||
|
import net.fabricmc.fabric.api.client.rendering.v1.HudLayerRegistrationCallback;
|
||||||
|
import net.hypixel.modapi.HypixelModAPI;
|
||||||
|
import net.hypixel.modapi.packet.impl.clientbound.event.ClientboundLocationPacket;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import xyz.stachel.zombiesutils.handlers.Location;
|
||||||
import net.fabricmc.api.ModInitializer;
|
import xyz.stachel.zombiesutils.handlers.Renderer;
|
||||||
|
|
||||||
public class ZombiesUtils implements ModInitializer {
|
public class ZombiesUtils implements ModInitializer {
|
||||||
|
|
||||||
|
@ -12,6 +16,9 @@ public class ZombiesUtils implements ModInitializer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInitialize() {
|
public void onInitialize() {
|
||||||
|
HypixelModAPI.getInstance().subscribeToEventPacket(ClientboundLocationPacket.class);
|
||||||
|
HypixelModAPI.getInstance().createHandler(ClientboundLocationPacket.class, Location::onLocation);
|
||||||
|
ZombiesUtils.LOGGER.info("initializing...");
|
||||||
|
HudLayerRegistrationCallback.EVENT.register(new Renderer());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package xyz.stachel.zombiesutils.game;
|
package xyz.stachel.zombiesutils.game;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -7,8 +9,6 @@ import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
class GameFile extends File {
|
class GameFile extends File {
|
||||||
private FileWriter writer;
|
private FileWriter writer;
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
package xyz.stachel.zombiesutils.game;
|
package xyz.stachel.zombiesutils.game;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import xyz.stachel.zombiesutils.game.GameMode.Map;
|
|
||||||
import xyz.stachel.zombiesutils.handlers.Location;
|
import xyz.stachel.zombiesutils.handlers.Location;
|
||||||
|
import xyz.stachel.zombiesutils.game.GameMode.Map;
|
||||||
|
import xyz.stachel.zombiesutils.util.Utils;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
@ -24,7 +25,7 @@ public class GameManager {
|
||||||
public void onRound(final int round) {
|
public void onRound(final int round) {
|
||||||
final String sn = Location.getServerNumber();
|
final String sn = Location.getServerNumber();
|
||||||
final String mode = Location.getMode();
|
final String mode = Location.getMode();
|
||||||
if (sn == null || mode == null || !mode.startsWith("ZOMBIES")) return;
|
if (sn == null || mode == null || !Utils.isZombies()) return;
|
||||||
|
|
||||||
if (!this.games.containsKey(sn)) {
|
if (!this.games.containsKey(sn)) {
|
||||||
addGame(sn, new GameMode(Map.DEAD_END), round);
|
addGame(sn, new GameMode(Map.DEAD_END), round);
|
||||||
|
|
|
@ -2,7 +2,7 @@ package xyz.stachel.zombiesutils.game;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
class GameMode {
|
public class GameMode {
|
||||||
private final Map map;
|
private final Map map;
|
||||||
private Difficulty difficulty;
|
private Difficulty difficulty;
|
||||||
|
|
||||||
|
@ -23,11 +23,11 @@ class GameMode {
|
||||||
return this.map;
|
return this.map;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Map {
|
public enum Map {
|
||||||
DEAD_END, BAD_BLOOD, PRISON, ALIEN_ARCADIUM;
|
DEAD_END, BAD_BLOOD, PRISON, ALIEN_ARCADIUM;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Difficulty {
|
public enum Difficulty {
|
||||||
NORMAL, HARD, RIP;
|
NORMAL, HARD, RIP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package xyz.stachel.zombiesutils.mixin.client;
|
package xyz.stachel.zombiesutils.mixin;
|
||||||
|
|
||||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||||
import net.minecraft.network.packet.s2c.play.TitleS2CPacket;
|
import net.minecraft.network.packet.s2c.play.TitleS2CPacket;
|
||||||
|
@ -12,7 +12,7 @@ import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@Mixin(ClientPlayNetworkHandler.class)
|
@Mixin(ClientPlayNetworkHandler.class)
|
||||||
public class ClientPlayNetworkHandlerMixin {
|
public abstract class ClientPlayNetworkHandlerMixin {
|
||||||
private static final Pattern pattern = Pattern.compile("Round (\\d{1,3})");
|
private static final Pattern pattern = Pattern.compile("Round (\\d{1,3})");
|
||||||
|
|
||||||
@Inject(at = @At("HEAD"), method = "onTitle")
|
@Inject(at = @At("HEAD"), method = "onTitle")
|
|
@ -0,0 +1,29 @@
|
||||||
|
package xyz.stachel.zombiesutils.mixin;
|
||||||
|
|
||||||
|
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
|
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
||||||
|
import net.minecraft.client.network.OtherClientPlayerEntity;
|
||||||
|
import net.minecraft.client.world.ClientWorld;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
|
||||||
|
@Mixin(OtherClientPlayerEntity.class)
|
||||||
|
public abstract class OtherClientPlayerEntityMixin extends AbstractClientPlayerEntity {
|
||||||
|
|
||||||
|
public OtherClientPlayerEntityMixin(ClientWorld world, GameProfile profile) {
|
||||||
|
super(world, profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ModifyReturnValue(method = "shouldRender", at = @At(value = "RETURN"))
|
||||||
|
public boolean shouldRender(boolean original, double distance) {
|
||||||
|
int dist = 1;
|
||||||
|
double d = this.getBoundingBox().getAverageSideLength() * 1.75 + ((double) dist * 2.5D);
|
||||||
|
if (Double.isNaN(d)) {
|
||||||
|
d = 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
d *= 1.0;
|
||||||
|
return (distance >= d * d) && original;
|
||||||
|
}
|
||||||
|
}
|
26
src/main/java/xyz/stachel/zombiesutils/util/Utils.java
Normal file
26
src/main/java/xyz/stachel/zombiesutils/util/Utils.java
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
package xyz.stachel.zombiesutils.util;
|
||||||
|
|
||||||
|
import xyz.stachel.zombiesutils.game.GameMode;
|
||||||
|
import xyz.stachel.zombiesutils.handlers.Location;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import static xyz.stachel.zombiesutils.game.GameMode.Map.*;
|
||||||
|
|
||||||
|
public class Utils {
|
||||||
|
|
||||||
|
public static Optional<GameMode.Map> getMap() {
|
||||||
|
return switch (Location.getMode()) {
|
||||||
|
case "ZOMBIES_DEAD_END" -> Optional.of(DEAD_END);
|
||||||
|
case "ZOMBIES_BAD_BLOOD" -> Optional.of(BAD_BLOOD);
|
||||||
|
case "ZOMBIES_ALIEN_ARCADIUM" -> Optional.of(ALIEN_ARCADIUM);
|
||||||
|
case "ZOMBIES_PRISON" -> Optional.of(PRISON);
|
||||||
|
default -> Optional.empty();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isZombies() {
|
||||||
|
return Location.getMode().startsWith("ZOMBIES");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -17,14 +17,11 @@
|
||||||
"entrypoints": {
|
"entrypoints": {
|
||||||
"main": [
|
"main": [
|
||||||
"xyz.stachel.zombiesutils.ZombiesUtils"
|
"xyz.stachel.zombiesutils.ZombiesUtils"
|
||||||
],
|
]
|
||||||
"client": [
|
|
||||||
"xyz.stachel.zombiesutils.ZombiesUtilsClient"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"mixins": [
|
"mixins": [
|
||||||
{
|
{
|
||||||
"config": "zombies-utils.client.mixins.json",
|
"config": "zombies-utils.mixins.json",
|
||||||
"environment": "client"
|
"environment": "client"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
13
src/main/resources/zombies-utils.mixins.json
Normal file
13
src/main/resources/zombies-utils.mixins.json
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
"required": true,
|
||||||
|
"package": "xyz.stachel.zombiesutils.mixin",
|
||||||
|
"compatibilityLevel": "JAVA_21",
|
||||||
|
"client": [
|
||||||
|
"ClientPlayNetworkHandlerMixin",
|
||||||
|
"OtherClientPlayerEntityMixin"
|
||||||
|
],
|
||||||
|
"injectors": {
|
||||||
|
"defaultRequire": 1
|
||||||
|
},
|
||||||
|
"mixins": []
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue