Skip to content

Commit

Permalink
I want to cuddleeee agh
Browse files Browse the repository at this point in the history
  • Loading branch information
SammySemicolon committed Apr 17, 2024
1 parent 40cc6fc commit c240096
Show file tree
Hide file tree
Showing 26 changed files with 268 additions and 187 deletions.
10 changes: 6 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,16 @@ dependencies {
runtimeOnly(fg.deobf("top.theillusivec4.curios:curios-forge:${curiosVersion}"))

implementation(fg.deobf("team.lodestar.lodestone:lodestone:${minecraftVersion}-${lodestoneVersion}"))
// implementation fg.deobf("curse.maven:mutil-351914:3941314")
// implementation fg.deobf("curse.maven:tetra-289712:4628304")

implementation(fg.deobf("curse.maven:farmers_delight-398521:4638874"))
implementation(fg.deobf("curse.maven:create-328085:4626108"))
compileOnly(fg.deobf("curse.maven:farmers_delight-398521:4638874"))

// implementation(fg.deobf("curse.maven:create-328085:4626108"))
//implementation(fg.deobf("curse.maven:jeed-532286:4599236"))

runtimeOnly(fg.deobf("curse.maven:world-stripper-250603:4578579"))
runtimeOnly(fg.deobf("curse.maven:spark-361579:4587309"))
runtimeOnly(fg.deobf("curse.maven:attributefix-280510:4911084"))
runtimeOnly(fg.deobf("curse.maven:overloaded-armor-bar-314002:4631133"))
}

tasks.withType<ProcessResources> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void setupEntries() {
.addPage(SpiritInfusionPage.fromOutput(NECKLACE_OF_THE_MYSTIC_MIRROR.get()))
);

addEntry("mirror_magic", 6, 10, b -> b
addEntry("mirror_magic", 8, 13, b -> b
.setWidgetConfig(w -> w.setIcon(SPECTRAL_LENS).setStyle(BookWidgetStyle.GILDED_RUNEWOOD))
.addPage(new HeadlineTextPage("mirror_magic", "mirror_magic.1"))
.addPage(SpiritInfusionPage.fromOutput(SPECTRAL_LENS.get()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@
import com.sammy.malum.registry.common.*;
import net.minecraft.client.*;
import net.minecraft.client.model.*;
import net.minecraft.network.chat.*;
import net.minecraft.util.*;
import net.minecraft.world.entity.*;
import net.minecraft.world.entity.ai.attributes.*;
import net.minecraft.world.item.*;
import net.minecraftforge.api.distmarker.*;
import net.minecraftforge.client.extensions.common.*;
import team.lodestar.lodestone.registry.common.*;
import team.lodestar.lodestone.systems.model.*;

import java.util.*;
Expand All @@ -24,9 +22,6 @@

public class MalignantStrongholdArmorItem extends MalumArmorItem {

public static final UUID MALIGNANT_CONVERSION_UUID = UUID.fromString("ff803d68-a615-4279-a59a-d847db2481d7");
public static final HashMap<Attribute, UUID> UUIDS = new HashMap<>();

public MalignantStrongholdArmorItem(Type slot, Properties builder) {
super(MALIGNANT_ALLOY, slot, builder);
}
Expand All @@ -43,50 +38,6 @@ public String getTexture() {
return "malignant_stronghold";
}

public static void updateAttributes(LivingEntity livingEntity) {
var attributes = livingEntity.getAttributes();
var malignantConversionAttribute = AttributeRegistry.MALIGNANT_CONVERSION.get();
if (attributes.hasAttribute(malignantConversionAttribute)) {
convertAttribute(livingEntity, 2f, AttributeRegistry.SOUL_WARD_STRENGTH.get(), Attributes.ARMOR, Attributes.ARMOR_TOUGHNESS);
convertAttribute(livingEntity, 1f, LodestoneAttributeRegistry.MAGIC_RESISTANCE.get(), Attributes.ARMOR, Attributes.ARMOR_TOUGHNESS);

convertAttribute(livingEntity, 4f, AttributeRegistry.ARCANE_RESONANCE.get(), Attributes.ARMOR_TOUGHNESS);
convertAttribute(livingEntity, 1f, AttributeRegistry.SOUL_WARD_RECOVERY_RATE.get(), Attributes.ARMOR_TOUGHNESS);

convertAttribute(livingEntity, 2f, LodestoneAttributeRegistry.MAGIC_PROFICIENCY.get(), Attributes.ARMOR);
convertAttribute(livingEntity, 1f, AttributeRegistry.SOUL_WARD_CAP.get(), Attributes.ARMOR);
}
}

private static void convertAttribute(LivingEntity livingEntity, float conversionPotency, Attribute sourceAttribute, Attribute... targetAttributes) {
var attributes = livingEntity.getAttributes();
double malignantConversion = attributes.getValue(AttributeRegistry.MALIGNANT_CONVERSION.get());

final AttributeInstance sourceInstance = livingEntity.getAttribute(sourceAttribute);
if (sourceInstance != null) {
sourceInstance.removeModifier(MALIGNANT_CONVERSION_UUID);
double cachedValue = sourceInstance.getValue();
for (Attribute target : targetAttributes) {
final AttributeInstance targetInstance = livingEntity.getAttribute(target);
if (targetInstance != null) {
final UUID uuid = UUIDS.computeIfAbsent(sourceAttribute, a -> Mth.createInsecureUUID(RandomSource.createNewThreadLocalInstance()));
targetInstance.removeModifier(uuid);
final double bonus = cachedValue * malignantConversion * conversionPotency;
if (bonus > 0) {
targetInstance.addTransientModifier(
new AttributeModifier(uuid, "Malignant Conversion: " + Component.translatable(target.getDescriptionId()),
bonus, AttributeModifier.Operation.ADDITION));
}
}
}
if (malignantConversion > 0) {
sourceInstance.addTransientModifier(
new AttributeModifier(MALIGNANT_CONVERSION_UUID, "Malignant Conversion: " + Component.translatable(sourceAttribute.getDescriptionId()),
-malignantConversion, AttributeModifier.Operation.MULTIPLY_TOTAL));
}
}
}

@OnlyIn(Dist.CLIENT)
@Override
public void initializeClient(Consumer<IClientItemExtensions> consumer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.sammy.malum.common.item.curiosities.curios.MalumCurioItem;
import com.sammy.malum.registry.common.item.ItemRegistry;
import com.sammy.malum.registry.common.item.ItemTagRegistry;
import net.minecraft.*;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
Expand All @@ -26,7 +27,7 @@ public CurioProspectorBelt(Properties builder) {

@Override
public void addExtraTooltipLines(Consumer<Component> consumer) {
consumer.accept(positiveEffect("enchanted_explosions", Enchantments.BLOCK_FORTUNE.getFullname(3)));
consumer.accept(positiveEffect("enchanted_explosions", Enchantments.BLOCK_FORTUNE.getFullname(3).copy().withStyle(ChatFormatting.BLUE)));
consumer.accept(positiveEffect("explosions_spare_valuables"));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
package com.sammy.malum.common.item.curiosities.curios.sets.rotten;

import com.google.common.collect.Multimap;
import com.sammy.malum.common.item.IMalumEventResponderItem;
import com.sammy.malum.common.item.curiosities.curios.MalumCurioItem;
import com.sammy.malum.registry.common.MobEffectRegistry;
import com.sammy.malum.registry.common.SoundRegistry;
import net.minecraft.network.chat.Component;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.ai.attributes.Attribute;
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import team.lodestar.lodestone.helpers.EntityHelper;
import top.theillusivec4.curios.api.SlotContext;
import com.sammy.malum.common.item.*;
import com.sammy.malum.common.item.curiosities.curios.*;
import com.sammy.malum.registry.common.*;
import net.minecraft.network.chat.*;
import net.minecraft.sounds.*;
import net.minecraft.world.effect.*;
import net.minecraft.world.entity.*;
import net.minecraft.world.item.*;
import net.minecraft.world.level.*;
import team.lodestar.lodestone.helpers.*;

import java.util.function.Consumer;
import java.util.function.*;

public class CurioStarvedBelt extends MalumCurioItem implements IMalumEventResponderItem {

Expand All @@ -33,12 +25,6 @@ public void addExtraTooltipLines(Consumer<Component> consumer) {
consumer.accept(positiveEffect("gluttony_magic_proficiency"));
}

@Override
public void addAttributeModifiers(Multimap<Attribute, AttributeModifier> map, SlotContext slotContext, ItemStack stack) {
addAttributeModifier(map, Attributes.ARMOR, uuid -> new AttributeModifier(uuid,
"Curio Armor", 2f, AttributeModifier.Operation.ADDITION));
}

@Override
public void pickupSpirit(LivingEntity collector, ItemStack stack, double arcaneResonance) {
MobEffect gluttony = MobEffectRegistry.GLUTTONY.get();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,20 @@
package com.sammy.malum.common.item.curiosities.curios.sets.rotten;

import com.google.common.collect.Multimap;
import com.sammy.malum.common.item.curiosities.curios.MalumCurioItem;
import com.sammy.malum.registry.common.MobEffectRegistry;
import com.sammy.malum.registry.common.SoundRegistry;
import com.sammy.malum.registry.common.item.ItemRegistry;
import net.minecraft.network.chat.Component;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.ai.attributes.Attribute;
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraftforge.event.entity.living.LivingEntityUseItemEvent;
import team.lodestar.lodestone.helpers.CurioHelper;
import team.lodestar.lodestone.helpers.EntityHelper;
import team.lodestar.lodestone.helpers.RandomHelper;
import top.theillusivec4.curios.api.SlotContext;

import java.util.function.Consumer;

import static com.sammy.malum.registry.common.item.ItemTagRegistry.GROSS_FOODS;
import com.sammy.malum.common.item.curiosities.curios.*;
import com.sammy.malum.registry.common.*;
import com.sammy.malum.registry.common.item.*;
import net.minecraft.network.chat.*;
import net.minecraft.sounds.*;
import net.minecraft.world.effect.*;
import net.minecraft.world.entity.player.*;
import net.minecraft.world.item.*;
import net.minecraft.world.level.*;
import net.minecraftforge.event.entity.living.*;
import team.lodestar.lodestone.helpers.*;

import java.util.function.*;

import static com.sammy.malum.registry.common.item.ItemTagRegistry.*;

public class CurioVoraciousRing extends MalumCurioItem {

Expand All @@ -37,14 +28,6 @@ public void addExtraTooltipLines(Consumer<Component> consumer) {
consumer.accept(positiveEffect("growing_gluttony"));
}

@Override
public void addAttributeModifiers(Multimap<Attribute, AttributeModifier> map, SlotContext slotContext, ItemStack stack) {
addAttributeModifier(map, Attributes.ARMOR_TOUGHNESS, uuid -> new AttributeModifier(uuid,
"Curio Armor Toughness", 1f, AttributeModifier.Operation.ADDITION));
addAttributeModifier(map, Attributes.ARMOR, uuid -> new AttributeModifier(uuid,
"Curio Armor", 1f, AttributeModifier.Operation.ADDITION));
}

public static void accelerateEating(LivingEntityUseItemEvent.Start event) {
if (CurioHelper.hasCurioEquipped(event.getEntity(), ItemRegistry.RING_OF_DESPERATE_VORACITY.get())) {
if (event.getItem().is(GROSS_FOODS)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void hurtEvent(LivingHurtEvent event, LivingEntity attacker, LivingEntity
level.playSound(null, target.getX(), target.getY(), target.getZ(), SoundRegistry.WEIGHT_OF_WORLDS_SLASH.get(), attacker.getSoundSource(), 1, 0.5f);
final MobEffect effect = MobEffectRegistry.DEACONS_FORTUNE.get();
if (attacker.hasEffect(effect) || level.random.nextFloat() < 0.25f) {
event.setAmount(event.getAmount()*3);
event.setAmount(event.getAmount()*2);
level.playSound(null, target.getX(), target.getY(), target.getZ(), SoundRegistry.MALIGNANT_METAL_RESONATES.get(), attacker.getSoundSource(), 2, 0.5f);
level.playSound(null, target.getX(), target.getY(), target.getZ(), SoundRegistry.MALIGNANT_METAL_RESONATES.get(), attacker.getSoundSource(), 2, 1.5f);
level.playSound(null, target.getX(), target.getY(), target.getZ(), SoundRegistry.DRAINING_MOTIF.get(), attacker.getSoundSource(), 2, 0.5f);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void hurtEvent(LivingHurtEvent event, LivingEntity attacker, LivingEntity

@Override
public int getCooldownDuration(Level level, LivingEntity livingEntity) {
return 60;
return 80;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ public static void registerListeners(AddReloadListenerEvent event) {
SpiritDataReloadListener.register(event);
ReapingDataReloadListener.register(event);
RitualRecipeReloadListener.register(event);
MalignantConversionReloadListener.register(event);
}

@SubscribeEvent
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,102 @@
package com.sammy.malum.core.handlers;

import com.mojang.datafixers.util.*;
import com.sammy.malum.common.capability.*;
import com.sammy.malum.common.item.curiosities.armor.*;
import com.sammy.malum.core.listeners.*;
import com.sammy.malum.registry.common.*;
import net.minecraft.network.chat.*;
import net.minecraft.util.*;
import net.minecraft.world.entity.*;
import net.minecraft.world.entity.ai.attributes.*;
import net.minecraftforge.event.entity.living.*;

import java.util.*;

public class MalignantConversionHandler {

public double malignantConversionCache;
private static final UUID MALIGNANT_CONVERSION_UUID = UUID.fromString("ff803d68-a615-4279-a59a-d847db2481d7");
public static final HashMap<Attribute, UUID> MODIFIER_UUIDS = new HashMap<>();

public final HashMap<Attribute, Double> cachedAttributeValues = new HashMap<>();
public boolean skipConversionLogic;

public static void checkForAttributeChanges(LivingEvent.LivingTickEvent event) {
final LivingEntity livingEntity = event.getEntity();
if (!livingEntity.level().isClientSide) {
MalignantConversionHandler handler = MalumLivingEntityDataCapability.getCapability(livingEntity).malignantConversionHandler;
final AttributeInstance attribute = livingEntity.getAttribute(AttributeRegistry.MALIGNANT_CONVERSION.get());
if (attribute != null) {
if (handler.malignantConversionCache != attribute.getValue()) {
MalignantStrongholdArmorItem.updateAttributes(livingEntity);
var handler = MalumLivingEntityDataCapability.getCapability(livingEntity).malignantConversionHandler;
final Attribute conversionAttribute = AttributeRegistry.MALIGNANT_CONVERSION.get();
AttributeInstance conversionInstance = livingEntity.getAttribute(conversionAttribute);
if (conversionInstance != null) {
if (handler.skipConversionLogic) {
if (conversionInstance.getValue() == 0) {
return;
}
handler.skipConversionLogic = false;
}
var conversionData = MalignantConversionReloadListener.CONVERSION_DATA;
for (MalignantConversionReloadListener.MalignantConversionData data : conversionData.values()) {
Attribute attribute = data.sourceAttribute();
AttributeInstance instance = livingEntity.getAttribute(attribute);
if (instance != null) {
if (handler.cachedAttributeValues.containsKey(attribute)) {
convertAttribute(livingEntity, data.sourceAttribute(), data.targetAttributes());
}
}
}
if (handler.cachedAttributeValues.containsKey(conversionAttribute)) {
if (handler.cachedAttributeValues.get(conversionAttribute) != conversionInstance.getValue()) {
for (MalignantConversionReloadListener.MalignantConversionData data : conversionData.values()) {
convertAttribute(livingEntity, data.sourceAttribute(), data.targetAttributes(), true);
}
}
}
handler.cachedAttributeValues.put(conversionAttribute, conversionInstance.getValue());
if (conversionInstance.getValue() == 0) {
handler.skipConversionLogic = true;
}
}
}
}

private static void convertAttribute(LivingEntity livingEntity, Attribute sourceAttribute, List<Pair<Attribute, Double>> targetAttributes) {
convertAttribute(livingEntity, sourceAttribute, targetAttributes, false);
}
private static void convertAttribute(LivingEntity livingEntity, Attribute sourceAttribute, List<Pair<Attribute, Double>> targetAttributes, boolean skipCacheComparison) {
var attributes = livingEntity.getAttributes();
double malignantConversion = attributes.getValue(AttributeRegistry.MALIGNANT_CONVERSION.get());

final AttributeInstance sourceInstance = livingEntity.getAttribute(sourceAttribute);
if (sourceInstance != null) {
var handler = MalumLivingEntityDataCapability.getCapability(livingEntity).malignantConversionHandler;
final AttributeModifier originalModifier = sourceInstance.getModifier(MALIGNANT_CONVERSION_UUID);
if (originalModifier != null) {
sourceInstance.removeModifier(originalModifier);
}
if (skipCacheComparison || handler.cachedAttributeValues.get(sourceAttribute) != sourceInstance.getValue()) {
double cachedValue = sourceInstance.getValue();
for (Pair<Attribute, Double> target : targetAttributes) {
final Attribute targetAttribute = target.getFirst();
final AttributeInstance targetInstance = livingEntity.getAttribute(targetAttribute);
if (targetInstance != null) {
final UUID uuid = MODIFIER_UUIDS.computeIfAbsent(sourceAttribute, a -> Mth.createInsecureUUID(RandomSource.createNewThreadLocalInstance()));
targetInstance.removeModifier(uuid);
final double bonus = cachedValue * malignantConversion * target.getSecond();
if (bonus > 0) {
targetInstance.addTransientModifier(
new AttributeModifier(uuid, "Malignant Conversion: " + Component.translatable(targetAttribute.getDescriptionId()),
bonus, AttributeModifier.Operation.ADDITION));
}
}
}
handler.cachedAttributeValues.put(sourceAttribute, sourceInstance.getValue());
if (malignantConversion > 0) {
sourceInstance.addTransientModifier(
new AttributeModifier(MALIGNANT_CONVERSION_UUID, "Malignant Conversion: " + Component.translatable(sourceAttribute.getDescriptionId()),
-malignantConversion, AttributeModifier.Operation.MULTIPLY_TOTAL));
}
handler.malignantConversionCache = attribute.getValue();
}
else if (handler.malignantConversionCache > 0) {
handler.malignantConversionCache = 0;
MalignantStrongholdArmorItem.updateAttributes(livingEntity);
if (originalModifier != null && sourceInstance.getModifier(MALIGNANT_CONVERSION_UUID) == null) {
sourceInstance.addTransientModifier(originalModifier);
}
}
}
Expand Down
Loading

0 comments on commit c240096

Please sign in to comment.