Improve crystal aura (second try at git) - #326
Conversation
…itted as now or nothing. Offhand still does not work correctly.
…ode to ticked as async was being weird. Fixed hotbar logic.
| ::worldWidthSetting | ||
| ) | ||
| forEachSetting { | ||
| visibility { old -> { old() && render }} |
There was a problem hiding this comment.
we typically keep spaces between }} in scenarios like this. No biggie, just thought i'd say anyway
| @Tab(RENDERING_TAB) private val renderLineSettings by configBlock(WorldLineSettings(this)) | ||
| .withEdits { | ||
| hideAllExcept ( | ||
| ::worldWidthSetting |
There was a problem hiding this comment.
can inline this so its (::worldWidthSetting)
| immediateRenderer("CrystalAura Immediate Renderer") { | ||
| runSafe { | ||
| if (lastPlace != null) { | ||
| if (lastPlace!!.second + 100 < System.currentTimeMillis()) { |
There was a problem hiding this comment.
we never use !! as its an unsafe operator. Could be changed to use
val place = lastPlace ?: return@listen
then using the place value as we know its not null
| hand, BlockHitResult(opportunity.crystalPosition, opportunity.side, opportunity.blockPos, false), 0 | ||
| ) | ||
| } | ||
| runSafe { |
There was a problem hiding this comment.
we're already in a SafeContext so we shouldnt need runSafe here
| lastPlace = Pair(opportunity.blockPos, System.currentTimeMillis()) | ||
| } | ||
| interaction.syncSelectedSlot() // TODO: when server only hotbar swap gets implemented, this will be removed | ||
| mc.interactionManager!!.sendSequencedPacket(world, { sequence -> |
There was a problem hiding this comment.
can just use interaction.sendSequencedPacket due to the SafeContext
| PlayerInteractBlockC2SPacket( | ||
| hand, BlockHitResult(opportunity.crystalPosition, opportunity.side, opportunity.blockPos, false), sequence | ||
| ) | ||
| }); |
There was a problem hiding this comment.
no need for ; here and the lambda can be moved out of the parenthesis like how the settings do visibility
| val entitiesNearby = fastEntitySearch<Entity>(3.5, pos) | ||
| val crystals = entitiesNearby.filterIsInstance<EndCrystalEntity>() | ||
| val otherEntities = entitiesNearby - crystals + player | ||
| val otherEntities = entitiesNearby - crystals.toSet() + player |
There was a problem hiding this comment.
is this to make duplicate lookups faster?
|
|
||
| if (itemToUse == null || swapHand == Hand.MAIN_HAND) { | ||
| if (swapHand == Hand.MAIN_HAND) { | ||
| val itemStack = selection.bestItemMatch(player.hotbarStacks) |
There was a problem hiding this comment.
this works, but ive been migrating things to use the containers. This would instead use HotbarContainer to access the slots
| if (itemStack == null) { // retrieve to hotbar | ||
| if (!selection.transfer(swapTo)) return@runSafe | ||
| } | ||
| val s = player.hotbarStacks.indexOf(itemStack) |
There was a problem hiding this comment.
instead of indexOf here, you could use the container as said above, and then access the index through Slot::index
| placeTimer.runSafeIfPassed(placeDelay.milliseconds) { | ||
| placeInternal(this@Opportunity, swapHand) | ||
| if (placeTimer.timePassed(placeDelay.milliseconds) || (postPacketPlace && safeToPlaceInstantly && !placePostPause)) { | ||
| runSafe { |
There was a problem hiding this comment.
shouldnt be a need here for runSafe as we're already in a runSafe context from the start of the function
note: this has not been tested on 2b2t as i do not have priority queue, i have tested it on ccbluex's server
additions:
fixes:
improvements: