FullBright

This commit is contained in:
kirillsaint 2023-07-01 15:14:51 +06:00
parent 99e0858f98
commit df8e8cc4ec
4 changed files with 56 additions and 1 deletions

View File

@ -0,0 +1,19 @@
package net.silentclient.client.mixin.mixins;
import net.minecraft.world.chunk.Chunk;
import net.silentclient.client.Client;
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.CallbackInfoReturnable;
@Mixin(Chunk.class)
public class ChunkMixin {
@Inject(method = {"getLightFor", "getLightSubtracted"}, at = @At("HEAD"), cancellable = true)
private void patchFullbright(CallbackInfoReturnable<Integer> cir) {
if (Client.getInstance().getModInstances().getFullBrightMod().isEnabled()) {
cir.setReturnValue(15);
}
}
}

View File

@ -1,9 +1,12 @@
package net.silentclient.client.mixin.mixins;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.world.World;
import net.silentclient.client.Client;
import net.silentclient.client.event.impl.EntityJoinLevelEvent;
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;
@ -11,6 +14,25 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(World.class)
public class WorldMixin {
@Inject(method = "checkLightFor", at = @At("HEAD"), cancellable = true)
private void checkLightFor(CallbackInfoReturnable<Boolean> cir) {
if (this.canFullbright()) {
cir.setReturnValue(true);
}
}
@Inject(method = {"getLightFromNeighborsFor", "getLightFromNeighbors", "getRawLight", "getLight(Lnet/minecraft/util/BlockPos;)I", "getLight(Lnet/minecraft/util/BlockPos;Z)I" }, at = @At("HEAD"), cancellable = true)
private void getLightFromNeighborsFor(CallbackInfoReturnable<Integer> cir) {
if (this.canFullbright()) {
cir.setReturnValue(15);
}
}
@Unique
private boolean canFullbright() {
return Minecraft.getMinecraft().isCallingFromMinecraftThread() && Client.getInstance().getModInstances().getFullBrightMod().isEnabled();
}
@Inject(method = "spawnEntityInWorld", at = @At("HEAD"), cancellable = true)
public void callEntityJoinLevelEvent1(Entity entityIn, CallbackInfoReturnable<Boolean> cir) {
EntityJoinLevelEvent event = new EntityJoinLevelEvent(entityIn);

View File

@ -0,0 +1,13 @@
package net.silentclient.client.utils;
public class ClientUtils {
public static boolean isDevelopment() {
for(StackTraceElement element : Thread.currentThread().getStackTrace()) {
if(element.getClassName().equals("GradleStart")) {
return true;
}
}
return false;
}
}

View File

@ -42,6 +42,7 @@
"mixins.ShaderGroupMixin",
"mixins.GuiContainerMixin",
"mixins.InventoryEffectRendererMixin",
"mixins.TextureManagerMixin"
"mixins.TextureManagerMixin",
"mixins.ChunkMixin"
]
}