Skip to content

Commit

Permalink
feat: KubeJS support, ConvergenceItems moved to their own file, disab…
Browse files Browse the repository at this point in the history
…led skills removed from GUI.

fix: some bugs related to locked items.
  • Loading branch information
Senior-S committed Sep 3, 2024
1 parent c7ec5d3 commit 513792d
Show file tree
Hide file tree
Showing 25 changed files with 253 additions and 96 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.0
1.1.1
28 changes: 23 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -149,22 +149,39 @@ repositories {
}
}

// KubeJS
maven {
// Shedaniel's maven (Architectury API)
url = "https://maven.architectury.dev"
content {
includeGroup "dev.architectury"
}
}
maven {
// saps.dev Maven (KubeJS and Rhino)
url = "https://maven.saps.dev/minecraft"
content {
includeGroup "dev.latvian.mods"
}
}

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

dependencies {
// Specify the version of Minecraft to use.
// Any artifact can be supplied so long as it has a "userdev" classifier artifact and is a compatible patcher artifact.
// The "userdev" classifier will be requested and setup by ForgeGradle.
// If the group id is "net.minecraft" and the artifact id is one of ["client", "server", "joined"],
// then special handling is done to allow a setup of a vanilla dependency without the use of an external repository.
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"

annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'

// KubeJS
implementation fg.deobf("dev.latvian.mods:kubejs-forge:${kubejs_version}")
implementation fg.deobf("dev.latvian.mods:rhino-forge:${rhino_version}")
implementation fg.deobf("dev.architectury:architectury-forge:${architectury_version}")

// Mixin Extras
compileOnly(annotationProcessor("io.github.llamalad7:mixinextras-common:0.4.0"))
implementation(jarJar("io.github.llamalad7:mixinextras-forge:0.4.0")) {
jarJar.ranged(it, "[0.4.0,)")
Expand Down Expand Up @@ -213,6 +230,7 @@ dependencies {
compileOnly fg.deobf("curse.maven:irons-spells-n-spellbooks-855414:5539243")
runtimeOnly fg.deobf("curse.maven:caelus-308989:5281700")

// Gecko Lib compatibility
runtimeOnly fg.deobf("curse.maven:geckolib-388172:5460309")
}

Expand Down
6 changes: 5 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ mapping_channel=official
# This must match the format required by the mapping channel.
mapping_version=1.20.1

# KubeJS
kubejs_version=2001.6.5-build.14
rhino_version=2001.2.2-build.17
architectury_version=9.1.12

# The unique mod identifier for the mod. Must be lowercase in English locale. Must fit the regex [a-z][a-z0-9_]{1,63}
# Must match the String constant located in the main mod class annotated with @Mod.
Expand All @@ -43,7 +47,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.1.0
mod_version=1.1.1
# 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
10 changes: 5 additions & 5 deletions src/main/java/com/seniors/justlevelingfork/JustLevelingFork.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import com.seniors.justlevelingfork.config.Configuration;
import com.seniors.justlevelingfork.config.models.EAptitude;
import com.seniors.justlevelingfork.config.models.LockItem;
import com.seniors.justlevelingfork.handler.*;
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.handler.HandlerCommonConfig;
import com.seniors.justlevelingfork.handler.HandlerConfigCommon;
import com.seniors.justlevelingfork.handler.HandlerCurios;
import com.seniors.justlevelingfork.handler.HandlerLockItemsConfig;
import com.seniors.justlevelingfork.integration.*;
import com.seniors.justlevelingfork.network.ServerNetworking;
import com.seniors.justlevelingfork.registry.*;
import com.seniors.justlevelingfork.registry.aptitude.Aptitude;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public static void Init() {
Path clientConfigPath = Paths.get("JLFork").resolve("just_leveling-client.toml");
ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, HandlerConfigClient.SPEC, clientConfigPath.toString());

HandlerConvergenceItemsConfig.HANDLER.load();

LoadDefaultTitles();
ManageOldConfig();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.seniors.justlevelingfork.config.models;

import com.seniors.justlevelingfork.JustLevelingFork;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;

public class LockItem {

Expand Down Expand Up @@ -52,7 +54,15 @@ private static LockItem formatString(String value) {

@Override
public String toString() {
List<String> strings = Aptitudes.stream().map(Aptitude::toString).toList();
if(Aptitudes.stream().anyMatch(Objects::isNull)){
JustLevelingFork.getLOGGER().info(">> Found null aptitude at item {}", this.Item);
}
List<String> strings = new ArrayList<>();
try{
strings = Aptitudes.stream().map(Aptitude::toString).toList();
} catch (NullPointerException e){
JustLevelingFork.getLOGGER().info(">> Found null aptitude at item {}", this.Item);
}

String aptitudeStringList = String.join(";", strings);

Expand All @@ -66,7 +76,12 @@ public static class Aptitude {
public int Level;

public Aptitude(String aptitudeName, int level) {
Aptitude = EAptitude.valueOf(StringUtils.capitalize(aptitudeName));
try {
Aptitude = EAptitude.valueOf(StringUtils.capitalize(aptitudeName));
} catch (IllegalArgumentException e){
JustLevelingFork.getLOGGER().info(">> Wrong aptitude name {}", aptitudeName);
Aptitude = EAptitude.Strength;
}
Level = level;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,6 @@ public class HandlerCommonConfig {
@IntField(min = 1, max = 10000)
public int convergenceProbability = 8;

@SerialEntry(comment = "Convergence skill convergence item list")
@ListGroup(controllerFactory = StringListGroup.class, valueFactory = StringListGroup.class)
public List<String> convergenceItemList = List.of();

@SerialEntry(comment = "Life Eater skill life steal amplifier increase")
@AutoGen(category = "common", group = "skills")
@FloatField(min = 0.0f, max = 10000.0f)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.seniors.justlevelingfork.handler;

import com.google.gson.GsonBuilder;
import com.seniors.justlevelingfork.JustLevelingFork;
import com.seniors.justlevelingfork.config.Configuration;
import com.seniors.justlevelingfork.config.StringListGroup;
import dev.isxander.yacl3.config.v2.api.ConfigClassHandler;
import dev.isxander.yacl3.config.v2.api.SerialEntry;
import dev.isxander.yacl3.config.v2.api.autogen.ListGroup;
import dev.isxander.yacl3.config.v2.api.serializer.GsonConfigSerializerBuilder;
import net.minecraft.resources.ResourceLocation;

import java.util.List;

public class HandlerConvergenceItemsConfig {
public static ConfigClassHandler<HandlerConvergenceItemsConfig> HANDLER = ConfigClassHandler.createBuilder(HandlerConvergenceItemsConfig.class)
.id(new ResourceLocation(JustLevelingFork.MOD_ID, "config"))
.serializer(config -> GsonConfigSerializerBuilder.create(config)
.setPath(Configuration.getAbsoluteDirectory().resolve("justleveling-fork.convergence-items.json5"))
.appendGsonBuilder(GsonBuilder::setPrettyPrinting)
.setJson5(true)
.build())
.build();

@SerialEntry(comment = "Convergence skill convergence item list")
@ListGroup(controllerFactory = StringListGroup.class, valueFactory = StringListGroup.class)
public List<String> convergenceItemList = List.of();
}
14 changes: 14 additions & 0 deletions src/main/java/com/seniors/justlevelingfork/kubejs/Plugin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.seniors.justlevelingfork.kubejs;

import com.seniors.justlevelingfork.client.core.ValueType;
import dev.latvian.mods.kubejs.KubeJSPlugin;
import dev.latvian.mods.kubejs.script.BindingsEvent;

public class Plugin extends KubeJSPlugin {

@Override
public void registerBindings(BindingsEvent event) {
super.registerBindings(event);
event.add("ValueType", ValueType.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ private void render(GuiGraphics matrixStack, float delta, int mouseX, int mouseY

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

if (RegistrySkills.WORMHOLE_STORAGE.get().isEnabled()) {
if (RegistrySkills.WORMHOLE_STORAGE != null && RegistrySkills.WORMHOLE_STORAGE.get().isEnabled()) {
this.this$isMouseCheck = false;
matrixStack.pose().pushPose();
int width = (getMinecraft().getWindow().getGuiScaledWidth() - 176) / 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ private static void appendEnchantmentNames(List<Component> list, ListTag tags, C
for (int i = 0; i < tags.size(); i++) {
CompoundTag nbt = tags.getCompound(i);

if (RegistrySkills.SCHOLAR.get().isEnabled()) {
if (RegistrySkills.SCHOLAR != null && RegistrySkills.SCHOLAR.get().isEnabled()) {
ForgeRegistries.ENCHANTMENTS.getDelegate(EnchantmentHelper.getEnchantmentId(nbt)).ifPresent(enchantment -> list.add(enchantment.get().getFullname(EnchantmentHelper.getEnchantmentLevel(nbt))));
} else {
ForgeRegistries.ENCHANTMENTS.getDelegate(EnchantmentHelper.getEnchantmentId(nbt)).ifPresent(enchantment -> list.add(Component.translatable("tooltip.skill.scholar.lock_item").withStyle(ChatFormatting.GRAY)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public final void onAddEffect(MobEffectInstance effect, Entity source, CallbackI
@Unique
private boolean this$onAddEffect(MobEffectInstance effect, Player player) {
int duration = effect.getDuration();
if (effect.getEffect().getCategory() == MobEffectCategory.HARMFUL && RegistrySkills.LION_HEART.get().isEnabled(player)) {
if (effect.getEffect().getCategory() == MobEffectCategory.HARMFUL && (RegistrySkills.LION_HEART != null && RegistrySkills.LION_HEART.get().isEnabled(player))) {
duration -= (int)((double)effect.getDuration() * RegistrySkills.LION_HEART.get().getValue()[0] / 100.0D);
}

Expand Down Expand Up @@ -135,7 +135,7 @@ public final void onAddEffect(MobEffectInstance effect, Entity source, CallbackI
int duration = effect.getDuration();
int amplifier = effect.getAmplifier();
if (effect.getEffect().getCategory() == MobEffectCategory.BENEFICIAL && player.isUsingItem() && (player.getMainHandItem().getItem() instanceof PotionItem || player.getOffhandItem().getItem() instanceof PotionItem)) {
if (RegistrySkills.ALCHEMY_MANIPULATION.get().isEnabled(player)) {
if (RegistrySkills.ALCHEMY_MANIPULATION != null && RegistrySkills.ALCHEMY_MANIPULATION.get().isEnabled(player)) {
amplifier += (int)RegistrySkills.ALCHEMY_MANIPULATION.get().getValue()[0];
}

Expand Down Expand Up @@ -172,9 +172,11 @@ public void getVisibilityPercent(Entity source, CallbackInfoReturnable<Double> c
LivingEntity var6 = this.this$class;
if (var6 instanceof ServerPlayer) {
ServerPlayer player = (ServerPlayer)var6;
double isSneaking = player.isShiftKeyDown() ? RegistrySkills.STEALTH_MASTERY.get().getValue()[0] : RegistrySkills.STEALTH_MASTERY.get().getValue()[1];
if (RegistrySkills.STEALTH_MASTERY.get().isEnabled(player)) {
cir.setReturnValue(visibilityPercent * isSneaking / 100.0D);
if(RegistrySkills.STEALTH_MASTERY != null){
double isSneaking = player.isShiftKeyDown() ? RegistrySkills.STEALTH_MASTERY.get().getValue()[0] : RegistrySkills.STEALTH_MASTERY.get().getValue()[1];
if (RegistrySkills.STEALTH_MASTERY.get().isEnabled(player)) {
cir.setReturnValue(visibilityPercent * isSneaking / 100.0D);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ protected MixPlayer(Level level) {


public int getMaxAirSupply() {
if (RegistrySkills.ATHLETICS.get().isEnabled(this.this$class)) {
if (RegistrySkills.ATHLETICS != null && RegistrySkills.ATHLETICS.get().isEnabled(this.this$class)) {
return (int) (300.0D * RegistrySkills.ATHLETICS.get().getValue()[0]);
}
return 300;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ private void render(AbstractClientPlayer entity, Component par2, PoseStack matri
private void draw$Text(Component component, int y, Entity entity, PoseStack matrices, MultiBufferSource buffer, int light) {
boolean flag = !entity.isDiscrete();
float f = entity.getNameTagOffsetY();
int i = "deadmau5".equals(component.getString()) ? (-10 - y) : -y;
matrices.pushPose();
matrices.translate(0.0F, f, 0.0F);
matrices.mulPose(this.entityRenderDispatcher.cameraOrientation());
Expand All @@ -53,9 +52,9 @@ private void render(AbstractClientPlayer entity, Component par2, PoseStack matri
int j = (int) (f1 * 255.0F) << 24;
Font font = getFont();
float f2 = ((float) -font.width(component) / 2);
font.drawInBatch(component, f2, i, 553648127, false, matrix4f, buffer, flag ? Font.DisplayMode.SEE_THROUGH : Font.DisplayMode.NORMAL, j, light);
font.drawInBatch(component, f2, -y, 553648127, false, matrix4f, buffer, flag ? Font.DisplayMode.SEE_THROUGH : Font.DisplayMode.NORMAL, j, light);
if (flag) {
font.drawInBatch(component, f2, i, -1, false, matrix4f, buffer, Font.DisplayMode.NORMAL, 0, light);
font.drawInBatch(component, f2, -y, -1, false, matrix4f, buffer, Font.DisplayMode.NORMAL, 0, light);
}
matrices.popPose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public abstract class MixPowderSnowBlock {
@Inject(method = {"canEntityWalkOnPowderSnow"}, at = {@At("HEAD")}, cancellable = true)
private static void canEntityWalkOnPowderSnow(Entity entity, CallbackInfoReturnable<Boolean> info) {
if (entity instanceof Player player) {
if (RegistrySkills.SNOW_WALKER.get().isEnabled(player))
if (RegistrySkills.SNOW_WALKER != null && RegistrySkills.SNOW_WALKER.get().isEnabled(player))
info.setReturnValue(Boolean.TRUE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ protected void onHitEntity(EntityHitResult hitResult, CallbackInfo info) {
this.this$class.doEnchantDamageEffects(livingentity, entity);
if (entity instanceof LivingEntity livingentity1) {
if (livingentity1 instanceof Player player) {
if (!RegistrySkills.TURTLE_SHIELD.get().isEnabled(player)) {
if (RegistrySkills.TURTLE_SHIELD == null || !RegistrySkills.TURTLE_SHIELD.get().isEnabled(player)) {
player.addEffect(new MobEffectInstance(MobEffects.LEVITATION, 200), MoreObjects.firstNonNull(entity1, this.this$class));
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public abstract class MixVillager {

@Inject(method = {"updateSpecialPrices"}, at = {@At("TAIL")})
public void updateSpecialPrices(Player player, CallbackInfo info) {
if (player != null && RegistrySkills.HAGGLER.get().isEnabled(player))
if (player != null && RegistrySkills.HAGGLER != null && RegistrySkills.HAGGLER.get().isEnabled(player))
for (MerchantOffer merchantoffer : this.this$class.getOffers()) {
double d0 = RegistrySkills.HAGGLER.get().getValue()[0] / 100.0D;
int j = (int) Math.floor(d0 * merchantoffer.getBaseCostA().getCount());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.seniors.justlevelingfork.JustLevelingFork;
import com.seniors.justlevelingfork.handler.HandlerCommonConfig;
import com.seniors.justlevelingfork.handler.HandlerConvergenceItemsConfig;
import com.seniors.justlevelingfork.network.ServerNetworking;
import net.minecraft.client.Minecraft;
import net.minecraft.client.player.LocalPlayer;
Expand Down Expand Up @@ -115,7 +116,7 @@ public CommonConfigSyncCP() {
treasureHunterProbability = HandlerCommonConfig.HANDLER.instance().treasureHunterProbability;
treasureHunterItemList = HandlerCommonConfig.HANDLER.instance().treasureHunterItemList;
convergenceProbability = HandlerCommonConfig.HANDLER.instance().convergenceProbability;
convergenceItemList = HandlerCommonConfig.HANDLER.instance().convergenceItemList;
convergenceItemList = HandlerConvergenceItemsConfig.HANDLER.instance().convergenceItemList;
lifeEaterModifier = HandlerCommonConfig.HANDLER.instance().lifeEaterModifier;
criticalRoll6Modifier = HandlerCommonConfig.HANDLER.instance().criticalRoll6Modifier;
criticalRoll1Probability = HandlerCommonConfig.HANDLER.instance().criticalRoll1Probability;
Expand Down Expand Up @@ -318,7 +319,7 @@ public void handle(Supplier<NetworkEvent.Context> supplier) {
HandlerCommonConfig.HANDLER.instance().treasureHunterProbability = this.treasureHunterProbability;
HandlerCommonConfig.HANDLER.instance().treasureHunterItemList = this.treasureHunterItemList;
HandlerCommonConfig.HANDLER.instance().convergenceProbability = this.convergenceProbability;
HandlerCommonConfig.HANDLER.instance().convergenceItemList = this.convergenceItemList;
HandlerConvergenceItemsConfig.HANDLER.instance().convergenceItemList = this.convergenceItemList;
HandlerCommonConfig.HANDLER.instance().lifeEaterModifier = this.lifeEaterModifier;
HandlerCommonConfig.HANDLER.instance().criticalRoll6Modifier = this.criticalRoll6Modifier;
HandlerCommonConfig.HANDLER.instance().criticalRoll1Probability = this.criticalRoll1Probability;
Expand Down
Loading

0 comments on commit 513792d

Please sign in to comment.