Events (100%)

This commit is contained in:
kirillsaint 2023-06-29 22:08:46 +06:00
parent 343c6a149e
commit 8f0cb20a23
5 changed files with 79 additions and 2 deletions

View File

@ -10,6 +10,7 @@ import net.silentclient.client.cosmetics.StaticResourceLocation;
import net.silentclient.client.event.impl.EventCameraRotation;
import net.silentclient.client.event.impl.EventPlayerHeadRotation;
import net.silentclient.client.event.impl.EventRender3D;
import net.silentclient.client.event.impl.EventZoomFov;
import net.silentclient.client.mixin.ducks.EntityRendererExt;
import net.silentclient.client.utils.culling.EntityCulling;
import org.spongepowered.asm.mixin.Mixin;
@ -19,6 +20,7 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(EntityRenderer.class)
public abstract class EntityRendererMixin implements EntityRendererExt {
@ -104,4 +106,12 @@ public abstract class EntityRendererMixin implements EntityRendererExt {
private void shouldNotPerformCulling(CallbackInfo ci) {
EntityCulling.shouldPerformCulling = false;
}
@Inject(method = "getFOVModifier", at = @At("RETURN"), cancellable = true)
public void getFOVModifier(float partialTicks, boolean useFOVSetting, CallbackInfoReturnable<Float> cir) {
EventZoomFov event = new EventZoomFov(cir.getReturnValue());
event.call();
cir.setReturnValue(event.getFov());
}
}

View File

@ -3,8 +3,10 @@ package net.silentclient.client.mixin.mixins;
import io.netty.channel.ChannelHandlerContext;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S02PacketChat;
import net.silentclient.client.event.impl.EventReceivePacket;
import net.silentclient.client.event.impl.EventSendPacket;
import net.silentclient.client.event.impl.NewMessageEvent;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
@ -12,7 +14,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(NetworkManager.class)
public class NetworkManagerMixin {
@Inject(method = "channelRead0(Lio/netty/channel/ChannelHandlerContext;Lnet/minecraft/network/Packet;)V", at = @At("HEAD"))
@Inject(method = "channelRead0(Lio/netty/channel/ChannelHandlerContext;Lnet/minecraft/network/Packet;)V", at = @At("HEAD"), cancellable = true)
public void packetEvent(ChannelHandlerContext p_channelRead0_1_, Packet p_channelRead0_2_, CallbackInfo ci) {
EventReceivePacket event = new EventReceivePacket(p_channelRead0_2_);
event.call();
@ -20,6 +22,15 @@ public class NetworkManagerMixin {
if(event.isCancelable()) {
ci.cancel();
}
if(p_channelRead0_2_ instanceof S02PacketChat && ((S02PacketChat) p_channelRead0_2_).getType() == 0) {
NewMessageEvent event2 = new NewMessageEvent(((S02PacketChat) p_channelRead0_2_).getChatComponent());
event2.call();
if(event2.isCancelable()) {
ci.cancel();
}
}
}
@Inject(method = "sendPacket(Lnet/minecraft/network/Packet;)V", at = @At("HEAD"))

View File

@ -0,0 +1,18 @@
package net.silentclient.client.mixin.mixins;
import net.minecraft.client.renderer.RenderGlobal;
import net.minecraft.client.renderer.culling.ICamera;
import net.minecraft.entity.Entity;
import net.silentclient.client.event.impl.RenderTickEvent;
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(RenderGlobal.class)
public class RenderGlobalMixin {
@Inject(method = "renderEntities", at = @At("HEAD"))
public void tickEvent(Entity renderViewEntity, ICamera camera, float partialTicks, CallbackInfo ci) {
new RenderTickEvent().call();
}
}

View File

@ -1,13 +1,25 @@
package net.silentclient.client.mixin.mixins;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.entity.RendererLivingEntity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityArmorStand;
import net.minecraft.entity.monster.IMob;
import net.minecraft.entity.passive.EntityAmbientCreature;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.passive.EntityWaterMob;
import net.minecraft.entity.player.EntityPlayer;
import net.silentclient.client.Client;
import net.silentclient.client.event.impl.EventHitOverlay;
import net.silentclient.client.event.impl.RenderLivingEvent;
import net.silentclient.client.mods.settings.FPSBoostMod;
import net.silentclient.client.utils.culling.EntityCulling;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(RendererLivingEntity.class)
@ -47,4 +59,29 @@ public class RendererLivingEntityMixin<T extends EntityLivingBase> {
public float setBrightnessAlpha(float original) {
return alpha;
}
@Inject(method = "doRender(Lnet/minecraft/entity/EntityLivingBase;DDDFF)V", at = @At("HEAD"), cancellable = true)
public void renderEvent(T entity, double x, double y, double z, float entityYaw, float partialTicks, CallbackInfo ci) {
RenderLivingEvent event = new RenderLivingEvent(entity, x, y, z, (RendererLivingEntity<EntityLivingBase>) (Object) this);
event.call();
if(event.isCancelable()) {
ci.cancel();
}
final float entityDistance = entity.getDistanceToEntity(Minecraft.getMinecraft().thePlayer);
if (EntityCulling.shouldPerformCulling) {
if (entity instanceof IMob && entityDistance > Client.getInstance().getSettingsManager().getSettingByClass(FPSBoostMod.class, "Hostile Entity Render Distance").getValInt()) {
ci.cancel();
} else if ((entity instanceof EntityAnimal || entity instanceof EntityAmbientCreature || entity instanceof EntityWaterMob) && entityDistance > Client.getInstance().getSettingsManager().getSettingByClass(FPSBoostMod.class, "Passive Entity Render Distance").getValInt()) {
ci.cancel();
} else if (entity instanceof EntityPlayer && entityDistance > Client.getInstance().getSettingsManager().getSettingByClass(FPSBoostMod.class, "Player Render Distance").getValInt()) {
ci.cancel();
} else if (entityDistance > Client.getInstance().getSettingsManager().getSettingByClass(FPSBoostMod.class, "Misc. Entity Render Distance").getValInt()) {
ci.cancel();
}
}
if(Client.getInstance().getSettingsManager().getSettingByClass(FPSBoostMod.class, "Hide Armor Stands").getValBoolean() && entity instanceof EntityArmorStand) {
ci.cancel();
}
}
}

View File

@ -33,6 +33,7 @@
"mixins.WorldClientMixin",
"mixins.NetworkManagerMixin",
"mixins.RenderManagerMixin",
"mixins.ItemRendererMixin"
"mixins.ItemRendererMixin",
"mixins.RenderGlobalMixin"
]
}