Finish porting most TERs

This commit is contained in:
tterrag 2020-03-29 12:20:33 -04:00
parent 11ae3bc820
commit 3c07aa51de
12 changed files with 101 additions and 92 deletions

View file

@ -39,7 +39,7 @@ public class KineticTileEntityRenderer extends SafeTileEntityRenderer<KineticTil
renderRotatingBuffer(te, getRotatedModel(te), ms, buffer.getBuffer(RenderType.getSolid())); renderRotatingBuffer(te, getRotatedModel(te), ms, buffer.getBuffer(RenderType.getSolid()));
} }
public static void renderRotatingKineticBlock(KineticTileEntity te, BlockState renderedState, MatrixStack ms, BufferBuilder buffer) { public static void renderRotatingKineticBlock(KineticTileEntity te, BlockState renderedState, MatrixStack ms, IVertexBuilder buffer) {
SuperByteBuffer superByteBuffer = CreateClient.bufferCache.renderBlockIn(KINETIC_TILE, renderedState); SuperByteBuffer superByteBuffer = CreateClient.bufferCache.renderBlockIn(KINETIC_TILE, renderedState);
renderRotatingBuffer(te, superByteBuffer, ms, buffer); renderRotatingBuffer(te, superByteBuffer, ms, buffer);
} }

View file

@ -10,9 +10,9 @@ import com.simibubi.create.modules.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.modules.contraptions.components.clock.CuckooClockTileEntity.Animation; import com.simibubi.create.modules.contraptions.components.clock.CuckooClockTileEntity.Animation;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.Direction.Axis; import net.minecraft.util.Direction.Axis;
@ -33,7 +33,7 @@ public class CuckooClockRenderer extends KineticTileEntityRenderer {
CuckooClockTileEntity clock = (CuckooClockTileEntity) te; CuckooClockTileEntity clock = (CuckooClockTileEntity) te;
BlockState blockState = te.getBlockState(); BlockState blockState = te.getBlockState();
int packedLightmapCoords =WorldRenderer.getLightmapCoordinates(te.getWorld(), blockState, te.getPos()); int packedLightmapCoords = WorldRenderer.getLightmapCoordinates(te.getWorld(), blockState, te.getPos());
Direction direction = blockState.get(CuckooClockBlock.HORIZONTAL_FACING); Direction direction = blockState.get(CuckooClockBlock.HORIZONTAL_FACING);
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid()); IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());

View file

@ -38,6 +38,7 @@ public class ContraptionEntityRenderer extends EntityRenderer<ContraptionEntity>
if (entity.getContraption() == null) if (entity.getContraption() == null)
return; return;
// TODO 1.15 buffered render
RenderSystem.pushMatrix(); RenderSystem.pushMatrix();
long randomBits = (long) entity.getEntityId() * 493286711L; long randomBits = (long) entity.getEntityId() * 493286711L;
randomBits = randomBits * randomBits * 4392167121L + randomBits * 98761L; randomBits = randomBits * randomBits * 4392167121L + randomBits * 98761L;

View file

@ -7,7 +7,8 @@ import static net.minecraft.state.properties.BlockStateProperties.AXIS;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.foundation.behaviour.filtering.FilteringRenderer; import com.simibubi.create.foundation.behaviour.filtering.FilteringRenderer;
@ -16,7 +17,6 @@ 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.NBTHelper; import com.simibubi.create.foundation.utility.NBTHelper;
import com.simibubi.create.foundation.utility.SuperByteBuffer; import com.simibubi.create.foundation.utility.SuperByteBuffer;
import com.simibubi.create.foundation.utility.TessellatorHelper;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
import com.simibubi.create.modules.contraptions.base.IRotate; import com.simibubi.create.modules.contraptions.base.IRotate;
import com.simibubi.create.modules.contraptions.base.KineticTileEntity; import com.simibubi.create.modules.contraptions.base.KineticTileEntity;
@ -28,13 +28,13 @@ import com.simibubi.create.modules.contraptions.components.deployer.DeployerTile
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.Vector3f;
import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType; import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.item.BlockItem; import net.minecraft.item.BlockItem;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.Direction.Axis; import net.minecraft.util.Direction.Axis;
@ -49,20 +49,21 @@ public class DeployerTileEntityRenderer extends SafeTileEntityRenderer<DeployerT
public DeployerTileEntityRenderer(TileEntityRendererDispatcher dispatcher) { public DeployerTileEntityRenderer(TileEntityRendererDispatcher dispatcher) {
super(dispatcher); super(dispatcher);
} }
@Override @Override
public void renderWithGL(DeployerTileEntity te, double x, double y, double z, float partialTicks, protected void renderSafe(DeployerTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
int destroyStage) { int light, int overlay) {
renderItem(te, x, y, z, partialTicks); renderItem(te, partialTicks, ms, buffer, light, overlay);
FilteringRenderer.renderOnTileEntity(te, x, y, z, partialTicks, destroyStage); FilteringRenderer.renderOnTileEntity(te, partialTicks, ms, buffer, light, overlay);
renderComponents(te, x, y, z, partialTicks); renderComponents(te, partialTicks, ms, buffer, light, overlay);
} }
protected void renderItem(DeployerTileEntity te, double x, double y, double z, float partialTicks) { protected void renderItem(DeployerTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
int light, int overlay) {
BlockState deployerState = te.getBlockState(); BlockState deployerState = te.getBlockState();
Vec3d offset = getHandOffset(te, partialTicks, deployerState).add(VecHelper.getCenterOf(BlockPos.ZERO)); Vec3d offset = getHandOffset(te, partialTicks, deployerState).add(VecHelper.getCenterOf(BlockPos.ZERO));
RenderSystem.pushMatrix(); ms.push();
RenderSystem.translated(offset.x + x, offset.y + y, offset.z + z); ms.translate(offset.x, offset.y, offset.z);
Direction facing = deployerState.get(FACING); Direction facing = deployerState.get(FACING);
boolean punching = te.mode == Mode.PUNCH; boolean punching = te.mode == Mode.PUNCH;
@ -71,56 +72,52 @@ public class DeployerTileEntityRenderer extends SafeTileEntityRenderer<DeployerT
float zRot = facing == Direction.UP ? 90 : facing == Direction.DOWN ? 270 : 0; float zRot = facing == Direction.UP ? 90 : facing == Direction.DOWN ? 270 : 0;
boolean displayMode = facing == Direction.UP && te.getSpeed() == 0 && !punching; boolean displayMode = facing == Direction.UP && te.getSpeed() == 0 && !punching;
RenderSystem.rotatef(yRot, 0, 1, 0); ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(yRot));
if (!displayMode) { if (!displayMode) {
RenderSystem.rotatef(zRot, 1, 0, 0); ms.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(zRot));
RenderSystem.translated(0, 0, -11 / 16f); ms.translate(0, 0, -11 / 16f);
} }
if (punching) if (punching)
RenderSystem.translatef(0, 1 / 8f, -1 / 16f); ms.translate(0, 1 / 8f, -1 / 16f);
ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer(); ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer();
TransformType transform = TransformType.NONE; TransformType transform = TransformType.NONE;
boolean isBlockItem = boolean isBlockItem =
(te.heldItem.getItem() instanceof BlockItem) && itemRenderer.getModelWithOverrides(te.heldItem).isGui3d(); (te.heldItem.getItem() instanceof BlockItem) && itemRenderer.getItemModelWithOverrides(te.heldItem, Minecraft.getInstance().world, null).isGui3d();
if (displayMode) { if (displayMode) {
float scale = isBlockItem ? 1.25f : 1; float scale = isBlockItem ? 1.25f : 1;
RenderSystem.translated(0, isBlockItem ? 9 / 16f : 11 / 16f, 0); ms.translate(0, isBlockItem ? 9 / 16f : 11 / 16f, 0);
RenderSystem.scaled(scale, scale, scale); ms.scale(scale, scale, scale);
transform = TransformType.GROUND; transform = TransformType.GROUND;
RenderSystem.rotatef(AnimationTickHolder.getRenderTick(), 0, 1, 0); ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(AnimationTickHolder.getRenderTick()));
} else { } else {
float scale = punching ? .75f : isBlockItem ? .75f - 1 / 64f : .5f; float scale = punching ? .75f : isBlockItem ? .75f - 1 / 64f : .5f;
RenderSystem.scaled(scale, scale, scale); ms.scale(scale, scale, scale);
transform = punching ? TransformType.THIRD_PERSON_RIGHT_HAND : TransformType.FIXED; transform = punching ? TransformType.THIRD_PERSON_RIGHT_HAND : TransformType.FIXED;
} }
itemRenderer.renderItem(te.heldItem, transform); itemRenderer.renderItem(te.heldItem, transform, light, overlay, ms, buffer);
RenderSystem.popMatrix(); ms.pop();
} }
protected void renderComponents(DeployerTileEntity te, double x, double y, double z, float partialTicks) { protected void renderComponents(DeployerTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
TessellatorHelper.prepareFastRender(); int light, int overlay) {
TessellatorHelper.begin(DefaultVertexFormats.BLOCK); IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
BufferBuilder buffer = Tessellator.getInstance().getBuffer(); KineticTileEntityRenderer.renderRotatingKineticBlock(te, getRenderedBlockState(te), ms, vb);
KineticTileEntityRenderer.renderRotatingKineticBlock(te, getWorld(), getRenderedBlockState(te), x, y, z,
buffer);
BlockState blockState = te.getBlockState(); BlockState blockState = te.getBlockState();
BlockPos pos = te.getPos(); BlockPos pos = te.getPos();
SuperByteBuffer pole = renderAndTransform(getWorld(), AllBlockPartials.DEPLOYER_POLE, blockState, pos, true); SuperByteBuffer pole = renderAndTransform(te.getWorld(), AllBlockPartials.DEPLOYER_POLE, blockState, pos, true);
SuperByteBuffer hand = renderAndTransform(getWorld(), te.getHandPose(), blockState, pos, false); SuperByteBuffer hand = renderAndTransform(te.getWorld(), te.getHandPose(), blockState, pos, false);
Vec3d offset = getHandOffset(te, partialTicks, blockState); Vec3d offset = getHandOffset(te, partialTicks, blockState);
pole.translate(x + offset.x, y + offset.y, z + offset.z).renderInto(buffer); pole.translate(offset.x, offset.y, offset.z).renderInto(ms, vb);
hand.translate(x + offset.x, y + offset.y, z + offset.z).renderInto(buffer); hand.translate(offset.x, offset.y, offset.z).renderInto(ms, vb);
TessellatorHelper.draw();
} }
protected Vec3d getHandOffset(DeployerTileEntity te, float partialTicks, BlockState blockState) { protected Vec3d getHandOffset(DeployerTileEntity te, float partialTicks, BlockState blockState) {

View file

@ -3,14 +3,15 @@ package com.simibubi.create.modules.contraptions.components.fan;
import static net.minecraft.state.properties.BlockStateProperties.FACING; import static net.minecraft.state.properties.BlockStateProperties.FACING;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.SuperByteBuffer; import com.simibubi.create.foundation.utility.SuperByteBuffer;
import com.simibubi.create.modules.contraptions.base.KineticTileEntity; import com.simibubi.create.modules.contraptions.base.KineticTileEntity;
import com.simibubi.create.modules.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.modules.contraptions.base.KineticTileEntityRenderer;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
@ -27,7 +28,8 @@ public class EncasedFanTileEntityRenderer extends KineticTileEntityRenderer {
Direction direction = te.getBlockState().get(FACING); Direction direction = te.getBlockState().get(FACING);
SuperByteBuffer superBuffer = AllBlockPartials.SHAFT_HALF.renderOnDirectional(te.getBlockState(), SuperByteBuffer superBuffer = AllBlockPartials.SHAFT_HALF.renderOnDirectional(te.getBlockState(),
direction.getOpposite()); direction.getOpposite());
standardKineticRotationTransform(superBuffer, te, getWorld()).translate(x, y, z).renderInto(buffer); IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
standardKineticRotationTransform(superBuffer, te).renderInto(ms, vb);
float time = AnimationTickHolder.getRenderTick(); float time = AnimationTickHolder.getRenderTick();
float speed = te.getSpeed() * 5; float speed = te.getSpeed() * 5;
@ -40,8 +42,8 @@ public class EncasedFanTileEntityRenderer extends KineticTileEntityRenderer {
SuperByteBuffer superByteBuffer = AllBlockPartials.ENCASED_FAN_INNER.renderOnDirectional(te.getBlockState(), SuperByteBuffer superByteBuffer = AllBlockPartials.ENCASED_FAN_INNER.renderOnDirectional(te.getBlockState(),
direction.getOpposite()); direction.getOpposite());
kineticRotationTransform(superByteBuffer, te, direction.getAxis(), angle, getWorld()); kineticRotationTransform(superByteBuffer, te, direction.getAxis(), angle);
superByteBuffer.translate(x, y, z).renderInto(buffer); superByteBuffer.renderInto(ms, vb);
} }
} }

View file

@ -3,6 +3,7 @@ package com.simibubi.create.modules.contraptions.components.flywheel;
import static com.simibubi.create.modules.contraptions.base.HorizontalKineticBlock.HORIZONTAL_FACING; import static com.simibubi.create.modules.contraptions.base.HorizontalKineticBlock.HORIZONTAL_FACING;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.SuperByteBuffer; import com.simibubi.create.foundation.utility.SuperByteBuffer;
@ -38,6 +39,8 @@ public class FlywheelRenderer extends KineticTileEntityRenderer {
SuperByteBuffer wheel = AllBlockPartials.FLYWHEEL.renderOnHorizontal(blockState.rotate(Rotation.CLOCKWISE_90)); SuperByteBuffer wheel = AllBlockPartials.FLYWHEEL.renderOnHorizontal(blockState.rotate(Rotation.CLOCKWISE_90));
float speed = wte.visualSpeed.get(partialTicks) * 3 / 10f; float speed = wte.visualSpeed.get(partialTicks) * 3 / 10f;
float angle = wte.angle + speed * partialTicks; float angle = wte.angle + speed * partialTicks;
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
if (FlywheelBlock.isConnected(blockState)) { if (FlywheelBlock.isConnected(blockState)) {
Direction connection = FlywheelBlock.getConnection(blockState); Direction connection = FlywheelBlock.getConnection(blockState);
@ -48,17 +51,17 @@ public class FlywheelRenderer extends KineticTileEntityRenderer {
boolean flip = blockState.get(FlywheelBlock.CONNECTION) == ConnectionState.LEFT; boolean flip = blockState.get(FlywheelBlock.CONNECTION) == ConnectionState.LEFT;
rotateToFacing(transformConnector(AllBlockPartials.FLYWHEEL_UPPER_ROTATING.renderOn(blockState), true, true, rotateToFacing(transformConnector(AllBlockPartials.FLYWHEEL_UPPER_ROTATING.renderOn(blockState), true, true,
rotation, flip), connection).translate(x, y, z).light(light).renderInto(buffer); rotation, flip), connection).light(light).renderInto(ms, vb);
rotateToFacing(transformConnector(AllBlockPartials.FLYWHEEL_LOWER_ROTATING.renderOn(blockState), false, rotateToFacing(transformConnector(AllBlockPartials.FLYWHEEL_LOWER_ROTATING.renderOn(blockState), false,
true, rotation, flip), connection).translate(x, y, z).light(light).renderInto(buffer); true, rotation, flip), connection).light(light).renderInto(ms, vb);
rotateToFacing(transformConnector(AllBlockPartials.FLYWHEEL_UPPER_SLIDING.renderOn(blockState), true, false, rotateToFacing(transformConnector(AllBlockPartials.FLYWHEEL_UPPER_SLIDING.renderOn(blockState), true, false,
rotation, flip), connection).translate(x, y, z).light(light).renderInto(buffer); rotation, flip), connection).light(light).renderInto(ms, vb);
rotateToFacing(transformConnector(AllBlockPartials.FLYWHEEL_LOWER_SLIDING.renderOn(blockState), false, rotateToFacing(transformConnector(AllBlockPartials.FLYWHEEL_LOWER_SLIDING.renderOn(blockState), false,
false, rotation, flip), connection).translate(x, y, z).light(light).renderInto(buffer); false, rotation, flip), connection).light(light).renderInto(ms, vb);
} }
kineticRotationTransform(wheel, te, blockState.get(HORIZONTAL_FACING).getAxis(), AngleHelper.rad(angle)); kineticRotationTransform(wheel, te, blockState.get(HORIZONTAL_FACING).getAxis(), AngleHelper.rad(angle));
wheel.renderInto(ms, buffer.getBuffer(RenderType.getSolid())); wheel.renderInto(ms, vb);
} }
@Override @Override

View file

@ -1,15 +1,16 @@
package com.simibubi.create.modules.contraptions.components.flywheel.engine; package com.simibubi.create.modules.contraptions.components.flywheel.engine;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.foundation.block.SafeTileEntityRenderer; import com.simibubi.create.foundation.block.SafeTileEntityRenderer;
import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AngleHelper;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.Direction.Axis;
public class EngineRenderer<T extends EngineTileEntity> extends SafeTileEntityRenderer<T> { public class EngineRenderer<T extends EngineTileEntity> extends SafeTileEntityRenderer<T> {
@ -18,8 +19,8 @@ public class EngineRenderer<T extends EngineTileEntity> extends SafeTileEntityRe
} }
@Override @Override
protected void renderFast(T te, double x, double y, double z, float partialTicks, int destroyStage, protected void renderSafe(T te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light,
BufferBuilder buffer) { int overlay) {
Block block = te.getBlockState().getBlock(); Block block = te.getBlockState().getBlock();
if (block instanceof EngineBlock) { if (block instanceof EngineBlock) {
EngineBlock engineBlock = (EngineBlock) block; EngineBlock engineBlock = (EngineBlock) block;
@ -27,8 +28,9 @@ public class EngineRenderer<T extends EngineTileEntity> extends SafeTileEntityRe
if (frame != null) { if (frame != null) {
Direction facing = te.getBlockState().get(EngineBlock.HORIZONTAL_FACING); Direction facing = te.getBlockState().get(EngineBlock.HORIZONTAL_FACING);
float angle = AngleHelper.rad(AngleHelper.horizontalAngle(facing)); float angle = AngleHelper.rad(AngleHelper.horizontalAngle(facing));
frame.renderOn(te.getBlockState()).translate(0, 0, -1).rotateCentered(Axis.Y, angle).translate(x, y, z) frame.renderOn(te.getBlockState()).translate(0, 0, -1).rotateCentered(Direction.UP, angle)
.light(WorldRenderer.getLightmapCoordinates(te.getWorld(), te.getBlockState(), te.getPos())).renderInto(buffer); .light(WorldRenderer.getLightmapCoordinates(te.getWorld(), te.getBlockState(), te.getPos()))
.renderInto(ms, buffer.getBuffer(RenderType.getSolid()));
} }
} }
} }

View file

@ -9,9 +9,9 @@ import com.simibubi.create.modules.contraptions.base.KineticTileEntity;
import com.simibubi.create.modules.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.modules.contraptions.base.KineticTileEntityRenderer;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.util.Direction.Axis; import net.minecraft.util.Direction.Axis;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@ -34,7 +34,7 @@ public class MechanicalMixerTileEntityRenderer extends KineticTileEntityRenderer
SuperByteBuffer superBuffer = AllBlockPartials.SHAFTLESS_COGWHEEL.renderOn(blockState); SuperByteBuffer superBuffer = AllBlockPartials.SHAFTLESS_COGWHEEL.renderOn(blockState);
standardKineticRotationTransform(superBuffer, te).renderInto(ms, vb); standardKineticRotationTransform(superBuffer, te).renderInto(ms, vb);
int packedLightmapCoords =WorldRenderer.getLightmapCoordinates(te.getWorld(), blockState, pos); int packedLightmapCoords = WorldRenderer.getLightmapCoordinates(te.getWorld(), blockState, pos);
float renderedHeadOffset = mixer.getRenderedHeadOffset(partialTicks); float renderedHeadOffset = mixer.getRenderedHeadOffset(partialTicks);
float speed = mixer.getRenderedHeadRotationSpeed(partialTicks); float speed = mixer.getRenderedHeadRotationSpeed(partialTicks);
float time = AnimationTickHolder.getRenderTick(); float time = AnimationTickHolder.getRenderTick();

View file

@ -10,9 +10,9 @@ import com.simibubi.create.modules.contraptions.base.KineticTileEntity;
import com.simibubi.create.modules.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.modules.contraptions.base.KineticTileEntityRenderer;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@ -30,7 +30,7 @@ public class MechanicalPressTileEntityRenderer extends KineticTileEntityRenderer
BlockPos pos = te.getPos(); BlockPos pos = te.getPos();
BlockState blockState = te.getBlockState(); BlockState blockState = te.getBlockState();
int packedLightmapCoords =WorldRenderer.getLightmapCoordinates(te.getWorld(), blockState, pos); int packedLightmapCoords = WorldRenderer.getLightmapCoordinates(te.getWorld(), blockState, pos);
float renderedHeadOffset = ((MechanicalPressTileEntity) te).getRenderedHeadOffset(partialTicks); float renderedHeadOffset = ((MechanicalPressTileEntity) te).getRenderedHeadOffset(partialTicks);
SuperByteBuffer headRender = AllBlockPartials.MECHANICAL_PRESS_HEAD.renderOnHorizontal(blockState); SuperByteBuffer headRender = AllBlockPartials.MECHANICAL_PRESS_HEAD.renderOnHorizontal(blockState);

View file

@ -3,26 +3,26 @@ package com.simibubi.create.modules.contraptions.components.saw;
import static net.minecraft.state.properties.BlockStateProperties.AXIS; import static net.minecraft.state.properties.BlockStateProperties.AXIS;
import static net.minecraft.state.properties.BlockStateProperties.FACING; import static net.minecraft.state.properties.BlockStateProperties.FACING;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.CreateClient; import com.simibubi.create.CreateClient;
import com.simibubi.create.foundation.behaviour.filtering.FilteringRenderer; import com.simibubi.create.foundation.behaviour.filtering.FilteringRenderer;
import com.simibubi.create.foundation.block.SafeTileEntityRenderer; import com.simibubi.create.foundation.block.SafeTileEntityRenderer;
import com.simibubi.create.foundation.utility.SuperByteBuffer; import com.simibubi.create.foundation.utility.SuperByteBuffer;
import com.simibubi.create.foundation.utility.TessellatorHelper;
import com.simibubi.create.modules.contraptions.base.IRotate; import com.simibubi.create.modules.contraptions.base.IRotate;
import com.simibubi.create.modules.contraptions.base.KineticTileEntity; import com.simibubi.create.modules.contraptions.base.KineticTileEntity;
import com.simibubi.create.modules.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.modules.contraptions.base.KineticTileEntityRenderer;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.Vector3f;
import net.minecraft.client.renderer.model.IBakedModel; import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.client.renderer.model.ItemCameraTransforms; import net.minecraft.client.renderer.model.ItemCameraTransforms;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.Rotation; import net.minecraft.util.Rotation;
@ -34,27 +34,26 @@ public class SawTileEntityRenderer extends SafeTileEntityRenderer<SawTileEntity>
public SawTileEntityRenderer(TileEntityRendererDispatcher dispatcher) { public SawTileEntityRenderer(TileEntityRendererDispatcher dispatcher) {
super(dispatcher); super(dispatcher);
} }
@Override @Override
public void renderWithGL(SawTileEntity te, double x, double y, double z, float partialTicks, int destroyStage) { protected void renderSafe(SawTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light,
renderItems(te, x, y, z, partialTicks); int overlay) {
FilteringRenderer.renderOnTileEntity(te, x, y, z, partialTicks, destroyStage); renderItems(te, partialTicks, ms, buffer, light, overlay);
renderShaft(te, x, y, z); FilteringRenderer.renderOnTileEntity(te, partialTicks, ms, buffer, light, overlay);
renderShaft(te, ms, buffer, light, overlay);
} }
protected void renderShaft(SawTileEntity te, double x, double y, double z) { protected void renderShaft(SawTileEntity te, MatrixStack ms, IRenderTypeBuffer buffer, int light,
TessellatorHelper.prepareFastRender(); int overlay) {
TessellatorHelper.begin(DefaultVertexFormats.BLOCK); KineticTileEntityRenderer.renderRotatingBuffer(te, getRotatedModel(te), ms, buffer.getBuffer(RenderType.getSolid()));
KineticTileEntityRenderer.renderRotatingBuffer(te, getWorld(), getRotatedModel(te), x, y, z,
Tessellator.getInstance().getBuffer());
TessellatorHelper.draw();
} }
protected void renderItems(SawTileEntity te, double x, double y, double z, float partialTicks) { protected void renderItems(SawTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light,
int overlay) {
boolean processingMode = te.getBlockState().get(SawBlock.FACING) == Direction.UP; boolean processingMode = te.getBlockState().get(SawBlock.FACING) == Direction.UP;
if (processingMode && !te.inventory.isEmpty()) { if (processingMode && !te.inventory.isEmpty()) {
boolean alongZ = !te.getBlockState().get(SawBlock.AXIS_ALONG_FIRST_COORDINATE); boolean alongZ = !te.getBlockState().get(SawBlock.AXIS_ALONG_FIRST_COORDINATE);
RenderSystem.pushMatrix(); ms.push();
boolean moving = te.inventory.recipeDuration != 0; boolean moving = te.inventory.recipeDuration != 0;
float offset = moving ? (float) (te.inventory.remainingTime) / te.inventory.recipeDuration : 0; float offset = moving ? (float) (te.inventory.remainingTime) / te.inventory.recipeDuration : 0;
@ -68,18 +67,17 @@ public class SawTileEntityRenderer extends SafeTileEntityRenderer<SawTileEntity>
ItemStack stack = te.inventory.getStackInSlot(0); ItemStack stack = te.inventory.getStackInSlot(0);
ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer(); ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer();
IBakedModel modelWithOverrides = itemRenderer.getModelWithOverrides(stack); IBakedModel modelWithOverrides = itemRenderer.getItemModelWithOverrides(stack, te.getWorld(), null);
boolean blockItem = modelWithOverrides.isGui3d(); boolean blockItem = modelWithOverrides.isGui3d();
RenderSystem.translated(x + (alongZ ? offset : .5), y + (blockItem ? .925f : 13f / 16f), ms.translate(alongZ ? offset : .5, blockItem ? .925f : 13f / 16f, alongZ ? .5 : offset);
z + (alongZ ? .5 : offset));
RenderSystem.scaled(.5, .5, .5); ms.scale(.5f, .5f, .5f);
if (alongZ) if (alongZ)
RenderSystem.rotatef(90, 0, 1, 0); ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(90));
RenderSystem.rotatef(90, 1, 0, 0); ms.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(90));
itemRenderer.renderItem(stack, ItemCameraTransforms.TransformType.FIXED); itemRenderer.renderItem(stack, ItemCameraTransforms.TransformType.FIXED, light, overlay, ms, buffer);
RenderSystem.popMatrix(); ms.pop();
} }
} }

View file

@ -1,5 +1,6 @@
package com.simibubi.create.modules.contraptions.redstone; package com.simibubi.create.modules.contraptions.redstone;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.foundation.block.SafeTileEntityRenderer; import com.simibubi.create.foundation.block.SafeTileEntityRenderer;
import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AngleHelper;
@ -7,10 +8,12 @@ import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.SuperByteBuffer; import com.simibubi.create.foundation.utility.SuperByteBuffer;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.state.properties.AttachFace; import net.minecraft.state.properties.AttachFace;
import net.minecraft.util.Direction;
import net.minecraft.util.Direction.Axis; import net.minecraft.util.Direction.Axis;
public class AnalogLeverTileEntityRenderer extends SafeTileEntityRenderer<AnalogLeverTileEntity> { public class AnalogLeverTileEntityRenderer extends SafeTileEntityRenderer<AnalogLeverTileEntity> {
@ -20,30 +23,32 @@ public class AnalogLeverTileEntityRenderer extends SafeTileEntityRenderer<Analog
} }
@Override @Override
public void renderFast(AnalogLeverTileEntity te, double x, double y, double z, float partialTicks, protected void renderSafe(AnalogLeverTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
int destroyStage, BufferBuilder buffer) { int light, int overlay) {
BlockState leverState = te.getBlockState(); BlockState leverState = te.getBlockState();
int lightCoords = WorldRenderer.getLightmapCoordinates(te.getWorld(), leverState, te.getPos()); int lightCoords = WorldRenderer.getLightmapCoordinates(te.getWorld(), leverState, te.getPos());
float state = te.clientState.get(partialTicks); float state = te.clientState.get(partialTicks);
IVertexBuffer vb = buffer.getBuffer(RenderType.getSolid());
// Handle // Handle
SuperByteBuffer handle = AllBlockPartials.ANALOG_LEVER_HANDLE.renderOn(leverState); SuperByteBuffer handle = AllBlockPartials.ANALOG_LEVER_HANDLE.renderOn(leverState);
float angle = (float) ((state / 15) * 90 / 180 * Math.PI); float angle = (float) ((state / 15) * 90 / 180 * Math.PI);
handle.translate(-1 / 2f, -1 / 16f, -1 / 2f).rotate(Axis.X, angle).translate(1 / 2f, 1 / 16f, 1 / 2f); handle.translate(-1 / 2f, -1 / 16f, -1 / 2f).rotate(Axis.X, angle).translate(1 / 2f, 1 / 16f, 1 / 2f);
transform(handle, leverState).light(lightCoords).translate(x, y, z).renderInto(buffer); transform(handle, leverState).light(lightCoords).renderInto(ms, vb);
// Indicator // Indicator
int color = ColorHelper.mixColors(0x2C0300, 0xCD0000, state / 15f); int color = ColorHelper.mixColors(0x2C0300, 0xCD0000, state / 15f);
SuperByteBuffer indicator = transform(AllBlockPartials.ANALOG_LEVER_INDICATOR.renderOn(leverState), leverState); SuperByteBuffer indicator = transform(AllBlockPartials.ANALOG_LEVER_INDICATOR.renderOn(leverState), leverState);
indicator.light(lightCoords).translate(x, y, z).color(color).renderInto(buffer); indicator.light(lightCoords).color(color).renderInto(ms, vb);
} }
private SuperByteBuffer transform(SuperByteBuffer buffer, BlockState leverState) { private SuperByteBuffer transform(SuperByteBuffer buffer, BlockState leverState) {
AttachFace face = leverState.get(AnalogLeverBlock.FACE); AttachFace face = leverState.get(AnalogLeverBlock.FACE);
float rX = face == AttachFace.FLOOR ? 0 : face == AttachFace.WALL ? 90 : 180; float rX = face == AttachFace.FLOOR ? 0 : face == AttachFace.WALL ? 90 : 180;
float rY = AngleHelper.horizontalAngle(leverState.get(AnalogLeverBlock.HORIZONTAL_FACING)); float rY = AngleHelper.horizontalAngle(leverState.get(AnalogLeverBlock.HORIZONTAL_FACING));
buffer.rotateCentered(Axis.X, (float) (rX / 180 * Math.PI)); buffer.rotateCentered(Direction.EAST, (float) (rX / 180 * Math.PI));
buffer.rotateCentered(Axis.Y, (float) (rY / 180 * Math.PI)); buffer.rotateCentered(Direction.UP, (float) (rY / 180 * Math.PI));
return buffer; return buffer;
} }

View file

@ -177,6 +177,7 @@ public class ZapperRenderHandler {
Minecraft mc = Minecraft.getInstance(); Minecraft mc = Minecraft.getInstance();
boolean rightHand = event.getHand() == Hand.MAIN_HAND ^ mc.player.getPrimaryHand() == HandSide.LEFT; boolean rightHand = event.getHand() == Hand.MAIN_HAND ^ mc.player.getPrimaryHand() == HandSide.LEFT;
// TODO 1.15 buffered render
RenderSystem.pushMatrix(); RenderSystem.pushMatrix();
float recoil = rightHand ? MathHelper.lerp(event.getPartialTicks(), lastRightHandAnimation, rightHandAnimation) float recoil = rightHand ? MathHelper.lerp(event.getPartialTicks(), lastRightHandAnimation, rightHandAnimation)
@ -210,7 +211,7 @@ public class ZapperRenderHandler {
RenderSystem.rotatef(f * -135.0F, 0.0F, 1.0F, 0.0F); RenderSystem.rotatef(f * -135.0F, 0.0F, 1.0F, 0.0F);
RenderSystem.translatef(f * 5.6F, 0.0F, 0.0F); RenderSystem.translatef(f * 5.6F, 0.0F, 0.0F);
RenderSystem.rotatef(f * 40.0F, 0.0F, 1.0F, 0.0F); RenderSystem.rotatef(f * 40.0F, 0.0F, 1.0F, 0.0F);
PlayerRenderer playerrenderer = mc.getRenderManager().getRenderer(abstractclientplayerentity); PlayerRenderer playerrenderer = (PlayerRenderer) mc.getRenderManager().getRenderer(abstractclientplayerentity);
RenderSystem.disableCull(); RenderSystem.disableCull();
if (rightHand) { if (rightHand) {
playerrenderer.renderRightArm(abstractclientplayerentity); playerrenderer.renderRightArm(abstractclientplayerentity);