Skip to content

Commit

Permalink
refactor: Support for L2Tabs and multiple fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Senior-S committed Aug 17, 2024
1 parent ca7ed96 commit 57848c2
Show file tree
Hide file tree
Showing 16 changed files with 137 additions and 44 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.8
1.0.9
24 changes: 18 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,18 @@ repositories {
name 'Xander Maven'
url 'https://maven.isxander.dev/releases'
}
// Tetra, PointBlank, Tac:Zero & MrCrayfish's Gun Mod
// Tetra, PointBlank, Tac:Zero, MrCrayfish's Gun Mod & ScorchedGuns 2
maven {
url "https://cursemaven.com"
content {
includeGroup "curse.maven"
}
}

// L2 Tabs
flatDir{
dirs 'libs'
}
}

dependencies {
Expand All @@ -165,6 +170,10 @@ dependencies {
jarJar.ranged(it, "[0.4.0,)")
}

// L2
compileOnly fg.deobf("dev.xkmc.l2library:l2library:2.4.28")
compileOnly fg.deobf("dev.xkmc.l2tabs:l2tabs:0.3.1")

// ClothConfig implementation (Required by BetterCombat)
implementation fg.deobf("me.shedaniel.cloth:cloth-config-forge:11.1.118")

Expand All @@ -183,21 +192,24 @@ dependencies {
implementation fg.deobf("dev.isxander:yet-another-config-lib:3.4.2+1.20.1-forge")
compileOnly(fg.deobf("dev.isxander:yet-another-config-lib:3.4.2+1.20.1-forge"))

// Tetra implementation
// Tetra compatibility
compileOnly fg.deobf("curse.maven:tetra-289712:${tetra_version}")
compileOnly fg.deobf("curse.maven:tetra-351914:${mutil_version}")

// PointBlank implementation
// PointBlank compatibility
compileOnly fg.deobf("curse.maven:vics-point-blank-961053:5541544")

// Timeless and classics: zero implementation
// Timeless and classics: zero compatibility
compileOnly fg.deobf("curse.maven:timeless-and-classics-zero-1028108:5529117")

// MrCrayfish's Gun Mod implementation
// MrCrayfish's Gun Mod compatibility
compileOnly fg.deobf("curse.maven:mrcrayfishs-gun-mod-unofficial-945471:5212457")
runtimeOnly fg.deobf("curse.maven:framework-549225:5388226")

// Iron's Spells 'n Spellbooks implementation
// Scorched Guns 2 compatibility
compileOnly fg.deobf("curse.maven:scorched-guns-802940:5630448")

// Iron's Spells 'n Spellbooks compatibility
compileOnly fg.deobf("curse.maven:irons-spells-n-spellbooks-855414:5539243")
runtimeOnly fg.deobf("curse.maven:caelus-308989:5281700")

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ mod_name=JustLevelingFork
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=APACHE
# The mod version. See https://semver.org/
mod_version=1.0.8
mod_version=1.0.9
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
# This should match the base package used for the mod sources.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
Expand Down
14 changes: 11 additions & 3 deletions src/main/java/com/seniors/justlevelingfork/JustLevelingClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
import com.mojang.blaze3d.platform.InputConstants;
import com.seniors.justlevelingfork.client.gui.OverlayAptitudeGui;
import com.seniors.justlevelingfork.client.gui.OverlayTitleGui;
import com.seniors.justlevelingfork.client.gui.TabJustLeveling;
import com.seniors.justlevelingfork.client.screen.JustLevelingScreen;
import com.seniors.justlevelingfork.handler.HandlerCommonConfig;
import com.seniors.justlevelingfork.integration.CrayfishGunModIntegration;
import com.seniors.justlevelingfork.integration.L2TabsIntegration;
import com.seniors.justlevelingfork.registry.RegistryClientEvents;
import com.seniors.justlevelingfork.registry.RegistryItems;
import dev.xkmc.l2tabs.tabs.core.TabRegistry;
import net.minecraft.client.KeyMapping;
import net.minecraft.client.Minecraft;
import net.minecraft.network.chat.Component;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.ConfigScreenHandler;
import net.minecraftforge.client.event.InputEvent;
Expand Down Expand Up @@ -49,8 +53,12 @@ public static void clientSetup(FMLClientSetupEvent event) {
MinecraftForge.EVENT_BUS.register(new RegistryClientEvents());
MinecraftForge.EVENT_BUS.register(new OverlayAptitudeGui());
MinecraftForge.EVENT_BUS.register(new OverlayTitleGui());
if (CrayfishGunModIntegration.isModLoaded())
MinecraftForge.EVENT_BUS.register(new CrayfishGunModIntegration());

if (L2TabsIntegration.isModLoaded()) {
event.enqueueWork(() -> {
TabRegistry.registerTab(3500, TabJustLeveling::new, RegistryItems.LEVELING_BOOK, Component.literal("Aptitudes"));
});
}
}

@SubscribeEvent
Expand Down
19 changes: 13 additions & 6 deletions src/main/java/com/seniors/justlevelingfork/JustLevelingFork.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
import com.seniors.justlevelingfork.handler.HandlerConfigCommon;
import com.seniors.justlevelingfork.handler.HandlerCurios;
import com.seniors.justlevelingfork.handler.HandlerLockItemsConfig;
import com.seniors.justlevelingfork.integration.CrayfishGunModIntegration;
import com.seniors.justlevelingfork.integration.IronsSpellsbooksIntegration;
import com.seniors.justlevelingfork.integration.ScorchedGuns2Integration;
import com.seniors.justlevelingfork.integration.TacZIntegration;
import com.seniors.justlevelingfork.network.ServerNetworking;
import com.seniors.justlevelingfork.registry.*;
Expand All @@ -23,7 +25,7 @@
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.fml.loading.moddiscovery.ModInfo;
import net.minecraftforge.forgespi.language.IModInfo;
import org.apache.commons.lang3.text.WordUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.MutablePair;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
Expand Down Expand Up @@ -71,16 +73,21 @@ public JustLevelingFork() {
MinecraftForge.EVENT_BUS.register(new HandlerCurios());
if (TacZIntegration.isModLoaded())
MinecraftForge.EVENT_BUS.register(new TacZIntegration());
if (CrayfishGunModIntegration.isModLoaded())
MinecraftForge.EVENT_BUS.register(new CrayfishGunModIntegration());
if (ScorchedGuns2Integration.isModLoaded())
MinecraftForge.EVENT_BUS.register(new ScorchedGuns2Integration());
if (IronsSpellsbooksIntegration.isModLoaded())
MinecraftForge.EVENT_BUS.register(new IronsSpellsbooksIntegration());

ServerNetworking.init();

// Check for new updates
if (HandlerCommonConfig.HANDLER.instance().checkForUpdates) {
try {
String version = getLatestVersion();

Optional<IModInfo> optionalModInfo = ModList.get().getMods().stream().filter(c -> Objects.equals(c.getModId(), this.MOD_ID)).findFirst();
Optional<IModInfo> optionalModInfo = ModList.get().getMods().stream().filter(c -> Objects.equals(c.getModId(), MOD_ID)).findFirst();

// Is this somehow isn't present then some really strange shit happen
if (optionalModInfo.isPresent()) {
Expand All @@ -91,8 +98,8 @@ public JustLevelingFork() {
LOGGER.info(">> NEW VERSION AVAILABLE: {}", version);
}
}
} catch (IOException e) {
throw new RuntimeException(e);
} catch (Exception e) {
LOGGER.warn(">> Error checking for updates!");
}
}
}
Expand Down Expand Up @@ -164,7 +171,7 @@ public static void migrateOldConfig() {
}

LockItem.Aptitude aptitude = new LockItem.Aptitude();
aptitude.Aptitude = EAptitude.valueOf(WordUtils.capitalizeFully(aptitudePath));
aptitude.Aptitude = EAptitude.valueOf(StringUtils.capitalize(aptitudePath));
aptitude.Level = Integer.parseInt(aptitudeValues[1]);

aptitudes.add(aptitude);
Expand All @@ -187,4 +194,4 @@ public static void migrateOldConfig() {
HandlerCommonConfig.HANDLER.instance().usingNewConfig = true;
HandlerCommonConfig.HANDLER.save();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.seniors.justlevelingfork.client.gui;

import com.seniors.justlevelingfork.client.core.Utils;
import com.seniors.justlevelingfork.client.screen.JustLevelingScreen;
import dev.xkmc.l2tabs.tabs.core.BaseTab;
import dev.xkmc.l2tabs.tabs.core.TabManager;
import dev.xkmc.l2tabs.tabs.core.TabToken;
import net.minecraft.client.Minecraft;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.ItemStack;

public class TabJustLeveling extends BaseTab<TabJustLeveling> {

public TabJustLeveling(TabToken<TabJustLeveling> token, TabManager manager, ItemStack stack, Component title){
super(token, manager, stack, title);
}

@Override
public void onTabClicked() {
Utils.playSound();
Minecraft.getInstance().setScreen(new JustLevelingScreen());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,8 @@ public void drawSkills(GuiGraphics matrixStack, int x, int y, int mouseX, int mo
matrixStack.blit(HandlerResources.SKILL_PAGE[this.selectedPage], x + 153, y + 14, 177 + j, 1, 6, 6);

boolean canLevelUpAptitude = (client.player.isCreative()
|| AptitudeLevelUpSP.requiredPoints(aptitudeLevel) <= client.player.totalExperience);
|| AptitudeLevelUpSP.requiredPoints(aptitudeLevel) <= client.player.totalExperience
|| AptitudeLevelUpSP.requiredLevels(aptitudeLevel) <= client.player.experienceLevel);
if (Utils.checkMouse(x + 149, y + 10, mouseX, mouseY, 14, 14)) {
if (AptitudeCapability.get(client.player).getGlobalLevel() >= HandlerCommonConfig.HANDLER.instance().playersMaxGlobalLevel) {
Utils.drawToolTip(matrixStack,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ public static void register(CommandDispatcher<CommandSourceStack> dispatcher) {
}

private static int execute(CommandContext<CommandSourceStack> command) throws CommandSyntaxException {
if(command.getSource().getEntity() instanceof Player player) {
if (command.getSource().getEntity() instanceof Player player) {
ItemStack stack = player.getMainHandItem();
if (stack == ItemStack.EMPTY || stack.isEmpty()){
if (stack == ItemStack.EMPTY || stack.isEmpty()) {
player.sendSystemMessage(Component.literal("No item detected in main hand!"));
return Command.SINGLE_SUCCESS;
}
Expand All @@ -44,9 +44,12 @@ private static int execute(CommandContext<CommandSourceStack> command) throws Co
Integer level = command.getArgument("level", Integer.class);

Optional<LockItem> optionalLockItem = HandlerLockItemsConfig.HANDLER.instance().lockItemList.stream().filter(c -> c.Item.equalsIgnoreCase(location.toString())).findFirst();
if(optionalLockItem.isPresent()){
if (optionalLockItem.isPresent()) {
LockItem lockItem = optionalLockItem.get();
int index = HandlerLockItemsConfig.HANDLER.instance().lockItemList.indexOf(lockItem);

lockItem.Aptitudes.stream().filter(c -> c.Aptitude.toString().equalsIgnoreCase(aptitudeName)).findFirst().ifPresent(value -> lockItem.Aptitudes.remove(value));

lockItem.Aptitudes.add(new LockItem.Aptitude(aptitudeName, level));

HandlerLockItemsConfig.HANDLER.instance().lockItemList.set(index, lockItem);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.seniors.justlevelingfork.config.models;

import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
Expand Down Expand Up @@ -64,14 +66,10 @@ public static class Aptitude {
public int Level;

public Aptitude(String aptitudeName, int level) {
Aptitude = EAptitude.valueOf(CapitalizeString(aptitudeName));
Aptitude = EAptitude.valueOf(StringUtils.capitalize(aptitudeName));
Level = level;
}

private String CapitalizeString(String str) {
return str.substring(0, 1).toUpperCase() + str.substring(1);
}

public Aptitude() {
Aptitude = EAptitude.Strength;
Level = 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import net.minecraft.world.entity.EntityType;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.RegistryObject;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -74,7 +75,7 @@ public boolean CheckRequirements(ServerPlayer serverPlayer) {
int value = 0;

try {
conditionType = EConditionType.valueOf(CapitalizeString(split[0]));
conditionType = EConditionType.valueOf(StringUtils.capitalize(split[0]));
comparator = EComparator.valueOf(split[2].toUpperCase());
if (conditionType != EConditionType.Special) {
value = Integer.parseInt(split[3]);
Expand All @@ -90,7 +91,7 @@ public boolean CheckRequirements(ServerPlayer serverPlayer) {
switch (conditionType) {
case Aptitude:
try {
EAptitude aptitude = EAptitude.valueOf(CapitalizeString(split[1]));
EAptitude aptitude = EAptitude.valueOf(StringUtils.capitalize(split[1]));
int aptitudeLevel = AptitudeCapability.get(serverPlayer).getAptitudeLevel(RegistryAptitudes.getAptitude(aptitude.toString()));

if (Compare(aptitudeLevel, value, comparator)) {
Expand Down Expand Up @@ -149,10 +150,6 @@ private Title register(String name, boolean requirement) {
return new Title(key, requirement, this.HideRequirements);
}

private String CapitalizeString(String str) {
return str.substring(0, 1).toUpperCase() + str.substring(1);
}

private boolean Compare(int a, int b, EComparator comparator) {
return switch (comparator) {
case EQUALS -> a == b;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.seniors.justlevelingfork.integration;

import net.minecraftforge.fml.ModList;

public class L2TabsIntegration {

public static boolean isModLoaded() {
return ModList.get().isLoaded("l2tabs");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.seniors.justlevelingfork.integration;

import com.seniors.justlevelingfork.common.capability.AptitudeCapability;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.eventbus.api.EventPriority;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.ModList;
import top.ribs.scguns.event.GunFireEvent;

public class ScorchedGuns2Integration {

public static boolean isModLoaded() {
return ModList.get().isLoaded("scguns");
}

@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onGunFireEvent(GunFireEvent.Pre event){
Player player = event.getEntity();

if (!player.isCreative()) {
ItemStack itemStack = event.getStack();
AptitudeCapability provider = AptitudeCapability.get(player);
if (!provider.canUseItemClient(itemStack)) {
event.setCanceled(true);
}
}
}

}
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package com.seniors.justlevelingfork.mixin;

import com.mojang.blaze3d.systems.RenderSystem;
import com.seniors.justlevelingfork.JustLevelingFork;
import com.seniors.justlevelingfork.client.core.Utils;
import com.seniors.justlevelingfork.client.gui.DrawTabs;
import com.seniors.justlevelingfork.integration.L2TabsIntegration;
import com.seniors.justlevelingfork.network.packet.common.OpenEnderChestSP;
import com.seniors.justlevelingfork.registry.RegistrySkills;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.inventory.EffectRenderingInventoryScreen;
import net.minecraft.client.gui.screens.inventory.InventoryScreen;
Expand Down Expand Up @@ -39,6 +40,10 @@ public MixInventoryScreen(Player player) {

@Inject(method = {"renderBg"}, at = {@At("TAIL")})
private void render(GuiGraphics matrixStack, float delta, int mouseX, int mouseY, CallbackInfo info) {
if(L2TabsIntegration.isModLoaded()){
return;
}

DrawTabs.render(matrixStack, mouseX, mouseY, 176, 166, getRecipeBookComponent().isVisible() ? 77 : 0);

if (RegistrySkills.WORMHOLE_STORAGE.get().isEnabled()) {
Expand Down Expand Up @@ -66,16 +71,16 @@ private void render(GuiGraphics matrixStack, float delta, int mouseX, int mouseY

@Inject(method = {"mouseClicked"}, at = {@At("HEAD")})
private void mouseClicked(double mouseX, double mouseY, int button, CallbackInfoReturnable<Boolean> info) {
if(L2TabsIntegration.isModLoaded()){
return;
}
if (button == 0 && this.this$isMouseCheck) this.this$checkMouse = true;
DrawTabs.mouseClicked(button);
}


public void onClose() {
this.this$checkMouse = false;
DrawTabs.onClose();
super.onClose();
}
}


Loading

0 comments on commit 57848c2

Please sign in to comment.