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