Finish porting most TERs
This commit is contained in:
parent
11ae3bc820
commit
3c07aa51de
12 changed files with 101 additions and 92 deletions
|
@ -39,7 +39,7 @@ public class KineticTileEntityRenderer extends SafeTileEntityRenderer<KineticTil
|
|||
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);
|
||||
renderRotatingBuffer(te, superByteBuffer, ms, buffer);
|
||||
}
|
||||
|
|
|
@ -10,9 +10,9 @@ import com.simibubi.create.modules.contraptions.base.KineticTileEntityRenderer;
|
|||
import com.simibubi.create.modules.contraptions.components.clock.CuckooClockTileEntity.Animation;
|
||||
|
||||
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.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Direction.Axis;
|
||||
|
@ -33,7 +33,7 @@ public class CuckooClockRenderer extends KineticTileEntityRenderer {
|
|||
|
||||
CuckooClockTileEntity clock = (CuckooClockTileEntity) te;
|
||||
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);
|
||||
|
||||
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
|
||||
|
|
|
@ -38,6 +38,7 @@ public class ContraptionEntityRenderer extends EntityRenderer<ContraptionEntity>
|
|||
if (entity.getContraption() == null)
|
||||
return;
|
||||
|
||||
// TODO 1.15 buffered render
|
||||
RenderSystem.pushMatrix();
|
||||
long randomBits = (long) entity.getEntityId() * 493286711L;
|
||||
randomBits = randomBits * randomBits * 4392167121L + randomBits * 98761L;
|
||||
|
|
|
@ -7,7 +7,8 @@ import static net.minecraft.state.properties.BlockStateProperties.AXIS;
|
|||
import java.util.Arrays;
|
||||
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.AllBlocks;
|
||||
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.NBTHelper;
|
||||
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.modules.contraptions.base.IRotate;
|
||||
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.Blocks;
|
||||
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.Tessellator;
|
||||
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.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Direction.Axis;
|
||||
|
@ -49,20 +49,21 @@ public class DeployerTileEntityRenderer extends SafeTileEntityRenderer<DeployerT
|
|||
public DeployerTileEntityRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||
super(dispatcher);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void renderWithGL(DeployerTileEntity te, double x, double y, double z, float partialTicks,
|
||||
int destroyStage) {
|
||||
renderItem(te, x, y, z, partialTicks);
|
||||
FilteringRenderer.renderOnTileEntity(te, x, y, z, partialTicks, destroyStage);
|
||||
renderComponents(te, x, y, z, partialTicks);
|
||||
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, 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();
|
||||
Vec3d offset = getHandOffset(te, partialTicks, deployerState).add(VecHelper.getCenterOf(BlockPos.ZERO));
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.translated(offset.x + x, offset.y + y, offset.z + z);
|
||||
ms.push();
|
||||
ms.translate(offset.x, offset.y, offset.z);
|
||||
|
||||
Direction facing = deployerState.get(FACING);
|
||||
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;
|
||||
boolean displayMode = facing == Direction.UP && te.getSpeed() == 0 && !punching;
|
||||
|
||||
RenderSystem.rotatef(yRot, 0, 1, 0);
|
||||
ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(yRot));
|
||||
if (!displayMode) {
|
||||
RenderSystem.rotatef(zRot, 1, 0, 0);
|
||||
RenderSystem.translated(0, 0, -11 / 16f);
|
||||
ms.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(zRot));
|
||||
ms.translate(0, 0, -11 / 16f);
|
||||
}
|
||||
|
||||
if (punching)
|
||||
RenderSystem.translatef(0, 1 / 8f, -1 / 16f);
|
||||
ms.translate(0, 1 / 8f, -1 / 16f);
|
||||
|
||||
ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer();
|
||||
|
||||
TransformType transform = TransformType.NONE;
|
||||
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) {
|
||||
float scale = isBlockItem ? 1.25f : 1;
|
||||
RenderSystem.translated(0, isBlockItem ? 9 / 16f : 11 / 16f, 0);
|
||||
RenderSystem.scaled(scale, scale, scale);
|
||||
ms.translate(0, isBlockItem ? 9 / 16f : 11 / 16f, 0);
|
||||
ms.scale(scale, scale, scale);
|
||||
transform = TransformType.GROUND;
|
||||
RenderSystem.rotatef(AnimationTickHolder.getRenderTick(), 0, 1, 0);
|
||||
ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(AnimationTickHolder.getRenderTick()));
|
||||
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
|
||||
itemRenderer.renderItem(te.heldItem, transform);
|
||||
RenderSystem.popMatrix();
|
||||
itemRenderer.renderItem(te.heldItem, transform, light, overlay, ms, buffer);
|
||||
ms.pop();
|
||||
}
|
||||
|
||||
protected void renderComponents(DeployerTileEntity te, double x, double y, double z, float partialTicks) {
|
||||
TessellatorHelper.prepareFastRender();
|
||||
TessellatorHelper.begin(DefaultVertexFormats.BLOCK);
|
||||
BufferBuilder buffer = Tessellator.getInstance().getBuffer();
|
||||
KineticTileEntityRenderer.renderRotatingKineticBlock(te, getWorld(), getRenderedBlockState(te), x, y, z,
|
||||
buffer);
|
||||
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);
|
||||
|
||||
BlockState blockState = te.getBlockState();
|
||||
BlockPos pos = te.getPos();
|
||||
|
||||
SuperByteBuffer pole = renderAndTransform(getWorld(), AllBlockPartials.DEPLOYER_POLE, blockState, pos, true);
|
||||
SuperByteBuffer hand = renderAndTransform(getWorld(), te.getHandPose(), blockState, pos, false);
|
||||
SuperByteBuffer pole = renderAndTransform(te.getWorld(), AllBlockPartials.DEPLOYER_POLE, blockState, pos, true);
|
||||
SuperByteBuffer hand = renderAndTransform(te.getWorld(), te.getHandPose(), blockState, pos, false);
|
||||
|
||||
Vec3d offset = getHandOffset(te, partialTicks, blockState);
|
||||
pole.translate(x + offset.x, y + offset.y, z + offset.z).renderInto(buffer);
|
||||
hand.translate(x + offset.x, y + offset.y, z + offset.z).renderInto(buffer);
|
||||
|
||||
TessellatorHelper.draw();
|
||||
pole.translate(offset.x, offset.y, offset.z).renderInto(ms, vb);
|
||||
hand.translate(offset.x, offset.y, offset.z).renderInto(ms, vb);
|
||||
}
|
||||
|
||||
protected Vec3d getHandOffset(DeployerTileEntity te, float partialTicks, BlockState blockState) {
|
||||
|
|
|
@ -3,14 +3,15 @@ package com.simibubi.create.modules.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.foundation.utility.AnimationTickHolder;
|
||||
import com.simibubi.create.foundation.utility.SuperByteBuffer;
|
||||
import com.simibubi.create.modules.contraptions.base.KineticTileEntity;
|
||||
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.RenderType;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
@ -27,7 +28,8 @@ public class EncasedFanTileEntityRenderer extends KineticTileEntityRenderer {
|
|||
Direction direction = te.getBlockState().get(FACING);
|
||||
SuperByteBuffer superBuffer = AllBlockPartials.SHAFT_HALF.renderOnDirectional(te.getBlockState(),
|
||||
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 speed = te.getSpeed() * 5;
|
||||
|
@ -40,8 +42,8 @@ public class EncasedFanTileEntityRenderer extends KineticTileEntityRenderer {
|
|||
|
||||
SuperByteBuffer superByteBuffer = AllBlockPartials.ENCASED_FAN_INNER.renderOnDirectional(te.getBlockState(),
|
||||
direction.getOpposite());
|
||||
kineticRotationTransform(superByteBuffer, te, direction.getAxis(), angle, getWorld());
|
||||
superByteBuffer.translate(x, y, z).renderInto(buffer);
|
||||
kineticRotationTransform(superByteBuffer, te, direction.getAxis(), angle);
|
||||
superByteBuffer.renderInto(ms, vb);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.simibubi.create.modules.contraptions.components.flywheel;
|
|||
import static com.simibubi.create.modules.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.foundation.utility.AngleHelper;
|
||||
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));
|
||||
float speed = wte.visualSpeed.get(partialTicks) * 3 / 10f;
|
||||
float angle = wte.angle + speed * partialTicks;
|
||||
|
||||
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
|
||||
|
||||
if (FlywheelBlock.isConnected(blockState)) {
|
||||
Direction connection = FlywheelBlock.getConnection(blockState);
|
||||
|
@ -48,17 +51,17 @@ public class FlywheelRenderer extends KineticTileEntityRenderer {
|
|||
boolean flip = blockState.get(FlywheelBlock.CONNECTION) == ConnectionState.LEFT;
|
||||
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
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));
|
||||
wheel.renderInto(ms, buffer.getBuffer(RenderType.getSolid()));
|
||||
wheel.renderInto(ms, vb);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
package com.simibubi.create.modules.contraptions.components.flywheel.engine;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.foundation.block.SafeTileEntityRenderer;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
|
||||
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.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Direction.Axis;
|
||||
|
||||
public class EngineRenderer<T extends EngineTileEntity> extends SafeTileEntityRenderer<T> {
|
||||
|
||||
|
@ -18,8 +19,8 @@ public class EngineRenderer<T extends EngineTileEntity> extends SafeTileEntityRe
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void renderFast(T te, double x, double y, double z, float partialTicks, int destroyStage,
|
||||
BufferBuilder buffer) {
|
||||
protected void renderSafe(T te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light,
|
||||
int overlay) {
|
||||
Block block = te.getBlockState().getBlock();
|
||||
if (block instanceof EngineBlock) {
|
||||
EngineBlock engineBlock = (EngineBlock) block;
|
||||
|
@ -27,8 +28,9 @@ public class EngineRenderer<T extends EngineTileEntity> extends SafeTileEntityRe
|
|||
if (frame != null) {
|
||||
Direction facing = te.getBlockState().get(EngineBlock.HORIZONTAL_FACING);
|
||||
float angle = AngleHelper.rad(AngleHelper.horizontalAngle(facing));
|
||||
frame.renderOn(te.getBlockState()).translate(0, 0, -1).rotateCentered(Axis.Y, angle).translate(x, y, z)
|
||||
.light(WorldRenderer.getLightmapCoordinates(te.getWorld(), te.getBlockState(), te.getPos())).renderInto(buffer);
|
||||
frame.renderOn(te.getBlockState()).translate(0, 0, -1).rotateCentered(Direction.UP, angle)
|
||||
.light(WorldRenderer.getLightmapCoordinates(te.getWorld(), te.getBlockState(), te.getPos()))
|
||||
.renderInto(ms, buffer.getBuffer(RenderType.getSolid()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,9 +9,9 @@ import com.simibubi.create.modules.contraptions.base.KineticTileEntity;
|
|||
import com.simibubi.create.modules.contraptions.base.KineticTileEntityRenderer;
|
||||
|
||||
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.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.util.Direction.Axis;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
@ -34,7 +34,7 @@ public class MechanicalMixerTileEntityRenderer extends KineticTileEntityRenderer
|
|||
SuperByteBuffer superBuffer = AllBlockPartials.SHAFTLESS_COGWHEEL.renderOn(blockState);
|
||||
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 speed = mixer.getRenderedHeadRotationSpeed(partialTicks);
|
||||
float time = AnimationTickHolder.getRenderTick();
|
||||
|
|
|
@ -10,9 +10,9 @@ import com.simibubi.create.modules.contraptions.base.KineticTileEntity;
|
|||
import com.simibubi.create.modules.contraptions.base.KineticTileEntityRenderer;
|
||||
|
||||
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.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.state.properties.BlockStateProperties;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
@ -30,7 +30,7 @@ public class MechanicalPressTileEntityRenderer extends KineticTileEntityRenderer
|
|||
|
||||
BlockPos pos = te.getPos();
|
||||
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);
|
||||
|
||||
SuperByteBuffer headRender = AllBlockPartials.MECHANICAL_PRESS_HEAD.renderOnHorizontal(blockState);
|
||||
|
|
|
@ -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.FACING;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.CreateClient;
|
||||
import com.simibubi.create.foundation.behaviour.filtering.FilteringRenderer;
|
||||
import com.simibubi.create.foundation.block.SafeTileEntityRenderer;
|
||||
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.KineticTileEntity;
|
||||
import com.simibubi.create.modules.contraptions.base.KineticTileEntityRenderer;
|
||||
|
||||
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.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.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Rotation;
|
||||
|
@ -34,27 +34,26 @@ public class SawTileEntityRenderer extends SafeTileEntityRenderer<SawTileEntity>
|
|||
public SawTileEntityRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||
super(dispatcher);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void renderWithGL(SawTileEntity te, double x, double y, double z, float partialTicks, int destroyStage) {
|
||||
renderItems(te, x, y, z, partialTicks);
|
||||
FilteringRenderer.renderOnTileEntity(te, x, y, z, partialTicks, destroyStage);
|
||||
renderShaft(te, x, y, z);
|
||||
protected void renderSafe(SawTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light,
|
||||
int overlay) {
|
||||
renderItems(te, partialTicks, ms, buffer, light, overlay);
|
||||
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) {
|
||||
TessellatorHelper.prepareFastRender();
|
||||
TessellatorHelper.begin(DefaultVertexFormats.BLOCK);
|
||||
KineticTileEntityRenderer.renderRotatingBuffer(te, getWorld(), getRotatedModel(te), x, y, z,
|
||||
Tessellator.getInstance().getBuffer());
|
||||
TessellatorHelper.draw();
|
||||
protected void renderShaft(SawTileEntity te, MatrixStack ms, IRenderTypeBuffer buffer, int light,
|
||||
int overlay) {
|
||||
KineticTileEntityRenderer.renderRotatingBuffer(te, getRotatedModel(te), ms, buffer.getBuffer(RenderType.getSolid()));
|
||||
}
|
||||
|
||||
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;
|
||||
if (processingMode && !te.inventory.isEmpty()) {
|
||||
boolean alongZ = !te.getBlockState().get(SawBlock.AXIS_ALONG_FIRST_COORDINATE);
|
||||
RenderSystem.pushMatrix();
|
||||
ms.push();
|
||||
|
||||
boolean moving = 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);
|
||||
ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer();
|
||||
IBakedModel modelWithOverrides = itemRenderer.getModelWithOverrides(stack);
|
||||
IBakedModel modelWithOverrides = itemRenderer.getItemModelWithOverrides(stack, te.getWorld(), null);
|
||||
boolean blockItem = modelWithOverrides.isGui3d();
|
||||
|
||||
RenderSystem.translated(x + (alongZ ? offset : .5), y + (blockItem ? .925f : 13f / 16f),
|
||||
z + (alongZ ? .5 : offset));
|
||||
ms.translate(alongZ ? offset : .5, blockItem ? .925f : 13f / 16f, alongZ ? .5 : offset);
|
||||
|
||||
RenderSystem.scaled(.5, .5, .5);
|
||||
ms.scale(.5f, .5f, .5f);
|
||||
if (alongZ)
|
||||
RenderSystem.rotatef(90, 0, 1, 0);
|
||||
RenderSystem.rotatef(90, 1, 0, 0);
|
||||
itemRenderer.renderItem(stack, ItemCameraTransforms.TransformType.FIXED);
|
||||
RenderSystem.popMatrix();
|
||||
ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(90));
|
||||
ms.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(90));
|
||||
itemRenderer.renderItem(stack, ItemCameraTransforms.TransformType.FIXED, light, overlay, ms, buffer);
|
||||
ms.pop();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.simibubi.create.modules.contraptions.redstone;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.foundation.block.SafeTileEntityRenderer;
|
||||
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 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.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.state.properties.AttachFace;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Direction.Axis;
|
||||
|
||||
public class AnalogLeverTileEntityRenderer extends SafeTileEntityRenderer<AnalogLeverTileEntity> {
|
||||
|
@ -20,30 +23,32 @@ public class AnalogLeverTileEntityRenderer extends SafeTileEntityRenderer<Analog
|
|||
}
|
||||
|
||||
@Override
|
||||
public void renderFast(AnalogLeverTileEntity te, double x, double y, double z, float partialTicks,
|
||||
int destroyStage, BufferBuilder buffer) {
|
||||
protected void renderSafe(AnalogLeverTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
||||
int light, int overlay) {
|
||||
BlockState leverState = te.getBlockState();
|
||||
int lightCoords = WorldRenderer.getLightmapCoordinates(te.getWorld(), leverState, te.getPos());
|
||||
float state = te.clientState.get(partialTicks);
|
||||
|
||||
IVertexBuffer vb = buffer.getBuffer(RenderType.getSolid());
|
||||
|
||||
// Handle
|
||||
SuperByteBuffer handle = AllBlockPartials.ANALOG_LEVER_HANDLE.renderOn(leverState);
|
||||
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);
|
||||
transform(handle, leverState).light(lightCoords).translate(x, y, z).renderInto(buffer);
|
||||
transform(handle, leverState).light(lightCoords).renderInto(ms, vb);
|
||||
|
||||
// Indicator
|
||||
int color = ColorHelper.mixColors(0x2C0300, 0xCD0000, state / 15f);
|
||||
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) {
|
||||
AttachFace face = leverState.get(AnalogLeverBlock.FACE);
|
||||
float rX = face == AttachFace.FLOOR ? 0 : face == AttachFace.WALL ? 90 : 180;
|
||||
float rY = AngleHelper.horizontalAngle(leverState.get(AnalogLeverBlock.HORIZONTAL_FACING));
|
||||
buffer.rotateCentered(Axis.X, (float) (rX / 180 * Math.PI));
|
||||
buffer.rotateCentered(Axis.Y, (float) (rY / 180 * Math.PI));
|
||||
buffer.rotateCentered(Direction.EAST, (float) (rX / 180 * Math.PI));
|
||||
buffer.rotateCentered(Direction.UP, (float) (rY / 180 * Math.PI));
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
|
|
@ -177,6 +177,7 @@ public class ZapperRenderHandler {
|
|||
Minecraft mc = Minecraft.getInstance();
|
||||
boolean rightHand = event.getHand() == Hand.MAIN_HAND ^ mc.player.getPrimaryHand() == HandSide.LEFT;
|
||||
|
||||
// TODO 1.15 buffered render
|
||||
RenderSystem.pushMatrix();
|
||||
|
||||
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.translatef(f * 5.6F, 0.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();
|
||||
if (rightHand) {
|
||||
playerrenderer.renderRightArm(abstractclientplayerentity);
|
||||
|
|
Loading…
Reference in a new issue