Skip to content

Commit

Permalink
Merge pull request #23 from cabbagegod/a.1.4.1+1.18.2
Browse files Browse the repository at this point in the history
CabbageScape a.1.4.1+1.18.2
  • Loading branch information
cabbagegod authored Feb 17, 2023
2 parents 8067e13 + 39d1703 commit 37e03e6
Show file tree
Hide file tree
Showing 46 changed files with 534 additions and 296 deletions.
5 changes: 5 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ dependencies {

// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

//Reflection API for EventHandler
implementation 'org.reflections:reflections:0.10.2'
include 'org.reflections:reflections:0.10.2'
include 'org.javassist:javassist:3.29.2-GA'
}

processResources {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G
loader_version=0.13.3

# Mod Properties
mod_version = a1.4+1.18.2
mod_version = a1.4.1+1.18.2
maven_group = com.cabbagegod
archives_base_name = cabbagescape

Expand Down
10 changes: 9 additions & 1 deletion src/main/java/com/cabbagegod/cabbagescape/Main.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
package com.cabbagegod.cabbagescape;

import com.cabbagegod.cabbagescape.client.cluetracker.ClueTracker;
import com.cabbagegod.cabbagescape.events.EventHandler;
import jdk.jfr.Event;
import net.fabricmc.api.ModInitializer;
import org.reflections.Reflections;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.Set;

public class Main implements ModInitializer {
// This logger is used to write text to the console and the log file.
// It is considered best practice to use your mod id as the logger's name.
Expand All @@ -15,6 +23,6 @@ public void onInitialize() {
// This code runs as soon as Minecraft is in a mod-load-ready state.
// However, some things (like resources) may still be uninitialized.
// Proceed with mild caution.
LOGGER.info("Hello Fabric world!");
LOGGER.info("Loaded CabbageScape");
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package com.cabbagegod.cabbagescape.events;
package com.cabbagegod.cabbagescape.callbacks;

import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.ActionResult;
import net.minecraft.util.math.BlockPos;

public interface DoorUseCallback {

Event<DoorUseCallback> EVENT = EventFactory.createArrayBacked(DoorUseCallback.class,
(listeners) -> (player, pos) -> {
for(DoorUseCallback listener : listeners){
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.cabbagegod.cabbagescape.callbacks;

import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;
import net.minecraft.util.ActionResult;

public interface ReceiveChatMessageCallback {

Event<ReceiveChatMessageCallback> EVENT = EventFactory.createArrayBacked(ReceiveChatMessageCallback.class, (listeners) -> (message) -> {
for (ReceiveChatMessageCallback listener : listeners) {
ActionResult result = listener.interact(message);

if(result != ActionResult.PASS) {
return result;
}
}

return ActionResult.PASS;
});

ActionResult interact(String message);
}
Original file line number Diff line number Diff line change
@@ -1,76 +1,81 @@
package com.cabbagegod.cabbagescape.client;

import com.cabbagegod.cabbagescape.Main;
import com.cabbagegod.cabbagescape.client.barrows.BarrowsHelper;
import com.cabbagegod.cabbagescape.client.blockoutline.BlockOutlineManager;
import com.cabbagegod.cabbagescape.client.blockoutline.PersistentOutlineRenderer;
import com.cabbagegod.cabbagescape.client.grounditems.GroundItemsManager;
import com.cabbagegod.cabbagescape.client.potiontimers.PotionTimerManager;
import com.cabbagegod.cabbagescape.commands.Commands;
import com.cabbagegod.cabbagescape.data.DataHandler;
import com.cabbagegod.cabbagescape.data.DelayedScreenshot;
import com.cabbagegod.cabbagescape.data.Settings;
import com.cabbagegod.cabbagescape.events.EventHandler;
import com.cabbagegod.cabbagescape.notifications.NotificationManager;
import com.cabbagegod.cabbagescape.ui.UpdateScreen;
import com.cabbagegod.cabbagescape.util.FileUtil;
import com.cabbagegod.cabbagescape.util.ScreenshotUtil;
import com.cabbagegod.cabbagescape.util.ThreadingUtil;
import com.google.gson.Gson;
import jdk.jshell.spi.ExecutionControl;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientEntityEvents;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents;
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gl.Framebuffer;
import net.minecraft.client.gl.SimpleFramebuffer;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.texture.NativeImage;
import net.minecraft.client.util.ScreenshotRecorder;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.sound.SoundEvents;
import net.minecraft.text.LiteralText;
import org.lwjgl.glfw.GLFW;

import java.io.DataOutputStream;
import org.reflections.Reflections;

import java.io.File;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;

public class CabbageScapeClient implements ClientModInitializer {
public static String settingsDir = "settings";
public static String version = "a1.4+1.18.2";
public static String version = "a1.4.1+1.18.2";
public static Settings settings;

public static NotificationManager notificationManager;

//Keybinds - F to pay respects
private static KeyBinding debugKey;
public static KeyBinding debugKey;

@Override
public void onInitializeClient() {
debugKey = KeybindHandler.createKeybind("debug_key", "category.cabbagescape", 0);

loadSettings();
VersionChecker.Verify();

notificationManager = new NotificationManager(settings.notificationSettings);

Commands.register();
setupEvents();
EventRegisterer.register();
GroundItemsManager.register();
BarrowsHelper.register();

//PotionTimerManager potionTimerManager = PotionTimerManager.getInstance();

BlockOutlineManager.getInstance().add(PersistentOutlineRenderer.getInstance());

loadEventHandlers();
}

private void loadEventHandlers(){
//Load all event handlers
Reflections reflections = new Reflections("com.cabbagegod.cabbagescape");
Set<Class<? extends EventHandler>> classes = reflections.getSubTypesOf(EventHandler.class);
for (Class handler: classes) {
try {
Constructor<?> hConst = handler.getConstructor();

EventHandler eventHandler = (EventHandler) hConst.newInstance();

eventHandler.start();

Main.LOGGER.info("Started Event: " + eventHandler.getClass().getTypeName());
} catch (NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException ignored) {
}
}
}

//Loads json file as settings
Expand Down Expand Up @@ -99,35 +104,7 @@ public static void saveSettings(){
private void setupEvents(){
ClientTickEvents.END_CLIENT_TICK.register(client -> {
delayedScreenshotQueue();

if(client.world != null) {
checkKeyPress(client);
}
});

ClientPlayConnectionEvents.JOIN.register(((handler, sender, client) -> {
if(VersionChecker.shouldShowUpdate())
client.setScreen(new UpdateScreen());
}));
}

//Is called every client tick to see if a hotkey was pressed
private void checkKeyPress(MinecraftClient client){
assert client.player != null;

if(debugKey.wasPressed()){
NativeImage image = ScreenshotRecorder.takeScreenshot(client.getFramebuffer());
try {
DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd_HH.mm.ss");;
String currentDate = dateFormat.format(LocalDateTime.now());

String screenshotDir = FileUtil.directoryPath + "screenshots/";
FileUtil.CreateNewDirecotryIfNotExists(screenshotDir);
image.writeTo(new File(screenshotDir + currentDate + ".png"));
} catch (IOException exception) {
exception.printStackTrace();
}
}
}

//Allows you to take a screenshot from another thread and or with a delay
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
package com.cabbagegod.cabbagescape.client;

import com.cabbagegod.cabbagescape.data.DataHandler;
import com.cabbagegod.cabbagescape.data.Skill;
import com.cabbagegod.cabbagescape.util.ScreenshotUtil;
import com.cabbagegod.cabbagescape.util.ThreadingUtil;
import net.minecraft.client.MinecraftClient;
import net.minecraft.text.LiteralText;

import java.util.ArrayList;
import java.util.List;

public class LevelUpManager {
private static String lastLevelUpMessage = "";
private static List<Skill> skills;

//These are used for checking if the player has received a level up
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
package com.cabbagegod.cabbagescape.client;

import com.cabbagegod.cabbagescape.data.Settings;
import com.cabbagegod.cabbagescape.github.Release;
import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;

import java.io.IOException;
import java.lang.reflect.Type;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.ArrayList;
import java.util.List;

public class VersionChecker {
private static boolean showUpdate = false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
package com.cabbagegod.cabbagescape.client.barrows;

import com.cabbagegod.cabbagescape.client.CabbageScapeClient;
import com.cabbagegod.cabbagescape.client.blockoutline.PersistentOutlineRenderer;
import com.cabbagegod.cabbagescape.events.DoorUseCallback;
import com.cabbagegod.cabbagescape.callbacks.DoorUseCallback;
import com.cabbagegod.cabbagescape.events.EventHandler;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.minecraft.block.Material;
import net.minecraft.client.MinecraftClient;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.decoration.ArmorStandEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.*;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.text.LiteralText;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;

import java.util.ArrayList;
import java.util.List;

public class BarrowsHelper {
public class BarrowsHelper implements EventHandler {
private static final Bounds BarrowsBounds = new Bounds(new Vec3d(1583,17,-78), new Vec3d(1708,100,48));
private static final Bounds BarrowsUndergroundBounds = new Bounds(new Vec3d(1583,17,-78), new Vec3d(1708,32,48));

private static boolean isInBarrows = false;
private static boolean isInBarrowsUnderground = false;

public static List<BlockPos> trackedDoors = new ArrayList<>();
Expand All @@ -37,7 +35,8 @@ public class BarrowsHelper {
static ArmorStandEntity toragIndicator;
static ArmorStandEntity veracIndicator;

public static void register(){
@Override
public void start() {
ClientTickEvents.END_CLIENT_TICK.register(BarrowsHelper::tickEvent);
DoorUseCallback.EVENT.register(BarrowsHelper::onUseDoor);
}
Expand All @@ -47,7 +46,7 @@ private static void tickEvent(MinecraftClient client) {
assert client.player != null;

//Check if player is in barrows
isInBarrows = BarrowsBounds.isWithinBounds(client.player.getPos());
boolean isInBarrows = BarrowsBounds.isWithinBounds(client.player.getPos());
isInBarrowsUnderground = BarrowsUndergroundBounds.isWithinBounds(client.player.getPos());

if(isInBarrows) {
Expand Down Expand Up @@ -120,6 +119,9 @@ private static void onUseDoor(PlayerEntity player, BlockPos pos){
assert MinecraftClient.getInstance().player != null;

if(isInBarrowsUnderground){
if(!CabbageScapeClient.settings.barrowsHelperSettings.doorMarkers)
return;

if(!trackedDoors.contains(pos)) {
trackedDoors.add(pos);
PersistentOutlineRenderer.getInstance().addPos(pos);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.cabbagegod.cabbagescape.client.blockoutline;

import com.cabbagegod.cabbagescape.client.CabbageScapeClient;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.Camera;
import net.minecraft.client.util.math.MatrixStack;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.cabbagegod.cabbagescape.client.cluetracker;

import net.fabricmc.loader.impl.lib.sat4j.core.Vec;
import net.minecraft.client.util.math.Vector3d;

public class ClueStep {
Expand Down
Loading

0 comments on commit 37e03e6

Please sign in to comment.