Skip to content

Commit

Permalink
Venom particles, gradle up
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexthw46 committed Apr 12, 2024
1 parent 652fcb5 commit d3949e9
Show file tree
Hide file tree
Showing 20 changed files with 128 additions and 72 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ curio_version=5.3.1+1.20.1
forge_version=47.1.3
patchouli_version=80-FORGE
gecko_version=4.2.2
mod_version=0.6.4.2
mod_version=0.6.5
ars_version=4.9.0.159
mod_id=ars_elemental
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// 1.20.1 2024-03-10T11:57:53.9149035 Tags for minecraft:mob_effect mod id ars_elemental
// 1.20.1 2024-04-04T12:55:45.8490267 Tags for minecraft:mob_effect mod id ars_elemental
bf78cab890974f864aecbb8b86f90cff309bf461 data/ars_elemental/tags/mob_effect/manabubble_blacklist.json
c3b7e8630b0cb0882260bf5e3ab8c45b4a446bdb data/ars_nouveau/tags/mob_effect/to_sync.json
8fa46e97c5ec2993fbb89bc556681143b7cda2ff data/ars_nouveau/tags/mob_effect/to_sync.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"values": [
"ars_elemental:hellfire",
"ars_elemental:static_charged"
"ars_elemental:venom"
]
}
2 changes: 2 additions & 0 deletions src/main/java/alexthw/ars_elemental/client/ClientEvents.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import alexthw.ars_elemental.client.mages.MageRenderer;
import alexthw.ars_elemental.client.mermaid.MermaidRenderer;
import alexthw.ars_elemental.client.particle.SparkParticle;
import alexthw.ars_elemental.client.particle.VenomParticle;
import alexthw.ars_elemental.common.entity.spells.EntityLerpedProjectile;
import alexthw.ars_elemental.common.items.CurioHolder;
import alexthw.ars_elemental.network.NetworkManager;
Expand Down Expand Up @@ -54,6 +55,7 @@ public class ClientEvents {
@SubscribeEvent
public static void registerParticles(RegisterParticleProvidersEvent event) {
event.registerSpriteSet(ModParticles.SPARK.get(), SparkParticle::factory);
event.registerSpriteSet(ModParticles.VENOM.get(), VenomParticle::factory);
}

@SubscribeEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ private SparkParticle(ClientLevel levelIn, double xCoordIn, double yCoordIn, dou
xd = xSpeedIn;
yd = ySpeedIn;
zd = zSpeedIn;
scale(1.5F);
scale(0.75F);
oRoll = roll = random.nextFloat() * 2 * (float) Math.PI;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package alexthw.ars_elemental.client.particle;

import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.particle.ParticleProvider;
import net.minecraft.client.particle.ParticleRenderType;
import net.minecraft.client.particle.SpriteSet;
import net.minecraft.client.particle.TextureSheetParticle;
import net.minecraft.core.particles.SimpleParticleType;
import org.jetbrains.annotations.NotNull;

public class VenomParticle extends TextureSheetParticle {
private final SpriteSet spriteSet;

private VenomParticle(ClientLevel levelIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn, SpriteSet spriteSet) {
super(levelIn, xCoordIn, yCoordIn, zCoordIn, xSpeedIn, ySpeedIn, zSpeedIn);
lifetime = 20;

this.spriteSet = spriteSet;
pickSprite(spriteSet);
xd = xSpeedIn;
yd = ySpeedIn;
zd = zSpeedIn;
//oRoll = roll = random.nextFloat() * 2 * (float) Math.PI;
}

@Override
public void tick() {
super.tick();
if ((age % 4) == 0) {
pickSprite(spriteSet);
}
}

@Override
public @NotNull ParticleRenderType getRenderType() {
return ParticleRenderType.PARTICLE_SHEET_OPAQUE;
}

@NotNull
public static ParticleProvider<SimpleParticleType> factory(SpriteSet spriteSet) {
return (data, level, x, y, z, dx, dy, dz) -> new VenomParticle(level, x, y, z, dx, dy, dz, spriteSet);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package alexthw.ars_elemental.common.glyphs;

import alexthw.ars_elemental.network.RayEffectPacket;
import alexthw.ars_elemental.network.DischargeEffectPacket;
import com.hollingsworth.arsnouveau.api.ANFakePlayer;
import com.hollingsworth.arsnouveau.api.spell.*;
import com.hollingsworth.arsnouveau.client.particle.ParticleColor;
Expand Down Expand Up @@ -70,7 +70,7 @@ public void onResolveEntity(EntityHitResult rayTraceResult, Level world, @NotNul
for (LivingEntity entity : world.getEntitiesOfClass(LivingEntity.class, new AABB(livingEntity.blockPosition()).inflate(range), (e) -> !e.equals(shooter))) {
attemptDamage(world, shooter, spellStats, spellContext, resolver, entity, source, damage);
this.applyConfigPotion(entity, ModPotions.SHOCKED_EFFECT.get(), spellStats);
RayEffectPacket.send(world, new ParticleColor(225, 200, 50), livingEntity.position(), entity.position());
DischargeEffectPacket.send(world, new ParticleColor(225, 200, 50), livingEntity.position(), entity.position());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package alexthw.ars_elemental.common.glyphs;

import alexthw.ars_elemental.api.item.ISchoolFocus;
import alexthw.ars_elemental.registry.ModPotions;
import com.hollingsworth.arsnouveau.api.spell.*;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.MobType;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.EntityHitResult;
import net.minecraftforge.common.ForgeConfigSpec;
Expand All @@ -29,7 +31,8 @@ public void onResolveEntity(EntityHitResult rayTraceResult, Level world, @NotNul
this.applyConfigPotion(target, ModPotions.VENOM.get(), spellStats);
target.removeEffect(MobEffects.POISON);
} else {
this.applyConfigPotion(target, MobEffects.POISON, spellStats);
boolean earth_switch = target.getMobType() == MobType.UNDEAD && ISchoolFocus.earthCheck(resolver);
this.applyConfigPotion(target, earth_switch ? ModPotions.VENOM.get() : MobEffects.POISON, spellStats);
}
}
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,28 +1,45 @@
package alexthw.ars_elemental.common.mob_effects;

import alexthw.ars_elemental.registry.ModParticles;
import alexthw.ars_elemental.registry.ModRegistry;
import com.hollingsworth.arsnouveau.api.util.DamageUtil;
import net.minecraft.world.effect.MobEffect;
import com.hollingsworth.arsnouveau.common.potions.ParticleMobEffect;
import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.world.effect.MobEffectCategory;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.LivingEntity;
import org.jetbrains.annotations.NotNull;

public class VenomEffect extends MobEffect {
public class VenomEffect extends ParticleMobEffect {
public VenomEffect() {
super(MobEffectCategory.HARMFUL, MobEffects.POISON.getColor());
}

@Override
public void applyEffectTick(@NotNull LivingEntity pLivingEntity, int pAmplifier) {
public void applyEffectTick(@NotNull LivingEntity living, int pAmplifier) {
if (living.level.isClientSide)
//3 loops
for (int i = 0; i < 3; i++) {
living.level.addParticle(getParticle(), living.getRandomX(.75D), 0.35 + living.getRandomY(), living.getRandomZ(.75D), 0.0D, 0.0D, 0.0D);
}
else
living.hurt(DamageUtil.source(living.level(), ModRegistry.POISON), 2 + (0.25F * pAmplifier));

pLivingEntity.hurt(DamageUtil.source(pLivingEntity.level(), ModRegistry.POISON), 2);
}

@Override
public ParticleOptions getParticle() {
return ModParticles.VENOM.get();
}

@Override
public boolean isDurationEffectTick(int pDuration, int pAmplifier) {
int j = 32 >> pAmplifier;
int j = switch (pAmplifier) {
case 0 -> 20;
case 1 -> 10;
default -> 32 >> pAmplifier;
};
return j == 0 || pDuration % j == 0;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ public AEMobEffectTagProvider(DataGenerator pOutput, CompletableFuture<HolderLoo
@Override
protected void addTags(HolderLookup.@NotNull Provider pProvider) {
tag(BUBBLE_BLACKLIST).add(MobEffects.LEVITATION, ModPotions.HYMN_OF_ORDER.get(), SUMMONING_SICKNESS_EFFECT.get());
tag(PotionEffectTags.TO_SYNC).add(ModPotions.MAGIC_FIRE.get());
tag(PotionEffectTags.TO_SYNC).add(ModPotions.MAGIC_FIRE.get(), ModPotions.VENOM.get());
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.network.NetworkDirection;
import net.minecraftforge.network.NetworkEvent;
import net.minecraftforge.network.PacketDistributor;
Expand All @@ -19,19 +20,19 @@

import static com.hollingsworth.arsnouveau.client.registry.ModParticles.SPARKLE_TYPE;

public class RayEffectPacket {
public class DischargeEffectPacket {

public Vec3 from;
public Vec3 to;
public ParticleColor color;

public RayEffectPacket(Vec3 from, Vec3 to, ParticleColor colors) {
public DischargeEffectPacket(Vec3 from, Vec3 to, ParticleColor colors) {
this.from = from;
this.to = to;
this.color = colors;
}

public static void encode(RayEffectPacket msg, FriendlyByteBuf buf) {
public static void encode(DischargeEffectPacket msg, FriendlyByteBuf buf) {
encodePos(buf, msg.from);
encodePos(buf, msg.to);
buf.writeInt(msg.color.getColor());
Expand All @@ -43,11 +44,11 @@ public static void encodePos(@Nonnull FriendlyByteBuf buf, @Nonnull Vec3 item) {
buf.writeDouble(item.z);
}

public static RayEffectPacket decode(FriendlyByteBuf buf) {
public static DischargeEffectPacket decode(FriendlyByteBuf buf) {
Vec3 from = decodeVector3d(buf);
Vec3 to = decodeVector3d(buf);
int colors = buf.readInt();
return new RayEffectPacket(from, to, ParticleColor.fromInt(colors));
return new DischargeEffectPacket(from, to, ParticleColor.fromInt(colors));
}

public static Vec3 decodeVector3d(@Nonnull FriendlyByteBuf buf) {
Expand All @@ -64,13 +65,13 @@ public static void send(@Nonnull Level level, @Nonnull ParticleColor spellColor,
double radiusSqr = radius * radius;

if (level instanceof ServerLevel serverLevel) {
RayEffectPacket fx = new RayEffectPacket(fromPoint, hitPoint, spellColor);
DischargeEffectPacket fx = new DischargeEffectPacket(fromPoint, hitPoint, spellColor);
serverLevel.getPlayers(p -> p.distanceToSqr(midpoint) <= radiusSqr)
.forEach(p -> NetworkManager.INSTANCE.send(PacketDistributor.PLAYER.with(() -> p), fx));
}
}

public static void whenThisPacketIsReceived(RayEffectPacket msg, Supplier<NetworkEvent.Context> ctx) {
public static void whenThisPacketIsReceived(DischargeEffectPacket msg, Supplier<NetworkEvent.Context> ctx) {
if (ctx.get().getDirection() == NetworkDirection.PLAY_TO_CLIENT) {
ctx.get().enqueueWork(() -> {

Expand All @@ -86,20 +87,30 @@ public static void whenThisPacketIsReceived(RayEffectPacket msg, Supplier<Networ
for (double d = start; d < distance; d += increment) {
double fractionalDistance = d / distance;
double speedCoefficient = Mth.lerp(fractionalDistance, 0.2, 0.001);
level.addParticle(
new ColoredDynamicTypeData(SPARKLE_TYPE.get(), msg.color, 0.5F, 10),
Mth.lerp(fractionalDistance, msg.from.x, msg.to.x),
Mth.lerp(fractionalDistance, msg.from.y, msg.to.y) + 0.5,
Mth.lerp(fractionalDistance, msg.from.z, msg.to.z),
(level.random.nextFloat() - 0.25) * speedCoefficient,
(level.random.nextFloat() - 0.25) * speedCoefficient,
(level.random.nextFloat() - 0.25) * speedCoefficient);
level.addParticle(ModParticles.SPARK.get(), Mth.lerp(fractionalDistance, msg.from.x, msg.to.x),
Mth.lerp(fractionalDistance, msg.from.y, msg.to.y) + 0.5,
Mth.lerp(fractionalDistance, msg.from.z, msg.to.z),
(level.random.nextFloat() - 0.5) * speedCoefficient,
(level.random.nextFloat() - 0.5) * speedCoefficient,
(level.random.nextFloat() - 0.5) * speedCoefficient);
if (ModList.get().isLoaded("cofh_core")) {
level.addParticle(
new ColoredDynamicTypeData(SPARKLE_TYPE.get(), msg.color, 0.5F, 10),
Mth.lerp(fractionalDistance, msg.from.x, msg.to.x),
Mth.lerp(fractionalDistance, msg.from.y, msg.to.y) + 0.5,
Mth.lerp(fractionalDistance, msg.from.z, msg.to.z),
(level.random.nextFloat() - 0.25) * speedCoefficient,
(level.random.nextFloat() - 0.25) * speedCoefficient,
(level.random.nextFloat() - 0.25) * speedCoefficient);
level.addParticle(ModParticles.SPARK.get(), Mth.lerp(fractionalDistance, msg.from.x, msg.to.x),
Mth.lerp(fractionalDistance, msg.from.y, msg.to.y) + 0.5,
Mth.lerp(fractionalDistance, msg.from.z, msg.to.z),
(level.random.nextFloat() - 0.5) * speedCoefficient,
(level.random.nextFloat() - 0.5) * speedCoefficient,
(level.random.nextFloat() - 0.5) * speedCoefficient);
} else
level.addParticle(
new ColoredDynamicTypeData(SPARKLE_TYPE.get(), msg.color, 0.5F, 10),
Mth.lerp(fractionalDistance, msg.from.x, msg.to.x),
Mth.lerp(fractionalDistance, msg.from.y, msg.to.y) + 0.5,
Mth.lerp(fractionalDistance, msg.from.z, msg.to.z),
(level.random.nextFloat() - 0.5) * speedCoefficient,
(level.random.nextFloat() - 0.5) * speedCoefficient,
(level.random.nextFloat() - 0.5) * speedCoefficient);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class NetworkManager {
public static void registerNetworkStuff(FMLCommonSetupEvent event) {
int index = 0;
INSTANCE.registerMessage(index++, OpenCurioBagPacket.class, OpenCurioBagPacket::encode, OpenCurioBagPacket::decode, OpenCurioBagPacket::whenThisPacketIsReceived);
INSTANCE.registerMessage(index++, RayEffectPacket.class, RayEffectPacket::encode, RayEffectPacket::decode, RayEffectPacket::whenThisPacketIsReceived);
INSTANCE.registerMessage(index++, DischargeEffectPacket.class, DischargeEffectPacket::encode, DischargeEffectPacket::decode, DischargeEffectPacket::whenThisPacketIsReceived);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ public class ModParticles {

public static final RegistryObject<SimpleParticleType> SPARK = PARTICLES.register("spark", () -> new SimpleParticleType(false));

public static final RegistryObject<SimpleParticleType> VENOM = PARTICLES.register("venom", () -> new SimpleParticleType(false));
}
15 changes: 7 additions & 8 deletions src/main/resources/assets/ars_elemental/particles/spark.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{
"textures": [
"cofh_core:spark_0",
"cofh_core:spark_1",
"cofh_core:spark_2",
"cofh_core:spark_3",
"cofh_core:spark_4",
"cofh_core:spark_5",
"cofh_core:spark_6",
"cofh_core:spark_7"
"ars_elemental:spark_0",
"ars_elemental:spark_1",
"ars_elemental:spark_2",
"ars_elemental:spark_3",
"ars_elemental:spark_4",
"ars_elemental:spark_5",
"ars_elemental:spark_6"
]
}
8 changes: 8 additions & 0 deletions src/main/resources/assets/ars_elemental/particles/venom.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"textures": [
"ars_elemental:venom_0",
"ars_elemental:venom_1",
"ars_elemental:venom_2",
"ars_elemental:venom_3"
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d3949e9

Please sign in to comment.