-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
140 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
progreso-client/src/main/kotlin/org/progreso/client/util/entity/Entity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.progreso.client.util.entity | ||
|
||
import net.minecraft.entity.Entity | ||
import net.minecraft.entity.player.PlayerEntity | ||
import org.progreso.api.managers.FriendManager | ||
import org.progreso.client.Client | ||
|
||
val Entity.canBeAttacked: Boolean | ||
get() { | ||
if (this == Client.mc.player) return false | ||
if (!isAlive) return false | ||
if (!isAttackable) return false | ||
return !(this is PlayerEntity && FriendManager.isFriend(name.string)) | ||
} |
16 changes: 0 additions & 16 deletions
16
progreso-client/src/main/kotlin/org/progreso/client/util/entity/EntityUtil.kt
This file was deleted.
Oops, something went wrong.
15 changes: 15 additions & 0 deletions
15
progreso-client/src/main/kotlin/org/progreso/client/util/player/Interaction.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.progreso.client.util.player | ||
|
||
import net.minecraft.client.network.ClientPlayerInteractionManager | ||
import net.minecraft.entity.LivingEntity | ||
import net.minecraft.util.Hand | ||
import org.progreso.client.Client.Companion.mc | ||
|
||
fun ClientPlayerInteractionManager.attack(entity: LivingEntity, checkStrength: Boolean = true) { | ||
if (checkStrength && mc.player.getAttackCooldownProgress(mc.tickDelta) != 1.0f) { | ||
return | ||
} | ||
|
||
attackEntity(mc.player, entity) | ||
mc.player.swingHand(Hand.MAIN_HAND) | ||
} |
55 changes: 55 additions & 0 deletions
55
progreso-client/src/main/kotlin/org/progreso/client/util/player/Inventory.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package org.progreso.client.util.player | ||
|
||
import net.minecraft.client.network.ClientPlayerInteractionManager | ||
import net.minecraft.entity.player.PlayerInventory | ||
import net.minecraft.item.ItemStack | ||
import net.minecraft.network.packet.c2s.play.UpdateSelectedSlotC2SPacket | ||
import net.minecraft.screen.slot.SlotActionType | ||
import org.progreso.client.Client.Companion.mc | ||
|
||
data class Slot(val index: Int, val stack: ItemStack) | ||
|
||
val PlayerInventory.hotbar get() = findItems(0, 9) { _, _ -> true } | ||
|
||
fun PlayerInventory.findItemInHotbar(predicate: (Int, ItemStack) -> Boolean): Slot? { | ||
return findItem(0, 9, predicate) | ||
} | ||
|
||
fun PlayerInventory.findItem( | ||
fromIndex: Int? = null, | ||
toIndex: Int? = null, | ||
predicate: (Int, ItemStack) -> Boolean | ||
): Slot? { | ||
return findItems(fromIndex, toIndex, predicate).firstOrNull() | ||
} | ||
|
||
fun PlayerInventory.findItems( | ||
fromIndex: Int? = null, | ||
toIndex: Int? = null, | ||
predicate: (Int, ItemStack) -> Boolean | ||
): List<Slot> { | ||
val result = mutableListOf<Slot>() | ||
|
||
for (i in (fromIndex ?: 0)..<(toIndex ?: size())) { | ||
val itemStack = getStack(i) | ||
|
||
if (predicate(i, itemStack)) { | ||
result.add(Slot(i, itemStack)) | ||
} | ||
} | ||
|
||
return result | ||
} | ||
|
||
fun PlayerInventory.updateSelectedSlot(index: Int) { | ||
mc.networkHandler.sendPacket(UpdateSelectedSlotC2SPacket(index)) | ||
selectedSlot = index | ||
} | ||
|
||
fun ClientPlayerInteractionManager.moveItem(fromIndex: Int, toIndex: Int) { | ||
val syncId = mc.player.currentScreenHandler?.syncId ?: 0 | ||
|
||
clickSlot(syncId, fromIndex, 0, SlotActionType.PICKUP, mc.player) | ||
clickSlot(syncId, toIndex, 0, SlotActionType.PICKUP, mc.player) | ||
clickSlot(syncId, fromIndex, 0, SlotActionType.PICKUP, mc.player) | ||
} |
55 changes: 0 additions & 55 deletions
55
progreso-client/src/main/kotlin/org/progreso/client/util/player/InventoryUtil.kt
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
progreso-client/src/main/kotlin/org/progreso/client/util/player/PlayerUtil.kt
This file was deleted.
Oops, something went wrong.
41 changes: 41 additions & 0 deletions
41
progreso-client/src/main/kotlin/org/progreso/client/util/world/World.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.progreso.client.util.world | ||
|
||
import net.minecraft.block.entity.BlockEntity | ||
import net.minecraft.util.math.ChunkPos | ||
import net.minecraft.world.World | ||
import net.minecraft.world.chunk.WorldChunk | ||
import org.progreso.client.Client | ||
import java.util.stream.Collectors | ||
import java.util.stream.Stream | ||
import kotlin.math.max | ||
|
||
val World.blockEntities: List<BlockEntity> | ||
get() { | ||
return loadedChunks | ||
.flatMap { it.blockEntities.values.stream() } | ||
.collect(Collectors.toList()) | ||
} | ||
|
||
val World.loadedChunks: Stream<WorldChunk> | ||
get() { | ||
val radius = max(2, Client.mc.options!!.clampedViewDistance) + 3 | ||
val diameter = radius * 2 + 1 | ||
val center = Client.mc.player.chunkPos | ||
val min = ChunkPos(center.x - radius, center.z - radius) | ||
val max = ChunkPos(center.x + radius, center.z + radius) | ||
|
||
return Stream.iterate(min) { | ||
var x = it.x | ||
var z = it.z | ||
x++ | ||
if (x > max.x) { | ||
x = min.x | ||
z++ | ||
} | ||
check(z <= max.z) | ||
ChunkPos(x, z) | ||
} | ||
.limit((diameter * diameter).toLong()) | ||
.filter { isChunkLoaded(it.x, it.z) } | ||
.map { getChunk(it.x, it.z) } | ||
} |
43 changes: 0 additions & 43 deletions
43
progreso-client/src/main/kotlin/org/progreso/client/util/world/WorldUtil.kt
This file was deleted.
Oops, something went wrong.