Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.ChestBlock;
import net.minecraft.block.MapColor;
import net.minecraft.block.entity.*;
import net.minecraft.block.enums.ChestType;
import net.minecraft.util.math.BlockPos;
Expand Down Expand Up @@ -105,48 +106,6 @@ public class StorageESP extends Module {
.build()
);

private final Setting<SettingColor> chest = sgGeneral.add(new ColorSetting.Builder()
.name("chest")
.description("The color of chests.")
.defaultValue(new SettingColor(255, 160, 0, 255))
.build()
);

private final Setting<SettingColor> trappedChest = sgGeneral.add(new ColorSetting.Builder()
.name("trapped-chest")
.description("The color of trapped chests.")
.defaultValue(new SettingColor(255, 0, 0, 255))
.build()
);

private final Setting<SettingColor> barrel = sgGeneral.add(new ColorSetting.Builder()
.name("barrel")
.description("The color of barrels.")
.defaultValue(new SettingColor(255, 160, 0, 255))
.build()
);

private final Setting<SettingColor> shulker = sgGeneral.add(new ColorSetting.Builder()
.name("shulker")
.description("The color of Shulker Boxes.")
.defaultValue(new SettingColor(255, 160, 0, 255))
.build()
);

private final Setting<SettingColor> enderChest = sgGeneral.add(new ColorSetting.Builder()
.name("ender-chest")
.description("The color of Ender Chests.")
.defaultValue(new SettingColor(120, 0, 255, 255))
.build()
);

private final Setting<SettingColor> other = sgGeneral.add(new ColorSetting.Builder()
.name("other")
.description("The color of furnaces, dispensers, droppers and hoppers.")
.defaultValue(new SettingColor(140, 140, 140, 255))
.build()
);

private final Setting<Double> fadeDistance = sgGeneral.add(new DoubleSetting.Builder()
.name("fade-distance")
.description("The distance at which the color will fade.")
Expand Down Expand Up @@ -191,20 +150,14 @@ private void getBlockEntityColor(BlockEntity blockEntity) {

if (!storageBlocks.get().contains(blockEntity.getType())) return;

if (blockEntity instanceof TrappedChestBlockEntity) lineColor.set(trappedChest.get()); // Must come before ChestBlockEntity as it is the superclass of TrappedChestBlockEntity
else if (blockEntity instanceof ChestBlockEntity) lineColor.set(chest.get());
else if (blockEntity instanceof BarrelBlockEntity) lineColor.set(barrel.get());
else if (blockEntity instanceof ShulkerBoxBlockEntity) lineColor.set(shulker.get());
else if (blockEntity instanceof EnderChestBlockEntity) lineColor.set(enderChest.get());
else if (blockEntity instanceof AbstractFurnaceBlockEntity || blockEntity instanceof BrewingStandBlockEntity || blockEntity instanceof ChiseledBookshelfBlockEntity || blockEntity instanceof CrafterBlockEntity || blockEntity instanceof DispenserBlockEntity || blockEntity instanceof DecoratedPotBlockEntity || blockEntity instanceof HopperBlockEntity) lineColor.set(other.get());
else return;

render = true;
Color c = new Color(blockEntity.getCachedState().getBlock().getDefaultMapColor().getRenderColor(MapColor.Brightness.NORMAL));
lineColor.set(c);

if (shapeMode.get() == ShapeMode.Sides || shapeMode.get() == ShapeMode.Both) {
sideColor.set(lineColor);
sideColor.set(c);
sideColor.a = fillOpacity.get();
}
render = true;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import meteordevelopment.meteorclient.utils.render.color.SettingColor;
import meteordevelopment.orbit.EventHandler;
import net.minecraft.block.Block;
import net.minecraft.util.Colors;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.chunk.Chunk;
Expand Down Expand Up @@ -53,10 +54,7 @@ public class BlockESP extends Module {
.defaultValue(
new ESPBlockData(
ShapeMode.Lines,
new SettingColor(0, 255, 200),
new SettingColor(0, 255, 200, 25),
true,
new SettingColor(0, 255, 200, 125)
true
)
)
.build()
Expand Down Expand Up @@ -86,8 +84,6 @@ public class BlockESP extends Module {

public BlockESP() {
super(Categories.Render, "block-esp", "Renders specified blocks through walls.", "search");

RainbowColors.register(this::onTickRainbow);
}

@Override
Expand All @@ -112,13 +108,6 @@ public void onDeactivate() {
}
}

private void onTickRainbow() {
if (!isActive()) return;

defaultBlockConfig.get().tickRainbow();
for (ESPBlockData blockData : blockConfigs.get().values()) blockData.tickRainbow();
}

ESPBlockData getBlockData(Block block) {
ESPBlockData blockData = blockConfigs.get().get(block);
return blockData == null ? defaultBlockConfig.get() : blockData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class ESPBlock {
public final int x, y, z;
private BlockState state;
public int neighbours;

public int color;
public ESPGroup group;

public boolean loaded = true;
Expand Down Expand Up @@ -190,8 +190,15 @@ public void render(Render3DEvent event) {
ESPBlockData blockData = blockEsp.getBlockData(state.getBlock());

ShapeMode shapeMode = blockData.shapeMode;
Color lineColor = blockData.lineColor;
Color sideColor = blockData.sideColor;
int c = this.color;

Color lineColor = new Color(c);
Color sideColor = new Color(
(c >> 16) & 255,
(c >> 8) & 255,
c & 255,
50
);

if (neighbours == 0) {
event.renderer.box(x1, y1, z1, x2, y2, z2, sideColor, lineColor, shapeMode, 0);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/*
* This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client).
* Copyright (c) Meteor Development.
*/

package meteordevelopment.meteorclient.systems.modules.render.blockesp;

import meteordevelopment.meteorclient.gui.GuiTheme;
Expand All @@ -13,27 +8,17 @@
import meteordevelopment.meteorclient.settings.IBlockData;
import meteordevelopment.meteorclient.settings.IGeneric;
import meteordevelopment.meteorclient.utils.misc.IChangeable;
import meteordevelopment.meteorclient.utils.render.color.SettingColor;
import net.minecraft.block.Block;
import net.minecraft.nbt.NbtCompound;

public class ESPBlockData implements IGeneric<ESPBlockData>, IChangeable, IBlockData<ESPBlockData> {
public ShapeMode shapeMode;
public SettingColor lineColor;
public SettingColor sideColor;

public boolean tracer;
public SettingColor tracerColor;
public boolean changed;

private boolean changed;

public ESPBlockData(ShapeMode shapeMode, SettingColor lineColor, SettingColor sideColor, boolean tracer, SettingColor tracerColor) {
public ESPBlockData(ShapeMode shapeMode, boolean tracer) {
this.shapeMode = shapeMode;
this.lineColor = lineColor;
this.sideColor = sideColor;

this.tracer = tracer;
this.tracerColor = tracerColor;
}

@Override
Expand All @@ -55,42 +40,24 @@ public void changed() {
changed = true;
}

public void tickRainbow() {
lineColor.update();
sideColor.update();
tracerColor.update();
}

@Override
public ESPBlockData set(ESPBlockData value) {
shapeMode = value.shapeMode;
lineColor.set(value.lineColor);
sideColor.set(value.sideColor);

tracer = value.tracer;
tracerColor.set(value.tracerColor);

changed = value.changed;

return this;
}

@Override
public ESPBlockData copy() {
return new ESPBlockData(shapeMode, new SettingColor(lineColor), new SettingColor(sideColor), tracer, new SettingColor(tracerColor));
return new ESPBlockData(shapeMode, tracer);
}

@Override
public NbtCompound toTag() {
NbtCompound tag = new NbtCompound();

tag.putString("shapeMode", shapeMode.name());
tag.put("lineColor", lineColor.toTag());
tag.put("sideColor", sideColor.toTag());

tag.putBoolean("tracer", tracer);
tag.put("tracerColor", tracerColor.toTag());

tag.putBoolean("changed", changed);

return tag;
Expand All @@ -99,12 +66,7 @@ public NbtCompound toTag() {
@Override
public ESPBlockData fromTag(NbtCompound tag) {
shapeMode = ShapeMode.valueOf(tag.getString("shapeMode", ""));
lineColor.fromTag(tag.getCompoundOrEmpty("lineColor"));
sideColor.fromTag(tag.getCompoundOrEmpty("sideColor"));

tracer = tag.getBoolean("tracer", false);
tracerColor.fromTag(tag.getCompoundOrEmpty("tracerColor"));

changed = tag.getBoolean("changed", false);

return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,34 +54,6 @@ public void initWidgets() {
.build()
);

sgGeneral.add(new ColorSetting.Builder()
.name("line-color")
.description("Color of lines.")
.defaultValue(new SettingColor(0, 255, 200))
.onModuleActivated(settingColorSetting -> settingColorSetting.get().set(blockData.lineColor))
.onChanged(settingColor -> {
if (!blockData.lineColor.equals(settingColor)) {
blockData.lineColor.set(settingColor);
onChanged();
}
})
.build()
);

sgGeneral.add(new ColorSetting.Builder()
.name("side-color")
.description("Color of sides.")
.defaultValue(new SettingColor(0, 255, 200, 25))
.onModuleActivated(settingColorSetting -> settingColorSetting.get().set(blockData.sideColor))
.onChanged(settingColor -> {
if (!blockData.sideColor.equals(settingColor)) {
blockData.sideColor.set(settingColor);
onChanged();
}
})
.build()
);

sgTracer.add(new BoolSetting.Builder()
.name("tracer")
.description("If tracer line is allowed to this block.")
Expand All @@ -96,20 +68,6 @@ public void initWidgets() {
.build()
);

sgTracer.add(new ColorSetting.Builder()
.name("tracer-color")
.description("Color of tracer line.")
.defaultValue(new SettingColor(0, 255, 200, 125))
.onModuleActivated(settingColorSetting -> settingColorSetting.get().set(blockData.tracerColor))
.onChanged(settingColor -> {
if (!blockData.tracerColor.equals(settingColor)) {
blockData.tracerColor.set(settingColor);
onChanged();
}
})
.build()
);

settings.onActivated();
add(theme.settings(settings)).expandX();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import meteordevelopment.meteorclient.events.render.Render3DEvent;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.MapColor;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkSectionPos;
import net.minecraft.world.Heightmap;
Expand Down Expand Up @@ -37,6 +38,10 @@ public ESPBlock get(int x, int y, int z) {
public void add(BlockPos blockPos, boolean update) {
ESPBlock block = new ESPBlock(blockPos.getX(), blockPos.getY(), blockPos.getZ());

BlockState state = mc.world.getBlockState(blockPos);

block.color = state.getBlock().getDefaultMapColor().getRenderColor(MapColor.Brightness.NORMAL);

if (blocks == null) blocks = new Long2ObjectOpenHashMap<>(64);
blocks.put(ESPBlock.getKey(blockPos), block);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import meteordevelopment.meteorclient.systems.modules.Modules;
import meteordevelopment.meteorclient.utils.misc.UnorderedArrayList;
import meteordevelopment.meteorclient.utils.render.RenderUtils;
import meteordevelopment.meteorclient.utils.render.color.Color;
import net.minecraft.block.Block;

import java.util.ArrayDeque;
Expand Down Expand Up @@ -141,8 +142,12 @@ public void merge(ESPGroup group) {
public void render(Render3DEvent event) {
ESPBlockData blockData = blockEsp.getBlockData(block);

if (blockData.tracer) {
event.renderer.line(RenderUtils.center.x, RenderUtils.center.y, RenderUtils.center.z, sumX / blocks.size() + 0.5, sumY / blocks.size() + 0.5, sumZ / blocks.size() + 0.5, blockData.tracerColor);
if (blockData.tracer && !blocks.isEmpty()) {
ESPBlock b = blocks.getFirst();

int c = b.color;

event.renderer.line(RenderUtils.center.x, RenderUtils.center.y, RenderUtils.center.z, sumX / blocks.size() + 0.5, sumY / blocks.size() + 0.5, sumZ / blocks.size() + 0.5, new Color(c));
}
}
}
Loading