Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds more options for building #579

Open
wants to merge 2 commits into
base: activity_system
Choose a base branch
from
Open
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 @@ -60,6 +60,8 @@ class BreakBlock(
override var rotation: Vec2f? = null,
override var distance: Double = 1337.0,
override var exposedSides: Int = 0,
private var handleLiquids: Boolean = true,
private var allowBreakBeneathPlayer: Boolean = false,
) : BuildActivity, TimeoutActivity, AttemptActivity, RotatingActivity, TimedActivity, RenderAABBActivity, RenderOverlayTextActivity, Activity() {
private var side: EnumFacing? = null
private var ticksNeeded = 0
Expand Down Expand Up @@ -213,7 +215,8 @@ class BreakBlock(
val hitVec = getHitVec(blockPos, miningSide)

/* prevent breaking the block the player is standing on */
if (player.flooredPosition.down() == blockPos
if (allowBreakBeneathPlayer
&& player.flooredPosition.down() == blockPos
&& !world.getBlockState(blockPos.down()).isSideSolid(world, blockPos.down(), EnumFacing.UP)
) {
availability = BuildActivity.Availability.BLOCKED_BY_PLAYER
Expand Down Expand Up @@ -363,6 +366,7 @@ class BreakBlock(
}

private fun SafeClientEvent.checkLiquids(): Boolean {
if (!handleLiquids) return false
var foundLiquid = false

if (world.getBlockState(blockPos).isLiquid) {
Expand All @@ -376,7 +380,7 @@ class BreakBlock(
return true
}

EnumFacing.entries
EnumFacing.values()
.filter { it != EnumFacing.DOWN }
.map { blockPos.offset(it) }
.filter { world.getBlockState(it).isLiquid }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ class BuildStructure(
private val allowBreakDescend: Boolean = false,
override val maximumRepeats: Int = 1,
override var repeated: Int = 0,
override val aabbCompounds: MutableSet<RenderAABBActivity.Companion.RenderAABBCompound> = mutableSetOf()
override val aabbCompounds: MutableSet<RenderAABBActivity.Companion.RenderAABBCompound> = mutableSetOf(),
private var handleLiquids: Boolean = true,
private var allowBreakBeneathPlayer: Boolean = false,
) : RepeatingActivity, RenderAABBActivity, Activity() {
private var currentOffset = BlockPos.ORIGIN
private var currentGoal: Goal? by Delegates.observable(null) { _, old, new ->
Expand Down Expand Up @@ -232,7 +234,9 @@ class BuildStructure(
/* the only option left is breaking the block */
addSubActivities(BreakBlock(
// blockPos, collectDrops = collectAll, minCollectAmount = 64
blockPos
blockPos,
handleLiquids = handleLiquids,
allowBreakBeneathPlayer = allowBreakBeneathPlayer,
), subscribe = true)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class AcquireItemInActiveHand(
}

// If the item is obsidian, break down ender chests
if (itemInfo.item == Blocks.OBSIDIAN.item) {
if (BuildTools.breakDownEnderChests && itemInfo.item == Blocks.OBSIDIAN.item) {
addSubActivities(BreakDownEnderChests(maximumRepeats = BuildTools.breakDownCycles))
return
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.lambda.client.manager.managers

import com.lambda.client.activity.Activity
import com.lambda.client.activity.activities.storage.*
import com.lambda.client.activity.activities.storage.ShulkerTransaction
import com.lambda.client.activity.activities.storage.StashTransaction
import com.lambda.client.activity.activities.storage.types.*
import com.lambda.client.activity.getShulkerInventory
import com.lambda.client.activity.types.RenderAABBActivity
Expand Down Expand Up @@ -30,18 +31,18 @@ import com.lambda.client.util.graphics.ESPRenderer
import com.lambda.client.util.graphics.GlStateUtils
import com.lambda.client.util.graphics.ProjectionUtils
import com.lambda.client.util.graphics.font.FontRenderAdapter
import com.lambda.client.util.items.*
import com.lambda.client.util.items.allSlots
import com.lambda.client.util.items.countEmpty
import com.lambda.client.util.items.countItem
import com.lambda.client.util.items.inventorySlots
import com.lambda.client.util.math.CoordinateConverter.asString
import com.lambda.client.util.math.VectorUtils.distanceTo
import com.lambda.client.util.text.MessageSendHelper
import com.lambda.client.util.threads.safeListener
import net.minecraft.init.Blocks
import net.minecraft.init.Items
import net.minecraft.item.Item
import net.minecraftforge.fml.common.gameevent.TickEvent
import org.lwjgl.opengl.GL11
import scala.tools.nsc.backend.icode.analysis.TypeFlowAnalysis.MethodTFA.Gen
import java.util.*

object ActivityManager : Manager, Activity() {
private val renderer = ESPRenderer()
Expand Down Expand Up @@ -111,26 +112,28 @@ object ActivityManager : Manager, Activity() {
listener<RenderOverlayEvent> {
if (hasNoSubActivities) return@listener

GlStateUtils.rescaleActual()
if (BuildTools.showDebugText) {
GlStateUtils.rescaleActual()

RenderOverlayTextActivity.normalizedRender.forEach { renderText ->
GL11.glPushMatrix()
val screenPos = ProjectionUtils.toScreenPos(renderText.origin)
GL11.glTranslated(screenPos.x, screenPos.y, 0.0)
GL11.glScalef(textScale * 2.0f, textScale * 2.0f, 1.0f)
RenderOverlayTextActivity.normalizedRender.forEach { renderText ->
GL11.glPushMatrix()
val screenPos = ProjectionUtils.toScreenPos(renderText.origin)
GL11.glTranslated(screenPos.x, screenPos.y, 0.0)
GL11.glScalef(textScale * 2.0f, textScale * 2.0f, 1.0f)

val halfWidth = FontRenderAdapter.getStringWidth(renderText.text) / -2.0f
val lineHeight = FontRenderAdapter.getFontHeight() + 2.0f
val yLift = lineHeight * 3 / 2
val halfWidth = FontRenderAdapter.getStringWidth(renderText.text) / -2.0f
val lineHeight = FontRenderAdapter.getFontHeight() + 2.0f
val yLift = lineHeight * 3 / 2

FontRenderAdapter.drawString(
renderText.text,
halfWidth,
lineHeight * renderText.index - yLift,
color = renderText.color
)
FontRenderAdapter.drawString(
renderText.text,
halfWidth,
lineHeight * renderText.index - yLift,
color = renderText.color
)

GL11.glPopMatrix()
GL11.glPopMatrix()
}
}
GlStateUtils.rescaleMc()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ object BuildTools : Module(

/* placing */
val placeDelay by setting("Place Delay", 1, 0..20, 1, { page == Page.BUILDING }, description = "Sets the delay ticks between placement tasks", unit = " ticks")
val breakDownCycles by setting("Break Down", 64, 1..200, 1, { page == Page.BUILDING }, description = "", unit = " ender chests")
val breakDownEnderChests by setting("BreakDownEChests", false, {page == Page.BUILDING})
val breakDownCycles by setting("Break Down", 64, 1..200, 1, { page == Page.BUILDING && breakDownEnderChests }, description = "", unit = " ender chests")
val pickBlock by setting("Pick Block Creative", true, { page == Page.BUILDING }, description = "Use pick block to place blocks when in creative mode")
val placeStrictness by setting("Placement Strictness", PlacementStrictness.DIRECTION, { page == Page.BUILDING }, description = "ANY: Allow all exposed surfaces. DIRECTION: Only allow surfaces in the direction of the player. VISIBLE: Only allow surfaces that are visible to the player.")
// val illegalPlacements by setting("Illegal Placements", false, { page == Page.BUILDING }, description = "Do not use on 2b2t. Tries to interact with invisible surfaces")
Expand Down Expand Up @@ -93,7 +94,8 @@ object BuildTools : Module(
val showDebugRender by setting("Debug Render", false, { page == Page.RENDER }, description = "Render debug info on tasks")
val maxDebugRange by setting("Max Debug Range", 8, 0..256, 1, { page == Page.RENDER && showDebugRender }, description = "Max distance to render debug info", unit = " blocks")
val maxDebugAmount by setting("Max Debug Amount", 20, 0..256, 1, { page == Page.RENDER && showDebugRender }, description = "Max amount of debug info to render")
val textScale by setting("Text Scale", 1.0f, 0.0f..4.0f, 0.25f, { page == Page.RENDER && showDebugRender }, description = "Scale of debug text")
val showDebugText by setting ("Show Text", true, { page == Page.RENDER && showDebugRender }, description = "Render debug text")
val textScale by setting("Text Scale", 1.0f, 0.0f..4.0f, 0.25f, { page == Page.RENDER && showDebugText && showDebugRender }, description = "Scale of debug text")
// val distScaleFactor by setting("Distance Scale Factor", 0.05f, 0.0f..1.0f, 0.05f, { page == Page.RENDER && showDebugRender })
// val minDistScale by setting("Min Distance Scale", 0.35f, 0.0f..1.0f, 0.05f, { page == Page.RENDER && showDebugRender })
val aFilled by setting("Filled Alpha", 26, 0..255, 1, { filled && page == Page.RENDER }, description = "Sets the opacity")
Expand Down