diff options
author | inglettronald <inglettronald@gmail.com> | 2023-05-25 16:23:19 -0500 |
---|---|---|
committer | inglettronald <inglettronald@gmail.com> | 2023-05-25 16:23:19 -0500 |
commit | f7b3746bcb1d48366760e9cdde9c8cdb8f89b645 (patch) | |
tree | f7621a7d4fcfdca27621266f289e9de5c802a6ed /src/main | |
parent | 093b826824391e06724933dcb74498516aecc8ab (diff) | |
download | DulkirMod-f7b3746bcb1d48366760e9cdde9c8cdb8f89b645.tar.gz DulkirMod-f7b3746bcb1d48366760e9cdde9c8cdb8f89b645.tar.bz2 DulkirMod-f7b3746bcb1d48366760e9cdde9c8cdb8f89b645.zip |
performance improvements
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/dulkirmod/mixins/MixinEntityRenderer.java | 21 | ||||
-rw-r--r-- | src/main/kotlin/dulkirmod/DulkirMod.kt | 6 | ||||
-rw-r--r-- | src/main/kotlin/dulkirmod/features/MemoryLeakFix.kt | 12 |
3 files changed, 24 insertions, 15 deletions
diff --git a/src/main/java/dulkirmod/mixins/MixinEntityRenderer.java b/src/main/java/dulkirmod/mixins/MixinEntityRenderer.java index f754f2c..b7099c2 100644 --- a/src/main/java/dulkirmod/mixins/MixinEntityRenderer.java +++ b/src/main/java/dulkirmod/mixins/MixinEntityRenderer.java @@ -1,25 +1,16 @@ package dulkirmod.mixins; -import dulkirmod.features.HurtCamSlider; -import dulkirmod.features.ViewBobbing; +import dulkirmod.config.DulkirConfig; import net.minecraft.client.renderer.EntityRenderer; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.Constant; +import org.spongepowered.asm.mixin.injection.ModifyConstant; @Mixin(EntityRenderer.class) public class MixinEntityRenderer { - @Inject(method = "hurtCameraEffect", at = @At("HEAD"), cancellable = true) - private void hurtCameraEffect(float partialTicks, CallbackInfo ci) { - if (HurtCamSlider.INSTANCE.renderHurt(partialTicks)) - ci.cancel(); - } - - @Inject(method = "setupViewBobbing", at = @At("HEAD"), cancellable = true) - private void modifyViewBobbing(float partialTicks, CallbackInfo ci) { - if (ViewBobbing.INSTANCE.renderBob(partialTicks)) - ci.cancel(); + @ModifyConstant(method = "hurtCameraEffect", constant = @Constant(floatValue = 14.0f)) + private float hurtCameraEffect(float constant) { + return constant * DulkirConfig.INSTANCE.getHurtCamIntensity(); } } diff --git a/src/main/kotlin/dulkirmod/DulkirMod.kt b/src/main/kotlin/dulkirmod/DulkirMod.kt index 6b955ef..70e029e 100644 --- a/src/main/kotlin/dulkirmod/DulkirMod.kt +++ b/src/main/kotlin/dulkirmod/DulkirMod.kt @@ -39,6 +39,7 @@ import kotlin.coroutines.EmptyCoroutineContext class DulkirMod { var lastLongUpdate: Long = 0 + var lastLongerUpdate: Long = 0 @Mod.EventHandler fun preInit(event: FMLPreInitializationEvent) { @@ -117,6 +118,11 @@ class DulkirMod { DragonFeatures.updateDragonDead() lastLongUpdate = currTime } + + if (currTime - lastLongerUpdate > 5000) { // longer update + MemoryLeakFix.clearBlankStands() + lastLongerUpdate = currTime + } } @SubscribeEvent diff --git a/src/main/kotlin/dulkirmod/features/MemoryLeakFix.kt b/src/main/kotlin/dulkirmod/features/MemoryLeakFix.kt index dcb46ef..0bf768f 100644 --- a/src/main/kotlin/dulkirmod/features/MemoryLeakFix.kt +++ b/src/main/kotlin/dulkirmod/features/MemoryLeakFix.kt @@ -3,6 +3,7 @@ package dulkirmod.features import dulkirmod.DulkirMod.Companion.mc import dulkirmod.config.DulkirConfig import net.minecraft.entity.Entity +import net.minecraft.entity.item.EntityArmorStand import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.gameevent.TickEvent @@ -31,4 +32,15 @@ object MemoryLeakFix { private fun isNullVec(entity: Entity): Boolean { return entity.posX == 0.0 && entity.posY == 0.0 && entity.posZ == 0.0 } + + fun clearBlankStands() { + val world = mc.theWorld ?: return + val currentEnts = world.loadedEntityList + currentEnts.forEach { + if (it !is EntityArmorStand) return + if (it.name != "Armor Stand") return + if (it.inventory.any{slot -> slot != null}) return + world.removeEntityFromWorld(it.entityId) + } + } }
\ No newline at end of file |