Skip to content

Commit

Permalink
修复部分其他模组的闪电不渲染的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ChloePrime committed Feb 26, 2024
1 parent c81c726 commit 0346325
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package mod.chloeprime.aaaparticles.common.internal;

public interface EffekLightningBolt {
boolean aaaParticles$getEffekTicket();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@ApiStatus.Internal
package mod.chloeprime.aaaparticles.common.internal;

import org.jetbrains.annotations.ApiStatus;
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
package mod.chloeprime.aaaparticles.mixin;

import mod.chloeprime.aaaparticles.client.ModClientHooks;
import mod.chloeprime.aaaparticles.common.internal.EffekLightningBolt;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LightningBolt;
import net.minecraft.world.level.Level;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.Unique;

@Mixin(LightningBolt.class)
public abstract class MixinLightningBolt extends Entity {
@Shadow private int life;
public abstract class MixinLightningBolt extends Entity implements EffekLightningBolt {
@Unique private boolean aaaParticles$effekTicket = true;

@Inject(
method = "tick",
at = @At(value = "INVOKE", shift = At.Shift.AFTER, target = "Lnet/minecraft/world/entity/Entity;tick()V")
)
private void playLightingEffek(CallbackInfo ci) {
if (life == 0 && level.isClientSide()) {
ModClientHooks.playLightningEffek((LightningBolt) (Object) this);
@Override
public boolean aaaParticles$getEffekTicket() {
if (aaaParticles$effekTicket) {
aaaParticles$effekTicket = false;
return true;
}
return false;
}

public MixinLightningBolt(EntityType<?> entityType, Level level) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package mod.chloeprime.aaaparticles.mixin.client;

import com.mojang.blaze3d.vertex.PoseStack;
import mod.chloeprime.aaaparticles.client.ModClientHooks;
import mod.chloeprime.aaaparticles.common.internal.EffekLightningBolt;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.entity.LightningBoltRenderer;
import net.minecraft.world.entity.LightningBolt;
Expand All @@ -15,7 +17,10 @@ public class MixinLightningBoltRenderer {
method = "render(Lnet/minecraft/world/entity/LightningBolt;FFLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V",
at = @At("HEAD"), cancellable = true
)
private void disableVanillaLightningModel(LightningBolt lightningBolt, float f, float g, PoseStack poseStack, MultiBufferSource multiBufferSource, int i, CallbackInfo ci) {
private void disableVanillaLightningModelAndPlayEffek(LightningBolt bolt, float f, float g, PoseStack poseStack, MultiBufferSource multiBufferSource, int i, CallbackInfo ci) {
if (((EffekLightningBolt) bolt).aaaParticles$getEffekTicket()) {
ModClientHooks.playLightningEffek(bolt);
}
ci.cancel();
}
}

0 comments on commit 0346325

Please sign in to comment.