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