Skip to content

Commit

Permalink
WERE IN
Browse files Browse the repository at this point in the history
  • Loading branch information
SammySemicolon committed Dec 9, 2024
1 parent 63fd7d8 commit 8d402d0
Show file tree
Hide file tree
Showing 73 changed files with 1,403 additions and 1,594 deletions.
3 changes: 3 additions & 0 deletions src/main/java/com/sammy/malum/MalumMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.sammy.malum.compability.irons_spellbooks.*;
import com.sammy.malum.compability.tetra.*;
import com.sammy.malum.config.*;
import com.sammy.malum.registry.common.*;
import com.sammy.malum.registry.common.item.tabs.*;
import net.minecraft.core.Holder;
import net.minecraft.core.HolderOwner;
Expand All @@ -23,6 +24,7 @@
import java.util.Map;

import static com.sammy.malum.registry.client.ParticleRegistry.*;
import static com.sammy.malum.registry.common.AttachmentTypeRegistry.ATTACHMENT_TYPES;
import static com.sammy.malum.registry.common.AttributeRegistry.*;
import static com.sammy.malum.registry.common.ContainerRegistry.*;
import static com.sammy.malum.registry.common.MobEffectRegistry.*;
Expand Down Expand Up @@ -66,6 +68,7 @@ public MalumMod() {
FEATURE_TYPES.register(modBus);
STRUCTURES.register(modBus);
CREATIVE_MODE_TABS.register(modBus);
ATTACHMENT_TYPES.register(modBus);

TetraCompat.init();
FarmersDelightCompat.init();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.sammy.malum.*;
import com.sammy.malum.client.*;
import com.sammy.malum.common.block.curiosities.mana_mote.*;
import com.sammy.malum.core.handlers.*;
import com.sammy.malum.core.systems.spirit.*;
import net.minecraft.client.renderer.*;
import net.minecraft.client.renderer.blockentity.*;
Expand All @@ -24,7 +23,7 @@ public MoteOfManaRenderer(BlockEntityRendererProvider.Context context) {
@Override
public void render(MoteOfManaBlockEntity blockEntityIn, float partialTicks, PoseStack poseStack, MultiBufferSource bufferIn, int combinedLightIn, int combinedOverlayIn) {
poseStack.pushPose();
MalumSpiritType spiritType = SpiritHarvestHandler.getSpiritType(blockEntityIn.getBlockState().getValue(SpiritMoteBlock.SPIRIT_TYPE));
MalumSpiritType spiritType = MalumSpiritType.getSpiritType(blockEntityIn.getBlockState().getValue(SpiritMoteBlock.SPIRIT_TYPE));

var builder = SpiritBasedWorldVFXBuilder.create(spiritType)
.setRenderType(LodestoneRenderTypes.ADDITIVE_TEXTURE.applyAndCache(MOTE_OF_MANA));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.mojang.blaze3d.vertex.PoseStack;
import com.sammy.malum.common.block.storage.jar.SpiritJarBlockEntity;
import com.sammy.malum.common.item.spirit.SpiritJarItem;
import com.sammy.malum.core.handlers.*;
import com.sammy.malum.core.systems.spirit.*;
import com.sammy.malum.registry.common.block.BlockRegistry;
import com.sammy.malum.registry.common.item.DataComponentRegistry;
import net.minecraft.client.model.geom.EntityModelSet;
Expand All @@ -30,7 +30,7 @@ public void renderByItem(ItemStack pStack, ItemDisplayContext pTransformType, Po
if (pStack.getItem() instanceof SpiritJarItem) {
if (pStack.has(DataComponentRegistry.SPIRIT_JAR_CONTENTS)) {
SpiritJarItem.Contents contents = pStack.get(DataComponentRegistry.SPIRIT_JAR_CONTENTS);
jar.type = SpiritHarvestHandler.getSpiritType(contents.spirit());
jar.type = MalumSpiritType.getSpiritType(contents.spirit());
jar.count = contents.count();

this.blockEntityRenderDispatcher.renderItem(jar, pPoseStack, pBuffer, pPackedLight, pPackedOverlay);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.sammy.malum.common.block.curiosities.mana_mote;

import com.sammy.malum.core.handlers.*;
import com.sammy.malum.core.systems.spirit.*;
import com.sammy.malum.visual_effects.*;
import net.minecraft.client.particle.*;
import net.minecraft.core.*;
Expand All @@ -19,7 +19,7 @@ public boolean addHitEffects(BlockState state, Level level, HitResult target, Pa
@Override
public boolean addDestroyEffects(BlockState state, Level level, BlockPos pos, ParticleEngine manager) {
if (state.getBlock() instanceof SpiritMoteBlock) {
SpiritMoteParticleEffects.destroy(level, pos, state, SpiritHarvestHandler.getSpiritType(state.getValue(SpiritMoteBlock.SPIRIT_TYPE)));
SpiritMoteParticleEffects.destroy(level, pos, state, MalumSpiritType.getSpiritType(state.getValue(SpiritMoteBlock.SPIRIT_TYPE)));
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.sammy.malum.common.block.curiosities.totem;

import com.sammy.malum.common.item.curiosities.tools.*;
import com.sammy.malum.core.handlers.*;
import com.sammy.malum.core.systems.spirit.*;
import com.sammy.malum.registry.common.*;
import com.sammy.malum.registry.common.block.*;
Expand Down Expand Up @@ -107,7 +106,7 @@ protected void saveAdditional(CompoundTag tag, HolderLookup.Provider registries)
@Override
protected void loadAdditional(CompoundTag tag, HolderLookup.Provider pRegistries) {
if (tag.contains("spirit")) {
spirit = SpiritHarvestHandler.getSpiritType(tag.getString("spirit"));
spirit = MalumSpiritType.getSpiritType(tag.getString("spirit"));
}
totemPoleState = tag.contains("state") ? TotemPoleState.values()[tag.getInt("state")] : TotemPoleState.INACTIVE;
chargeProgress = tag.getInt("chargeProgress");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.sammy.malum.common.item.spirit.SpiritJarItem;
import com.sammy.malum.common.item.spirit.SpiritShardItem;
import com.sammy.malum.common.packets.CodecUtil;
import com.sammy.malum.core.handlers.*;
import com.sammy.malum.core.systems.spirit.MalumSpiritType;
import com.sammy.malum.registry.common.block.BlockEntityRegistry;
import com.sammy.malum.registry.common.item.DataComponentRegistry;
Expand Down Expand Up @@ -232,7 +231,7 @@ protected void saveAdditional(CompoundTag compound, HolderLookup.Provider pRegis
@Override
public void loadAdditional(@NotNull CompoundTag compound, HolderLookup.Provider pRegistries) {
if (compound.contains("spirit")) {
type = SpiritHarvestHandler.getSpiritType(compound.getString("spirit"));
type = MalumSpiritType.getSpiritType(compound.getString("spirit"));
} else {
type = null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.sammy.malum.common.block.the_device;

import com.sammy.malum.common.capability.MalumPlayerDataCapability;
import com.sammy.malum.registry.common.SoundRegistry;
import com.sammy.malum.registry.common.*;
import net.minecraft.core.BlockPos;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.InteractionHand;
Expand Down Expand Up @@ -29,7 +28,7 @@ protected ItemInteractionResult useItemOn(ItemStack pStack, BlockState pState, L
pPlayer.swing(pHand, true);
playSound(pLevel, pPos);
if (pPlayer.isCreative()) {
MalumPlayerDataCapability.getCapabilityOptional(pPlayer).ifPresent(it -> it.hasBeenRejected = false);
pPlayer.getData(AttachmentTypeRegistry.PROGRESSION_DATA).hasBeenRejected = false;
}
return ItemInteractionResult.SUCCESS;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.sammy.malum.common.capabilities;

import com.mojang.serialization.*;
import com.mojang.serialization.codecs.*;
import com.sammy.malum.common.capabilities.soul_data.*;
import net.minecraft.core.*;
import net.minecraft.world.item.*;

import java.util.*;

public class CachedSpiritDropsData {

public static final Codec<CachedSpiritDropsData> CODEC = RecordCodecBuilder.create(obj -> obj.group(
Codec.list(ItemStack.CODEC).optionalFieldOf("spiritDrops", Collections.emptyList()).forGetter(c -> c.spiritDrops),
UUIDUtil.CODEC.optionalFieldOf("spiritOwner", null).forGetter(c -> c.spiritOwner)
).apply(obj, CachedSpiritDropsData::new));

private List<ItemStack> spiritDrops = new ArrayList<>();
private UUID spiritOwner;

public CachedSpiritDropsData() {

}
public CachedSpiritDropsData(List<ItemStack> spiritDrops, UUID spiritOwner) {
this.spiritDrops = spiritDrops;
this.spiritOwner = spiritOwner;
}

public List<ItemStack> getSpiritDrops() {
return spiritDrops;
}

public UUID getSpiritOwner() {
return spiritOwner;
}
}
23 changes: 23 additions & 0 deletions src/main/java/com/sammy/malum/common/capabilities/CurioData.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.sammy.malum.common.capabilities;

import com.mojang.serialization.*;
import com.mojang.serialization.codecs.*;

public class CurioData {

public static Codec<CurioData> CODEC = RecordCodecBuilder.create(obj -> obj.group(
Codec.INT.fieldOf("watcherNecklaceCooldown").forGetter(c -> c.watcherNecklaceCooldown),
Codec.INT.fieldOf("hiddenBladeNecklaceCooldown").forGetter(c -> c.hiddenBladeNecklaceCooldown)
).apply(obj, CurioData::new));

public int watcherNecklaceCooldown;
public int hiddenBladeNecklaceCooldown;

public CurioData() {
}

public CurioData(int watcherNecklaceCooldown, int hiddenBladeNecklaceCooldown) {
this.watcherNecklaceCooldown = hiddenBladeNecklaceCooldown;
this.hiddenBladeNecklaceCooldown = hiddenBladeNecklaceCooldown;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.sammy.malum.common.capabilities;

import com.mojang.serialization.*;
import com.mojang.serialization.codecs.*;
import net.minecraft.core.*;
import net.minecraft.world.entity.ai.attributes.*;

import java.util.*;

public class MalignantInfluenceData {

public static Codec<MalignantInfluenceData> CODEC = Codec.unit(MalignantInfluenceData::new);

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

public MalignantInfluenceData() {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.sammy.malum.common.capabilities;

import com.mojang.serialization.*;
import com.mojang.serialization.codecs.*;

public class ProgressionData {

public static Codec<ProgressionData> CODEC = RecordCodecBuilder.create(obj -> obj.group(
Codec.BOOL.fieldOf("obtainedEncyclopedia").forGetter(c -> c.obtainedEncyclopedia),
Codec.BOOL.fieldOf("hasBeenRejected").forGetter(c -> c.hasBeenRejected)
).apply(obj, ProgressionData::new));

public boolean obtainedEncyclopedia;
public boolean hasBeenRejected;

public ProgressionData() {
}

public ProgressionData(boolean obtainedEncyclopedia, boolean hasBeenRejected) {
this.obtainedEncyclopedia = obtainedEncyclopedia;
this.hasBeenRejected = hasBeenRejected;
}
}
110 changes: 110 additions & 0 deletions src/main/java/com/sammy/malum/common/capabilities/SoulWardData.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
package com.sammy.malum.common.capabilities;

import com.mojang.serialization.*;
import com.mojang.serialization.codecs.*;
import com.sammy.malum.config.*;
import com.sammy.malum.registry.common.*;
import net.minecraft.network.*;
import net.minecraft.network.codec.*;
import net.minecraft.util.*;
import net.minecraft.world.entity.*;
import net.minecraft.world.entity.ai.attributes.*;
import net.minecraft.world.entity.player.*;
import team.lodestar.lodestone.helpers.*;

import java.util.*;

public class SoulWardData {

public static Codec<SoulWardData> CODEC = RecordCodecBuilder.create(obj -> obj.group(
Codec.DOUBLE.fieldOf("soulWard").forGetter(sw -> sw.soulWard),
Codec.DOUBLE.fieldOf("soulWardProgress").forGetter(sw -> sw.soulWardCooldown)
).apply(obj, SoulWardData::new));

public static StreamCodec<FriendlyByteBuf, SoulWardData> STREAM_CODEC = StreamCodec.composite(
ByteBufCodecs.DOUBLE, p -> p.soulWard,
ByteBufCodecs.DOUBLE, p -> p.soulWardCooldown,
SoulWardData::new);

private double soulWard;
private double soulWardCooldown;

private boolean isDirty;

public SoulWardData() {
}

public SoulWardData(double soulWard, double soulWardCooldown) {
this.soulWard = soulWard;
this.soulWardCooldown = soulWardCooldown;
}

public void recoverSoulWard(LivingEntity entity, double amount) {
var multiplier = Optional.ofNullable(entity.getAttribute(AttributeRegistry.SOUL_WARD_RECOVERY_MULTIPLIER)).map(AttributeInstance::getValue).orElse(1.0);
addSoulWard(amount * multiplier);
if (!(entity instanceof Player player) || !player.isCreative()) {
var capacity = entity.getAttribute(AttributeRegistry.SOUL_WARD_CAPACITY);
if (capacity != null) {
var sound = soulWard >= capacity.getValue() ? SoundRegistry.SOUL_WARD_CHARGE : SoundRegistry.SOUL_WARD_GROW;
double pitchOffset = (soulWard / capacity.getValue()) * 0.5f + (Mth.ceil(soulWard) % 3) * 0.25f;
SoundHelper.playSound(entity, sound.get(), 0.25f, (float) (1f + pitchOffset));
}
}
addCooldown(entity, 1);
}

public void addSoulWard(double added) {
setSoulWard(soulWard + added);
}

public void reduceSoulWard(double removed) {
setSoulWard(soulWard - removed);
}

public void setSoulWard(double soulWard) {
this.soulWard = Math.max(soulWard, 0);
isDirty = true;
}

public double getSoulWard() {
return soulWard;
}

public void addCooldown(LivingEntity living, double multiplier) {
final double newCooldown = getSoulWardCooldown(living) * multiplier;
if (soulWardCooldown < newCooldown) {
soulWardCooldown = newCooldown;
setDirty(true);
}
}

public void tickCooldown() {
if (soulWardCooldown > 0) {
soulWardCooldown--;
}
}

public double getCooldown() {
return soulWardCooldown;
}

public boolean isDirty() {
return isDirty;
}

public void setDirty(boolean dirty) {
isDirty = dirty;
}

public boolean isDepleted() {
return soulWard <= 0;
}

public static float getSoulWardCooldown(LivingEntity living) {
return getSoulWardCooldown(living.getAttributeValue(AttributeRegistry.SOUL_WARD_RECOVERY_RATE));
}

public static float getSoulWardCooldown(double recoverySpeed) {
return Mth.floor(CommonConfig.SOUL_WARD_RATE.getConfigValue() / recoverySpeed);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.sammy.malum.common.capabilities;

import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;

public class StaffAbilityData {

public static Codec<StaffAbilityData> CODEC = RecordCodecBuilder.create(obj -> obj.group(
Codec.INT.fieldOf("reserveChargeCount").forGetter(c -> c.reserveChargeCount),
Codec.FLOAT.fieldOf("reserveChargeProgress").forGetter(c -> c.reserveChargeProgress)
).apply(obj, StaffAbilityData::new));

public int reserveChargeCount;
public float reserveChargeProgress;

public StaffAbilityData() {
}

public StaffAbilityData(int reserveChargeCount, float reserveChargeProgress) {
this.reserveChargeCount = reserveChargeCount;
this.reserveChargeProgress = reserveChargeProgress;
}
}
Loading

0 comments on commit 8d402d0

Please sign in to comment.