Skip to content

Commit

Permalink
backup cause i almost lost it that was terrifying
Browse files Browse the repository at this point in the history
  • Loading branch information
GrahamKracker committed Dec 28, 2024
1 parent 197835a commit b85fba3
Show file tree
Hide file tree
Showing 45 changed files with 1,625 additions and 743 deletions.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void recalculate() {
calculate.ifSuccess(this::finishRecalculation).ifError(errorMessage -> {
CookiesUtils.sendFailedMessage(Optional.ofNullable(errorMessage)
.orElse("An error occurred while evaluating the recipe tree."));
CraftHelperManager.remove();
//CraftHelperManager.remove();
});
}

Expand Down Expand Up @@ -131,13 +131,13 @@ public void render(DrawContext drawContext, int x, int y, int mouseX, int mouseY

final ArrayList<TooltipComponent> craftHelperComponents = new ArrayList<>(list);
craftHelperComponents.addFirst(new SpacerComponent(0, width));
drawContext.drawTooltip(
/*drawContext.drawTooltip(
MinecraftClient.getInstance().textRenderer,
craftHelperComponents,
lastX,
lastY,
CraftHelperTooltipPositioner.INSTANCE,
null);
null);*/

final Optional<Pair<CraftHelperComponentPart, Integer>> textUnder = getTextUnder(mouseX, mouseY, list);
if (textUnder.isPresent()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@

import codes.cookies.mod.config.ConfigManager;
import codes.cookies.mod.events.api.ScreenKeyEvents;
import codes.cookies.mod.features.crafthelper.CraftHelperLocation;
import codes.cookies.mod.repository.RepositoryItem;
import codes.cookies.mod.utils.SkyblockUtils;
import codes.cookies.mod.utils.accessors.InventoryScreenAccessor;
import codes.cookies.mod.utils.compatibility.legendarytooltips.LegendaryTooltips;
import lombok.Getter;
import lombok.Setter;

import org.jetbrains.annotations.NotNull;
import org.joml.Vector2ic;

Expand All @@ -29,12 +31,13 @@ public class CraftHelperManager {
@NotNull
@Getter
private static CraftHelperInstance active = CraftHelperInstance.EMPTY;
private static CraftHelperLocation location;
public static CraftHelperLocation location;

public static void init() {
location = ConfigManager.getConfig().helpersConfig.craftHelper.craftHelperLocation.getValue();
ConfigManager.getConfig().helpersConfig.craftHelper.craftHelperLocation.withCallback((oldValue, newValue) -> location = newValue);
ScreenEvents.AFTER_INIT.register((client, screen, scaledWidth, scaledHeight) -> {
active = CraftHelperInstance.EMPTY;
if (!(screen instanceof InventoryScreenAccessor)) {
return;
}
Expand All @@ -48,16 +51,16 @@ public static void init() {
active.recalculate();
}

ScreenEvents.afterRender(screen).register(CraftHelperListener::onRender);
/*ScreenEvents.afterRender(screen).register(CraftHelperListener::onRender);
ScreenMouseEvents.allowMouseClick(screen).register(CraftHelperListener::onMouseClick);
ScreenMouseEvents.allowMouseScroll(screen).register(CraftHelperListener::onMouseScroll);
ScreenKeyboardEvents.allowKeyPress(screen).register(CraftHelperListener::onKeyPressed);
ScreenKeyboardEvents.allowKeyRelease(screen).register(CraftHelperListener::onKeyReleased);
ScreenKeyEvents.getExtension(screen).cookies$allowCharTyped().register(CraftHelperListener::onCharTyped);
ScreenKeyEvents.getExtension(screen).cookies$allowCharTyped().register(CraftHelperListener::onCharTyped);*/
});
}

public static void pushNewCraftHelperItem(RepositoryItem repositoryItem, int amount) {
/*public static void pushNewCraftHelperItem(RepositoryItem repositoryItem, int amount) {
active = new CraftHelperInstance(repositoryItem, amount, new ArrayList<>());
active.recalculate();
}
Expand All @@ -72,8 +75,6 @@ private interface CraftHelperListener {
private static int calculateX(Screen screen) {
return switch (CraftHelperManager.location) {
case LEFT -> 0;
case LEFT_INVENTORY -> InventoryScreenAccessor.getX(screen) - 1;
case RIGHT_INVENTORY -> InventoryScreenAccessor.getX(screen) + 1;
case RIGHT -> screen.width;
};
}
Expand Down Expand Up @@ -154,5 +155,5 @@ static boolean onCharTyped(Screen screen, char chr, int modifiers) {
return getCurrent().map(instance -> !instance.onCharTyped(chr, modifiers)).orElse(true);
}
}

*/
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import codes.cookies.mod.CookiesMod;
import codes.cookies.mod.features.misc.utils.crafthelper.CraftHelperInstance;
import codes.cookies.mod.features.misc.utils.crafthelper.CraftHelperManager;
import codes.cookies.mod.features.misc.utils.crafthelper.CraftHelperPlacement;
import codes.cookies.mod.features.crafthelper.CraftHelperPlacement;
import codes.cookies.mod.repository.RepositoryItem;
import codes.cookies.mod.utils.RenderUtils;
import codes.cookies.mod.utils.cookies.Constants;
Expand Down Expand Up @@ -49,7 +49,7 @@ public HeadingPart(
this.formattedName = CraftHelperText.of(createHeading());
this.close = CraftHelperText.of(Text.empty().append(createMove()).append(" ").append(createClose()));
this.amountText = CraftHelperText.of(createAmount());
this.tooltipField = new TooltipFieldPart(5,5, 18, 18);
this.tooltipField = new TooltipFieldPart(5, 5, 18, 18);
this.tooltipField.setHoverText(getLore());
}

Expand All @@ -64,7 +64,7 @@ public HeadingPart(RepositoryItem repositoryItem, CraftHelperInstance craftHelpe

private void pressedClose() {
SoundUtils.playSound(SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP);
CraftHelperManager.remove();
//CraftHelperManager.remove();
}

@Override
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
package codes.cookies.mod.commands.dev.debug;

import codes.cookies.mod.features.crafthelper.CraftHelperPlacementScreen;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import codes.cookies.mod.CookiesMod;
import codes.cookies.mod.commands.system.ClientCommand;
import codes.cookies.mod.features.misc.utils.crafthelper.CraftHelperPlacement;

import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;

import org.jetbrains.annotations.NotNull;

public class OpenCraftHelperPlacementScreen extends ClientCommand {

@Override
public @NotNull LiteralArgumentBuilder<FabricClientCommandSource> getCommand() {
return literal("openCraftHelperPlacementScreen").executes(run(this::openScreen));
}
@Override
public @NotNull LiteralArgumentBuilder<FabricClientCommandSource> getCommand() {
return literal("openCraftHelperPlacementScreen").executes(run(this::openScreen));
}

private void openScreen() {
CookiesMod.openScreen(new CraftHelperPlacement());
}
private void openScreen() {
CookiesMod.openScreen(new CraftHelperPlacementScreen());
}
}
Original file line number Diff line number Diff line change
@@ -1,49 +1,53 @@
package codes.cookies.mod.commands.dev.debug;

import codes.cookies.mod.features.crafthelper.CraftHelperManager;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.context.CommandContext;
import codes.cookies.mod.commands.arguments.RealIdentifierArgument;
import codes.cookies.mod.commands.system.ClientCommand;
import codes.cookies.mod.features.misc.utils.crafthelper.CraftHelperManager;
import codes.cookies.mod.repository.RepositoryItem;

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

import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;

import net.minecraft.util.Identifier;

import org.jetbrains.annotations.NotNull;

/**
*
*/
public class SetSelectedCraftHelperItemDebugCommand extends ClientCommand {
@Override
public @NotNull LiteralArgumentBuilder<FabricClientCommandSource> getCommand() {
List<Identifier> identifiers = new ArrayList<>();
RepositoryItem.getItemMap().keySet().forEach(
item -> identifiers.add(
Identifier.of("skyblock", item.replace(":", "/").replace("-", "/").replace(";", "/").toLowerCase(Locale.ROOT))
)
);

return literal("setSelectedCraftHelperItem")
.then(
argument(
"item",
new RealIdentifierArgument(identifiers)
).executes(run(this::setSelectedItem))
);
}

private void setSelectedItem(CommandContext<FabricClientCommandSource> context) {
final Identifier item = context.getArgument("item", Identifier.class);
final RepositoryItem repositoryItem = RepositoryItem.of(item.getPath());

if (repositoryItem != null) {
CraftHelperManager.pushNewCraftHelperItem(repositoryItem, 1);
sendSuccessMessage("Switched to item " + item);
} else {
sendFailedMessage("Could not find item " + item.getPath());
}
}
@Override
public @NotNull LiteralArgumentBuilder<FabricClientCommandSource> getCommand() {
List<Identifier> identifiers = new ArrayList<>();
RepositoryItem.getItemMap().keySet().forEach(
item -> identifiers.add(
Identifier.of("skyblock", item.replace(":", "/").replace("-", "/").replace(";", "/").toLowerCase(Locale.ROOT))
)
);

return literal("setSelectedCraftHelperItem")
.then(
argument(
"item",
new RealIdentifierArgument(identifiers)
).executes(run(this::setSelectedItem))
);
}

private void setSelectedItem(CommandContext<FabricClientCommandSource> context) {
final Identifier item = context.getArgument("item", Identifier.class);
final RepositoryItem repositoryItem = RepositoryItem.of(item.getPath());

if (repositoryItem != null) {
CraftHelperManager.pushNewCraftHelperItem(repositoryItem, 1);
sendSuccessMessage("Switched to item " + item);
} else {
sendFailedMessage("Could not find item " + item.getPath());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import codes.cookies.mod.config.system.options.EnumCycleOption;
import codes.cookies.mod.config.system.options.SliderOption;
import codes.cookies.mod.data.profile.items.ItemSources;
import codes.cookies.mod.features.misc.utils.crafthelper.CraftHelperLocation;
import codes.cookies.mod.features.misc.utils.crafthelper.CraftHelperPlacement;
import codes.cookies.mod.features.crafthelper.CraftHelperLocation;
import codes.cookies.mod.features.crafthelper.CraftHelperPlacementScreen;

import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
Expand All @@ -26,21 +26,21 @@
public class HelpersConfig extends Category {


public BooleanOption anvilHelper = new BooleanOption(CONFIG_HELPERS_ANVIL_HELPER, false);
public BooleanOption anvilHelper = new BooleanOption(CONFIG_HELPERS_ANVIL_HELPER, false);

public BooleanOption itemChestTracker = new BooleanOption(CONFIG_HELPERS_CHEST_TRACKER, true);
public BooleanOption itemChestTracker = new BooleanOption(CONFIG_HELPERS_CHEST_TRACKER, true);

public CraftHelperFoldable craftHelper = new CraftHelperFoldable();

@Hidden
public SliderOption<Integer> craftHelperSlot = SliderOption.integerOption("", 14);
@Hidden
public SliderOption<Integer> craftHelperSlot = SliderOption.integerOption("", 14);

public class CraftHelperFoldable extends Foldable {
public BooleanOption craftHelper = new BooleanOption(CONFIG_HELPERS_CRAFT_HELPER_SETTING, true);

@Hidden
public EnumCycleOption<CraftHelperLocation> craftHelperLocation =
new EnumCycleOption<>("", CraftHelperLocation.RIGHT_INVENTORY);
new EnumCycleOption<>("", CraftHelperLocation.RIGHT);

public ButtonOption openCraftHelperLocationEditor = new ButtonOption(CONFIG_HELPERS_CRAFT_HELPER_LOCATIONS,
this::openCraftHelperEditor,
Expand Down Expand Up @@ -99,7 +99,7 @@ public String getName() {
}

private void openCraftHelperEditor() {
CookiesMod.openScreen(new CraftHelperPlacement());
CookiesMod.openScreen(new CraftHelperPlacementScreen());
}

@Override
Expand All @@ -110,16 +110,16 @@ public String getName() {


public HelpersConfig() {
super(new ItemStack(Items.SCAFFOLDING), CONFIG_HELPERS);
}

@Override
public Row getRow() {
return Row.BOTTOM;
}

@Override
public int getColumn() {
return 0;
}
super(new ItemStack(Items.SCAFFOLDING), CONFIG_HELPERS);
}

@Override
public Row getRow() {
return Row.BOTTOM;
}

@Override
public int getColumn() {
return 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
import java.util.Optional;
import java.util.function.Predicate;

import com.mojang.serialization.Codec;
import codes.cookies.mod.features.misc.utils.crafthelper.CraftHelperInstance;
import codes.cookies.mod.features.misc.utils.crafthelper.CraftHelperManager;
import codes.cookies.mod.features.crafthelper.CraftHelperItem;
import codes.cookies.mod.utils.json.CodecJsonSerializable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class CraftHelperData implements CodecJsonSerializable<CraftHelperInstance> {
//todo
public class CraftHelperData { /*implements CodecJsonSerializable<CraftHelperInstance> {
public CraftHelperData() {
CraftHelperManager.remove();
CraftHelperManager.setActive(CraftHelperInstance.EMPTY);
}
private static final Logger LOGGER = LoggerFactory.getLogger(CraftHelperData.class);
Expand All @@ -25,7 +24,8 @@ public Codec<CraftHelperInstance> getCodec() {
@Override
public void load(CraftHelperInstance value) {
CraftHelperManager.setActive(value);
codes.cookies.mod.features.misc.utils.crafthelper.CraftHelperManager.setActive(value);
codes.cookies.mod.features.crafthelper.CraftHelperManager.pushNewCraftHelperItem(new CraftHelperItem(value.getRepositoryItem()));
}
@Override
Expand All @@ -38,5 +38,5 @@ public CraftHelperInstance getValue() {
@Override
public Logger getLogger() {
return LOGGER;
}
}*/
}
Loading

0 comments on commit b85fba3

Please sign in to comment.