Skip to content

Commit

Permalink
Fix spirit jar
Browse files Browse the repository at this point in the history
  • Loading branch information
SammySemicolon committed Mar 2, 2025
1 parent 0ee259b commit f5a061b
Show file tree
Hide file tree
Showing 16 changed files with 191 additions and 195 deletions.
1 change: 1 addition & 0 deletions src/generated/resources/assets/malum/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,7 @@
"malum.effect.geas.explosion_fire": "Overexertion Ignites You",
"malum.effect.geas.explosion_lover": "Absorbed Explosions Generate Haste",
"malum.effect.geas.fall_damage_auto_attack": "Outgoing Fall Damage Strikes Targets With Your Held Weapon Regardless Of Distance",
"malum.effect.geas.faster_natural_healing": "Saturation Heals Faster",
"malum.effect.geas.gleeful_target": "Aliments, Blessings, Curses are Paused When Wounded",
"malum.effect.geas.gleeful_target_arcane_resonance": "Arcane Resonance Aids Stasis Duration",
"malum.effect.geas.hunger_as_withdrawal": "Addiction to Slaughter",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,8 @@
},
{
"function": "minecraft:copy_components",
"source": "block_entity"
},
{
"function": "minecraft:copy_custom_data",
"ops": [
{
"op": "replace",
"source": "spirit",
"target": "spirit"
},
{
"op": "replace",
"source": "count",
"target": "count"
}
"include": [
"malum:spirit_jar_contents"
],
"source": "block_entity"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public SpiritJarRenderer(BlockEntityRendererProvider.Context context) {
public void render(SpiritJarBlockEntity blockEntityIn, float partialTicks, PoseStack poseStack, MultiBufferSource bufferIn, int combinedLightIn, int combinedOverlayIn) {
Level level = Minecraft.getInstance().level;
ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer();
if (blockEntityIn.type != null) {
final MalumSpiritType type = blockEntityIn.type;
if (blockEntityIn.contents != null) {
var type = blockEntityIn.contents.spirit();
double time = ((level.getGameTime() + partialTicks) * 0.05f) % 6.28f;
double y = 0.5f + (float) Math.sin(time) * 0.2f;
poseStack.pushPose();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.mojang.blaze3d.vertex.PoseStack;
import com.sammy.malum.common.block.storage.jar.SpiritJarBlockEntity;
import com.sammy.malum.common.data_components.*;
import com.sammy.malum.common.item.spirit.SpiritJarItem;
import com.sammy.malum.core.systems.spirit.*;
import com.sammy.malum.registry.common.block.BlockRegistry;
Expand Down Expand Up @@ -29,10 +30,7 @@ public SpiritJarItemRenderer(BlockEntityRenderDispatcher pBlockEntityRenderDispa
public void renderByItem(ItemStack pStack, ItemDisplayContext pTransformType, PoseStack pPoseStack, MultiBufferSource pBuffer, int pPackedLight, int pPackedOverlay) {
if (pStack.getItem() instanceof SpiritJarItem) {
if (pStack.has(DataComponentRegistry.SPIRIT_JAR_CONTENTS)) {
SpiritJarItem.Contents contents = pStack.get(DataComponentRegistry.SPIRIT_JAR_CONTENTS);
jar.type = MalumSpiritType.getSpiritType(contents.spirit());
jar.count = contents.count();

jar.contents = pStack.get(DataComponentRegistry.SPIRIT_JAR_CONTENTS);
this.blockEntityRenderDispatcher.renderItem(jar, pPoseStack, pBuffer, pPackedLight, pPackedOverlay);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ public static void setupEntries(ArcanaProgressionScreen screen) {
screen.addEntry("pact_of_the_shield", -2, 11, b -> b
.configureWidget(w -> w.setIcon(MalumGeasEffectTypeRegistry.PACT_OF_THE_SHIELD))
);
screen.addEntry("pact_of_the_fortress", -3, 10, b -> b
screen.addEntry("pact_of_the_fortress", -3, 12, b -> b
.configureWidget(w -> w.setIcon(MalumGeasEffectTypeRegistry.PACT_OF_THE_FORTRESS))
);

screen.addEntry("pact_of_the_animated", 2, 11, b -> b
.configureWidget(w -> w.setIcon(MalumGeasEffectTypeRegistry.PACT_OF_THE_ANIMATED))
);
screen.addEntry("pact_of_the_wise", 3, 10, b -> b
screen.addEntry("pact_of_the_wise", 3, 12, b -> b
.configureWidget(w -> w.setIcon(MalumGeasEffectTypeRegistry.PACT_OF_THE_ANIMATED))
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class TotemMagicEntries {
public static void setupEntries(ArcanaProgressionScreen screen) {
Item EMPTY = ItemStack.EMPTY.getItem();

screen.addEntry("totem_magic", 0, 13, b -> b
screen.addEntry("totem_magic", 0, 14, b -> b
.configureWidget(w -> w.setIcon(RUNEWOOD_TOTEM_BASE).setStyle(BookWidgetStyle.GILDED_RUNEWOOD))
.addPage(new HeadlineTextItemPage("totem_magic", "totem_magic.1", RUNEWOOD_TOTEM_BASE.get()))
.addPage(new TextPage("totem_magic.2"))
Expand All @@ -29,7 +29,7 @@ public static void setupEntries(ArcanaProgressionScreen screen) {
.addPage(SpiritInfusionPage.fromOutput(RUNEWOOD_TOTEM_BASE.get()))
);

screen.addEntry("managing_totems", 0, 14, b -> b
screen.addEntry("managing_totems", 0, 16, b -> b
.configureWidget(w -> w.setIcon(TOTEMIC_STAFF).setStyle(BookWidgetStyle.SMALL_RUNEWOOD))
.addPage(new HeadlineTextItemPage("managing_totems", "managing_totems.1", TOTEMIC_STAFF.get()))
.addPage(new TextPage("managing_totems.2"))
Expand All @@ -41,7 +41,7 @@ public static void setupEntries(ArcanaProgressionScreen screen) {
))
);

screen.addEntry("sacred_rite", -2, 14, b -> b
screen.addEntry("sacred_rite", -2, 16, b -> b
.setWidgetSupplier(RiteEntryObject::new)
.configureWidget(w -> w.setStyle(BookWidgetStyle.DARK_TOTEMIC_RUNEWOOD))
.addPage(new SpiritRiteTextPage(SpiritRiteRegistry.SACRED_RITE, "sacred_rite"))
Expand All @@ -50,7 +50,7 @@ public static void setupEntries(ArcanaProgressionScreen screen) {
.addPage(new SpiritRiteRecipePage(SpiritRiteRegistry.ELDRITCH_SACRED_RITE))
);

screen.addEntry("corrupt_sacred_rite", -3, 14, b -> b
screen.addEntry("corrupt_sacred_rite", -3, 16, b -> b
.setWidgetSupplier(RiteEntryObject::new)
.configureWidget(w -> w.setStyle(BookWidgetStyle.DARK_TOTEMIC_SOULWOOD))
.addPage(new SpiritRiteTextPage(SpiritRiteRegistry.SACRED_RITE, "corrupt_sacred_rite"))
Expand All @@ -59,7 +59,7 @@ public static void setupEntries(ArcanaProgressionScreen screen) {
.addPage(new SpiritRiteRecipePage(SpiritRiteRegistry.ELDRITCH_SACRED_RITE))
);

screen.addEntry("infernal_rite", -3, 15, b -> b
screen.addEntry("infernal_rite", -3, 16, b -> b
.setWidgetSupplier(RiteEntryObject::new)
.configureWidget(w -> w.setStyle(BookWidgetStyle.DARK_TOTEMIC_RUNEWOOD))
.addPage(new SpiritRiteTextPage(SpiritRiteRegistry.INFERNAL_RITE, "infernal_rite"))
Expand All @@ -68,7 +68,7 @@ public static void setupEntries(ArcanaProgressionScreen screen) {
.addPage(new SpiritRiteRecipePage(SpiritRiteRegistry.ELDRITCH_INFERNAL_RITE))
);

screen.addEntry("corrupt_infernal_rite", -4, 15, b -> b
screen.addEntry("corrupt_infernal_rite", -4, 16, b -> b
.configureWidget(w -> w.setStyle(BookWidgetStyle.DARK_TOTEMIC_SOULWOOD))
.setWidgetSupplier(RiteEntryObject::new)
.addPage(new SpiritRiteTextPage(SpiritRiteRegistry.INFERNAL_RITE, "corrupt_infernal_rite"))
Expand All @@ -95,7 +95,7 @@ public static void setupEntries(ArcanaProgressionScreen screen) {
.addPage(new SpiritRiteRecipePage(SpiritRiteRegistry.ELDRITCH_EARTHEN_RITE))
);

screen.addEntry("wicked_rite", 2, 14, b -> b
screen.addEntry("wicked_rite", 2, 16, b -> b
.setWidgetSupplier(RiteEntryObject::new)
.configureWidget(w -> w.setStyle(BookWidgetStyle.DARK_TOTEMIC_RUNEWOOD))
.addPage(new SpiritRiteTextPage(SpiritRiteRegistry.WICKED_RITE, "wicked_rite"))
Expand All @@ -104,7 +104,7 @@ public static void setupEntries(ArcanaProgressionScreen screen) {
.addPage(new SpiritRiteRecipePage(SpiritRiteRegistry.ELDRITCH_WICKED_RITE))
);

screen.addEntry("corrupt_wicked_rite", 3, 14, b -> b
screen.addEntry("corrupt_wicked_rite", 3, 16, b -> b
.configureWidget(w -> w.setStyle(BookWidgetStyle.DARK_TOTEMIC_SOULWOOD))
.setWidgetSupplier(RiteEntryObject::new)
.addPage(new SpiritRiteTextPage(SpiritRiteRegistry.WICKED_RITE, "corrupt_wicked_rite"))
Expand All @@ -113,7 +113,7 @@ public static void setupEntries(ArcanaProgressionScreen screen) {
.addPage(new SpiritRiteRecipePage(SpiritRiteRegistry.ELDRITCH_WICKED_RITE))
);

screen.addEntry("aerial_rite", 3, 15, b -> b
screen.addEntry("aerial_rite", 3, 16, b -> b
.setWidgetSupplier(RiteEntryObject::new)
.configureWidget(w -> w.setStyle(BookWidgetStyle.DARK_TOTEMIC_RUNEWOOD))
.addPage(new SpiritRiteTextPage(SpiritRiteRegistry.AERIAL_RITE, "aerial_rite"))
Expand All @@ -122,7 +122,7 @@ public static void setupEntries(ArcanaProgressionScreen screen) {
.addPage(new SpiritRiteRecipePage(SpiritRiteRegistry.ELDRITCH_AERIAL_RITE))
);

screen.addEntry("corrupt_aerial_rite", 4, 15, b -> b
screen.addEntry("corrupt_aerial_rite", 4, 16, b -> b
.configureWidget(w -> w.setStyle(BookWidgetStyle.DARK_TOTEMIC_SOULWOOD))
.setWidgetSupplier(RiteEntryObject::new)
.addPage(new SpiritRiteTextPage(SpiritRiteRegistry.AERIAL_RITE, "corrupt_aerial_rite"))
Expand Down Expand Up @@ -163,15 +163,15 @@ public static void setupEntries(ArcanaProgressionScreen screen) {
.addPage(SpiritInfusionPage.fromOutput(SOULWOOD_TOTEM_BASE.get()))
);

screen.addEntry("blight", -1, 17, b -> b
screen.addEntry("blight", -1, 19, b -> b
.configureWidget(w -> w.setIcon(BLIGHTED_GUNK).setStyle(BookWidgetStyle.SMALL_SOULWOOD))
.addPage(new HeadlineTextPage("blight.intro", "blight.intro.1"))
.addPage(new HeadlineTextPage("blight.composition", "blight.composition.1"))
.addPage(new HeadlineTextPage("blight.spread", "blight.spread.1"))
.addPage(new HeadlineTextPage("blight.arcane_rite", "blight.arcane_rite.1"))
);

screen.addEntry("soulwood", 1, 17, b -> b
screen.addEntry("soulwood", 1, 19, b -> b
.configureWidget(w -> w.setIcon(SOULWOOD_GROWTH).setStyle(BookWidgetStyle.SMALL_SOULWOOD))
.addPage(new HeadlineTextItemPage("soulwood", "soulwood.1", SOULWOOD_GROWTH.get()))
.addPage(new TextPage("soulwood.2"))
Expand All @@ -185,7 +185,7 @@ public static void setupEntries(ArcanaProgressionScreen screen) {
new CraftingPage(new ItemStack(CURSED_SAP_BLOCK.get(), 8), CURSED_SAP.get(), CURSED_SAP.get(), EMPTY, CURSED_SAP.get(), CURSED_SAP.get()))
));

screen.addEntry("unchained_transmutation", 0, 18, b -> b
screen.addEntry("unchained_transmutation", 0, 19, b -> b
.configureWidget(w -> w.setIcon(SOUL_SAND).setStyle(BookWidgetStyle.SOULWOOD))
.addPage(new HeadlineTextPage("unchained_transmutation", "unchained_transmutation.intro.1"))
.addPage(new TextPage("unchained_transmutation.intro.2"))
Expand All @@ -205,7 +205,7 @@ public static void setupEntries(ArcanaProgressionScreen screen) {
.addPage(new SpiritTransmutationRecipeTreePage("unchained_transmutation.deepslate", DEEPSLATE))
);

screen.addEntry("totemic_runes", 0, 17, b -> b
screen.addEntry("totemic_runes", 0, 19, b -> b
.configureWidget(w -> w.setIcon(RUNE_OF_THE_ARENA).setStyle(BookWidgetStyle.SOULWOOD))
.addPage(new HeadlineTextPage("totemic_runes", "totemic_runes.1"))
.addPage(new TextPage("totemic_runes.2"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.sammy.malum.common.block.*;
import com.sammy.malum.common.block.storage.*;
import com.sammy.malum.common.block.storage.jar.*;
import com.sammy.malum.common.data_components.*;
import com.sammy.malum.common.item.spirit.*;
import com.sammy.malum.core.systems.ritual.*;
import com.sammy.malum.core.systems.spirit.*;
Expand Down Expand Up @@ -288,20 +289,21 @@ public void eatSpirits() {
}
}
for (SpiritJarBlockEntity jar : jars) {
if (spirit.equals(jar.type) && jar.count > 0) {
absorptionProgress.compute(jar, (p, i) -> i == null ? 1 : i + 1);
if (absorptionProgress.get(jar) >= 5) {
final BlockPos jarPosition = jar.getBlockPos();
final int absorbedAmount = Math.min(jar.count, ritualTier == null ? 4 : ritualTier.spiritThreshold/16);
increase += absorbedAmount;
jar.count -= absorbedAmount;
if (jar.count == 0) {
jar.type = null;
final SpiritJarContentsComponent contents = jar.contents;
if (contents != null) {
var jarSpirit = contents.spirit();
if (spirit.equals(jarSpirit)) {
absorptionProgress.compute(jar, (p, i) -> i == null ? 1 : i + 1);
if (absorptionProgress.get(jar) >= 5) {
final BlockPos jarPosition = jar.getBlockPos();
final int absorbedAmount = Math.min(contents.count(), ritualTier == null ? 4 : ritualTier.spiritThreshold / 16);
increase += absorbedAmount;
jar.contents = contents.remove(absorbedAmount);
level.playSound(null, jarPosition, SoundRegistry.RITUAL_ABSORBS_SPIRIT.get(), SoundSource.BLOCKS, 1, 0.9f + level.random.nextFloat() * 0.2f);
ParticleEffectTypeRegistry.RITUAL_PLINTH_EATS_SPIRIT.createPositionedEffect((ServerLevel) level, new PositionEffectData(worldPosition), new ColorEffectData(spirit), RitualPlinthAbsorbItemParticleEffect.createData(jar.getItemPos(), spirit.getSpiritShard().getDefaultInstance()));
absorptionProgress.remove(jar);
BlockStateHelper.updateAndNotifyState(level, jarPosition);
}
level.playSound(null, jarPosition, SoundRegistry.RITUAL_ABSORBS_SPIRIT.get(), SoundSource.BLOCKS, 1, 0.9f + level.random.nextFloat() * 0.2f);
ParticleEffectTypeRegistry.RITUAL_PLINTH_EATS_SPIRIT.createPositionedEffect((ServerLevel) level, new PositionEffectData(worldPosition), new ColorEffectData(spirit), RitualPlinthAbsorbItemParticleEffect.createData(jar.getItemPos(), spirit.getSpiritShard().getDefaultInstance()));
absorptionProgress.remove(jar);
BlockStateHelper.updateAndNotifyState(level, jarPosition);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,11 @@

public class EtherBlockEntity extends LodestoneBlockEntity {

public DyedItemColor firstColor;
public DyedItemColor secondColor;
public DyedItemColor firstColor = EtherItem.DEFAULT_FIRST_COLOR;
public DyedItemColor secondColor = EtherItem.DEFAULT_SECOND_COLOR;

public EtherBlockEntity(BlockEntityType<? extends EtherBlockEntity> type, BlockPos pos, BlockState state) {
super(type, pos, state);
this.firstColor = EtherItem.DEFAULT_FIRST_COLOR;
this.secondColor = EtherItem.DEFAULT_FIRST_COLOR;
}

public EtherBlockEntity(BlockPos pos, BlockState state) {
Expand All @@ -57,6 +55,7 @@ protected void applyImplicitComponents(BlockEntity.DataComponentInput componentI
firstColor = componentInput.get(DataComponents.DYED_COLOR);
secondColor = componentInput.get(DataComponentRegistry.SECONDARY_DYED_COLOR);
}

@Override
public void removeComponentsFromTag(CompoundTag tag) {
tag.remove("firstColor");
Expand All @@ -65,27 +64,23 @@ public void removeComponentsFromTag(CompoundTag tag) {

@Override
protected void loadAdditional(CompoundTag tag, HolderLookup.Provider registries) {
firstColor = DyedItemColor.CODEC.parse(NbtOps.INSTANCE, tag.get("firstColor")).result().orElse(firstColor);
if (firstColor == null) {
firstColor = EtherItem.DEFAULT_FIRST_COLOR;
}
secondColor = DyedItemColor.CODEC.parse(NbtOps.INSTANCE, tag.get("secondColor")).result().orElse(secondColor);
if (secondColor == null) {
if (EtherItem.isIridescent(getBlockState().getBlock().asItem().getDefaultInstance())) {
secondColor = EtherItem.DEFAULT_SECOND_COLOR;
return;
}
firstColor = DyedItemColor.CODEC.parse(NbtOps.INSTANCE, tag.get("firstColor")).result().orElse(EtherItem.DEFAULT_FIRST_COLOR);
if (!EtherItem.isIridescent(this)) {
secondColor = firstColor;
return;
}
secondColor = DyedItemColor.CODEC.parse(NbtOps.INSTANCE, tag.get("secondColor")).result().orElse(EtherItem.DEFAULT_SECOND_COLOR);
}

@Override
protected void saveAdditional(CompoundTag tag, HolderLookup.Provider registries) {
if (firstColor != null) {
tag.put("firstColor", DyedItemColor.CODEC.encodeStart(NbtOps.INSTANCE, firstColor).getOrThrow());
}
if (secondColor != null) {
tag.put("secondColor", DyedItemColor.CODEC.encodeStart(NbtOps.INSTANCE, secondColor).getOrThrow());
if (EtherItem.isIridescent(this)) {
if (secondColor != null) {
tag.put("secondColor", DyedItemColor.CODEC.encodeStart(NbtOps.INSTANCE, secondColor).getOrThrow());
}
}
super.saveAdditional(tag, registries);
}
Expand Down Expand Up @@ -124,7 +119,7 @@ public void tick() {
int lifeTime = RandomHelper.randomBetween(random, 50, 60);
float scale = RandomHelper.randomBetween(random, 0.7f, 0.9f);
float velocity = RandomHelper.randomBetween(random, 0.02f, 0.025f);
var lightSpecs = SpiritLightSpecs.spiritLightSpecs(level, new Vec3(x, y-0.05f, z), color);
var lightSpecs = SpiritLightSpecs.spiritLightSpecs(level, new Vec3(x, y - 0.05f, z), color);
lightSpecs.getBuilder()
.setRenderTarget(RenderHandler.LATE_DELAYED_RENDER)
.setLifetime(lifeTime)
Expand All @@ -139,7 +134,7 @@ public void tick() {
int lifeTime = RandomHelper.randomBetween(random, 50, 60);
float scale = RandomHelper.randomBetween(random, 0.3f, 0.5f);
float velocity = RandomHelper.randomBetween(random, 0.02f, 0.025f);
var lightSpecs = SparkParticleEffects.spiritMotionSparks(level, new Vec3(x, y-0.05f, z), color);
var lightSpecs = SparkParticleEffects.spiritMotionSparks(level, new Vec3(x, y - 0.05f, z), color);
lightSpecs.getBuilder()
.setRenderTarget(RenderHandler.LATE_DELAYED_RENDER)
.setLifetime(lifeTime)
Expand Down
Loading

0 comments on commit f5a061b

Please sign in to comment.