Начинающий
Начинающий
- Статус
- Оффлайн
- Регистрация
- 7 Фев 2024
- Сообщения
- 144
- Реакции
- 0
- Выберите загрузчик игры
- Fabric
ss-
Ну типа прикольна, хз кто еще пишет на фабрике 1.16.5 что-то :)
Ну типа прикольна, хз кто еще пишет на фабрике 1.16.5 что-то :)
PlayerEntityRendererMixin:
package mixin;
import com.client.impl.function.client.Optimization;
import com.client.impl.function.visual.BadTrip;
import com.client.impl.function.visual.chinahat.ChinaHatFeatureRenderer;
import com.client.system.function.FunctionManager;
import com.client.utils.render.CapeLayer;
import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.render.entity.LivingEntityRenderer;
import net.minecraft.client.render.entity.PlayerEntityRenderer;
import net.minecraft.client.render.entity.feature.CapeFeatureRenderer;
import net.minecraft.client.render.entity.model.PlayerEntityModel;
import net.minecraft.client.util.math.MatrixStack;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(PlayerEntityRenderer.class)
public abstract class PlayerEntityRendererMixin extends LivingEntityRenderer<AbstractClientPlayerEntity, PlayerEntityModel<AbstractClientPlayerEntity>> {
@Unique
private static final float BASE_SCALE = 0.9375f;
public PlayerEntityRendererMixin(EntityRenderDispatcher dispatcher, PlayerEntityModel<AbstractClientPlayerEntity> model, float shadowRadius) {
super(dispatcher, model, shadowRadius);
}
@Inject(method = "<init>(Lnet/minecraft/client/render/entity/EntityRenderDispatcher;Z)V", at = @At("TAIL"))
private void init(EntityRenderDispatcher dispatcher, boolean bl, CallbackInfo ci) {
addFeature(new ChinaHatFeatureRenderer<>(this));
addFeature(new CapeLayer(this));
features.removeIf((modelFeature) -> {
return modelFeature instanceof CapeFeatureRenderer;
});
}
@Unique
private Optimization optimization;
@Unique
private BadTrip badTrip;
@Inject(method = "render(Lnet/minecraft/client/network/AbstractClientPlayerEntity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At("HEAD"), cancellable = true)
private void render(AbstractClientPlayerEntity abstractClientPlayerEntity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, CallbackInfo ci) {
if (optimization == null) optimization = FunctionManager.get(Optimization.class);
if (optimization.isEnabled() && !optimization.getPlayerEntities().contains(abstractClientPlayerEntity)) ci.cancel();
}
@Inject(method = "scale(Lnet/minecraft/client/network/AbstractClientPlayerEntity;Lnet/minecraft/client/util/math/MatrixStack;F)V", at = @At("HEAD"), cancellable = true)
private void onScale(AbstractClientPlayerEntity player, MatrixStack matrices, float amount, CallbackInfo ci) {
if (badTrip == null) badTrip = FunctionManager.get(BadTrip.class);
if (badTrip != null && badTrip.isEnabled()) {
ci.cancel();
float timeFactor = (float) ((Math.sin((double) System.currentTimeMillis() / 300.0 * Math.PI) * 2 + 0.5));
float widthHeightFactor = (float) (BASE_SCALE + 0.8999998569488525 * timeFactor);
float minY = 0.3375f;
float maxY = BASE_SCALE;
float smoothY = maxY - (maxY - minY) * ((float) Math.sin(System.currentTimeMillis() / 100.0) * 0.5f + 0.5f);
matrices.scale(widthHeightFactor + 3, smoothY, widthHeightFactor + 3);
}
}
}
BadTrip:
public class BadTrip extends Function {
public static boolean flexx = false;
private CustomSoundInstance currentSound;
private long lastPlayTime = 0;
private final DoubleSetting volume = Double().name("Громкость звука").enName("Volume").defaultValue(0.35).min(0.05).max(1.0).build();
public BadTrip() {
super("Bad Trip", Category.VISUAL);
}
@Override
public void onEnable() {
super.onEnable();
flexx = true;
this.playSound();
lastPlayTime = System.currentTimeMillis();
}
@Override
public void onDisable() {
super.onDisable();
flexx = false;
this.stopCurrentSound();
}
@Override
public void tick(TickEvent.Post event) {
if (this.isEnabled() && this.currentSound != null) {
if (!mc.getSoundManager().isPlaying(currentSound)) {
if (System.currentTimeMillis() - lastPlayTime > 100) {
this.restartSound();
}
} else {
lastPlayTime = System.currentTimeMillis();
}
}
}
public void playSound() {
currentSound = new CustomSoundInstance(com.client.utils.files.SoundManager.BADTRIP_EVENT, SoundCategory.MASTER);
currentSound.setVolume(volume.floatValue());
mc.getSoundManager().play(currentSound);
lastPlayTime = System.currentTimeMillis();
}
private void restartSound() {
this.stopCurrentSound();
this.playSound();
}
public void stopCurrentSound() {
if (this.currentSound != null) {
mc.getSoundManager().stop(currentSound);
currentSound = null;
}
}
}
