Half-and-half
This commit is contained in:
parent
2d319a8e50
commit
80910e38f5
@ -0,0 +1,11 @@
|
||||
package io.github.cottonmc.templates.mixin.particles;
|
||||
|
||||
import net.minecraft.client.particle.Particle;
|
||||
import net.minecraft.util.math.random.Random;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(Particle.class)
|
||||
public interface AccessorParticle {
|
||||
@Accessor("random") Random templates$getRandom();
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package io.github.cottonmc.templates.mixin.particles;
|
||||
|
||||
import net.minecraft.client.particle.SpriteBillboardParticle;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
@Mixin(SpriteBillboardParticle.class)
|
||||
public interface AccessorSpriteBillboardParticle {
|
||||
@Invoker("setSprite") void templates$setSprite(Sprite sprite);
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package io.github.cottonmc.templates.mixin.particles;
|
||||
|
||||
import io.github.cottonmc.templates.api.ThemeableBlockEntity;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.particle.BlockDustParticle;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
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(BlockDustParticle.class)
|
||||
public class MixinBlockDustParticle {
|
||||
@Inject(
|
||||
method = "<init>(Lnet/minecraft/client/world/ClientWorld;DDDDDDLnet/minecraft/block/BlockState;Lnet/minecraft/util/math/BlockPos;)V",
|
||||
at = @At("TAIL")
|
||||
)
|
||||
void templates$init$modifyParticleSprite(ClientWorld clientWorld, double d, double e, double f, double g, double h, double i, BlockState state, BlockPos pos, CallbackInfo ci) {
|
||||
if(clientWorld.getBlockEntity(pos) instanceof ThemeableBlockEntity themeable && ((AccessorParticle) this).templates$getRandom().nextBoolean()) {
|
||||
BlockState theme = themeable.getThemeState();
|
||||
if(theme.isAir()) return;
|
||||
|
||||
Sprite replacement = MinecraftClient.getInstance().getBlockRenderManager().getModels().getModelParticleSprite(theme);
|
||||
((AccessorSpriteBillboardParticle) this).templates$setSprite(replacement);
|
||||
}
|
||||
}
|
||||
}
|
@ -17,15 +17,14 @@ public abstract class MixinEntity {
|
||||
|
||||
@ModifyArg(
|
||||
method = "spawnSprintingParticles",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/particle/BlockStateParticleEffect;<init>(Lnet/minecraft/particle/ParticleType;Lnet/minecraft/block/BlockState;)V"),
|
||||
require = 0
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/particle/BlockStateParticleEffect;<init>(Lnet/minecraft/particle/ParticleType;Lnet/minecraft/block/BlockState;)V")
|
||||
)
|
||||
private BlockState templates$spawnSprintingParticles$modifyParticleState(BlockState origState) {
|
||||
World world = ((Entity) (Object) this).getWorld();
|
||||
|
||||
if(world.getBlockEntity(getLandingPos()) instanceof ThemeableBlockEntity themeable) {
|
||||
BlockState theme = themeable.getThemeState();
|
||||
if(theme.getBlock() != Blocks.AIR) return theme;
|
||||
if(!theme.isAir()) return theme;
|
||||
}
|
||||
|
||||
return origState;
|
||||
|
@ -25,15 +25,14 @@ public class MixinLivingEntity {
|
||||
|
||||
@ModifyArg(
|
||||
method = "fall",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/particle/BlockStateParticleEffect;<init>(Lnet/minecraft/particle/ParticleType;Lnet/minecraft/block/BlockState;)V"),
|
||||
require = 0
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/particle/BlockStateParticleEffect;<init>(Lnet/minecraft/particle/ParticleType;Lnet/minecraft/block/BlockState;)V")
|
||||
)
|
||||
private BlockState templates$fall$modifyParticleState(BlockState origState) {
|
||||
World world = ((Entity) (Object) this).getWorld();
|
||||
|
||||
if(lastFallCheckPos != null && world.getBlockEntity(lastFallCheckPos) instanceof ThemeableBlockEntity themeable) {
|
||||
BlockState theme = themeable.getThemeState();
|
||||
if(theme.getBlock() != Blocks.AIR) return theme;
|
||||
if(!theme.isAir()) return theme;
|
||||
}
|
||||
|
||||
return origState;
|
||||
|
@ -6,6 +6,11 @@
|
||||
"particles.MixinEntity",
|
||||
"particles.MixinLivingEntity"
|
||||
],
|
||||
"client": [
|
||||
"particles.AccessorParticle",
|
||||
"particles.AccessorSpriteBillboardParticle",
|
||||
"particles.MixinBlockDustParticle"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user