ChipiMod/src/main/java/net/Chipperfluff/chipi/mixin/DataTrackerMixin.java
lordlogo2002 6b95a3891f Refactor imports and improve code organization across multiple classes
- Reordered and grouped import statements in various files for better readability.
- Removed unnecessary imports and cleaned up unused code.
- Simplified constructors and methods in several classes to enhance clarity.
- Standardized formatting and spacing for consistency throughout the codebase.
- Ensured that all necessary imports are included where required, particularly in structure-related classes.
2025-12-25 16:34:58 +01:00

26 lines
860 B
Java

package net.Chipperfluff.chipi.mixin;
import net.minecraft.entity.data.DataTracker;
import net.minecraft.entity.data.TrackedData;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(DataTracker.class)
public abstract class DataTrackerMixin {
@Shadow
protected abstract <T> DataTracker.Entry<T> getEntry(TrackedData<T> data);
@Inject(method = "get", at = @At("HEAD"), cancellable = true)
private <T> void chipi$nullSafeGet(TrackedData<T> data, CallbackInfoReturnable<T> cir) {
DataTracker.Entry<T> entry = this.getEntry(data);
if (entry == null) {
cir.setReturnValue(null);
}
}
}