1
0
mirror of https://github.com/chylex/Hardcore-Ender-Expansion-2.git synced 2025-07-04 22:38:55 +02:00
Hardcore-Ender-Expansion-2/.idea/shelf/Later/shelved.patch
2021-01-15 18:42:49 +01:00

37 lines
16 KiB
Diff

Index: src/main/java/chylex/hee/network/client/PacketClientRotateInstantly.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
<+>package chylex.hee.network.client\r\nimport chylex.hee.network.BaseClientPacket\r\nimport chylex.hee.system.migration.forge.Side\r\nimport chylex.hee.system.migration.forge.Sided\r\nimport chylex.hee.system.migration.vanilla.EntityLivingBase\r\nimport chylex.hee.system.migration.vanilla.EntityPlayerSP\r\nimport chylex.hee.system.util.use\r\nimport net.minecraft.entity.Entity\r\nimport net.minecraft.network.PacketBuffer\r\n\r\nclass PacketClientRotateInstantly() : BaseClientPacket(){\r\n\tconstructor(entity: Entity, yaw: Float, pitch: Float) : this(){\r\n\t\tthis.entityId = entity.entityId\r\n\t\tthis.yaw = yaw\r\n\t\tthis.pitch = pitch\r\n\t}\r\n\t\r\n\tprivate var entityId: Int? = null\r\n\tprivate var yaw: Float? = null\r\n\tprivate var pitch: Float? = null\r\n\t\r\n\toverride fun write(buffer: PacketBuffer) = buffer.use {\r\n\t\twriteInt(entityId!!)\r\n\t\twriteFloat(yaw!!)\r\n\t\twriteFloat(pitch!!)\r\n\t}\r\n\t\r\n\toverride fun read(buffer: PacketBuffer) = buffer.use {\r\n\t\tentityId = readInt()\r\n\t\tyaw = readFloat()\r\n\t\tpitch = readFloat()\r\n\t}\r\n\t\r\n\t@Sided(Side.CLIENT)\r\n\toverride fun handle(player: EntityPlayerSP){\r\n\t\tentityId?.let(player.world::getEntityByID)?.let {\r\n\t\t\tit.setPositionAndRotation(it.posX, it.posY, it.posZ, yaw!!, pitch!!)\r\n\t\t\tit.setRenderYawOffset(yaw!!)\r\n\t\t\tit.rotationYawHead = yaw!!\r\n\t\t\t\r\n\t\t\tif (it is EntityLivingBase){\r\n\t\t\t\tit.prevRenderYawOffset = it.renderYawOffset\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/main/java/chylex/hee/network/client/PacketClientRotateInstantly.kt (revision 41aa0b6695a1ac98e2d75beae7cb260618fe1f25)
+++ src/main/java/chylex/hee/network/client/PacketClientRotateInstantly.kt (date 1579529026808)
@@ -41,6 +41,8 @@
if (it is EntityLivingBase){
it.prevRenderYawOffset = it.renderYawOffset
}
+
+ // UPDATE would this fix some weirdness? it.setPositionAndRotationDirect(it.posX, it.posY, it.posZ, it.rotationYaw, it.rotationPitch, 0, true)
}
}
}
Index: src/main/java/chylex/hee/game/entity/living/behavior/EndermanTeleportHandler.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
<+>package chylex.hee.game.entity.living.behavior\r\nimport chylex.hee.game.entity.living.EntityMobAbstractEnderman\r\nimport chylex.hee.game.fx.FxEntityData\r\nimport chylex.hee.game.fx.FxEntityHandler\r\nimport chylex.hee.game.particle.ParticleFadingSpot\r\nimport chylex.hee.game.particle.ParticleTeleport\r\nimport chylex.hee.game.particle.spawner.ParticleSpawnerCustom\r\nimport chylex.hee.game.particle.util.IOffset.Constant\r\nimport chylex.hee.game.particle.util.IOffset.Gaussian\r\nimport chylex.hee.game.particle.util.IOffset.InBox\r\nimport chylex.hee.game.particle.util.IShape.Line\r\nimport chylex.hee.game.particle.util.IShape.Point\r\nimport chylex.hee.game.world.util.Teleporter\r\nimport chylex.hee.game.world.util.Teleporter.Companion.FxTeleportData\r\nimport chylex.hee.game.world.util.Teleporter.FxRange.Extended\r\nimport chylex.hee.game.world.util.Teleporter.FxRange.Silent\r\nimport chylex.hee.network.client.PacketClientFX\r\nimport chylex.hee.system.migration.Facing.DOWN\r\nimport chylex.hee.system.migration.Facing.UP\r\nimport chylex.hee.system.migration.vanilla.Potions\r\nimport chylex.hee.system.migration.vanilla.Sounds\r\nimport chylex.hee.system.util.Pos\r\nimport chylex.hee.system.util.TagCompound\r\nimport chylex.hee.system.util.Vec3\r\nimport chylex.hee.system.util.addY\r\nimport chylex.hee.system.util.blocksMovement\r\nimport chylex.hee.system.util.color.IntColor.Companion.RGB\r\nimport chylex.hee.system.util.component1\r\nimport chylex.hee.system.util.component2\r\nimport chylex.hee.system.util.component3\r\nimport chylex.hee.system.util.directionTowards\r\nimport chylex.hee.system.util.floorToInt\r\nimport chylex.hee.system.util.isLoaded\r\nimport chylex.hee.system.util.makeEffect\r\nimport chylex.hee.system.util.motionX\r\nimport chylex.hee.system.util.motionZ\r\nimport chylex.hee.system.util.nextFloat\r\nimport chylex.hee.system.util.nextInt\r\nimport chylex.hee.system.util.nextVector2\r\nimport chylex.hee.system.util.offsetUntil\r\nimport chylex.hee.system.util.playClient\r\nimport chylex.hee.system.util.posVec\r\nimport chylex.hee.system.util.toRadians\r\nimport chylex.hee.system.util.use\r\nimport net.minecraft.entity.Entity\r\nimport net.minecraft.util.SoundCategory\r\nimport net.minecraft.util.math.AxisAlignedBB\r\nimport net.minecraft.util.math.BlockPos\r\nimport net.minecraft.util.math.Vec3d\r\nimport net.minecraftforge.common.util.INBTSerializable\r\nimport java.util.Random\r\nimport java.util.UUID\r\nimport kotlin.math.min\r\n\r\nclass EndermanTeleportHandler(private val enderman: EntityMobAbstractEnderman) : INBTSerializable<TagCompound>{\r\n\tcompanion object{\r\n\t\tprivate const val DEFAULT_RESTORE_Y = -256.0\r\n\t\t\r\n\t\tprivate const val COOLDOWN_TAG = \"Cooldown\"\r\n\t\tprivate const val DELAY_TICKS_TAG = \"DelayTicks\"\r\n\t\t\r\n\t\tprivate val TELEPORTER_GENERAL = Teleporter(resetFall = true, causedInstability = 15u, effectRange = Extended(16F))\r\n\t\tprivate val TELEPORTER_SILENT = Teleporter(resetFall = true, causedInstability = 15u, effectRange = Silent)\r\n\t\tprivate val TELEPORTER_WEAK = Teleporter(resetFall = false, resetPathfinding = false)\r\n\t\t\r\n\t\tprivate fun PARTICLE_TELEPORT_FAIL(target: Entity) = ParticleSpawnerCustom(\r\n\t\t\ttype = ParticleFadingSpot,\r\n\t\t\tdata = ParticleFadingSpot.Data(color = RGB(40u), lifespan = 20..32, scale = (0.08F)..(0.12F)),\r\n\t\t\tpos = InBox(target, 0.33F),\r\n\t\t\tmot = Constant(0.012F, UP) + Gaussian(0.008F)\r\n\t\t)\r\n\t\t\r\n\t\tprivate val PARTICLE_TELEPORT_OUT_OF_WORLD = ParticleSpawnerCustom(\r\n\t\t\ttype = ParticleTeleport,\r\n\t\t\tpos = InBox(0.1F, 0.25F, 0.1F),\r\n\t\t\tmot = InBox(0.05F),\r\n\t\t\tmaxRange = 64.0,\r\n\t\t\thideOnMinimalSetting = false\r\n\t\t)\r\n\t\t\r\n\t\tval FX_TELEPORT_FAIL = object : FxEntityHandler(){\r\n\t\t\toverride fun handle(entity: Entity, rand: Random){\r\n\t\t\t\tPARTICLE_TELEPORT_FAIL(entity).spawn(Point(entity, heightMp = 0.5F, amount = 55), rand)\r\n\t\t\t\tSounds.ENTITY_ENDERMAN_TELEPORT.playClient(entity.posVec, SoundCategory.HOSTILE, volume = 0.75F) // TODO custom sound\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\tval FX_TELEPORT_OUT_OF_WORLD = object : FxEntityHandler(){\r\n\t\t\toverride fun handle(entity: Entity, rand: Random){\r\n\t\t\t\tval startPoint = entity.posVec\r\n\t\t\t\tval endPoint = startPoint.addY(256.0)\r\n\t\t\t\t\r\n\t\t\t\tPARTICLE_TELEPORT_OUT_OF_WORLD.spawn(Line(startPoint, endPoint, 0.5), rand)\r\n\t\t\t\tSounds.ENTITY_ENDERMAN_TELEPORT.playClient(startPoint, SoundCategory.HOSTILE, volume = 2F) // TODO custom sound\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\tprivate fun sendDelayedTeleportFX(entity: Entity){\r\n\t\t\tval point = entity.posVec.addY(entity.height.toDouble())\r\n\t\t\tFxTeleportData(point, point, entity.width, entity.height, entity.soundCategory, soundVolume = 0.8F).send(entity.world)\r\n\t\t}\r\n\t}\r\n\t\r\n\tprivate val world = enderman.world\r\n\tprivate val rand = enderman.rng\r\n\t\r\n\tprivate var tpCooldown = 0\r\n\tprivate var failCooldown: Byte = 0\r\n\t\r\n\tprivate var tpDelayTicks = 0\r\n\tprivate var tpDelayedReappearing = false\r\n\tprivate var tpDelayedCallback: (() -> Boolean)? = null\r\n\tprivate var tpDelayRestoreY = DEFAULT_RESTORE_Y\r\n\t\r\n\tprivate var lastDodged: UUID? = null\r\n\t\r\n\tfun update(){\r\n\t\tif (tpCooldown > 0){\r\n\t\t\t--tpCooldown\r\n\t\t}\r\n\t\t\r\n\t\tif (failCooldown > 0){\r\n\t\t\t--failCooldown\r\n\t\t}\r\n\t\t\r\n\t\tif (tpDelayTicks > 0 && --tpDelayTicks == 0){\r\n\t\t\tenderman.setNoAI(false)\r\n\t\t\tenderman.setPositionAndUpdate(enderman.posX, tpDelayRestoreY, enderman.posZ)\r\n\t\t\t\r\n\t\t\ttpDelayedReappearing = true\r\n\t\t\t\r\n\t\t\tif (tpDelayedCallback?.invoke() != true){\r\n\t\t\t\tenderman.remove()\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\ttpDelayedReappearing = false\r\n\t\t\ttpDelayedCallback = null\r\n\t\t\ttpDelayRestoreY = DEFAULT_RESTORE_Y\r\n\t\t}\r\n\t}\r\n\t\r\n\t// Helpers\r\n\t\r\n\tfun checkCooldownSilent(): Boolean{\r\n\t\treturn tpCooldown == 0 && tpDelayTicks == 0\r\n\t}\r\n\t\r\n\tprivate fun checkCooldown(): Boolean{\r\n\t\tif (tpDelayTicks > 0){\r\n\t\t\treturn false\r\n\t\t}\r\n\t\t\r\n\t\tif (tpCooldown == 0){\r\n\t\t\treturn true\r\n\t\t}\r\n\t\t\r\n\t\tif (failCooldown == 0.toByte()){\r\n\t\t\tPacketClientFX(FX_TELEPORT_FAIL, FxEntityData(enderman)).sendToAllAround(enderman, 16.0)\r\n\t\t\tfailCooldown = rand.nextInt(26, 34).toByte()\r\n\t\t}\r\n\t\t\r\n\t\treturn false\r\n\t}\r\n\t\r\n\tprivate fun checkPositionSuitable(target: Vec3d): Boolean{\r\n\t\tval pos = Pos(target)\r\n\t\t\r\n\t\tif (!pos.isLoaded(world) || !pos.down().blocksMovement(world)){\r\n\t\t\treturn false\r\n\t\t}\r\n\t\t\r\n\t\tval (x, y, z) = target\r\n\t\tval hw = enderman.width * 0.5F\r\n\t\t\r\n\t\tval aabb = AxisAlignedBB(\r\n\t\t\tx - hw,\r\n\t\t\ty,\r\n\t\t\tz - hw,\r\n\t\t\tx + hw,\r\n\t\t\ty + enderman.height,\r\n\t\t\tz + hw\r\n\t\t)\r\n\t\t\r\n\t\treturn enderman.canTeleportTo(aabb)\r\n\t}\r\n\t\r\n\tprivate fun teleportCheckLocation(teleporter: Teleporter, target: Vec3d): Boolean{\r\n\t\treturn checkPositionSuitable(target) && teleporter.toLocation(enderman, target)\r\n\t}\r\n\t\r\n\tprivate fun getPositionInsideBlock(target: BlockPos): Vec3d{\r\n\t\tval xzMaxOffset = 0.5F - (enderman.width * 0.5F)\r\n\t\t\r\n\t\treturn Vec3d(\r\n\t\t\ttarget.x + 0.5 + rand.nextFloat(-xzMaxOffset, xzMaxOffset),\r\n\t\t\ttarget.y.toDouble(),\r\n\t\t\ttarget.z + 0.5 + rand.nextFloat(-xzMaxOffset, xzMaxOffset)\r\n\t\t)\r\n\t}\r\n\t\r\n\tprivate fun findTop(target: BlockPos, maxDecreaseY: Int): BlockPos?{\r\n\t\treturn target.offsetUntil(DOWN, 0..maxDecreaseY){ it.blocksMovement(world) }?.up()\r\n\t}\r\n\t\r\n\t// General teleports\r\n\t\r\n\tfun teleportTo(target: Vec3d): Boolean{\r\n\t\tif (!checkCooldown()){\r\n\t\t\treturn false\r\n\t\t}\r\n\t\t\r\n\t\tif (tpDelayedReappearing){\r\n\t\t\tif (teleportCheckLocation(TELEPORTER_SILENT, target)){\r\n\t\t\t\tsendDelayedTeleportFX(enderman)\r\n\t\t\t\ttpDelayedReappearing = false\r\n\t\t\t\t\r\n\t\t\t\ttpCooldown = enderman.teleportCooldown\r\n\t\t\t\treturn true\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\treturn false\r\n\t\t}\r\n\t\t\r\n\t\tif (teleportCheckLocation(TELEPORTER_GENERAL, target)){\r\n\t\t\ttpCooldown = enderman.teleportCooldown\r\n\t\t\treturn true\r\n\t\t}\r\n\t\t\r\n\t\treturn false\r\n\t}\r\n\t\r\n\tfun teleportTo(target: BlockPos): Boolean{\r\n\t\treturn teleportTo(getPositionInsideBlock(target))\r\n\t}\r\n\t\r\n\tfun teleportAround(target: Entity, angleRange: ClosedFloatingPointRange<Float>, distanceRange: ClosedFloatingPointRange<Double>): Boolean{\r\n\t\tif (!checkCooldown()){\r\n\t\t\treturn false\r\n\t\t}\r\n\t\t\r\n\t\tval targetVec = target.posVec\r\n\t\t\r\n\t\tfor(attempt in 1..50){\r\n\t\t\tval dir = Vec3.fromYaw(target.rotationYaw + rand.nextFloat(angleRange))\r\n\t\t\tval distance = rand.nextFloat(distanceRange)\r\n\t\t\t\r\n\t\t\tval offsetVec = targetVec.add(dir.scale(distance))\r\n\t\t\tval targetPos = findTop(Pos(offsetVec).add(0, rand.nextInt(-4, 8), 0), maxDecreaseY = 4)\r\n\t\t\t\r\n\t\t\tif (targetPos != null && teleportTo(targetPos)){\r\n\t\t\t\treturn true\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\treturn false\r\n\t}\r\n\t\r\n\tfun teleportRandom(distanceRange: ClosedFloatingPointRange<Double>): Boolean{\r\n\t\tif (!checkCooldown()){\r\n\t\t\treturn false\r\n\t\t}\r\n\t\t\r\n\t\tval endermanPos = Pos(enderman)\r\n\t\t\r\n\t\tfor(attempt in 1..25){\r\n\t\t\tval (x, y, z) = rand.nextVector2(xz = rand.nextFloat(distanceRange), y = rand.nextFloat(-24.0, 48.0))\r\n\t\t\tval targetPos = findTop(endermanPos.add(x, y, z), maxDecreaseY = 24)\r\n\t\t\t\r\n\t\t\tif (targetPos != null && teleportTo(targetPos)){\r\n\t\t\t\treturn true\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\treturn false\r\n\t}\r\n\t\r\n\t// Special teleports\r\n\t\r\n\tfun teleportDelayed(delayTicks: Int, callback: () -> Boolean): Boolean{\r\n\t\tif (enderman.isAIDisabled || !checkCooldown()){\r\n\t\t\treturn false\r\n\t\t}\r\n\t\t\r\n\t\tsendDelayedTeleportFX(enderman)\r\n\t\t\r\n\t\ttpDelayTicks = delayTicks\r\n\t\ttpDelayedCallback = callback\r\n\t\ttpDelayRestoreY = enderman.posY\r\n\t\t\r\n\t\tenderman.setNoAI(true)\r\n\t\tenderman.addPotionEffect(Potions.INVISIBILITY.makeEffect(delayTicks, enderman.getActivePotionEffect(Potions.INVISIBILITY)?.amplifier ?: 0, isAmbient = true, showParticles = false))\r\n\t\tenderman.setPositionAndUpdate(enderman.posX, 4095.0, enderman.posZ)\r\n\t\t\r\n\t\treturn true\r\n\t}\r\n\t\r\n\tfun teleportDodge(dodge: Entity): Boolean{\r\n\t\tval uuid = dodge.uniqueID\r\n\t\t\r\n\t\tif (uuid == lastDodged){\r\n\t\t\treturn false\r\n\t\t}\r\n\t\t\r\n\t\tval endermanPos = enderman.posVec\r\n\t\tval dodgePos = dodge.posVec\r\n\t\t\r\n\t\tval perpendicularVec = Vec3.fromXZ(-dodge.motionZ, dodge.motionX).normalize()\r\n\t\tval dodgeDist = (enderman.width * 0.75) + (dodge.width * 0.75) + 0.25\r\n\t\t\r\n\t\tval dir = maxOf(-1, 1, compareBy {\r\n\t\t\tendermanPos.add(perpendicularVec.scale(it * dodgeDist)).squareDistanceTo(dodgePos) + (rand.nextDouble() * 0.1)\r\n\t\t})\r\n\t\t\r\n\t\tfor(attempt in 1..3){\r\n\t\t\tval basePos = endermanPos\r\n\t\t\t\t.add(perpendicularVec.scale(dir * rand.nextFloat(dodgeDist, dodgeDist + 0.4))\r\n\t\t\t\t.add(rand.nextVector2(xz = rand.nextFloat(0.0, 0.15), y = 1.5)))\r\n\t\t\t\r\n\t\t\tfor(offset in 0..2){\r\n\t\t\t\tval targetPos = Vec3d(basePos.x, basePos.y.floorToInt() - offset + 0.01, basePos.z)\r\n\t\t\t\t\r\n\t\t\t\tif (teleportCheckLocation(TELEPORTER_WEAK, targetPos)){\r\n\t\t\t\t\tlastDodged = uuid\r\n\t\t\t\t\treturn true\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\treturn false\r\n\t}\r\n\t\r\n\tfun teleportTowards(target: Entity, angleRange: ClosedFloatingPointRange<Float>, distanceRange: ClosedFloatingPointRange<Double>): Boolean{\r\n\t\tif (!checkCooldown()){\r\n\t\t\treturn false\r\n\t\t}\r\n\t\t\r\n\t\tval endermanVec = enderman.posVec\r\n\t\tval diffVec = endermanVec.directionTowards(target.posVec)\r\n\t\t\r\n\t\tfor(attempt in 1..50){\r\n\t\t\tval dir = diffVec.rotateYaw(rand.nextFloat(angleRange).toRadians())\r\n\t\t\tval distance = rand.nextFloat(distanceRange)\r\n\t\t\t\r\n\t\t\tval offsetVec = endermanVec.add(dir.scale(distance))\r\n\t\t\tval targetPos = findTop(Pos(offsetVec).add(0, rand.nextInt(-4, 8), 0), maxDecreaseY = 4)\r\n\t\t\t\r\n\t\t\tif (targetPos != null && teleportCheckLocation(TELEPORTER_WEAK, getPositionInsideBlock(targetPos))){\r\n\t\t\t\treturn true\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\treturn false\r\n\t}\r\n\t\r\n\tfun teleportOutOfWorld(force: Boolean = false): Boolean{\r\n\t\tif (!force && !checkCooldown()){\r\n\t\t\treturn false\r\n\t\t}\r\n\t\t\r\n\t\tPacketClientFX(FX_TELEPORT_OUT_OF_WORLD, FxEntityData(enderman)).sendToAllAround(enderman, 64.0)\r\n\t\tenderman.remove()\r\n\t\treturn true\r\n\t}\r\n\t\r\n\t// Serialization\r\n\t\r\n\toverride fun serializeNBT() = TagCompound().apply {\r\n\t\tputShort(COOLDOWN_TAG, tpCooldown.toShort())\r\n\t\tputShort(DELAY_TICKS_TAG, tpDelayTicks.toShort())\r\n\t}\r\n\t\r\n\toverride fun deserializeNBT(nbt: TagCompound) = nbt.use {\r\n\t\ttpCooldown = getShort(COOLDOWN_TAG).toInt()\r\n\t\ttpDelayTicks = min(1, getShort(DELAY_TICKS_TAG).toInt())\r\n\t}\r\n}\r\n
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/main/java/chylex/hee/game/entity/living/behavior/EndermanTeleportHandler.kt (revision 41aa0b6695a1ac98e2d75beae7cb260618fe1f25)
+++ src/main/java/chylex/hee/game/entity/living/behavior/EndermanTeleportHandler.kt (date 1579529026806)
@@ -61,7 +61,7 @@
private val TELEPORTER_GENERAL = Teleporter(resetFall = true, causedInstability = 15u, effectRange = Extended(16F))
private val TELEPORTER_SILENT = Teleporter(resetFall = true, causedInstability = 15u, effectRange = Silent)
- private val TELEPORTER_WEAK = Teleporter(resetFall = false, resetPathfinding = false)
+ private val TELEPORTER_WEAK = Teleporter(resetFall = false, resetPathfinding = false) // UPDATE figure out why the fuck mobs just rotate in place
private fun PARTICLE_TELEPORT_FAIL(target: Entity) = ParticleSpawnerCustom(
type = ParticleFadingSpot,