-
Notifications
You must be signed in to change notification settings - Fork 3
/
AbstractBlockMixin.java
30 lines (25 loc) · 1.17 KB
/
AbstractBlockMixin.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package com.jorianwoltjer.liveoverflowmod.mixin;
import net.minecraft.block.AbstractBlock;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3i;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import java.util.Objects;
import java.util.Random;
import static com.jorianwoltjer.liveoverflowmod.client.ClientEntrypoint.passiveMods;
@Mixin(AbstractBlock.class)
public class AbstractBlockMixin {
private static final long xFactor = new Random().nextLong();
private static final long yFactor = new Random().nextLong();
private static final long zFactor = new Random().nextLong();
// Randomize texture rotations (prevent leaks)
@Redirect(method="getRenderingSeed", at=@At(value="INVOKE", target="Lnet/minecraft/util/math/MathHelper;hashCode(Lnet/minecraft/util/math/Vec3i;)J"))
private long getSeed(Vec3i vec) {
if (passiveMods.enabled) {
return Objects.hash(vec.getX() * xFactor, vec.getY() * yFactor, vec.getZ() * zFactor);
} else {
return MathHelper.hashCode(vec);
}
}
}