repo for my hex addons :3
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

phlib: intrusive holder tracking

+41 -2
+1
util/changelog
··· 1 + 0.1.2 intrusive holder allocation tracking
+1 -1
util/gradle.properties
··· 2 2 yarn_mappings=1.20.1+build.10 3 3 loader_version=0.16.14 4 4 scala_loader_version=0.3.1.11 5 - version=0.1.1 5 + version=0.1.2 6 6 maven_group=org.eu.net.pool 7 7 modid=phlib 8 8 archives_base_name=phlib
+2
util/src/main/resources/phlib.mixins.json
··· 4 4 "package": "org.eu.net.pool.phlib.mixin", 5 5 "compatibilityLevel": "JAVA_17", 6 6 "mixins": [ 7 + "ActuallySimpleRegistryMixin", 8 + "AllocationTrackerMixin", 7 9 "PatternIotaMixin", 8 10 "SimpleRegistryMixin" 9 11 ]
+12 -1
util/src/main/scala/org/eu/net/pool/phlib/main.scala
··· 155 155 env.addExtension: 156 156 new CastingEnvironmentComponent with CastingEnvironmentComponent.PostExecution: 157 157 override def getKey: CastingEnvironmentComponent.Key[?] = key 158 - 159 158 override def onPostExecution(result: CastResult): Unit = 160 159 result.getSideEffects.collectFirst: 161 160 case m: OperatorSideEffect.DoMishap => ··· 244 243 extension (p: ServerPlayerEntity) def gimmeIota(iota: Iota): Unit = 245 244 val m = p.getComponent(HexCardinalComponents.STAFFCAST_IMAGE) 246 245 m.setImage(m.getVM(Hand.MAIN_HAND).getImage.withStack(_ ++ Vector(iota))) 246 + 247 + private[phlib] trait AllocationTracked: 248 + private[phlib] val phlib$createdAt: Exception 249 + 250 + package mixin: 251 + import net.minecraft.block.Block 252 + import net.minecraft.item.Item 253 + import org.spongepowered.asm.mixin.injection.{At, Inject} 254 + import org.spongepowered.asm.mixin.Mixin 255 + @Mixin(value = Array(classOf[Item], classOf[Block])) 256 + private[phlib] class AllocationTrackerMixin() extends AnyRef with AllocationTracked: 257 + private[phlib] val phlib$createdAt: Exception = new RuntimeException(s"unregistered $this ($getClass) created") 247 258 248 259 // this is out-of-scope for phlib but I have no idea where else to put it 249 260 def init() =
+25
util/src/main/scala/org/eu/net/pool/phlib/mixin/ActuallySimpleRegistryMixin.java
··· 1 + package org.eu.net.pool.phlib.mixin; 2 + 3 + import com.llamalad7.mixinextras.injector.ModifyExpressionValue; 4 + import net.minecraft.registry.SimpleRegistry; 5 + import net.minecraft.registry.entry.RegistryEntry; 6 + import org.eu.net.pool.phlib.AllocationTracked; 7 + import org.jetbrains.annotations.Nullable; 8 + import org.spongepowered.asm.mixin.Mixin; 9 + import org.spongepowered.asm.mixin.Shadow; 10 + import org.spongepowered.asm.mixin.injection.At; 11 + 12 + import java.util.Map; 13 + 14 + @Mixin(SimpleRegistry.class) 15 + public class ActuallySimpleRegistryMixin<T> { 16 + @Shadow private Map<T, RegistryEntry.Reference<T>> intrusiveValueToEntry; 17 + 18 + @ModifyExpressionValue(method = "freeze", at = @At(value = "NEW", target = "(Ljava/lang/String;)Ljava/lang/IllegalStateException;", ordinal = 1)) 19 + IllegalStateException addSuppressed(IllegalStateException original) { 20 + for (var entry: intrusiveValueToEntry.entrySet()) { 21 + if (entry.getKey() instanceof AllocationTracked t) original.addSuppressed(t.phlib$createdAt()); 22 + } 23 + return original; 24 + } 25 + }