mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2024-12-28 16:06:28 +01:00
Fix bell not stopping at the bottom of its swing
This commit is contained in:
parent
88b00e2ce2
commit
f0822a5cd4
1 changed files with 11 additions and 2 deletions
|
@ -12,12 +12,15 @@ import com.jozufozu.flywheel.util.AnimationTickHolder;
|
|||
import net.minecraft.client.renderer.tileentity.BellTileEntityRenderer;
|
||||
import net.minecraft.tileentity.BellTileEntity;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.vector.Quaternion;
|
||||
import net.minecraft.util.math.vector.Vector3f;
|
||||
|
||||
public class BellInstance extends TileEntityInstance<BellTileEntity> implements IDynamicInstance {
|
||||
|
||||
private final OrientedData bell;
|
||||
|
||||
private float lastRingTime = Float.NaN;
|
||||
|
||||
public BellInstance(MaterialManager<?> materialManager, BellTileEntity tile) {
|
||||
super(materialManager, tile);
|
||||
|
||||
|
@ -28,13 +31,19 @@ public class BellInstance extends TileEntityInstance<BellTileEntity> implements
|
|||
|
||||
@Override
|
||||
public void beginFrame() {
|
||||
float ringTime = (float)tile.ringingTicks + AnimationTickHolder.getPartialTicks();
|
||||
|
||||
if (ringTime == lastRingTime) return;
|
||||
lastRingTime = ringTime;
|
||||
|
||||
if (tile.isRinging) {
|
||||
float ringness = (float)tile.ringingTicks + AnimationTickHolder.getPartialTicks();
|
||||
float angle = MathHelper.sin(ringness / (float)Math.PI) / (4.0F + ringness / 3.0F);
|
||||
float angle = MathHelper.sin(ringTime / (float) Math.PI) / (4.0F + ringTime / 3.0F);
|
||||
|
||||
Vector3f ringAxis = tile.ringDirection.rotateYCCW().getUnitVector();
|
||||
|
||||
bell.setRotation(ringAxis.getRadialQuaternion(angle));
|
||||
} else {
|
||||
bell.setRotation(Quaternion.IDENTITY);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue