-
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
Snoworange420
committed
Feb 21, 2023
1 parent
3e74d50
commit fdbfdac
Showing
103 changed files
with
6,854 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package nl.snoworange.cranberry; | ||
|
||
import net.minecraft.client.settings.KeyBinding; | ||
import net.minecraftforge.common.MinecraftForge; | ||
import net.minecraftforge.fml.client.registry.ClientRegistry; | ||
import net.minecraftforge.fml.common.Mod; | ||
import net.minecraftforge.fml.common.event.FMLInitializationEvent; | ||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; | ||
import nl.snoworange.cranberry.features.command.CommandManager; | ||
import nl.snoworange.cranberry.features.friend.Friend; | ||
import nl.snoworange.cranberry.features.module.ModuleManager; | ||
import nl.snoworange.cranberry.util.FileUtils; | ||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.lwjgl.input.Keyboard; | ||
|
||
@Mod(modid = Main.MOD_ID, name = Main.NAME, version = Main.VERSION, acceptedMinecraftVersions = Main.ACCEPTED_MINECRAFT_VERSIONS) | ||
public class Main { | ||
|
||
//Refrences | ||
public static final String MOD_ID = "cranberry"; | ||
public static final String NAME = "Cranberry"; | ||
public static final String VERSION = "v0.6.3"; | ||
public static final String ACCEPTED_MINECRAFT_VERSIONS = "[1.12.2]"; | ||
public static final Logger LOGGER = LogManager.getLogger("Cranberry"); | ||
|
||
public static ModuleManager moduleManager; | ||
public static Friend friendManager; | ||
public static CommandManager commandManager; | ||
public static KeyBinding clickGuiKeybind; | ||
|
||
|
||
@Mod.Instance | ||
public static Main instance; | ||
|
||
@Mod.EventHandler | ||
public void preInit(FMLPreInitializationEvent event) { | ||
MinecraftForge.EVENT_BUS.register(instance); | ||
|
||
moduleManager = new ModuleManager(); | ||
commandManager = new CommandManager(); | ||
friendManager = new Friend(); //sounds weird, why? | ||
|
||
clickGuiKeybind = new KeyBinding("ClickGUI", Keyboard.KEY_NONE, Main.NAME); | ||
ClientRegistry.registerKeyBinding(clickGuiKeybind); | ||
} | ||
|
||
@Mod.EventHandler | ||
public void init(FMLInitializationEvent event) { | ||
FileUtils.init(); | ||
FileUtils.loadAll(FileUtils.cranberry); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/nl/snoworange/cranberry/event/EventStage.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,22 @@ | ||
package nl.snoworange.cranberry.event; | ||
|
||
import net.minecraftforge.fml.common.eventhandler.Event; | ||
|
||
public class EventStage extends Event { | ||
private int stage; | ||
|
||
public EventStage() { | ||
} | ||
|
||
public EventStage(int stage) { | ||
this.stage = stage; | ||
} | ||
|
||
public int getStage() { | ||
return this.stage; | ||
} | ||
|
||
public void setStage(int stage) { | ||
this.stage = stage; | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
src/main/java/nl/snoworange/cranberry/event/ForgeEventListener.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 nl.snoworange.cranberry.event; | ||
|
||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.network.play.server.SPacketEntityStatus; | ||
import net.minecraftforge.common.MinecraftForge; | ||
import net.minecraftforge.event.entity.living.LivingEvent; | ||
import net.minecraftforge.fml.common.eventhandler.EventPriority; | ||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; | ||
import nl.snoworange.cranberry.event.events.BozoJustDiedEvent; | ||
import nl.snoworange.cranberry.event.events.DeathEvent; | ||
import nl.snoworange.cranberry.event.events.PacketEvent; | ||
import nl.snoworange.cranberry.event.events.TotemPopEvent; | ||
|
||
public class ForgeEventListener { | ||
|
||
private static final Minecraft mc = Minecraft.getMinecraft(); | ||
|
||
@SubscribeEvent //doesn't work, why? | ||
public void onLiving(LivingEvent.LivingUpdateEvent event) { | ||
if (event.getEntityLiving() instanceof EntityPlayer) { | ||
for (EntityPlayer player : mc.world.playerEntities) { | ||
if (player == null || player.getHealth() > 0.0F) | ||
continue; | ||
MinecraftForge.EVENT_BUS.post(new DeathEvent(player)); | ||
} | ||
} | ||
} | ||
|
||
//bozo | ||
@SubscribeEvent(priority = EventPriority.LOWEST) | ||
public void onDeath(DeathEvent event) { | ||
if (event.getPlayer().getName().equalsIgnoreCase("asdacashier") | ||
|| event.getPlayer().getName().equalsIgnoreCase("Kryptic_MZ")) { | ||
MinecraftForge.EVENT_BUS.post(new BozoJustDiedEvent(event.getPlayer())); | ||
} | ||
} | ||
|
||
@SubscribeEvent(priority = EventPriority.HIGH) | ||
public void onPacket(PacketEvent.Receive event) { | ||
|
||
if (mc.world == null) return; | ||
|
||
if (event.getPacket() instanceof SPacketEntityStatus) { | ||
|
||
SPacketEntityStatus packet = (SPacketEntityStatus) event.getPacket(); | ||
|
||
if (packet.getOpCode() == 35) { | ||
Entity entity = packet.getEntity(mc.world); | ||
|
||
if (!(entity instanceof EntityPlayer) || entity.getName().equalsIgnoreCase(Minecraft.getMinecraft().player.getName())) | ||
return; | ||
|
||
MinecraftForge.EVENT_BUS.post(new TotemPopEvent((EntityPlayer) entity)); | ||
} | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/nl/snoworange/cranberry/event/events/BozoJustDiedEvent.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,28 @@ | ||
package nl.snoworange.cranberry.event.events; | ||
|
||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraftforge.fml.common.eventhandler.Cancelable; | ||
import nl.snoworange.cranberry.event.EventStage; | ||
|
||
@Cancelable | ||
public class BozoJustDiedEvent extends EventStage { | ||
|
||
private final EntityPlayer player; | ||
private boolean easy = false; | ||
|
||
public BozoJustDiedEvent(EntityPlayer player) { | ||
this.player = player; | ||
} | ||
|
||
public EntityPlayer getPlayer() { | ||
return player; | ||
} | ||
|
||
public void tooEasy(boolean easy) { | ||
this.easy = easy; | ||
} | ||
|
||
public boolean isEasy() { | ||
return this.easy; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/nl/snoworange/cranberry/event/events/DeathEvent.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,17 @@ | ||
package nl.snoworange.cranberry.event.events; | ||
|
||
import net.minecraft.entity.player.EntityPlayer; | ||
import nl.snoworange.cranberry.event.EventStage; | ||
|
||
public class DeathEvent extends EventStage { | ||
|
||
public EntityPlayer player; | ||
|
||
public DeathEvent(EntityPlayer player) { | ||
this.player = player; | ||
} | ||
|
||
public EntityPlayer getPlayer() { | ||
return player; | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
src/main/java/nl/snoworange/cranberry/event/events/PacketEvent.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,48 @@ | ||
package nl.snoworange.cranberry.event.events; | ||
|
||
import net.minecraft.network.Packet; | ||
import net.minecraftforge.fml.common.eventhandler.Cancelable; | ||
import nl.snoworange.cranberry.event.EventStage; | ||
|
||
@Cancelable | ||
public class PacketEvent extends EventStage { | ||
|
||
private final Packet<?> packet; | ||
public int stage; | ||
|
||
public PacketEvent(Packet<?> packet) { | ||
this.packet = packet; | ||
} | ||
|
||
public Packet<?> getPacket() { | ||
return this.packet; | ||
} | ||
|
||
public int getStage() { | ||
return this.stage; | ||
} | ||
|
||
public static class PostSend extends PacketEvent { | ||
public PostSend(Packet<?> packet) { | ||
super(packet); | ||
} | ||
} | ||
|
||
public static class PostReceive extends PacketEvent { | ||
public PostReceive(Packet<?> packet) { | ||
super(packet); | ||
} | ||
} | ||
|
||
public static class Send extends PacketEvent { | ||
public Send(Packet<?> packet) { | ||
super(packet); | ||
} | ||
} | ||
|
||
public static class Receive extends PacketEvent { | ||
public Receive(Packet<?> packet) { | ||
super(packet); | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/nl/snoworange/cranberry/event/events/TotemPopEvent.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,18 @@ | ||
package nl.snoworange.cranberry.event.events; | ||
|
||
import net.minecraft.entity.player.EntityPlayer; | ||
import nl.snoworange.cranberry.event.EventStage; | ||
|
||
public class TotemPopEvent extends EventStage { | ||
|
||
private final EntityPlayer player; | ||
|
||
public TotemPopEvent(EntityPlayer player) { | ||
this.player = player; | ||
} | ||
|
||
public EntityPlayer getPlayer() { | ||
return player; | ||
} | ||
|
||
} |
45 changes: 45 additions & 0 deletions
45
src/main/java/nl/snoworange/cranberry/features/command/Command.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,45 @@ | ||
package nl.snoworange.cranberry.features.command; | ||
|
||
import net.minecraft.client.Minecraft; | ||
|
||
public class Command { | ||
|
||
public String name, description, syntax; | ||
|
||
public static final Minecraft mc = Minecraft.getMinecraft(); | ||
|
||
public Command(String name, String description, String syntax) { | ||
this.name = name; | ||
this.description = description; | ||
this.syntax = syntax; | ||
} | ||
|
||
public void onCommand(String[] args, String command) { | ||
|
||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getDescription() { | ||
return description; | ||
} | ||
|
||
public void setDescription(String description) { | ||
this.description = description; | ||
} | ||
|
||
public String getSyntax() { | ||
return syntax; | ||
} | ||
|
||
public void setSyntax(String syntax) { | ||
this.syntax = syntax; | ||
} | ||
|
||
} |
83 changes: 83 additions & 0 deletions
83
src/main/java/nl/snoworange/cranberry/features/command/CommandManager.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,83 @@ | ||
package nl.snoworange.cranberry.features.command; | ||
|
||
import com.mojang.realmsclient.gui.ChatFormatting; | ||
import net.minecraftforge.client.event.ClientChatEvent; | ||
import net.minecraftforge.common.MinecraftForge; | ||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; | ||
import nl.snoworange.cranberry.features.command.commands.Friend; | ||
import nl.snoworange.cranberry.features.command.commands.Load; | ||
import nl.snoworange.cranberry.features.command.commands.Prefix; | ||
import nl.snoworange.cranberry.features.command.commands.Save; | ||
import nl.snoworange.cranberry.util.FileUtils; | ||
import nl.snoworange.cranberry.util.minecraft.ChatUtils; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class CommandManager { | ||
|
||
public static List<Command> commands = new ArrayList<>(); | ||
public static String prefix = "^"; | ||
|
||
public CommandManager() { | ||
MinecraftForge.EVENT_BUS.register(this); | ||
|
||
commands.add(new Save()); | ||
commands.add(new Load()); | ||
|
||
commands.add(new Prefix()); | ||
commands.add(new Friend()); | ||
} | ||
|
||
@SubscribeEvent | ||
public void onChat(ClientChatEvent event) { | ||
String message = event.getMessage(); | ||
|
||
if (!message.startsWith(prefix)) { | ||
return; | ||
} | ||
|
||
event.setCanceled(true); | ||
message = message.substring(prefix.length()); | ||
|
||
if (message.split(" ").length > 0) { | ||
|
||
boolean commandFound = false; | ||
String commandName = message.split(" ")[0]; | ||
|
||
if (commandName.equals("") || commandName.equals("help")) { | ||
sendCommandDescriptions(); | ||
} else { | ||
for (Command command : commands) { | ||
if (command.name.equalsIgnoreCase(commandName)) { | ||
command.onCommand(Arrays.copyOfRange(message.split(" "), 1, message.split(" ").length), message); | ||
commandFound = true; | ||
break; | ||
} | ||
} | ||
if (!commandFound) { | ||
ChatUtils.sendMessage(ChatFormatting.DARK_RED + "command does not exist, use " + ChatFormatting.ITALIC + prefix + "help " + ChatFormatting.RESET + "" + ChatFormatting.DARK_RED + "for help."); | ||
} | ||
} | ||
} | ||
} | ||
|
||
private void sendCommandDescriptions() { | ||
ChatUtils.sendMessage("Commands:"); | ||
for (Command command : commands) { | ||
ChatUtils.sendMessage(command.name + " - " + command.description + " [" + command.syntax + "]"); | ||
} | ||
} | ||
|
||
public void setCommandPrefix(String newPrefix) { | ||
prefix = newPrefix; | ||
|
||
FileUtils.savePrefix(FileUtils.cranberry, newPrefix); | ||
} | ||
|
||
public void sendCorrectionMessage(String name, String syntax) { | ||
String correction = "correct usage of " + ChatFormatting.WHITE + name + ChatFormatting.GRAY + " command -> " + ChatFormatting.WHITE + prefix + syntax + ChatFormatting.GRAY + "."; | ||
ChatUtils.sendMessage(correction); | ||
} | ||
} |
Oops, something went wrong.