mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-15 23:03:41 +01:00
Fix mixer weirdness.
- Mixer and Press instances now use the quaternion shader.
This commit is contained in:
parent
213711ce77
commit
5f49698a94
2 changed files with 68 additions and 71 deletions
|
@ -1,91 +1,81 @@
|
|||
package com.simibubi.create.content.contraptions.components.mixer;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
import com.simibubi.create.content.contraptions.base.RotatingData;
|
||||
import com.simibubi.create.content.contraptions.base.ShaftlessCogInstance;
|
||||
import com.simibubi.create.foundation.render.backend.instancing.*;
|
||||
import com.simibubi.create.foundation.render.backend.instancing.impl.ModelData;
|
||||
import com.simibubi.create.foundation.render.backend.instancing.impl.OrientedData;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
import com.simibubi.create.foundation.utility.MatrixStacker;
|
||||
|
||||
import net.minecraft.util.Direction;
|
||||
|
||||
public class MixerInstance extends ShaftlessCogInstance implements IDynamicInstance {
|
||||
|
||||
private final InstanceKey<RotatingData> mixerHead;
|
||||
private final InstanceKey<ModelData> mixerPole;
|
||||
private final InstanceKey<RotatingData> mixerHead;
|
||||
private final InstanceKey<OrientedData> mixerPole;
|
||||
private final MechanicalMixerTileEntity mixer;
|
||||
|
||||
public MixerInstance(InstancedTileRenderer<?> dispatcher, KineticTileEntity tile) {
|
||||
super(dispatcher, tile);
|
||||
public MixerInstance(InstancedTileRenderer<?> dispatcher, MechanicalMixerTileEntity tile) {
|
||||
super(dispatcher, tile);
|
||||
this.mixer = tile;
|
||||
|
||||
mixerHead = getRotatingMaterial().getModel(AllBlockPartials.MECHANICAL_MIXER_HEAD, blockState)
|
||||
.createInstance();
|
||||
mixerHead = getRotatingMaterial().getModel(AllBlockPartials.MECHANICAL_MIXER_HEAD, blockState)
|
||||
.createInstance();
|
||||
|
||||
mixerHead.getInstance()
|
||||
.setRotationAxis(Direction.Axis.Y);
|
||||
mixerHead.getInstance()
|
||||
.setRotationAxis(Direction.Axis.Y);
|
||||
|
||||
mixerPole = getTransformMaterial()
|
||||
.getModel(AllBlockPartials.MECHANICAL_MIXER_POLE, blockState)
|
||||
.createInstance();
|
||||
mixerPole = getOrientedMaterial()
|
||||
.getModel(AllBlockPartials.MECHANICAL_MIXER_POLE, blockState)
|
||||
.createInstance();
|
||||
|
||||
|
||||
MechanicalMixerTileEntity mixer = (MechanicalMixerTileEntity) tile;
|
||||
float renderedHeadOffset = getRenderedHeadOffset(mixer);
|
||||
float renderedHeadOffset = getRenderedHeadOffset();
|
||||
|
||||
transformPole(renderedHeadOffset);
|
||||
transformHead(mixer, renderedHeadOffset);
|
||||
}
|
||||
transformPole(renderedHeadOffset);
|
||||
transformHead(renderedHeadOffset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beginFrame() {
|
||||
MechanicalMixerTileEntity mixer = (MechanicalMixerTileEntity) tile;
|
||||
@Override
|
||||
public void beginFrame() {
|
||||
|
||||
float renderedHeadOffset = getRenderedHeadOffset(mixer);
|
||||
float renderedHeadOffset = getRenderedHeadOffset();
|
||||
|
||||
if (mixer.running) {
|
||||
transformPole(renderedHeadOffset);
|
||||
}
|
||||
transformPole(renderedHeadOffset);
|
||||
transformHead(renderedHeadOffset);
|
||||
}
|
||||
|
||||
transformHead(mixer, renderedHeadOffset);
|
||||
}
|
||||
private void transformHead(float renderedHeadOffset) {
|
||||
float speed = mixer.getRenderedHeadRotationSpeed(AnimationTickHolder.getPartialTicks());
|
||||
|
||||
private void transformHead(MechanicalMixerTileEntity mixer, float renderedHeadOffset) {
|
||||
float speed = mixer.getRenderedHeadRotationSpeed(AnimationTickHolder.getPartialTicks());
|
||||
mixerHead.getInstance()
|
||||
.setPosition(getInstancePosition())
|
||||
.nudge(0, -renderedHeadOffset, 0)
|
||||
.setRotationalSpeed(speed * 2);
|
||||
}
|
||||
|
||||
mixerHead.getInstance()
|
||||
.setPosition(getInstancePosition())
|
||||
.nudge(0, -renderedHeadOffset, 0)
|
||||
.setRotationalSpeed(speed * 2);
|
||||
}
|
||||
private void transformPole(float renderedHeadOffset) {
|
||||
mixerPole.getInstance()
|
||||
.setPosition(getInstancePosition())
|
||||
.nudge(0, -renderedHeadOffset, 0);
|
||||
}
|
||||
|
||||
private void transformPole(float renderedHeadOffset) {
|
||||
MatrixStack ms = new MatrixStack();
|
||||
private float getRenderedHeadOffset() {
|
||||
return mixer.getRenderedHeadOffset(AnimationTickHolder.getPartialTicks());
|
||||
}
|
||||
|
||||
MatrixStacker msr = MatrixStacker.of(ms);
|
||||
msr.translate(getInstancePosition());
|
||||
msr.translate(0, -renderedHeadOffset, 0);
|
||||
@Override
|
||||
public void updateLight() {
|
||||
super.updateLight();
|
||||
|
||||
mixerPole.getInstance().setTransform(ms);
|
||||
}
|
||||
relight(pos.down(), mixerHead.getInstance());
|
||||
relight(pos, mixerPole.getInstance());
|
||||
}
|
||||
|
||||
private float getRenderedHeadOffset(MechanicalMixerTileEntity mixer) {
|
||||
return mixer.getRenderedHeadOffset(AnimationTickHolder.getPartialTicks());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateLight() {
|
||||
super.updateLight();
|
||||
|
||||
relight(pos.down(), mixerHead.getInstance());
|
||||
|
||||
relight(pos, mixerPole.getInstance());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
super.remove();
|
||||
mixerHead.delete();
|
||||
mixerPole.delete();
|
||||
}
|
||||
@Override
|
||||
public void remove() {
|
||||
super.remove();
|
||||
mixerHead.delete();
|
||||
mixerPole.delete();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package com.simibubi.create.content.contraptions.components.press;
|
||||
|
||||
import net.minecraft.client.renderer.Quaternion;
|
||||
import net.minecraft.client.renderer.Vector3f;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
|
@ -8,19 +11,28 @@ import com.simibubi.create.foundation.render.backend.instancing.IDynamicInstance
|
|||
import com.simibubi.create.foundation.render.backend.instancing.InstanceKey;
|
||||
import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer;
|
||||
import com.simibubi.create.foundation.render.backend.instancing.impl.ModelData;
|
||||
import com.simibubi.create.foundation.render.backend.instancing.impl.OrientedData;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
import com.simibubi.create.foundation.utility.MatrixStacker;
|
||||
|
||||
public class PressInstance extends ShaftInstance implements IDynamicInstance {
|
||||
|
||||
private final InstanceKey<ModelData> pressHead;
|
||||
private final InstanceKey<OrientedData> pressHead;
|
||||
private final MechanicalPressTileEntity press;
|
||||
|
||||
public PressInstance(InstancedTileRenderer<?> dispatcher, MechanicalPressTileEntity tile) {
|
||||
super(dispatcher, tile);
|
||||
press = tile;
|
||||
|
||||
pressHead = AllBlockPartials.MECHANICAL_PRESS_HEAD.renderOnHorizontalModel(dispatcher, blockState).createInstance();
|
||||
pressHead = dispatcher.getOrientedMaterial()
|
||||
.getModel(AllBlockPartials.MECHANICAL_PRESS_HEAD, blockState)
|
||||
.createInstance();
|
||||
|
||||
Quaternion q = Vector3f.POSITIVE_Y.getDegreesQuaternion(AngleHelper.horizontalAngle(blockState.get(MechanicalPressBlock.HORIZONTAL_FACING)));
|
||||
|
||||
pressHead.getInstance().setRotation(q);
|
||||
|
||||
transformModels();
|
||||
}
|
||||
|
||||
|
@ -35,14 +47,9 @@ public class PressInstance extends ShaftInstance implements IDynamicInstance {
|
|||
private void transformModels() {
|
||||
float renderedHeadOffset = getRenderedHeadOffset(press);
|
||||
|
||||
MatrixStack ms = new MatrixStack();
|
||||
|
||||
MatrixStacker msr = MatrixStacker.of(ms);
|
||||
msr.translate(getInstancePosition());
|
||||
msr.translate(0, -renderedHeadOffset, 0);
|
||||
|
||||
pressHead.getInstance()
|
||||
.setTransform(ms);
|
||||
.setPosition(getInstancePosition())
|
||||
.nudge(0, -renderedHeadOffset, 0);
|
||||
}
|
||||
|
||||
private float getRenderedHeadOffset(MechanicalPressTileEntity press) {
|
||||
|
|
Loading…
Reference in a new issue