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,91 +1,81 @@
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();
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) {
} float speed = mixer.getRenderedHeadRotationSpeed(AnimationTickHolder.getPartialTicks());
private void transformHead(MechanicalMixerTileEntity mixer, float renderedHeadOffset) { mixerHead.getInstance()
float speed = mixer.getRenderedHeadRotationSpeed(AnimationTickHolder.getPartialTicks()); .setPosition(getInstancePosition())
.nudge(0, -renderedHeadOffset, 0)
.setRotationalSpeed(speed * 2);
}
mixerHead.getInstance() private void transformPole(float renderedHeadOffset) {
.setPosition(getInstancePosition()) mixerPole.getInstance()
.nudge(0, -renderedHeadOffset, 0) .setPosition(getInstancePosition())
.setRotationalSpeed(speed * 2); .nudge(0, -renderedHeadOffset, 0);
} }
private void transformPole(float renderedHeadOffset) { private float getRenderedHeadOffset() {
MatrixStack ms = new MatrixStack(); return mixer.getRenderedHeadOffset(AnimationTickHolder.getPartialTicks());
}
MatrixStacker msr = MatrixStacker.of(ms); @Override
msr.translate(getInstancePosition()); public void updateLight() {
msr.translate(0, -renderedHeadOffset, 0); super.updateLight();
mixerPole.getInstance().setTransform(ms); relight(pos.down(), mixerHead.getInstance());
} relight(pos, mixerPole.getInstance());
}
private float getRenderedHeadOffset(MechanicalMixerTileEntity mixer) { @Override
return mixer.getRenderedHeadOffset(AnimationTickHolder.getPartialTicks()); public void remove() {
} super.remove();
mixerHead.delete();
@Override mixerPole.delete();
public void updateLight() { }
super.updateLight();
relight(pos.down(), mixerHead.getInstance());
relight(pos, mixerPole.getInstance());
}
@Override
public void remove() {
super.remove();
mixerHead.delete();
mixerPole.delete();
}
} }

View file

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