generated from Polyfrost/OneConfigExampleMod
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
521 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 0 additions & 48 deletions
48
src/main/java/org/polyfrost/example/config/TestConfig.java
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
21 changes: 0 additions & 21 deletions
21
src/main/java/org/polyfrost/example/mixin/MinecraftMixin.java
This file was deleted.
Oops, something went wrong.
22 changes: 13 additions & 9 deletions
22
...ava/org/polyfrost/example/ExampleMod.java → ...uteguimc/zombieshelper/ZombiesHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
src/main/java/win/cuteguimc/zombieshelper/config/ZombiesHelperConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
|
23 changes: 23 additions & 0 deletions
23
src/main/java/win/cuteguimc/zombieshelper/hud/ZombiesHelperHud.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 + ""; | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/win/cuteguimc/zombieshelper/listener/BlockUseEntityListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
src/main/java/win/cuteguimc/zombieshelper/listener/NoPuncherListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
19
src/main/java/win/cuteguimc/zombieshelper/mixin/EntityMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/win/cuteguimc/zombieshelper/mixin/EntityPlayerMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
Oops, something went wrong.