Skip to content

Commit

Permalink
refactor: harmoniclib WIP
Browse files Browse the repository at this point in the history
[skip ci]
  • Loading branch information
WakelessSloth56 committed Feb 19, 2024
1 parent 73ebd69 commit f9ec29b
Show file tree
Hide file tree
Showing 83 changed files with 577 additions and 393 deletions.
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ runs {
ext {
resourceReplaceProperties = [
arnicalib_version_range: arnicalib_version_range,
lib_mod_id : lib_mod_id,
lib_mod_name : lib_mod_name,
lib_mod_authors : lib_mod_authors,
lib_mod_description : lib_mod_description
]
}

Expand Down
5 changes: 5 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,8 @@ mod_license=GNU GPLv3
mod_authors=WakelessSloth56, LainIO24, Libellule505
mod_credits=AUIOC
mod_description=HarmonicEnchantments

lib_mod_id=harmoniclib
lib_mod_name=HarmonicLib
lib_mod_authors=WakelessSloth56, LainIO24
lib_mod_description=HarmonicLib
Original file line number Diff line number Diff line change
Expand Up @@ -19,35 +19,22 @@

package org.auioc.mcmod.harmonicench;

import net.neoforged.api.distmarker.Dist;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.fml.ModLoadingContext;
import net.neoforged.fml.config.ModConfig;
import net.neoforged.fml.loading.FMLEnvironment;
import net.neoforged.neoforge.common.NeoForge;
import org.auioc.mcmod.harmonicench.client.ClientInitialization;
import org.auioc.mcmod.harmonicench.common.config.HECommonConfig;
import org.auioc.mcmod.harmonicench.common.enchantment.HEEnchantments;
import org.auioc.mcmod.harmonicench.common.event.HECommonEventHandler;
import org.auioc.mcmod.harmonicench.common.mobeffect.HEMobEffects;
import org.auioc.mcmod.harmonicench.server.advancement.EnchantmentPerformancePredicates;
import org.auioc.mcmod.harmonicench.server.advancement.HECriteriaTriggers;
import org.auioc.mcmod.harmonicench.server.event.HEServerEventHandler;
import org.auioc.mcmod.harmonicench.advancement.HEEPerformancePredicates;
import org.auioc.mcmod.harmonicench.config.HECommonConfig;
import org.auioc.mcmod.harmonicench.effect.HEMobEffects;
import org.auioc.mcmod.harmonicench.enchantment.HEEnchantments;

public final class Initialization {
public final class HEInitialization {

public static void init() {
registerConfig();
modSetup();
forgeSetup();

if (FMLEnvironment.dist == Dist.CLIENT) {
ClientInitialization.init();
}
}

private static final IEventBus modEventBus = HarmonicEnchantments.getModEventBus();
private static final IEventBus forgeEventBus = NeoForge.EVENT_BUS;

public static void registerConfig() {
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, HECommonConfig.CONFIG);
Expand All @@ -56,13 +43,7 @@ public static void registerConfig() {
private static void modSetup() {
HEEnchantments.ENCHANTMENTS.register(modEventBus);
HEMobEffects.MOB_EFFECTS.register(modEventBus);
EnchantmentPerformancePredicates.init(modEventBus);
HECriteriaTriggers.TRIGGERS.register(modEventBus);
}

private static void forgeSetup() {
forgeEventBus.register(HECommonEventHandler.class);
forgeEventBus.register(HEServerEventHandler.class);
HEEPerformancePredicates.EPPT.register(modEventBus);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public final class HarmonicEnchantments implements IHMod {
public HarmonicEnchantments(IEventBus modEventBus) {
HarmonicEnchantments.modEventBus = modEventBus;
IHMod.validateVersion(BUILD_INFO, LOGGER);
Initialization.init();
HEInitialization.init();
}

public static IEventBus getModEventBus() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright (C) 2024 AUIOC.ORG
*
* This file is part of HarmonicEnchantments, a mod made for Minecraft.
*
* ArnicaLib is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/

package org.auioc.mcmod.harmonicench.advancement;

import com.mojang.serialization.Codec;
import net.neoforged.neoforge.registries.DeferredHolder;
import net.neoforged.neoforge.registries.DeferredRegister;
import org.auioc.mcmod.harmonicench.HarmonicEnchantments;
import org.auioc.mcmod.harmonicench.enchantment.impl.AimEnchantment;
import org.auioc.mcmod.harmonicench.enchantment.impl.CurseOfRebellingEnchantment;
import org.auioc.mcmod.harmoniclib.advancement.predicate.HEPerformancePredicateType;
import org.auioc.mcmod.harmoniclib.advancement.predicate.IHEPerformancePredicate;
import org.auioc.mcmod.harmoniclib.core.HLRegistries;

public class HEEPerformancePredicates {

public static final DeferredRegister<HEPerformancePredicateType> EPPT = DeferredRegister.create(HLRegistries.ENCHANTMENT_PERFORMANCE_PREDICATE_TYPE, HarmonicEnchantments.MOD_ID);

// ============================================================================================================== //

private static DeferredHolder<HEPerformancePredicateType, HEPerformancePredicateType> register(String id, Codec<? extends IHEPerformancePredicate> codec) {
return EPPT.register(id, () -> new HEPerformancePredicateType(codec));
}

public static DeferredHolder<HEPerformancePredicateType, HEPerformancePredicateType> AIM = register("aim", AimEnchantment.PerformancePredicate.CODEC);
public static DeferredHolder<HEPerformancePredicateType, HEPerformancePredicateType> CURSE_OF_REBELLING = register("curse_of_rebelling", CurseOfRebellingEnchantment.PerformancePredicate.CODEC);


}
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/

package org.auioc.mcmod.harmonicench.common.config;
package org.auioc.mcmod.harmonicench.config;

import net.minecraft.resources.ResourceLocation;
import net.neoforged.neoforge.common.ModConfigSpec;
import net.neoforged.neoforge.registries.DeferredHolder;
import org.auioc.mcmod.harmonicench.api.enchantment.HEEnchantmentManager;
import org.auioc.mcmod.harmonicench.common.enchantment.HEEnchantments;
import org.auioc.mcmod.harmonicench.enchantment.HEEnchantments;
import org.auioc.mcmod.harmoniclib.enchantment.api.HEEnchantmentManager;

import java.util.Comparator;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/

package org.auioc.mcmod.harmonicench.common.damagesource;
package org.auioc.mcmod.harmonicench.damagesource;

import org.auioc.mcmod.harmonicench.HarmonicEnchantments;
import net.minecraft.core.registries.Registries;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import net.neoforged.neoforge.common.data.DatapackBuiltinEntriesProvider;
import net.neoforged.neoforge.data.event.GatherDataEvent;
import org.auioc.mcmod.harmonicench.HarmonicEnchantments;
import org.auioc.mcmod.harmonicench.common.damagesource.HEDamageTypes;
import org.auioc.mcmod.harmonicench.damagesource.HEDamageTypes;
import org.auioc.mcmod.harmonicench.datagen.provider.HEAdvancementProvider;
import org.auioc.mcmod.harmonicench.datagen.provider.HEDamageTypeTagsProvider;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@
import org.auioc.mcmod.arnicalib.game.loot.predicate.EntityAttributeCondition;
import org.auioc.mcmod.arnicalib.game.tag.HEntityTypeTags;
import org.auioc.mcmod.harmonicench.HarmonicEnchantments;
import org.auioc.mcmod.harmonicench.common.enchantment.HEEnchantments;
import org.auioc.mcmod.harmonicench.common.enchantment.impl.AimEnchantment;
import org.auioc.mcmod.harmonicench.common.enchantment.impl.CurseOfRebellingEnchantment;
import org.auioc.mcmod.harmonicench.common.enchantment.impl.ProficiencyEnchantment;
import org.auioc.mcmod.harmonicench.server.advancement.criterion.EnchantmentPerformedTrigger;
import org.auioc.mcmod.harmonicench.enchantment.HEEnchantments;
import org.auioc.mcmod.harmonicench.enchantment.impl.AimEnchantment;
import org.auioc.mcmod.harmonicench.enchantment.impl.CurseOfRebellingEnchantment;
import org.auioc.mcmod.harmonicench.enchantment.impl.ProficiencyEnchantment;
import org.auioc.mcmod.harmoniclib.advancement.criterion.EnchantmentPerformedTrigger;

import java.util.List;
import java.util.Optional;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import net.minecraft.tags.DamageTypeTags;
import net.neoforged.neoforge.common.data.ExistingFileHelper;
import org.auioc.mcmod.harmonicench.HarmonicEnchantments;
import org.auioc.mcmod.harmonicench.common.damagesource.HEDamageTypes;
import org.auioc.mcmod.harmonicench.damagesource.HEDamageTypes;

import java.util.concurrent.CompletableFuture;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/

package org.auioc.mcmod.harmonicench.common.mobeffect;
package org.auioc.mcmod.harmonicench.effect;

import net.minecraft.core.registries.Registries;
import net.minecraft.world.effect.MobEffect;
import net.neoforged.neoforge.registries.DeferredHolder;
import net.neoforged.neoforge.registries.DeferredRegister;
import org.auioc.mcmod.harmonicench.HarmonicEnchantments;
import org.auioc.mcmod.harmonicench.common.mobeffect.impl.ConfusionMobEffect;
import org.auioc.mcmod.harmonicench.common.mobeffect.impl.WeightlessnessMobEffect;
import org.auioc.mcmod.harmonicench.effect.impl.ConfusionMobEffect;
import org.auioc.mcmod.harmonicench.effect.impl.WeightlessnessMobEffect;

import java.util.function.Supplier;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/

package org.auioc.mcmod.harmonicench.common.mobeffect.impl;
package org.auioc.mcmod.harmonicench.effect.impl;

import org.auioc.mcmod.arnicalib.game.input.InputUtils;
import org.auioc.mcmod.harmonicench.api.effect.IMovementInputMobEffect;
import net.minecraft.client.player.Input;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.effect.MobEffectCategory;
import org.auioc.mcmod.arnicalib.game.input.InputUtils;
import org.auioc.mcmod.harmoniclib.effect.IMovementInputMobEffect;

public class ConfusionMobEffect extends MobEffect implements IMovementInputMobEffect {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/

package org.auioc.mcmod.harmonicench.common.mobeffect.impl;
package org.auioc.mcmod.harmonicench.effect.impl;

import org.auioc.mcmod.arnicalib.game.effect.MobEffectUtils;
import org.auioc.mcmod.harmonicench.common.mobeffect.HEMobEffects;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.effect.MobEffectCategory;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.phys.Vec3;
import org.auioc.mcmod.arnicalib.game.effect.MobEffectUtils;
import org.auioc.mcmod.harmonicench.effect.HEMobEffects;

public class WeightlessnessMobEffect extends MobEffect {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,36 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/

package org.auioc.mcmod.harmonicench.common.enchantment;
package org.auioc.mcmod.harmonicench.enchantment;

import net.minecraft.core.registries.Registries;
import net.minecraft.world.item.enchantment.Enchantment;
import net.neoforged.neoforge.registries.DeferredHolder;
import net.neoforged.neoforge.registries.DeferredRegister;
import org.auioc.mcmod.harmonicench.HarmonicEnchantments;
import org.auioc.mcmod.harmonicench.common.enchantment.impl.AimEnchantment;
import org.auioc.mcmod.harmonicench.common.enchantment.impl.BaneOfChampionsEnchantment;
import org.auioc.mcmod.harmonicench.common.enchantment.impl.BlessingEnchantment;
import org.auioc.mcmod.harmonicench.common.enchantment.impl.BluntEnchantment;
import org.auioc.mcmod.harmonicench.common.enchantment.impl.CurseOfRebellingEnchantment;
import org.auioc.mcmod.harmonicench.common.enchantment.impl.CurseOfSacrificingEnchantment;
import org.auioc.mcmod.harmonicench.common.enchantment.impl.DeepStudyEnchantment;
import org.auioc.mcmod.harmonicench.common.enchantment.impl.DiningEnchantment;
import org.auioc.mcmod.harmonicench.common.enchantment.impl.EfficacyEnchantment;
import org.auioc.mcmod.harmonicench.common.enchantment.impl.ElectrificationEnchantment;
import org.auioc.mcmod.harmonicench.common.enchantment.impl.ForgingEnchantment;
import org.auioc.mcmod.harmonicench.common.enchantment.impl.FreeRidingEnchantment;
import org.auioc.mcmod.harmonicench.common.enchantment.impl.HandinessEnchantment;
import org.auioc.mcmod.harmonicench.common.enchantment.impl.IceAspectEnchantment;
import org.auioc.mcmod.harmonicench.common.enchantment.impl.LongEnchantment;
import org.auioc.mcmod.harmonicench.common.enchantment.impl.LuckOfTheSnowEnchantment;
import org.auioc.mcmod.harmonicench.common.enchantment.impl.MobAffinityEnchantment;
import org.auioc.mcmod.harmonicench.common.enchantment.impl.ProficiencyEnchantment;
import org.auioc.mcmod.harmonicench.common.enchantment.impl.RapierEnchantment;
import org.auioc.mcmod.harmonicench.common.enchantment.impl.SafeTeleportingEnchantment;
import org.auioc.mcmod.harmonicench.common.enchantment.impl.SiphoningEnchantment;
import org.auioc.mcmod.harmonicench.common.enchantment.impl.SnipingEnchantment;
import org.auioc.mcmod.harmonicench.common.enchantment.impl.SunAffinityEnchantment;
import org.auioc.mcmod.harmonicench.enchantment.impl.AimEnchantment;
import org.auioc.mcmod.harmonicench.enchantment.impl.BaneOfChampionsEnchantment;
import org.auioc.mcmod.harmonicench.enchantment.impl.BlessingEnchantment;
import org.auioc.mcmod.harmonicench.enchantment.impl.BluntEnchantment;
import org.auioc.mcmod.harmonicench.enchantment.impl.CurseOfRebellingEnchantment;
import org.auioc.mcmod.harmonicench.enchantment.impl.CurseOfSacrificingEnchantment;
import org.auioc.mcmod.harmonicench.enchantment.impl.DeepStudyEnchantment;
import org.auioc.mcmod.harmonicench.enchantment.impl.DiningEnchantment;
import org.auioc.mcmod.harmonicench.enchantment.impl.EfficacyEnchantment;
import org.auioc.mcmod.harmonicench.enchantment.impl.ElectrificationEnchantment;
import org.auioc.mcmod.harmonicench.enchantment.impl.ForgingEnchantment;
import org.auioc.mcmod.harmonicench.enchantment.impl.FreeRidingEnchantment;
import org.auioc.mcmod.harmonicench.enchantment.impl.HandinessEnchantment;
import org.auioc.mcmod.harmonicench.enchantment.impl.IceAspectEnchantment;
import org.auioc.mcmod.harmonicench.enchantment.impl.LongEnchantment;
import org.auioc.mcmod.harmonicench.enchantment.impl.LuckOfTheSnowEnchantment;
import org.auioc.mcmod.harmonicench.enchantment.impl.MobAffinityEnchantment;
import org.auioc.mcmod.harmonicench.enchantment.impl.ProficiencyEnchantment;
import org.auioc.mcmod.harmonicench.enchantment.impl.RapierEnchantment;
import org.auioc.mcmod.harmonicench.enchantment.impl.SafeTeleportingEnchantment;
import org.auioc.mcmod.harmonicench.enchantment.impl.SiphoningEnchantment;
import org.auioc.mcmod.harmonicench.enchantment.impl.SnipingEnchantment;
import org.auioc.mcmod.harmonicench.enchantment.impl.SunAffinityEnchantment;

import java.util.function.Supplier;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/

package org.auioc.mcmod.harmonicench.common.enchantment.impl;
package org.auioc.mcmod.harmonicench.enchantment.impl;

import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
Expand All @@ -42,13 +42,13 @@
import org.auioc.mcmod.arnicalib.base.math.MathUtil;
import org.auioc.mcmod.arnicalib.game.enchantment.HEnchantmentCategory;
import org.auioc.mcmod.arnicalib.game.world.phys.RayCastUtils;
import org.auioc.mcmod.harmonicench.api.advancement.EPPredicateType;
import org.auioc.mcmod.harmonicench.api.advancement.IEnchantmentPerformancePredicate;
import org.auioc.mcmod.harmonicench.api.enchantment.AbstractHEEnchantment;
import org.auioc.mcmod.harmonicench.api.enchantment.ILivingEnchantment;
import org.auioc.mcmod.harmonicench.api.enchantment.IPlayerEnchantment;
import org.auioc.mcmod.harmonicench.server.advancement.EnchantmentPerformancePredicates;
import org.auioc.mcmod.harmonicench.server.advancement.HECriteriaTriggers;
import org.auioc.mcmod.harmonicench.advancement.HEEPerformancePredicates;
import org.auioc.mcmod.harmoniclib.advancement.HLCriteriaTriggers;
import org.auioc.mcmod.harmoniclib.advancement.predicate.HEPerformancePredicateType;
import org.auioc.mcmod.harmoniclib.advancement.predicate.IHEPerformancePredicate;
import org.auioc.mcmod.harmoniclib.enchantment.api.AbstractHEEnchantment;
import org.auioc.mcmod.harmoniclib.enchantment.api.ILivingEnchantment;
import org.auioc.mcmod.harmoniclib.enchantment.api.IPlayerEnchantment;

import java.util.Optional;

Expand Down Expand Up @@ -111,15 +111,15 @@ public void onPlayerTick(int lvl, ItemStack itemStack, EquipmentSlot slot, Playe
}

private void triggerAdvancement(ServerPlayer player, ItemStack itemStack, LivingEntity aimedEntity) {
HECriteriaTriggers.ENCHANTMENT_PERFORMED.get().trigger(
HLCriteriaTriggers.ENCHANTMENT_PERFORMED.get().trigger(
player, this, itemStack,
(PerformancePredicate p) -> p.matches(player, aimedEntity)
);
}

// ============================================================================================================== //

public record PerformancePredicate(Optional<ContextAwarePredicate> aimedEntity, Optional<DistancePredicate> distance) implements IEnchantmentPerformancePredicate {
public record PerformancePredicate(Optional<ContextAwarePredicate> aimedEntity, Optional<DistancePredicate> distance) implements IHEPerformancePredicate {

public PerformancePredicate(EntityPredicate aimedEntityPredicate) {
this(Optional.of(EntityPredicate.wrap(aimedEntityPredicate)), Optional.empty());
Expand All @@ -137,8 +137,8 @@ public boolean matches(ServerPlayer player, LivingEntity aimedLiving) {
// ========================================================================================================== //

@Override
public EPPredicateType getType() {
return EnchantmentPerformancePredicates.AIM.get();
public HEPerformancePredicateType getType() {
return HEEPerformancePredicates.AIM.get();
}

public static final Codec<PerformancePredicate> CODEC = RecordCodecBuilder.create(instance -> instance.group(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/

package org.auioc.mcmod.harmonicench.common.enchantment.impl;
package org.auioc.mcmod.harmonicench.enchantment.impl;

import org.auioc.mcmod.harmonicench.api.enchantment.AbstractHEEnchantment;
import org.auioc.mcmod.harmonicench.api.enchantment.ILivingEnchantment;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;
Expand All @@ -29,6 +27,8 @@
import net.minecraft.world.item.enchantment.DamageEnchantment;
import net.minecraft.world.item.enchantment.Enchantment;
import net.minecraft.world.item.enchantment.EnchantmentCategory;
import org.auioc.mcmod.harmoniclib.enchantment.api.AbstractHEEnchantment;
import org.auioc.mcmod.harmoniclib.enchantment.api.ILivingEnchantment;

public class BaneOfChampionsEnchantment extends AbstractHEEnchantment implements ILivingEnchantment.Hurt {

Expand Down
Loading

0 comments on commit f9ec29b

Please sign in to comment.