mirror of
https://github.com/chylex/Hardcore-Ender-Expansion-2.git
synced 2024-11-25 13:42:44 +01:00
Compare commits
4 Commits
5564fc4a24
...
2cb463f0aa
Author | SHA1 | Date | |
---|---|---|---|
2cb463f0aa | |||
2b343108bc | |||
65d8d709ab | |||
f73bcc6635 |
11
build.gradle
11
build.gradle
@ -16,7 +16,7 @@ buildscript {
|
||||
ext {
|
||||
forge_gradle_version = "4.1.+"
|
||||
mixin_gradle_version = "0.7-SNAPSHOT"
|
||||
kotlin_version = "1.5.20"
|
||||
kotlin_version = "1.7.0"
|
||||
}
|
||||
|
||||
repositories {
|
||||
@ -83,16 +83,13 @@ allprojects {
|
||||
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
apiVersion = "1.5"
|
||||
languageVersion = "1.5"
|
||||
useIR = true
|
||||
apiVersion = "1.7"
|
||||
languageVersion = "1.7"
|
||||
freeCompilerArgs = [
|
||||
"-Xno-call-assertions",
|
||||
"-Xno-param-assertions",
|
||||
"-Xno-receiver-assertions",
|
||||
"-Xjvm-default=all",
|
||||
"-Xuse-experimental=kotlin.contracts.ExperimentalContracts",
|
||||
"-XXLanguage:+InlineClasses"
|
||||
"-XXLanguage:+InlineClasses",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,6 @@
|
||||
package chylex.hee.game.world.generation.noise
|
||||
|
||||
import chylex.hee.util.math.FloatRange
|
||||
import chylex.hee.util.math.range
|
||||
import chylex.hee.util.math.remapRange
|
||||
import chylex.hee.util.math.remap
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.pow
|
||||
import kotlin.math.roundToInt
|
||||
@ -28,12 +26,12 @@ class NoiseValue(var value: Double) {
|
||||
it.coerceIn(minimum, maximum)
|
||||
}
|
||||
|
||||
fun remap(oldRange: FloatRange, newRange: FloatRange) = then {
|
||||
remapRange(it, oldRange, newRange)
|
||||
fun remap(fromMin: Double, fromMax: Double, toMin: Double, toMax: Double) = then {
|
||||
it.remap(fromMin, fromMax, toMin, toMax)
|
||||
}
|
||||
|
||||
fun remap(newRange: FloatRange) = then {
|
||||
remapRange(it, range(0F, 1F), newRange)
|
||||
fun remap(toMin: Double, toMax: Double) = then {
|
||||
it.remap(fromMin = 0.0, fromMax = 1.0, toMin, toMax)
|
||||
}
|
||||
|
||||
inline fun ifNonZero(block: NoiseValue.() -> Unit) {
|
||||
|
@ -18,54 +18,65 @@ import net.minecraft.util.math.BlockPos
|
||||
import net.minecraft.util.math.vector.Vector3d
|
||||
import org.apache.logging.log4j.Logger
|
||||
|
||||
inline fun <T : PacketBuffer> T.use(block: T.() -> Unit) {
|
||||
block()
|
||||
}
|
||||
|
||||
// BlockPos
|
||||
|
||||
inline fun PacketBuffer.writePos(pos: BlockPos) {
|
||||
inline fun ByteBuf.writePos(pos: BlockPos) {
|
||||
this.writeLong(pos.toLong())
|
||||
}
|
||||
|
||||
inline fun PacketBuffer.readPos(): BlockPos {
|
||||
inline fun ByteBuf.readPos(): BlockPos {
|
||||
return Pos(this.readLong())
|
||||
}
|
||||
|
||||
// Vec3d (Full)
|
||||
|
||||
fun PacketBuffer.writeVec(vec: Vector3d) {
|
||||
fun ByteBuf.writeVec(vec: Vector3d) {
|
||||
this.writeDouble(vec.x)
|
||||
this.writeDouble(vec.y)
|
||||
this.writeDouble(vec.z)
|
||||
}
|
||||
|
||||
fun PacketBuffer.readVec(): Vector3d {
|
||||
return Vec(readDouble(), readDouble(), readDouble())
|
||||
fun ByteBuf.readVec(): Vector3d {
|
||||
return Vec(this.readDouble(), this.readDouble(), this.readDouble())
|
||||
}
|
||||
|
||||
// Vec3d (Float)
|
||||
|
||||
fun PacketBuffer.writeFloatVec(vec: Vector3d) {
|
||||
fun ByteBuf.writeFloatVec(vec: Vector3d) {
|
||||
this.writeFloat(vec.x.toFloat())
|
||||
this.writeFloat(vec.y.toFloat())
|
||||
this.writeFloat(vec.z.toFloat())
|
||||
}
|
||||
|
||||
fun PacketBuffer.readFloatVec(): Vector3d {
|
||||
return Vec(readFloat().toDouble(), readFloat().toDouble(), readFloat().toDouble())
|
||||
fun ByteBuf.readFloatVec(): Vector3d {
|
||||
return Vec(this.readFloat().toDouble(), this.readFloat().toDouble(), this.readFloat().toDouble())
|
||||
}
|
||||
|
||||
// Vec3d (Compact)
|
||||
|
||||
fun PacketBuffer.writeCompactVec(vec: Vector3d) {
|
||||
fun ByteBuf.writeCompactVec(vec: Vector3d) {
|
||||
this.writeInt((vec.x * 8.0).floorToInt())
|
||||
this.writeInt((vec.y * 8.0).floorToInt())
|
||||
this.writeInt((vec.z * 8.0).floorToInt())
|
||||
}
|
||||
|
||||
fun PacketBuffer.readCompactVec(): Vector3d {
|
||||
return Vec(readInt() * 0.125, readInt() * 0.125, readInt() * 0.125)
|
||||
fun ByteBuf.readCompactVec(): Vector3d {
|
||||
return Vec(this.readInt() * 0.125, this.readInt() * 0.125, this.readInt() * 0.125)
|
||||
}
|
||||
|
||||
// Enum
|
||||
|
||||
fun <T : Enum<T>> PacketBuffer.writeEnum(value: T?) {
|
||||
this.writeVarInt(value?.ordinal ?: -1)
|
||||
}
|
||||
|
||||
inline fun <reified T : Enum<T>> PacketBuffer.readEnum(): T? {
|
||||
val ordinal = this.readVarInt()
|
||||
|
||||
return if (ordinal >= 0)
|
||||
T::class.java.enumConstants.getOrNull(ordinal)
|
||||
else
|
||||
null
|
||||
}
|
||||
|
||||
// NBT
|
||||
|
@ -46,17 +46,17 @@ fun lerp(from: Double, to: Double, progress: Double): Double {
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps a range of values in [from] range to values in [to] range using linear interpolation.
|
||||
* Remaps a value from the range [[fromMin], [fromMax]] to a value in the range [[toMin], [toMax]] using linear interpolation.
|
||||
*/
|
||||
fun remapRange(value: Float, from: FloatRange, to: FloatRange): Float {
|
||||
val remappedBetween0And1 = (value - from.start) / (from.end - from.start)
|
||||
return to.start + remappedBetween0And1 * (to.end - to.start)
|
||||
fun Float.remap(fromMin: Float, fromMax: Float, toMin: Float, toMax: Float): Float {
|
||||
val remappedBetween0And1 = (this - fromMin) / (fromMax - fromMin)
|
||||
return toMin + remappedBetween0And1 * (toMax - toMin)
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps a range of values in [from] range to values in [to] range using linear interpolation.
|
||||
* Remaps a value from the range [[fromMin], [fromMax]] to a value in the range [[toMin], [toMax]] using linear interpolation.
|
||||
*/
|
||||
fun remapRange(value: Double, from: FloatRange, to: FloatRange): Double {
|
||||
val remappedBetween0And1 = (value - from.start) / (from.end - from.start)
|
||||
return to.start + remappedBetween0And1 * (to.end - to.start)
|
||||
fun Double.remap(fromMin: Double, fromMax: Double, toMin: Double, toMax: Double): Double {
|
||||
val remappedBetween0And1 = (this - fromMin) / (fromMax - fromMin)
|
||||
return toMin + remappedBetween0And1 * (toMax - toMin)
|
||||
}
|
||||
|
@ -1,14 +0,0 @@
|
||||
package chylex.hee.util.math
|
||||
|
||||
@JvmInline
|
||||
value class FloatRange(private val combined: Long) {
|
||||
constructor(start: Float, end: Float) : this((start.toRawBits() shlong 32) or (end.toRawBits().toLong() and 0xFFFF_FFFFL))
|
||||
|
||||
val start
|
||||
get() = Float.fromBits((combined ushr 32).toInt())
|
||||
|
||||
val end
|
||||
get() = Float.fromBits((combined and 0xFFFF_FFFFL).toInt())
|
||||
}
|
||||
|
||||
fun range(start: Float, end: Float) = FloatRange(start, end)
|
@ -15,6 +15,7 @@ import net.minecraftforge.common.util.Constants.NBT
|
||||
import org.apache.logging.log4j.Logger
|
||||
import java.util.Locale
|
||||
import java.util.UUID
|
||||
import kotlin.contracts.ExperimentalContracts
|
||||
import kotlin.contracts.contract
|
||||
|
||||
typealias NBTBase = net.minecraft.nbt.INBT
|
||||
@ -54,12 +55,14 @@ inline fun TagCompound.hasKey(key: String, type: Int): Boolean {
|
||||
return this.contains(key, type)
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
@JvmName("isNotNullAndHasKey")
|
||||
inline fun TagCompound?.hasKey(key: String): Boolean {
|
||||
contract { returns(true) implies (this@hasKey != null) }
|
||||
return this != null && this.hasKey(key)
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
@JvmName("isNotNullAndHasKey")
|
||||
inline fun TagCompound?.hasKey(key: String, type: Int): Boolean {
|
||||
contract { returns(true) implies (this@hasKey != null) }
|
||||
|
@ -1,7 +1,6 @@
|
||||
package chylex.hee.util.random
|
||||
|
||||
import chylex.hee.util.math.range
|
||||
import chylex.hee.util.math.remapRange
|
||||
import chylex.hee.util.math.remap
|
||||
import java.util.Random
|
||||
import kotlin.math.pow
|
||||
|
||||
@ -30,7 +29,7 @@ abstract class RandomDouble private constructor(val min: Double, val max: Double
|
||||
|
||||
fun Exp(min: Double, max: Double, exp: Double) = object : RandomDouble(min, max) {
|
||||
override fun invoke(rand: Random): Double {
|
||||
return remapRange(rand.nextDouble().pow(exp), range(0F, 1F), range(min.toFloat(), max.toFloat()))
|
||||
return rand.nextDouble().pow(exp).remap(fromMin = 0.0, fromMax = 1.0, toMin = min, toMax = max)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
rootProject.name = "HEE"
|
||||
|
||||
include ":util"
|
||||
include ":system"
|
||||
include ":debug"
|
||||
|
@ -25,8 +25,7 @@ import chylex.hee.util.forge.SubscribeAllEvents
|
||||
import chylex.hee.util.forge.SubscribeEvent
|
||||
import chylex.hee.util.math.LerpedFloat
|
||||
import chylex.hee.util.math.floorToInt
|
||||
import chylex.hee.util.math.range
|
||||
import chylex.hee.util.math.remapRange
|
||||
import chylex.hee.util.math.remap
|
||||
import chylex.hee.util.math.scale
|
||||
import com.mojang.blaze3d.matrix.MatrixStack
|
||||
import com.mojang.blaze3d.platform.GlStateManager.FogMode.EXP2
|
||||
@ -118,7 +117,7 @@ object TerritoryRenderer {
|
||||
// Fog rendering
|
||||
|
||||
private val currentFogDensityMp
|
||||
get() = 1F + (9F * remapRange(currentVoidFactor, range(-0.5F, 1F), range(0F, 1F)).coerceIn(0F, 1F).pow(1.5F))
|
||||
get() = 1F + (9F * currentVoidFactor.remap(fromMin = -0.5F, fromMax = 1F, toMin = 0F, toMax = 1F).coerceIn(0F, 1F).pow(1.5F))
|
||||
|
||||
private val currentRenderDistanceMp
|
||||
get() = MC.settings.renderDistanceChunks.let { if (it > 12) 0F else (1F - (it / 16.5F)).pow((it - 1) * 0.25F) }
|
||||
@ -148,7 +147,7 @@ object TerritoryRenderer {
|
||||
get() = Void.voidFactor.get(MC.partialTicks)
|
||||
|
||||
val currentSkyAlpha
|
||||
get() = remapRange(currentVoidFactor, range(-1F, 0.5F), range(1F, 0F)).coerceIn(0F, 1F)
|
||||
get() = currentVoidFactor.remap(fromMin = -1F, fromMax = 0.5F, toMin = 1F, toMax = 0F).coerceIn(0F, 1F)
|
||||
|
||||
private object Void {
|
||||
private val VOID_PARTICLE = ParticleSpawnerCustom(
|
||||
|
@ -49,13 +49,13 @@ class RenderEntityTokenHolder(manager: EntityRendererManager) : EntityRenderer<E
|
||||
matrix.rotateX(55F)
|
||||
matrix.rotateZ(55F)
|
||||
|
||||
ModelEntityTokenHolder.render(matrix, buffer.getBuffer(RenderType.getEntityTranslucent(getEntityTexture(entity) ?: textures.getValue(NORMAL))), combinedLight, OverlayTexture.NO_OVERLAY, 1F, 1F, 1F, alpha)
|
||||
ModelEntityTokenHolder.render(matrix, buffer.getBuffer(RenderType.getEntityTranslucent(getEntityTexture(entity))), combinedLight, OverlayTexture.NO_OVERLAY, 1F, 1F, 1F, alpha)
|
||||
|
||||
matrix.pop()
|
||||
matrix.pop()
|
||||
}
|
||||
|
||||
override fun getEntityTexture(entity: EntityTokenHolder): ResourceLocation? {
|
||||
return textures[entity.tokenType]
|
||||
override fun getEntityTexture(entity: EntityTokenHolder): ResourceLocation {
|
||||
return textures.getValue(entity.tokenType)
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,6 @@ import chylex.hee.game.world.util.setState
|
||||
import chylex.hee.init.ModSounds
|
||||
import chylex.hee.network.client.PacketClientFX
|
||||
import chylex.hee.util.buffer.readPos
|
||||
import chylex.hee.util.buffer.use
|
||||
import chylex.hee.util.buffer.writePos
|
||||
import chylex.hee.util.math.center
|
||||
import chylex.hee.util.nbt.TagCompound
|
||||
@ -174,9 +173,9 @@ interface IBlockDeathFlowerDecaying {
|
||||
private val PARTICLE_MOT = Gaussian(0.02F)
|
||||
|
||||
class FxHealData(private val pos: BlockPos, private val newLevel: Int) : IFxData {
|
||||
override fun write(buffer: PacketBuffer) = buffer.use {
|
||||
writePos(pos)
|
||||
writeByte(newLevel)
|
||||
override fun write(buffer: PacketBuffer) {
|
||||
buffer.writePos(pos)
|
||||
buffer.writeByte(newLevel)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,6 @@ import chylex.hee.init.ModSounds
|
||||
import chylex.hee.init.ModTileEntities
|
||||
import chylex.hee.network.client.PacketClientFX
|
||||
import chylex.hee.util.buffer.readCompactVec
|
||||
import chylex.hee.util.buffer.use
|
||||
import chylex.hee.util.buffer.writeCompactVec
|
||||
import chylex.hee.util.collection.mutableWeightedListOf
|
||||
import chylex.hee.util.collection.weightedListOf
|
||||
@ -119,17 +118,17 @@ class TileEntityMinersBurialAltar(type: TileEntityType<TileEntityMinersBurialAlt
|
||||
)
|
||||
|
||||
class FxSpawnData(private val pos: Vector3d, private val type: Byte) : IFxData {
|
||||
override fun write(buffer: PacketBuffer) = buffer.use {
|
||||
writeCompactVec(pos)
|
||||
writeByte(type.toInt())
|
||||
override fun write(buffer: PacketBuffer) {
|
||||
buffer.writeCompactVec(pos)
|
||||
buffer.writeByte(type.toInt())
|
||||
}
|
||||
}
|
||||
|
||||
val FX_SPAWN = object : IFxHandler<FxSpawnData> {
|
||||
override fun handle(buffer: PacketBuffer, world: World, rand: Random) = buffer.use {
|
||||
val pos = readCompactVec()
|
||||
override fun handle(buffer: PacketBuffer, world: World, rand: Random) {
|
||||
val pos = buffer.readCompactVec()
|
||||
|
||||
when (readByte()) {
|
||||
when (buffer.readByte()) {
|
||||
REDEEM_TYPE_TOKEN -> {
|
||||
PARTICLE_SPAWN.spawn(Point(pos, 9), rand)
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ abstract class TileEntityBasePortalController(type: TileEntityType<out TileEntit
|
||||
when (clientRenderState) {
|
||||
Invisible -> clientAnimationProgress.update(max(0F, clientAnimationProgress - clientAnimationFadeOutSpeed))
|
||||
is Animating -> clientAnimationProgress.update(min(1F, clientAnimationProgress + clientAnimationFadeInSpeed))
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,8 +23,9 @@ import chylex.hee.network.client.PacketClientMoveYourAss
|
||||
import chylex.hee.network.client.PacketClientRotateInstantly
|
||||
import chylex.hee.network.client.PacketClientTeleportInstantly
|
||||
import chylex.hee.util.buffer.readCompactVec
|
||||
import chylex.hee.util.buffer.use
|
||||
import chylex.hee.util.buffer.readEnum
|
||||
import chylex.hee.util.buffer.writeCompactVec
|
||||
import chylex.hee.util.buffer.writeEnum
|
||||
import chylex.hee.util.math.Pos
|
||||
import chylex.hee.util.math.Vec
|
||||
import chylex.hee.util.math.addY
|
||||
@ -78,16 +79,16 @@ class Teleporter(
|
||||
private val soundVolume: Float,
|
||||
private val extraRange: Float = 0F,
|
||||
) : IFxData {
|
||||
override fun write(buffer: PacketBuffer) = buffer.use {
|
||||
writeCompactVec(startPoint)
|
||||
writeCompactVec(endPoint)
|
||||
writeByte((width * 10F).floorToInt().coerceIn(0, 100))
|
||||
writeByte((height * 10F).floorToInt().coerceIn(0, 100))
|
||||
override fun write(buffer: PacketBuffer) {
|
||||
buffer.writeCompactVec(startPoint)
|
||||
buffer.writeCompactVec(endPoint)
|
||||
buffer.writeByte((width * 10F).floorToInt().coerceIn(0, 100))
|
||||
buffer.writeByte((height * 10F).floorToInt().coerceIn(0, 100))
|
||||
|
||||
writeRegistryId(soundEvent)
|
||||
writeEnumValue(soundCategory)
|
||||
writeByte((soundVolume * 10F).floorToInt().coerceIn(0, 250))
|
||||
writeByte(extraRange.floorToInt().coerceIn(0, 255))
|
||||
buffer.writeRegistryId(soundEvent)
|
||||
buffer.writeEnum(soundCategory)
|
||||
buffer.writeByte((soundVolume * 10F).floorToInt().coerceIn(0, 250))
|
||||
buffer.writeByte(extraRange.floorToInt().coerceIn(0, 255))
|
||||
}
|
||||
|
||||
fun send(world: World) {
|
||||
@ -99,20 +100,20 @@ class Teleporter(
|
||||
}
|
||||
|
||||
val FX_TELEPORT = object : IFxHandler<FxTeleportData> {
|
||||
override fun handle(buffer: PacketBuffer, world: World, rand: Random) = buffer.use {
|
||||
override fun handle(buffer: PacketBuffer, world: World, rand: Random) {
|
||||
val player = MC.player ?: return
|
||||
val playerPos = player.posVec
|
||||
|
||||
val startPoint = readCompactVec()
|
||||
val endPoint = readCompactVec()
|
||||
val startPoint = buffer.readCompactVec()
|
||||
val endPoint = buffer.readCompactVec()
|
||||
|
||||
val halfWidth = (readByte() / 10F) * 0.5F
|
||||
val halfHeight = (readByte() / 10F) * 0.5F
|
||||
val halfWidth = (buffer.readByte() / 10F) * 0.5F
|
||||
val halfHeight = (buffer.readByte() / 10F) * 0.5F
|
||||
|
||||
val soundEvent = readRegistryIdSafe(SoundEvent::class.java)
|
||||
val soundCategory = readEnumValue(SoundCategory::class.java)
|
||||
val soundVolume = readByte() / 10F
|
||||
val soundRange = 16F + readByte()
|
||||
val soundEvent = buffer.readRegistryIdSafe(SoundEvent::class.java)
|
||||
val soundCategory = buffer.readEnum() ?: SoundCategory.NEUTRAL
|
||||
val soundVolume = buffer.readByte() / 10F
|
||||
val soundRange = 16F + buffer.readByte()
|
||||
|
||||
val soundPosition = if (playerPos.squareDistanceTo(startPoint) < playerPos.squareDistanceTo(endPoint))
|
||||
startPoint
|
||||
|
@ -16,7 +16,6 @@ import chylex.hee.game.world.util.getTile
|
||||
import chylex.hee.game.world.util.removeBlock
|
||||
import chylex.hee.game.world.util.setState
|
||||
import chylex.hee.init.ModEntities
|
||||
import chylex.hee.util.buffer.use
|
||||
import chylex.hee.util.math.Pos
|
||||
import chylex.hee.util.math.Vec3
|
||||
import chylex.hee.util.math.subtractY
|
||||
@ -86,12 +85,12 @@ open class EntityFallingBlockHeavy(type: EntityType<out EntityFallingBlockHeavy>
|
||||
return NetworkHooks.getEntitySpawningPacket(this)
|
||||
}
|
||||
|
||||
override fun writeSpawnData(buffer: PacketBuffer) = buffer.use {
|
||||
writeInt(fallTile?.let(Block::getStateId) ?: 0)
|
||||
override fun writeSpawnData(buffer: PacketBuffer) {
|
||||
buffer.writeInt(fallTile?.let(Block::getStateId) ?: 0)
|
||||
}
|
||||
|
||||
override fun readSpawnData(buffer: PacketBuffer) = buffer.use {
|
||||
fallTile = Block.getStateById(readInt())
|
||||
override fun readSpawnData(buffer: PacketBuffer) {
|
||||
fallTile = Block.getStateById(buffer.readInt())
|
||||
}
|
||||
|
||||
override fun tick() {
|
||||
|
@ -18,7 +18,6 @@ import chylex.hee.init.ModEntities
|
||||
import chylex.hee.init.ModSounds
|
||||
import chylex.hee.network.client.PacketClientFX
|
||||
import chylex.hee.util.buffer.readPos
|
||||
import chylex.hee.util.buffer.use
|
||||
import chylex.hee.util.buffer.writePos
|
||||
import chylex.hee.util.math.Pos
|
||||
import chylex.hee.util.random.nextFloat
|
||||
@ -45,16 +44,16 @@ class EntityFallingObsidian : EntityFallingBlockHeavy {
|
||||
private val DAMAGE = Damage(PEACEFUL_EXCLUSION, ARMOR_PROTECTION(false), ENCHANTMENT_PROTECTION)
|
||||
|
||||
class FxFallData(private val pos: BlockPos, private val volume: Float) : IFxData {
|
||||
override fun write(buffer: PacketBuffer) = buffer.use {
|
||||
writePos(pos)
|
||||
writeFloat(volume)
|
||||
override fun write(buffer: PacketBuffer) {
|
||||
buffer.writePos(pos)
|
||||
buffer.writeFloat(volume)
|
||||
}
|
||||
}
|
||||
|
||||
val FX_FALL = object : IFxHandler<FxFallData> {
|
||||
override fun handle(buffer: PacketBuffer, world: World, rand: Random) = buffer.use {
|
||||
val pos = readPos()
|
||||
val volume = readFloat()
|
||||
override fun handle(buffer: PacketBuffer, world: World, rand: Random) {
|
||||
val pos = buffer.readPos()
|
||||
val volume = buffer.readFloat()
|
||||
|
||||
repeat(2) {
|
||||
ModSounds.BLOCK_OBSIDIAN_LAND.playClient(pos, SoundCategory.BLOCKS, volume = volume, pitch = rand.nextFloat(0.8F, 1.2F))
|
||||
|
@ -24,8 +24,7 @@ import chylex.hee.init.ModEntities
|
||||
import chylex.hee.system.heeTag
|
||||
import chylex.hee.util.math.Vec
|
||||
import chylex.hee.util.math.center
|
||||
import chylex.hee.util.math.range
|
||||
import chylex.hee.util.math.remapRange
|
||||
import chylex.hee.util.math.remap
|
||||
import chylex.hee.util.nbt.TagCompound
|
||||
import chylex.hee.util.nbt.use
|
||||
import chylex.hee.util.random.nextFloat
|
||||
@ -269,9 +268,9 @@ class EntityInfusedTNT : TNTEntity {
|
||||
val waterRatio = foundWaterBlocks.size.toFloat() / totalCountedBlocks
|
||||
|
||||
val dropAmount = when {
|
||||
waterRatio < 0.1 -> remapRange(waterRatio, range(0.0F, 0.1F), range(1.0F, 1.6F))
|
||||
waterRatio < 0.4 -> remapRange(waterRatio, range(0.1F, 0.4F), range(1.6F, 4.0F))
|
||||
else -> remapRange(waterRatio, range(0.4F, 1.0F), range(4.0F, 5.8F))
|
||||
waterRatio < 0.1 -> waterRatio.remap(fromMin = 0.0F, fromMax = 0.1F, toMin = 1.0F, toMax = 1.6F)
|
||||
waterRatio < 0.4 -> waterRatio.remap(fromMin = 0.1F, fromMax = 0.4F, toMin = 1.6F, toMax = 4.0F)
|
||||
else -> waterRatio.remap(fromMin = 0.4F, fromMax = 1.0F, toMin = 4.0F, toMax = 5.8F)
|
||||
}
|
||||
|
||||
val lootTable = Environment.getLootTable(LootTables.GAMEPLAY_FISHING)
|
||||
|
@ -5,7 +5,6 @@ import chylex.hee.game.particle.spawner.properties.IOffset.Constant
|
||||
import chylex.hee.game.particle.spawner.properties.IOffset.InBox
|
||||
import chylex.hee.game.particle.spawner.properties.IShape.Point
|
||||
import chylex.hee.init.ModEntities
|
||||
import chylex.hee.util.buffer.use
|
||||
import chylex.hee.util.math.square
|
||||
import net.minecraft.entity.EntityType
|
||||
import net.minecraft.item.ItemStack
|
||||
@ -33,12 +32,12 @@ class EntityItemFreshlyCooked : EntityItemBase, IEntityAdditionalSpawnData {
|
||||
)
|
||||
}
|
||||
|
||||
override fun writeSpawnData(buffer: PacketBuffer) = buffer.use {
|
||||
writeShort(age)
|
||||
override fun writeSpawnData(buffer: PacketBuffer) {
|
||||
buffer.writeShort(age)
|
||||
}
|
||||
|
||||
override fun readSpawnData(buffer: PacketBuffer) = buffer.use {
|
||||
age = readShort().toInt()
|
||||
override fun readSpawnData(buffer: PacketBuffer) {
|
||||
age = buffer.readShort().toInt()
|
||||
}
|
||||
|
||||
override fun tick() {
|
||||
|
@ -18,7 +18,6 @@ import chylex.hee.init.ModEntities
|
||||
import chylex.hee.init.ModSounds
|
||||
import chylex.hee.network.client.PacketClientFX
|
||||
import chylex.hee.util.buffer.readPos
|
||||
import chylex.hee.util.buffer.use
|
||||
import chylex.hee.util.buffer.writePos
|
||||
import chylex.hee.util.math.Pos
|
||||
import chylex.hee.util.math.center
|
||||
@ -46,16 +45,16 @@ class EntityItemRevitalizationSubstance : EntityItemBase {
|
||||
private const val MAX_RADIUS = 8.5F
|
||||
|
||||
class FxRevitalizeGooData(private val center: BlockPos, private val radius: Float) : IFxData {
|
||||
override fun write(buffer: PacketBuffer) = buffer.use {
|
||||
writePos(center)
|
||||
writeFloat(radius)
|
||||
override fun write(buffer: PacketBuffer) {
|
||||
buffer.writePos(center)
|
||||
buffer.writeFloat(radius)
|
||||
}
|
||||
}
|
||||
|
||||
val FX_REVITALIZE_GOO = object : IFxHandler<FxRevitalizeGooData> {
|
||||
override fun handle(buffer: PacketBuffer, world: World, rand: Random) = buffer.use {
|
||||
val center = readPos()
|
||||
val radius = readFloat()
|
||||
override fun handle(buffer: PacketBuffer, world: World, rand: Random) {
|
||||
val center = buffer.readPos()
|
||||
val radius = buffer.readFloat()
|
||||
|
||||
forEachGoo(world, center, radius) { pos, _ ->
|
||||
BlockEnderGooPurified.FX_PLACE.let {
|
||||
|
@ -22,7 +22,8 @@ import chylex.hee.init.ModSounds
|
||||
import chylex.hee.network.client.PacketClientFX
|
||||
import chylex.hee.network.client.PacketClientLaunchInstantly
|
||||
import chylex.hee.system.heeTag
|
||||
import chylex.hee.util.buffer.use
|
||||
import chylex.hee.util.buffer.readEnum
|
||||
import chylex.hee.util.buffer.writeEnum
|
||||
import chylex.hee.util.forge.Side
|
||||
import chylex.hee.util.forge.Sided
|
||||
import chylex.hee.util.math.LerpedFloat
|
||||
@ -114,16 +115,16 @@ class EntityTokenHolder(type: EntityType<EntityTokenHolder>, world: World) : Ent
|
||||
dataManager.register(DATA_CHARGE, 1F)
|
||||
}
|
||||
|
||||
override fun writeSpawnData(buffer: PacketBuffer) = buffer.use {
|
||||
writeByte(tokenType.ordinal)
|
||||
writeShort(territoryType?.ordinal ?: -1)
|
||||
writeFloat(currentCharge)
|
||||
override fun writeSpawnData(buffer: PacketBuffer) {
|
||||
buffer.writeEnum(tokenType)
|
||||
buffer.writeEnum(territoryType)
|
||||
buffer.writeFloat(currentCharge)
|
||||
}
|
||||
|
||||
override fun readSpawnData(buffer: PacketBuffer) = buffer.use {
|
||||
tokenType = TokenType.values().getOrElse(readByte().toInt()) { TokenType.NORMAL }
|
||||
territoryType = TerritoryType.values().getOrNull(readShort().toInt())
|
||||
renderCharge.updateImmediately(readFloat())
|
||||
override fun readSpawnData(buffer: PacketBuffer) {
|
||||
tokenType = buffer.readEnum<TokenType>() ?: TokenType.NORMAL
|
||||
territoryType = buffer.readEnum<TerritoryType>()
|
||||
renderCharge.updateImmediately(buffer.readFloat())
|
||||
}
|
||||
|
||||
override fun tick() {
|
||||
|
@ -128,6 +128,6 @@ abstract class EntityMobAbstractEnderman(type: EntityType<out EntityMobAbstractE
|
||||
override fun isDamageAbsolute() = source.isDamageAbsolute
|
||||
override fun canHarmInCreative() = source.canHarmInCreative()
|
||||
|
||||
override fun getDeathMessage(victim: LivingEntity): ITextComponent? = source.getDeathMessage(victim)
|
||||
override fun getDeathMessage(victim: LivingEntity): ITextComponent = source.getDeathMessage(victim)
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +38,6 @@ import chylex.hee.init.ModSounds
|
||||
import chylex.hee.network.client.PacketClientFX
|
||||
import chylex.hee.system.heeTag
|
||||
import chylex.hee.util.buffer.readTag
|
||||
import chylex.hee.util.buffer.use
|
||||
import chylex.hee.util.buffer.writeTag
|
||||
import chylex.hee.util.color.IColorGenerator
|
||||
import chylex.hee.util.color.RGB
|
||||
@ -159,12 +158,12 @@ class EntityMobUndread(type: EntityType<EntityMobUndread>, world: World) : Monst
|
||||
return NetworkHooks.getEntitySpawningPacket(this)
|
||||
}
|
||||
|
||||
override fun writeSpawnData(buffer: PacketBuffer) = buffer.use {
|
||||
writeTag(TagCompound().apply { putList(DUSTS_TAG, dustEffects.serializeNBT()) })
|
||||
override fun writeSpawnData(buffer: PacketBuffer) {
|
||||
buffer.writeTag(TagCompound().apply { putList(DUSTS_TAG, dustEffects.serializeNBT()) })
|
||||
}
|
||||
|
||||
override fun readSpawnData(buffer: PacketBuffer) = buffer.use {
|
||||
dustEffects = UndreadDustEffects.fromNBT(readTag().getListOfStrings(DUSTS_TAG))
|
||||
override fun readSpawnData(buffer: PacketBuffer) {
|
||||
dustEffects = UndreadDustEffects.fromNBT(buffer.readTag().getListOfStrings(DUSTS_TAG))
|
||||
}
|
||||
|
||||
override fun tick() {
|
||||
|
@ -20,7 +20,6 @@ import chylex.hee.init.ModEntities
|
||||
import chylex.hee.init.ModSounds
|
||||
import chylex.hee.system.heeTag
|
||||
import chylex.hee.util.buffer.readDecoded
|
||||
import chylex.hee.util.buffer.use
|
||||
import chylex.hee.util.buffer.writeEncoded
|
||||
import chylex.hee.util.color.RGB
|
||||
import chylex.hee.util.nbt.TagCompound
|
||||
@ -120,22 +119,22 @@ class EntityMobVillagerDying(type: EntityType<EntityMobVillagerDying>, world: Wo
|
||||
return NetworkHooks.getEntitySpawningPacket(this)
|
||||
}
|
||||
|
||||
override fun writeSpawnData(buffer: PacketBuffer) = buffer.use {
|
||||
writeEncoded(villager, VillagerData.CODEC, HEE.log)
|
||||
writeVarInt(deathTime)
|
||||
override fun writeSpawnData(buffer: PacketBuffer) {
|
||||
buffer.writeEncoded(villager, VillagerData.CODEC, HEE.log)
|
||||
buffer.writeVarInt(deathTime)
|
||||
|
||||
writeFloat(renderYawOffset)
|
||||
writeFloat(rotationYawHead)
|
||||
writeFloat(limbSwing)
|
||||
buffer.writeFloat(renderYawOffset)
|
||||
buffer.writeFloat(rotationYawHead)
|
||||
buffer.writeFloat(limbSwing)
|
||||
}
|
||||
|
||||
override fun readSpawnData(buffer: PacketBuffer) = buffer.use {
|
||||
villager = readDecoded(VillagerData.CODEC, HEE.log)
|
||||
deathTime = readVarInt()
|
||||
override fun readSpawnData(buffer: PacketBuffer) {
|
||||
villager = buffer.readDecoded(VillagerData.CODEC, HEE.log)
|
||||
deathTime = buffer.readVarInt()
|
||||
|
||||
renderYawOffset = readFloat()
|
||||
rotationYawHead = readFloat()
|
||||
limbSwing = readFloat()
|
||||
renderYawOffset = buffer.readFloat()
|
||||
rotationYawHead = buffer.readFloat()
|
||||
limbSwing = buffer.readFloat()
|
||||
|
||||
prevRenderYawOffset = renderYawOffset
|
||||
prevRotationYawHead = rotationYawHead
|
||||
|
@ -47,6 +47,7 @@ class AITargetAttackerFixed(entity: MobEntity, private val callReinforcements: B
|
||||
|
||||
private fun alertOthers() {
|
||||
val maxDistance = targetDistance
|
||||
val goalOwner = goalOwner
|
||||
val (x, y, z) = goalOwner.posVec
|
||||
|
||||
val friendlies = goalOwner.world.getLoadedEntitiesWithinAABB(goalOwner.javaClass, AxisAlignedBB(x, y, z, x + 1.0, y + 1.0, z + 1.0).grow(maxDistance, 10.0, maxDistance))
|
||||
|
@ -21,7 +21,6 @@ import chylex.hee.game.world.util.getBlocksInside
|
||||
import chylex.hee.game.world.util.isAir
|
||||
import chylex.hee.init.ModEntities
|
||||
import chylex.hee.system.heeTag
|
||||
import chylex.hee.util.buffer.use
|
||||
import chylex.hee.util.forge.EventPriority
|
||||
import chylex.hee.util.forge.SubscribeAllEvents
|
||||
import chylex.hee.util.forge.SubscribeEvent
|
||||
@ -130,19 +129,19 @@ class EntityProjectileEnderPearl(type: EntityType<EntityProjectileEnderPearl>, w
|
||||
return NetworkHooks.getEntitySpawningPacket(this)
|
||||
}
|
||||
|
||||
override fun writeSpawnData(buffer: PacketBuffer) = buffer.use {
|
||||
writeBoolean(infusions.has(HARMLESS))
|
||||
writeBoolean(infusions.has(SLOW))
|
||||
override fun writeSpawnData(buffer: PacketBuffer) {
|
||||
buffer.writeBoolean(infusions.has(HARMLESS))
|
||||
buffer.writeBoolean(infusions.has(SLOW))
|
||||
}
|
||||
|
||||
override fun readSpawnData(buffer: PacketBuffer) = buffer.use {
|
||||
override fun readSpawnData(buffer: PacketBuffer) {
|
||||
var list = InfusionList.EMPTY
|
||||
|
||||
if (readBoolean()) {
|
||||
if (buffer.readBoolean()) {
|
||||
list = list.with(HARMLESS)
|
||||
}
|
||||
|
||||
if (readBoolean()) {
|
||||
if (buffer.readBoolean()) {
|
||||
list = list.with(SLOW)
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,6 @@ import chylex.hee.game.world.util.offsetUntil
|
||||
import chylex.hee.init.ModEntities
|
||||
import chylex.hee.system.heeTag
|
||||
import chylex.hee.util.buffer.readPos
|
||||
import chylex.hee.util.buffer.use
|
||||
import chylex.hee.util.buffer.writePos
|
||||
import chylex.hee.util.color.IColorGenerator
|
||||
import chylex.hee.util.color.IntColor
|
||||
@ -172,13 +171,13 @@ class EntityProjectileEyeOfEnder(type: EntityType<EntityProjectileEyeOfEnder>, w
|
||||
return NetworkHooks.getEntitySpawningPacket(this)
|
||||
}
|
||||
|
||||
override fun writeSpawnData(buffer: PacketBuffer) = buffer.use {
|
||||
writePos(targetPos ?: BlockPos.ZERO)
|
||||
writeShort(timer)
|
||||
writeFloat(speed)
|
||||
override fun writeSpawnData(buffer: PacketBuffer) {
|
||||
buffer.writePos(targetPos ?: BlockPos.ZERO)
|
||||
buffer.writeShort(timer)
|
||||
buffer.writeFloat(speed)
|
||||
}
|
||||
|
||||
override fun readSpawnData(buffer: PacketBuffer) = buffer.use {
|
||||
override fun readSpawnData(buffer: PacketBuffer) {
|
||||
targetPos = buffer.readPos().takeIf { it != BlockPos.ZERO }
|
||||
timer = buffer.readShort().toInt()
|
||||
speed = buffer.readFloat()
|
||||
|
@ -26,7 +26,6 @@ import chylex.hee.init.ModSounds
|
||||
import chylex.hee.network.client.PacketClientFX
|
||||
import chylex.hee.system.heeTag
|
||||
import chylex.hee.util.buffer.readCompactVec
|
||||
import chylex.hee.util.buffer.use
|
||||
import chylex.hee.util.buffer.writeCompactVec
|
||||
import chylex.hee.util.color.IColorGenerator
|
||||
import chylex.hee.util.color.RGB
|
||||
@ -119,19 +118,19 @@ class EntityProjectileSpatialDash(type: EntityType<EntityProjectileSpatialDash>,
|
||||
)
|
||||
|
||||
class FxExpireData(private val point: Vector3d, private val ownerEntity: Entity?) : IFxData {
|
||||
override fun write(buffer: PacketBuffer) = buffer.use {
|
||||
writeCompactVec(point)
|
||||
writeInt(ownerEntity?.entityId ?: -1)
|
||||
override fun write(buffer: PacketBuffer) {
|
||||
buffer.writeCompactVec(point)
|
||||
buffer.writeInt(ownerEntity?.entityId ?: -1)
|
||||
}
|
||||
}
|
||||
|
||||
val FX_EXPIRE = object : IFxHandler<FxExpireData> {
|
||||
override fun handle(buffer: PacketBuffer, world: World, rand: Random) = buffer.use {
|
||||
override fun handle(buffer: PacketBuffer, world: World, rand: Random) {
|
||||
val player = MC.player ?: return
|
||||
val playerPos = player.posVec
|
||||
|
||||
val point = readCompactVec()
|
||||
val forceAudible = readInt() == player.entityId
|
||||
val point = buffer.readCompactVec()
|
||||
val forceAudible = buffer.readInt() == player.entityId
|
||||
|
||||
val soundPoint = if (forceAudible) {
|
||||
val distance = playerPos.distanceTo(point)
|
||||
|
@ -29,7 +29,6 @@ import chylex.hee.init.ModSounds
|
||||
import chylex.hee.network.client.PacketClientFX
|
||||
import chylex.hee.system.heeTag
|
||||
import chylex.hee.util.buffer.readPos
|
||||
import chylex.hee.util.buffer.use
|
||||
import chylex.hee.util.buffer.writePos
|
||||
import chylex.hee.util.math.Pos
|
||||
import chylex.hee.util.math.Vec3
|
||||
@ -161,14 +160,14 @@ class EntityTechnicalIgneousPlateLogic(type: EntityType<EntityTechnicalIgneousPl
|
||||
)
|
||||
|
||||
class FxCoolingData(private val pos: BlockPos, private val amount: Float) : IFxData {
|
||||
override fun write(buffer: PacketBuffer) = buffer.use {
|
||||
writePos(pos)
|
||||
writeFloat(amount)
|
||||
override fun write(buffer: PacketBuffer) {
|
||||
buffer.writePos(pos)
|
||||
buffer.writeFloat(amount)
|
||||
}
|
||||
}
|
||||
|
||||
val FX_COOLING = object : IFxHandler<FxCoolingData> {
|
||||
override fun handle(buffer: PacketBuffer, world: World, rand: Random) = buffer.use {
|
||||
override fun handle(buffer: PacketBuffer, world: World, rand: Random) {
|
||||
val pos = buffer.readPos()
|
||||
val amount = buffer.readFloat()
|
||||
|
||||
|
@ -14,7 +14,6 @@ import chylex.hee.game.world.generation.feature.tombdungeon.piece.TombDungeonRoo
|
||||
import chylex.hee.game.world.generation.feature.tombdungeon.piece.TombDungeonRoom_Tomb
|
||||
import chylex.hee.init.ModEntities
|
||||
import chylex.hee.system.heeTag
|
||||
import chylex.hee.util.buffer.use
|
||||
import chylex.hee.util.delegate.NotifyOnChange
|
||||
import chylex.hee.util.nbt.TagCompound
|
||||
import chylex.hee.util.nbt.getEnum
|
||||
@ -93,12 +92,12 @@ class EntityTechnicalTrigger(type: EntityType<EntityTechnicalTrigger>, world: Wo
|
||||
|
||||
override fun registerData() {}
|
||||
|
||||
override fun writeSpawnData(buffer: PacketBuffer) = buffer.use {
|
||||
writeInt(type.ordinal)
|
||||
override fun writeSpawnData(buffer: PacketBuffer) {
|
||||
buffer.writeInt(type.ordinal)
|
||||
}
|
||||
|
||||
override fun readSpawnData(buffer: PacketBuffer) = buffer.use {
|
||||
type = Types.values().getOrNull(readInt()) ?: INVALID
|
||||
override fun readSpawnData(buffer: PacketBuffer) {
|
||||
type = Types.values().getOrNull(buffer.readInt()) ?: INVALID
|
||||
}
|
||||
|
||||
override fun tick() {
|
||||
|
@ -27,7 +27,6 @@ import chylex.hee.network.client.PacketClientFX
|
||||
import chylex.hee.system.heeTag
|
||||
import chylex.hee.system.heeTagOrNull
|
||||
import chylex.hee.util.buffer.readPos
|
||||
import chylex.hee.util.buffer.use
|
||||
import chylex.hee.util.buffer.writePos
|
||||
import chylex.hee.util.math.ceilToInt
|
||||
import chylex.hee.util.math.floorToInt
|
||||
@ -68,9 +67,9 @@ class ItemAbstractEnergyUser(private val impl: IEnergyItem) : HeeItemBuilder() {
|
||||
}
|
||||
|
||||
class FxChargeData(private val cluster: TileEntityEnergyCluster, private val player: PlayerEntity) : IFxData {
|
||||
override fun write(buffer: PacketBuffer) = buffer.use {
|
||||
writePos(cluster.pos)
|
||||
writeInt(player.entityId)
|
||||
override fun write(buffer: PacketBuffer) {
|
||||
buffer.writePos(cluster.pos)
|
||||
buffer.writeInt(player.entityId)
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,9 +85,9 @@ class ItemAbstractEnergyUser(private val impl: IEnergyItem) : HeeItemBuilder() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun handle(buffer: PacketBuffer, world: World, rand: Random) = buffer.use {
|
||||
val cluster = readPos().getTile<TileEntityEnergyCluster>(world) ?: return
|
||||
val player = world.getEntityByID(readInt()) as? PlayerEntity ?: return
|
||||
override fun handle(buffer: PacketBuffer, world: World, rand: Random) {
|
||||
val cluster = buffer.readPos().getTile<TileEntityEnergyCluster>(world) ?: return
|
||||
val player = world.getEntityByID(buffer.readInt()) as? PlayerEntity ?: return
|
||||
|
||||
ParticleSpawnerCustom(
|
||||
type = ParticleEnergyTransferToPlayer,
|
||||
|
@ -19,8 +19,9 @@ import chylex.hee.game.particle.spawner.properties.IShape.Line
|
||||
import chylex.hee.game.world.util.getTile
|
||||
import chylex.hee.init.ModSounds
|
||||
import chylex.hee.network.client.PacketClientFX
|
||||
import chylex.hee.util.buffer.readEnum
|
||||
import chylex.hee.util.buffer.readPos
|
||||
import chylex.hee.util.buffer.use
|
||||
import chylex.hee.util.buffer.writeEnum
|
||||
import chylex.hee.util.buffer.writePos
|
||||
import chylex.hee.util.math.center
|
||||
import chylex.hee.util.math.directionTowards
|
||||
@ -74,19 +75,19 @@ object ItemRevitalizationSubstance : HeeItemBuilder() {
|
||||
)
|
||||
|
||||
class FxUseData(private val pos: BlockPos, private val player: PlayerEntity, private val hand: Hand) : IFxData {
|
||||
override fun write(buffer: PacketBuffer) = buffer.use {
|
||||
writePos(pos)
|
||||
writeInt(player.entityId)
|
||||
writeByte(hand.ordinal)
|
||||
override fun write(buffer: PacketBuffer) {
|
||||
buffer.writePos(pos)
|
||||
buffer.writeInt(player.entityId)
|
||||
buffer.writeEnum(hand)
|
||||
}
|
||||
}
|
||||
|
||||
val FX_FAIL = object : IFxHandler<FxUseData> {
|
||||
override fun handle(buffer: PacketBuffer, world: World, rand: Random) = buffer.use {
|
||||
val blockPos = readPos().center
|
||||
override fun handle(buffer: PacketBuffer, world: World, rand: Random) {
|
||||
val blockPos = buffer.readPos().center
|
||||
|
||||
val player = world.getEntityByID(readInt()) as? PlayerEntity ?: return
|
||||
val hand = Hand.values().getOrNull(readByte().toInt()) ?: return
|
||||
val player = world.getEntityByID(buffer.readInt()) as? PlayerEntity ?: return
|
||||
val hand = buffer.readEnum<Hand>() ?: return
|
||||
|
||||
val handPos = ModelHelper.getHandPosition(player, hand)
|
||||
val startPoint = handPos.add(handPos.directionTowards(blockPos).scale(0.2))
|
||||
|
@ -25,8 +25,9 @@ import chylex.hee.init.ModSounds
|
||||
import chylex.hee.network.client.PacketClientFX
|
||||
import chylex.hee.system.heeTag
|
||||
import chylex.hee.system.heeTagOrNull
|
||||
import chylex.hee.util.buffer.readEnum
|
||||
import chylex.hee.util.buffer.readPos
|
||||
import chylex.hee.util.buffer.use
|
||||
import chylex.hee.util.buffer.writeEnum
|
||||
import chylex.hee.util.buffer.writePos
|
||||
import chylex.hee.util.nbt.getPos
|
||||
import chylex.hee.util.nbt.hasKey
|
||||
@ -145,17 +146,17 @@ object ItemTableLink : HeeItemBuilder() {
|
||||
}
|
||||
|
||||
class FxUseData(private val pos: BlockPos, private val type: SoundType) : IFxData {
|
||||
override fun write(buffer: PacketBuffer) = buffer.use {
|
||||
writePos(pos)
|
||||
writeByte(type.ordinal)
|
||||
override fun write(buffer: PacketBuffer) {
|
||||
buffer.writePos(pos)
|
||||
buffer.writeEnum(type)
|
||||
}
|
||||
}
|
||||
|
||||
val FX_USE = object : IFxHandler<FxUseData> {
|
||||
override fun handle(buffer: PacketBuffer, world: World, rand: Random) = buffer.use {
|
||||
val pos = readPos()
|
||||
override fun handle(buffer: PacketBuffer, world: World, rand: Random) {
|
||||
val pos = buffer.readPos()
|
||||
|
||||
when (SoundType.values().getOrNull(readByte().toInt())) {
|
||||
when (buffer.readEnum<SoundType>()) {
|
||||
LINK_SUCCESS -> ModSounds.ITEM_TABLE_LINK_USE_SUCCESS.playClient(pos, SoundCategory.PLAYERS, pitch = rand.nextFloat(0.49F, 0.51F))
|
||||
LINK_RESTART -> ModSounds.ITEM_TABLE_LINK_USE_SPECIAL.playClient(pos, SoundCategory.PLAYERS, pitch = rand.nextFloat(0.69F, 0.71F))
|
||||
LINK_OUTPUT -> ModSounds.ITEM_TABLE_LINK_USE_SPECIAL.playClient(pos, SoundCategory.PLAYERS, volume = 0.9F, pitch = 0.63F)
|
||||
|
@ -3,8 +3,7 @@ package chylex.hee.game.mechanics.instability.dimension
|
||||
import chylex.hee.game.mechanics.instability.dimension.components.EndermiteSpawnLogic
|
||||
import chylex.hee.util.math.ceilToInt
|
||||
import chylex.hee.util.math.floorToInt
|
||||
import chylex.hee.util.math.range
|
||||
import chylex.hee.util.math.remapRange
|
||||
import chylex.hee.util.math.remap
|
||||
import chylex.hee.util.nbt.TagCompound
|
||||
import chylex.hee.util.nbt.use
|
||||
import net.minecraft.util.math.BlockPos
|
||||
@ -27,7 +26,7 @@ open class DimensionInstabilityGlobal(private val world: World, private val ende
|
||||
|
||||
private fun calculateActionMultiplier(ticksSinceEndermiteSpawn: Long): Float {
|
||||
return if (ticksSinceEndermiteSpawn < 300L)
|
||||
remapRange(ticksSinceEndermiteSpawn.toFloat(), range(0F, 300F), range(0.2F, 1F))
|
||||
ticksSinceEndermiteSpawn.toFloat().remap(fromMin = 0F, fromMax = 300F, toMin = 0.2F, toMax = 1F)
|
||||
else
|
||||
1F
|
||||
}
|
||||
|
@ -5,7 +5,8 @@ import chylex.hee.game.mechanics.instability.region.IRegionEntryConstructor
|
||||
import chylex.hee.util.math.shlong
|
||||
import net.minecraft.util.math.BlockPos
|
||||
|
||||
inline class Entry5x5(override val compacted: Long) : IRegionEntry {
|
||||
@JvmInline
|
||||
value class Entry5x5(override val compacted: Long) : IRegionEntry {
|
||||
private companion object {
|
||||
private const val MASK_X = 0x00000_FFFFFL
|
||||
private const val MASK_Z = 0xFFFFF_00000L
|
||||
|
@ -17,7 +17,6 @@ import chylex.hee.game.world.util.getTile
|
||||
import chylex.hee.init.ModBlocks
|
||||
import chylex.hee.network.client.PacketClientFX
|
||||
import chylex.hee.util.buffer.readPos
|
||||
import chylex.hee.util.buffer.use
|
||||
import chylex.hee.util.buffer.writePos
|
||||
import chylex.hee.util.math.center
|
||||
import chylex.hee.util.math.directionTowards
|
||||
@ -45,24 +44,24 @@ class TableParticleHandler(private val table: TileEntityBaseTable) {
|
||||
private val PARTICLE_CLUSTER_MOT = InBox(0.004F)
|
||||
|
||||
class FxProcessPedestalsData(private val table: TileEntityBaseTable, private val targetPositions: List<BlockPos>, private val travelTime: Int) : IFxData {
|
||||
override fun write(buffer: PacketBuffer) = buffer.use {
|
||||
writePos(table.pos)
|
||||
writeByte(travelTime)
|
||||
writeByte(targetPositions.size)
|
||||
override fun write(buffer: PacketBuffer) {
|
||||
buffer.writePos(table.pos)
|
||||
buffer.writeByte(travelTime)
|
||||
buffer.writeByte(targetPositions.size)
|
||||
|
||||
for (pos in targetPositions) {
|
||||
writeLong(pos.toLong())
|
||||
buffer.writeLong(pos.toLong())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val FX_PROCESS_PEDESTALS = object : IFxHandler<FxProcessPedestalsData> {
|
||||
override fun handle(buffer: PacketBuffer, world: World, rand: Random) = buffer.use {
|
||||
val table = readPos().getTile<TileEntityBaseTable>(world) ?: return
|
||||
val travelTime = readByte().toInt()
|
||||
override fun handle(buffer: PacketBuffer, world: World, rand: Random) {
|
||||
val table = buffer.readPos().getTile<TileEntityBaseTable>(world) ?: return
|
||||
val travelTime = buffer.readByte().toInt()
|
||||
|
||||
repeat(readByte().toInt()) {
|
||||
val targetPos = readPos()
|
||||
repeat(buffer.readByte().toInt()) {
|
||||
val targetPos = buffer.readPos()
|
||||
|
||||
if (targetPos.getBlock(world) === ModBlocks.TABLE_PEDESTAL) {
|
||||
ParticleSpawnerCustom(
|
||||
@ -77,16 +76,16 @@ class TableParticleHandler(private val table: TileEntityBaseTable) {
|
||||
}
|
||||
|
||||
class FxDrainClusterData(private val table: TileEntityBaseTable, private val clusterPos: BlockPos) : IFxData {
|
||||
override fun write(buffer: PacketBuffer) = buffer.use {
|
||||
writePos(clusterPos)
|
||||
writePos(table.pos)
|
||||
override fun write(buffer: PacketBuffer) {
|
||||
buffer.writePos(clusterPos)
|
||||
buffer.writePos(table.pos)
|
||||
}
|
||||
}
|
||||
|
||||
val FX_DRAIN_CLUSTER = object : IFxHandler<FxDrainClusterData> {
|
||||
override fun handle(buffer: PacketBuffer, world: World, rand: Random) = buffer.use {
|
||||
val cluster = readPos().getTile<TileEntityEnergyCluster>(world) ?: return
|
||||
val table = readPos().getTile<TileEntityBaseTable>(world) ?: return
|
||||
override fun handle(buffer: PacketBuffer, world: World, rand: Random) {
|
||||
val cluster = buffer.readPos().getTile<TileEntityEnergyCluster>(world) ?: return
|
||||
val table = buffer.readPos().getTile<TileEntityBaseTable>(world) ?: return
|
||||
|
||||
val clusterPos = cluster.pos.center
|
||||
val tablePos = table.pos.center
|
||||
|
@ -9,7 +9,7 @@ import net.minecraft.item.crafting.SpecialRecipeSerializer
|
||||
abstract class RecipeBaseDynamic : ICraftingRecipe {
|
||||
private val serializer = SpecialRecipeSerializer { this }
|
||||
|
||||
final override fun getId() = serializer.registryName
|
||||
final override fun getId() = serializer.registryName!!
|
||||
final override fun getSerializer() = serializer
|
||||
|
||||
final override fun isDynamic() = true
|
||||
|
@ -27,8 +27,7 @@ import chylex.hee.util.math.Pos
|
||||
import chylex.hee.util.math.ceilToInt
|
||||
import chylex.hee.util.math.directionTowards
|
||||
import chylex.hee.util.math.floorToInt
|
||||
import chylex.hee.util.math.range
|
||||
import chylex.hee.util.math.remapRange
|
||||
import chylex.hee.util.math.remap
|
||||
import chylex.hee.util.math.square
|
||||
import chylex.hee.util.random.nextFloat
|
||||
import net.minecraft.entity.Entity
|
||||
@ -129,7 +128,6 @@ object TerritoryVoid {
|
||||
|
||||
private const val PLAYER_NEXT_DAMAGE_TIME_TAG = "VoidNextDamageTime"
|
||||
|
||||
private val FACTOR_DAMAGE_REMAP_FROM = range(0.5F, 3F)
|
||||
private val DAMAGE = Damage(DEAL_CREATIVE, IGNORE_INVINCIBILITY())
|
||||
|
||||
fun onWorldTick(world: ServerWorld) {
|
||||
@ -158,10 +156,10 @@ object TerritoryVoid {
|
||||
val nextDamageTime = getLong(PLAYER_NEXT_DAMAGE_TIME_TAG)
|
||||
|
||||
if (currentTime >= nextDamageTime) {
|
||||
val amount = remapRange(factor, FACTOR_DAMAGE_REMAP_FROM, range(2F, 6F)).ceilToInt().toFloat()
|
||||
val amount = factor.remap(fromMin = 0.5F, fromMax = 3F, toMin = 2F, toMax = 6F).ceilToInt().toFloat()
|
||||
|
||||
if (DAMAGE.dealTo(amount, entity, TITLE_WITHER)) {
|
||||
val cooldown = min(30, remapRange(factor, FACTOR_DAMAGE_REMAP_FROM, range(30F, 6F)).floorToInt())
|
||||
val cooldown = min(30, factor.remap(fromMin = 0.5F, fromMax = 3F, toMin = 30F, toMax = 6F).floorToInt())
|
||||
putLong(PLAYER_NEXT_DAMAGE_TIME_TAG, currentTime + cooldown)
|
||||
}
|
||||
}
|
||||
|
@ -30,8 +30,7 @@ import chylex.hee.util.math.Size
|
||||
import chylex.hee.util.math.component1
|
||||
import chylex.hee.util.math.component2
|
||||
import chylex.hee.util.math.component3
|
||||
import chylex.hee.util.math.range
|
||||
import chylex.hee.util.math.remapRange
|
||||
import chylex.hee.util.math.remap
|
||||
import chylex.hee.util.math.square
|
||||
import chylex.hee.util.math.xz
|
||||
import chylex.hee.util.random.RandomInt.Companion.Biased
|
||||
@ -122,9 +121,9 @@ object Generator_ForgottenTombs : ITerritoryGenerator {
|
||||
val noiseY = NoiseGenerator.OldPerlinNormalized(rand, scale = 48.0, octaves = 2)
|
||||
|
||||
for ((x, y, z) in BlockPos.ZERO.allInCenteredBoxMutable(RADIUS_XZ, RADIUS_Y, RADIUS_XZ)) {
|
||||
val normalizedY = remapRange(y.toFloat(), range(-radY, radY), range(0F, 1F))
|
||||
val normalizedY = y.toFloat().remap(fromMin = -radY, fromMax = radY, toMin = 0F, toMax = 1F)
|
||||
|
||||
val powerY = remapRange(sqrt(normalizedY), range(0F, 1F), range(4.8F, 1.6F))
|
||||
val powerY = sqrt(normalizedY).remap(fromMin = 0F, fromMax = 1F, toMin = 4.8F, toMax = 1.6F)
|
||||
val powerXZ = powerY * 0.8F
|
||||
|
||||
val corner = 1 + ((abs(x) + abs(z)) / (3F * radXZ)).pow(2F)
|
||||
|
@ -48,8 +48,7 @@ import chylex.hee.util.math.addY
|
||||
import chylex.hee.util.math.ceilToInt
|
||||
import chylex.hee.util.math.center
|
||||
import chylex.hee.util.math.floorToInt
|
||||
import chylex.hee.util.math.range
|
||||
import chylex.hee.util.math.remapRange
|
||||
import chylex.hee.util.math.remap
|
||||
import chylex.hee.util.math.scale
|
||||
import chylex.hee.util.math.scaleY
|
||||
import chylex.hee.util.math.square
|
||||
@ -208,7 +207,7 @@ object Generator_LostGarden : ITerritoryGenerator {
|
||||
}
|
||||
|
||||
val edgeMpXZ = if (distRatioXZ > 0.86)
|
||||
remapRange(distRatioXZ.coerceAtMost(1.0), range(0.86F, 1F), range(1F, 0.86F * noiseXZ.getRawValue(-x * 3, -z * 3).toFloat()))
|
||||
distRatioXZ.coerceAtMost(1.0).remap(fromMin = 0.86, fromMax = 1.0, toMin = 1.0, toMax = 0.86 * noiseXZ.getRawValue(-x * 3, -z * 3))
|
||||
else
|
||||
1.0
|
||||
|
||||
@ -218,10 +217,10 @@ object Generator_LostGarden : ITerritoryGenerator {
|
||||
}
|
||||
|
||||
val valueValley = 1.0 - noiseValley.getValue(x, z) {
|
||||
remap(range(0.5F, 1F), range(0F, 1F))
|
||||
remap(fromMin = 0.5, fromMax = 1.0, toMin = 0.0, toMax = 1.0)
|
||||
coerce()
|
||||
redistribute(0.5)
|
||||
remap(range(0F, 0.75F))
|
||||
remap(0.0, 0.75)
|
||||
|
||||
if (valueXZ < 0.6) {
|
||||
multiply(valueXZ / 0.6)
|
||||
@ -229,7 +228,7 @@ object Generator_LostGarden : ITerritoryGenerator {
|
||||
}
|
||||
|
||||
val valueThreshold = noiseThreshold.getValue(x, z) {
|
||||
remap(range(0.14F, 0.29F))
|
||||
remap(0.14, 0.29)
|
||||
}
|
||||
|
||||
val valueTotalXZ = valueXZ * valueValley
|
||||
@ -237,7 +236,7 @@ object Generator_LostGarden : ITerritoryGenerator {
|
||||
val edgeMpY = (0.5 - (1.0 - edgeMpXZ))
|
||||
val endersolY = -0.125 + (0.575 * noiseEndersol.getValue(x, z) {
|
||||
if (value > 0.6) {
|
||||
remap(range(0.6F, 1F), range(0.6F, 5F))
|
||||
remap(fromMin = 0.6, fromMax = 1.0, toMin = 0.6, toMax = 5.0)
|
||||
}
|
||||
})
|
||||
|
||||
@ -277,20 +276,20 @@ object Generator_LostGarden : ITerritoryGenerator {
|
||||
|
||||
private fun NoiseValue.distanceReshapeXZ(distance: Double) {
|
||||
value = when (distance) {
|
||||
in (0.00)..(0.40) -> value * remapRange(distance, range(0F, 0.4F), range(0.8F, 1F))
|
||||
in (0.00)..(0.40) -> value * distance.remap(fromMin = 0.0, fromMax = 0.4, toMin = 0.8, toMax = 1.0)
|
||||
in (0.40)..(0.85) -> value
|
||||
in (0.85)..(1.00) -> value * remapRange(distance, range(0.85F, 1F), range(1F, 0F))
|
||||
in (0.85)..(1.00) -> value * distance.remap(fromMin = 0.85, fromMax = 1.0, toMin = 1.0, toMax = 0.0)
|
||||
else -> 0.0
|
||||
}
|
||||
}
|
||||
|
||||
private fun NoiseValue.distanceReshapeY(distance: Double) {
|
||||
value = when (distance) {
|
||||
in (-1.0)..(-0.6) -> value * square(remapRange(distance, range(-1F, -0.5F), range(0F, 1F)))
|
||||
in (-1.0)..(-0.6) -> value * square(distance.remap(fromMin = -1.0, fromMax = -0.5, toMin = 0.0, toMax = 1.0))
|
||||
in (-0.6)..( 0.5) -> value
|
||||
in ( 0.5)..( 0.8) -> value * remapRange(distance, range(0.5F, 0.8F), range(1F, 0.5F))
|
||||
in ( 0.5)..( 0.8) -> value * distance.remap(fromMin = 0.5, fromMax = 0.8, toMin = 1.0, toMax = 0.5)
|
||||
in ( 0.8)..( 1.4) -> value * 0.5
|
||||
in ( 1.4)..( 2.0) -> value * remapRange(distance, range(1.4F, 2F), range(0.5F, 0.1F))
|
||||
in ( 1.4)..( 2.0) -> value * distance.remap(fromMin = 1.4, fromMax = 2.0, toMin = 0.5, toMax = 0.1)
|
||||
else -> 0.0
|
||||
}
|
||||
}
|
||||
|
@ -46,8 +46,7 @@ import chylex.hee.util.math.Vec
|
||||
import chylex.hee.util.math.ceilToInt
|
||||
import chylex.hee.util.math.center
|
||||
import chylex.hee.util.math.directionTowards
|
||||
import chylex.hee.util.math.range
|
||||
import chylex.hee.util.math.remapRange
|
||||
import chylex.hee.util.math.remap
|
||||
import chylex.hee.util.math.square
|
||||
import chylex.hee.util.math.toRadians
|
||||
import chylex.hee.util.random.RandomInt.Companion.Constant
|
||||
@ -338,7 +337,7 @@ object Generator_ObsidianTowers : ITerritoryGenerator {
|
||||
private fun generate(world: SegmentedWorld, rand: Random, island: Island, builder: ObsidianTowerBuilder) {
|
||||
island.generateBase(world, rand)
|
||||
island.generatePillars(world, rand, amount = (1 + island.radius).ceilToInt(), exclusionRadius = 8.0)
|
||||
builder.build(rand)?.generate(OffsetStructureWorld(world, island.center.subtract(ObsidianTowerPieces.STRUCTURE_SIZE.getPos(CENTER, MIN, CENTER))))
|
||||
builder.build(rand).generate(OffsetStructureWorld(world, island.center.subtract(ObsidianTowerPieces.STRUCTURE_SIZE.getPos(CENTER, MIN, CENTER))))
|
||||
}
|
||||
}
|
||||
|
||||
@ -415,7 +414,7 @@ object Generator_ObsidianTowers : ITerritoryGenerator {
|
||||
ENDIUM_ORES {
|
||||
override fun beforePillars(world: SegmentedWorld, rand: Random, island: Island) {
|
||||
val piles = if (island.radius >= 5.0)
|
||||
rand.nextRounded(remapRange(island.radius, range(5F, 7F), range(2F, 4F)).toFloat())
|
||||
rand.nextRounded(island.radius.toFloat().remap(fromMin = 5F, fromMax = 7F, toMin = 2F, toMax = 4F))
|
||||
else
|
||||
1
|
||||
|
||||
|
@ -43,8 +43,7 @@ import chylex.hee.util.math.addY
|
||||
import chylex.hee.util.math.ceilToInt
|
||||
import chylex.hee.util.math.center
|
||||
import chylex.hee.util.math.floorToInt
|
||||
import chylex.hee.util.math.range
|
||||
import chylex.hee.util.math.remapRange
|
||||
import chylex.hee.util.math.remap
|
||||
import chylex.hee.util.math.scale
|
||||
import chylex.hee.util.math.scaleY
|
||||
import chylex.hee.util.math.square
|
||||
@ -129,7 +128,7 @@ object Generator_TheHub : ITerritoryGenerator {
|
||||
redistribute(0.4)
|
||||
|
||||
ifNonZero {
|
||||
remap(range(0.2F, 1F))
|
||||
remap(0.2, 1.0)
|
||||
multiply(ELEVATION_BOTTOM)
|
||||
}
|
||||
}
|
||||
@ -155,7 +154,7 @@ object Generator_TheHub : ITerritoryGenerator {
|
||||
private fun NoiseValue.distanceReshape(distance: Double) {
|
||||
value = when (distance) {
|
||||
in (0.00)..(0.85) -> value
|
||||
in (0.85)..(1.00) -> value * remapRange(distance, range(0.85F, 1F), range(1F, 0F))
|
||||
in (0.85)..(1.00) -> value * distance.remap(fromMin = 0.85, fromMax = 1.0, toMin = 1.0, toMax = 0.0)
|
||||
else -> 0.0
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package chylex.hee.network.client
|
||||
|
||||
import chylex.hee.network.BaseClientPacket
|
||||
import chylex.hee.util.buffer.readFloatVec
|
||||
import chylex.hee.util.buffer.use
|
||||
import chylex.hee.util.buffer.writeFloatVec
|
||||
import chylex.hee.util.forge.Side
|
||||
import chylex.hee.util.forge.Sided
|
||||
@ -20,14 +19,14 @@ class PacketClientLaunchInstantly() : BaseClientPacket() {
|
||||
private var entityId: Int? = null
|
||||
private lateinit var motion: Vector3d
|
||||
|
||||
override fun write(buffer: PacketBuffer) = buffer.use {
|
||||
writeInt(entityId!!)
|
||||
writeFloatVec(motion)
|
||||
override fun write(buffer: PacketBuffer) {
|
||||
buffer.writeInt(entityId!!)
|
||||
buffer.writeFloatVec(motion)
|
||||
}
|
||||
|
||||
override fun read(buffer: PacketBuffer) = buffer.use {
|
||||
entityId = readInt()
|
||||
motion = readFloatVec()
|
||||
override fun read(buffer: PacketBuffer) {
|
||||
entityId = buffer.readInt()
|
||||
motion = buffer.readFloatVec()
|
||||
}
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
|
@ -2,7 +2,6 @@ package chylex.hee.network.client
|
||||
|
||||
import chylex.hee.network.BaseClientPacket
|
||||
import chylex.hee.util.buffer.readVec
|
||||
import chylex.hee.util.buffer.use
|
||||
import chylex.hee.util.buffer.writeVec
|
||||
import chylex.hee.util.forge.Side
|
||||
import chylex.hee.util.forge.Sided
|
||||
@ -17,12 +16,12 @@ class PacketClientMoveYourAss() : BaseClientPacket() {
|
||||
|
||||
private lateinit var position: Vector3d
|
||||
|
||||
override fun write(buffer: PacketBuffer) = buffer.use {
|
||||
writeVec(position)
|
||||
override fun write(buffer: PacketBuffer) {
|
||||
buffer.writeVec(position)
|
||||
}
|
||||
|
||||
override fun read(buffer: PacketBuffer) = buffer.use {
|
||||
position = readVec()
|
||||
override fun read(buffer: PacketBuffer) {
|
||||
position = buffer.readVec()
|
||||
}
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
|
@ -1,7 +1,6 @@
|
||||
package chylex.hee.network.client
|
||||
|
||||
import chylex.hee.network.BaseClientPacket
|
||||
import chylex.hee.util.buffer.use
|
||||
import chylex.hee.util.forge.Side
|
||||
import chylex.hee.util.forge.Sided
|
||||
import net.minecraft.client.entity.player.ClientPlayerEntity
|
||||
@ -17,14 +16,14 @@ class PacketClientPotionDuration() : BaseClientPacket() {
|
||||
private var effect: Effect? = null
|
||||
private var newDuration: Int? = null
|
||||
|
||||
override fun write(buffer: PacketBuffer) = buffer.use {
|
||||
writeRegistryId(effect!!)
|
||||
writeInt(newDuration!!)
|
||||
override fun write(buffer: PacketBuffer) {
|
||||
buffer.writeRegistryId(effect!!)
|
||||
buffer.writeInt(newDuration!!)
|
||||
}
|
||||
|
||||
override fun read(buffer: PacketBuffer) = buffer.use {
|
||||
effect = readRegistryIdSafe(Effect::class.java)
|
||||
newDuration = readInt()
|
||||
override fun read(buffer: PacketBuffer) {
|
||||
effect = buffer.readRegistryIdSafe(Effect::class.java)
|
||||
newDuration = buffer.readInt()
|
||||
}
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
|
@ -1,7 +1,6 @@
|
||||
package chylex.hee.network.client
|
||||
|
||||
import chylex.hee.network.BaseClientPacket
|
||||
import chylex.hee.util.buffer.use
|
||||
import chylex.hee.util.forge.Side
|
||||
import chylex.hee.util.forge.Sided
|
||||
import net.minecraft.client.entity.player.ClientPlayerEntity
|
||||
@ -20,16 +19,16 @@ class PacketClientRotateInstantly() : BaseClientPacket() {
|
||||
private var yaw: Float? = null
|
||||
private var pitch: Float? = null
|
||||
|
||||
override fun write(buffer: PacketBuffer) = buffer.use {
|
||||
writeInt(entityId!!)
|
||||
writeFloat(yaw!!)
|
||||
writeFloat(pitch!!)
|
||||
override fun write(buffer: PacketBuffer) {
|
||||
buffer.writeInt(entityId!!)
|
||||
buffer.writeFloat(yaw!!)
|
||||
buffer.writeFloat(pitch!!)
|
||||
}
|
||||
|
||||
override fun read(buffer: PacketBuffer) = buffer.use {
|
||||
entityId = readInt()
|
||||
yaw = readFloat()
|
||||
pitch = readFloat()
|
||||
override fun read(buffer: PacketBuffer) {
|
||||
entityId = buffer.readInt()
|
||||
yaw = buffer.readFloat()
|
||||
pitch = buffer.readFloat()
|
||||
}
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
|
@ -2,7 +2,6 @@ package chylex.hee.network.client
|
||||
|
||||
import chylex.hee.network.BaseClientPacket
|
||||
import chylex.hee.util.buffer.readVec
|
||||
import chylex.hee.util.buffer.use
|
||||
import chylex.hee.util.buffer.writeVec
|
||||
import chylex.hee.util.forge.Side
|
||||
import chylex.hee.util.forge.Sided
|
||||
@ -20,14 +19,14 @@ class PacketClientTeleportInstantly() : BaseClientPacket() {
|
||||
private var entityId: Int? = null
|
||||
private lateinit var position: Vector3d
|
||||
|
||||
override fun write(buffer: PacketBuffer) = buffer.use {
|
||||
writeInt(entityId!!)
|
||||
writeVec(position)
|
||||
override fun write(buffer: PacketBuffer) {
|
||||
buffer.writeInt(entityId!!)
|
||||
buffer.writeVec(position)
|
||||
}
|
||||
|
||||
override fun read(buffer: PacketBuffer) = buffer.use {
|
||||
entityId = readInt()
|
||||
position = readVec()
|
||||
override fun read(buffer: PacketBuffer) {
|
||||
entityId = buffer.readInt()
|
||||
position = buffer.readVec()
|
||||
}
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
|
@ -5,7 +5,6 @@ import chylex.hee.game.territory.storage.VoidData
|
||||
import chylex.hee.game.territory.system.storage.TerritoryEntry
|
||||
import chylex.hee.network.BaseClientPacket
|
||||
import chylex.hee.util.buffer.readTag
|
||||
import chylex.hee.util.buffer.use
|
||||
import chylex.hee.util.buffer.writeTag
|
||||
import chylex.hee.util.forge.Side
|
||||
import chylex.hee.util.forge.Sided
|
||||
@ -20,12 +19,12 @@ class PacketClientTerritoryEnvironment() : BaseClientPacket() {
|
||||
|
||||
private var void: TagCompound? = null
|
||||
|
||||
override fun write(buffer: PacketBuffer) = buffer.use {
|
||||
writeOptionalTag(void)
|
||||
override fun write(buffer: PacketBuffer) {
|
||||
buffer.writeOptionalTag(void)
|
||||
}
|
||||
|
||||
override fun read(buffer: PacketBuffer) = buffer.use {
|
||||
void = readOptionalTag()
|
||||
override fun read(buffer: PacketBuffer) {
|
||||
void = buffer.readOptionalTag()
|
||||
}
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
|
@ -4,7 +4,6 @@ import chylex.hee.client.util.MC
|
||||
import chylex.hee.game.item.interfaces.getHeeInterface
|
||||
import chylex.hee.game.mechanics.trinket.ITrinketItem
|
||||
import chylex.hee.network.BaseClientPacket
|
||||
import chylex.hee.util.buffer.use
|
||||
import chylex.hee.util.forge.Side
|
||||
import chylex.hee.util.forge.Sided
|
||||
import net.minecraft.client.entity.player.ClientPlayerEntity
|
||||
@ -22,14 +21,14 @@ class PacketClientTrinketBreak() : BaseClientPacket() {
|
||||
private var entityId: Int? = null
|
||||
private lateinit var item: Item
|
||||
|
||||
override fun write(buffer: PacketBuffer) = buffer.use {
|
||||
writeInt(entityId!!)
|
||||
writeInt(Item.getIdFromItem(item))
|
||||
override fun write(buffer: PacketBuffer) {
|
||||
buffer.writeInt(entityId!!)
|
||||
buffer.writeInt(Item.getIdFromItem(item))
|
||||
}
|
||||
|
||||
override fun read(buffer: PacketBuffer) = buffer.use {
|
||||
entityId = readInt()
|
||||
item = Item.getItemById(readInt())
|
||||
override fun read(buffer: PacketBuffer) {
|
||||
entityId = buffer.readInt()
|
||||
item = Item.getItemById(buffer.readInt())
|
||||
}
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
|
@ -1,7 +1,6 @@
|
||||
package chylex.hee.network.client
|
||||
|
||||
import chylex.hee.network.BaseClientPacket
|
||||
import chylex.hee.util.buffer.use
|
||||
import chylex.hee.util.forge.Side
|
||||
import chylex.hee.util.forge.Sided
|
||||
import net.minecraft.client.entity.player.ClientPlayerEntity
|
||||
@ -14,12 +13,12 @@ class PacketClientUpdateExperience() : BaseClientPacket() {
|
||||
|
||||
private var experience: Float? = null
|
||||
|
||||
override fun write(buffer: PacketBuffer) = buffer.use {
|
||||
writeFloat(experience!!)
|
||||
override fun write(buffer: PacketBuffer) {
|
||||
buffer.writeFloat(experience!!)
|
||||
}
|
||||
|
||||
override fun read(buffer: PacketBuffer) = buffer.use {
|
||||
experience = readFloat()
|
||||
override fun read(buffer: PacketBuffer) {
|
||||
experience = buffer.readFloat()
|
||||
}
|
||||
|
||||
@Sided(Side.CLIENT)
|
||||
|
@ -2,7 +2,6 @@ package chylex.hee.network.server
|
||||
|
||||
import chylex.hee.HEE
|
||||
import chylex.hee.network.BaseServerPacket
|
||||
import chylex.hee.util.buffer.use
|
||||
import net.minecraft.entity.player.ServerPlayerEntity
|
||||
import net.minecraft.network.PacketBuffer
|
||||
|
||||
@ -19,12 +18,12 @@ class PacketServerContainerEvent() : BaseServerPacket() {
|
||||
|
||||
private var eventId: Byte? = null
|
||||
|
||||
override fun write(buffer: PacketBuffer) = buffer.use {
|
||||
writeByte(eventId!!.toInt())
|
||||
override fun write(buffer: PacketBuffer) {
|
||||
buffer.writeByte(eventId!!.toInt())
|
||||
}
|
||||
|
||||
override fun read(buffer: PacketBuffer) = buffer.use {
|
||||
eventId = readByte()
|
||||
override fun read(buffer: PacketBuffer) {
|
||||
eventId = buffer.readByte()
|
||||
}
|
||||
|
||||
override fun handle(player: ServerPlayerEntity) {
|
||||
|
@ -7,7 +7,6 @@ import chylex.hee.game.item.interfaces.getHeeInterface
|
||||
import chylex.hee.game.mechanics.trinket.TrinketHandler
|
||||
import chylex.hee.init.ModContainers
|
||||
import chylex.hee.network.BaseServerPacket
|
||||
import chylex.hee.util.buffer.use
|
||||
import net.minecraft.entity.player.ServerPlayerEntity
|
||||
import net.minecraft.network.PacketBuffer
|
||||
|
||||
@ -18,12 +17,12 @@ class PacketServerOpenInventoryItem() : BaseServerPacket() {
|
||||
|
||||
private var slot: Int? = null
|
||||
|
||||
override fun write(buffer: PacketBuffer) = buffer.use {
|
||||
writeVarInt(slot!!)
|
||||
override fun write(buffer: PacketBuffer) {
|
||||
buffer.writeVarInt(slot!!)
|
||||
}
|
||||
|
||||
override fun read(buffer: PacketBuffer) = buffer.use {
|
||||
slot = readVarInt()
|
||||
override fun read(buffer: PacketBuffer) {
|
||||
slot = buffer.readVarInt()
|
||||
}
|
||||
|
||||
override fun handle(player: ServerPlayerEntity) {
|
||||
|
@ -2,7 +2,6 @@ package chylex.hee.network.server
|
||||
|
||||
import chylex.hee.game.container.slot.SlotTrinketItemInventory
|
||||
import chylex.hee.network.BaseServerPacket
|
||||
import chylex.hee.util.buffer.use
|
||||
import net.minecraft.entity.player.ServerPlayerEntity
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.network.PacketBuffer
|
||||
@ -14,12 +13,12 @@ class PacketServerShiftClickTrinket() : BaseServerPacket() {
|
||||
|
||||
private var sourceSlot: Int? = null
|
||||
|
||||
override fun write(buffer: PacketBuffer) = buffer.use {
|
||||
writeInt(sourceSlot!!)
|
||||
override fun write(buffer: PacketBuffer) {
|
||||
buffer.writeInt(sourceSlot!!)
|
||||
}
|
||||
|
||||
override fun read(buffer: PacketBuffer) = buffer.use {
|
||||
sourceSlot = readInt()
|
||||
override fun read(buffer: PacketBuffer) {
|
||||
sourceSlot = buffer.readInt()
|
||||
}
|
||||
|
||||
override fun handle(player: ServerPlayerEntity) {
|
||||
|
Loading…
Reference in New Issue
Block a user