mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-16 10:55:01 -04:00
rename raycastHit to target
This commit is contained in:
parent
7393705984
commit
02a87b9680
@ -123,9 +123,9 @@ class TargetHandler(
|
||||
}
|
||||
|
||||
if (entities) {
|
||||
val entityRaycastHit = raycastEntity(origin, direction) ?: return target
|
||||
val entityTarget = raycastEntity(origin, direction) ?: return target
|
||||
target ?: return null
|
||||
return (entityRaycastHit.distance < target.distance).decide(entityRaycastHit, target)
|
||||
return (entityTarget.distance < target.distance).decide(entityTarget, target)
|
||||
}
|
||||
|
||||
return target
|
||||
|
@ -98,20 +98,20 @@ class BreakInteractionHandler(
|
||||
cancelDigging()
|
||||
return false
|
||||
}
|
||||
val raycastHit = renderWindow.camera.targetHandler.target
|
||||
val target = renderWindow.camera.targetHandler.target
|
||||
|
||||
if (raycastHit !is BlockTarget) {
|
||||
if (target !is BlockTarget) {
|
||||
cancelDigging()
|
||||
return false
|
||||
}
|
||||
|
||||
if (raycastHit.distance >= connection.player.reachDistance) {
|
||||
if (target.distance >= connection.player.reachDistance) {
|
||||
cancelDigging()
|
||||
return false
|
||||
}
|
||||
|
||||
// check if we look at another block or our inventory changed
|
||||
if (breakPosition != raycastHit.blockPosition || breakBlockState != raycastHit.blockState || breakSelectedSlot != connection.player.selectedHotbarSlot) {
|
||||
if (breakPosition != target.blockPosition || breakBlockState != target.blockState || breakSelectedSlot != connection.player.selectedHotbarSlot) {
|
||||
cancelDigging()
|
||||
}
|
||||
|
||||
@ -120,22 +120,22 @@ class BreakInteractionHandler(
|
||||
if (breakPosition != null) {
|
||||
return
|
||||
}
|
||||
connection.sendPacket(PlayerActionC2SP(PlayerActionC2SP.Actions.START_DIGGING, raycastHit.blockPosition, raycastHit.direction))
|
||||
connection.sendPacket(PlayerActionC2SP(PlayerActionC2SP.Actions.START_DIGGING, target.blockPosition, target.direction))
|
||||
|
||||
breakPosition = raycastHit.blockPosition
|
||||
breakBlockState = raycastHit.blockState
|
||||
breakPosition = target.blockPosition
|
||||
breakBlockState = target.blockState
|
||||
breakProgress = 0.0
|
||||
|
||||
breakSelectedSlot = connection.player.selectedHotbarSlot
|
||||
}
|
||||
|
||||
fun finishDigging() {
|
||||
connection.sendPacket(PlayerActionC2SP(PlayerActionC2SP.Actions.FINISHED_DIGGING, raycastHit.blockPosition, raycastHit.direction))
|
||||
connection.sendPacket(PlayerActionC2SP(PlayerActionC2SP.Actions.FINISHED_DIGGING, target.blockPosition, target.direction))
|
||||
clearDigging()
|
||||
connection.world.setBlockState(raycastHit.blockPosition, null)
|
||||
connection.world.setBlockState(target.blockPosition, null)
|
||||
|
||||
raycastHit.blockState.breakSoundEvent?.let {
|
||||
connection.world.playSoundEvent(it, raycastHit.blockPosition, volume = raycastHit.blockState.soundEventVolume, pitch = raycastHit.blockState.soundEventPitch)
|
||||
target.blockState.breakSoundEvent?.let {
|
||||
connection.world.playSoundEvent(it, target.blockPosition, volume = target.blockState.soundEventVolume, pitch = target.blockState.soundEventPitch)
|
||||
}
|
||||
}
|
||||
|
||||
@ -176,14 +176,14 @@ class BreakInteractionHandler(
|
||||
|
||||
val isToolEffective = breakItemInHand?.item?.let {
|
||||
return@let if (it is MiningToolItem) {
|
||||
it.isEffectiveOn(connection, raycastHit.blockState)
|
||||
it.isEffectiveOn(connection, target.blockState)
|
||||
} else {
|
||||
false
|
||||
}
|
||||
} ?: false
|
||||
val isBestTool = !raycastHit.blockState.requiresTool || isToolEffective
|
||||
val isBestTool = !target.blockState.requiresTool || isToolEffective
|
||||
|
||||
var speedMultiplier = breakItemInHand?.let { it.item.getMiningSpeedMultiplier(connection, raycastHit.blockState, it) } ?: 1.0f
|
||||
var speedMultiplier = breakItemInHand?.let { it.item.getMiningSpeedMultiplier(connection, target.blockState, it) } ?: 1.0f
|
||||
|
||||
if (isToolEffective) {
|
||||
breakItemInHand?.enchantments?.get(efficiencyEnchantment)?.let {
|
||||
@ -212,7 +212,7 @@ class BreakInteractionHandler(
|
||||
speedMultiplier /= 5.0f
|
||||
}
|
||||
|
||||
var damage = speedMultiplier / raycastHit.blockState.hardness
|
||||
var damage = speedMultiplier / target.blockState.hardness
|
||||
|
||||
damage /= if (isBestTool) {
|
||||
30
|
||||
|
@ -82,28 +82,28 @@ class BlockOutlineRenderer(
|
||||
}
|
||||
|
||||
override fun prepareDraw() {
|
||||
val raycastHit = renderWindow.camera.targetHandler.target.nullCast<BlockTarget>()
|
||||
val target = renderWindow.camera.targetHandler.target.nullCast<BlockTarget>()
|
||||
|
||||
var currentMesh = currentMesh
|
||||
|
||||
if (raycastHit == null) {
|
||||
if (target == null) {
|
||||
unload()
|
||||
return
|
||||
}
|
||||
|
||||
if (raycastHit.distance >= connection.player.reachDistance) {
|
||||
if (target.distance >= connection.player.reachDistance) {
|
||||
unload()
|
||||
return
|
||||
}
|
||||
|
||||
if (connection.player.gamemode == Gamemodes.ADVENTURE || connection.player.gamemode == Gamemodes.SPECTATOR) {
|
||||
if (raycastHit.blockState.block.blockEntityType == null) {
|
||||
if (target.blockState.block.blockEntityType == null) {
|
||||
unload()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if (raycastHit.blockPosition == currentOutlinePosition && raycastHit.blockState == currentOutlineBlockState && !reload) {
|
||||
if (target.blockPosition == currentOutlinePosition && target.blockState == currentOutlineBlockState && !reload) {
|
||||
return
|
||||
}
|
||||
|
||||
@ -114,20 +114,20 @@ class BlockOutlineRenderer(
|
||||
currentMesh?.unload()
|
||||
currentMesh = LineMesh(renderWindow)
|
||||
|
||||
val blockOffset = raycastHit.blockPosition.toVec3d + raycastHit.blockPosition.getWorldOffset(raycastHit.blockState.block)
|
||||
val blockOffset = target.blockPosition.toVec3d + target.blockPosition.getWorldOffset(target.blockState.block)
|
||||
|
||||
currentMesh.drawVoxelShape(raycastHit.blockState.outlineShape, blockOffset, RenderConstants.DEFAULT_LINE_WIDTH, profile.outlineColor)
|
||||
currentMesh.drawVoxelShape(target.blockState.outlineShape, blockOffset, RenderConstants.DEFAULT_LINE_WIDTH, profile.outlineColor)
|
||||
|
||||
|
||||
if (profile.showCollisionBoxes) {
|
||||
currentMesh.drawVoxelShape(raycastHit.blockState.collisionShape, blockOffset, RenderConstants.DEFAULT_LINE_WIDTH, profile.collisionColor, 0.005f)
|
||||
currentMesh.drawVoxelShape(target.blockState.collisionShape, blockOffset, RenderConstants.DEFAULT_LINE_WIDTH, profile.collisionColor, 0.005f)
|
||||
}
|
||||
|
||||
currentMesh.load()
|
||||
|
||||
|
||||
this.currentOutlinePosition = raycastHit.blockPosition
|
||||
this.currentOutlineBlockState = raycastHit.blockState
|
||||
this.currentOutlinePosition = target.blockPosition
|
||||
this.currentOutlineBlockState = target.blockState
|
||||
this.currentMesh = currentMesh
|
||||
this.reload = false
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user