diff --git a/src/openonyx/features/render/AppearanceMode.java b/src/openonyx/features/render/AppearanceMode.java new file mode 100644 index 0000000..2742a9a --- /dev/null +++ b/src/openonyx/features/render/AppearanceMode.java @@ -0,0 +1,35 @@ +package openonyx.features.render; + +import openonyx.history.DisplayNamed; + +public enum AppearanceMode implements DisplayNamed { + FADE("Fade", 1.0F), + POP("Pop", 0.62F), + GROW("Grow", 0.0F); + + private final String i; + private final float f; + + AppearanceMode(String string1, float f) { + this.i = string1; + this.f = fx; + } + + public float L() { + return this.f; + } + + private static AppearanceMode[] L() { + AppearanceMode[] appearanceModes = new AppearanceMode[3]; + boolean bl = true; + appearanceModes[0] = FADE; + appearanceModes[1] = POP; + appearanceModes[2] = GROW; + return appearanceModes; + } + + @Override + public String getDisplayName() { + return this.i; + } +} diff --git a/src/openonyx/features/render/ArmWidthMode.java b/src/openonyx/features/render/ArmWidthMode.java new file mode 100644 index 0000000..880be7d --- /dev/null +++ b/src/openonyx/features/render/ArmWidthMode.java @@ -0,0 +1,14 @@ +package openonyx.features.render; + +public enum ArmWidthMode { + DEFAULT, + SLIM; + + private static ArmWidthMode[] L() { + ArmWidthMode[] armWidthModes = new ArmWidthMode[2]; + boolean bl = true; + armWidthModes[0] = DEFAULT; + armWidthModes[1] = SLIM; + return armWidthModes; + } +} diff --git a/src/openonyx/features/render/Arrows.java b/src/openonyx/features/render/Arrows.java new file mode 100644 index 0000000..a8a720e --- /dev/null +++ b/src/openonyx/features/render/Arrows.java @@ -0,0 +1,184 @@ +package openonyx.features.render; + +import java.util.ArrayList; +import java.util.Iterator; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.gui.inventory.GuiInventory; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Vec3; +import openonyx.features.Module; +import openonyx.features.ModuleCategory; +import openonyx.history.internal.ColorSetting; +import openonyx.history.internal.EnumSetting; +import openonyx.history.internal.NumberSetting; +import openonyx.render.Render2D; +import openonyx.render.WorldToScreen; +import openonyx.theme.internal.ColorUtils; + +public final class Arrows extends Module { + private long D; + public final NumberSetting size; + public final NumberSetting distance; + private final Render2D render2D; + public final ColorSetting color; + public final EnumSetting design = new EnumSetting<>("Design", DesignMode.OUTLINE).describe("Which arrow is drawn"); + private static final ResourceLocation RESOURCE_LOCATION = new ResourceLocation("onyx", "textures/pointers/solid.png"); + private static final float j = 100.0F; + private float m; + public final NumberSetting opacity; + private static final float l = 100.0F; + public final NumberSetting range; + public final NumberSetting glow; + private static final ResourceLocation RESOURCE_LOCATION2 = new ResourceLocation("onyx", "textures/pointers/chevron.png"); + public final ColorSetting secondColor; + private static final ResourceLocation RESOURCE_LOCATION3 = new ResourceLocation("onyx", "textures/pointers/outline.png"); + private static final double e = 90.0; + + private float L() { + Arrows arrows1 = this; + long lx = System.nanoTime(); + float f = arrows1.D == 0L ? 16.0F : Math.min((float)(lx - arrows1.D) / 1000000.0F, 100.0F); + arrows1.D = lx; + return f; + } + + private static int L(int i, int j, float f) { + int k = Math.round(ColorUtils.alpha(i) + (ColorUtils.alpha(jx) - ColorUtils.alpha(i)) * f); + int lx = Math.round(ColorUtils.red(i) + (ColorUtils.red(jx) - ColorUtils.red(i)) * f); + int mx = Math.round(ColorUtils.green(i) + (ColorUtils.green(jx) - ColorUtils.green(i)) * f); + jx = Math.round(ColorUtils.blue(i) + (ColorUtils.blue(jx) - ColorUtils.blue(i)) * f); + return ColorUtils.argb(k, lx, mx, jx); + } + + private void L(float f, int i, int j) { + this.render2D.L(this.L(), -f / 2.0F + f / 18.0F, -f / 2.0F, f, f, i, L(i, jx, 0.33333334F), L(i, jx, 0.6666667F), jx); + } + + private void L(float f, float g, float h, float i, float j, float k) { + int lx = ColorUtils.withAlpha(this.color.getValue(), ColorUtils.alpha(this.color.getValue()) / 255.0F * jx); + int mx = ColorUtils.withAlpha(this.secondColor.getValue(), ColorUtils.alpha(this.secondColor.getValue()) / 255.0F * jx); + this.render2D.pushMatrix(); + this.render2D.transforms().d(f, g); + this.render2D.transforms().L(h); + if (k > 0.0F) { + f = i * (1.0F + 0.5F * Math.min(k, 2.0F)); + g = 0.22F * Math.min(k, 1.5F); + this.L(f, ColorUtils.withAlpha(lx, ColorUtils.alpha(lx) / 255.0F * g), ColorUtils.withAlpha(mx, ColorUtils.alpha(mx) / 255.0F * g)); + } + + this.L(i, lx, mx); + this.render2D.popMatrix(); + } + + public void L(float f) { + Arrows arrows1 = this; + if (arrows1.isEnabled() && mc.theWorld != null && mc.thePlayer != null) { + if (mc.gameSettings.thirdPersonView == 0) { + ScaledResolution scaledResolution = new ScaledResolution(mc); + float s = scaledResolution.getScaledWidth(); + float lx = scaledResolution.getScaledHeight(); + float g = arrows1.distance.getFloat() + (mc.currentScreen instanceof GuiInventory ? 100.0F : 0.0F); + arrows1.m = arrows1.m + (g - arrows1.m) * (float)(1.0 - Math.exp(-arrows1.L() / 90.0)); + double d; + double ex; + float v; + if (WorldToScreen.L()) { + Vec3 vec3 = WorldToScreen.getVec3(); + Vec3 vec31; + Vec3 vec32 = vec31 = WorldToScreen.getVec32(); + d = vec3.xCoord; + ex = vec3.zCoord; + v = g = (float)Math.toDegrees(Math.atan2(-vec32.xCoord, vec31.zCoord)); + } else { + d = mc.thePlayer.lastTickPosX + (mc.thePlayer.posX - mc.thePlayer.lastTickPosX) * f; + ex = mc.thePlayer.lastTickPosZ + (mc.thePlayer.posZ - mc.thePlayer.lastTickPosZ) * f; + v = g = mc.thePlayer.prevRotationYaw + (mc.thePlayer.rotationYaw - mc.thePlayer.prevRotationYaw) * f; + } + + double r = Math.cos(Math.toRadians(v)); + double h = Math.sin(Math.toRadians(g)); + float t = s / 2.0F; + lx /= 2.0F; + g = arrows1.opacity.getFloat() / 100.0F; + float i = arrows1.glow.getFloat() / 100.0F; + float jx = arrows1.size.getFloat(); + double k = arrows1.range.getValue(); + ArrayList arrayList = new ArrayList<>(mc.theWorld.playerEntities); + arrows1.render2D.beginFrame(); + Iterator iterator = arrayList.iterator(); + + label47: + while (true) { + Iterator iterator1 = iterator; + + while (iterator1.hasNext()) { + EntityPlayer entityPlayer; + if ((entityPlayer = (EntityPlayer)iterator.next()) == null) { + continue label47; + } + + if (entityPlayer == mc.thePlayer) { + iterator1 = iterator; + } else { + if (!entityPlayer.isEntityAlive()) { + continue label47; + } + + if (entityPlayer.isInvisible()) { + iterator1 = iterator; + } else if (mc.thePlayer.getDistanceToEntity(entityPlayer) > k) { + iterator1 = iterator; + } else { + double mx = entityPlayer.lastTickPosX + (entityPlayer.posX - entityPlayer.lastTickPosX) * f - d; + double o; + double p = -((o = entityPlayer.lastTickPosZ + (entityPlayer.posZ - entityPlayer.lastTickPosZ) * f - ex) * r - mx * h); + mx = -(mx * r + o * h); + float q = (float)Math.atan2(p, mx); + iterator1 = iterator; + float u = (float)(arrows1.m * Math.cos(q)) + t; + float n = (float)(arrows1.m * Math.sin(q)) + lx; + arrows1.L(u, n, q, jx, g, i); + } + } + } + + arrows1.render2D.clearScissors(); + return; + } + } + } + } + + public Arrows() { + super("Arrows", "Points at the players around you", ModuleCategory.RENDER); + this.distance = new NumberSetting("Distance", 60.0, 20.0, 150.0, 1.0).withSuffix(" px").describe("How far the pointers sit from the cursor"); + this.size = new NumberSetting("Size", 18.0, 8.0, 40.0, 1.0).withSuffix(" px").describe("How large each pointer is"); + this.color = new ColorSetting("Color", -8857601).D().describe("Colour the pointer starts from"); + this.secondColor = new ColorSetting("Second color", -4879105).D().L(60.0).describe("Colour the pointer runs into"); + this.opacity = new NumberSetting("Opacity", 49.0, 5.0, 100.0, 1.0).withSuffix("%").describe("How solid the pointers are"); + this.glow = new NumberSetting("Glow", 100.0, 0.0, 250.0, 5.0).withSuffix("%").describe("How much light the pointers throw"); + this.range = new NumberSetting("Range", 128.0, 8.0, 256.0, 8.0).withSuffix(" m").describe("Farthest a player can be and still get a pointer"); + this.render2D = new Render2D().withoutCursor(); + } + + @Override + protected void onDisable() { + this.m = 0.0F; + this.D = 0L; + } + + private ResourceLocation L() { + switch ((DesignMode)this.design.getValue()) { + case OUTLINE: + while (false) { + } + + return RESOURCE_LOCATION; + case SOLID: + return RESOURCE_LOCATION2; + default: + return RESOURCE_LOCATION3; + } + } +} diff --git a/src/openonyx/features/render/BedESP.java b/src/openonyx/features/render/BedESP.java new file mode 100644 index 0000000..ceee22d --- /dev/null +++ b/src/openonyx/features/render/BedESP.java @@ -0,0 +1,577 @@ +package openonyx.features.render; + +import java.util.ArrayDeque; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import meteordevelopment.orbit.EventHandler; +import net.minecraft.block.Block; +import net.minecraft.block.BlockBed; +import net.minecraft.block.material.MapColor; +import net.minecraft.block.material.Material; +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.multiplayer.ChunkProviderClient; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.BlockPos; +import net.minecraft.util.EnumFacing; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.IChunkProvider; +import net.minecraft.world.chunk.storage.ExtendedBlockStorage; +import openonyx.configuration.internal.WorldChangeEvent; +import openonyx.features.Module; +import openonyx.features.ModuleCategory; +import openonyx.features.combat.BedTracker; +import openonyx.history.internal.BooleanSetting; +import openonyx.history.internal.ColorSetting; +import openonyx.history.internal.NumberSetting; +import openonyx.interaction.BlockUtils; +import openonyx.render.BedBoxRenderer; +import openonyx.render.BoxRenderer; +import openonyx.render.Render2D; +import openonyx.theme.internal.ColorUtils; +import openonyx.utilities.Timer; + +public final class BedESP extends Module { + private static final double r = 0.5625; + public final BooleanSetting ownBedBeam; + public final NumberSetting defenseRadius; + public final BooleanSetting enemyBeds; + public final BooleanSetting ownBed = new BooleanSetting("Own bed", true).describe("Highlight the bed the tracker believes is yours"); + public final NumberSetting refresh; + public final NumberSetting tagFalloff; + private boolean b; + public final BooleanSetting fill; + public final NumberSetting beamOpacity; + public final ColorSetting enemyColor; + public final BooleanSetting beam; + public final BooleanSetting tagBlur; + private final List blockPosList; + private static final double C = 0.003; + public final BooleanSetting defenseTags; + private final BedESPOverlay bedESPOverlay; + public final NumberSetting lineWidth; + public final NumberSetting beamHeight; + public final NumberSetting tagScale; + public final ColorSetting ownColor; + public final BooleanSetting beamColor; + private static final int L = 8; + private final List bedESPData2s; + public final BooleanSetting throughWalls; + public final NumberSetting defenseOpacity; + public final BooleanSetting ownBeamColor; + public final BooleanSetting defense; + public final ColorSetting beamTint; + public final ColorSetting ownBeamTint; + public final NumberSetting beamWidth; + private final List bedESPData3s; + private final Timer timer; + + @Override + protected void onEnable() { + this.F(); + } + + private static List L(Map map, Map map1) { + Map map2 = map; + ArrayList arrayList = new ArrayList(); + + Iterator iterator; + for (Iterator iterator1 = iterator = map2.entrySet().iterator(); iterator1.hasNext(); iterator1 = iterator) { + Entry entry = (Entry)iterator.next(); + IBlockState iBlockState; + Block block = (iBlockState = (IBlockState)map1.get(entry.getKey())).getBlock(); + arrayList.add(new BedESPData(new ItemStack(block, 1, block.damageDropped(iBlockState)), block.getLocalizedName(), ((int[])entry.getValue())[0])); + } + + arrayList.sort(Comparator.comparingInt(BedESPData::count).reversed()); + return arrayList; + } + + public void d(float f) { + BedESP bedESP1 = this; + if (bedESP1.isEnabled() && mc.theWorld != null && mc.thePlayer != null) { + if (!bedESP1.b || bedESP1.timer.hasReached(bedESP1.refresh.getInt())) { + bedESP1.l(); + bedESP1.timer.reset(); + bedESP1.b = true; + } + + if (!bedESP1.blockPosList.isEmpty()) { + boolean bl = false; + float g = bedESP1.defenseOpacity.getFloat() / 100.0F; + Iterator iterator; + Iterator iterator2 = iterator = (bedESP1.defense.isEnabled() ? bedESP1.bedESPData2s : List.of()).iterator(); + + while (iterator2.hasNext()) { + BedESPData2 bedESPData2 = (BedESPData2)iterator.next(); + AxisAlignedBB axisAlignedBB; + if ((axisAlignedBB = bedESP1.d(bedESPData2.pos())) == null) { + iterator2 = iterator; + } else { + if (!bl) { + if (!BoxRenderer.L(f, bedESP1.throughWalls.isEnabled())) { + return; + } + + bl = true; + } + + BoxRenderer.L( + axisAlignedBB, + ColorUtils.withAlpha(bedESPData2.color(), g), + bedESP1.lineWidth.getFloat(), + bedESP1.fill.isEnabled() ? ColorUtils.withAlpha(bedESPData2.color(), g * 0.18F) : 0 + ); + iterator2 = iterator; + } + } + + Iterator iterator1; + iterator2 = iterator1 = bedESP1.blockPosList.iterator(); + + while (iterator2.hasNext()) { + BlockPos blockPos = (BlockPos)iterator1.next(); + boolean bl1; + if ((bl1 = BedTracker.INSTANCE.L(blockPos)) && !bedESP1.ownBed.isEnabled()) { + iterator2 = iterator1; + } else if (!bl1 && !bedESP1.enemyBeds.isEnabled()) { + iterator2 = iterator1; + } else { + AxisAlignedBB axisAlignedBB1; + if ((axisAlignedBB1 = bedESP1.L(blockPos)) == null) { + iterator2 = iterator1; + } else { + if (!bl) { + if (!BoxRenderer.L(f, bedESP1.throughWalls.isEnabled())) { + return; + } + + bl = true; + } + + int i = bl1 ? bedESP1.ownColor.getValue() : bedESP1.enemyColor.getValue(); + BoxRenderer.L( + axisAlignedBB1, + ColorUtils.withAlpha(i, ColorUtils.alpha(i) / 255.0F * 0.95F), + bedESP1.lineWidth.getFloat(), + bedESP1.fill.isEnabled() ? ColorUtils.withAlpha(i, ColorUtils.alpha(i) / 255.0F * 0.16F) : 0 + ); + iterator2 = iterator1; + } + } + } + + if (bl) { + BoxRenderer.L(); + } + + bedESP1.L(f); + } + } + } + + private void F() { + this.blockPosList.clear(); + this.bedESPData2s.clear(); + this.bedESPData3s.clear(); + this.b = false; + } + + private static boolean L(BlockPos blockPos) { + BlockPos blockPos1 = blockPos; + EnumFacing[] enumFacings; + int i = (enumFacings = EnumFacing.values()).length; + + for (int k = j = 0; k < i; k = ++j) { + EnumFacing enumFacing = enumFacings[j]; + if (BlockUtils.d(blockPos1.offset(enumFacing))) { + return true; + } + } + + return false; + } + + private void l() { + BedESP bedESP1 = this; + bedESP1.blockPosList.clear(); + IChunkProvider iChunkProvider; + if ((iChunkProvider = mc.theWorld.getChunkProvider()) instanceof ChunkProviderClient) { + ChunkProviderClient chunkProviderClient = (ChunkProviderClient)iChunkProvider; + int o = Block.getIdFromBlock(Blocks.bed); + Iterator iterator = chunkProviderClient.getLoadedChunks().iterator(); + + label60: + while (true) { + for (Iterator iterator1 = iterator; iterator1.hasNext(); iterator1 = iterator) { + Chunk chunk; + if ((chunk = (Chunk)iterator.next()) == null) { + continue label60; + } + + if (!chunk.isEmpty()) { + int n = chunk.xPosition << 4; + int j = chunk.zPosition << 4; + ExtendedBlockStorage[] extendedBlockStorages; + int k = (extendedBlockStorages = chunk.getBlockStorageArray()).length; + + int l; + for (int p = l = 0; p < k; p = ++l) { + ExtendedBlockStorage extendedBlockStorage; + if ((extendedBlockStorage = extendedBlockStorages[l]) != null && !extendedBlockStorage.isEmpty()) { + char[] d = extendedBlockStorage.getData(); + int m = extendedBlockStorage.getYLocation(); + + int i; + for (int q = i = 0; q < d.length; q = ++i) { + char c; + if ((c = d[i]) >> 4 == o && (c & '\b') != 0) { + bedESP1.blockPosList.add(new BlockPos(n + (i & 15), m + (i >> 8 & 15), j + (i >> 4 & 15))); + } + } + } + } + continue label60; + } + } + + bedESP1.h(); + return; + } + } + } + + private AxisAlignedBB d(BlockPos blockPos) { + return BlockUtils.d(blockPos) ? null : BlockUtils.L(blockPos).offset(blockPos.getX(), blockPos.getY(), blockPos.getZ()).expand(0.003, 0.003, 0.003); + } + + private void h() { + BedESP bedESP1 = this; + bedESP1.bedESPData2s.clear(); + bedESP1.bedESPData3s.clear(); + if (bedESP1.defense.isEnabled() || bedESP1.defenseTags.isEnabled()) { + int i = bedESP1.defenseRadius.getInt(); + HashSet hashSet1 = new HashSet(); + Iterator iterator = bedESP1.blockPosList.iterator(); + + label121: + while (true) { + Iterator iterator1 = iterator; + + while (iterator1.hasNext()) { + BlockPos blockPos = (BlockPos)iterator.next(); + boolean bl; + if ((bl = BedTracker.INSTANCE.L(blockPos)) && !bedESP1.ownBed.isEnabled()) { + iterator1 = iterator; + } else if (!bl && !bedESP1.enemyBeds.isEnabled()) { + iterator1 = iterator; + } else { + IBlockState iBlockState; + if ((iBlockState = mc.theWorld.getBlockState(blockPos)).getBlock() instanceof BlockBed) { + BlockPos blockPos3 = blockPos.offset(iBlockState.getValue(BlockBed.FACING).getOpposite()); + int j = Math.min(blockPos.getX(), blockPos3.getX()) - i; + int k = Math.max(blockPos.getX(), blockPos3.getX()) + i; + int l = Math.min(blockPos.getZ(), blockPos3.getZ()) - i; + int m = Math.max(blockPos.getZ(), blockPos3.getZ()) + i; + int n = blockPos.getY(); + int o = Math.min(255, blockPos.getY() + i); + LinkedHashMap linkedHashMap = new LinkedHashMap(); + LinkedHashMap linkedHashMap1 = new LinkedHashMap(); + int p = 0; + HashSet hashSet = new HashSet(); + ArrayDeque arrayDeque = new ArrayDeque(); + + for (BlockPos blockPos1 : List.of(blockPos, blockPos3)) { + hashSet.add(blockPos1); + EnumFacing[] enumFacings = EnumFacing.values(); + int q = enumFacings.length; + + int rx; + for (int v = rx = 0; v < q; v = ++rx) { + EnumFacing enumFacing = enumFacings[rx]; + BlockPos blockPos2; + if ((blockPos2 = blockPos1.offset(enumFacing)).getY() >= n) { + arrayDeque.add(blockPos2); + } + } + } + + label118: + while (true) { + ArrayDeque arrayDeque1 = arrayDeque; + + while (!arrayDeque1.isEmpty()) { + BlockPos blockPos4; + if ((blockPos4 = (BlockPos)arrayDeque.poll()).getY() < n) { + continue label118; + } + + if (blockPos4.getY() > o) { + arrayDeque1 = arrayDeque; + } else { + if (blockPos4.getX() < j) { + continue label118; + } + + if (blockPos4.getX() > k) { + arrayDeque1 = arrayDeque; + } else { + if (blockPos4.getZ() < l) { + continue label118; + } + + if (blockPos4.getZ() > m) { + arrayDeque1 = arrayDeque; + } else if (!hashSet.add(blockPos4)) { + arrayDeque1 = arrayDeque; + } else { + Block block; + IBlockState iBlockState1; + if ((block = (iBlockState1 = mc.theWorld.getBlockState(blockPos4)).getBlock()).getMaterial() == Material.air) { + arrayDeque1 = arrayDeque; + } else if (!block.getMaterial().isSolid()) { + arrayDeque1 = arrayDeque; + } else { + if (!(block instanceof BlockBed)) { + int s = Block.getIdFromBlock(block) << 4 | block.damageDropped(iBlockState1) & 15; + linkedHashMap.computeIfAbsent(s, integer -> { + int[] x = new int[1]; + boolean bl1 = true; + return x; + })[0]++; + p++; + linkedHashMap1.putIfAbsent(s, iBlockState1); + if (L(blockPos4) && hashSet1.add(blockPos4)) { + bedESP1.bedESPData2s.add(new BedESPData2(blockPos4, L(iBlockState1))); + } + + EnumFacing[] enumFacings1; + int t = (enumFacings1 = EnumFacing.values()).length; + + int u; + for (int w = u = 0; w < t; w = u) { + EnumFacing enumFacing1 = enumFacings1[u]; + u++; + arrayDeque.add(blockPos4.offset(enumFacing1)); + } + continue label118; + } + + arrayDeque1 = arrayDeque; + } + } + } + } + } + + if (bedESP1.defenseTags.isEnabled() && p > 0) { + bedESP1.bedESPData3s.add(new BedESPData3(blockPos, bl, L(linkedHashMap, linkedHashMap1), p)); + } + continue label121; + } + } + + iterator1 = iterator; + } + } + + return; + } + } + } + + public List getBedESPData3s() { + return this.bedESPData3s; + } + + public BedESP() { + super("BedESP", "Highlights beds through walls", ModuleCategory.RENDER); + this.enemyBeds = new BooleanSetting("Enemy beds", true).describe("Highlight every other bed"); + this.ownColor = new ColorSetting("Own color", -9706613).describe("Colour of your own bed").visibleWhen(this.ownBed); + this.enemyColor = new ColorSetting("Enemy color", -38302).describe("Colour of enemy beds").visibleWhen(this.enemyBeds); + this.defense = new BooleanSetting("Defense", false) + .describe("Outline the blocks walling each bed in, coloured by what they are made of") + .onChange(boolean_ -> this.F()); + this.defenseRadius = new NumberSetting("Defense radius", 3.0, 1.0, 6.0, 1.0) + .withSuffix(" m") + .describe("How far around a bed counts as its defense") + .visibleWhen(() -> this.defense.isEnabled() || this.defenseTags.isEnabled()) + .onChange(double_ -> this.F()); + this.defenseOpacity = new NumberSetting("Defense opacity", 70.0, 10.0, 100.0, 5.0) + .withSuffix("%") + .describe("How strongly the defense outlines are drawn") + .visibleWhen(this.defense); + this.defenseTags = new BooleanSetting("Defense tags", false) + .describe("Float the blocks making up each bed's defense above the bed itself") + .onChange(boolean_ -> this.F()); + this.tagScale = new NumberSetting("Tag scale", 1.0, 0.5, 2.0, 0.05) + .withSuffix("x") + .describe("Defense tag size - it still shrinks with distance") + .visibleWhen(this.defenseTags); + this.tagFalloff = new NumberSetting("Tag falloff", 1.0, 0.0, 2.0, 0.05) + .withSuffix("x") + .describe("How hard a tag shrinks as its bed gets further away - 0 keeps every tag the same size however far off it is") + .visibleWhen(this.defenseTags); + this.tagBlur = new BooleanSetting("Tag blur", true) + .describe("Frost the world behind each defense tag instead of tinting it flat") + .visibleWhen(this.defenseTags); + this.beam = new BooleanSetting("Beam", false).describe("Stand a light beam over every highlighted bed"); + this.beamHeight = new NumberSetting("Beam height", 24.0, 4.0, 128.0, 4.0) + .withSuffix(" m") + .describe("How far the beam reaches above the bed") + .visibleWhen(this.beam); + this.beamWidth = new NumberSetting("Beam width", 0.5, 0.1, 2.0, 0.1).withSuffix(" m").describe("How wide the beam column is").visibleWhen(this.beam); + this.beamOpacity = new NumberSetting("Beam opacity", 55.0, 10.0, 100.0, 5.0) + .withSuffix("%") + .describe("How strongly the beam is drawn at its base") + .visibleWhen(this.beam); + this.beamColor = new BooleanSetting("Beam color", false) + .describe("Draw every beam in one colour of its own instead of the bed's own/enemy colour") + .visibleWhen(this.beam); + this.beamTint = new ColorSetting("Beam tint", -8399617).describe("The colour every beam is drawn in").visibleWhen(this.beamColor); + this.ownBedBeam = new BooleanSetting("Own bed beam", true) + .describe("Stand a beam over your own bed too - off leaves the column to enemy beds, which is one less thing lit up in the middle of your own base") + .visibleWhen(this.beam); + this.ownBeamColor = new BooleanSetting("Own beam color", false) + .describe("Give your own bed's beam a colour of its own instead of the one the rest of the beams use") + .visibleWhen(() -> this.beam.isEnabled() && this.ownBedBeam.isEnabled()); + this.ownBeamTint = new ColorSetting("Own beam tint", -9706613) + .describe("The colour your own bed's beam is drawn in") + .visibleWhen(() -> this.beam.isEnabled() && this.ownBedBeam.isEnabled() && this.ownBeamColor.isEnabled()); + this.fill = new BooleanSetting("Fill", true); + this.throughWalls = new BooleanSetting("Through walls", true); + this.lineWidth = new NumberSetting("Line width", 1.5, 0.5, 5.0, 0.5).withSuffix(" px"); + this.refresh = new NumberSetting("Refresh", 500.0, 100.0, 2000.0, 50.0).withSuffix("ms").describe("How often the world is rescanned for beds"); + this.timer = new Timer(); + this.blockPosList = new ArrayList<>(); + this.bedESPData2s = new ArrayList<>(); + this.bedESPData3s = new ArrayList<>(); + this.bedESPOverlay = new BedESPOverlay(this); + } + + private void L(float f) { + BedESP bedESP1 = this; + if (bedESP1.beam.isEnabled()) { + boolean bl = false; + float g = bedESP1.beamOpacity.getFloat() / 100.0F; + double d = bedESP1.beamWidth.getValue(); + double e = bedESP1.beamHeight.getValue(); + Iterator iterator = bedESP1.blockPosList.iterator(); + + label49: + while (true) { + Iterator iterator1 = iterator; + + while (iterator1.hasNext()) { + BlockPos blockPos = (BlockPos)iterator.next(); + boolean bl1; + if (bl1 = BedTracker.INSTANCE.L(blockPos)) { + if (!bedESP1.ownBed.isEnabled()) { + continue label49; + } + + if (!bedESP1.ownBedBeam.isEnabled()) { + iterator1 = iterator; + continue; + } + } + + if (!bl1 && !bedESP1.enemyBeds.isEnabled()) { + iterator1 = iterator; + } else { + AxisAlignedBB axisAlignedBB; + if ((axisAlignedBB = bedESP1.L(blockPos)) == null) { + iterator1 = iterator; + } else { + if (!bl) { + if (!BedBoxRenderer.L(f, bedESP1.throughWalls.isEnabled())) { + return; + } + + bl = true; + } + + int l; + float h = ColorUtils.alpha(l = bedESP1.L(bl1)) / 255.0F * g; + iterator1 = iterator; + double i = blockPos.getY() + 0.5625; + double j = (axisAlignedBB.minX + axisAlignedBB.maxX) / 2.0; + double k = (axisAlignedBB.minZ + axisAlignedBB.maxZ) / 2.0; + BedBoxRenderer.L(j, k, i, i + e, d, ColorUtils.withAlpha(l, h * 0.55F), ColorUtils.withAlpha(l, 0.0F)); + BedBoxRenderer.L(j, k, i, i + e, d * 0.35, ColorUtils.withAlpha(l, h), ColorUtils.withAlpha(l, 0.0F)); + } + } + } + + if (bl) { + BedBoxRenderer.L(); + } + + return; + } + } + } + + @EventHandler + private void onWorldChange(WorldChangeEvent worldChangeEvent) { + this.F(); + } + + private static int L(IBlockState iBlockState) { + IBlockState iBlockState1 = iBlockState; + Block block; + if ((block = iBlockState1.getBlock()) == Blocks.obsidian) { + return -15003098; + } + + if (block == Blocks.glass) { + return -4199947; + } + + MapColor mapColor; + int i = (mapColor = block.getMapColor(iBlockState1)) == null ? 0 : mapColor.colorValue; + return i == 0 ? -5197648 : 0xFF000000 | i; + } + + public boolean h() { + return this.bedESPOverlay.L(); + } + + @Override + protected void onDisable() { + this.F(); + } + + public void L(Render2D render2D, float f, float g) { + this.bedESPOverlay.L(render2D, f, g); + } + + private int L(boolean bl) { + if (bl && this.ownBeamColor.isEnabled()) { + return this.ownBeamTint.getValue(); + } else { + return this.beamColor.isEnabled() ? this.beamTint.getValue() : bl ? this.ownColor.getValue() : this.enemyColor.getValue(); + } + } + + private AxisAlignedBB L(BlockPos blockPos) { + IBlockState iBlockState; + if (!((iBlockState = mc.theWorld.getBlockState(blockPos)).getBlock() instanceof BlockBed)) { + return null; + } + + BlockPos blockPos1 = blockPos.offset(iBlockState.getValue(BlockBed.FACING).getOpposite()); + double d = Math.min(blockPos.getX(), blockPos1.getX()) - 0.003; + double e = Math.min(blockPos.getZ(), blockPos1.getZ()) - 0.003; + double f = Math.max(blockPos.getX(), blockPos1.getX()) + 1 + 0.003; + double g = Math.max(blockPos.getZ(), blockPos1.getZ()) + 1 + 0.003; + return AxisAlignedBB.fromBounds(d, blockPos.getY() - 0.003, e, f, blockPos.getY() + 0.5625 + 0.003, g); + } +} diff --git a/src/openonyx/features/render/BedESPData.java b/src/openonyx/features/render/BedESPData.java new file mode 100644 index 0000000..18a9f07 --- /dev/null +++ b/src/openonyx/features/render/BedESPData.java @@ -0,0 +1,6 @@ +package openonyx.features.render; + +import net.minecraft.item.ItemStack; + +public record BedESPData(ItemStack icon, String name, int count) { +}