mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-29 08:27:03 +01:00
Merge remote-tracking branch 'origin/mc1.15/dev' into mc1.15/dev
This commit is contained in:
commit
1739e72af0
2 changed files with 68 additions and 71 deletions
|
@ -1,23 +1,23 @@
|
||||||
package com.simibubi.create.content.contraptions.components.mixer;
|
package com.simibubi.create.content.contraptions.components.mixer;
|
||||||
|
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
|
||||||
import com.simibubi.create.AllBlockPartials;
|
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.RotatingData;
|
||||||
import com.simibubi.create.content.contraptions.base.ShaftlessCogInstance;
|
import com.simibubi.create.content.contraptions.base.ShaftlessCogInstance;
|
||||||
import com.simibubi.create.foundation.render.backend.instancing.*;
|
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.AnimationTickHolder;
|
||||||
import com.simibubi.create.foundation.utility.MatrixStacker;
|
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
|
|
||||||
public class MixerInstance extends ShaftlessCogInstance implements IDynamicInstance {
|
public class MixerInstance extends ShaftlessCogInstance implements IDynamicInstance {
|
||||||
|
|
||||||
private final InstanceKey<RotatingData> mixerHead;
|
private final InstanceKey<RotatingData> mixerHead;
|
||||||
private final InstanceKey<ModelData> mixerPole;
|
private final InstanceKey<OrientedData> mixerPole;
|
||||||
|
private final MechanicalMixerTileEntity mixer;
|
||||||
|
|
||||||
public MixerInstance(InstancedTileRenderer<?> dispatcher, KineticTileEntity tile) {
|
public MixerInstance(InstancedTileRenderer<?> dispatcher, MechanicalMixerTileEntity tile) {
|
||||||
super(dispatcher, tile);
|
super(dispatcher, tile);
|
||||||
|
this.mixer = tile;
|
||||||
|
|
||||||
mixerHead = getRotatingMaterial().getModel(AllBlockPartials.MECHANICAL_MIXER_HEAD, blockState)
|
mixerHead = getRotatingMaterial().getModel(AllBlockPartials.MECHANICAL_MIXER_HEAD, blockState)
|
||||||
.createInstance();
|
.createInstance();
|
||||||
|
@ -25,32 +25,27 @@ public class MixerInstance extends ShaftlessCogInstance implements IDynamicInsta
|
||||||
mixerHead.getInstance()
|
mixerHead.getInstance()
|
||||||
.setRotationAxis(Direction.Axis.Y);
|
.setRotationAxis(Direction.Axis.Y);
|
||||||
|
|
||||||
mixerPole = getTransformMaterial()
|
mixerPole = getOrientedMaterial()
|
||||||
.getModel(AllBlockPartials.MECHANICAL_MIXER_POLE, blockState)
|
.getModel(AllBlockPartials.MECHANICAL_MIXER_POLE, blockState)
|
||||||
.createInstance();
|
.createInstance();
|
||||||
|
|
||||||
|
|
||||||
MechanicalMixerTileEntity mixer = (MechanicalMixerTileEntity) tile;
|
float renderedHeadOffset = getRenderedHeadOffset();
|
||||||
float renderedHeadOffset = getRenderedHeadOffset(mixer);
|
|
||||||
|
|
||||||
transformPole(renderedHeadOffset);
|
transformPole(renderedHeadOffset);
|
||||||
transformHead(mixer, renderedHeadOffset);
|
transformHead(renderedHeadOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void beginFrame() {
|
public void beginFrame() {
|
||||||
MechanicalMixerTileEntity mixer = (MechanicalMixerTileEntity) tile;
|
|
||||||
|
|
||||||
float renderedHeadOffset = getRenderedHeadOffset(mixer);
|
float renderedHeadOffset = getRenderedHeadOffset();
|
||||||
|
|
||||||
if (mixer.running) {
|
|
||||||
transformPole(renderedHeadOffset);
|
transformPole(renderedHeadOffset);
|
||||||
|
transformHead(renderedHeadOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
transformHead(mixer, renderedHeadOffset);
|
private void transformHead(float renderedHeadOffset) {
|
||||||
}
|
|
||||||
|
|
||||||
private void transformHead(MechanicalMixerTileEntity mixer, float renderedHeadOffset) {
|
|
||||||
float speed = mixer.getRenderedHeadRotationSpeed(AnimationTickHolder.getPartialTicks());
|
float speed = mixer.getRenderedHeadRotationSpeed(AnimationTickHolder.getPartialTicks());
|
||||||
|
|
||||||
mixerHead.getInstance()
|
mixerHead.getInstance()
|
||||||
|
@ -60,16 +55,12 @@ public class MixerInstance extends ShaftlessCogInstance implements IDynamicInsta
|
||||||
}
|
}
|
||||||
|
|
||||||
private void transformPole(float renderedHeadOffset) {
|
private void transformPole(float renderedHeadOffset) {
|
||||||
MatrixStack ms = new MatrixStack();
|
mixerPole.getInstance()
|
||||||
|
.setPosition(getInstancePosition())
|
||||||
MatrixStacker msr = MatrixStacker.of(ms);
|
.nudge(0, -renderedHeadOffset, 0);
|
||||||
msr.translate(getInstancePosition());
|
|
||||||
msr.translate(0, -renderedHeadOffset, 0);
|
|
||||||
|
|
||||||
mixerPole.getInstance().setTransform(ms);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private float getRenderedHeadOffset(MechanicalMixerTileEntity mixer) {
|
private float getRenderedHeadOffset() {
|
||||||
return mixer.getRenderedHeadOffset(AnimationTickHolder.getPartialTicks());
|
return mixer.getRenderedHeadOffset(AnimationTickHolder.getPartialTicks());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +69,6 @@ public class MixerInstance extends ShaftlessCogInstance implements IDynamicInsta
|
||||||
super.updateLight();
|
super.updateLight();
|
||||||
|
|
||||||
relight(pos.down(), mixerHead.getInstance());
|
relight(pos.down(), mixerHead.getInstance());
|
||||||
|
|
||||||
relight(pos, mixerPole.getInstance());
|
relight(pos, mixerPole.getInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
package com.simibubi.create.content.contraptions.components.press;
|
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.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.simibubi.create.AllBlockPartials;
|
import com.simibubi.create.AllBlockPartials;
|
||||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
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.InstanceKey;
|
||||||
import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer;
|
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.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.AnimationTickHolder;
|
||||||
import com.simibubi.create.foundation.utility.MatrixStacker;
|
import com.simibubi.create.foundation.utility.MatrixStacker;
|
||||||
|
|
||||||
public class PressInstance extends ShaftInstance implements IDynamicInstance {
|
public class PressInstance extends ShaftInstance implements IDynamicInstance {
|
||||||
|
|
||||||
private final InstanceKey<ModelData> pressHead;
|
private final InstanceKey<OrientedData> pressHead;
|
||||||
private final MechanicalPressTileEntity press;
|
private final MechanicalPressTileEntity press;
|
||||||
|
|
||||||
public PressInstance(InstancedTileRenderer<?> dispatcher, MechanicalPressTileEntity tile) {
|
public PressInstance(InstancedTileRenderer<?> dispatcher, MechanicalPressTileEntity tile) {
|
||||||
super(dispatcher, tile);
|
super(dispatcher, tile);
|
||||||
press = 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();
|
transformModels();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,14 +47,9 @@ public class PressInstance extends ShaftInstance implements IDynamicInstance {
|
||||||
private void transformModels() {
|
private void transformModels() {
|
||||||
float renderedHeadOffset = getRenderedHeadOffset(press);
|
float renderedHeadOffset = getRenderedHeadOffset(press);
|
||||||
|
|
||||||
MatrixStack ms = new MatrixStack();
|
|
||||||
|
|
||||||
MatrixStacker msr = MatrixStacker.of(ms);
|
|
||||||
msr.translate(getInstancePosition());
|
|
||||||
msr.translate(0, -renderedHeadOffset, 0);
|
|
||||||
|
|
||||||
pressHead.getInstance()
|
pressHead.getInstance()
|
||||||
.setTransform(ms);
|
.setPosition(getInstancePosition())
|
||||||
|
.nudge(0, -renderedHeadOffset, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private float getRenderedHeadOffset(MechanicalPressTileEntity press) {
|
private float getRenderedHeadOffset(MechanicalPressTileEntity press) {
|
||||||
|
|
Loading…
Reference in a new issue