Skip to content

Commit

Permalink
Add xray - ballmc
Browse files Browse the repository at this point in the history
Accept pull 56
  • Loading branch information
Syz66 committed Nov 2, 2023
2 parents 58bf9e9 + 3b4b919 commit 1a0d3ae
Show file tree
Hide file tree
Showing 9 changed files with 381 additions and 5 deletions.
29 changes: 29 additions & 0 deletions src/main/java/me/pianopenguin471/mixins/BlockGrassMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package me.pianopenguin471.mixins;

import ravenweave.client.module.modules.render.Xray;
import net.minecraft.block.Block;
import net.minecraft.block.BlockGrass;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.util.EnumWorldBlockLayer;
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;
import ravenweave.client.main.Raven;

@Mixin(priority = 1005, value = BlockGrass.class)
public class BlockGrassMixin extends Block {

public BlockGrassMixin(Material p_i46399_1_, MapColor p_i46399_2_) {
super(p_i46399_1_, p_i46399_2_);
}

@Inject(method = "getBlockLayer", at = @At("HEAD"), cancellable = true)
public void getBlockLayer(CallbackInfoReturnable<EnumWorldBlockLayer> cir) {
if(Raven.moduleManager.getModuleByClazz(Xray.class).isEnabled()) {
cir.setReturnValue(super.getBlockLayer());
}
}

}
40 changes: 40 additions & 0 deletions src/main/java/me/pianopenguin471/mixins/BlockMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package me.pianopenguin471.mixins;

import ravenweave.client.module.modules.render.Xray;
import net.minecraft.block.Block;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.world.IBlockAccess;
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;
import ravenweave.client.main.Raven;

@Mixin(value = Block.class, priority = 1005)
public class BlockMixin {

@Inject(method = "shouldSideBeRendered", at = @At("HEAD"), cancellable = true)
public void shouldSideBeRendered(IBlockAccess p_shouldSideBeRendered_1_, BlockPos p_shouldSideBeRendered_2_,
EnumFacing p_shouldSideBeRendered_3_, CallbackInfoReturnable<Boolean> cir) {
if(Raven.moduleManager.getModuleByClazz(Xray.class).isEnabled() && Xray.hypixel.isToggled()) {
cir.setReturnValue(Xray.isOreBlock((Block) (Object) this));
}
}

@Inject(method = "getBlockLayer", at = @At("HEAD"), cancellable = true)
public void getBlockLayer(CallbackInfoReturnable<EnumWorldBlockLayer> cir) {
if(Raven.moduleManager.getModuleByClazz(Xray.class).isEnabled()) {
cir.setReturnValue(Xray.isOreBlock((Block) (Object) this) ? EnumWorldBlockLayer.SOLID : EnumWorldBlockLayer.TRANSLUCENT);
}
}

@Inject(method = "getAmbientOcclusionLightValue", at = @At("HEAD"), cancellable = true)
public void getAmbientOcclusionLightValue(CallbackInfoReturnable<Float> cir) {
if (Raven.moduleManager.getModuleByClazz(Xray.class).isEnabled()) {
cir.setReturnValue(1F);
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package me.pianopenguin471.mixins;

import ravenweave.client.module.modules.render.Xray;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.BlockModelRenderer;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.resources.model.IBakedModel;
import net.minecraft.crash.CrashReport;
import net.minecraft.crash.CrashReportCategory;
import net.minecraft.util.BlockPos;
import net.minecraft.util.ReportedException;
import net.minecraft.world.IBlockAccess;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import ravenweave.client.main.Raven;
@Mixin(value = BlockModelRenderer.class, priority = 999)
public abstract class BlockModelRendererMixin {

@Shadow public abstract boolean renderModelAmbientOcclusion(IBlockAccess p_renderModelAmbientOcclusion_1_, IBakedModel p_renderModelAmbientOcclusion_2_, Block p_renderModelAmbientOcclusion_3_, BlockPos p_renderModelAmbientOcclusion_4_, WorldRenderer p_renderModelAmbientOcclusion_5_, boolean p_renderModelAmbientOcclusion_6_);

@Shadow public abstract boolean renderModelStandard(IBlockAccess p_renderModelStandard_1_, IBakedModel p_renderModelStandard_2_, Block p_renderModelStandard_3_, BlockPos p_renderModelStandard_4_, WorldRenderer p_renderModelStandard_5_, boolean p_renderModelStandard_6_);

/**
* @author mc code
* @reason god help me
*/
@Overwrite
public boolean renderModel(IBlockAccess p_renderModel_1_, IBakedModel p_renderModel_2_, IBlockState p_renderModel_3_, BlockPos p_renderModel_4_, WorldRenderer p_renderModel_5_, boolean p_renderModel_6_) {
boolean flag = Minecraft.isAmbientOcclusionEnabled() && p_renderModel_3_.getBlock().getLightValue() == 0 && p_renderModel_2_.isAmbientOcclusion() || Raven.moduleManager.getModuleByClazz(Xray.class).isEnabled();

try {
Block block = p_renderModel_3_.getBlock();
return flag ? this.renderModelAmbientOcclusion(p_renderModel_1_, p_renderModel_2_, block, p_renderModel_4_, p_renderModel_5_, p_renderModel_6_) : this.renderModelStandard(p_renderModel_1_, p_renderModel_2_, block, p_renderModel_4_, p_renderModel_5_, p_renderModel_6_);
} catch (Throwable var11) {
CrashReport crashreport = CrashReport.makeCrashReport(var11, "Tesselating block model");
CrashReportCategory crashreportcategory = crashreport.makeCategory("Block model being tesselated");
CrashReportCategory.addBlockInfo(crashreportcategory, p_renderModel_4_, p_renderModel_3_);
crashreportcategory.addCrashSection("Using AO", flag);
throw new ReportedException(crashreport);
}
}
}
152 changes: 149 additions & 3 deletions src/main/java/me/pianopenguin471/mixins/EntityRendererMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItemFrame;
import net.minecraft.world.World;
import net.minecraft.potion.Potion;
import net.minecraft.util.*;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -17,16 +19,27 @@
import ravenweave.client.module.modules.combat.HitBoxes;
import ravenweave.client.module.modules.combat.KillAura;
import ravenweave.client.module.modules.combat.Reach;
import ravenweave.client.module.modules.render.Xray;

import java.util.List;

@Mixin(priority = 995, value = EntityRenderer.class)
public class EntityRendererMixin {
public abstract class EntityRendererMixin {

@Shadow
public Minecraft mc;
private Minecraft mc;
@Shadow
public Entity pointedEntity;
private Entity pointedEntity;

@Shadow private boolean lightmapUpdateNeeded;
@Shadow private float torchFlickerX;
@Shadow private float bossColorModifier;
@Shadow private float bossColorModifierPrev;

@Shadow protected abstract float getNightVisionBrightness(EntityLivingBase p_getNightVisionBrightness_1_, float p_getNightVisionBrightness_2_);

@Shadow @Final private int[] lightmapColors;
@Shadow @Final private DynamicTexture lightmapTexture;

/**
* @author mc code
Expand Down Expand Up @@ -119,4 +132,137 @@ public void getMouseOver(float p_getMouseOver_1_) {
this.mc.mcProfiler.endSection();
}
}
@Overwrite
public void updateLightmap(float p_updateLightmap_1_) {
if (this.lightmapUpdateNeeded) {
this.mc.mcProfiler.startSection("lightTex");
World world = this.mc.theWorld;
Module xray = Raven.moduleManager.getModuleByClazz(Xray.class);
if (world != null) {

if (xray.isEnabled()) {
for (int i = 0; i < 256; ++i) {
this.lightmapColors[i] = 255 << 24 | 255 << 16 | 255 << 8 | 255;
}

this.lightmapTexture.updateDynamicTexture();
this.lightmapUpdateNeeded = false;
this.mc.mcProfiler.endSection();

return;
}

float f = world.getSunBrightness(1.0F);
float f1 = f * 0.95F + 0.05F;

for (int i = 0; i < 256; ++i) {
float f2 = world.provider.getLightBrightnessTable()[i / 16] * f1;
float f3 = world.provider.getLightBrightnessTable()[i % 16] * (this.torchFlickerX * 0.1F + 1.5F);
if (world.getLastLightningBolt() > 0) {
f2 = world.provider.getLightBrightnessTable()[i / 16];
}

float f4 = f2 * (f * 0.65F + 0.35F);
float f5 = f2 * (f * 0.65F + 0.35F);
float f6 = f3 * ((f3 * 0.6F + 0.4F) * 0.6F + 0.4F);
float f7 = f3 * (f3 * f3 * 0.6F + 0.4F);
float f8 = f4 + f3;
float f9 = f5 + f6;
float f10 = f2 + f7;
f8 = f8 * 0.96F + 0.03F;
f9 = f9 * 0.96F + 0.03F;
f10 = f10 * 0.96F + 0.03F;
float f16;
if (this.bossColorModifier > 0.0F) {
f16 = this.bossColorModifierPrev + (this.bossColorModifier - this.bossColorModifierPrev) * p_updateLightmap_1_;
f8 = f8 * (1.0F - f16) + f8 * 0.7F * f16;
f9 = f9 * (1.0F - f16) + f9 * 0.6F * f16;
f10 = f10 * (1.0F - f16) + f10 * 0.6F * f16;
}

if (world.provider.getDimensionId() == 1) {
f8 = 0.22F + f3 * 0.75F;
f9 = 0.28F + f6 * 0.75F;
f10 = 0.25F + f7 * 0.75F;
}

float f17;
if (this.mc.thePlayer.isPotionActive(Potion.nightVision)) {
f16 = this.getNightVisionBrightness(this.mc.thePlayer, p_updateLightmap_1_);
f17 = 1.0F / f8;
if (f17 > 1.0F / f9) {
f17 = 1.0F / f9;
}

if (f17 > 1.0F / f10) {
f17 = 1.0F / f10;
}

f8 = f8 * (1.0F - f16) + f8 * f17 * f16;
f9 = f9 * (1.0F - f16) + f9 * f17 * f16;
f10 = f10 * (1.0F - f16) + f10 * f17 * f16;
}

if (f8 > 1.0F) {
f8 = 1.0F;
}

if (f9 > 1.0F) {
f9 = 1.0F;
}

if (f10 > 1.0F) {
f10 = 1.0F;
}

f16 = this.mc.gameSettings.gammaSetting;
f17 = 1.0F - f8;
float f13 = 1.0F - f9;
float f14 = 1.0F - f10;
f17 = 1.0F - f17 * f17 * f17 * f17;
f13 = 1.0F - f13 * f13 * f13 * f13;
f14 = 1.0F - f14 * f14 * f14 * f14;
f8 = f8 * (1.0F - f16) + f17 * f16;
f9 = f9 * (1.0F - f16) + f13 * f16;
f10 = f10 * (1.0F - f16) + f14 * f16;
f8 = f8 * 0.96F + 0.03F;
f9 = f9 * 0.96F + 0.03F;
f10 = f10 * 0.96F + 0.03F;
if (f8 > 1.0F) {
f8 = 1.0F;
}

if (f9 > 1.0F) {
f9 = 1.0F;
}

if (f10 > 1.0F) {
f10 = 1.0F;
}

if (f8 < 0.0F) {
f8 = 0.0F;
}

if (f9 < 0.0F) {
f9 = 0.0F;
}

if (f10 < 0.0F) {
f10 = 0.0F;
}

int j = 255;
int k = (int) (f8 * 255.0F);
int l = (int) (f9 * 255.0F);
int i1 = (int) (f10 * 255.0F);
this.lightmapColors[i] = j << 24 | k << 16 | l << 8 | i1;
}

this.lightmapTexture.updateDynamicTexture();
this.lightmapUpdateNeeded = false;
this.mc.mcProfiler.endSection();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ private String renderStringHook(String s) {
return s;
}
}
}
}

66 changes: 66 additions & 0 deletions src/main/java/me/pianopenguin471/mixins/WorldRendererMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package me.pianopenguin471.mixins;

import ravenweave.client.module.modules.render.Xray;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.util.MathHelper;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;

import java.nio.ByteOrder;
import java.nio.IntBuffer;
import ravenweave.client.main.Raven;

@Mixin(value = WorldRenderer.class, priority = 999)
public abstract class WorldRendererMixin {

@Shadow public abstract int getColorIndex(int p_getColorIndex_1_);

@Shadow private boolean noColor;
@Shadow private IntBuffer rawIntBuffer;

/**
* @author mc code
* @reason aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
*/
@Overwrite
public void putColorMultiplier(float p_putColorMultiplier_1_, float p_putColorMultiplier_2_, float p_putColorMultiplier_3_, int p_putColorMultiplier_4_) {
int i = this.getColorIndex(p_putColorMultiplier_4_);
int j = -1;

if (!this.noColor) {
j = this.rawIntBuffer.get(i);
int k;
int l;
int i1;
if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN) {
k = (int) ((float) (j & 255) * p_putColorMultiplier_1_);
l = (int) ((float) (j >> 8 & 255) * p_putColorMultiplier_2_);
i1 = (int) ((float) (j >> 16 & 255) * p_putColorMultiplier_3_);
j &= -16777216;
j = j | i1 << 16 | l << 8 | k;
} else {
k = (int) ((float) (j >> 24 & 255) * p_putColorMultiplier_1_);
l = (int) ((float) (j >> 16 & 255) * p_putColorMultiplier_2_);
i1 = (int) ((float) (j >> 8 & 255) * p_putColorMultiplier_3_);
j &= 255;
j = j | k << 24 | l << 16 | i1 << 8;
}

if(Raven.moduleManager.getModuleByClazz(Xray.class).isEnabled()) {
j = getColor(k, l, i1, (int) Xray.opacity.getInput());
}
}

this.rawIntBuffer.put(i, j);
}

public int getColor(int red, int green, int blue, int alpha) {
int color = MathHelper.clamp_int(alpha, 0, 255) << 24;
color |= MathHelper.clamp_int(red, 0, 255) << 16;
color |= MathHelper.clamp_int(green, 0, 255) << 8;
color |= MathHelper.clamp_int(blue, 0, 255);
return color;
}

}
1 change: 1 addition & 0 deletions src/main/java/ravenweave/client/module/ModuleManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public ModuleManager() {
addModule(new Chams());
addModule(new ChestESP());
addModule(new Nametags());
addModule(new Xray());
addModule(new AntiShuffle());
addModule(new PlayerESP());
addModule(new Tracers());
Expand Down
Loading

0 comments on commit 1a0d3ae

Please sign in to comment.