Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
guimc233 committed Aug 13, 2024
1 parent c87bb52 commit a31db01
Show file tree
Hide file tree
Showing 19 changed files with 521 additions and 120 deletions.
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# gradle.properties file -- CHANGE THE VALUES STARTING WITH `mod_*` AND REMOVE THIS COMMENT.

# Sets the name of your mod.
mod_name=ExampleMod
mod_name=ZombiesHelper
# Sets the id of your mod that mod loaders use to recognize it.
mod_id=examplemod
mod_id=zombieshelper
# Sets the version of your mod. Make sure to update this when you make changes according to semver.
mod_version=1.0.0
# Sets the name of the jar file that you put in your 'mods' folder.
mod_archives_name=ExampleMod
mod_archives_name=ZombiesHelper

# Gradle Configuration -- DO NOT TOUCH THESE VALUES.
polyfrost.defaults.loom=3
Expand Down
48 changes: 0 additions & 48 deletions src/main/java/org/polyfrost/example/config/TestConfig.java

This file was deleted.

20 changes: 0 additions & 20 deletions src/main/java/org/polyfrost/example/hud/TestHud.java

This file was deleted.

21 changes: 0 additions & 21 deletions src/main/java/org/polyfrost/example/mixin/MinecraftMixin.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,33 +1,37 @@
package org.polyfrost.example;
package win.cuteguimc.zombieshelper;

import org.polyfrost.example.command.ExampleCommand;
import org.polyfrost.example.config.TestConfig;
import win.cuteguimc.zombieshelper.command.OpenGUICommand;
import win.cuteguimc.zombieshelper.config.ZombiesHelperConfig;
import cc.polyfrost.oneconfig.events.event.InitializationEvent;
import net.minecraftforge.fml.common.Mod;
import cc.polyfrost.oneconfig.utils.commands.CommandManager;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import win.cuteguimc.zombieshelper.listener.BlockUseEntityListener;
import win.cuteguimc.zombieshelper.listener.NoPuncherListener;

/**
* The entrypoint of the Example Mod that initializes it.
*
* @see Mod
* @see InitializationEvent
*/
@Mod(modid = ExampleMod.MODID, name = ExampleMod.NAME, version = ExampleMod.VERSION)
public class ExampleMod {
@Mod(modid = ZombiesHelper.MODID, name = ZombiesHelper.NAME, version = ZombiesHelper.VERSION)
public class ZombiesHelper {

// Sets the variables from `gradle.properties`. See the `blossom` config in `build.gradle.kts`.
public static final String MODID = "@ID@";
public static final String NAME = "@NAME@";
public static final String VERSION = "@VER@";
@Mod.Instance(MODID)
public static ExampleMod INSTANCE; // Adds the instance of the mod, so we can access other variables.
public static TestConfig config;
public static ZombiesHelper INSTANCE; // Adds the instance of the mod, so we can access other variables.
public static ZombiesHelperConfig config;

// Register the config and commands.
@Mod.EventHandler
public void onInit(FMLInitializationEvent event) {
config = new TestConfig();
CommandManager.INSTANCE.registerCommand(new ExampleCommand());
config = new ZombiesHelperConfig();
new NoPuncherListener();
new BlockUseEntityListener();
CommandManager.INSTANCE.registerCommand(new OpenGUICommand());
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.polyfrost.example.command;
package win.cuteguimc.zombieshelper.command;

import org.polyfrost.example.ExampleMod;
import win.cuteguimc.zombieshelper.ZombiesHelper;
import cc.polyfrost.oneconfig.utils.commands.annotations.Command;
import cc.polyfrost.oneconfig.utils.commands.annotations.Main;

Expand All @@ -10,12 +10,12 @@
*
* @see Command
* @see Main
* @see ExampleMod
* @see ZombiesHelper
*/
@Command(value = ExampleMod.MODID, description = "Access the " + ExampleMod.NAME + " GUI.")
public class ExampleCommand {
@Command(value = ZombiesHelper.MODID, description = "Access the " + ZombiesHelper.NAME + " GUI.")
public class OpenGUICommand {
@Main
private void handle() {
ExampleMod.INSTANCE.config.openGui();
ZombiesHelper.INSTANCE.config.openGui();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package win.cuteguimc.zombieshelper.config;

import cc.polyfrost.oneconfig.config.annotations.HUD;
import cc.polyfrost.oneconfig.config.annotations.KeyBind;
import cc.polyfrost.oneconfig.config.core.OneKeyBind;
import cc.polyfrost.oneconfig.libs.universal.UKeyboard;
import win.cuteguimc.zombieshelper.ZombiesHelper;
import cc.polyfrost.oneconfig.config.Config;
import cc.polyfrost.oneconfig.config.annotations.Slider;
import cc.polyfrost.oneconfig.config.annotations.Switch;
import cc.polyfrost.oneconfig.config.data.Mod;
import cc.polyfrost.oneconfig.config.data.ModType;
import win.cuteguimc.zombieshelper.hud.ZombiesHelperHud;

public class ZombiesHelperConfig extends Config {
@Switch(
name = "Block UseEntity"
)
public static boolean blockUseEntity = false;

@KeyBind(
name = "Toggle Block UseEntity Keybind"
)
public static OneKeyBind toggleBlockUseEntityKeyBind = new OneKeyBind(UKeyboard.KEY_LEFT);

@Switch(
name = "No Puncher"
)
public static boolean noPuncher = true;

@Switch(
name = "Hide Player"
)
public static boolean hidePlayer = false;

@Switch(
name = "ESP"
)
public static boolean esp = false;

@Slider(
name = "ESP Range",
min = 0f, max = 100f
)
public static float espRange = 50f;

@HUD(
name = "Nearby Entity HUD",
category = "NEHUD"
)
public ZombiesHelperHud hud = new ZombiesHelperHud();

public ZombiesHelperConfig() {
super(new Mod(ZombiesHelper.NAME, ModType.UTIL_QOL), ZombiesHelper.MODID + ".json");
registerKeyBind(toggleBlockUseEntityKeyBind, () -> blockUseEntity = !blockUseEntity);
initialize();
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package win.cuteguimc.zombieshelper.hud;

import cc.polyfrost.oneconfig.hud.SingleTextHud;
import net.minecraft.client.Minecraft;
import win.cuteguimc.zombieshelper.config.ZombiesHelperConfig;
import win.cuteguimc.zombieshelper.utils.Utils;

import java.util.stream.Collectors;

public class ZombiesHelperHud extends SingleTextHud {
public ZombiesHelperHud() {
super("Nearby Entity", true);
}

@Override
public String getText(boolean example) {
if (Minecraft.getMinecraft().theWorld == null || Minecraft.getMinecraft().thePlayer == null) return "World not loaded";
else {
int entityAmount = (int) Minecraft.getMinecraft().theWorld.loadedEntityList.stream().filter(entity -> Utils.isTarget(entity) && Minecraft.getMinecraft().thePlayer.getDistanceToEntity(entity) <= 8).count();
return entityAmount + "";
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package win.cuteguimc.zombieshelper.listener;

import cc.polyfrost.oneconfig.events.EventManager;
import cc.polyfrost.oneconfig.events.event.SendPacketEvent;
import cc.polyfrost.oneconfig.libs.eventbus.Subscribe;
import net.minecraft.block.BlockChest;
import net.minecraft.client.Minecraft;
import net.minecraft.network.Packet;
import net.minecraft.network.play.client.C02PacketUseEntity;
import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement;
import win.cuteguimc.zombieshelper.config.ZombiesHelperConfig;
import win.cuteguimc.zombieshelper.utils.Utils;

public class BlockUseEntityListener {
private final Minecraft mc = Minecraft.getMinecraft();

public BlockUseEntityListener() {
EventManager.INSTANCE.register(this);
}

@Subscribe
public void onPacketSend(SendPacketEvent event) {
if (!ZombiesHelperConfig.blockUseEntity) return;
Packet packet = event.packet;
if ((packet instanceof C08PacketPlayerBlockPlacement &&
mc.theWorld.getBlockState(((C08PacketPlayerBlockPlacement) packet).getPosition()).getBlock() instanceof BlockChest) ||
packet instanceof C02PacketUseEntity && !Utils.isTarget(((C02PacketUseEntity) packet).getEntityFromWorld(mc.theWorld))) {
event.isCancelled = true;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package win.cuteguimc.zombieshelper.listener;

import cc.polyfrost.oneconfig.events.EventManager;
import cc.polyfrost.oneconfig.events.event.ChatReceiveEvent;
import cc.polyfrost.oneconfig.events.event.SendPacketEvent;
import cc.polyfrost.oneconfig.libs.eventbus.Subscribe;
import net.minecraft.block.BlockChest;
import net.minecraft.client.Minecraft;
import net.minecraft.network.Packet;
import net.minecraft.network.play.client.C02PacketUseEntity;
import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement;
import win.cuteguimc.zombieshelper.config.ZombiesHelperConfig;
import win.cuteguimc.zombieshelper.utils.Utils;

import java.util.Locale;

public class NoPuncherListener {
private int lastPuncherTick = -1;
private final Minecraft mc = Minecraft.getMinecraft();

public NoPuncherListener() {
EventManager.INSTANCE.register(this);
}

@Subscribe
public void onChatReceive(ChatReceiveEvent event) {
if (mc.theWorld == null || mc.thePlayer == null) return;
if (!ZombiesHelperConfig.noPuncher) return;
String message = event.message.getUnformattedTextForChat();
if (message.toLowerCase(Locale.ROOT).contains("you found the puncher in the lucky chest")) {
lastPuncherTick = mc.thePlayer.ticksExisted;
}
}

@Subscribe
public void onPacketSend(SendPacketEvent event) {
if (!ZombiesHelperConfig.noPuncher) return;
Packet packet = event.packet;
if (((packet instanceof C08PacketPlayerBlockPlacement &&
mc.theWorld.getBlockState(((C08PacketPlayerBlockPlacement) packet).getPosition()).getBlock() instanceof BlockChest) ||
packet instanceof C02PacketUseEntity && !Utils.isTarget(((C02PacketUseEntity) packet).getEntityFromWorld(mc.theWorld))) &&
mc.thePlayer.ticksExisted - lastPuncherTick <= 20*10.2) {
event.isCancelled = true;
}
}
}
19 changes: 19 additions & 0 deletions src/main/java/win/cuteguimc/zombieshelper/mixin/EntityMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package win.cuteguimc.zombieshelper.mixin;

import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import win.cuteguimc.zombieshelper.config.ZombiesHelperConfig;

@Mixin(Entity.class)
public class EntityMixin {
@Inject(method = "isInvisible()Z", at = @At("RETURN"), cancellable = true)
private void onIsInvisible(CallbackInfoReturnable<Boolean> cir) {
if (((Entity) (Object) this) instanceof EntityPlayer && ZombiesHelperConfig.hidePlayer) {
cir.setReturnValue(true);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package win.cuteguimc.zombieshelper.mixin;

import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import win.cuteguimc.zombieshelper.config.ZombiesHelperConfig;

@Mixin(EntityPlayer.class)
public class EntityPlayerMixin {
@Inject(method = "isInvisibleToPlayer(Lnet/minecraft/entity/player/EntityPlayer;)Z", at = @At("RETURN"), cancellable = true)
private void onIsInvisibleToPlayer(EntityPlayer player, CallbackInfoReturnable<Boolean> cir) {
if (ZombiesHelperConfig.hidePlayer) {
cir.setReturnValue(false);
}
}
}
Loading

0 comments on commit a31db01

Please sign in to comment.