-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
64d54bb
commit b01ef4b
Showing
10 changed files
with
163 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/generated/resources/assets/vampirism/particles/mist_smoke.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"textures": [ | ||
"minecraft:generic_7", | ||
"minecraft:generic_6", | ||
"minecraft:generic_5", | ||
"minecraft:generic_4", | ||
"minecraft:generic_3", | ||
"minecraft:generic_2", | ||
"minecraft:generic_1", | ||
"minecraft:generic_0" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/main/java/de/teamlapen/vampirism/client/particle/MistSmokeParticle.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package de.teamlapen.vampirism.client.particle; | ||
|
||
import net.minecraft.client.multiplayer.ClientLevel; | ||
import net.minecraft.client.particle.Particle; | ||
import net.minecraft.client.particle.ParticleProvider; | ||
import net.minecraft.client.particle.SimpleAnimatedParticle; | ||
import net.minecraft.client.particle.SpriteSet; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.core.particles.SimpleParticleType; | ||
import net.minecraft.util.FastColor; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class MistSmokeParticle extends SimpleAnimatedParticle { | ||
|
||
MistSmokeParticle(ClientLevel pLevel, double pX, double pY, double pZ, double pXSpeed, double pYSpeed, double pZSpeed, int pPackedColor, SpriteSet pSprites) { | ||
super(pLevel, pX, pY, pZ, pSprites, 0.0F); | ||
this.friction = 0.92F; | ||
this.quadSize = 0.5F; | ||
this.setAlpha(0.8F); | ||
this.setColor(1, 1, 1); | ||
this.lifetime = (int)((double)(this.quadSize * 12.0F) / (Math.random() * 0.8F + 0.2F)); | ||
this.setSpriteFromAge(pSprites); | ||
this.hasPhysics = false; | ||
this.xd = pXSpeed; | ||
this.yd = pYSpeed; | ||
this.zd = pZSpeed; | ||
} | ||
|
||
@Override | ||
public void tick() { | ||
super.tick(); | ||
if (!this.removed) { | ||
this.setSpriteFromAge(this.sprites); | ||
if (this.age > this.lifetime / 2) { | ||
this.setAlpha((1.0F - ((float)this.age - (float)(this.lifetime / 2)) / (float)this.lifetime) * 0.8f); | ||
} | ||
|
||
if (this.level.getBlockState(BlockPos.containing(this.x, this.y, this.z)).isAir()) { | ||
this.yd -= 0.0074F; | ||
} | ||
} | ||
} | ||
|
||
public static class Provider implements ParticleProvider<SimpleParticleType> { | ||
private final SpriteSet sprites; | ||
|
||
public Provider(SpriteSet pSprites) { | ||
this.sprites = pSprites; | ||
} | ||
|
||
public Particle createParticle(@NotNull SimpleParticleType pType, @NotNull ClientLevel pLevel, double pX, double pY, double pZ, double pXSpeed, double pYSpeed, double pZSpeed) { | ||
return new MistSmokeParticle(pLevel, pX, pY, pZ, pXSpeed, pYSpeed, pZSpeed, FastColor.ARGB32.color(128, 255, 255, 255), this.sprites); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/main/java/de/teamlapen/vampirism/data/provider/ModParticleDescriptionProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package de.teamlapen.vampirism.data.provider; | ||
|
||
import de.teamlapen.vampirism.api.util.VResourceLocation; | ||
import de.teamlapen.vampirism.core.ModParticles; | ||
import net.minecraft.data.PackOutput; | ||
import net.neoforged.neoforge.common.data.ExistingFileHelper; | ||
import net.neoforged.neoforge.common.data.ParticleDescriptionProvider; | ||
|
||
public class ModParticleDescriptionProvider extends ParticleDescriptionProvider { | ||
|
||
protected ModParticleDescriptionProvider(PackOutput output, ExistingFileHelper fileHelper) { | ||
super(output, fileHelper); | ||
} | ||
|
||
@Override | ||
protected void addDescriptions() { | ||
spriteSet(ModParticles.MIST_SMOKE.get(), VResourceLocation.mc("generic"), 8, true); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
src/main/java/de/teamlapen/vampirism/mixin/client/LivingEntityRendererMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package de.teamlapen.vampirism.mixin.client; | ||
|
||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation; | ||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; | ||
import com.llamalad7.mixinextras.sugar.Local; | ||
import com.llamalad7.mixinextras.sugar.Share; | ||
import com.llamalad7.mixinextras.sugar.ref.LocalBooleanRef; | ||
import com.llamalad7.mixinextras.sugar.ref.LocalRef; | ||
import com.mojang.blaze3d.vertex.PoseStack; | ||
import com.mojang.blaze3d.vertex.VertexConsumer; | ||
import de.teamlapen.vampirism.api.entity.player.actions.IActionHandler; | ||
import de.teamlapen.vampirism.api.entity.player.vampire.IVampirePlayer; | ||
import de.teamlapen.vampirism.entity.player.vampire.actions.VampireActions; | ||
import net.minecraft.client.model.EntityModel; | ||
import net.minecraft.client.renderer.MultiBufferSource; | ||
import net.minecraft.client.renderer.RenderType; | ||
import net.minecraft.client.renderer.entity.EntityRenderer; | ||
import net.minecraft.client.renderer.entity.EntityRendererProvider; | ||
import net.minecraft.client.renderer.entity.LivingEntityRenderer; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.util.FastColor; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import net.minecraft.world.entity.player.Player; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(LivingEntityRenderer.class) | ||
public abstract class LivingEntityRendererMixin<T extends LivingEntity, M extends EntityModel<T>> extends EntityRenderer<T> { | ||
|
||
protected LivingEntityRendererMixin(EntityRendererProvider.Context pContext) { | ||
super(pContext); | ||
} | ||
|
||
@Inject(method= "render(Lnet/minecraft/world/entity/LivingEntity;FFLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V", at= @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/MultiBufferSource;getBuffer(Lnet/minecraft/client/renderer/RenderType;)Lcom/mojang/blaze3d/vertex/VertexConsumer;", shift = At.Shift.BEFORE)) | ||
private void test(T pEntity, float pEntityYaw, float pPartialTicks, PoseStack pPoseStack, MultiBufferSource pBuffer, int pPackedLight, CallbackInfo ci, @Local(name = "rendertype") LocalRef<RenderType> renderType, @Local(name = "flag") boolean flag, @Local(name = "flag1") boolean flag1, @Share("mist") LocalBooleanRef mist) { | ||
if (flag && !flag1 && pEntity instanceof Player player && IActionHandler.<IVampirePlayer>get(player).map(s -> s.isActionActive(VampireActions.HALF_INVULNERABLE)).orElse(false)) { | ||
ResourceLocation resourcelocation = this.getTextureLocation(pEntity); | ||
renderType.set(RenderType.itemEntityTranslucentCull(resourcelocation)); | ||
mist.set(true); | ||
} | ||
} | ||
|
||
@WrapOperation(method = "render(Lnet/minecraft/world/entity/LivingEntity;FFLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/model/EntityModel;renderToBuffer(Lcom/mojang/blaze3d/vertex/PoseStack;Lcom/mojang/blaze3d/vertex/VertexConsumer;III)V")) | ||
private void changeColor(EntityModel instance, PoseStack poseStack, VertexConsumer consumer, int i1, int i2, int i3, Operation<Void> original, @Share("mist") LocalBooleanRef mist) { | ||
original.call(instance, poseStack, consumer, i1, i2, mist.get() ? FastColor.ARGB32.color(0,255,255,255) : i3); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters