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
3b288738ce
commit
d2350667a2
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.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 a new issue