Port databits from newer version

This commit is contained in:
FatSaw
2023-03-07 00:45:31 +02:00
parent e627088d55
commit a8ba53b243
2 changed files with 49 additions and 1 deletions

View File

@@ -0,0 +1,47 @@
package io.akarin.server.mixin.optimization;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import net.minecraft.server.DataBits;
@Mixin(value = DataBits.class, remap = false)
public abstract class MixinDataBits {
@Shadow @Final private long[] a;
@Shadow @Final private int b;
@Shadow @Final private long c;
@Overwrite
public void a(int i, int j) {
int k = i * this.b;
int l = k >> 6;
int i1 = (i + 1) * this.b - 1 >> 6;
int j1 = k ^ l << 6;
this.a[l] = this.a[l] & ~(this.c << j1) | ((long) j & this.c) << j1;
if (l != i1) {
int k1 = 64 - j1;
int l1 = this.b - k1;
this.a[i1] = this.a[i1] >>> l1 << l1 | ((long) j & this.c) >> k1;
}
}
@Overwrite
public int a(int i) {
int j = i * this.b;
int k = j >> 6;
int l = (i + 1) * this.b - 1 >> 6;
int i1 = j ^ k << 6;
if (k == l) {
return (int) (this.a[k] >>> i1 & this.c);
} else {
int j1 = 64 - i1;
return (int) ((this.a[k] >>> i1 | this.a[l] << j1) & this.c);
}
}
}

View File

@@ -49,6 +49,7 @@
"optimization.MixinContainerHorse",
"optimization.MixinExplosion",
"optimization.MixinMathHelper",
"optimization.MixinBlockStationary"
"optimization.MixinBlockStationary",
"optimization.MixinDataBits"
]
}