Merge remote-tracking branch 'origin/mc1.15/dev' into mc1.15/dev

This commit is contained in:
grimmauld 2021-03-28 00:21:13 +01:00
commit 1739e72af0
2 changed files with 68 additions and 71 deletions

View file

@ -1,23 +1,23 @@
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<OrientedData> mixerPole;
private final MechanicalMixerTileEntity mixer;
public MixerInstance(InstancedTileRenderer<?> dispatcher, KineticTileEntity tile) {
public MixerInstance(InstancedTileRenderer<?> dispatcher, MechanicalMixerTileEntity tile) {
super(dispatcher, tile);
this.mixer = tile;
mixerHead = getRotatingMaterial().getModel(AllBlockPartials.MECHANICAL_MIXER_HEAD, blockState)
.createInstance();
@ -25,32 +25,27 @@ public class MixerInstance extends ShaftlessCogInstance implements IDynamicInsta
mixerHead.getInstance()
.setRotationAxis(Direction.Axis.Y);
mixerPole = getTransformMaterial()
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);
transformHead(renderedHeadOffset);
}
@Override
public void beginFrame() {
MechanicalMixerTileEntity mixer = (MechanicalMixerTileEntity) tile;
float renderedHeadOffset = getRenderedHeadOffset(mixer);
float renderedHeadOffset = getRenderedHeadOffset();
if (mixer.running) {
transformPole(renderedHeadOffset);
transformHead(renderedHeadOffset);
}
transformHead(mixer, renderedHeadOffset);
}
private void transformHead(MechanicalMixerTileEntity mixer, float renderedHeadOffset) {
private void transformHead(float renderedHeadOffset) {
float speed = mixer.getRenderedHeadRotationSpeed(AnimationTickHolder.getPartialTicks());
mixerHead.getInstance()
@ -60,16 +55,12 @@ public class MixerInstance extends ShaftlessCogInstance implements IDynamicInsta
}
private void transformPole(float renderedHeadOffset) {
MatrixStack ms = new MatrixStack();
MatrixStacker msr = MatrixStacker.of(ms);
msr.translate(getInstancePosition());
msr.translate(0, -renderedHeadOffset, 0);
mixerPole.getInstance().setTransform(ms);
mixerPole.getInstance()
.setPosition(getInstancePosition())
.nudge(0, -renderedHeadOffset, 0);
}
private float getRenderedHeadOffset(MechanicalMixerTileEntity mixer) {
private float getRenderedHeadOffset() {
return mixer.getRenderedHeadOffset(AnimationTickHolder.getPartialTicks());
}
@ -78,7 +69,6 @@ public class MixerInstance extends ShaftlessCogInstance implements IDynamicInsta
super.updateLight();
relight(pos.down(), mixerHead.getInstance());
relight(pos, mixerPole.getInstance());
}

View file

@ -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) {