1
0
mirror of https://github.com/chylex/Hardcore-Ender-Expansion-2.git synced 2025-04-11 03:15:44 +02:00

Add method renames (world time, entity attributes)

This commit is contained in:
chylex 2019-10-07 10:29:28 +02:00
parent 2d1b12d6c4
commit d2a8717c4b
57 changed files with 201 additions and 125 deletions

View File

@ -8,6 +8,7 @@ import chylex.hee.system.migration.forge.Side
import chylex.hee.system.migration.forge.Sided
import chylex.hee.system.util.getStack
import chylex.hee.system.util.isNotEmpty
import chylex.hee.system.util.totalTime
import net.minecraft.client.gui.inventory.GuiBrewingStand
import net.minecraft.entity.player.InventoryPlayer
@ -18,7 +19,7 @@ class GuiBrewingStandCustom(inventory: InventoryPlayer, private val brewingStand
private val BUBBLE_LENGTHS = intArrayOf(0, 6, 11, 16, 20, 24, 29)
}
private var brewStartTime = brewingStand.world.totalWorldTime
private var brewStartTime = brewingStand.world.totalTime
init{
inventorySlots = ContainerBrewingStandCustom(inventory, brewingStand)
@ -32,7 +33,7 @@ class GuiBrewingStandCustom(inventory: InventoryPlayer, private val brewingStand
MC.textureManager.bindTexture(TEX_BACKGROUND)
drawTexturedModalRect(x, y, 0, 0, xSize, ySize)
val worldTime = brewingStand.world.totalWorldTime
val worldTime = brewingStand.world.totalTime
val brewTime = brewingStand.brewTime
if (brewTime > 0){

View File

@ -6,6 +6,7 @@ import chylex.hee.game.entity.living.EntityMobAbstractEnderman
import chylex.hee.system.migration.forge.Side
import chylex.hee.system.migration.forge.Sided
import chylex.hee.system.util.nextFloat
import chylex.hee.system.util.totalTime
import net.minecraft.client.renderer.entity.RenderEnderman
import net.minecraft.client.renderer.entity.RenderManager
import net.minecraft.entity.monster.EntityEnderman
@ -22,7 +23,7 @@ open class RenderEntityMobAbstractEnderman(manager: RenderManager) : RenderEnder
}
if (entity.isShaking){
rand.setSeed(entity.world.totalWorldTime)
rand.setSeed(entity.world.totalTime)
super.doRender(entity, x + (rand.nextGaussian() * 0.01), y + (rand.nextGaussian() * 0.01), z + (rand.nextGaussian() * 0.01), rotationYaw, partialTicks)
}
else{
@ -30,7 +31,7 @@ open class RenderEntityMobAbstractEnderman(manager: RenderManager) : RenderEnder
}
if (entity.isAggressive){
rand.setSeed(entity.world.totalWorldTime * 2L / 3L)
rand.setSeed(entity.world.totalTime * 2L / 3L)
val prevPrevYaw = entity.prevRotationYawHead
val prevYaw = entity.rotationYawHead

View File

@ -3,6 +3,7 @@ import chylex.hee.client.render.util.GL
import chylex.hee.game.entity.living.EntityMobVillagerDying
import chylex.hee.system.migration.forge.Side
import chylex.hee.system.migration.forge.Sided
import chylex.hee.system.util.totalTime
import net.minecraft.client.model.ModelVillager
import net.minecraft.client.renderer.entity.RenderLiving
import net.minecraft.client.renderer.entity.RenderManager
@ -15,7 +16,7 @@ class RenderEntityMobVillagerDying(manager: RenderManager) : RenderLiving<Entity
private val rand = Random()
override fun doRender(entity: EntityMobVillagerDying, x: Double, y: Double, z: Double, rotationYaw: Float, partialTicks: Float){
rand.setSeed(entity.world.totalWorldTime)
rand.setSeed(entity.world.totalTime)
val mp = min(1F, entity.deathTime / 50F) * 0.005F
super.doRender(entity, x + (rand.nextGaussian() * mp), y + (rand.nextGaussian() * mp), z + (rand.nextGaussian() * mp), rotationYaw, partialTicks)

View File

@ -16,6 +16,7 @@ import chylex.hee.system.util.getOrCreateCompound
import chylex.hee.system.util.getState
import chylex.hee.system.util.heeTag
import chylex.hee.system.util.setBlock
import chylex.hee.system.util.totalTime
import net.minecraft.block.material.MapColor
import net.minecraft.block.material.Material
import net.minecraft.block.state.IBlockState
@ -98,7 +99,7 @@ abstract class BlockAbstractGoo(private val fluid: FluidBase, material: Material
* it is enough to compare if either the world time or the entity has changed since last call (on the same thread)
*/
val currentWorldTime = world.totalWorldTime
val currentWorldTime = world.totalTime
if (lastCollidingEntity.get()?.takeUnless { it.first != currentWorldTime || it.second != entity.uniqueID } == null){
lastCollidingEntity.set(Pair(currentWorldTime, entity.uniqueID))
@ -132,7 +133,7 @@ abstract class BlockAbstractGoo(private val fluid: FluidBase, material: Material
protected fun trackTick(entity: Entity, maxTicks: Int): Int{
val world = entity.world
val currentWorldTime = world.totalWorldTime
val currentWorldTime = world.totalTime
with(entity.heeTag.getOrCreateCompound(tickTrackingKey)){
val lastWorldTime = getLongOrNull(LAST_TIME_TAG) ?: (currentWorldTime - 1)

View File

@ -23,6 +23,7 @@ import chylex.hee.system.util.get
import chylex.hee.system.util.nextInt
import chylex.hee.system.util.nextItemOrNull
import chylex.hee.system.util.setState
import chylex.hee.system.util.totalTime
import chylex.hee.system.util.with
import net.minecraft.block.state.IBlockState
import net.minecraft.entity.Entity
@ -72,7 +73,7 @@ open class BlockEnderGooPurified : BlockAbstractGoo(FluidEnderGooPurified, Mater
// Status effects
private fun updateGooEffects(entity: EntityLivingBase, totalTicks: Int){
val currentTime = entity.world.totalWorldTime
val currentTime = entity.world.totalTime
val rand = entity.rng
if (totalTicks > 25 && currentTime % 40L == 0L){

View File

@ -22,6 +22,7 @@ import chylex.hee.system.util.playServer
import chylex.hee.system.util.posVec
import chylex.hee.system.util.setState
import chylex.hee.system.util.toYaw
import chylex.hee.system.util.totalTime
import chylex.hee.system.util.with
import net.minecraft.block.Block
import net.minecraft.block.BlockDirt
@ -140,11 +141,11 @@ class BlockGraveDirt(builder: BlockBuilder) : BlockSimpleShaped(builder, AxisAli
@Sided(Side.CLIENT)
override fun randomDisplayTick(state: IBlockState, world: World, pos: BlockPos, rand: Random){
if (state[TYPE] == SPIDERLING && world.difficulty != PEACEFUL && world.totalWorldTime - clientLastSpiderlingSound > 35L){
if (state[TYPE] == SPIDERLING && world.difficulty != PEACEFUL && world.totalTime - clientLastSpiderlingSound > 35L){
val distanceSq = MC.player?.getDistanceSqToCenter(pos) ?: 0.0
if (rand.nextInt(3 + (distanceSq.floorToInt() / 5)) == 0){
clientLastSpiderlingSound = world.totalWorldTime
clientLastSpiderlingSound = world.totalTime
makeSpiderling(world, pos, yaw = 0F).apply {
ambientSound.playClient(pos, soundCategory, volume = 0.35F, pitch = rand.nextFloat(0.4F, 0.6F))

View File

@ -37,6 +37,7 @@ import chylex.hee.system.util.isAir
import chylex.hee.system.util.isAnyPlayerWithinRange
import chylex.hee.system.util.nextFloat
import chylex.hee.system.util.nextInt
import chylex.hee.system.util.totalTime
import net.minecraft.util.ITickable
import net.minecraft.util.math.BlockPos
import kotlin.math.max
@ -96,7 +97,7 @@ class TileEntityEnergyCluster : TileEntityBase(), ITickable{
get() = proximityHandler.affectedByProximity
val wasUsedRecently
get() = world.totalWorldTime - lastUseTick < 20L
get() = world.totalTime - lastUseTick < 20L
// Fields
@ -131,7 +132,7 @@ class TileEntityEnergyCluster : TileEntityBase(), ITickable{
energyLevel -= quantity
ticksToRegen = 20 + (40F / currentHealth.regenSpeedMp).ceilToInt()
lastUseTick = world.totalWorldTime
lastUseTick = world.totalTime
isInactive = false
return tryDisturb()
@ -240,7 +241,7 @@ class TileEntityEnergyCluster : TileEntityBase(), ITickable{
override fun update(){
if (world.isRemote){
if (world.totalWorldTime % 3L == 0L){
if (world.totalTime % 3L == 0L){
particle?.let { it.first.spawn(it.second, world.rand) }
}
@ -253,7 +254,7 @@ class TileEntityEnergyCluster : TileEntityBase(), ITickable{
}
if (isInactive){
if (world.totalWorldTime % 80L == 0L){
if (world.totalTime % 80L == 0L){
val activationRange = when(internalHealthStatus){
UNSTABLE -> 48.0
DAMAGED -> 32.0

View File

@ -36,6 +36,7 @@ import chylex.hee.system.util.nextFloat
import chylex.hee.system.util.playClient
import chylex.hee.system.util.posVec
import chylex.hee.system.util.setPos
import chylex.hee.system.util.totalTime
import chylex.hee.system.util.updateState
import chylex.hee.system.util.with
import net.minecraft.block.state.IBlockState
@ -139,7 +140,7 @@ class TileEntityTablePedestal : TileEntityBase(){
}
private fun spawnSmokeParticles(){
val currentTime = world.totalWorldTime
val currentTime = world.totalTime
if (lastSmokeTime != currentTime){
lastSmokeTime = currentTime
@ -255,7 +256,7 @@ class TileEntityTablePedestal : TileEntityBase(){
if (updateInputModCounter){
++inputModCounter
inputModTime = world.totalWorldTime
inputModTime = world.totalTime
}
}

View File

@ -18,6 +18,7 @@ import chylex.hee.system.util.nextFloat
import chylex.hee.system.util.playClient
import chylex.hee.system.util.readPos
import chylex.hee.system.util.selectVulnerableEntities
import chylex.hee.system.util.totalTime
import chylex.hee.system.util.use
import chylex.hee.system.util.writePos
import io.netty.buffer.ByteBuf
@ -68,7 +69,7 @@ class EntityFallingObsidian : EntityFallingBlockHeavy{
if (!world.isRemote && pos != lastFallPos){
if (pos.y < lastFallPos.y && fallDistance >= 1F){
val damageAmount = 5F * (ln(2F * (1.2F + fallDistance)) - 1F).pow(1.8F)
val worldTime = world.totalWorldTime
val worldTime = world.totalTime
for(entity in world.selectVulnerableEntities.inBox<EntityLivingBase>(entityBoundingBox)){
val uuid = entity.uniqueID

View File

@ -21,6 +21,7 @@ import chylex.hee.system.util.selectEntities
import chylex.hee.system.util.setBlock
import chylex.hee.system.util.setState
import chylex.hee.system.util.size
import chylex.hee.system.util.totalTime
import chylex.hee.system.util.with
import net.minecraft.block.BlockCauldron.LEVEL
import net.minecraft.entity.Entity
@ -75,7 +76,7 @@ class EntityItemCauldronTrigger : EntityItem{
override fun onUpdate(){
super.onUpdate()
if (!world.isRemote && world.totalWorldTime % 5L == 0L){
if (!world.isRemote && world.totalTime % 5L == 0L){
val pos = Pos(this)
val state = pos.getState(world)
val block = state.block

View File

@ -18,6 +18,7 @@ import chylex.hee.system.util.motionVec
import chylex.hee.system.util.posVec
import chylex.hee.system.util.setEnum
import chylex.hee.system.util.square
import chylex.hee.system.util.totalTime
import chylex.hee.system.util.use
import io.netty.buffer.ByteBuf
import net.minecraft.entity.Entity
@ -42,7 +43,7 @@ class EntityTokenHolder(world: World) : Entity(world), IEntityAdditionalSpawnDat
private val DATA_CHARGE = EntityData.register<EntityTokenHolder, Float>(DataSerializers.FLOAT)
}
val renderRotation = LerpedFloat(world.totalWorldTime * 3F)
val renderRotation = LerpedFloat(world.totalTime * 3F)
val renderCharge = LerpedFloat(1F)
var tokenType = TokenType.NORMAL
@ -79,7 +80,7 @@ class EntityTokenHolder(world: World) : Entity(world), IEntityAdditionalSpawnDat
super.onUpdate()
if (world.isRemote){
renderRotation.update(world.totalWorldTime * 3F)
renderRotation.update(world.totalTime * 3F)
renderCharge.update(currentCharge)
}
else{

View File

@ -25,6 +25,7 @@ import chylex.hee.system.util.TagCompound
import chylex.hee.system.util.Vec3
import chylex.hee.system.util.directionTowards
import chylex.hee.system.util.floorToInt
import chylex.hee.system.util.getAttribute
import chylex.hee.system.util.heeTag
import chylex.hee.system.util.math.LerpedFloat
import chylex.hee.system.util.motionVec
@ -33,6 +34,7 @@ import chylex.hee.system.util.nextItemOrNull
import chylex.hee.system.util.posVec
import chylex.hee.system.util.scale
import chylex.hee.system.util.selectVulnerableEntities
import chylex.hee.system.util.value
import chylex.hee.system.util.withY
import net.minecraft.block.material.EnumPushReaction
import net.minecraft.entity.Entity
@ -129,16 +131,16 @@ class EntityBossEnderEye(world: World) : EntityFlying(world), IMob{
attributeMap.registerAttribute(ATTACK_DAMAGE)
attributeMap.registerAttribute(FLYING_SPEED)
getEntityAttribute(MAX_HEALTH).baseValue = 300.0
getEntityAttribute(ATTACK_DAMAGE).baseValue = 4.0
getEntityAttribute(FLYING_SPEED).baseValue = 0.0925
getEntityAttribute(FOLLOW_RANGE).baseValue = 16.0
getAttribute(MAX_HEALTH).baseValue = 300.0
getAttribute(ATTACK_DAMAGE).baseValue = 4.0
getAttribute(FLYING_SPEED).baseValue = 0.0925
getAttribute(FOLLOW_RANGE).baseValue = 16.0
experienceValue = 50
}
private fun updateDemonLevelAttributes(){
getEntityAttribute(ATTACK_DAMAGE).baseValue = 4.0 * damageMultiplier
getAttribute(ATTACK_DAMAGE).baseValue = 4.0 * damageMultiplier
experienceValue = (50 * experienceMultiplier).floorToInt()
}
@ -240,7 +242,7 @@ class EntityBossEnderEye(world: World) : EntityFlying(world), IMob{
return attacker
}
val range = getEntityAttribute(FOLLOW_RANGE).attributeValue
val range = getAttribute(FOLLOW_RANGE).value
val targets = world.selectVulnerableEntities.inRange<EntityPlayer>(posVec, range).filter(::canEntityBeSeen)
return rng.nextItemOrNull(targets).also { attackTarget = it }

View File

@ -1,6 +1,7 @@
package chylex.hee.game.entity.living
import chylex.hee.game.entity.CustomCreatureType
import chylex.hee.game.entity.util.EntityData
import chylex.hee.system.util.getAttribute
import chylex.hee.system.util.tryRemoveModifier
import net.minecraft.entity.Entity
import net.minecraft.entity.EntityLivingBase
@ -45,7 +46,7 @@ abstract class EntityMobAbstractEnderman(world: World) : EntityEnderman(world){
isAggressive = prevAggressive
if (newTarget != null){
getEntityAttribute(MOVEMENT_SPEED).tryRemoveModifier(ATTACKING_SPEED_BOOST)
getAttribute(MOVEMENT_SPEED).tryRemoveModifier(ATTACKING_SPEED_BOOST)
}
}

View File

@ -27,6 +27,7 @@ import chylex.hee.system.util.AITargetEyeContact
import chylex.hee.system.util.AIWatchIdle
import chylex.hee.system.util.Pos
import chylex.hee.system.util.TagCompound
import chylex.hee.system.util.getAttribute
import chylex.hee.system.util.heeTag
import chylex.hee.system.util.nextFloat
import chylex.hee.system.util.nextInt
@ -188,9 +189,9 @@ class EntityMobEnderman(world: World) : EntityMobAbstractEnderman(world){
override fun applyEntityAttributes(){
super.applyEntityAttributes()
getEntityAttribute(MAX_HEALTH).baseValue = 40.0
getEntityAttribute(ATTACK_DAMAGE).baseValue = 5.0
getEntityAttribute(FOLLOW_RANGE).baseValue = 64.0
getAttribute(MAX_HEALTH).baseValue = 40.0
getAttribute(ATTACK_DAMAGE).baseValue = 5.0
getAttribute(FOLLOW_RANGE).baseValue = 64.0
experienceValue = 10
}

View File

@ -13,6 +13,7 @@ import chylex.hee.system.util.AISwim
import chylex.hee.system.util.AITargetAttacker
import chylex.hee.system.util.AITargetNearby
import chylex.hee.system.util.TagCompound
import chylex.hee.system.util.getAttribute
import chylex.hee.system.util.heeTag
import chylex.hee.system.util.square
import net.minecraft.entity.Entity
@ -39,8 +40,8 @@ open class EntityMobEndermite(world: World) : EntityEndermite(world){
override fun applyEntityAttributes(){
super.applyEntityAttributes()
getEntityAttribute(MAX_HEALTH).baseValue = 8.0
getEntityAttribute(ATTACK_DAMAGE).baseValue = 2.0
getAttribute(MAX_HEALTH).baseValue = 8.0
getAttribute(ATTACK_DAMAGE).baseValue = 2.0
experienceValue = 3
}

View File

@ -21,6 +21,7 @@ import chylex.hee.system.util.AITargetAttacker
import chylex.hee.system.util.AITargetRandom
import chylex.hee.system.util.AITargetSwarmSwitch
import chylex.hee.system.util.TagCompound
import chylex.hee.system.util.getAttribute
import chylex.hee.system.util.heeTag
import chylex.hee.system.util.with
import net.minecraft.block.BlockSilverfish
@ -84,9 +85,9 @@ class EntityMobSilverfish(world: World) : EntitySilverfish(world), ICritTracker{
override fun applyEntityAttributes(){
super.applyEntityAttributes()
getEntityAttribute(MAX_HEALTH).baseValue = 8.0
getEntityAttribute(ATTACK_DAMAGE).baseValue = 2.0
getEntityAttribute(FOLLOW_RANGE).baseValue = 12.0
getAttribute(MAX_HEALTH).baseValue = 8.0
getAttribute(ATTACK_DAMAGE).baseValue = 2.0
getAttribute(FOLLOW_RANGE).baseValue = 12.0
experienceValue = 3
}

View File

@ -37,6 +37,7 @@ import chylex.hee.system.util.TagCompound
import chylex.hee.system.util.addY
import chylex.hee.system.util.directionTowards
import chylex.hee.system.util.floorToInt
import chylex.hee.system.util.getAttribute
import chylex.hee.system.util.getState
import chylex.hee.system.util.heeTag
import chylex.hee.system.util.isLoaded
@ -48,6 +49,7 @@ import chylex.hee.system.util.selectExistingEntities
import chylex.hee.system.util.selectVulnerableEntities
import chylex.hee.system.util.square
import chylex.hee.system.util.toRadians
import chylex.hee.system.util.totalTime
import chylex.hee.system.util.tryApplyModifier
import chylex.hee.system.util.tryRemoveModifier
import net.minecraft.block.Block
@ -162,10 +164,10 @@ class EntityMobSpiderling(world: World) : EntityMob(world), ILightStartleHandler
override fun applyEntityAttributes(){
super.applyEntityAttributes()
getEntityAttribute(MAX_HEALTH).baseValue = rand.nextInt(11, 13).toDouble()
getEntityAttribute(ATTACK_DAMAGE).baseValue = 1.5
getEntityAttribute(MOVEMENT_SPEED).baseValue = 0.32
getEntityAttribute(FOLLOW_RANGE).baseValue = 20.0
getAttribute(MAX_HEALTH).baseValue = rand.nextInt(11, 13).toDouble()
getAttribute(ATTACK_DAMAGE).baseValue = 1.5
getAttribute(MOVEMENT_SPEED).baseValue = 0.32
getAttribute(FOLLOW_RANGE).baseValue = 20.0
experienceValue = 2
}
@ -235,7 +237,7 @@ class EntityMobSpiderling(world: World) : EntityMob(world), ILightStartleHandler
}
if (onGround){
getEntityAttribute(ATTACK_DAMAGE).tryRemoveModifier(FALL_CRIT_DAMAGE)
getAttribute(ATTACK_DAMAGE).tryRemoveModifier(FALL_CRIT_DAMAGE)
}
if (jumpCooldown > 0){
@ -271,7 +273,7 @@ class EntityMobSpiderling(world: World) : EntityMob(world), ILightStartleHandler
ForgeHooks.onLivingJump(this)
jumpCooldown = rand.nextInt(18, 22)
getEntityAttribute(ATTACK_DAMAGE).tryApplyModifier(FALL_CRIT_DAMAGE)
getAttribute(ATTACK_DAMAGE).tryApplyModifier(FALL_CRIT_DAMAGE)
}
}
}
@ -317,7 +319,7 @@ class EntityMobSpiderling(world: World) : EntityMob(world), ILightStartleHandler
override fun onLightStartled(): Boolean{
wakeUp(instant = false, preventSleep = true)
if (world.totalWorldTime < lightStartleResetTime){
if (world.totalTime < lightStartleResetTime){
return false
}
@ -359,7 +361,7 @@ class EntityMobSpiderling(world: World) : EntityMob(world), ILightStartleHandler
super.setAttackTarget(newTarget)
if (newTarget == null && lightStartleResetTime == 0L){
lightStartleResetTime = world.totalWorldTime + (30L * 20L)
lightStartleResetTime = world.totalTime + (30L * 20L)
}
}
}
@ -376,7 +378,7 @@ class EntityMobSpiderling(world: World) : EntityMob(world), ILightStartleHandler
override fun jump(){ // TODO could improve by making the motion less smooth when starting the jump, somehow
if (jumpCooldown == 0){
getEntityAttribute(ATTACK_DAMAGE).tryApplyModifier(FALL_CRIT_DAMAGE)
getAttribute(ATTACK_DAMAGE).tryApplyModifier(FALL_CRIT_DAMAGE)
super.jump()
}
}
@ -426,7 +428,7 @@ class EntityMobSpiderling(world: World) : EntityMob(world), ILightStartleHandler
override fun attackEntityAsMob(entity: Entity): Boolean{
if (tasks.taskEntries.any { it.using && it.action is AIAttackLeap }){
getEntityAttribute(ATTACK_DAMAGE).tryApplyModifier(FALL_CRIT_DAMAGE)
getAttribute(ATTACK_DAMAGE).tryApplyModifier(FALL_CRIT_DAMAGE)
}
if (!DAMAGE_GENERAL.dealToFrom(entity, this)){

View File

@ -12,6 +12,7 @@ import chylex.hee.system.util.AISwim
import chylex.hee.system.util.AITargetAttacker
import chylex.hee.system.util.AITargetNearby
import chylex.hee.system.util.AIWatchIdle
import chylex.hee.system.util.getAttribute
import chylex.hee.system.util.nextFloat
import chylex.hee.system.util.square
import net.minecraft.block.Block
@ -45,10 +46,10 @@ class EntityMobUndread(world: World) : EntityMob(world){
override fun applyEntityAttributes(){
super.applyEntityAttributes()
getEntityAttribute(MAX_HEALTH).baseValue = 12.0
getEntityAttribute(ATTACK_DAMAGE).baseValue = 4.0
getEntityAttribute(MOVEMENT_SPEED).baseValue = 0.18
getEntityAttribute(FOLLOW_RANGE).baseValue = 24.0
getAttribute(MAX_HEALTH).baseValue = 12.0
getAttribute(ATTACK_DAMAGE).baseValue = 4.0
getAttribute(MOVEMENT_SPEED).baseValue = 0.18
getAttribute(FOLLOW_RANGE).baseValue = 24.0
experienceValue = 5
}

View File

@ -6,6 +6,7 @@ import chylex.hee.system.util.Vec3
import chylex.hee.system.util.directionTowards
import chylex.hee.system.util.nextFloat
import chylex.hee.system.util.square
import chylex.hee.system.util.totalTime
import net.minecraft.entity.EntityCreature
import net.minecraft.entity.EntityLivingBase
import net.minecraft.entity.ai.EntityAIBase
@ -34,7 +35,7 @@ class AIAttackLeap(
}
val target = entity.attackTarget ?: return false
val currentTime = entity.world.totalWorldTime
val currentTime = entity.world.totalTime
if (currentTime - lastLeapTime < triggerCooldown){
return false
@ -69,7 +70,7 @@ class AIAttackLeap(
entity.motionZ += (diff.z * strengthXZ) + (entity.motionZ * 0.1)
entity.motionY = strengthY
lastLeapTime = entity.world.totalWorldTime
lastLeapTime = entity.world.totalTime
}
override fun updateTask(){

View File

@ -7,6 +7,7 @@ import chylex.hee.system.util.getState
import chylex.hee.system.util.nextInt
import chylex.hee.system.util.posVec
import chylex.hee.system.util.square
import chylex.hee.system.util.totalTime
import net.minecraft.block.state.IBlockState
import net.minecraft.entity.EntityCreature
import net.minecraft.entity.ai.EntityAIBase
@ -24,7 +25,7 @@ class AIPickUpBlock(
fun onBlockReached(state: IBlockState)
}
private var timeOfNextAttempt = entity.world.totalWorldTime + entity.rng.nextInt(ticksPerAttempt / 2, ticksPerAttempt)
private var timeOfNextAttempt = entity.world.totalTime + entity.rng.nextInt(ticksPerAttempt / 2, ticksPerAttempt)
private var targetNavPos: Vec3d? = null
private var targetBlockPos: BlockPos? = null
@ -37,7 +38,7 @@ class AIPickUpBlock(
val world = entity.world
if (world.totalWorldTime < timeOfNextAttempt){
if (world.totalTime < timeOfNextAttempt){
return false
}
@ -84,7 +85,7 @@ class AIPickUpBlock(
}
override fun resetTask(){
timeOfNextAttempt = entity.world.totalWorldTime + ticksPerAttempt
timeOfNextAttempt = entity.world.totalTime + ticksPerAttempt
targetBlockPos = null
targetBlockState = null
}

View File

@ -4,6 +4,7 @@ import chylex.hee.system.util.lookDirVec
import chylex.hee.system.util.lookPosVec
import chylex.hee.system.util.square
import chylex.hee.system.util.toRadians
import chylex.hee.system.util.totalTime
import it.unimi.dsi.fastutil.objects.Object2LongArrayMap
import net.minecraft.entity.EntityCreature
import net.minecraft.entity.EntityLivingBase
@ -38,7 +39,7 @@ class AITargetEyeContact<T : EntityLivingBase>(
stareStarts.keys.retainAll(foundTargets)
val currentTime = entity.world.totalWorldTime
val currentTime = entity.world.totalTime
for(target in foundTargets){
val stareStart = stareStarts.getLong(target)

View File

@ -4,6 +4,7 @@ import chylex.hee.system.util.directionTowards
import chylex.hee.system.util.lookPosVec
import chylex.hee.system.util.motionVec
import chylex.hee.system.util.square
import chylex.hee.system.util.totalTime
sealed class EnderEyeAttack{
abstract val canTakeKnockback: Boolean
@ -42,7 +43,7 @@ sealed class EnderEyeAttack{
}
if (distSq < square(1.4)){
val currentTime = world.totalWorldTime
val currentTime = world.totalTime
if (currentTime - lastAttackTime >= 20L){
lastAttackTime = currentTime

View File

@ -2,6 +2,7 @@ package chylex.hee.game.entity.living.behavior
import chylex.hee.game.entity.living.EntityMobAbstractEnderman
import chylex.hee.system.util.OPERATION_MUL_INCR_INDIVIDUAL
import chylex.hee.system.util.TagCompound
import chylex.hee.system.util.getAttribute
import chylex.hee.system.util.nextInt
import chylex.hee.system.util.tryApplyModifier
import chylex.hee.system.util.tryRemoveModifier
@ -49,11 +50,11 @@ class EndermanWaterHandler(private val enderman: EntityMobAbstractEnderman): ITi
private fun updateDebuff(){
if (debuffTicks > 0){
enderman.isShaking = true
enderman.getEntityAttribute(ATTACK_DAMAGE).tryApplyModifier(DEBUFF_WEAKNESS)
enderman.getAttribute(ATTACK_DAMAGE).tryApplyModifier(DEBUFF_WEAKNESS)
}
else{
enderman.isShaking = false
enderman.getEntityAttribute(ATTACK_DAMAGE).tryRemoveModifier(DEBUFF_WEAKNESS)
enderman.getAttribute(ATTACK_DAMAGE).tryRemoveModifier(DEBUFF_WEAKNESS)
}
}

View File

@ -1,7 +1,9 @@
package chylex.hee.game.entity.living.helpers
import chylex.hee.system.util.directionTowards
import chylex.hee.system.util.getAttribute
import chylex.hee.system.util.lookPosVec
import chylex.hee.system.util.square
import chylex.hee.system.util.value
import net.minecraft.entity.EntityLiving
import net.minecraft.entity.SharedMonsterAttributes.FLYING_SPEED
import net.minecraft.entity.ai.EntityMoveHelper
@ -23,7 +25,7 @@ class EntityMoveFlyingForward(entity: EntityLiving) : EntityMoveHelper(entity){
val xz = sqrt(square(diff.x) + square(diff.z))
val dot = Vec3d.fromPitchYaw(entity.rotationPitch, entity.rotationYaw).dotProduct(diff).coerceAtLeast(0.0)
val speed = entity.getEntityAttribute(FLYING_SPEED).attributeValue * square(dot)
val speed = entity.getAttribute(FLYING_SPEED).value * square(dot)
entity.setMoveForward((xz * speed).toFloat())
entity.setMoveVertical((diff.y * speed).toFloat())

View File

@ -19,13 +19,16 @@ import chylex.hee.system.util.TagCompound
import chylex.hee.system.util.ceilToInt
import chylex.hee.system.util.distanceTo
import chylex.hee.system.util.floorToInt
import chylex.hee.system.util.getAttribute
import chylex.hee.system.util.getPos
import chylex.hee.system.util.getTile
import chylex.hee.system.util.heeTag
import chylex.hee.system.util.heeTagOrNull
import chylex.hee.system.util.readPos
import chylex.hee.system.util.setPos
import chylex.hee.system.util.totalTime
import chylex.hee.system.util.use
import chylex.hee.system.util.value
import chylex.hee.system.util.writePos
import io.netty.buffer.ByteBuf
import net.minecraft.client.resources.I18n
@ -146,9 +149,9 @@ abstract class ItemAbstractEnergyUser : Item(){
if (hasKey(CLUSTER_POS_TAG)){
removeClusterTags(this)
}
else if (pos.distanceTo(player) <= player.getEntityAttribute(EntityPlayer.REACH_DISTANCE).attributeValue){
else if (pos.distanceTo(player) <= player.getAttribute(EntityPlayer.REACH_DISTANCE).value){
setPos(CLUSTER_POS_TAG, pos)
setByte(CLUSTER_TICK_OFFSET_TAG, (4L - (world.totalWorldTime % 4L)).toByte())
setByte(CLUSTER_TICK_OFFSET_TAG, (4L - (world.totalTime % 4L)).toByte())
}
}
@ -161,13 +164,13 @@ abstract class ItemAbstractEnergyUser : Item(){
}
with(stack.heeTagOrNull ?: return){
if (hasKey(CLUSTER_POS_TAG) && (world.totalWorldTime + getByte(CLUSTER_TICK_OFFSET_TAG)) % 4L == 0L){
if (hasKey(CLUSTER_POS_TAG) && (world.totalTime + getByte(CLUSTER_TICK_OFFSET_TAG)) % 4L == 0L){
val pos = getPos(CLUSTER_POS_TAG)
val tile = pos.getTile<TileEntityEnergyCluster>(world)
if ((isSelected || entity.getHeldItem(OFF_HAND) === stack) &&
getShort(ENERGY_LEVEL_TAG) < calculateInternalEnergyCapacity(stack) &&
pos.distanceTo(entity) <= entity.getEntityAttribute(EntityPlayer.REACH_DISTANCE).attributeValue &&
pos.distanceTo(entity) <= entity.getAttribute(EntityPlayer.REACH_DISTANCE).value &&
tile != null &&
tile.drainEnergy(Units(1))
){

View File

@ -3,6 +3,7 @@ import chylex.hee.game.block.BlockAncientCobweb
import chylex.hee.system.migration.Hand.OFF_HAND
import chylex.hee.system.util.nextInt
import chylex.hee.system.util.size
import chylex.hee.system.util.totalTime
import net.minecraft.entity.Entity
import net.minecraft.entity.EntityLivingBase
import net.minecraft.entity.item.EntityItem
@ -16,7 +17,7 @@ import kotlin.math.min
class ItemAncientCobweb(private val sourceBlock: BlockAncientCobweb) : ItemBlock(sourceBlock){
override fun onUpdate(stack: ItemStack, world: World, entity: Entity, itemSlot: Int, isSelected: Boolean){
if (world.isRemote || world.totalWorldTime % 4L != 0L){
if (world.isRemote || world.totalTime % 4L != 0L){
return
}

View File

@ -4,6 +4,7 @@ import chylex.hee.system.util.cleanupNBT
import chylex.hee.system.util.hasKey
import chylex.hee.system.util.heeTag
import chylex.hee.system.util.heeTagOrNull
import chylex.hee.system.util.totalTime
import net.minecraft.advancements.CriteriaTriggers
import net.minecraft.enchantment.EnchantmentHelper
import net.minecraft.entity.Entity
@ -61,7 +62,7 @@ class ItemElytraOverride : ItemElytra(){
setFloat(COUNTER_TAG, 0F)
setTag(LAST_POS_TAG, createPositionTag(entity))
}
else if (world.totalWorldTime % 20L == 0L){
else if (world.totalTime % 20L == 0L){
var newCounter = getFloat(COUNTER_TAG) + calculateCounterIncrement(entity, getCompoundTag(LAST_POS_TAG))
val damageAfter = 1F + (0.33F * EnchantmentHelper.getEnchantmentLevel(Enchantments.UNBREAKING, stack))

View File

@ -38,6 +38,7 @@ import chylex.hee.system.util.over
import chylex.hee.system.util.setLongArray
import chylex.hee.system.util.setPos
import chylex.hee.system.util.toDegrees
import chylex.hee.system.util.totalTime
import it.unimi.dsi.fastutil.longs.LongAVLTreeSet
import it.unimi.dsi.fastutil.longs.LongArrayList
import it.unimi.dsi.fastutil.longs.LongCollection
@ -186,7 +187,7 @@ class ItemEnergyOracle : ItemAbstractEnergyUser(), IInfusableItem{
}
val tag = stack.heeTag
val currentTime = world.totalWorldTime
val currentTime = world.totalTime
// unique identifier

View File

@ -28,6 +28,7 @@ import chylex.hee.system.util.getTile
import chylex.hee.system.util.hasKey
import chylex.hee.system.util.heeTag
import chylex.hee.system.util.heeTagOrNull
import chylex.hee.system.util.totalTime
import net.minecraft.client.renderer.color.IItemColor
import net.minecraft.client.resources.I18n
import net.minecraft.client.util.ITooltipFlag
@ -149,7 +150,7 @@ class ItemEnergyReceptacle : ItemAbstractInfusable(){
setTag(CLUSTER_SNAPSHOT_TAG, cluster.getClusterSnapshot().tag)
setLong(UPDATE_TIME_TAG, world.totalWorldTime)
setLong(UPDATE_TIME_TAG, world.totalTime)
setInteger(RENDER_COLOR_TAG, cluster.color.primary(75F, 80F).i)
setInteger(INITIAL_LEVEL_TAG, cluster.energyLevel.internal.value)
@ -181,7 +182,7 @@ class ItemEnergyReceptacle : ItemAbstractInfusable(){
return
}
val currentTime = world.totalWorldTime
val currentTime = world.totalTime
val ticksElapsed = currentTime - getLong(UPDATE_TIME_TAG)
if (ticksElapsed < ENERGY_LOSS_TICK_RATE){
@ -215,7 +216,7 @@ class ItemEnergyReceptacle : ItemAbstractInfusable(){
}
else{
val snapshot = ClusterSnapshot(tag.getCompoundTag(CLUSTER_SNAPSHOT_TAG))
val level = calculateNewEnergyLevel(snapshot, world.totalWorldTime - tag.getLong(UPDATE_TIME_TAG), InfusionTag.getList(stack))
val level = calculateNewEnergyLevel(snapshot, world.totalTime - tag.getLong(UPDATE_TIME_TAG), InfusionTag.getList(stack))
lines.add(I18n.format("item.hee.energy_receptacle.tooltip.holding", level.displayString))
}

View File

@ -10,6 +10,7 @@ import chylex.hee.system.migration.forge.Sided
import chylex.hee.system.migration.forge.SubscribeEvent
import chylex.hee.system.util.copyIf
import chylex.hee.system.util.isNotEmpty
import chylex.hee.system.util.totalTime
import net.minecraft.entity.Entity
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.init.Items
@ -23,10 +24,10 @@ import java.util.UUID
class ItemRingOfPreservation : ItemAbstractTrinket(), ICustomRepairBehavior{
private class HurtPlayerInfo private constructor(val playerId: UUID, val worldTime: Long){
constructor(player: EntityPlayer) : this(player.uniqueID, player.world.totalWorldTime)
constructor(player: EntityPlayer) : this(player.uniqueID, player.world.totalTime)
fun matches(player: EntityPlayer): Boolean{
return player.uniqueID == playerId && player.world.totalWorldTime == worldTime
return player.uniqueID == playerId && player.world.totalTime == worldTime
}
}

View File

@ -14,6 +14,7 @@ import chylex.hee.system.migration.forge.EventPriority
import chylex.hee.system.migration.forge.EventResult
import chylex.hee.system.migration.forge.SubscribeEvent
import chylex.hee.system.util.floorToInt
import chylex.hee.system.util.getAttribute
import chylex.hee.system.util.nextFloat
import chylex.hee.system.util.playUniversal
import chylex.hee.system.util.posVec
@ -153,7 +154,7 @@ class ItemScorchingSword : ItemSword(SCORCHING_SWORD), IScorchingItem, ICustomRe
private fun isPassive(target: EntityLivingBase): Boolean{
@Suppress("SENSELESS_COMPARISON")
if (target.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE) != null){
if (target.getAttribute(SharedMonsterAttributes.ATTACK_DAMAGE) != null){
return false
}

View File

@ -28,6 +28,7 @@ import chylex.hee.system.util.nextFloat
import chylex.hee.system.util.playClient
import chylex.hee.system.util.readPos
import chylex.hee.system.util.setPos
import chylex.hee.system.util.totalTime
import chylex.hee.system.util.use
import chylex.hee.system.util.writePos
import io.netty.buffer.ByteBuf
@ -153,7 +154,7 @@ class ItemTableLink : Item(){
if (heldItem.isNotEmpty){
setPos(POS_TAG, newStoredPos)
setLong(TIME_TAG, world.totalWorldTime)
setLong(TIME_TAG, world.totalTime)
}
PacketClientFX(FX_USE, FxUseData(pos, soundType)).sendToAllAround(world, pos, 16.0)
@ -163,13 +164,13 @@ class ItemTableLink : Item(){
}
override fun onUpdate(stack: ItemStack, world: World, entity: Entity, itemSlot: Int, isSelected: Boolean){
if (world.isRemote || world.totalWorldTime % 10L != 0L){
if (world.isRemote || world.totalTime % 10L != 0L){
return
}
val tag = stack.heeTagOrNull
if (tag.hasKey(TIME_TAG) && world.totalWorldTime - tag.getLong(TIME_TAG) >= RESET_TIME_TICKS){
if (tag.hasKey(TIME_TAG) && world.totalTime - tag.getLong(TIME_TAG) >= RESET_TIME_TICKS){
removeLinkingTags(stack)
}
}

View File

@ -9,6 +9,7 @@ import chylex.hee.system.migration.forge.SubscribeEvent
import chylex.hee.system.util.ceilToInt
import chylex.hee.system.util.posVec
import chylex.hee.system.util.square
import chylex.hee.system.util.totalTime
import net.minecraft.entity.Entity
import net.minecraft.entity.EntityLivingBase
import net.minecraft.entity.player.EntityPlayer
@ -78,7 +79,7 @@ class ItemTalismanOfGriefing : ItemAbstractTrinket(){
}
private fun markEntitiesForTalismanRepair(explosion: Explosion, entities: List<Entity>){
val currentTime = explosion.world.totalWorldTime
val currentTime = explosion.world.totalTime
val recentlyExploded = lastRepairMarkEntities.get()
if (lastRepairMarkTime.get() != currentTime){
@ -156,7 +157,7 @@ class ItemTalismanOfGriefing : ItemAbstractTrinket(){
val entity = e.entityLiving
val world = entity.world
if (lastRepairMarkTime.get() != world.totalWorldTime || !lastRepairMarkEntities.get().remove(entity.uniqueID)){
if (lastRepairMarkTime.get() != world.totalTime || !lastRepairMarkEntities.get().remove(entity.uniqueID)){
return
}

View File

@ -8,12 +8,15 @@ import chylex.hee.system.migration.forge.EventPriority
import chylex.hee.system.migration.forge.Side
import chylex.hee.system.migration.forge.Sided
import chylex.hee.system.migration.forge.SubscribeEvent
import chylex.hee.system.util.getAttribute
import chylex.hee.system.util.hasKey
import chylex.hee.system.util.heeTag
import chylex.hee.system.util.heeTagOrNull
import chylex.hee.system.util.playClient
import chylex.hee.system.util.posVec
import chylex.hee.system.util.selectExistingEntities
import chylex.hee.system.util.totalTime
import chylex.hee.system.util.value
import net.minecraft.entity.Entity
import net.minecraft.entity.EntityLivingBase
import net.minecraft.entity.passive.EntityVillager
@ -87,11 +90,11 @@ class ItemTotemOfUndyingCustom : ItemAbstractTrinket(){
// Villager logic
override fun onUpdate(stack: ItemStack, world: World, entity: Entity, itemSlot: Int, isSelected: Boolean){
if (world.isRemote || world.totalWorldTime % 10L != 0L || canPlaceIntoTrinketSlot(stack) || entity !is EntityPlayer){
if (world.isRemote || world.totalTime % 10L != 0L || canPlaceIntoTrinketSlot(stack) || entity !is EntityPlayer){
return
}
val isNearVillager = world.selectExistingEntities.inRange<EntityVillager>(entity.posVec, entity.getEntityAttribute(REACH_DISTANCE).attributeValue).isNotEmpty()
val isNearVillager = world.selectExistingEntities.inRange<EntityVillager>(entity.posVec, entity.getAttribute(REACH_DISTANCE).value).isNotEmpty()
val wasNearVillager = stack.heeTagOrNull.hasKey(SHAKING_TAG)
if (isNearVillager && !wasNearVillager){

View File

@ -1,4 +1,6 @@
package chylex.hee.game.mechanics.damage
import chylex.hee.system.util.getAttribute
import chylex.hee.system.util.value
import net.minecraft.entity.Entity
import net.minecraft.entity.EntityLivingBase
import net.minecraft.entity.SharedMonsterAttributes.ATTACK_DAMAGE
@ -27,7 +29,7 @@ class Damage(private vararg val processors: IDamageProcessor){
dealToInternal(amount, target, null, null, title)
fun dealToFrom(target: Entity, source: EntityLivingBase, title: String = determineTitleDirect(source)) =
dealToInternal(source.getEntityAttribute(ATTACK_DAMAGE).attributeValue.toFloat(), target, source, source, title)
dealToInternal(source.getAttribute(ATTACK_DAMAGE).value.toFloat(), target, source, source, title)
fun dealToFrom(amount: Float, target: Entity, source: Entity, title: String = determineTitleDirect(source)) =
dealToInternal(amount, target, source, source, title)

View File

@ -8,6 +8,7 @@ import chylex.hee.system.util.ceilToInt
import chylex.hee.system.util.component1
import chylex.hee.system.util.component2
import chylex.hee.system.util.nextInt
import chylex.hee.system.util.totalTime
import net.minecraft.util.math.ChunkPos
import net.minecraftforge.common.util.INBTSerializable
import java.util.Random
@ -80,7 +81,7 @@ class ProximityHandler(private val cluster: TileEntityEnergyCluster) : INBTSeria
val world = cluster.world
if (world.totalWorldTime % INSTABILITY_INTERVAL_TICKS == 0L){
if (world.totalTime % INSTABILITY_INTERVAL_TICKS == 0L){
val pos = cluster.pos
with(Instability.get(world)){

View File

@ -11,6 +11,7 @@ import chylex.hee.system.util.component3
import chylex.hee.system.util.delegate.NotifyOnChange
import chylex.hee.system.util.floorToInt
import chylex.hee.system.util.nextFloat
import chylex.hee.system.util.totalTime
import net.minecraft.entity.item.EntityItem
import net.minecraft.item.ItemStack
import net.minecraftforge.common.util.INBTSerializable
@ -44,7 +45,7 @@ class RevitalizationHandler(private val cluster: TileEntityEnergyCluster) : INBT
return
}
val currentTime = cluster.world.totalWorldTime
val currentTime = cluster.world.totalTime
val timeDiff = currentTime - lastDrainTime
if (timeDiff < DRAIN_RATE_TICKS){
@ -111,7 +112,7 @@ class RevitalizationHandler(private val cluster: TileEntityEnergyCluster) : INBT
val durationTicks = 20F * (50F + (30F * sqrt(capacityUnits))) / (0.25F + (0.75F * cluster.currentHealth.regenAmountMp))
val toDrain = cluster.energyBaseCapacity * 0.5F
lastDrainTime = cluster.world.totalWorldTime
lastDrainTime = cluster.world.totalTime
drainAmount = maxOf(Internal(1), toDrain * (DRAIN_RATE_TICKS / durationTicks)).internal
drainTarget = maxOf(Units(0), cluster.energyLevel - toDrain).units
return true

View File

@ -4,6 +4,7 @@ import chylex.hee.system.util.TagCompound
import chylex.hee.system.util.ceilToInt
import chylex.hee.system.util.floorToInt
import chylex.hee.system.util.remapRange
import chylex.hee.system.util.totalTime
import net.minecraft.util.math.BlockPos
import net.minecraft.world.World
import kotlin.math.max
@ -39,7 +40,7 @@ open class DimensionInstabilityGlobal(private val world: World, private val ende
}
override fun triggerAction(amount: UShort, pos: BlockPos){
val currentTime = world.totalWorldTime
val currentTime = world.totalTime
val ticksSinceLastAction = currentTime - lastActionTime
val ticksSinceEndermiteSpawn = currentTime - lastEndermiteSpawnTime

View File

@ -19,6 +19,7 @@ import chylex.hee.system.util.getBlock
import chylex.hee.system.util.getTile
import chylex.hee.system.util.nextFloat
import chylex.hee.system.util.readPos
import chylex.hee.system.util.totalTime
import chylex.hee.system.util.use
import chylex.hee.system.util.writePos
import io.netty.buffer.ByteBuf
@ -109,7 +110,7 @@ class TableParticleHandler(private val table: TileEntityBaseTable){
fun tick(processTickRate: Int){
val particleRate = getParticleRate(processTickRate)
val modTick = table.world.totalWorldTime % particleRate
val modTick = table.world.totalTime % particleRate
if (modTick == 0L){
lastDrainedCluster?.let {

View File

@ -20,6 +20,7 @@ import chylex.hee.system.util.getPos
import chylex.hee.system.util.getTile
import chylex.hee.system.util.setLongArray
import chylex.hee.system.util.setPos
import chylex.hee.system.util.totalTime
import net.minecraft.item.ItemStack
import net.minecraft.util.math.BlockPos
import net.minecraft.world.World
@ -88,7 +89,7 @@ abstract class ProcessManyPedestals(private val world: World, pos: Array<BlockPo
when(val state = currentState){
is Work -> {
if (tiles.any { world.totalWorldTime - it.inputModTime < 20L } || context.isPaused){
if (tiles.any { world.totalTime - it.inputModTime < 20L } || context.isPaused){
setStatusIndicator(tiles, PAUSED)
}
else{

View File

@ -41,7 +41,7 @@ object ParticleEnderGoo : IParticleMaker{
particleGravity = 0.15F
particleMaxAge = rand.nextInt(34, 42)
maxAge = rand.nextInt(34, 42)
}
override fun onUpdate(){
@ -51,7 +51,7 @@ object ParticleEnderGoo : IParticleMaker{
particleAngle += angleOffset
angleOffset *= 0.94F
if (particleAge > particleMaxAge - 15){
if (age > maxAge - 15){
particleScale *= 0.9F
}

View File

@ -79,7 +79,7 @@ object ParticleEnergyCluster : IParticleMaker{
init{
if (unsafeData.size < 2){
particleAlpha = 0F
particleMaxAge = 0
maxAge = 0
}
else{
loadColor(unsafeData[0])
@ -87,7 +87,7 @@ object ParticleEnergyCluster : IParticleMaker{
particleScale = unsafeData[1] * 0.01F
particleMaxAge = TOTAL_LIFESPAN
maxAge = TOTAL_LIFESPAN
multiplyVelocity(square(particleScale * 0.5F).coerceAtMost(1F))
}
@ -95,11 +95,11 @@ object ParticleEnergyCluster : IParticleMaker{
override fun onUpdate(){
if (clusterPos.getBlock(world) !== ModBlocks.ENERGY_CLUSTER){
if (particleAge < TOTAL_LIFESPAN - FADE_OUT_DURATION){
particleAge = TOTAL_LIFESPAN - FADE_OUT_DURATION
if (age < TOTAL_LIFESPAN - FADE_OUT_DURATION){
age = TOTAL_LIFESPAN - FADE_OUT_DURATION
}
particleAge += 2
age += 2
}
super.onUpdate()

View File

@ -43,12 +43,12 @@ object ParticleEnergyClusterRevitalization : IParticleMaker{
particleBlue = 1F
particleAlpha = 0F
particleMaxAge = TOTAL_LIFESPAN
maxAge = TOTAL_LIFESPAN
val cluster = clusterPos.getTile<TileEntityEnergyCluster>(world)
if (cluster == null){
particleAge = particleMaxAge
age = maxAge
isRevitalizing = false
targetDistance = 0.0
@ -65,11 +65,11 @@ object ParticleEnergyClusterRevitalization : IParticleMaker{
override fun onUpdate(){
if ((clusterPos.getTile<TileEntityEnergyCluster>(world)?.clientOrbitingOrbs ?: 0) == 0.toByte()){
if (particleAge < TOTAL_LIFESPAN - FADE_OUT_DURATION){
particleAge = TOTAL_LIFESPAN - FADE_OUT_DURATION
if (age < TOTAL_LIFESPAN - FADE_OUT_DURATION){
age = TOTAL_LIFESPAN - FADE_OUT_DURATION
}
particleAge += 3
age += 3
}
super.onUpdate()
@ -78,8 +78,8 @@ object ParticleEnergyClusterRevitalization : IParticleMaker{
val posVec = Vec3d(posX, posY, posZ)
val newPos: Vec3d
if (isRevitalizing && particleAge > TOTAL_LIFESPAN - FADE_OUT_DURATION){
newPos = posVec.offsetTowards(clusterPos.center, 1.0 - (TOTAL_LIFESPAN - particleAge).toDouble() / TOTAL_LIFESPAN)
if (isRevitalizing && age > TOTAL_LIFESPAN - FADE_OUT_DURATION){
newPos = posVec.offsetTowards(clusterPos.center, 1.0 - (TOTAL_LIFESPAN - age).toDouble() / TOTAL_LIFESPAN)
}
else{
motionTarget = motionTarget.offsetTowards(motionOffset, 0.1).normalize()

View File

@ -33,7 +33,7 @@ object ParticleEnergyTableDrain : IParticleMaker{
init{
if (unsafeData.size < 2){
particleAlpha = 0F
particleMaxAge = 0
maxAge = 0
}
else{
loadColor(unsafeData[0])
@ -41,7 +41,7 @@ object ParticleEnergyTableDrain : IParticleMaker{
particleScale = unsafeData[1] * 0.01F
particleMaxAge = 6
maxAge = 6
}
}

View File

@ -37,7 +37,7 @@ object ParticleEnergyTransferToPedestal : IParticleMaker{
init{
if (unsafeData.size < 4){
particleAlpha = 0F
particleMaxAge = 0
maxAge = 0
targetPos = Vec3d.ZERO
}
@ -56,8 +56,8 @@ object ParticleEnergyTransferToPedestal : IParticleMaker{
super.onUpdate()
if (Pos(targetPos).getBlock(world) !== ModBlocks.TABLE_PEDESTAL){
if (particleAge < particleMaxAge - 5){
particleMaxAge = particleAge + 5
if (age < maxAge - 5){
maxAge = age + 5
}
particleAlpha -= 0.2F

View File

@ -49,7 +49,7 @@ object ParticleEnergyTransferToPlayer : IParticleMaker{
init{
if (unsafeData.size < 4){
particleAlpha = 0F
particleMaxAge = 0
maxAge = 0
speed = 0.0
player = WeakReference(null)
@ -75,7 +75,7 @@ object ParticleEnergyTransferToPlayer : IParticleMaker{
newTargetPos = ModelHelper.getHandPosition(player, if (player.getHeldItem(MAIN_HAND).item is ItemAbstractEnergyUser) MAIN_HAND else OFF_HAND)
setupMotion(speed + (particleAge * 0.005))
setupMotion(speed + (age * 0.005))
super.onUpdate()
}
}

View File

@ -51,10 +51,10 @@ object ParticleFadingSpot : IParticleMaker{
particleScale = data[1] * 0.01F
particleMaxAge = data[2]
maxAge = data[2]
alphaPerTick = 1F / particleMaxAge
scalePerTick = particleScale / (particleMaxAge + rand.nextInt(1, 9))
alphaPerTick = 1F / maxAge
scalePerTick = particleScale / (maxAge + rand.nextInt(1, 9))
}
override fun onUpdate(){

View File

@ -44,13 +44,13 @@ object ParticleGlitter : IParticleMaker{
particleScale = rand.nextFloat(0.35F, 0.5F)
particleMaxAge = (4F / rand.nextFloat(0.1F, 1F)).toInt() * rand.nextInt(data[1], data[2])
maxAge = (4F / rand.nextFloat(0.1F, 1F)).toInt() * rand.nextInt(data[1], data[2])
}
override fun onUpdate(){
super.onUpdate()
if (particleAge < (particleMaxAge * 3) / 4 && rand.nextInt(5) == 0){
if (age < (maxAge * 3) / 4 && rand.nextInt(5) == 0){
particleAlpha = rand.nextFloat(0.5F, 1F)
}

View File

@ -40,7 +40,7 @@ object ParticleGrowingSpot : IParticleMaker{
particleScale = rand.nextFloat(0.25F, 0.35F)
particleMaxAge = data[1]
maxAge = data[1]
}
override fun onUpdate(){

View File

@ -47,11 +47,11 @@ object ParticleTeleport : IParticleMaker{
particleGreen = particleBlue * 0.3F
particleRed = particleBlue * 0.9F
particleMaxAge = rand.nextInt(data[0], data[1])
maxAge = rand.nextInt(data[0], data[1])
}
override fun renderParticle(buffer: BufferBuilder, entity: Entity, partialTicks: Float, rotationX: Float, rotationZ: Float, rotationYZ: Float, rotationXY: Float, rotationXZ: Float){
particleScale = initialScale * (1F - (particleAge + partialTicks) / (particleMaxAge + 1F))
particleScale = initialScale * (1F - (age + partialTicks) / (maxAge + 1F))
super.renderParticle(buffer, entity, partialTicks, rotationX, rotationZ, rotationYZ, rotationXY, rotationXZ)
}
}

View File

@ -41,7 +41,7 @@ object ParticleVoid : IParticleMaker{
particleScale = rand.nextFloat(0.25F, 0.4F)
particleMaxAge = (30F / rand.nextFloat(0.3F, 1F)).ceilToInt()
maxAge = (30F / rand.nextFloat(0.3F, 1F)).ceilToInt()
motionVec = Vec3d(
rand.nextFloat(-1.0, 1.0),
@ -70,7 +70,7 @@ object ParticleVoid : IParticleMaker{
motionVec = motionVec.scale(0.996)
if (particleAge >= particleMaxAge - 3){
if (age >= maxAge - 3){
particleAlpha = max(0F, particleAlpha - 0.25F)
}
else{

View File

@ -16,6 +16,14 @@ abstract class ParticleBase(world: World, posX: Double, posY: Double, posZ: Doub
motionZ = value.z
}
protected var age
get() = particleAge
set(value){ particleAge = value }
protected var maxAge
get() = particleMaxAge
@JvmName("setMaxAge2") set(value){ particleMaxAge = value }
protected fun loadColor(color: Int){
loadColor(IntColor(color))
}
@ -27,12 +35,12 @@ abstract class ParticleBase(world: World, posX: Double, posY: Double, posZ: Doub
}
protected fun interpolateAge(baseValue: Float, fadeInDuration: Int = 0, fadeOutDuration: Int = 0): Float{
val fadeOutAfter = particleMaxAge - fadeOutDuration
val fadeOutAfter = maxAge - fadeOutDuration
return baseValue * when{
particleAge < fadeInDuration -> particleAge.toFloat() / fadeInDuration
particleAge > fadeOutAfter -> 1F - ((particleAge - fadeOutAfter).toFloat() / fadeOutDuration)
else -> 1F
age < fadeInDuration -> age.toFloat() / fadeInDuration
age > fadeOutAfter -> 1F - ((age - fadeOutAfter).toFloat() / fadeOutDuration)
else -> 1F
}
}
}

View File

@ -9,7 +9,7 @@ abstract class ParticleBaseEnergyTransfer(world: World, posX: Double, posY: Doub
protected abstract val targetPos: Vec3d
init{
particleMaxAge = 200
maxAge = 200
}
protected fun setupMotion(speed: Double){

View File

@ -22,6 +22,7 @@ import chylex.hee.system.util.nextFloat
import chylex.hee.system.util.posVec
import chylex.hee.system.util.remapRange
import chylex.hee.system.util.square
import chylex.hee.system.util.totalTime
import net.minecraft.entity.Entity
import net.minecraft.entity.EntityLivingBase
import net.minecraft.util.DamageSource
@ -110,7 +111,7 @@ object TerritoryVoid{
private val DAMAGE = Damage(DEAL_CREATIVE, IGNORE_INVINCIBILITY())
fun onWorldTick(world: World){
if (world.totalWorldTime % 3L != 0L){
if (world.totalTime % 3L != 0L){
return
}
@ -134,7 +135,7 @@ object TerritoryVoid{
}
with(entity.heeTag){
val currentTime = world.totalWorldTime
val currentTime = world.totalTime
val nextDamageTime = getLong(PLAYER_NEXT_DAMAGE_TIME_TAG)
if (currentTime >= nextDamageTime){

View File

@ -10,9 +10,11 @@ import chylex.hee.system.util.component1
import chylex.hee.system.util.component2
import chylex.hee.system.util.component3
import chylex.hee.system.util.floorToInt
import chylex.hee.system.util.getAttribute
import chylex.hee.system.util.getState
import chylex.hee.system.util.lookDirVec
import chylex.hee.system.util.lookPosVec
import chylex.hee.system.util.value
import net.minecraft.block.state.IBlockState
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.entity.player.EntityPlayer.REACH_DISTANCE
@ -139,7 +141,7 @@ class RayTracer(
fun traceBlocksInPlayerReach(player: EntityPlayer): RayTraceResult?{
val vecFrom = player.lookPosVec
val vecTo = vecFrom.add(player.lookDirVec.scale(player.getEntityAttribute(REACH_DISTANCE).attributeValue))
val vecTo = vecFrom.add(player.lookDirVec.scale(player.getAttribute(REACH_DISTANCE).value))
return traceBlocksBetweenVectors(player.world, vecFrom, vecTo)
}

View File

@ -18,6 +18,7 @@ import net.minecraft.entity.ai.EntityAINearestAttackableTarget
import net.minecraft.entity.ai.EntityAISwimming
import net.minecraft.entity.ai.EntityAIWatchClosest
import net.minecraft.entity.ai.attributes.AttributeModifier
import net.minecraft.entity.ai.attributes.IAttribute
import net.minecraft.entity.ai.attributes.IAttributeInstance
import net.minecraft.entity.item.EntityItem
import net.minecraft.entity.player.EntityPlayer.PERSISTED_NBT_TAG
@ -105,6 +106,15 @@ const val OPERATION_MUL_INCR_GROUPED = 1
/** Performs operation: base * (1 + x) * (1 + y) */
const val OPERATION_MUL_INCR_INDIVIDUAL = 2
// Attributes (Renames)
fun EntityLivingBase.getAttribute(attribute: IAttribute): IAttributeInstance{
return this.getEntityAttribute(attribute)
}
val IAttributeInstance.value
get() = this.attributeValue
// Attributes (Helpers)
fun IAttributeInstance.tryApplyModifier(modifier: AttributeModifier){

View File

@ -3,6 +3,13 @@ import net.minecraft.world.World
import net.minecraft.world.storage.WorldSavedData
import net.minecraftforge.fml.common.FMLCommonHandler
// Renaming
val World.totalTime
get() = this.totalWorldTime
// World data
inline fun <reified T : WorldSavedData> World.perDimensionData(name: String, constructor: (String) -> T): T{
return this.perWorldStorage.let {
it.getOrLoadData(T::class.java, name) as? T ?: constructor(name).also { data -> it.setData(name, data) }