diff --git a/gradle.properties b/gradle.properties index 6e146e892..7b2df9e6c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ org.gradle.daemon=false # Dependency Version minecraftVersion=1.18.2 forgeVersion=40.2.0 -lodestoneVersion=1.4.2.476 +lodestoneVersion=1.4.2.484 forgegradleVersion=5.1.53 mixingradleVersion=0.7-SNAPSHOT librarianVersion=1.+ diff --git a/src/main/java/com/sammy/malum/client/particles/slash/SoulSlashParticle.java b/src/main/java/com/sammy/malum/client/particles/slash/SoulSlashParticle.java deleted file mode 100644 index 901352a8d..000000000 --- a/src/main/java/com/sammy/malum/client/particles/slash/SoulSlashParticle.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.sammy.malum.client.particles.slash; - -import com.mojang.blaze3d.vertex.*; -import net.minecraft.client.*; -import net.minecraft.client.multiplayer.*; -import net.minecraft.client.particle.*; -import team.lodestar.lodestone.systems.particle.world.*; - -public class SoulSlashParticle extends GenericParticle { - - public SoulSlashParticle(ClientLevel world, WorldParticleOptions options, ParticleEngine.MutableSpriteSet spriteSet, double x, double y, double z, double xd, double yd, double zd) { - super(world, options, spriteSet, x, y, z, xd, yd, zd); - } - - @Override - public void tick() { - super.tick(); - } - - @Override - public void render(VertexConsumer consumer, Camera camera, float partialTicks) { - super.render(consumer, camera, partialTicks); - } - - @Override - protected int getLightColor(float partialTicks) { - return 0xF000F0; - } -} \ No newline at end of file diff --git a/src/main/java/com/sammy/malum/client/particles/spiritflame/SpiritFlameParticle.java b/src/main/java/com/sammy/malum/client/particles/spiritflame/SpiritFlameParticle.java index 99bfe24fc..6dfe10f91 100644 --- a/src/main/java/com/sammy/malum/client/particles/spiritflame/SpiritFlameParticle.java +++ b/src/main/java/com/sammy/malum/client/particles/spiritflame/SpiritFlameParticle.java @@ -2,8 +2,8 @@ import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.particle.ParticleEngine; +import team.lodestar.lodestone.systems.particle.options.*; import team.lodestar.lodestone.systems.particle.world.FrameSetParticle; -import team.lodestar.lodestone.systems.particle.world.WorldParticleOptions; public class SpiritFlameParticle extends FrameSetParticle { diff --git a/src/main/java/com/sammy/malum/client/particles/spiritflame/SpiritFlameParticleType.java b/src/main/java/com/sammy/malum/client/particles/spiritflame/SpiritFlameParticleType.java index 9a63881f0..1ee942f30 100644 --- a/src/main/java/com/sammy/malum/client/particles/spiritflame/SpiritFlameParticleType.java +++ b/src/main/java/com/sammy/malum/client/particles/spiritflame/SpiritFlameParticleType.java @@ -7,7 +7,7 @@ import net.minecraft.client.particle.ParticleProvider; import net.minecraft.client.particle.SpriteSet; import net.minecraft.core.particles.ParticleType; -import team.lodestar.lodestone.systems.particle.world.WorldParticleOptions; +import team.lodestar.lodestone.systems.particle.options.*; import javax.annotation.Nullable; diff --git a/src/main/java/com/sammy/malum/client/renderer/block/SpiritJarRenderer.java b/src/main/java/com/sammy/malum/client/renderer/block/SpiritJarRenderer.java index 076c6c4e3..9692beaf2 100644 --- a/src/main/java/com/sammy/malum/client/renderer/block/SpiritJarRenderer.java +++ b/src/main/java/com/sammy/malum/client/renderer/block/SpiritJarRenderer.java @@ -28,7 +28,7 @@ public void render(SpiritJarBlockEntity blockEntityIn, float partialTicks, PoseS poseStack.translate(0.5f, y, 0.5f); poseStack.mulPose(Vector3f.YP.rotationDegrees(((level.getGameTime() % 360) + partialTicks) * 3)); poseStack.scale(0.6f, 0.6f, 0.6f); - itemRenderer.renderStatic(blockEntityIn.type.getSpiritShardItem().getDefaultInstance(), ItemTransforms.TransformType.FIXED, combinedLightIn, NO_OVERLAY, poseStack, bufferIn, 0); + itemRenderer.renderStatic(blockEntityIn.type.spiritShard.get().getDefaultInstance(), ItemTransforms.TransformType.FIXED, combinedLightIn, NO_OVERLAY, poseStack, bufferIn, 0); poseStack.popPose(); } } diff --git a/src/main/java/com/sammy/malum/client/renderer/entity/FloatingItemEntityRenderer.java b/src/main/java/com/sammy/malum/client/renderer/entity/FloatingItemEntityRenderer.java index 255140c24..75fe6dec2 100644 --- a/src/main/java/com/sammy/malum/client/renderer/entity/FloatingItemEntityRenderer.java +++ b/src/main/java/com/sammy/malum/client/renderer/entity/FloatingItemEntityRenderer.java @@ -20,7 +20,9 @@ import team.lodestar.lodestone.systems.rendering.*; import team.lodestar.lodestone.systems.rendering.trail.*; +import java.awt.*; import java.util.*; +import java.util.List; import java.util.stream.*; import static com.sammy.malum.MalumMod.*; @@ -51,13 +53,15 @@ public void render(FloatingItemEntity entity, float entityYaw, float partialTick poseStack.translate(-x, -y, -z); VFXBuilders.WorldVFXBuilder builder = VFXBuilders.createWorld().setPosColorTexLightmapDefaultFormat(); VertexConsumer lightBuffer = DELAYED_RENDER.getBuffer(LIGHT_TYPE); + final Color primaryColor = entity.spiritType.getPrimaryColor(); + final Color secondaryColor = entity.spiritType.getSecondaryColor(); for (int i = 0; i < 2; i++) { float size = 0.2f + i * 0.2f; float alpha = (0.7f - i * 0.35f); builder.setAlpha(alpha) - .renderTrail(lightBuffer, poseStack, trailPoints, f -> size, f -> builder.setAlpha(alpha * f).setColor(ColorHelper.colorLerp(Easing.SINE_IN, f * 2f, entity.endColor, entity.startColor))) - .renderTrail(lightBuffer, poseStack, trailPoints, f -> 1.5f * size, f -> builder.setAlpha(alpha * f / 2f).setColor(ColorHelper.colorLerp(Easing.SINE_IN, f * 1.5f, entity.endColor, entity.startColor))) - .renderTrail(lightBuffer, poseStack, trailPoints, f -> size * 2.5f, f -> builder.setAlpha(alpha * f / 4f).setColor(ColorHelper.colorLerp(Easing.SINE_IN, f * 1.5f, entity.endColor, entity.startColor))); + .renderTrail(lightBuffer, poseStack, trailPoints, f -> size, f -> builder.setAlpha(alpha * f).setColor(ColorHelper.colorLerp(Easing.SINE_IN, f * 2f, secondaryColor, primaryColor))) + .renderTrail(lightBuffer, poseStack, trailPoints, f -> 1.5f * size, f -> builder.setAlpha(alpha * f / 2f).setColor(ColorHelper.colorLerp(Easing.SINE_IN, f * 1.5f, secondaryColor, primaryColor))) + .renderTrail(lightBuffer, poseStack, trailPoints, f -> size * 2.5f, f -> builder.setAlpha(alpha * f / 4f).setColor(ColorHelper.colorLerp(Easing.SINE_IN, f * 1.5f, secondaryColor, primaryColor))); } poseStack.translate(x, y, z); } @@ -69,7 +73,7 @@ public void render(FloatingItemEntity entity, float entityYaw, float partialTick public static void renderSpirit(FloatingItemEntity entity, ItemRenderer itemRenderer, float partialTicks, PoseStack poseStack, MultiBufferSource bufferIn, int packedLightIn) { ItemStack itemStack = entity.getItem(); BakedModel model = itemRenderer.getModel(itemStack, entity.level, null, entity.getItem().getCount()); - VFXBuilders.WorldVFXBuilder builder = VFXBuilders.createWorld().setPosColorTexLightmapDefaultFormat().setColor(entity.startColor); + VFXBuilders.WorldVFXBuilder builder = VFXBuilders.createWorld().setPosColorTexLightmapDefaultFormat().setColor(entity.spiritType.getPrimaryColor()); float yOffset = entity.getYOffset(partialTicks); float scale = model.getTransforms().getTransform(ItemTransforms.TransformType.GROUND).scale.y(); float rotation = entity.getRotation(partialTicks); diff --git a/src/main/java/com/sammy/malum/client/screen/codex/pages/SpiritRiteRecipePage.java b/src/main/java/com/sammy/malum/client/screen/codex/pages/SpiritRiteRecipePage.java index 909dbc461..57baaa95d 100644 --- a/src/main/java/com/sammy/malum/client/screen/codex/pages/SpiritRiteRecipePage.java +++ b/src/main/java/com/sammy/malum/client/screen/codex/pages/SpiritRiteRecipePage.java @@ -36,7 +36,7 @@ public void renderRight(Minecraft minecraft, PoseStack poseStack, EntryScreen sc public void renderRite(PoseStack poseStack, EntryScreen screen, int left, int top, int mouseX, int mouseY, List spirits) { for (int i = 0; i < spirits.size(); i++) { - ItemStack stack = spirits.get(i).getSpiritShardItem().getDefaultInstance(); + ItemStack stack = spirits.get(i).spiritShard.get().getDefaultInstance(); renderItem(screen, poseStack, stack, left, top - 20 * i, mouseX, mouseY); } } diff --git a/src/main/java/com/sammy/malum/common/block/curiosities/spirit_crucible/SpiritCrucibleCoreBlockEntity.java b/src/main/java/com/sammy/malum/common/block/curiosities/spirit_crucible/SpiritCrucibleCoreBlockEntity.java index 84911d1b6..4231c1dc5 100644 --- a/src/main/java/com/sammy/malum/common/block/curiosities/spirit_crucible/SpiritCrucibleCoreBlockEntity.java +++ b/src/main/java/com/sammy/malum/common/block/curiosities/spirit_crucible/SpiritCrucibleCoreBlockEntity.java @@ -458,12 +458,10 @@ public void passiveParticles() { ItemStack item = spiritInventory.getStackInSlot(i); if (item.getItem() instanceof SpiritShardItem spiritSplinterItem) { Vec3 offset = spiritOffset(spiritsRendered++, 0); - Color color = spiritSplinterItem.type.getPrimaryColor(); - Color endColor = spiritSplinterItem.type.getSecondaryColor(); double x = getBlockPos().getX() + offset.x(); double y = getBlockPos().getY() + offset.y(); double z = getBlockPos().getZ() + offset.z(); - SpiritLightSpecs.spiritLightSpecs(level, new Vec3(x,y,z), color, endColor); + SpiritLightSpecs.spiritLightSpecs(level, new Vec3(x,y,z), spiritSplinterItem.type); } } } diff --git a/src/main/java/com/sammy/malum/common/block/curiosities/weeping_well/VoidConduitBlockEntity.java b/src/main/java/com/sammy/malum/common/block/curiosities/weeping_well/VoidConduitBlockEntity.java index e39923a75..589fb9259 100644 --- a/src/main/java/com/sammy/malum/common/block/curiosities/weeping_well/VoidConduitBlockEntity.java +++ b/src/main/java/com/sammy/malum/common/block/curiosities/weeping_well/VoidConduitBlockEntity.java @@ -25,6 +25,7 @@ import team.lodestar.lodestone.systems.particle.data.*; import team.lodestar.lodestone.systems.particle.data.color.*; import team.lodestar.lodestone.systems.particle.data.spin.*; +import team.lodestar.lodestone.systems.particle.render_types.*; import team.lodestar.lodestone.systems.particle.world.*; import java.awt.*; diff --git a/src/main/java/com/sammy/malum/common/block/ether/EtherBlockEntity.java b/src/main/java/com/sammy/malum/common/block/ether/EtherBlockEntity.java index 975943b8f..9a568f448 100644 --- a/src/main/java/com/sammy/malum/common/block/ether/EtherBlockEntity.java +++ b/src/main/java/com/sammy/malum/common/block/ether/EtherBlockEntity.java @@ -160,7 +160,7 @@ public void tick() { .setRandomOffset(0.15f, 0.2f) .addMotion(0, 0.0035f, 0) .setRandomMotion(0.001f, 0.005f) - .addActor(p -> p.setParticleSpeed(p.getParticleSpeed().scale(0.985f-level.random.nextFloat() * 0.04f))) + .addActor(p -> p.setParticleMotion(p.getParticleSpeed().scale(0.985f-level.random.nextFloat() * 0.04f))) .enableNoClip() .setDiscardFunction(SimpleParticleOptions.ParticleDiscardFunctionType.ENDING_CURVE_INVISIBLE) .spawn(level, x, y, z); @@ -173,7 +173,7 @@ public void tick() { .setRandomOffset(0.1f, 0.225f) .addMotion(0, velocity / 2f, 0) .setRandomMotion(0, 0.015f) - .addActor(p -> p.setParticleSpeed(p.getParticleSpeed().scale(0.97f-level.random.nextFloat() * 0.025f))) + .addActor(p -> p.setParticleMotion(p.getParticleSpeed().scale(0.97f-level.random.nextFloat() * 0.025f))) .enableNoClip() .setDiscardFunction(SimpleParticleOptions.ParticleDiscardFunctionType.ENDING_CURVE_INVISIBLE) .spawn(level, x, y, z); diff --git a/src/main/java/com/sammy/malum/common/block/mana_mote/SoulstoneBlock.java b/src/main/java/com/sammy/malum/common/block/mana_mote/SoulstoneBlock.java index 15bee5d68..49ce63b07 100644 --- a/src/main/java/com/sammy/malum/common/block/mana_mote/SoulstoneBlock.java +++ b/src/main/java/com/sammy/malum/common/block/mana_mote/SoulstoneBlock.java @@ -27,7 +27,7 @@ public InteractionResult use(BlockState pState, Level pLevel, BlockPos pPos, Pla return super.use(pState, pLevel, pPos, player, pHand, pHit); } MalumSpiritType spiritType = spiritShardItem.type; - BlockState blockstate = spiritType.getSpiritMoteBlock().defaultBlockState(); + BlockState blockstate = spiritType.spiritMote.get().defaultBlockState(); SoundType soundtype = blockstate.getSoundType(pLevel, pPos, player); pLevel.setBlock(pPos, blockstate, 3); pLevel.levelEvent(2001, pPos, Block.getId(pState)); diff --git a/src/main/java/com/sammy/malum/common/block/storage/MalumItemHolderBlockEntity.java b/src/main/java/com/sammy/malum/common/block/storage/MalumItemHolderBlockEntity.java index 840f4dccc..c1a7b53ad 100644 --- a/src/main/java/com/sammy/malum/common/block/storage/MalumItemHolderBlockEntity.java +++ b/src/main/java/com/sammy/malum/common/block/storage/MalumItemHolderBlockEntity.java @@ -48,7 +48,7 @@ public void tick() { if (level.isClientSide) { if (inventory.getStackInSlot(0).getItem() instanceof SpiritShardItem item) { MalumSpiritType type = item.type; - SpiritLightSpecs.rotatingLightSpecs(level, getItemCenterPos(), type.getPrimaryColor(), type.getSecondaryColor(), 0.4f, 2); + SpiritLightSpecs.rotatingLightSpecs(level, getItemCenterPos(), type, 0.4f, 2); } } } diff --git a/src/main/java/com/sammy/malum/common/block/storage/jar/SpiritJarBlockEntity.java b/src/main/java/com/sammy/malum/common/block/storage/jar/SpiritJarBlockEntity.java index 0020df7b1..e7f965563 100644 --- a/src/main/java/com/sammy/malum/common/block/storage/jar/SpiritJarBlockEntity.java +++ b/src/main/java/com/sammy/malum/common/block/storage/jar/SpiritJarBlockEntity.java @@ -65,7 +65,7 @@ public int getSlots() { @Override public ItemStack getStackInSlot(int slot) { if (slot == 0 && type != null) { - return new ItemStack(type.getSpiritShardItem(), count); // Yes, this can create a stack bigger than 64. It's fine. + return new ItemStack(type.spiritShard.get(), count); // Yes, this can create a stack bigger than 64. It's fine. } else return ItemStack.EMPTY; } @@ -107,7 +107,7 @@ public ItemStack extractItem(int slot, int amount, boolean simulate) { } } - return new ItemStack(extractedType.getSpiritShardItem(), amountToExtract); + return new ItemStack(extractedType.spiritShard.get(), amountToExtract); } @Override @@ -241,7 +241,7 @@ public void tick() { double x = getBlockPos().getX() + 0.5f; double y = getBlockPos().getY() + 0.5f + (float)Math.sin((level.getGameTime() % 360) / 20f) * 0.2f; double z = getBlockPos().getZ() + 0.5f; - SpiritLightSpecs.rotatingLightSpecs(level, new Vec3(x, y, z), type.getPrimaryColor(), type.getSecondaryColor(), 0.4f, 3); + SpiritLightSpecs.rotatingLightSpecs(level, new Vec3(x, y, z), type, 0.4f, 3); } } } diff --git a/src/main/java/com/sammy/malum/common/entity/FloatingEntity.java b/src/main/java/com/sammy/malum/common/entity/FloatingEntity.java index eda3d0a9e..d12884c44 100644 --- a/src/main/java/com/sammy/malum/common/entity/FloatingEntity.java +++ b/src/main/java/com/sammy/malum/common/entity/FloatingEntity.java @@ -1,5 +1,6 @@ package com.sammy.malum.common.entity; +import com.sammy.malum.core.systems.spirit.*; import com.sammy.malum.registry.common.SpiritTypeRegistry; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; @@ -31,11 +32,9 @@ public abstract class FloatingEntity extends Entity { - protected static final EntityDataAccessor DATA_COLOR = SynchedEntityData.defineId(FloatingEntity.class, EntityDataSerializers.INT); - protected static final EntityDataAccessor DATA_END_COLOR = SynchedEntityData.defineId(FloatingEntity.class, EntityDataSerializers.INT); + protected static final EntityDataAccessor DATA_SPIRIT = SynchedEntityData.defineId(FloatingEntity.class, EntityDataSerializers.STRING); public final TrailPointBuilder trailPointBuilder = TrailPointBuilder.create(10); - public Color startColor = SpiritTypeRegistry.ARCANE_SPIRIT.getPrimaryColor(); - public Color endColor = SpiritTypeRegistry.ARCANE_SPIRIT.getSecondaryColor(); + public MalumSpiritType spiritType = SpiritTypeRegistry.SACRED_SPIRIT; public int maxAge; public int age; public float moveTime; @@ -50,8 +49,7 @@ public FloatingEntity(EntityType type, Level level) { @Override protected void defineSynchedData() { - this.getEntityData().define(DATA_COLOR, SpiritTypeRegistry.ARCANE_SPIRIT.getPrimaryColor().getRGB()); - this.getEntityData().define(DATA_END_COLOR, SpiritTypeRegistry.ARCANE_SPIRIT.getSecondaryColor().getRGB()); + this.getEntityData().define(DATA_SPIRIT, SpiritTypeRegistry.SACRED_SPIRIT.identifier); } @Override @@ -61,8 +59,7 @@ public void addAdditionalSaveData(CompoundTag compound) { compound.putFloat("moveTime", moveTime); compound.putFloat("windUp", windUp); - compound.putInt("start", startColor.getRGB()); - compound.putInt("end", endColor.getRGB()); + compound.putString("spiritType", spiritType.identifier); } @Override @@ -71,17 +68,13 @@ public void readAdditionalSaveData(CompoundTag compound) { maxAge = compound.getInt("maxAge"); moveTime = compound.getFloat("moveTime"); windUp = compound.getFloat("windUp"); - startColor = new Color(compound.getInt("start")); - endColor = new Color(compound.getInt("end")); + spiritType = SpiritTypeRegistry.SPIRITS.get(compound.getString("spiritType")); } @Override public void onSyncedDataUpdated(EntityDataAccessor pKey) { - if (DATA_COLOR.equals(pKey)) { - startColor = new Color(entityData.get(DATA_COLOR)); - } - if (DATA_END_COLOR.equals(pKey)) { - endColor = new Color(entityData.get(DATA_END_COLOR)); + if (DATA_SPIRIT.equals(pKey)) { + spiritType = SpiritTypeRegistry.SPIRITS.get(entityData.get(DATA_SPIRIT)); } super.onSyncedDataUpdated(pKey); } diff --git a/src/main/java/com/sammy/malum/common/entity/FloatingItemEntity.java b/src/main/java/com/sammy/malum/common/entity/FloatingItemEntity.java index 577b5422e..7b5a1206e 100644 --- a/src/main/java/com/sammy/malum/common/entity/FloatingItemEntity.java +++ b/src/main/java/com/sammy/malum/common/entity/FloatingItemEntity.java @@ -1,7 +1,7 @@ package com.sammy.malum.common.entity; +import com.sammy.malum.common.item.spirit.*; import com.sammy.malum.registry.common.item.ItemRegistry; -import com.sammy.malum.core.systems.item.IFloatingGlowItem; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; @@ -11,8 +11,6 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; -import java.awt.*; - public class FloatingItemEntity extends FloatingEntity { private static final EntityDataAccessor DATA_ITEM_STACK = SynchedEntityData.defineId(FloatingItemEntity.class, EntityDataSerializers.ITEM_STACK); @@ -24,20 +22,14 @@ public FloatingItemEntity(EntityType type, Level level } public void setItem(ItemStack pStack) { - if (pStack.getItem() instanceof IFloatingGlowItem glow) { - setColor(glow.getColor(), glow.getEndColor()); + if (pStack.getItem() instanceof SpiritShardItem shardItem) { + this.spiritType = shardItem.type; } if (!pStack.is(this.getDefaultItem()) || pStack.hasTag()) { this.getEntityData().set(DATA_ITEM_STACK, pStack); } } - public void setColor(Color color, Color endColor) { - this.startColor = color; - getEntityData().set(DATA_COLOR, color.getRGB()); - this.endColor = endColor; - getEntityData().set(DATA_END_COLOR, endColor.getRGB()); - } @Override protected void defineSynchedData() { this.getEntityData().define(DATA_ITEM_STACK, ItemStack.EMPTY); diff --git a/src/main/java/com/sammy/malum/common/entity/night_terror/NightTerrorSeekerEntity.java b/src/main/java/com/sammy/malum/common/entity/night_terror/NightTerrorSeekerEntity.java index d3cc8c55d..ba717300a 100644 --- a/src/main/java/com/sammy/malum/common/entity/night_terror/NightTerrorSeekerEntity.java +++ b/src/main/java/com/sammy/malum/common/entity/night_terror/NightTerrorSeekerEntity.java @@ -20,6 +20,7 @@ import team.lodestar.lodestone.systems.particle.data.*; import team.lodestar.lodestone.systems.particle.data.color.*; import team.lodestar.lodestone.systems.particle.data.spin.*; +import team.lodestar.lodestone.systems.particle.render_types.*; import team.lodestar.lodestone.systems.particle.world.*; import java.awt.*; @@ -212,7 +213,7 @@ public static void spawnParticles(NightTerrorSeekerEntity nightTerrorSeekerEntit double lerpY = Mth.lerp(pDelta, oy, y) + motion.y / 4f; double lerpZ = Mth.lerp(pDelta, oz, z) + motion.z / 4f; float alphaMultiplier = (0.35f + extraAlpha) * Math.min(1, nightTerrorSeekerEntity.age * 0.2f); - SpiritLightSpecs.spiritLightSpecs(nightTerrorSeekerEntity.level, new Vec3(lerpX, lerpY, lerpZ), firstColor, firstColor.darker(), b -> b.setMotion(norm)); +// SpiritLightSpecs.spiritLightSpecs(nightTerrorSeekerEntity.level, new Vec3(lerpX, lerpY, lerpZ), firstColor, firstColor.darker(), b -> b.setMotion(norm)); final ColorParticleDataBuilder colorDataBuilder = ColorParticleData.create(NIGHT_TERROR_DARK, NIGHT_TERROR_DARK) .setEasing(Easing.QUINTIC_OUT) diff --git a/src/main/java/com/sammy/malum/common/entity/nitrate/EthericNitrateEntity.java b/src/main/java/com/sammy/malum/common/entity/nitrate/EthericNitrateEntity.java index 19236560f..1149c452c 100644 --- a/src/main/java/com/sammy/malum/common/entity/nitrate/EthericNitrateEntity.java +++ b/src/main/java/com/sammy/malum/common/entity/nitrate/EthericNitrateEntity.java @@ -16,6 +16,7 @@ import team.lodestar.lodestone.systems.particle.data.*; import team.lodestar.lodestone.systems.particle.data.color.*; import team.lodestar.lodestone.systems.particle.data.spin.*; +import team.lodestar.lodestone.systems.particle.render_types.*; import team.lodestar.lodestone.systems.particle.world.*; import java.awt.*; @@ -81,7 +82,7 @@ public static void spawnParticles(EthericNitrateEntity ethericNitrateEntity) { double lerpY = Mth.lerp(pDelta, oy, y) - motion.y / 4f; double lerpZ = Mth.lerp(pDelta, oz, z) - motion.z / 4f; float alphaMultiplier = (0.35f + extraAlpha) * Math.min(1, ethericNitrateEntity.windUp * 2); - SpiritLightSpecs.spiritLightSpecs(ethericNitrateEntity.level, new Vec3(lerpX, lerpY, lerpZ), firstColor, SECOND_COLOR, b -> b.setMotion(norm)); + //SpiritLightSpecs.spiritLightSpecs(ethericNitrateEntity.level, new Vec3(lerpX, lerpY, lerpZ), firstColor, SECOND_COLOR, b -> b.setMotion(norm)); final ColorParticleDataBuilder colorDataBuilder = ColorParticleData.create(SECOND_COLOR, SECOND_SMOKE_COLOR) .setEasing(Easing.QUINTIC_OUT) diff --git a/src/main/java/com/sammy/malum/common/entity/nitrate/VividNitrateEntity.java b/src/main/java/com/sammy/malum/common/entity/nitrate/VividNitrateEntity.java index 7f1c8c2c8..0fd36637b 100644 --- a/src/main/java/com/sammy/malum/common/entity/nitrate/VividNitrateEntity.java +++ b/src/main/java/com/sammy/malum/common/entity/nitrate/VividNitrateEntity.java @@ -17,6 +17,7 @@ import team.lodestar.lodestone.systems.particle.data.*; import team.lodestar.lodestone.systems.particle.data.color.*; import team.lodestar.lodestone.systems.particle.data.spin.*; +import team.lodestar.lodestone.systems.particle.render_types.*; import team.lodestar.lodestone.systems.particle.world.*; import java.awt.*; @@ -121,7 +122,7 @@ public static void spawnParticles(VividNitrateEntity vividNitrateEntity) { double lerpY = Mth.lerp(pDelta, oy, y) - motion.y / 4f; double lerpZ = Mth.lerp(pDelta, oz, z) - motion.z / 4f; float alphaMultiplier = (0.30f + extraAlpha) * Math.min(1, vividNitrateEntity.windUp * 2); - SpiritLightSpecs.spiritLightSpecs(vividNitrateEntity.level, new Vec3(lerpX, lerpY, lerpZ), firstColor, secondColor, b -> b.setMotion(norm)); +// SpiritLightSpecs.spiritLightSpecs(vividNitrateEntity.level, new Vec3(lerpX, lerpY, lerpZ), firstColor, secondColor, b -> b.setMotion(norm)); final ColorParticleDataBuilder colorDataBuilder = ColorParticleData.create(secondColor, SECOND_SMOKE_COLOR) .setEasing(Easing.QUINTIC_OUT) diff --git a/src/main/java/com/sammy/malum/common/entity/spirit/SpiritItemEntity.java b/src/main/java/com/sammy/malum/common/entity/spirit/SpiritItemEntity.java index 156d11f26..a33446501 100644 --- a/src/main/java/com/sammy/malum/common/entity/spirit/SpiritItemEntity.java +++ b/src/main/java/com/sammy/malum/common/entity/spirit/SpiritItemEntity.java @@ -66,7 +66,10 @@ public boolean fireImmune() { public void spawnParticles(double x, double y, double z) { Vec3 motion = getDeltaMovement(); Vec3 norm = motion.normalize().scale(0.05f); - SpiritLightSpecs.spiritLightSpecs(level, new Vec3(x, y, z), startColor, endColor, b -> b.setMotion(norm)); + var lightSpecs = SpiritLightSpecs.spiritLightSpecs(level, new Vec3(x, y, z), spiritType); + lightSpecs.getBuilder().setMotion(norm); + lightSpecs.getBloomBuilder().setMotion(norm); + lightSpecs.spawnParticles(); } @Override diff --git a/src/main/java/com/sammy/malum/common/item/spirit/SpiritShardItem.java b/src/main/java/com/sammy/malum/common/item/spirit/SpiritShardItem.java index 285c798c6..ea29edebd 100644 --- a/src/main/java/com/sammy/malum/common/item/spirit/SpiritShardItem.java +++ b/src/main/java/com/sammy/malum/common/item/spirit/SpiritShardItem.java @@ -1,6 +1,5 @@ package com.sammy.malum.common.item.spirit; -import com.sammy.malum.core.systems.item.IFloatingGlowItem; import com.sammy.malum.core.systems.spirit.MalumSpiritType; import com.sammy.malum.visual_effects.*; import net.minecraft.network.chat.Component; @@ -15,7 +14,7 @@ import java.awt.*; import java.util.List; -public class SpiritShardItem extends Item implements IFloatingGlowItem, ItemParticleSupplier { +public class SpiritShardItem extends Item implements ItemParticleSupplier { public final MalumSpiritType type; public SpiritShardItem(Properties properties, MalumSpiritType type) { @@ -25,17 +24,7 @@ public SpiritShardItem(Properties properties, MalumSpiritType type) { @Override public void appendHoverText(ItemStack pStack, @Nullable Level pLevel, List pTooltip, TooltipFlag pFlag) { - pTooltip.add(type.getSpiritShardFlavourTextComponent(pStack)); - } - - @Override - public Color getColor() { - return type.getPrimaryColor(); - } - - @Override - public Color getEndColor() { - return type.getSecondaryColor(); + pTooltip.add(type.getSpiritShardFlavourTextComponent()); } @Override diff --git a/src/main/java/com/sammy/malum/common/packets/particle/curiosities/blight/BlightMistParticlePacket.java b/src/main/java/com/sammy/malum/common/packets/particle/curiosities/blight/BlightMistParticlePacket.java index 4acffd9a8..7b44478d8 100644 --- a/src/main/java/com/sammy/malum/common/packets/particle/curiosities/blight/BlightMistParticlePacket.java +++ b/src/main/java/com/sammy/malum/common/packets/particle/curiosities/blight/BlightMistParticlePacket.java @@ -16,6 +16,7 @@ import team.lodestar.lodestone.systems.particle.data.*; import team.lodestar.lodestone.systems.particle.data.color.*; import team.lodestar.lodestone.systems.particle.data.spin.*; +import team.lodestar.lodestone.systems.particle.render_types.*; import team.lodestar.lodestone.systems.particle.world.*; import java.awt.*; diff --git a/src/main/java/com/sammy/malum/common/packets/particle/curiosities/blight/BlightTransformItemParticlePacket.java b/src/main/java/com/sammy/malum/common/packets/particle/curiosities/blight/BlightTransformItemParticlePacket.java index 2156de558..3b1e15296 100644 --- a/src/main/java/com/sammy/malum/common/packets/particle/curiosities/blight/BlightTransformItemParticlePacket.java +++ b/src/main/java/com/sammy/malum/common/packets/particle/curiosities/blight/BlightTransformItemParticlePacket.java @@ -18,6 +18,7 @@ import team.lodestar.lodestone.systems.particle.data.*; import team.lodestar.lodestone.systems.particle.data.color.*; import team.lodestar.lodestone.systems.particle.data.spin.*; +import team.lodestar.lodestone.systems.particle.render_types.*; import team.lodestar.lodestone.systems.particle.world.*; import java.awt.*; diff --git a/src/main/java/com/sammy/malum/common/packets/particle/curiosities/rite/generic/MajorEntityEffectParticlePacket.java b/src/main/java/com/sammy/malum/common/packets/particle/curiosities/rite/generic/MajorEntityEffectParticlePacket.java index edef7d6b3..b1b42a228 100644 --- a/src/main/java/com/sammy/malum/common/packets/particle/curiosities/rite/generic/MajorEntityEffectParticlePacket.java +++ b/src/main/java/com/sammy/malum/common/packets/particle/curiosities/rite/generic/MajorEntityEffectParticlePacket.java @@ -42,7 +42,7 @@ public void execute(Supplier context) { .enableNoClip() .setRandomOffset(0.2f, 0.2f) .setRandomMotion(0.02f) - .addActor(p -> p.setParticleSpeed(p.getParticleSpeed().scale(0.95f))) + .addActor(p -> p.setParticleMotion(p.getParticleSpeed().scale(0.95f))) .repeat(level, posX, posY, posZ, 8); } WorldParticleBuilder.create(LodestoneParticleRegistry.WISP_PARTICLE) @@ -54,7 +54,7 @@ public void execute(Supplier context) { .enableNoClip() .setRandomOffset(0.05f, 0.05f) .setRandomMotion(0.05f) - .addActor(p -> p.setParticleSpeed(p.getParticleSpeed().scale(0.5f))) + .addActor(p -> p.setParticleMotion(p.getParticleSpeed().scale(0.5f))) .repeat(level, posX, posY, posZ, 12); WorldParticleBuilder.create(LodestoneParticleRegistry.SMOKE_PARTICLE) @@ -66,7 +66,7 @@ public void execute(Supplier context) { .enableNoClip() .setRandomOffset(0.15f, 0.15f) .setRandomMotion(0.015f, 0.015f) - .addActor(p -> p.setParticleSpeed(p.getParticleSpeed().scale(0.92f))) + .addActor(p -> p.setParticleMotion(p.getParticleSpeed().scale(0.92f))) .repeat(level, posX, posY, posZ, 20); } diff --git a/src/main/java/com/sammy/malum/compability/jei/categories/SpiritRiteRecipeCategory.java b/src/main/java/com/sammy/malum/compability/jei/categories/SpiritRiteRecipeCategory.java index 26bbbf448..687421e8b 100644 --- a/src/main/java/com/sammy/malum/compability/jei/categories/SpiritRiteRecipeCategory.java +++ b/src/main/java/com/sammy/malum/compability/jei/categories/SpiritRiteRecipeCategory.java @@ -89,7 +89,7 @@ public IDrawable getIcon() { public void setRecipe(IRecipeLayoutBuilder builder, MalumRiteType rite, IFocusGroup focuses) { for (int i = 0; i < rite.spirits.size(); i++) { builder.addSlot(RecipeIngredientRole.CATALYST, 63, 121 - 20 * i) - .addItemStack(rite.spirits.get(i).getSpiritShardItem().getDefaultInstance()); + .addItemStack(rite.spirits.get(i).spiritShard.get().getDefaultInstance()); } } } diff --git a/src/main/java/com/sammy/malum/core/helper/SpiritHelper.java b/src/main/java/com/sammy/malum/core/helper/SpiritHelper.java index ceed7cdf6..c1aa48bdf 100644 --- a/src/main/java/com/sammy/malum/core/helper/SpiritHelper.java +++ b/src/main/java/com/sammy/malum/core/helper/SpiritHelper.java @@ -204,7 +204,7 @@ public static List getSpiritItemStacks(MalumEntitySpiritData data) { return spirits; } for (SpiritWithCount spiritWithCount : data.dataEntries) { - spirits.add(new ItemStack(spiritWithCount.type.getSpiritShardItem(), spiritWithCount.count)); + spirits.add(new ItemStack(spiritWithCount.type.spiritShard.get(), spiritWithCount.count)); } return spirits; } diff --git a/src/main/java/com/sammy/malum/core/systems/item/IFloatingGlowItem.java b/src/main/java/com/sammy/malum/core/systems/item/IFloatingGlowItem.java deleted file mode 100644 index 181372f55..000000000 --- a/src/main/java/com/sammy/malum/core/systems/item/IFloatingGlowItem.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.sammy.malum.core.systems.item; - -import java.awt.*; - -public interface IFloatingGlowItem -{ - public Color getColor(); - - public Color getEndColor(); -} diff --git a/src/main/java/com/sammy/malum/core/systems/recipe/SpiritWithCount.java b/src/main/java/com/sammy/malum/core/systems/recipe/SpiritWithCount.java index 7e13c4ad4..b33072af6 100644 --- a/src/main/java/com/sammy/malum/core/systems/recipe/SpiritWithCount.java +++ b/src/main/java/com/sammy/malum/core/systems/recipe/SpiritWithCount.java @@ -72,7 +72,7 @@ public ArrayList getStacks() { @Override public Item getItem() { - return type.getSpiritShardItem(); + return type.spiritShard.get(); } @Override diff --git a/src/main/java/com/sammy/malum/core/systems/spirit/MalumEntitySpiritData.java b/src/main/java/com/sammy/malum/core/systems/spirit/MalumEntitySpiritData.java index eee523af6..17921eecf 100644 --- a/src/main/java/com/sammy/malum/core/systems/spirit/MalumEntitySpiritData.java +++ b/src/main/java/com/sammy/malum/core/systems/spirit/MalumEntitySpiritData.java @@ -54,8 +54,6 @@ public CompoundTag save() { public static MalumEntitySpiritData load(CompoundTag tag) { CompoundTag nbt = tag.getCompound(SOUL_DATA); - - String type = nbt.getString("primaryType"); int dataAmount = nbt.getInt("dataAmount"); if (dataAmount == 0) { diff --git a/src/main/java/com/sammy/malum/core/systems/spirit/MalumSpiritType.java b/src/main/java/com/sammy/malum/core/systems/spirit/MalumSpiritType.java index 2cc6d32f7..39146668c 100644 --- a/src/main/java/com/sammy/malum/core/systems/spirit/MalumSpiritType.java +++ b/src/main/java/com/sammy/malum/core/systems/spirit/MalumSpiritType.java @@ -16,37 +16,49 @@ import net.minecraft.world.level.block.state.properties.*; import net.minecraft.world.phys.*; import team.lodestar.lodestone.helpers.*; +import team.lodestar.lodestone.systems.easing.*; +import team.lodestar.lodestone.systems.particle.data.color.*; import java.awt.*; import java.util.function.*; public class MalumSpiritType { + public static SpiritTypeBuilder create(String identifier, Supplier spiritShard, Supplier spiritMote) { + return new SpiritTypeBuilder(identifier, spiritShard, spiritMote); + } + public final String identifier; - protected final Supplier spiritShard; - protected final Supplier spiritMote; + public final Supplier spiritShard; + public final Supplier spiritMote; private final Color primaryColor; private final Color secondaryColor; + private final float mainColorCoefficient; + private final Easing mainColorEasing; - public MalumSpiritType(String identifier, Color primaryColor, Supplier spiritShard, Supplier spiritMote) { - this(identifier, primaryColor, new Color(primaryColor.getGreen(), primaryColor.getBlue(), primaryColor.getRed()), spiritShard, spiritMote); - } + private final Color primaryBloomColor; + private final Color secondaryBloomColor; + private final float bloomColorCoefficient; + private final Easing bloomColorEasing; + + protected Rarity itemRarity; + protected Component spiritItemDescription; - public MalumSpiritType(String identifier, Color primaryColor, Color secondaryColor, Supplier spiritShard, Supplier spiritMote) { + public MalumSpiritType(String identifier, Supplier spiritShard, Supplier spiritMote, + Color primaryColor, Color secondaryColor, float mainColorCoefficient, Easing mainColorEasing, + Color primaryBloomColor, Color secondaryBloomColor, float bloomColorCoefficient, Easing bloomColorEasing) { this.identifier = identifier; this.spiritShard = spiritShard; this.spiritMote = spiritMote; this.primaryColor = primaryColor; this.secondaryColor = secondaryColor; - } - - public SpiritShardItem getSpiritShardItem() { - return spiritShard.get(); - } - - public SpiritMoteBlock getSpiritMoteBlock() { - return spiritMote.get(); + this.mainColorCoefficient = mainColorCoefficient; + this.mainColorEasing = mainColorEasing; + this.primaryBloomColor = primaryBloomColor; + this.secondaryBloomColor = secondaryBloomColor; + this.bloomColorCoefficient = bloomColorCoefficient; + this.bloomColorEasing = bloomColorEasing; } public Color getPrimaryColor() { @@ -57,22 +69,49 @@ public Color getSecondaryColor() { return secondaryColor; } - public Component getSpiritJarCounterComponent(int count) { - return new TextComponent(" " + count + " ").append(new TranslatableComponent(getSpiritDescription())).withStyle(Style.EMPTY.withColor(primaryColor.getRGB())); + public ColorParticleDataBuilder createMainColorData() { + return createMainColorData(1f); } - public Component getSpiritShardFlavourTextComponent(ItemStack stack) { - return new TranslatableComponent(getSpiritFlavourText()).withStyle(ChatFormatting.ITALIC).withStyle(Style.EMPTY.withColor(ColorHelper.darker(primaryColor, 1, 0.75f).getRGB())); + public ColorParticleDataBuilder createMainColorData(float coefficientMultiplier) { + return ColorParticleData.create(primaryColor, secondaryColor).setCoefficient(mainColorCoefficient*coefficientMultiplier).setEasing(mainColorEasing); } - public String getSpiritDescription() { - return "malum.spirit.description." + identifier; + public ColorParticleDataBuilder createBloomColorData() { + return createBloomColorData(1f); + } + + public ColorParticleDataBuilder createBloomColorData(float coefficientMultiplier) { + return ColorParticleData.create(primaryBloomColor, secondaryBloomColor).setCoefficient(bloomColorCoefficient*coefficientMultiplier).setEasing(bloomColorEasing); + } + + public Rarity getItemRarity() { + if (itemRarity == null) { + TextColor textColor = TextColor.fromRgb(ColorHelper.brighter(primaryColor, 1, 0.85f).getRGB()); + itemRarity = Rarity.create("malum$" + identifier, (style) -> style.withColor(textColor)); + } + return itemRarity; + } + + public Component getSpiritShardFlavourTextComponent() { + if (spiritItemDescription == null) { + spiritItemDescription = new TranslatableComponent(getSpiritFlavourText()).withStyle(ChatFormatting.ITALIC).withStyle(Style.EMPTY.withColor(ColorHelper.darker(primaryColor, 1, 0.75f).getRGB())); + } + return spiritItemDescription; } public String getSpiritFlavourText() { return "malum.spirit.flavour." + identifier; } + public Component getSpiritJarCounterComponent(int count) { + return new TextComponent(" " + count + " ").append(new TranslatableComponent(getSpiritDescription())).withStyle(Style.EMPTY.withColor(primaryColor.getRGB())); + } + + public String getSpiritDescription() { + return "malum.spirit.description." + identifier; + } + public ResourceLocation getTotemGlowTexture() { return MalumMod.malumPath("vfx/totem_poles/" + identifier + "_glow"); } @@ -81,9 +120,4 @@ public BlockState getTotemPoleBlockState(boolean isCorrupt, BlockHitResult hit) Block base = isCorrupt ? BlockRegistry.SOULWOOD_TOTEM_POLE.get() : BlockRegistry.RUNEWOOD_TOTEM_POLE.get(); return base.defaultBlockState().setValue(BlockStateProperties.HORIZONTAL_FACING, hit.getDirection()).setValue(SpiritTypeRegistry.SPIRIT_TYPE_PROPERTY, identifier); } - - public Rarity getItemRarity() { - TextColor textColor = TextColor.fromRgb(ColorHelper.brighter(primaryColor, 1, 0.85f).getRGB()); - return Rarity.create("malum$" + identifier, (style) -> style.withColor(textColor)); - } } \ No newline at end of file diff --git a/src/main/java/com/sammy/malum/core/systems/spirit/SpiritTypeBuilder.java b/src/main/java/com/sammy/malum/core/systems/spirit/SpiritTypeBuilder.java new file mode 100644 index 000000000..b113bc418 --- /dev/null +++ b/src/main/java/com/sammy/malum/core/systems/spirit/SpiritTypeBuilder.java @@ -0,0 +1,67 @@ +package com.sammy.malum.core.systems.spirit; + +import com.sammy.malum.common.block.mana_mote.*; +import com.sammy.malum.common.item.spirit.*; +import team.lodestar.lodestone.systems.easing.*; + +import java.awt.*; +import java.util.function.*; + +public class SpiritTypeBuilder { + + public final String identifier; + public final Supplier spiritShard; + public final Supplier spiritMote; + + public Color primaryColor; + public Color secondaryColor; + public float mainColorCoefficient; + public Easing mainColorEasing = Easing.LINEAR; + + public Color primaryBloomColor; + public Color secondaryBloomColor; + public float bloomColorCoefficient; + public Easing bloomColorEasing = Easing.LINEAR; + + public SpiritTypeBuilder(String identifier, Supplier spiritShard, Supplier spiritMote) { + this.identifier = identifier; + this.spiritShard = spiritShard; + this.spiritMote = spiritMote; + } + public SpiritTypeBuilder setColorData(Color primaryColor, Color secondaryColor, float colorCoefficient) { + return setMainColorData(primaryColor, secondaryColor, colorCoefficient).setBloomColorData(primaryColor, secondaryColor, colorCoefficient); + } + public SpiritTypeBuilder setColorData(Color primaryColor, Color secondaryColor, float colorCoefficient, Easing easing) { + return setMainColorData(primaryColor, secondaryColor, colorCoefficient, easing).setBloomColorData(primaryColor, secondaryColor, colorCoefficient, easing); + } + + public SpiritTypeBuilder setMainColorData(Color primaryColor, Color secondaryColor, float mainColorCoefficient, Easing mainColorEasing) { + this.mainColorEasing = mainColorEasing; + return setMainColorData(primaryColor, secondaryColor, mainColorCoefficient); + } + + public SpiritTypeBuilder setMainColorData(Color primaryColor, Color secondaryColor, float mainColorCoefficient) { + this.primaryColor = primaryColor; + this.secondaryColor = secondaryColor; + this.mainColorCoefficient = mainColorCoefficient; + return this; + } + + public SpiritTypeBuilder setBloomColorData(Color primaryBloomColor, Color secondaryBloomColor, float bloomColorCoefficient, Easing bloomColorEasing) { + this.bloomColorEasing = bloomColorEasing; + return setBloomColorData(primaryBloomColor, secondaryBloomColor, bloomColorCoefficient); + } + + public SpiritTypeBuilder setBloomColorData(Color primaryBloomColor, Color secondaryBloomColor, float bloomColorCoefficient) { + this.primaryBloomColor = primaryBloomColor; + this.secondaryBloomColor = secondaryBloomColor; + this.bloomColorCoefficient = bloomColorCoefficient; + return this; + } + + public MalumSpiritType build() { + return new MalumSpiritType(identifier, spiritShard, spiritMote, + primaryColor, secondaryColor, mainColorCoefficient, mainColorEasing, + primaryBloomColor, secondaryBloomColor, bloomColorCoefficient, bloomColorEasing); + } +} diff --git a/src/main/java/com/sammy/malum/registry/client/ParticleRegistry.java b/src/main/java/com/sammy/malum/registry/client/ParticleRegistry.java index b63ebd95a..06bbe4a11 100644 --- a/src/main/java/com/sammy/malum/registry/client/ParticleRegistry.java +++ b/src/main/java/com/sammy/malum/registry/client/ParticleRegistry.java @@ -19,8 +19,10 @@ public class ParticleRegistry { public static RegistryObject SPIRIT_FLAME_PARTICLE = PARTICLES.register("spirit_flame", SpiritFlameParticleType::new); + public static RegistryObject WEIRD_SQUIGGLE = PARTICLES.register("weird_squiggle", LodestoneParticleType::new); public static RegistryObject LIGHT_SPEC_SMALL = PARTICLES.register("light_spec_small", LodestoneParticleType::new); public static RegistryObject LIGHT_SPEC_LARGE = PARTICLES.register("light_spec_large", LodestoneParticleType::new); + public static RegistryObject STAR = PARTICLES.register("star", LodestoneParticleType::new); public static RegistryObject ROUND_SPARK = PARTICLES.register("round_spark", LodestoneSparkParticleType::new); @@ -30,8 +32,10 @@ public class ParticleRegistry { public static void registerParticleFactory(ParticleFactoryRegisterEvent event) { Minecraft.getInstance().particleEngine.register(SPIRIT_FLAME_PARTICLE.get(), SpiritFlameParticleType.Factory::new); + Minecraft.getInstance().particleEngine.register(WEIRD_SQUIGGLE.get(), LodestoneParticleType.Factory::new); Minecraft.getInstance().particleEngine.register(LIGHT_SPEC_SMALL.get(), LodestoneParticleType.Factory::new); Minecraft.getInstance().particleEngine.register(LIGHT_SPEC_LARGE.get(), LodestoneParticleType.Factory::new); + Minecraft.getInstance().particleEngine.register(STAR.get(), LodestoneParticleType.Factory::new); Minecraft.getInstance().particleEngine.register(ROUND_SPARK.get(), LodestoneSparkParticleType.Factory::new); diff --git a/src/main/java/com/sammy/malum/registry/common/SpiritTypeRegistry.java b/src/main/java/com/sammy/malum/registry/common/SpiritTypeRegistry.java index 8af7080b8..04b857042 100644 --- a/src/main/java/com/sammy/malum/registry/common/SpiritTypeRegistry.java +++ b/src/main/java/com/sammy/malum/registry/common/SpiritTypeRegistry.java @@ -1,8 +1,6 @@ package com.sammy.malum.registry.common; import com.sammy.malum.*; -import com.sammy.malum.common.block.mana_mote.*; -import com.sammy.malum.common.item.spirit.*; import com.sammy.malum.core.systems.spirit.*; import com.sammy.malum.registry.common.block.*; import com.sammy.malum.registry.common.item.*; @@ -11,44 +9,53 @@ import net.minecraftforge.client.event.*; import net.minecraftforge.eventbus.api.*; import net.minecraftforge.fml.common.*; +import team.lodestar.lodestone.systems.easing.*; import java.awt.*; import java.util.List; import java.util.*; -import java.util.function.*; @SuppressWarnings("unchecked") @Mod.EventBusSubscriber(modid= MalumMod.MALUM, value= Dist.CLIENT, bus= Mod.EventBusSubscriber.Bus.MOD) public class SpiritTypeRegistry { public static Map SPIRITS = new LinkedHashMap<>(); - public static MalumSpiritType SACRED_SPIRIT = create("sacred", new Color(243, 40, 143), ItemRegistry.SACRED_SPIRIT, BlockRegistry.MOTE_OF_SACRED_ARCANA); + public static MalumSpiritType SACRED_SPIRIT = create(MalumSpiritType.create("sacred", ItemRegistry.SACRED_SPIRIT, BlockRegistry.MOTE_OF_SACRED_ARCANA) + .setColorData(new Color(238, 44, 136), new Color(40, 143, 243), 0.8f) + .build()); - public static MalumSpiritType WICKED_SPIRIT = create("wicked", new Color(155, 62, 245), ItemRegistry.WICKED_SPIRIT, BlockRegistry.MOTE_OF_WICKED_ARCANA); + public static MalumSpiritType WICKED_SPIRIT = create(MalumSpiritType.create("wicked", ItemRegistry.WICKED_SPIRIT, BlockRegistry.MOTE_OF_WICKED_ARCANA) + .setColorData(new Color(121, 44, 236), new Color(72, 21, 255), 0.8f) + .build()); - public static MalumSpiritType ARCANE_SPIRIT = create("arcane", new Color(212, 55, 255), ItemRegistry.ARCANE_SPIRIT, BlockRegistry.MOTE_OF_RAW_ARCANA); + public static MalumSpiritType ARCANE_SPIRIT = create(MalumSpiritType.create("arcane", ItemRegistry.ARCANE_SPIRIT, BlockRegistry.MOTE_OF_RAW_ARCANA) + .setColorData(new Color(213, 70, 255), new Color(32, 222, 229), 1.1f, Easing.SINE_IN_OUT) + .build()); - public static MalumSpiritType ELDRITCH_SPIRIT = create("eldritch", new Color(125, 29, 215), new Color(39, 201, 103), ItemRegistry.ELDRITCH_SPIRIT, BlockRegistry.MOTE_OF_ELDRITCH_ARCANA); + public static MalumSpiritType ELDRITCH_SPIRIT = create(MalumSpiritType.create("eldritch", ItemRegistry.ELDRITCH_SPIRIT, BlockRegistry.MOTE_OF_ELDRITCH_ARCANA) + .setColorData(new Color(203, 12, 248), new Color(24, 78, 164), 0.9f) + .build()); - public static MalumSpiritType AERIAL_SPIRIT = create("aerial", new Color(75, 243, 218), ItemRegistry.AERIAL_SPIRIT, BlockRegistry.MOTE_OF_AERIAL_ARCANA); + public static MalumSpiritType AERIAL_SPIRIT = create(MalumSpiritType.create("aerial", ItemRegistry.AERIAL_SPIRIT, BlockRegistry.MOTE_OF_AERIAL_ARCANA) + .setColorData(new Color(75, 243, 218), new Color(243, 218, 75), 1.1f, Easing.SINE_IN) + .build()); - public static MalumSpiritType AQUEOUS_SPIRIT = create("aqueous", new Color(29, 100, 232), ItemRegistry.AQUEOUS_SPIRIT, BlockRegistry.MOTE_OF_AQUEOUS_ARCANA); + public static MalumSpiritType AQUEOUS_SPIRIT = create(MalumSpiritType.create("aqueous", ItemRegistry.AQUEOUS_SPIRIT, BlockRegistry.MOTE_OF_AQUEOUS_ARCANA) + .setColorData(new Color(29, 100, 232), new Color(41, 238, 133), 0.8f, Easing.SINE_IN_OUT) + .build()); - public static MalumSpiritType INFERNAL_SPIRIT = create("infernal", new Color(210, 134, 39), ItemRegistry.INFERNAL_SPIRIT, BlockRegistry.MOTE_OF_INFERNAL_ARCANA); + public static MalumSpiritType INFERNAL_SPIRIT = create(MalumSpiritType.create("infernal", ItemRegistry.INFERNAL_SPIRIT, BlockRegistry.MOTE_OF_INFERNAL_ARCANA) + .setColorData(new Color(250, 154, 31), new Color(210, 39, 150), 0.9f, Easing.SINE_IN_OUT) + .build()); - public static MalumSpiritType EARTHEN_SPIRIT = create("earthen", new Color(73, 234, 27), ItemRegistry.EARTHEN_SPIRIT, BlockRegistry.MOTE_OF_EARTHEN_ARCANA); + public static MalumSpiritType EARTHEN_SPIRIT = create(MalumSpiritType.create("earthen", ItemRegistry.EARTHEN_SPIRIT, BlockRegistry.MOTE_OF_EARTHEN_ARCANA) + .setColorData(new Color(72, 238, 25), new Color(208, 26, 65), 0.9f, Easing.SINE_IN) + .build()); public static SpiritTypeProperty SPIRIT_TYPE_PROPERTY = new SpiritTypeProperty("spirit_type", SPIRITS.values()); - public static MalumSpiritType create(String identifier, Color color, Supplier spiritShard, Supplier spiritMote) { - MalumSpiritType spiritType = new MalumSpiritType(identifier, color, spiritShard, spiritMote); - SPIRITS.put(identifier, spiritType); - return spiritType; - } - - public static MalumSpiritType create(String identifier, Color color, Color endColor, Supplier spiritShard, Supplier spiritMote) { - MalumSpiritType spiritType = new MalumSpiritType(identifier, color, endColor, spiritShard, spiritMote); - SPIRITS.put(identifier, spiritType); + public static MalumSpiritType create(MalumSpiritType spiritType) { + SPIRITS.put(spiritType.identifier, spiritType); return spiritType; } @@ -57,13 +64,6 @@ public static int getIndexForSpiritType(MalumSpiritType type) { return types.indexOf(type); } - public static MalumSpiritType getSpiritTypeForIndex(int slot) { - if (slot >= SPIRITS.size()) - return null; - List types = SPIRITS.values().stream().toList(); - return types.get(slot); - } - @OnlyIn(Dist.CLIENT) @SubscribeEvent public static void stitchTextures(TextureStitchEvent.Pre event) { diff --git a/src/main/java/com/sammy/malum/visual_effects/ParticleEffectSpawner.java b/src/main/java/com/sammy/malum/visual_effects/ParticleEffectSpawner.java new file mode 100644 index 000000000..da5fa8c2a --- /dev/null +++ b/src/main/java/com/sammy/malum/visual_effects/ParticleEffectSpawner.java @@ -0,0 +1,52 @@ +package com.sammy.malum.visual_effects; + +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.*; +import team.lodestar.lodestone.systems.particle.builder.*; + +import javax.annotation.*; +import java.util.function.*; +import java.util.logging.*; + +public class ParticleEffectSpawner> { + + private final T builder; + private final Consumer particleSpawner; + + private final WorldParticleBuilder bloomBuilder; + private final Consumer bloomSpawner; + + public ParticleEffectSpawner(T builder, Consumer particleSpawner, @Nullable WorldParticleBuilder bloomBuilder, @Nullable Consumer bloomSpawner) { + this.builder = builder; + this.particleSpawner = particleSpawner; + this.bloomBuilder = bloomBuilder; + this.bloomSpawner = bloomSpawner; + } + + public ParticleEffectSpawner(Level level, Vec3 pos, T builder, WorldParticleBuilder bloomBuilder) { + this(builder, b -> b.spawn(level, pos.x, pos.y, pos.z), bloomBuilder, b -> b.spawn(level, pos.x, pos.y, pos.z)); + } + + public ParticleEffectSpawner(Level level, Vec3 pos, T builder) { + this(builder, b -> b.spawn(level, pos.x, pos.y, pos.z), null, null); + } + + public ParticleEffectSpawner(T builder, Consumer particleSpawner) { + this(builder, particleSpawner, null, null); + } + + public T getBuilder() { + return builder; + } + + public WorldParticleBuilder getBloomBuilder() { + return bloomBuilder; + } + + public void spawnParticles() { + particleSpawner.accept(builder); + if (bloomSpawner != null) { + bloomSpawner.accept(bloomBuilder); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/sammy/malum/visual_effects/ScreenParticleEffects.java b/src/main/java/com/sammy/malum/visual_effects/ScreenParticleEffects.java index bad0cc104..1a377c675 100644 --- a/src/main/java/com/sammy/malum/visual_effects/ScreenParticleEffects.java +++ b/src/main/java/com/sammy/malum/visual_effects/ScreenParticleEffects.java @@ -12,6 +12,7 @@ import team.lodestar.lodestone.systems.particle.data.*; import team.lodestar.lodestone.systems.particle.data.color.*; import team.lodestar.lodestone.systems.particle.data.spin.*; +import team.lodestar.lodestone.systems.particle.render_types.*; import team.lodestar.lodestone.systems.particle.screen.*; import team.lodestar.lodestone.systems.particle.screen.base.*; diff --git a/src/main/java/com/sammy/malum/visual_effects/SparkParticleEffects.java b/src/main/java/com/sammy/malum/visual_effects/SparkParticleEffects.java new file mode 100644 index 000000000..3e8a74748 --- /dev/null +++ b/src/main/java/com/sammy/malum/visual_effects/SparkParticleEffects.java @@ -0,0 +1,40 @@ +package com.sammy.malum.visual_effects; + +import com.sammy.malum.core.systems.spirit.*; +import com.sammy.malum.registry.client.*; +import net.minecraft.world.level.*; +import net.minecraft.world.phys.*; +import team.lodestar.lodestone.helpers.*; +import team.lodestar.lodestone.systems.easing.*; +import team.lodestar.lodestone.systems.particle.*; +import team.lodestar.lodestone.systems.particle.builder.*; +import team.lodestar.lodestone.systems.particle.data.*; +import team.lodestar.lodestone.systems.particle.data.color.*; +import team.lodestar.lodestone.systems.particle.data.spin.*; + +import java.util.*; +import java.util.function.*; + +import static net.minecraft.util.Mth.nextFloat; + +public class SparkParticleEffects { + + public static ParticleEffectSpawner spiritMotionSparks(Level level, Vec3 pos, MalumSpiritType spiritType) { + Random rand = level.getRandom(); + final ColorParticleData colorData = spiritType.createMainColorData(1.25f).build(); + final SpinParticleData spinData = SpinParticleData.createRandomDirection(rand, nextFloat(rand, 0.05f, 0.1f)).randomSpinOffset(rand).build(); + final Consumer slowDown = p -> p.setParticleMotion(p.getParticleSpeed().scale(0.95f)); + int lifetime = RandomHelper.randomBetween(rand, 10, 20); + final SparkParticleBuilder sparkParticleBuilder = SparkParticleBuilder.create(ParticleRegistry.ROUND_SPARK) + .setLengthData(GenericParticleData.create(0.1f, 0.2f, 0f).setEasing(Easing.SINE_IN, Easing.SINE_IN_OUT).build()) + .setTransparencyData(GenericParticleData.create(0.8f, 0f).build()) + .setScaleData(GenericParticleData.create(0.1f, RandomHelper.randomBetween(rand, 0.2f, 0.3f), 0).build()) + .setColorData(colorData) + .setLifetime(lifetime) + .enableNoClip() + .addActor(slowDown); + final WorldParticleBuilder bloomParticleBuilder = SpiritLightSpecs.spiritBloom(level, spiritType, spinData, lifetime).addActor(slowDown); + + return new ParticleEffectSpawner<>(level, pos, sparkParticleBuilder, bloomParticleBuilder); + } +} diff --git a/src/main/java/com/sammy/malum/visual_effects/SpiritAltarParticleEffects.java b/src/main/java/com/sammy/malum/visual_effects/SpiritAltarParticleEffects.java index 04e08c2af..6d9b5600a 100644 --- a/src/main/java/com/sammy/malum/visual_effects/SpiritAltarParticleEffects.java +++ b/src/main/java/com/sammy/malum/visual_effects/SpiritAltarParticleEffects.java @@ -9,21 +9,12 @@ import net.minecraft.util.*; import net.minecraft.world.item.*; import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.*; import net.minecraft.world.phys.*; import team.lodestar.lodestone.helpers.*; -import team.lodestar.lodestone.setup.*; import team.lodestar.lodestone.systems.blockentity.*; -import team.lodestar.lodestone.systems.easing.*; import team.lodestar.lodestone.systems.particle.builder.*; -import team.lodestar.lodestone.systems.particle.data.*; -import team.lodestar.lodestone.systems.particle.data.color.*; -import team.lodestar.lodestone.systems.particle.data.spin.*; -import team.lodestar.lodestone.systems.particle.world.*; -import java.awt.*; import java.util.*; -import java.util.List; import java.util.function.*; import static com.sammy.malum.visual_effects.SpiritLightSpecs.spiritLightSpecs; @@ -61,9 +52,7 @@ public static void passiveSpiritAltarParticles(SpiritAltarBlockEntity altar) { accelerator.addParticles(altar, activeSpiritType); } } - Color color = activeSpiritType.getPrimaryColor(); - Color endColor = activeSpiritType.getSecondaryColor(); - SpiritLightSpecs.rotatingLightSpecs(level, itemPos, color, endColor, 0.5f, 3, b -> b.multiplyLifetime(1.2f).modifyData(b::getScaleData, d -> d.multiplyValue(1.2f))); + SpiritLightSpecs.rotatingLightSpecs(level, itemPos, activeSpiritType, 0.5f, 3, b -> b.multiplyLifetime(1.2f).modifyData(b::getScaleData, d -> d.multiplyValue(1.2f))); } int spiritsRendered = 0; @@ -71,18 +60,22 @@ public static void passiveSpiritAltarParticles(SpiritAltarBlockEntity altar) { ItemStack item = spiritInventory.getStackInSlot(i); if (item.getItem() instanceof SpiritShardItem spiritSplinterItem) { Vec3 offset = altar.getSpiritItemOffset(spiritsRendered++, 0); - Color color = spiritSplinterItem.type.getPrimaryColor(); - Color endColor = spiritSplinterItem.type.getSecondaryColor(); + activeSpiritType = spiritSplinterItem.type; BlockPos blockPos = altar.getBlockPos(); Vec3 spiritPosition = new Vec3(blockPos.getX() + offset.x, blockPos.getY() + offset.y, blockPos.getZ() + offset.z); - spiritLightSpecs(level, spiritPosition, color, endColor); + spiritLightSpecs(level, spiritPosition, activeSpiritType).spawnParticles(); if (recipe != null) { Vec3 velocity = itemPos.subtract(spiritPosition).normalize().scale(RandomHelper.randomBetween(random, 0.03f, 0.06f)); if (random.nextFloat() < 0.85f) { - SpiritLightSpecs.spiritMotionSparks(level, spiritPosition, color, endColor, b -> b.setMotion(velocity), b -> b.setMotion(velocity)); + var sparkParticles = SparkParticleEffects.spiritMotionSparks(level, spiritPosition, activeSpiritType); + sparkParticles.getBuilder().setMotion(velocity).modifyData(SparkParticleBuilder::getScaleData, d -> d.multiplyValue(1.2f)); + sparkParticles.getBloomBuilder().setMotion(velocity); + sparkParticles.spawnParticles(); } if (random.nextFloat() < 0.85f) { - spiritLightSpecs(level, spiritPosition, color, endColor, b -> b.multiplyLifetime(0.8f).modifyData(b::getScaleData, d -> d.multiplyValue(1.4f)).setMotion(velocity.scale(1.5f))); + var lightSpecs = SpiritLightSpecs.spiritLightSpecs(level, spiritPosition, activeSpiritType); + lightSpecs.getBuilder().multiplyLifetime(0.8f).setMotion(velocity.scale(1.5f)).modifyData(WorldParticleBuilder::getScaleData, d -> d.multiplyValue(1.6f)); + lightSpecs.spawnParticles(); } } } @@ -95,47 +88,60 @@ public static void craftItemParticles(SpiritAltarBlockEntity altar) { return; } Level level = altar.getLevel(); - Color color = activeSpiritType.getPrimaryColor(); - Color endColor = activeSpiritType.getSecondaryColor(); long gameTime = level.getGameTime(); BlockPos altarPos = altar.getBlockPos(); Vec3 targetPos = altar.getCentralItemOffset().add(altarPos.getX(),altarPos.getY(), altarPos.getZ()); for (int i = 0; i < 8; i++) { - for (int j = 0; j < 3; j++) { - int finalI = i + 2; - Vec3 offsetPosition = DataHelper.rotatingRadialOffset(targetPos, 0.65f, i, 8, gameTime, 160); - int finalJ = j; - Consumer behavior = b -> b.addActor(p -> { - if (level.getGameTime() > gameTime + finalI * 4 && level.getGameTime() < gameTime + finalI * 8) { - p.setParticleSpeed(p.getParticleSpeed().add(0, 0.01f * (1- finalJ *0.4f), 0)); - } - }); - spiritLightSpecs(level, offsetPosition, color, endColor, - b -> b - .act(behavior) - .setColorData(b.getColorData().copy().setCoefficient(0.35f).build()) - .modifyData(b::getScaleData, d -> d.multiplyValue(3f).multiplyCoefficient(0.9f)) - .modifyData(b::getTransparencyData, d -> d.multiplyCoefficient(0.9f)) - .multiplyLifetime(1.5f) - .setLifetime(b.getParticleOptions().lifetimeSupplier.get() + finalI * 2), - b -> b - .act(behavior) - .setColorData(b.getColorData().copy().setCoefficient(0.35f).build()) - .modifyData(b::getScaleData, d -> d.multiplyValue(1.2f).multiplyCoefficient(0.9f)) - .modifyData(b::getTransparencyData, d -> d.multiplyCoefficient(0.9f)) - .setLifetime(b.getParticleOptions().lifetimeSupplier.get() + finalI * 2) - ); - } + int finalI = i; + Vec3 offsetPosition = DataHelper.rotatingRadialOffset(targetPos, 0.6f, i, 8, gameTime, 160); + + var lightSpecs = spiritLightSpecs(level, offsetPosition, activeSpiritType); + lightSpecs.getBuilder().act(b -> b + .modifyColorData(d -> d.multiplyCoefficient(0.35f)) + .modifyData(b::getScaleData, d -> d.multiplyValue(2f).multiplyCoefficient(0.9f)) + .modifyData(b::getTransparencyData, d -> d.multiplyCoefficient(0.9f)) + .multiplyLifetime(1.5f) + .setLifetime(b.getParticleOptions().lifetimeSupplier.get() + finalI * 2)); + lightSpecs.getBloomBuilder().act(b -> b + .modifyColorData(d -> d.multiplyCoefficient(0.35f)) + .modifyData(b::getScaleData, d -> d.multiplyValue(1.6f).multiplyCoefficient(0.9f)) + .modifyData(b::getTransparencyData, d -> d.multiplyCoefficient(0.9f)) + .setLifetime((int) (b.getParticleOptions().lifetimeSupplier.get() + finalI * 2.5f))); + lightSpecs.spawnParticles(); + } + + for (int i = 0; i < 8; i++) { + int finalI = i; + Vec3 offsetPosition = DataHelper.rotatingRadialOffset(targetPos, 0.6f, i, 8, gameTime, 160); + Consumer behavior = b -> b.addActor(p -> { + if (level.getGameTime() > gameTime + finalI * 4 && level.getGameTime() < gameTime + (finalI + 4) * 4) { + p.setParticleMotion(p.getParticleSpeed().add(0, 0.015f, 0)); + } + }); + + var lightSpecs = spiritLightSpecs(level, offsetPosition, activeSpiritType); + lightSpecs.getBuilder().act(b -> b + .act(behavior) + .modifyColorData(d -> d.multiplyCoefficient(0.35f)) + .modifyData(b::getScaleData, d -> d.multiplyValue(2f).multiplyCoefficient(0.9f)) + .modifyData(b::getTransparencyData, d -> d.multiplyCoefficient(0.9f)) + .multiplyLifetime(1.5f) + .setLifetime(b.getParticleOptions().lifetimeSupplier.get() + finalI * 2)); + lightSpecs.getBloomBuilder().act(b -> b + .act(behavior) + .modifyColorData(d -> d.multiplyCoefficient(0.35f)) + .modifyData(b::getScaleData, d -> d.multiplyValue(1.6f).multiplyCoefficient(0.9f)) + .modifyData(b::getTransparencyData, d -> d.multiplyCoefficient(0.9f)) + .setLifetime((int) (b.getParticleOptions().lifetimeSupplier.get() + finalI * 2.5f))); + lightSpecs.spawnParticles(); } } public static void runewoodObeliskParticles(RunewoodObeliskBlockEntity obelisk, SpiritAltarBlockEntity altar, MalumSpiritType spiritType) { Level level = obelisk.getLevel(); - Color color = spiritType.getPrimaryColor(); - Color endColor = spiritType.getSecondaryColor(); BlockPos obeliskPos = obelisk.getBlockPos(); Vec3 startPos = obelisk.getParticleOffset().add(obeliskPos.getX(), obeliskPos.getY(), obeliskPos.getZ()); - spiritLightSpecs(level, startPos, color, endColor); + spiritLightSpecs(level, startPos, spiritType).spawnParticles(); if (level.getGameTime() % 2L == 0) { Random random = level.random; long gameTime = level.getGameTime(); @@ -146,21 +152,21 @@ public static void runewoodObeliskParticles(RunewoodObeliskBlockEntity obelisk, Vec3 offsetPosition = DataHelper.rotatingRadialOffset(startPos.add(0, yOffset, 0), 0.45f, 0, 1, gameTime, 30); Consumer behavior = b -> b.addActor(p -> { if (gameTime % 6L == 0) { - p.setParticleSpeed(p.getParticleSpeed().scale(1.05f)); + p.setParticleMotion(p.getParticleSpeed().scale(1.05f)); } }); - spiritLightSpecs(level, offsetPosition, color, endColor, - b -> b - .act(behavior) - .setMotion(velocity) - .multiplyLifetime(2f) - .modifyData(b::getScaleData, d -> d.multiplyValue(RandomHelper.randomBetween(random, 1f, 2f))), - b -> b - .act(behavior) - .setMotion(velocity) - .multiplyLifetime(1.5f) - .modifyData(b::getScaleData, d -> d.multiplyValue(RandomHelper.randomBetween(random, 0.6f, 1.5f))) - ); + var lightSpecs = spiritLightSpecs(level, offsetPosition, spiritType); + lightSpecs.getBuilder().act(b -> b + .act(behavior) + .setMotion(velocity) + .multiplyLifetime(2f) + .modifyData(b::getScaleData, d -> d.multiplyValue(RandomHelper.randomBetween(random, 1f, 2f)))); + lightSpecs.getBloomBuilder().act(b -> b + .act(behavior) + .setMotion(velocity) + .multiplyLifetime(1.5f) + .modifyData(b::getScaleData, d -> d.multiplyValue(RandomHelper.randomBetween(random, 0.6f, 1.5f)))); + lightSpecs.spawnParticles(); } } diff --git a/src/main/java/com/sammy/malum/visual_effects/SpiritLightSpecs.java b/src/main/java/com/sammy/malum/visual_effects/SpiritLightSpecs.java index f401d7e88..5dad0d2ca 100644 --- a/src/main/java/com/sammy/malum/visual_effects/SpiritLightSpecs.java +++ b/src/main/java/com/sammy/malum/visual_effects/SpiritLightSpecs.java @@ -1,19 +1,18 @@ package com.sammy.malum.visual_effects; +import com.sammy.malum.core.systems.spirit.*; import com.sammy.malum.registry.client.*; -import net.minecraft.core.particles.*; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; import team.lodestar.lodestone.helpers.*; import team.lodestar.lodestone.setup.LodestoneParticleRegistry; -import team.lodestar.lodestone.systems.easing.*; +import team.lodestar.lodestone.systems.particle.*; import team.lodestar.lodestone.systems.particle.builder.*; import team.lodestar.lodestone.systems.particle.data.color.ColorParticleData; import team.lodestar.lodestone.systems.particle.data.GenericParticleData; import team.lodestar.lodestone.systems.particle.data.spin.SpinParticleData; -import team.lodestar.lodestone.systems.particle.world.*; +import team.lodestar.lodestone.systems.particle.type.*; -import java.awt.*; import java.util.*; import java.util.List; import java.util.function.*; @@ -22,105 +21,68 @@ public class SpiritLightSpecs { - public static void rotatingLightSpecs(Level level, Vec3 pos, Color color, Color endColor, float distance, int rotatingSpecs) { - rotatingLightSpecs(level, pos, color, endColor, distance, rotatingSpecs, b -> {}); + public static void rotatingLightSpecs(Level level, Vec3 pos, MalumSpiritType spiritType, float distance, int rotatingSpecs) { + rotatingLightSpecs(level, pos, spiritType, distance, rotatingSpecs, b -> {}); } - public static void rotatingLightSpecs(Level level, Vec3 pos, Color color, Color endColor, float distance, int rotatingSpecs, Consumer sharedModifier) { - rotatingLightSpecs(level, pos, color, endColor, distance, rotatingSpecs, sharedModifier, sharedModifier); + public static void rotatingLightSpecs(Level level, Vec3 pos, MalumSpiritType spiritType, float distance, int rotatingSpecs, Consumer sharedModifier) { + rotatingLightSpecs(level, pos, spiritType, distance, rotatingSpecs, sharedModifier, sharedModifier); } - public static void rotatingLightSpecs(Level level, Vec3 pos, Color color, Color endColor, float distance, int rotatingSpecs, Consumer lightSpecModifier, Consumer bloomModifier) { + public static void rotatingLightSpecs(Level level, Vec3 pos, MalumSpiritType spiritType, float distance, int rotatingSpecs, Consumer lightSpecModifier, Consumer bloomModifier) { long gameTime = level.getGameTime(); if (level.getGameTime() % 2L == 0) { for (int i = 0; i < rotatingSpecs; i++) { long offsetGameTime = gameTime + i * 120L; double yOffset = Math.sin((offsetGameTime % 360) / 30f) * 0.1f; Vec3 offsetPosition = DataHelper.rotatingRadialOffset(pos.add(0, yOffset, 0), distance, i, rotatingSpecs, gameTime, 160); - spiritLightSpecs(level, offsetPosition, color, endColor, - b -> b.act(lightSpecModifier) - .multiplyLifetime(2f) - .modifyData(b::getScaleData, d -> d.multiplyValue(1.2f)), - b -> b.act(bloomModifier) - .multiplyLifetime(1.4f) - .modifyData(List.of(b::getScaleData, b::getTransparencyData), d -> d.multiplyValue(0.6f)) - ); + + var lightSpecs = spiritLightSpecs(level, offsetPosition, spiritType); + lightSpecs.getBuilder().act(lightSpecModifier).multiplyLifetime(2f).modifyData(WorldParticleBuilder::getScaleData, d -> d.multiplyValue(1.2f)); + lightSpecs.getBloomBuilder().act(bloomModifier).act(b -> b.multiplyLifetime(1.4f).modifyData(List.of(b::getScaleData, b::getTransparencyData), d -> d.multiplyValue(0.6f))); + lightSpecs.spawnParticles(); } } - spiritLightSpecs(level, pos, color, endColor, - b -> b.act(lightSpecModifier) - .modifyData(b::getScaleData, d -> d.multiplyValue(1.7f)) - .modifyData(b::getTransparencyData, d -> d.multiplyValue(0.5f)), - b -> b.act(bloomModifier) - .modifyData(b::getScaleData, d -> d.multiplyValue(1.3f)) - .modifyData(b::getTransparencyData, d -> d.multiplyValue(0.75f)) - ); - } + var lightSpecs = spiritLightSpecs(level, pos, spiritType); + lightSpecs.getBuilder().act(lightSpecModifier) + .modifyData(WorldParticleBuilder::getScaleData, d -> d.multiplyValue(1.7f)) + .modifyData(WorldParticleBuilder::getTransparencyData, d -> d.multiplyValue(0.5f)); - public static void spiritLightSpecs(Level level, Vec3 pos, Color color, Color endColor) { - spiritLightSpecs(level, pos, color, endColor, b -> { - }); - } + lightSpecs.getBloomBuilder().act(bloomModifier) + .modifyData(WorldParticleBuilder::getScaleData, d -> d.multiplyValue(1.3f)) + .modifyData(WorldParticleBuilder::getTransparencyData, d -> d.multiplyValue(0.75f)); - public static void spiritLightSpecs(Level level, Vec3 pos, Color color, Color endColor, Consumer sharedModifier) { - spiritLightSpecs(level, pos, color, endColor, sharedModifier, sharedModifier); + lightSpecs.spawnParticles(); } - public static void spiritLightSpecs(Level level, Vec3 pos, Color color, Color endColor, Consumer lightSpecModifier, Consumer bloomModifier) { - Random rand = level.getRandom(); - final ColorParticleData colorData = ColorParticleData.create(color, endColor).setCoefficient(0.7f).build(); - final SpinParticleData spinData = SpinParticleData.createRandomDirection(rand, nextFloat(rand, 0.05f, 0.1f)).randomSpinOffset(rand).build(); - final Consumer slowDown = p -> p.setParticleSpeed(p.getParticleSpeed().scale(0.95f)); - int lifetime = RandomHelper.randomBetween(rand, 10, 20); - WorldParticleBuilder.create(rand.nextFloat() < 0.9 ? ParticleRegistry.LIGHT_SPEC_SMALL : ParticleRegistry.LIGHT_SPEC_LARGE) - .setTransparencyData(GenericParticleData.create(0.8f, 0f).build()) - .setSpinData(spinData) - .setScaleData(GenericParticleData.create(0.025f, RandomHelper.randomBetween(rand, 0.2f, 0.3f), 0).build()) - .setColorData(colorData) - .setLifetime(lifetime) - .enableNoClip() - .addActor(slowDown) - .act(lightSpecModifier) - .spawn(level, pos.x, pos.y, pos.z); - - spiritBloom(level, pos, colorData, spinData, lifetime, slowDown, bloomModifier); + public static ParticleEffectSpawner spiritLightSpecs(Level level, Vec3 pos, MalumSpiritType spiritType) { + return spiritLightSpecs(level, pos, spiritType, ParticleRegistry.LIGHT_SPEC_SMALL); } - public static void spiritMotionSparks(Level level, Vec3 pos, Color color, Color endColor, Consumer sparkModifier) { - spiritMotionSparks(level, pos, color, endColor, sparkModifier, b -> {}); - } - public static void spiritMotionSparks(Level level, Vec3 pos, Color color, Color endColor, Consumer sparkModifier, Consumer bloomModifier) { + public static ParticleEffectSpawner spiritLightSpecs(Level level, Vec3 pos, MalumSpiritType spiritType, Supplier particle) { Random rand = level.getRandom(); - final ColorParticleData colorData = ColorParticleData.create(color, endColor).setCoefficient(1.25f).build(); + final ColorParticleData colorData = spiritType.createMainColorData(0.7f).build(); final SpinParticleData spinData = SpinParticleData.createRandomDirection(rand, nextFloat(rand, 0.05f, 0.1f)).randomSpinOffset(rand).build(); - final Consumer slowDown = p -> p.setParticleSpeed(p.getParticleSpeed().scale(0.95f)); + final Consumer slowDown = p -> p.setParticleMotion(p.getParticleSpeed().scale(0.95f)); int lifetime = RandomHelper.randomBetween(rand, 10, 20); - SparkParticleBuilder.create(ParticleRegistry.ROUND_SPARK) - .setLengthData(GenericParticleData.create(0.1f, 0.2f, 0f).setEasing(Easing.SINE_IN, Easing.SINE_IN_OUT).build()) + final WorldParticleBuilder worldParticleBuilder = WorldParticleBuilder.create(particle) .setTransparencyData(GenericParticleData.create(0.8f, 0f).build()) + .setSpinData(spinData) .setScaleData(GenericParticleData.create(0.025f, RandomHelper.randomBetween(rand, 0.2f, 0.3f), 0).build()) .setColorData(colorData) .setLifetime(lifetime) .enableNoClip() - .addActor(slowDown) - .act(sparkModifier) - .spawn(level, pos.x, pos.y, pos.z); - - spiritBloom(level, pos, colorData, spinData, lifetime, slowDown, bloomModifier); + .addActor(slowDown); + final WorldParticleBuilder bloomParticleBuilder = SpiritLightSpecs.spiritBloom(level, spiritType, spinData, lifetime).addActor(slowDown); + return new ParticleEffectSpawner<>(level, pos, worldParticleBuilder, bloomParticleBuilder); } - public static void spiritBloom(Level level, Vec3 pos, ColorParticleData colorData, SpinParticleData spinData, int lifetime, Consumer actor, Consumer bloomModifier) { + public static WorldParticleBuilder spiritBloom(Level level, MalumSpiritType spiritType, SpinParticleData spinData, int lifetime) { Random rand = level.random; - WorldParticleBuilder.create(LodestoneParticleRegistry.WISP_PARTICLE) - .setTransparencyData(GenericParticleData.create(0.25f, 0f).build()) + return WorldParticleBuilder.create(LodestoneParticleRegistry.WISP_PARTICLE) + .setTransparencyData(GenericParticleData.create(0.35f, 0f).build()) .setSpinData(spinData) - .setScaleData(GenericParticleData.create(0.04f, RandomHelper.randomBetween(rand, 0.08f, 0.125f), 0).build()) - .setColorData(colorData) + .setScaleData(GenericParticleData.create(0.04f, RandomHelper.randomBetween(rand, 0.08f, 0.15f), 0).setCoefficient(1.15f).build()) + .setColorData(spiritType.createBloomColorData().build()) .setLifetime(lifetime) - .enableNoClip() - .addActor(actor) - .act(bloomModifier) - .spawn(level, pos.x, pos.y, pos.z) - .setScaleData(GenericParticleData.create(0.065f, RandomHelper.randomBetween(rand, 0.12f, 0.22f), 0).build()) - .act(bloomModifier) - .spawn(level, pos.x, pos.y, pos.z); + .enableNoClip(); } } \ No newline at end of file diff --git a/src/main/java/com/sammy/malum/visual_effects/networked/BlightingMistParticleEffect.java b/src/main/java/com/sammy/malum/visual_effects/networked/BlightingMistParticleEffect.java index ca61665e4..df6cca032 100644 --- a/src/main/java/com/sammy/malum/visual_effects/networked/BlightingMistParticleEffect.java +++ b/src/main/java/com/sammy/malum/visual_effects/networked/BlightingMistParticleEffect.java @@ -11,6 +11,7 @@ import team.lodestar.lodestone.systems.particle.data.*; import team.lodestar.lodestone.systems.particle.data.color.*; import team.lodestar.lodestone.systems.particle.data.spin.*; +import team.lodestar.lodestone.systems.particle.render_types.*; import team.lodestar.lodestone.systems.particle.world.*; import java.awt.*; diff --git a/src/main/java/com/sammy/malum/visual_effects/networked/WeepingWellReactionParticleEffect.java b/src/main/java/com/sammy/malum/visual_effects/networked/WeepingWellReactionParticleEffect.java index 90ec2248f..82974b1ce 100644 --- a/src/main/java/com/sammy/malum/visual_effects/networked/WeepingWellReactionParticleEffect.java +++ b/src/main/java/com/sammy/malum/visual_effects/networked/WeepingWellReactionParticleEffect.java @@ -11,6 +11,7 @@ import team.lodestar.lodestone.systems.particle.data.*; import team.lodestar.lodestone.systems.particle.data.color.*; import team.lodestar.lodestone.systems.particle.data.spin.*; +import team.lodestar.lodestone.systems.particle.render_types.*; import team.lodestar.lodestone.systems.particle.world.*; import java.awt.*; diff --git a/src/main/java/com/sammy/malum/visual_effects/networked/basic/DrippingSmokeParticleEffect.java b/src/main/java/com/sammy/malum/visual_effects/networked/basic/DrippingSmokeParticleEffect.java index 7e236a688..5a6c16f30 100644 --- a/src/main/java/com/sammy/malum/visual_effects/networked/basic/DrippingSmokeParticleEffect.java +++ b/src/main/java/com/sammy/malum/visual_effects/networked/basic/DrippingSmokeParticleEffect.java @@ -37,7 +37,7 @@ public Supplier get() { double posZ = positionData.posZ + 0.5f; int adjustedLifespan = (int) (60 * (intensity) * 0.6f); - Function> actorFunction = f -> (p -> p.setParticleSpeed(p.getParticleSpeed().add(new Vec3(posX, posY, posZ).subtract(p.getPos()).normalize().multiply(f, 0, f)))); + Function> actorFunction = f -> (p -> p.setParticleMotion(p.getParticleSpeed().add(new Vec3(posX, posY, posZ).subtract(p.getParticlePosition()).normalize().multiply(f, 0, f)))); for (int i = 0; i < 2; i++) { int spinDirection = (random.nextBoolean() ? 1 : -1); diff --git a/src/main/java/com/sammy/malum/visual_effects/networked/basic/HexingSmokeParticleEffect.java b/src/main/java/com/sammy/malum/visual_effects/networked/basic/HexingSmokeParticleEffect.java index 9ef0ad33b..e4256f5f9 100644 --- a/src/main/java/com/sammy/malum/visual_effects/networked/basic/HexingSmokeParticleEffect.java +++ b/src/main/java/com/sammy/malum/visual_effects/networked/basic/HexingSmokeParticleEffect.java @@ -48,7 +48,7 @@ public Supplier get() { .enableNoClip() .setRandomOffset(0.2f, 0.2f) .setRandomMotion(0.02f) - .addActor(p -> p.setParticleSpeed(p.getParticleSpeed().scale(0.95f))) + .addActor(p -> p.setParticleMotion(p.getParticleSpeed().scale(0.95f))) .repeat(level, posX, posY, posZ, (int) (4*intensity)); } WorldParticleBuilder.create(LodestoneParticleRegistry.WISP_PARTICLE) @@ -60,7 +60,7 @@ public Supplier get() { .enableNoClip() .setRandomOffset(0.05f, 0.05f) .setRandomMotion(0.05f) - .addActor(p -> p.setParticleSpeed(p.getParticleSpeed().scale(0.5f))) + .addActor(p -> p.setParticleMotion(p.getParticleSpeed().scale(0.5f))) .repeat(level, posX, posY, posZ, (int) (6*intensity)); WorldParticleBuilder.create(LodestoneParticleRegistry.SMOKE_PARTICLE) .setTransparencyData(GenericParticleData.create(0, 0.05f, 0).build()) @@ -71,7 +71,7 @@ public Supplier get() { .enableNoClip() .setRandomOffset(0.15f, 0.15f) .setRandomMotion(0.015f, 0.015f) - .addActor(p -> p.setParticleSpeed(p.getParticleSpeed().scale(0.92f))) + .addActor(p -> p.setParticleMotion(p.getParticleSpeed().scale(0.92f))) .repeat(level, posX, posY, posZ, (int) (10*intensity)); }; } diff --git a/src/main/resources/assets/malum/particles/star.json b/src/main/resources/assets/malum/particles/star.json new file mode 100644 index 000000000..c4bfbafe7 --- /dev/null +++ b/src/main/resources/assets/malum/particles/star.json @@ -0,0 +1,5 @@ +{ + "textures": [ + "malum:star" + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/malum/particles/weird_squiggle.json b/src/main/resources/assets/malum/particles/weird_squiggle.json new file mode 100644 index 000000000..5599cdb0a --- /dev/null +++ b/src/main/resources/assets/malum/particles/weird_squiggle.json @@ -0,0 +1,10 @@ +{ + "textures": [ + "malum:weird_squiggle0", + "malum:weird_squiggle1", + "malum:weird_squiggle2", + "malum:weird_squiggle3", + "malum:weird_squiggle4", + "malum:weird_squiggle5" + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/malum/textures/particle/weird_squiggle0.png b/src/main/resources/assets/malum/textures/particle/weird_squiggle0.png new file mode 100644 index 000000000..5aec534a8 Binary files /dev/null and b/src/main/resources/assets/malum/textures/particle/weird_squiggle0.png differ diff --git a/src/main/resources/assets/malum/textures/particle/weird_squiggle1.png b/src/main/resources/assets/malum/textures/particle/weird_squiggle1.png new file mode 100644 index 000000000..5346a809d Binary files /dev/null and b/src/main/resources/assets/malum/textures/particle/weird_squiggle1.png differ diff --git a/src/main/resources/assets/malum/textures/particle/weird_squiggle2.png b/src/main/resources/assets/malum/textures/particle/weird_squiggle2.png new file mode 100644 index 000000000..340979829 Binary files /dev/null and b/src/main/resources/assets/malum/textures/particle/weird_squiggle2.png differ diff --git a/src/main/resources/assets/malum/textures/particle/weird_squiggle3.png b/src/main/resources/assets/malum/textures/particle/weird_squiggle3.png new file mode 100644 index 000000000..50d48f865 Binary files /dev/null and b/src/main/resources/assets/malum/textures/particle/weird_squiggle3.png differ diff --git a/src/main/resources/assets/malum/textures/particle/weird_squiggle4.png b/src/main/resources/assets/malum/textures/particle/weird_squiggle4.png new file mode 100644 index 000000000..4035e8d51 Binary files /dev/null and b/src/main/resources/assets/malum/textures/particle/weird_squiggle4.png differ diff --git a/src/main/resources/assets/malum/textures/particle/weird_squiggle5.png b/src/main/resources/assets/malum/textures/particle/weird_squiggle5.png new file mode 100644 index 000000000..940407cb4 Binary files /dev/null and b/src/main/resources/assets/malum/textures/particle/weird_squiggle5.png differ diff --git a/src/main/resources/assets/malum/textures/vfx/zigzag.png b/src/main/resources/assets/malum/textures/vfx/zigzag.png new file mode 100644 index 000000000..aa60af48d Binary files /dev/null and b/src/main/resources/assets/malum/textures/vfx/zigzag.png differ