0
0
mirror of https://github.com/Wurst-Imperium/Wurst7.git synced 2024-09-20 09:16:20 +02:00

Add checkboxes that toggle each group

This commit is contained in:
Alexander01998 2022-05-04 22:44:02 +02:00
parent cb1b5dca72
commit c50e288ef7
4 changed files with 56 additions and 29 deletions

View File

@ -37,6 +37,7 @@ import net.wurstclient.hacks.chestesp.ChestEspEntityGroup;
import net.wurstclient.hacks.chestesp.ChestEspGroup;
import net.wurstclient.hacks.chestesp.ChestEspRenderer;
import net.wurstclient.hacks.chestesp.ChestEspStyle;
import net.wurstclient.settings.CheckboxSetting;
import net.wurstclient.settings.ColorSetting;
import net.wurstclient.settings.EnumSetting;
import net.wurstclient.util.ChunkUtils;
@ -48,41 +49,51 @@ public class ChestEspHack extends Hack implements UpdateListener,
private final EnumSetting<ChestEspStyle> style =
new EnumSetting<>("Style", ChestEspStyle.values(), ChestEspStyle.BOXES);
private final ChestEspBlockGroup basicChests =
new ChestEspBlockGroup(new ColorSetting("Chest color",
"Normal chests will be highlighted in this color.", Color.GREEN));
private final ChestEspBlockGroup basicChests = new ChestEspBlockGroup(
new ColorSetting("Chest color",
"Normal chests will be highlighted in this color.", Color.GREEN),
null);
private final ChestEspBlockGroup trapChests =
new ChestEspBlockGroup(new ColorSetting("Trap color",
"Trapped chests will be highlighted in this color.",
new Color(0xFF8000)));
new ChestEspBlockGroup(
new ColorSetting("Trap color",
"Trapped chests will be highlighted in this color.",
new Color(0xFF8000)),
new CheckboxSetting("Include traps", true));
private final ChestEspBlockGroup enderChests =
new ChestEspBlockGroup(new ColorSetting("Ender color",
"Ender chests will be highlighted in this color.", Color.CYAN));
private final ChestEspBlockGroup enderChests = new ChestEspBlockGroup(
new ColorSetting("Ender color",
"Ender chests will be highlighted in this color.", Color.CYAN),
new CheckboxSetting("Include ender chests", true));
private final ChestEspBlockGroup barrels =
new ChestEspBlockGroup(new ColorSetting("Barrel color",
"Barrels will be highlighted in this color.", Color.GREEN));
private final ChestEspBlockGroup barrels = new ChestEspBlockGroup(
new ColorSetting("Barrel color",
"Barrels will be highlighted in this color.", Color.GREEN),
new CheckboxSetting("Include barrels", true));
private final ChestEspBlockGroup shulkerBoxes =
new ChestEspBlockGroup(new ColorSetting("Shulker color",
"Shulker boxes will be highlighted in this color.", Color.MAGENTA));
private final ChestEspBlockGroup shulkerBoxes = new ChestEspBlockGroup(
new ColorSetting("Shulker color",
"Shulker boxes will be highlighted in this color.", Color.MAGENTA),
new CheckboxSetting("Include shulkers", true));
private final ChestEspEntityGroup minecarts =
new ChestEspEntityGroup(new ColorSetting("Cart color",
"Minecarts will be highlighted in this color.", Color.GREEN));
private final ChestEspEntityGroup minecarts = new ChestEspEntityGroup(
new ColorSetting("Cart color",
"Minecarts will be highlighted in this color.", Color.GREEN),
new CheckboxSetting("Include carts", true));
private final List<ChestEspGroup> groups = Arrays.asList(basicChests,
trapChests, enderChests, barrels, shulkerBoxes, minecarts);
private final List<ChestEspEntityGroup> entityGroups =
Arrays.asList(minecarts);
public ChestEspHack()
{
super("ChestESP");
setCategory(Category.RENDER);
addSetting(style);
groups.stream().map(ChestEspGroup::getSetting)
groups.stream().flatMap(ChestEspGroup::getSettings)
.forEach(this::addSetting);
}
@ -154,19 +165,23 @@ public class ChestEspHack extends Hack implements UpdateListener,
matrixStack.push();
RenderUtils.applyRegionalRenderOffset(matrixStack);
minecarts.updateBoxes(partialTicks);
entityGroups.stream().filter(ChestEspGroup::isEnabled)
.forEach(g -> g.updateBoxes(partialTicks));
ChestEspRenderer espRenderer = new ChestEspRenderer(matrixStack);
if(style.getSelected().hasBoxes())
{
RenderSystem.setShader(GameRenderer::getPositionShader);
groups.forEach(espRenderer::renderBoxes);
groups.stream().filter(ChestEspGroup::isEnabled)
.forEach(espRenderer::renderBoxes);
}
if(style.getSelected().hasLines())
{
RenderSystem.setShader(GameRenderer::getPositionShader);
groups.forEach(espRenderer::renderLines);
groups.stream().filter(ChestEspGroup::isEnabled)
.forEach(espRenderer::renderLines);
}
matrixStack.pop();

View File

@ -14,14 +14,15 @@ import net.minecraft.block.entity.ChestBlockEntity;
import net.minecraft.block.enums.ChestType;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Box;
import net.wurstclient.settings.CheckboxSetting;
import net.wurstclient.settings.ColorSetting;
import net.wurstclient.util.BlockUtils;
public final class ChestEspBlockGroup extends ChestEspGroup
{
public ChestEspBlockGroup(ColorSetting color)
public ChestEspBlockGroup(ColorSetting color, CheckboxSetting enabled)
{
super(color);
super(color, enabled);
}
public void add(BlockEntity be)

View File

@ -10,15 +10,16 @@ package net.wurstclient.hacks.chestesp;
import java.util.ArrayList;
import net.minecraft.entity.Entity;
import net.wurstclient.settings.CheckboxSetting;
import net.wurstclient.settings.ColorSetting;
public final class ChestEspEntityGroup extends ChestEspGroup
{
private final ArrayList<Entity> entities = new ArrayList<>();
public ChestEspEntityGroup(ColorSetting color)
public ChestEspEntityGroup(ColorSetting color, CheckboxSetting enabled)
{
super(color);
super(color, enabled);
}
public void add(Entity e)

View File

@ -11,18 +11,23 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.stream.Stream;
import net.minecraft.util.math.Box;
import net.wurstclient.settings.CheckboxSetting;
import net.wurstclient.settings.ColorSetting;
import net.wurstclient.settings.Setting;
public abstract class ChestEspGroup
{
protected final ArrayList<Box> boxes = new ArrayList<>();
private final ColorSetting color;
private final CheckboxSetting enabled;
public ChestEspGroup(ColorSetting color)
public ChestEspGroup(ColorSetting color, CheckboxSetting enabled)
{
this.color = Objects.requireNonNull(color);
this.enabled = enabled;
}
public void clear()
@ -30,9 +35,14 @@ public abstract class ChestEspGroup
boxes.clear();
}
public ColorSetting getSetting()
public boolean isEnabled()
{
return color;
return enabled == null || enabled.isChecked();
}
public Stream<Setting> getSettings()
{
return Stream.of(enabled, color).filter(Objects::nonNull);
}
public float[] getColorF()