mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2024-11-14 06:24:12 +01:00
restore old tile rendering from 3336778052
This commit is contained in:
parent
2aa06b0786
commit
5ba4477ada
@ -1,25 +1,27 @@
|
||||
package com.simibubi.create.content.contraptions.base;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.CreateClient;
|
||||
import com.simibubi.create.content.contraptions.KineticDebugger;
|
||||
import com.simibubi.create.content.contraptions.relays.elementary.CogWheelBlock;
|
||||
import com.simibubi.create.foundation.render.Compartment;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.render.instancing.InstancedModel;
|
||||
import com.simibubi.create.foundation.render.instancing.RotatingData;
|
||||
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
import com.simibubi.create.foundation.utility.ColorHelper;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.render.Compartment;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.RenderTypeLookup;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.state.properties.BlockStateProperties;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Direction.Axis;
|
||||
import net.minecraft.util.Direction.AxisDirection;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.LightType;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||
|
||||
@ -36,11 +38,20 @@ public class KineticTileEntityRenderer extends SafeTileEntityRenderer<KineticTil
|
||||
@Override
|
||||
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
||||
int light, int overlay) {
|
||||
// for (RenderType type : RenderType.getBlockLayers())
|
||||
// if (RenderTypeLookup.canRenderInLayer(te.getBlockState(), type))
|
||||
// renderRotatingBuffer(te, getRotatedModel(te));
|
||||
for (RenderType type : RenderType.getBlockLayers())
|
||||
if (RenderTypeLookup.canRenderInLayer(te.getBlockState(), type))
|
||||
renderRotatingBuffer(te, getRotatedModel(te), ms, buffer.getBuffer(type), light);
|
||||
}
|
||||
|
||||
// addInstanceData(new InstanceContext.World<>(te));
|
||||
public static void renderRotatingKineticBlock(KineticTileEntity te, BlockState renderedState, MatrixStack ms,
|
||||
IVertexBuilder buffer, int light) {
|
||||
SuperByteBuffer superByteBuffer = CreateClient.bufferCache.renderBlockIn(KINETIC_TILE, renderedState);
|
||||
renderRotatingBuffer(te, superByteBuffer, ms, buffer, light);
|
||||
}
|
||||
|
||||
public static void renderRotatingBuffer(KineticTileEntity te, SuperByteBuffer superBuffer, MatrixStack ms,
|
||||
IVertexBuilder buffer, int light) {
|
||||
standardKineticRotationTransform(superBuffer, te, light).renderInto(ms, buffer);
|
||||
}
|
||||
|
||||
public static float getAngleForTe(KineticTileEntity te, final BlockPos pos, Axis axis) {
|
||||
@ -105,5 +116,8 @@ public class KineticTileEntityRenderer extends SafeTileEntityRenderer<KineticTil
|
||||
return te.getBlockState();
|
||||
}
|
||||
|
||||
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
|
||||
return CreateClient.bufferCache.renderBlockIn(KINETIC_TILE, getRenderedBlockState(te));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,11 +3,15 @@ package com.simibubi.create.content.contraptions.components.actors;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
import com.simibubi.create.content.contraptions.base.SingleRotatingInstance;
|
||||
import com.simibubi.create.foundation.render.instancing.InstancedTileRenderer;
|
||||
import com.simibubi.create.foundation.render.instancing.InstancedModel;
|
||||
import com.simibubi.create.foundation.render.instancing.InstancedTileRenderRegistry;
|
||||
import com.simibubi.create.foundation.render.instancing.RotatingData;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
||||
import com.simibubi.create.foundation.render.contraption.RenderedContraption;
|
||||
import com.simibubi.create.foundation.render.instancing.*;
|
||||
import com.simibubi.create.foundation.render.instancing.actors.StaticRotatingActorData;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.world.LightType;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
|
||||
@ -20,6 +24,24 @@ public class DrillInstance extends SingleRotatingInstance {
|
||||
super(modelManager, tile);
|
||||
}
|
||||
|
||||
public static void addInstanceForContraption(RenderedContraption contraption, MovementContext context) {
|
||||
RenderMaterial<?, InstancedModel<StaticRotatingActorData>> renderMaterial = contraption.getActorMaterial();
|
||||
|
||||
BlockState state = context.state;
|
||||
InstancedModel<StaticRotatingActorData> model = renderMaterial.getModel(AllBlockPartials.DRILL_HEAD, state);
|
||||
|
||||
model.setupInstance(data -> {
|
||||
Direction facing = state.get(DrillBlock.FACING);
|
||||
float eulerX = AngleHelper.verticalAngle(facing) + ((facing.getAxis() == Direction.Axis.Y) ? 180 : 0);
|
||||
float eulerY = facing.getHorizontalAngle();
|
||||
data.setPosition(context.localPos)
|
||||
.setBlockLight(contraption.renderWorld.getLightLevel(LightType.BLOCK, context.localPos))
|
||||
.setRotationOffset(0)
|
||||
.setRotationAxis(0, 0, 1)
|
||||
.setLocalRotation(eulerX, eulerY, 0);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected InstancedModel<RotatingData> getModel() {
|
||||
return AllBlockPartials.DRILL_HEAD.renderOnDirectionalSouthRotating(modelManager, tile.getBlockState());
|
||||
|
@ -42,7 +42,7 @@ public class DrillMovementBehaviour extends BlockBreakingMovementBehaviour {
|
||||
|
||||
@Override
|
||||
public void addInstance(RenderedContraption contraption, MovementContext context) {
|
||||
DrillRenderer.addInstanceForContraption(contraption, context);
|
||||
DrillInstance.addInstanceForContraption(contraption, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,28 +1,23 @@
|
||||
package com.simibubi.create.content.contraptions.components.actors;
|
||||
|
||||
import static net.minecraft.state.properties.BlockStateProperties.FACING;
|
||||
|
||||
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.KineticTileEntityRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.render.contraption.ContraptionProgram;
|
||||
import com.simibubi.create.foundation.render.contraption.RenderedContraption;
|
||||
import com.simibubi.create.foundation.render.instancing.InstancedModel;
|
||||
import com.simibubi.create.foundation.render.instancing.RenderMaterial;
|
||||
import com.simibubi.create.foundation.render.instancing.actors.StaticRotatingActorData;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
import com.simibubi.create.foundation.utility.MatrixStacker;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.utility.VecHelper;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.world.LightType;
|
||||
|
||||
import static net.minecraft.state.properties.BlockStateProperties.FACING;
|
||||
|
||||
public class DrillRenderer extends KineticTileEntityRenderer {
|
||||
|
||||
@ -30,26 +25,13 @@ public class DrillRenderer extends KineticTileEntityRenderer {
|
||||
super(dispatcher);
|
||||
}
|
||||
|
||||
protected static SuperByteBuffer getRotatingModel(BlockState state) {
|
||||
return AllBlockPartials.DRILL_HEAD.renderOnDirectionalSouth(state);
|
||||
@Override
|
||||
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
|
||||
return AllBlockPartials.DRILL_HEAD.renderOnDirectionalSouth(te.getBlockState());
|
||||
}
|
||||
|
||||
public static void addInstanceForContraption(RenderedContraption contraption, MovementContext context) {
|
||||
RenderMaterial<?, InstancedModel<StaticRotatingActorData>> renderMaterial = contraption.getActorMaterial();
|
||||
|
||||
BlockState state = context.state;
|
||||
InstancedModel<StaticRotatingActorData> model = renderMaterial.getModel(AllBlockPartials.DRILL_HEAD, state);
|
||||
|
||||
model.setupInstance(data -> {
|
||||
Direction facing = state.get(DrillBlock.FACING);
|
||||
float eulerX = AngleHelper.verticalAngle(facing) + ((facing.getAxis() == Direction.Axis.Y) ? 180 : 0);
|
||||
float eulerY = facing.getHorizontalAngle();
|
||||
data.setPosition(context.localPos)
|
||||
.setBlockLight(contraption.renderWorld.getLightLevel(LightType.BLOCK, context.localPos))
|
||||
.setRotationOffset(0)
|
||||
.setRotationAxis(0, 0, 1)
|
||||
.setLocalRotation(eulerX, eulerY, 0);
|
||||
});
|
||||
protected static SuperByteBuffer getRotatingModel(BlockState state) {
|
||||
return AllBlockPartials.DRILL_HEAD.renderOnDirectionalSouth(state);
|
||||
}
|
||||
|
||||
public static void renderInContraption(MovementContext context, MatrixStack ms, MatrixStack msLocal,
|
||||
|
@ -1,9 +1,10 @@
|
||||
package com.simibubi.create.content.contraptions.components.actors;
|
||||
|
||||
import static net.minecraft.state.properties.BlockStateProperties.HORIZONTAL_FACING;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.render.contraption.RenderedContraption;
|
||||
import com.simibubi.create.foundation.render.instancing.InstancedModel;
|
||||
import com.simibubi.create.foundation.render.instancing.RenderMaterial;
|
||||
@ -11,7 +12,9 @@ import com.simibubi.create.foundation.render.instancing.actors.StaticRotatingAct
|
||||
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.utility.VecHelper;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
@ -22,8 +25,6 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.LightType;
|
||||
|
||||
import static net.minecraft.state.properties.BlockStateProperties.HORIZONTAL_FACING;
|
||||
|
||||
public class HarvesterRenderer extends SafeTileEntityRenderer<HarvesterTileEntity> {
|
||||
|
||||
public HarvesterRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||
@ -82,4 +83,7 @@ public class HarvesterRenderer extends SafeTileEntityRenderer<HarvesterTileEntit
|
||||
.getModel())
|
||||
.renderInto(ms, buffers.getBuffer(RenderType.getCutoutMipped()));
|
||||
}
|
||||
|
||||
public static void transformHead(MatrixStack ms, float angle) {}
|
||||
|
||||
}
|
||||
|
@ -6,10 +6,9 @@ import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.clock.CuckooClockTileEntity.Animation;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.render.instancing.InstancedModel;
|
||||
import com.simibubi.create.foundation.render.instancing.RotatingData;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
@ -90,6 +89,17 @@ public class CuckooClockRenderer extends KineticTileEntityRenderer {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
|
||||
return transform(AllBlockPartials.SHAFT_HALF, te);
|
||||
}
|
||||
|
||||
private SuperByteBuffer transform(AllBlockPartials partial, KineticTileEntity te) {
|
||||
return partial.renderOnDirectionalSouth(te.getBlockState(), te.getBlockState()
|
||||
.get(CuckooClockBlock.HORIZONTAL_FACING)
|
||||
.getOpposite());
|
||||
}
|
||||
|
||||
private SuperByteBuffer rotateHand(SuperByteBuffer buffer, float angle, Direction facing) {
|
||||
float pivotX = 2 / 16f;
|
||||
float pivotY = 6 / 16f;
|
||||
|
@ -26,6 +26,7 @@ import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
import static com.simibubi.create.content.contraptions.base.HorizontalKineticBlock.HORIZONTAL_FACING;
|
||||
import static com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer.standardKineticRotationTransform;
|
||||
|
||||
public class MechanicalCrafterRenderer extends SafeTileEntityRenderer<MechanicalCrafterTileEntity> {
|
||||
|
||||
@ -151,12 +152,12 @@ public class MechanicalCrafterRenderer extends SafeTileEntityRenderer<Mechanical
|
||||
BlockState blockState = te.getBlockState();
|
||||
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
|
||||
|
||||
// SuperByteBuffer superBuffer = AllBlockPartials.SHAFTLESS_COGWHEEL.renderOn(blockState);
|
||||
// standardKineticRotationTransform(superBuffer, te, light);
|
||||
// superBuffer.rotateCentered(Direction.UP, (float) (blockState.get(HORIZONTAL_FACING)
|
||||
// .getAxis() != Axis.X ? 0 : Math.PI / 2));
|
||||
// superBuffer.rotateCentered(Direction.EAST, (float) (Math.PI / 2));
|
||||
// superBuffer.renderInto(ms, vb);
|
||||
SuperByteBuffer superBuffer = AllBlockPartials.SHAFTLESS_COGWHEEL.renderOn(blockState);
|
||||
standardKineticRotationTransform(superBuffer, te, light);
|
||||
superBuffer.rotateCentered(Direction.UP, (float) (blockState.get(HORIZONTAL_FACING)
|
||||
.getAxis() != Direction.Axis.X ? 0 : Math.PI / 2));
|
||||
superBuffer.rotateCentered(Direction.EAST, (float) (Math.PI / 2));
|
||||
superBuffer.renderInto(ms, vb);
|
||||
|
||||
Direction targetDirection = MechanicalCrafterBlock.getTargetDirection(blockState);
|
||||
BlockPos pos = te.getPos();
|
||||
|
@ -1,5 +1,8 @@
|
||||
package com.simibubi.create.content.contraptions.components.deployer;
|
||||
|
||||
import static com.simibubi.create.content.contraptions.base.DirectionalAxisKineticBlock.AXIS_ALONG_FIRST_COORDINATE;
|
||||
import static com.simibubi.create.content.contraptions.base.DirectionalKineticBlock.FACING;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
@ -8,16 +11,22 @@ import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.deployer.DeployerTileEntity.Mode;
|
||||
import com.simibubi.create.content.contraptions.components.deployer.DeployerTileEntity.State;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringRenderer;
|
||||
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
import com.simibubi.create.foundation.utility.NBTHelper;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.utility.VecHelper;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.*;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.ItemRenderer;
|
||||
import net.minecraft.client.renderer.Matrix4f;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.Vector3f;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.item.BlockItem;
|
||||
@ -28,27 +37,18 @@ import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import static com.simibubi.create.content.contraptions.base.DirectionalAxisKineticBlock.AXIS_ALONG_FIRST_COORDINATE;
|
||||
import static com.simibubi.create.content.contraptions.base.DirectionalKineticBlock.FACING;
|
||||
|
||||
public class DeployerRenderer extends SafeTileEntityRenderer<DeployerTileEntity> {
|
||||
|
||||
public DeployerRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||
super(dispatcher);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGlobalRenderer(DeployerTileEntity te) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderSafe(DeployerTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
||||
int light, int overlay) {
|
||||
renderItem(te, partialTicks, ms, buffer, light, overlay);
|
||||
FilteringRenderer.renderOnTileEntity(te, partialTicks, ms, buffer, light, overlay);
|
||||
renderComponents(te, partialTicks, ms, buffer, light, overlay);
|
||||
|
||||
}
|
||||
|
||||
protected void renderItem(DeployerTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
||||
@ -102,6 +102,7 @@ public class DeployerRenderer extends SafeTileEntityRenderer<DeployerTileEntity>
|
||||
protected void renderComponents(DeployerTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
||||
int light, int overlay) {
|
||||
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
|
||||
KineticTileEntityRenderer.renderRotatingKineticBlock(te, getRenderedBlockState(te), ms, vb, light);
|
||||
|
||||
BlockState blockState = te.getBlockState();
|
||||
BlockPos pos = te.getPos();
|
||||
@ -111,9 +112,9 @@ public class DeployerRenderer extends SafeTileEntityRenderer<DeployerTileEntity>
|
||||
SuperByteBuffer hand = te.getHandPose()
|
||||
.renderOn(blockState);
|
||||
|
||||
transform(te.getWorld(), (SuperByteBuffer) pole.translate(offset.x, offset.y, offset.z), blockState, pos, true).renderInto(ms,
|
||||
transform(te.getWorld(), pole.translate(offset.x, offset.y, offset.z), blockState, pos, true).renderInto(ms,
|
||||
vb);
|
||||
transform(te.getWorld(), (SuperByteBuffer) hand.translate(offset.x, offset.y, offset.z), blockState, pos, false).renderInto(ms,
|
||||
transform(te.getWorld(), hand.translate(offset.x, offset.y, offset.z), blockState, pos, false).renderInto(ms,
|
||||
vb);
|
||||
}
|
||||
|
||||
|
@ -1,20 +1,21 @@
|
||||
package com.simibubi.create.content.contraptions.components.fan;
|
||||
|
||||
import static net.minecraft.state.properties.BlockStateProperties.FACING;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.IRotate;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
||||
import com.simibubi.create.foundation.render.instancing.InstancedModel;
|
||||
import com.simibubi.create.foundation.render.instancing.RotatingData;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.LightType;
|
||||
|
||||
import static net.minecraft.state.properties.BlockStateProperties.FACING;
|
||||
|
||||
public class EncasedFanRenderer extends KineticTileEntityRenderer {
|
||||
|
||||
@ -25,7 +26,29 @@ public class EncasedFanRenderer extends KineticTileEntityRenderer {
|
||||
@Override
|
||||
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
||||
int light, int overlay) {
|
||||
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
|
||||
Direction direction = te.getBlockState()
|
||||
.get(FACING);
|
||||
IVertexBuilder vb = buffer.getBuffer(RenderType.getCutoutMipped());
|
||||
|
||||
int lightBehind = WorldRenderer.getLightmapCoordinates(te.getWorld(), te.getPos().offset(direction.getOpposite()));
|
||||
int lightInFront = WorldRenderer.getLightmapCoordinates(te.getWorld(), te.getPos().offset(direction));
|
||||
|
||||
SuperByteBuffer shaftHalf =
|
||||
AllBlockPartials.SHAFT_HALF.renderOnDirectionalSouth(te.getBlockState(), direction.getOpposite());
|
||||
SuperByteBuffer fanInner =
|
||||
AllBlockPartials.ENCASED_FAN_INNER.renderOnDirectionalSouth(te.getBlockState(), direction.getOpposite());
|
||||
|
||||
float time = AnimationTickHolder.getRenderTick();
|
||||
float speed = te.getSpeed() * 5;
|
||||
if (speed > 0)
|
||||
speed = MathHelper.clamp(speed, 80, 64 * 20);
|
||||
if (speed < 0)
|
||||
speed = MathHelper.clamp(speed, -64 * 20, -80);
|
||||
float angle = (time * speed * 3 / 10f) % 360;
|
||||
angle = angle / 180f * (float) Math.PI;
|
||||
|
||||
standardKineticRotationTransform(shaftHalf, te, lightBehind).renderInto(ms, vb);
|
||||
kineticRotationTransform(fanInner, te, direction.getAxis(), angle, lightInFront).renderInto(ms, vb);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,15 +1,16 @@
|
||||
package com.simibubi.create.content.contraptions.components.flywheel;
|
||||
|
||||
import static com.simibubi.create.content.contraptions.base.HorizontalKineticBlock.HORIZONTAL_FACING;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.flywheel.FlywheelBlock.ConnectionState;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.render.instancing.InstancedModel;
|
||||
import com.simibubi.create.foundation.render.instancing.RotatingData;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
@ -21,8 +22,6 @@ import net.minecraft.util.Direction.AxisDirection;
|
||||
import net.minecraft.util.Rotation;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
import static com.simibubi.create.content.contraptions.base.HorizontalKineticBlock.HORIZONTAL_FACING;
|
||||
|
||||
public class FlywheelRenderer extends KineticTileEntityRenderer {
|
||||
|
||||
public FlywheelRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||
@ -74,6 +73,12 @@ public class FlywheelRenderer extends KineticTileEntityRenderer {
|
||||
wheel.renderInto(ms, vb);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
|
||||
return AllBlockPartials.SHAFT_HALF.renderOnDirectionalSouth(te.getBlockState(), te.getBlockState()
|
||||
.get(HORIZONTAL_FACING)
|
||||
.getOpposite());
|
||||
}
|
||||
|
||||
protected SuperByteBuffer transformConnector(SuperByteBuffer buffer, boolean upper, boolean rotating, float angle,
|
||||
boolean flip) {
|
||||
|
@ -1,10 +1,11 @@
|
||||
package com.simibubi.create.content.contraptions.components.millstone;
|
||||
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.CreateClient;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
||||
import com.simibubi.create.foundation.render.instancing.InstancedModel;
|
||||
import com.simibubi.create.foundation.render.instancing.RotatingData;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
|
||||
public class MillstoneRenderer extends KineticTileEntityRenderer {
|
||||
@ -13,5 +14,9 @@ public class MillstoneRenderer extends KineticTileEntityRenderer {
|
||||
super(dispatcher);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
|
||||
return CreateClient.bufferCache.renderPartial(AllBlockPartials.MILLSTONE_COG, te.getBlockState());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,10 +5,9 @@ import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.render.instancing.InstancedModel;
|
||||
import com.simibubi.create.foundation.render.instancing.RotatingData;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
@ -23,11 +22,6 @@ public class MechanicalMixerRenderer extends KineticTileEntityRenderer {
|
||||
super(dispatcher);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGlobalRenderer(KineticTileEntity te) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
||||
int light, int overlay) {
|
||||
@ -37,6 +31,9 @@ public class MechanicalMixerRenderer extends KineticTileEntityRenderer {
|
||||
|
||||
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
|
||||
|
||||
SuperByteBuffer superBuffer = AllBlockPartials.SHAFTLESS_COGWHEEL.renderOn(blockState);
|
||||
standardKineticRotationTransform(superBuffer, te, light).renderInto(ms, vb);
|
||||
|
||||
int packedLightmapCoords = WorldRenderer.getLightmapCoordinates(te.getWorld(), blockState, pos);
|
||||
float renderedHeadOffset = mixer.getRenderedHeadOffset(partialTicks);
|
||||
float speed = mixer.getRenderedHeadRotationSpeed(partialTicks);
|
||||
@ -54,4 +51,5 @@ public class MechanicalMixerRenderer extends KineticTileEntityRenderer {
|
||||
.light(packedLightmapCoords)
|
||||
.renderInto(ms, vb);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,8 +3,8 @@ package com.simibubi.create.content.contraptions.components.motor;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
||||
import com.simibubi.create.foundation.render.instancing.InstancedModel;
|
||||
import com.simibubi.create.foundation.render.instancing.RotatingData;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
|
||||
public class CreativeMotorRenderer extends KineticTileEntityRenderer {
|
||||
@ -13,5 +13,9 @@ public class CreativeMotorRenderer extends KineticTileEntityRenderer {
|
||||
super(dispatcher);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
|
||||
return AllBlockPartials.SHAFT_HALF.renderOnDirectionalSouth(te.getBlockState());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,11 +19,6 @@ public class MechanicalPressRenderer extends KineticTileEntityRenderer {
|
||||
super(dispatcher);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGlobalRenderer(KineticTileEntity tile) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
||||
int light, int overlay) {
|
||||
|
@ -1,18 +1,20 @@
|
||||
package com.simibubi.create.content.contraptions.components.saw;
|
||||
|
||||
import static net.minecraft.state.properties.BlockStateProperties.FACING;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.CreateClient;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.render.instancing.InstancedModel;
|
||||
import com.simibubi.create.foundation.render.instancing.RotatingData;
|
||||
import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringRenderer;
|
||||
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
import com.simibubi.create.foundation.utility.MatrixStacker;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.utility.VecHelper;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
@ -28,8 +30,6 @@ import net.minecraft.util.Rotation;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
import static net.minecraft.state.properties.BlockStateProperties.FACING;
|
||||
|
||||
public class SawRenderer extends SafeTileEntityRenderer<SawTileEntity> {
|
||||
|
||||
public SawRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||
@ -42,7 +42,7 @@ public class SawRenderer extends SafeTileEntityRenderer<SawTileEntity> {
|
||||
renderBlade(te, ms, buffer, light);
|
||||
renderItems(te, partialTicks, ms, buffer, light, overlay);
|
||||
FilteringRenderer.renderOnTileEntity(te, partialTicks, ms, buffer, light, overlay);
|
||||
|
||||
renderShaft(te, ms, buffer, light, overlay);
|
||||
}
|
||||
|
||||
protected void renderBlade(SawTileEntity te, MatrixStack ms, IRenderTypeBuffer buffer, int light){
|
||||
@ -79,8 +79,9 @@ public class SawRenderer extends SafeTileEntityRenderer<SawTileEntity> {
|
||||
ms.pop();
|
||||
}
|
||||
|
||||
protected void renderShaft(SawTileEntity te, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) {
|
||||
//KineticTileEntityRenderer.renderRotatingBuffer(te, getRotatedModel(te));
|
||||
protected void renderShaft(SawTileEntity te, MatrixStack ms, IRenderTypeBuffer buffer, int light,
|
||||
int overlay) {
|
||||
KineticTileEntityRenderer.renderRotatingBuffer(te, getRotatedModel(te), ms, buffer.getBuffer(RenderType.getSolid()), light);
|
||||
}
|
||||
|
||||
protected void renderItems(SawTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light,
|
||||
@ -124,6 +125,14 @@ public class SawRenderer extends SafeTileEntityRenderer<SawTileEntity> {
|
||||
}
|
||||
}
|
||||
|
||||
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
|
||||
BlockState state = te.getBlockState();
|
||||
if (state.get(FACING).getAxis().isHorizontal())
|
||||
return AllBlockPartials.SHAFT_HALF.renderOnDirectionalSouth(state.rotate(Rotation.CLOCKWISE_180));
|
||||
return CreateClient.bufferCache.renderBlockIn(KineticTileEntityRenderer.KINETIC_TILE,
|
||||
getRenderedBlockState(te));
|
||||
}
|
||||
|
||||
protected BlockState getRenderedBlockState(KineticTileEntity te) {
|
||||
return KineticTileEntityRenderer.shaft(KineticTileEntityRenderer.getRotationAxisOf(te));
|
||||
}
|
||||
|
@ -4,11 +4,9 @@ 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.KineticTileEntityRenderer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.render.instancing.InstancedModel;
|
||||
import com.simibubi.create.foundation.render.instancing.RotatingData;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
import net.minecraft.block.BlockState;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
@ -44,4 +42,11 @@ public class BearingRenderer extends KineticTileEntityRenderer {
|
||||
superBuffer.renderInto(ms, buffer.getBuffer(RenderType.getSolid()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
|
||||
return AllBlockPartials.SHAFT_HALF.renderOnDirectionalSouth(te.getBlockState(), te.getBlockState()
|
||||
.get(BearingBlock.FACING)
|
||||
.getOpposite());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,11 +4,10 @@ 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.KineticTileEntityRenderer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.render.instancing.InstancedModel;
|
||||
import com.simibubi.create.foundation.render.instancing.RotatingData;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
import com.simibubi.create.foundation.utility.MatrixStacker;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
@ -51,4 +50,9 @@ public class PumpRenderer extends KineticTileEntityRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
|
||||
return AllBlockPartials.MECHANICAL_PUMP_COG.renderOnDirectionalSouth(te.getBlockState());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,23 +1,29 @@
|
||||
package com.simibubi.create.content.contraptions.relays.belt;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.AllSpriteShifts;
|
||||
import com.simibubi.create.CreateClient;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
||||
import com.simibubi.create.content.contraptions.relays.belt.transport.TransportedItemStack;
|
||||
import com.simibubi.create.foundation.block.render.SpriteShiftEntry;
|
||||
import com.simibubi.create.foundation.render.ShadowRenderHelper;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.render.instancing.BeltData;
|
||||
import com.simibubi.create.foundation.render.instancing.InstancedModel;
|
||||
import com.simibubi.create.foundation.render.instancing.RotatingData;
|
||||
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
import com.simibubi.create.foundation.utility.Iterate;
|
||||
import com.simibubi.create.foundation.utility.MatrixStacker;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.ItemRenderer;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.Vector3f;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
@ -39,6 +45,11 @@ public class BeltRenderer extends SafeTileEntityRenderer<BeltTileEntity> {
|
||||
super(dispatcher);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGlobalRenderer(BeltTileEntity te) {
|
||||
return BeltBlock.canTransportObjects(te.getBlockState());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderSafe(BeltTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
||||
int light, int overlay) {
|
||||
@ -47,13 +58,95 @@ public class BeltRenderer extends SafeTileEntityRenderer<BeltTileEntity> {
|
||||
if (!AllBlocks.BELT.has(blockState))
|
||||
return;
|
||||
|
||||
// addInstanceData(new InstanceContext.World<>(te));
|
||||
renderItems(te, partialTicks, ms, buffer, light, overlay);
|
||||
BeltSlope beltSlope = blockState.get(BeltBlock.SLOPE);
|
||||
BeltPart part = blockState.get(BeltBlock.PART);
|
||||
Direction facing = blockState.get(BeltBlock.HORIZONTAL_FACING);
|
||||
AxisDirection axisDirection = facing.getAxisDirection();
|
||||
|
||||
boolean downward = beltSlope == BeltSlope.DOWNWARD;
|
||||
boolean upward = beltSlope == BeltSlope.UPWARD;
|
||||
boolean diagonal = downward || upward;
|
||||
boolean start = part == BeltPart.START;
|
||||
boolean end = part == BeltPart.END;
|
||||
boolean sideways = beltSlope == BeltSlope.SIDEWAYS;
|
||||
boolean alongX = facing.getAxis() == Axis.X;
|
||||
|
||||
MatrixStacker msr = MatrixStacker.of(ms);
|
||||
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
|
||||
float renderTick = AnimationTickHolder.getRenderTick();
|
||||
|
||||
ms.push();
|
||||
msr.centre();
|
||||
msr.rotateY(AngleHelper.horizontalAngle(facing) + (upward ? 180 : 0) + (sideways ? 270 : 0));
|
||||
msr.rotateZ(sideways ? 90 : 0);
|
||||
msr.rotateX(!diagonal && beltSlope != BeltSlope.HORIZONTAL ? 90 : 0);
|
||||
msr.unCentre();
|
||||
|
||||
if (downward || beltSlope == BeltSlope.VERTICAL && axisDirection == AxisDirection.POSITIVE) {
|
||||
boolean b = start;
|
||||
start = end;
|
||||
end = b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGlobalRenderer(BeltTileEntity te) {
|
||||
return te.isController();
|
||||
for (boolean bottom : Iterate.trueAndFalse) {
|
||||
|
||||
AllBlockPartials beltPartial = getBeltPartial(diagonal, start, end, bottom);
|
||||
|
||||
SuperByteBuffer beltBuffer = beltPartial.renderOn(blockState)
|
||||
.light(light);
|
||||
|
||||
SpriteShiftEntry spriteShift = getSpriteShiftEntry(diagonal, bottom);
|
||||
|
||||
// UV shift
|
||||
float speed = te.getSpeed();
|
||||
if (speed != 0) {
|
||||
float time = renderTick * axisDirection.getOffset();
|
||||
if (diagonal && (downward ^ alongX) || !sideways && !diagonal && alongX
|
||||
|| sideways && axisDirection == AxisDirection.NEGATIVE)
|
||||
speed = -speed;
|
||||
|
||||
float scrollMult = diagonal ? 3f / 8f : 0.5f;
|
||||
|
||||
float spriteSize = spriteShift.getTarget().getMaxV() - spriteShift.getTarget().getMinV();
|
||||
|
||||
double scroll = speed * time / (36 * 16);
|
||||
scroll = scroll - Math.floor(scroll);
|
||||
scroll = scroll * spriteSize * scrollMult;
|
||||
|
||||
beltBuffer.shiftUVScrolling(spriteShift, (float) scroll);
|
||||
}
|
||||
|
||||
beltBuffer.renderInto(ms, vb);
|
||||
|
||||
// Diagonal belt do not have a separate bottom model
|
||||
if (diagonal)
|
||||
break;
|
||||
}
|
||||
ms.pop();
|
||||
|
||||
if (te.hasPulley()) {
|
||||
// TODO 1.15 find a way to cache this model matrix computation
|
||||
MatrixStack modelTransform = new MatrixStack();
|
||||
Direction dir = blockState.get(BeltBlock.HORIZONTAL_FACING)
|
||||
.rotateY();
|
||||
if (sideways)
|
||||
dir = Direction.UP;
|
||||
msr = MatrixStacker.of(modelTransform);
|
||||
msr.centre();
|
||||
if (dir.getAxis() == Axis.X)
|
||||
msr.rotateY(90);
|
||||
if (dir.getAxis() == Axis.Y)
|
||||
msr.rotateX(90);
|
||||
msr.rotateX(90);
|
||||
msr.unCentre();
|
||||
|
||||
SuperByteBuffer superBuffer = CreateClient.bufferCache
|
||||
.renderDirectionalPartial(AllBlockPartials.BELT_PULLEY, blockState, dir, modelTransform);
|
||||
KineticTileEntityRenderer.standardKineticRotationTransform(superBuffer, te, light)
|
||||
.renderInto(ms, vb);
|
||||
}
|
||||
|
||||
renderItems(te, partialTicks, ms, buffer, light, overlay);
|
||||
}
|
||||
|
||||
public static SpriteShiftEntry getSpriteShiftEntry(boolean diagonal, boolean bottom) {
|
||||
|
@ -5,16 +5,17 @@ import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.IRotate;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
||||
import com.simibubi.create.foundation.render.instancing.InstancedModel;
|
||||
import com.simibubi.create.foundation.render.instancing.RotatingData;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
import com.simibubi.create.foundation.utility.Iterate;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Direction.Axis;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.LightType;
|
||||
|
||||
public class SplitShaftRenderer extends KineticTileEntityRenderer {
|
||||
|
||||
@ -25,7 +26,32 @@ public class SplitShaftRenderer extends KineticTileEntityRenderer {
|
||||
@Override
|
||||
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
||||
int light, int overlay) {
|
||||
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
|
||||
Block block = te.getBlockState().getBlock();
|
||||
final Axis boxAxis = ((IRotate) block).getRotationAxis(te.getBlockState());
|
||||
final BlockPos pos = te.getPos();
|
||||
float time = AnimationTickHolder.getRenderTick();
|
||||
|
||||
for (Direction direction : Iterate.directions) {
|
||||
Axis axis = direction.getAxis();
|
||||
if (boxAxis != axis)
|
||||
continue;
|
||||
|
||||
float offset = getRotationOffsetForPosition(te, pos, axis);
|
||||
float angle = (time * te.getSpeed() * 3f / 10) % 360;
|
||||
float modifier = 1;
|
||||
|
||||
if (te instanceof SplitShaftTileEntity)
|
||||
modifier = ((SplitShaftTileEntity) te).getRotationSpeedModifier(direction);
|
||||
|
||||
angle *= modifier;
|
||||
angle += offset;
|
||||
angle = angle / 180f * (float) Math.PI;
|
||||
|
||||
SuperByteBuffer superByteBuffer =
|
||||
AllBlockPartials.SHAFT_HALF.renderOnDirectionalSouth(te.getBlockState(), direction);
|
||||
kineticRotationTransform(superByteBuffer, te, axis, angle, light);
|
||||
superByteBuffer.renderInto(ms, buffer.getBuffer(RenderType.getSolid()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,23 +1,20 @@
|
||||
package com.simibubi.create.content.contraptions.relays.gearbox;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
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.KineticTileEntityRenderer;
|
||||
import com.simibubi.create.foundation.render.instancing.InstancedModel;
|
||||
import com.simibubi.create.foundation.render.instancing.RotatingData;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
import com.simibubi.create.foundation.utility.Iterate;
|
||||
import com.simibubi.create.foundation.utility.Pair;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.state.properties.BlockStateProperties;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Direction.Axis;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.LightType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GearboxRenderer extends KineticTileEntityRenderer {
|
||||
|
||||
@ -28,7 +25,34 @@ public class GearboxRenderer extends KineticTileEntityRenderer {
|
||||
@Override
|
||||
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
||||
int light, int overlay) {
|
||||
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
|
||||
final Axis boxAxis = te.getBlockState().get(BlockStateProperties.AXIS);
|
||||
final BlockPos pos = te.getPos();
|
||||
float time = AnimationTickHolder.getRenderTick();
|
||||
|
||||
for (Direction direction : Iterate.directions) {
|
||||
final Axis axis = direction.getAxis();
|
||||
if (boxAxis == axis)
|
||||
continue;
|
||||
|
||||
SuperByteBuffer shaft = AllBlockPartials.SHAFT_HALF.renderOnDirectionalSouth(te.getBlockState(), direction);
|
||||
float offset = getRotationOffsetForPosition(te, pos, axis);
|
||||
float angle = (time * te.getSpeed() * 3f / 10) % 360;
|
||||
|
||||
if (te.getSpeed() != 0 && te.hasSource()) {
|
||||
BlockPos source = te.source.subtract(te.getPos());
|
||||
Direction sourceFacing = Direction.getFacingFromVector(source.getX(), source.getY(), source.getZ());
|
||||
if (sourceFacing.getAxis() == direction.getAxis())
|
||||
angle *= sourceFacing == direction ? 1 : -1;
|
||||
else if (sourceFacing.getAxisDirection() == direction.getAxisDirection())
|
||||
angle *= -1;
|
||||
}
|
||||
|
||||
angle += offset;
|
||||
angle = angle / 180f * (float) Math.PI;
|
||||
|
||||
kineticRotationTransform(shaft, te, axis, angle, light);
|
||||
shaft.renderInto(ms, buffer.getBuffer(RenderType.getSolid()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,13 +6,12 @@ import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
||||
import com.simibubi.create.content.logistics.block.mechanicalArm.ArmTileEntity.Phase;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.render.instancing.InstancedModel;
|
||||
import com.simibubi.create.foundation.render.instancing.RotatingData;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
import com.simibubi.create.foundation.utility.ColorHelper;
|
||||
import com.simibubi.create.foundation.utility.Iterate;
|
||||
import com.simibubi.create.foundation.utility.MatrixStacker;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
@ -30,11 +29,6 @@ public class ArmRenderer extends KineticTileEntityRenderer {
|
||||
super(dispatcher);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGlobalRenderer(KineticTileEntity te) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderSafe(KineticTileEntity te, float pt, MatrixStack ms, IRenderTypeBuffer buffer, int light,
|
||||
int overlay) {
|
||||
@ -123,4 +117,9 @@ public class ArmRenderer extends KineticTileEntityRenderer {
|
||||
ms.pop();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
|
||||
return AllBlockPartials.ARM_COG.renderOn(te.getBlockState());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -25,8 +25,8 @@ public class CancelTileEntityRenderMixin {
|
||||
*/
|
||||
@Inject(at = @At("RETURN"), method = "getTileEntities", cancellable = true)
|
||||
private void noRenderInstancedTiles(CallbackInfoReturnable<List<TileEntity>> cir) {
|
||||
List<TileEntity> tiles = cir.getReturnValue();
|
||||
|
||||
tiles.removeIf(tile -> tile instanceof IInstanceRendered && !((IInstanceRendered) tile).shouldRenderAsTE());
|
||||
// List<TileEntity> tiles = cir.getReturnValue();
|
||||
//
|
||||
// tiles.removeIf(tile -> tile instanceof IInstanceRendered && !((IInstanceRendered) tile).shouldRenderAsTE());
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package com.simibubi.create.foundation.render;
|
||||
|
||||
import java.nio.Buffer;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
@ -29,9 +30,7 @@ public class SuperByteBuffer extends TemplateBuffer {
|
||||
private MatrixStack transforms;
|
||||
|
||||
// Vertex Texture Coords
|
||||
private boolean shouldShiftUV;
|
||||
private SpriteShiftEntry spriteShift;
|
||||
private float uTarget, vTarget;
|
||||
private SpriteShiftFunc spriteShiftFunc;
|
||||
|
||||
// Vertex Lighting
|
||||
private boolean shouldLight;
|
||||
@ -105,12 +104,8 @@ public class SuperByteBuffer extends TemplateBuffer {
|
||||
float u = getU(buffer, i);
|
||||
float v = getV(buffer, i);
|
||||
|
||||
if (shouldShiftUV) {
|
||||
float targetU = spriteShift.getTarget()
|
||||
.getInterpolatedU((getUnInterpolatedU(spriteShift.getOriginal(), u) / sheetSize) + uTarget * 16);
|
||||
float targetV = spriteShift.getTarget()
|
||||
.getInterpolatedV((getUnInterpolatedV(spriteShift.getOriginal(), v) / sheetSize) + vTarget * 16);
|
||||
builder.texture(targetU, targetV);
|
||||
if (spriteShiftFunc != null) {
|
||||
spriteShiftFunc.shift(builder, u, v);
|
||||
} else
|
||||
builder.texture(u, v);
|
||||
|
||||
@ -131,7 +126,7 @@ public class SuperByteBuffer extends TemplateBuffer {
|
||||
}
|
||||
|
||||
transforms = new MatrixStack();
|
||||
shouldShiftUV = false;
|
||||
spriteShiftFunc = null;
|
||||
shouldColor = false;
|
||||
shouldLight = false;
|
||||
}
|
||||
@ -159,20 +154,29 @@ public class SuperByteBuffer extends TemplateBuffer {
|
||||
}
|
||||
|
||||
public SuperByteBuffer shiftUV(SpriteShiftEntry entry) {
|
||||
shouldShiftUV = true;
|
||||
spriteShift = entry;
|
||||
uTarget = 0;
|
||||
vTarget = 0;
|
||||
sheetSize = 1;
|
||||
this.spriteShiftFunc = (builder, u, v) -> {
|
||||
float targetU = entry.getTarget().getInterpolatedU((getUnInterpolatedU(entry.getOriginal(), u)));
|
||||
float targetV = entry.getTarget().getInterpolatedV((getUnInterpolatedV(entry.getOriginal(), v)));
|
||||
builder.texture(targetU, targetV);
|
||||
};
|
||||
return this;
|
||||
}
|
||||
|
||||
public SuperByteBuffer shiftUVScrolling(SpriteShiftEntry entry, float scrollV) {
|
||||
this.spriteShiftFunc = (builder, u, v) -> {
|
||||
float targetU = u - entry.getOriginal().getMinU() + entry.getTarget().getMinU();
|
||||
float targetV = v - entry.getOriginal().getMinV() + entry.getTarget().getMinV() + scrollV;
|
||||
builder.texture(targetU, targetV);
|
||||
};
|
||||
return this;
|
||||
}
|
||||
|
||||
public SuperByteBuffer shiftUVtoSheet(SpriteShiftEntry entry, float uTarget, float vTarget, int sheetSize) {
|
||||
shouldShiftUV = true;
|
||||
spriteShift = entry;
|
||||
this.uTarget = uTarget;
|
||||
this.vTarget = vTarget;
|
||||
this.sheetSize = sheetSize;
|
||||
this.spriteShiftFunc = (builder, u, v) -> {
|
||||
float targetU = entry.getTarget().getInterpolatedU((getUnInterpolatedU(entry.getOriginal(), u) / sheetSize) + uTarget * 16);
|
||||
float targetV = entry.getTarget().getInterpolatedV((getUnInterpolatedV(entry.getOriginal(), v) / sheetSize) + vTarget * 16);
|
||||
builder.texture(targetU, targetV);
|
||||
};
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -220,4 +224,9 @@ public class SuperByteBuffer extends TemplateBuffer {
|
||||
return ((Buffer) template).limit() == 0;
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface SpriteShiftFunc {
|
||||
void shift(IVertexBuilder builder, float u, float v);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -42,14 +42,15 @@ public abstract class InstancedTileRenderer<P extends BasicProgram> {
|
||||
if (instance != null) {
|
||||
return (TileEntityInstance<? super T>) instance;
|
||||
} else if (create) {
|
||||
TileEntityInstance<? super T> renderer = InstancedTileRenderRegistry.instance.create(this, tile);
|
||||
|
||||
if (renderer != null) {
|
||||
FastRenderDispatcher.addedLastTick.get(tile.getWorld()).add(tile);
|
||||
instances.put(tile, renderer);
|
||||
}
|
||||
|
||||
return renderer;
|
||||
return null;
|
||||
// TileEntityInstance<? super T> renderer = InstancedTileRenderRegistry.instance.create(this, tile);
|
||||
//
|
||||
// if (renderer != null) {
|
||||
// FastRenderDispatcher.addedLastTick.get(tile.getWorld()).add(tile);
|
||||
// instances.put(tile, renderer);
|
||||
// }
|
||||
//
|
||||
// return renderer;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ layout (location = 5) in vec3 networkTint;
|
||||
layout (location = 6) in float speed;
|
||||
layout (location = 7) in float offset;
|
||||
layout (location = 8) in vec3 eulerAngles;
|
||||
layout (location = 9) in vec2 uv;
|
||||
layout (location = 9) in vec2 sourceTexture;
|
||||
layout (location = 10) in vec4 scrollTexture;
|
||||
layout (location = 11) in float scrollMult;
|
||||
|
||||
@ -81,7 +81,7 @@ void main() {
|
||||
float scroll = fract(speed * uTime / (36 * 16) + offset) * scrollSize * scrollMult;
|
||||
|
||||
Diffuse = diffuse(norm);
|
||||
TexCoords = aTexCoords - uv + scrollTexture.xy + vec2(0, scroll);
|
||||
TexCoords = aTexCoords - sourceTexture + scrollTexture.xy + vec2(0, scroll);
|
||||
Light = light;
|
||||
gl_Position = uViewProjection * worldPos;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user