feat: scuffed but mostly working storage ESP
This commit is contained in:
parent
82e93b6359
commit
1a189e9c8a
1 changed files with 134 additions and 0 deletions
134
src/main/java/ftbsc/bscv/modules/vision/StorageESP.java
Normal file
134
src/main/java/ftbsc/bscv/modules/vision/StorageESP.java
Normal file
|
@ -0,0 +1,134 @@
|
|||
package ftbsc.bscv.modules.vision;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.google.auto.service.AutoService;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import ftbsc.bscv.ICommons;
|
||||
import ftbsc.bscv.api.ILoadable;
|
||||
import ftbsc.bscv.modules.AbstractModule;
|
||||
import ftbsc.bscv.modules.QuickModule;
|
||||
import ftbsc.bscv.tools.Setting;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import net.minecraft.client.renderer.WorldVertexBufferUploader;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.tileentity.BarrelTileEntity;
|
||||
import net.minecraft.tileentity.BeaconTileEntity;
|
||||
import net.minecraft.tileentity.BlastFurnaceTileEntity;
|
||||
import net.minecraft.tileentity.ChestTileEntity;
|
||||
import net.minecraft.tileentity.CommandBlockTileEntity;
|
||||
import net.minecraft.tileentity.ConduitTileEntity;
|
||||
import net.minecraft.tileentity.DispenserTileEntity;
|
||||
import net.minecraft.tileentity.DropperTileEntity;
|
||||
import net.minecraft.tileentity.EndGatewayTileEntity;
|
||||
import net.minecraft.tileentity.EnderChestTileEntity;
|
||||
import net.minecraft.tileentity.FurnaceTileEntity;
|
||||
import net.minecraft.tileentity.HopperTileEntity;
|
||||
import net.minecraft.tileentity.MobSpawnerTileEntity;
|
||||
import net.minecraft.tileentity.ShulkerBoxTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TrappedChestTileEntity;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.math.vector.Vector3f;
|
||||
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
||||
import net.minecraftforge.common.ForgeConfigSpec;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
||||
@AutoService(ILoadable.class)
|
||||
public class StorageESP extends QuickModule implements ICommons {
|
||||
private static final Vector3f COLOR = new Vector3f(191.f/255.f, 97.f/255.f, 106.f/255.f);
|
||||
private static final Vector3f CHEST_COLOR = new Vector3f(255.f/255.f, 170.f/255.f, 0.f/255.f);
|
||||
private static final Vector3f ENDER_CHEST_COLOR = new Vector3f(170.f/255.f, 0.f/255.f, 170.f/255.f);
|
||||
private static final Vector3f SHULKER_COLOR = new Vector3f( 0.f/255.f, 170.f/255.f, 170.f/255.f);
|
||||
private static final Vector3f HOPPER_COLOR = new Vector3f(170.f/255.f, 170.f/255.f, 170.f/255.f);
|
||||
private static final Vector3f FURNACE_COLOR = new Vector3f(255.f/255.f, 85.f/255.f, 85.f/255.f);
|
||||
private static final Vector3f DROPPER_COLOR = new Vector3f( 0.f/255.f, 170.f/255.f, 0.f/255.f);
|
||||
|
||||
protected int getDefaultKey() { return UNBOUND; }
|
||||
|
||||
public final ForgeConfigSpec.ConfigValue<Double> width;
|
||||
public final ForgeConfigSpec.ConfigValue<Double> alpha;
|
||||
|
||||
public StorageESP() {
|
||||
super();
|
||||
|
||||
this.width = Setting.Decimal.builder()
|
||||
.min(0)
|
||||
.fallback(1.)
|
||||
.name("width")
|
||||
.comment("line width")
|
||||
.build(this);
|
||||
|
||||
this.alpha = Setting.Decimal.builder()
|
||||
.min(0.)
|
||||
.max(1.)
|
||||
.fallback(0.7)
|
||||
.name("alpha")
|
||||
.comment("line alpha")
|
||||
.build(this);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Vector3f tileHighlight(TileEntity entity) {
|
||||
if (entity instanceof EnderChestTileEntity) return ENDER_CHEST_COLOR;
|
||||
if (entity instanceof BarrelTileEntity) return CHEST_COLOR;
|
||||
if (entity instanceof BeaconTileEntity) return COLOR;
|
||||
if (entity instanceof BlastFurnaceTileEntity) return FURNACE_COLOR;
|
||||
if (entity instanceof ChestTileEntity) return CHEST_COLOR;
|
||||
if (entity instanceof CommandBlockTileEntity) return COLOR;
|
||||
if (entity instanceof ConduitTileEntity) return COLOR;
|
||||
if (entity instanceof DispenserTileEntity) return DROPPER_COLOR; // TODO not highlighted???
|
||||
if (entity instanceof DropperTileEntity) return DROPPER_COLOR; // TODO not highlighted???
|
||||
if (entity instanceof EndGatewayTileEntity) return COLOR;
|
||||
if (entity instanceof FurnaceTileEntity) return FURNACE_COLOR;
|
||||
if (entity instanceof HopperTileEntity) return HOPPER_COLOR;
|
||||
if (entity instanceof MobSpawnerTileEntity) return COLOR;
|
||||
if (entity instanceof ShulkerBoxTileEntity) return SHULKER_COLOR;
|
||||
if (entity instanceof TrappedChestTileEntity) return CHEST_COLOR;
|
||||
return null;
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onRenderWorld(RenderWorldLastEvent event) {
|
||||
RenderSystem.pushMatrix(); // ??
|
||||
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.disableTexture();
|
||||
RenderSystem.disableDepthTest();
|
||||
RenderSystem.lineWidth(this.width.get().floatValue());
|
||||
|
||||
Vector3d projectedView = MC.gameRenderer.getMainCamera().getPosition().scale(-1);
|
||||
MatrixStack stack = event.getMatrixStack();
|
||||
stack.pushPose(); // ??
|
||||
stack.translate(projectedView.x(), projectedView.y(), projectedView.z());
|
||||
|
||||
BufferBuilder builder = Tessellator.getInstance().getBuilder();
|
||||
builder.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_COLOR);
|
||||
|
||||
for (TileEntity ent : MC.level.tickableBlockEntities) {
|
||||
Vector3f color = this.tileHighlight(ent);
|
||||
if (color != null) {
|
||||
AxisAlignedBB bounds = ent.getBlockState().getCollisionShape(MC.level, ent.getBlockPos()).bounds().move(ent.getBlockPos());
|
||||
WorldRenderer.renderLineBox(stack, builder, bounds, color.x(), color.y(), color.z(), this.alpha.get().floatValue());
|
||||
}
|
||||
}
|
||||
|
||||
builder.end();
|
||||
WorldVertexBufferUploader.end(builder);
|
||||
stack.popPose(); // ??
|
||||
|
||||
RenderSystem.lineWidth(1.f);
|
||||
RenderSystem.enableTexture();
|
||||
RenderSystem.enableDepthTest();
|
||||
RenderSystem.disableBlend();
|
||||
RenderSystem.enableCull();
|
||||
|
||||
RenderSystem.popMatrix(); // ??
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue