- 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.
26 lines
860 B
Java
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);
|
|
}
|
|
}
|
|
}
|