mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-16 23:11:40 +01:00
Non-fast TER updates
This commit is contained in:
parent
c44908b210
commit
501caa52b0
18 changed files with 224 additions and 130 deletions
|
@ -12,6 +12,8 @@ import net.minecraft.client.renderer.Vector4f;
|
||||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
|
import net.minecraft.util.Direction.Axis;
|
||||||
|
import net.minecraft.util.Direction.AxisDirection;
|
||||||
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
||||||
|
|
||||||
public class SuperByteBuffer {
|
public class SuperByteBuffer {
|
||||||
|
@ -99,6 +101,7 @@ public class SuperByteBuffer {
|
||||||
if (original.limit() == 0)
|
if (original.limit() == 0)
|
||||||
return;
|
return;
|
||||||
if (!(buffer instanceof BufferBuilder)) {
|
if (!(buffer instanceof BufferBuilder)) {
|
||||||
|
// TODO add "slow" path that writes all the data instead of using bulk put
|
||||||
throw new IllegalArgumentException("Unsupported buffer type!");
|
throw new IllegalArgumentException("Unsupported buffer type!");
|
||||||
}
|
}
|
||||||
((BufferBuilder)buffer).putBulkData(build(input));
|
((BufferBuilder)buffer).putBulkData(build(input));
|
||||||
|
@ -113,15 +116,25 @@ public class SuperByteBuffer {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SuperByteBuffer rotate(Direction axis, float angle) {
|
@Deprecated
|
||||||
if (angle == 0)
|
public SuperByteBuffer rotate(Axis axis, float radians) {
|
||||||
return this;
|
return rotate(Direction.getFacingFromAxis(AxisDirection.POSITIVE, axis), radians);
|
||||||
transforms.multiply(axis.getUnitVector().getDegreesQuaternion(angle));
|
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SuperByteBuffer rotateCentered(Direction axis, float angle) {
|
public SuperByteBuffer rotate(Direction axis, float radians) {
|
||||||
return translate(-.5f, -.5f, -.5f).rotate(axis, angle).translate(.5f, .5f, .5f);
|
if (radians == 0)
|
||||||
|
return this;
|
||||||
|
transforms.multiply(axis.getUnitVector().getRadialQuaternion(radians));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public SuperByteBuffer rotateCentered(Axis axis, float radians) {
|
||||||
|
return rotateCentered(Direction.getFacingFromAxis(AxisDirection.POSITIVE, axis), radians);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SuperByteBuffer rotateCentered(Direction axis, float radians) {
|
||||||
|
return translate(-.5f, -.5f, -.5f).rotate(axis, radians).translate(.5f, .5f, .5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SuperByteBuffer shiftUV(TextureAtlasSprite from, TextureAtlasSprite to) {
|
public SuperByteBuffer shiftUV(TextureAtlasSprite from, TextureAtlasSprite to) {
|
||||||
|
|
|
@ -65,7 +65,7 @@ public class KineticTileEntityRenderer extends SafeTileEntityRenderer<KineticTil
|
||||||
float angle) {
|
float angle) {
|
||||||
int light = te.getBlockState().getLightValue(te.getWorld(), te.getPos());
|
int light = te.getBlockState().getLightValue(te.getWorld(), te.getPos());
|
||||||
buffer.light((0xF0 << 24) | (light << 4));
|
buffer.light((0xF0 << 24) | (light << 4));
|
||||||
buffer.rotateCentered(Direction.getFacingFromAxis(AxisDirection.POSITIVE, axis), angle);
|
buffer.rotateCentered(axis, angle);
|
||||||
|
|
||||||
int white = 0xFFFFFF;
|
int white = 0xFFFFFF;
|
||||||
if (KineticDebugger.isActive()) {
|
if (KineticDebugger.isActive()) {
|
||||||
|
|
|
@ -12,10 +12,15 @@ import com.simibubi.create.modules.contraptions.base.KineticTileEntityRenderer;
|
||||||
import com.simibubi.create.modules.contraptions.components.contraptions.MovementContext;
|
import com.simibubi.create.modules.contraptions.components.contraptions.MovementContext;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||||
import net.minecraft.util.Direction.Axis;
|
import net.minecraft.util.Direction.Axis;
|
||||||
|
|
||||||
public class DrillTileEntityRenderer extends KineticTileEntityRenderer {
|
public class DrillTileEntityRenderer extends KineticTileEntityRenderer {
|
||||||
|
|
||||||
|
public DrillTileEntityRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||||
|
super(dispatcher);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
|
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
|
||||||
return getRotatingModel(te.getBlockState());
|
return getRotatingModel(te.getBlockState());
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.simibubi.create.modules.contraptions.components.clock;
|
package com.simibubi.create.modules.contraptions.components.clock;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
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;
|
||||||
|
@ -9,16 +10,22 @@ import com.simibubi.create.modules.contraptions.components.clock.CuckooClockTile
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.client.renderer.BufferBuilder;
|
import net.minecraft.client.renderer.BufferBuilder;
|
||||||
|
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||||
|
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;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
|
||||||
public class CuckooClockRenderer extends KineticTileEntityRenderer {
|
public class CuckooClockRenderer extends KineticTileEntityRenderer {
|
||||||
|
|
||||||
|
public CuckooClockRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||||
|
super(dispatcher);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderFast(KineticTileEntity te, double x, double y, double z, float partialTicks, int destroyStage,
|
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
||||||
BufferBuilder buffer) {
|
int light, int overlay) {
|
||||||
super.renderFast(te, x, y, z, partialTicks, destroyStage, buffer);
|
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
|
||||||
if (!(te instanceof CuckooClockTileEntity))
|
if (!(te instanceof CuckooClockTileEntity))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.simibubi.create.modules.contraptions.components.contraptions.bearing;
|
package com.simibubi.create.modules.contraptions.components.contraptions.bearing;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
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;
|
||||||
|
@ -7,16 +8,23 @@ 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.BufferBuilder;
|
||||||
|
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.state.properties.BlockStateProperties;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.Direction.Axis;
|
import net.minecraft.util.Direction.Axis;
|
||||||
|
|
||||||
public class BearingTileEntityRenderer extends KineticTileEntityRenderer {
|
public class BearingTileEntityRenderer extends KineticTileEntityRenderer {
|
||||||
|
|
||||||
|
public BearingTileEntityRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||||
|
super(dispatcher);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderFast(KineticTileEntity te, double x, double y, double z, float partialTicks,
|
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
||||||
int destroyStage, BufferBuilder buffer) {
|
int light, int overlay) {
|
||||||
super.renderFast(te, x, y, z, partialTicks, destroyStage, buffer);
|
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
|
||||||
|
|
||||||
IBearingTileEntity bearingTe = (IBearingTileEntity) te;
|
IBearingTileEntity bearingTe = (IBearingTileEntity) te;
|
||||||
final Direction facing = te.getBlockState().get(BlockStateProperties.FACING);
|
final Direction facing = te.getBlockState().get(BlockStateProperties.FACING);
|
||||||
|
@ -25,9 +33,8 @@ public class BearingTileEntityRenderer extends KineticTileEntityRenderer {
|
||||||
if (facing.getAxis().isHorizontal())
|
if (facing.getAxis().isHorizontal())
|
||||||
superBuffer.rotateCentered(Axis.Y, AngleHelper.rad(AngleHelper.horizontalAngle(facing.getOpposite())));
|
superBuffer.rotateCentered(Axis.Y, AngleHelper.rad(AngleHelper.horizontalAngle(facing.getOpposite())));
|
||||||
float interpolatedAngle = bearingTe.getInterpolatedAngle(partialTicks - 1);
|
float interpolatedAngle = bearingTe.getInterpolatedAngle(partialTicks - 1);
|
||||||
kineticRotationTransform(superBuffer, te, facing.getAxis(), (float) (interpolatedAngle / 180 * Math.PI),
|
kineticRotationTransform(superBuffer, te, facing.getAxis(), (float) (interpolatedAngle / 180 * Math.PI));
|
||||||
getWorld());
|
superBuffer.renderInto(ms, buffer.getBuffer(RenderType.getSolid()));
|
||||||
superBuffer.translate(x, y, z).renderInto(buffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -7,14 +7,13 @@ 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.BufferBuilder;
|
||||||
|
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||||
import net.minecraft.state.properties.BlockStateProperties;
|
import net.minecraft.state.properties.BlockStateProperties;
|
||||||
|
|
||||||
public class MechanicalPistonTileEntityRenderer extends KineticTileEntityRenderer {
|
public class MechanicalPistonTileEntityRenderer extends KineticTileEntityRenderer {
|
||||||
|
|
||||||
@Override
|
public MechanicalPistonTileEntityRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||||
public void renderFast(KineticTileEntity te, double x, double y, double z, float partialTicks,
|
super(dispatcher);
|
||||||
int destroyStage, BufferBuilder buffer) {
|
|
||||||
super.renderFast(te, x, y, z, partialTicks, destroyStage, buffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package com.simibubi.create.modules.contraptions.components.contraptions.pulley;
|
package com.simibubi.create.modules.contraptions.components.contraptions.pulley;
|
||||||
|
|
||||||
|
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.CreateClient;
|
import com.simibubi.create.CreateClient;
|
||||||
|
@ -9,18 +11,25 @@ import com.simibubi.create.modules.contraptions.base.KineticTileEntityRenderer;
|
||||||
import com.simibubi.create.modules.contraptions.components.contraptions.ContraptionEntity;
|
import com.simibubi.create.modules.contraptions.components.contraptions.ContraptionEntity;
|
||||||
|
|
||||||
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.tileentity.TileEntityRendererDispatcher;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.Direction.AxisDirection;
|
import net.minecraft.util.Direction.AxisDirection;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
import net.minecraft.world.IWorld;
|
||||||
|
|
||||||
public class PulleyRenderer extends KineticTileEntityRenderer {
|
public class PulleyRenderer extends KineticTileEntityRenderer {
|
||||||
|
|
||||||
|
public PulleyRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||||
|
super(dispatcher);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderFast(KineticTileEntity te, double x, double y, double z, float partialTicks, int destroyStage,
|
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
||||||
BufferBuilder buffer) {
|
int light, int overlay) {
|
||||||
super.renderFast(te, x, y, z, partialTicks, destroyStage, buffer);
|
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
|
||||||
|
|
||||||
PulleyTileEntity pulley = (PulleyTileEntity) te;
|
PulleyTileEntity pulley = (PulleyTileEntity) te;
|
||||||
BlockState blockState = te.getBlockState();
|
BlockState blockState = te.getBlockState();
|
||||||
|
@ -37,29 +46,31 @@ public class PulleyRenderer extends KineticTileEntityRenderer {
|
||||||
if (pulley.movedContraption != null) {
|
if (pulley.movedContraption != null) {
|
||||||
ContraptionEntity e = pulley.movedContraption;
|
ContraptionEntity e = pulley.movedContraption;
|
||||||
PulleyContraption c = (PulleyContraption) pulley.movedContraption.getContraption();
|
PulleyContraption c = (PulleyContraption) pulley.movedContraption.getContraption();
|
||||||
double entityPos = MathHelper.lerp(partialTicks, e.lastTickPosY, e.posY);
|
double entityPos = MathHelper.lerp(partialTicks, e.lastTickPosY, e.getY());
|
||||||
offset = (float) -(entityPos - c.getAnchor().getY() - c.initialOffset);
|
offset = (float) -(entityPos - c.getAnchor().getY() - c.initialOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
|
||||||
|
|
||||||
if (pulley.running || pulley.offset == 0)
|
if (pulley.running || pulley.offset == 0)
|
||||||
renderAt(offset > .25f ? magnet : halfMagnet, x, y, z, offset, pos, buffer);
|
renderAt(te.getWorld(), offset > .25f ? magnet : halfMagnet, offset, pos, ms, vb);
|
||||||
|
|
||||||
float f = offset % 1;
|
float f = offset % 1;
|
||||||
if (offset > .75f && (f < .25f || f > .75f))
|
if (offset > .75f && (f < .25f || f > .75f))
|
||||||
renderAt(halfRope, x, y, z, f > .75f ? f - 1 : f, pos, buffer);
|
renderAt(te.getWorld(), halfRope, f > .75f ? f - 1 : f, pos, ms, vb);
|
||||||
|
|
||||||
if (!pulley.running)
|
if (!pulley.running)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (int i = 0; i < offset - 1.25f; i++)
|
for (int i = 0; i < offset - 1.25f; i++)
|
||||||
renderAt(rope, x, y, z, offset - i - 1, pos, buffer);
|
renderAt(te.getWorld(), rope, offset - i - 1, pos, ms, vb);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void renderAt(SuperByteBuffer partial, double x, double y, double z, float offset, BlockPos pulleyPos,
|
public void renderAt(IWorld world, SuperByteBuffer partial, float offset, BlockPos pulleyPos,
|
||||||
BufferBuilder buffer) {
|
MatrixStack ms, IVertexBuilder buffer) {
|
||||||
BlockPos actualPos = pulleyPos.down((int) offset);
|
BlockPos actualPos = pulleyPos.down((int) offset);
|
||||||
int light = getWorld().getBlockState(actualPos).getPackedLightmapCoords(getWorld(), actualPos);
|
int light = world.getBlockState(actualPos).getPackedLightmapCoords(world, actualPos);
|
||||||
partial.translate(x, y - offset, z).light(light).renderInto(buffer);
|
partial.translate(0, -offset, 0).light(light).renderInto(ms, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -2,29 +2,36 @@ package com.simibubi.create.modules.contraptions.components.crank;
|
||||||
|
|
||||||
import static net.minecraft.state.properties.BlockStateProperties.FACING;
|
import static net.minecraft.state.properties.BlockStateProperties.FACING;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.simibubi.create.AllBlockPartials;
|
import com.simibubi.create.AllBlockPartials;
|
||||||
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.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.tileentity.TileEntityRendererDispatcher;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
|
|
||||||
public class HandCrankTileEntityRenderer extends KineticTileEntityRenderer {
|
public class HandCrankTileEntityRenderer extends KineticTileEntityRenderer {
|
||||||
|
|
||||||
|
public HandCrankTileEntityRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||||
|
super(dispatcher);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderFast(KineticTileEntity te, double x, double y, double z, float partialTicks,
|
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
||||||
int destroyStage, BufferBuilder buffer) {
|
int light, int overlay) {
|
||||||
super.renderFast(te, x, y, z, partialTicks, destroyStage, buffer);
|
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
|
||||||
|
|
||||||
BlockState state = te.getBlockState();
|
BlockState state = te.getBlockState();
|
||||||
Direction facing = state.get(FACING);
|
Direction facing = state.get(FACING);
|
||||||
SuperByteBuffer handle = AllBlockPartials.HAND_CRANK_HANDLE.renderOnDirectional(state, facing.getOpposite());
|
SuperByteBuffer handle = AllBlockPartials.HAND_CRANK_HANDLE.renderOnDirectional(state, facing.getOpposite());
|
||||||
HandCrankTileEntity crank = (HandCrankTileEntity) te;
|
HandCrankTileEntity crank = (HandCrankTileEntity) te;
|
||||||
kineticRotationTransform(handle, te, facing.getAxis(),
|
kineticRotationTransform(handle, te, facing.getAxis(),
|
||||||
(crank.independentAngle + partialTicks * crank.chasingVelocity) / 360, getWorld());
|
(crank.independentAngle + partialTicks * crank.chasingVelocity) / 360);
|
||||||
handle.translate(x, y, z).renderInto(buffer);
|
handle.renderInto(ms, buffer.getBuffer(RenderType.getSolid()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ 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.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;
|
||||||
|
@ -9,14 +10,20 @@ 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.BufferBuilder;
|
||||||
|
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||||
|
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;
|
||||||
|
|
||||||
public class EncasedFanTileEntityRenderer extends KineticTileEntityRenderer {
|
public class EncasedFanTileEntityRenderer extends KineticTileEntityRenderer {
|
||||||
|
|
||||||
|
public EncasedFanTileEntityRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||||
|
super(dispatcher);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderFast(KineticTileEntity te, double x, double y, double z, float partialTicks,
|
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
||||||
int destroyStage, BufferBuilder buffer) {
|
int light, int overlay) {
|
||||||
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());
|
||||||
|
|
|
@ -2,6 +2,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.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;
|
||||||
|
@ -11,6 +12,9 @@ import com.simibubi.create.modules.contraptions.components.flywheel.FlywheelBloc
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.client.renderer.BufferBuilder;
|
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.Direction;
|
||||||
import net.minecraft.util.Direction.Axis;
|
import net.minecraft.util.Direction.Axis;
|
||||||
import net.minecraft.util.Direction.AxisDirection;
|
import net.minecraft.util.Direction.AxisDirection;
|
||||||
|
@ -19,10 +23,14 @@ import net.minecraft.util.Rotation;
|
||||||
|
|
||||||
public class FlywheelRenderer extends KineticTileEntityRenderer {
|
public class FlywheelRenderer extends KineticTileEntityRenderer {
|
||||||
|
|
||||||
|
public FlywheelRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||||
|
super(dispatcher);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderFast(KineticTileEntity te, double x, double y, double z, float partialTicks, int destroyStage,
|
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
||||||
BufferBuilder buffer) {
|
int light, int overlay) {
|
||||||
super.renderFast(te, x, y, z, partialTicks, destroyStage, buffer);
|
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
|
||||||
|
|
||||||
BlockState blockState = te.getBlockState();
|
BlockState blockState = te.getBlockState();
|
||||||
FlywheelTileEntity wte = (FlywheelTileEntity) te;
|
FlywheelTileEntity wte = (FlywheelTileEntity) te;
|
||||||
|
@ -33,7 +41,7 @@ public class FlywheelRenderer extends KineticTileEntityRenderer {
|
||||||
|
|
||||||
if (FlywheelBlock.isConnected(blockState)) {
|
if (FlywheelBlock.isConnected(blockState)) {
|
||||||
Direction connection = FlywheelBlock.getConnection(blockState);
|
Direction connection = FlywheelBlock.getConnection(blockState);
|
||||||
int light = blockState.getPackedLightmapCoords(getWorld(), te.getPos().offset(connection));
|
int light = blockState.getPackedLightmapCoords(te.getWorld(), te.getPos().offset(connection));
|
||||||
float rotation = connection.getAxis() == Axis.X ^ connection.getAxisDirection() == AxisDirection.NEGATIVE
|
float rotation = connection.getAxis() == Axis.X ^ connection.getAxisDirection() == AxisDirection.NEGATIVE
|
||||||
? -angle
|
? -angle
|
||||||
: angle;
|
: angle;
|
||||||
|
@ -49,9 +57,8 @@ public class FlywheelRenderer extends KineticTileEntityRenderer {
|
||||||
false, rotation, flip), connection).translate(x, y, z).light(light).renderInto(buffer);
|
false, rotation, flip), connection).translate(x, y, z).light(light).renderInto(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
kineticRotationTransform(wheel, te, blockState.get(HORIZONTAL_FACING).getAxis(), AngleHelper.rad(angle),
|
kineticRotationTransform(wheel, te, blockState.get(HORIZONTAL_FACING).getAxis(), AngleHelper.rad(angle));
|
||||||
getWorld());
|
wheel.renderInto(ms, buffer.getBuffer(RenderType.getSolid()));
|
||||||
wheel.translate(x, y, z).renderInto(buffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package com.simibubi.create.modules.contraptions.components.mixer;
|
package com.simibubi.create.modules.contraptions.components.mixer;
|
||||||
|
|
||||||
|
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;
|
||||||
|
@ -8,33 +10,37 @@ 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.BufferBuilder;
|
||||||
|
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||||
|
import net.minecraft.client.renderer.RenderType;
|
||||||
import net.minecraft.util.Direction.Axis;
|
import net.minecraft.util.Direction.Axis;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
public class MechanicalMixerTileEntityRenderer extends KineticTileEntityRenderer {
|
public class MechanicalMixerTileEntityRenderer extends KineticTileEntityRenderer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderFast(KineticTileEntity te, double x, double y, double z, float partialTicks,
|
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
||||||
int destroyStage, BufferBuilder buffer) {
|
int light, int overlay) {
|
||||||
BlockState blockState = te.getBlockState();
|
BlockState blockState = te.getBlockState();
|
||||||
MechanicalMixerTileEntity mixer = (MechanicalMixerTileEntity) te;
|
MechanicalMixerTileEntity mixer = (MechanicalMixerTileEntity) te;
|
||||||
BlockPos pos = te.getPos();
|
BlockPos pos = te.getPos();
|
||||||
|
|
||||||
|
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
|
||||||
|
|
||||||
SuperByteBuffer superBuffer = AllBlockPartials.SHAFTLESS_COGWHEEL.renderOn(blockState);
|
SuperByteBuffer superBuffer = AllBlockPartials.SHAFTLESS_COGWHEEL.renderOn(blockState);
|
||||||
standardKineticRotationTransform(superBuffer, te, getWorld()).translate(x, y, z).renderInto(buffer);
|
standardKineticRotationTransform(superBuffer, te).renderInto(ms, vb);
|
||||||
|
|
||||||
int packedLightmapCoords = blockState.getPackedLightmapCoords(getWorld(), pos);
|
int packedLightmapCoords = blockState.getPackedLightmapCoords(te.getWorld(), 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();
|
||||||
float angle = (float) (((time * speed * 6 / 10f) % 360) / 180 * (float) Math.PI);
|
float angle = (float) (((time * speed * 6 / 10f) % 360) / 180 * (float) Math.PI);
|
||||||
|
|
||||||
SuperByteBuffer poleRender = AllBlockPartials.MECHANICAL_MIXER_POLE.renderOn(blockState);
|
SuperByteBuffer poleRender = AllBlockPartials.MECHANICAL_MIXER_POLE.renderOn(blockState);
|
||||||
poleRender.translate(x, y - renderedHeadOffset, z).light(packedLightmapCoords).renderInto(buffer);
|
poleRender.translate(0, -renderedHeadOffset, 0).light(packedLightmapCoords).renderInto(ms, vb);
|
||||||
|
|
||||||
SuperByteBuffer headRender = AllBlockPartials.MECHANICAL_MIXER_HEAD.renderOn(blockState);
|
SuperByteBuffer headRender = AllBlockPartials.MECHANICAL_MIXER_HEAD.renderOn(blockState);
|
||||||
headRender.rotateCentered(Axis.Y, angle).translate(x, y - renderedHeadOffset, z).light(packedLightmapCoords)
|
headRender.rotateCentered(Axis.Y, angle).translate(0, -renderedHeadOffset, 0).light(packedLightmapCoords)
|
||||||
.renderInto(buffer);
|
.renderInto(ms, vb);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,14 @@ 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.tileentity.TileEntityRendererDispatcher;
|
||||||
|
|
||||||
public class MotorTileEntityRenderer extends KineticTileEntityRenderer {
|
public class MotorTileEntityRenderer extends KineticTileEntityRenderer {
|
||||||
|
|
||||||
|
public MotorTileEntityRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||||
|
super(dispatcher);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
|
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
|
||||||
return AllBlockPartials.SHAFT_HALF.renderOnHorizontal(te.getBlockState());
|
return AllBlockPartials.SHAFT_HALF.renderOnHorizontal(te.getBlockState());
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.simibubi.create.modules.contraptions.components.press;
|
||||||
|
|
||||||
import static net.minecraft.state.properties.BlockStateProperties.HORIZONTAL_FACING;
|
import static net.minecraft.state.properties.BlockStateProperties.HORIZONTAL_FACING;
|
||||||
|
|
||||||
|
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.foundation.utility.SuperByteBuffer;
|
import com.simibubi.create.foundation.utility.SuperByteBuffer;
|
||||||
|
@ -10,23 +11,30 @@ 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.BufferBuilder;
|
||||||
|
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.state.properties.BlockStateProperties;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
public class MechanicalPressTileEntityRenderer extends KineticTileEntityRenderer {
|
public class MechanicalPressTileEntityRenderer extends KineticTileEntityRenderer {
|
||||||
|
|
||||||
|
public MechanicalPressTileEntityRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||||
|
super(dispatcher);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderFast(KineticTileEntity te, double x, double y, double z, float partialTicks,
|
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
||||||
int destroyStage, BufferBuilder buffer) {
|
int light, int overlay) {
|
||||||
super.renderFast(te, x, y, z, partialTicks, destroyStage, buffer);
|
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
|
||||||
|
|
||||||
BlockPos pos = te.getPos();
|
BlockPos pos = te.getPos();
|
||||||
BlockState blockState = te.getBlockState();
|
BlockState blockState = te.getBlockState();
|
||||||
int packedLightmapCoords = blockState.getPackedLightmapCoords(getWorld(), pos);
|
int packedLightmapCoords = blockState.getPackedLightmapCoords(te.getWorld(), 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);
|
||||||
headRender.translate(x, y - renderedHeadOffset, z).light(packedLightmapCoords).renderInto(buffer);
|
headRender.translate(0, -renderedHeadOffset, 0).light(packedLightmapCoords).renderInto(ms, buffer.getBuffer(RenderType.getSolid()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -5,10 +5,15 @@ 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.tileentity.TileEntityRendererDispatcher;
|
||||||
import net.minecraft.state.properties.BlockStateProperties;
|
import net.minecraft.state.properties.BlockStateProperties;
|
||||||
|
|
||||||
public class EncasedShaftTileEntityRenderer extends KineticTileEntityRenderer {
|
public class EncasedShaftTileEntityRenderer extends KineticTileEntityRenderer {
|
||||||
|
|
||||||
|
public EncasedShaftTileEntityRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||||
|
super(dispatcher);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected BlockState getRenderedBlockState(KineticTileEntity te) {
|
protected BlockState getRenderedBlockState(KineticTileEntity te) {
|
||||||
return AllBlocks.SHAFT.get().getDefaultState().with(BlockStateProperties.AXIS,
|
return AllBlocks.SHAFT.get().getDefaultState().with(BlockStateProperties.AXIS,
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.simibubi.create.modules.contraptions.relays.encased;
|
package com.simibubi.create.modules.contraptions.relays.encased;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
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;
|
||||||
|
@ -8,16 +9,23 @@ 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.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.tileentity.TileEntityRendererDispatcher;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.Direction.Axis;
|
import net.minecraft.util.Direction.Axis;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
public class SplitShaftTileEntityRenderer extends KineticTileEntityRenderer {
|
public class SplitShaftTileEntityRenderer extends KineticTileEntityRenderer {
|
||||||
|
|
||||||
|
public SplitShaftTileEntityRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||||
|
super(dispatcher);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderFast(KineticTileEntity te, double x, double y, double z, float partialTicks, int destroyStage,
|
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
||||||
BufferBuilder buffer) {
|
int light, int overlay) {
|
||||||
|
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
|
||||||
Block block = te.getBlockState().getBlock();
|
Block block = te.getBlockState().getBlock();
|
||||||
final Axis boxAxis = ((IRotate) block).getRotationAxis(te.getBlockState());
|
final Axis boxAxis = ((IRotate) block).getRotationAxis(te.getBlockState());
|
||||||
final BlockPos pos = te.getPos();
|
final BlockPos pos = te.getPos();
|
||||||
|
@ -41,9 +49,8 @@ public class SplitShaftTileEntityRenderer extends KineticTileEntityRenderer {
|
||||||
|
|
||||||
SuperByteBuffer superByteBuffer =
|
SuperByteBuffer superByteBuffer =
|
||||||
AllBlockPartials.SHAFT_HALF.renderOnDirectional(te.getBlockState(), direction);
|
AllBlockPartials.SHAFT_HALF.renderOnDirectional(te.getBlockState(), direction);
|
||||||
kineticRotationTransform(superByteBuffer, te, axis, angle, getWorld());
|
kineticRotationTransform(superByteBuffer, te, axis, angle);
|
||||||
superByteBuffer.translate(x, y, z).renderInto(buffer);
|
superByteBuffer.renderInto(ms, buffer.getBuffer(RenderType.getSolid()));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package com.simibubi.create.modules.contraptions.relays.gauge;
|
package com.simibubi.create.modules.contraptions.relays.gauge;
|
||||||
|
|
||||||
|
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.utility.SuperByteBuffer;
|
import com.simibubi.create.foundation.utility.SuperByteBuffer;
|
||||||
|
@ -10,6 +12,8 @@ import com.simibubi.create.modules.contraptions.relays.gauge.GaugeBlock.Type;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.client.renderer.BufferBuilder;
|
import net.minecraft.client.renderer.BufferBuilder;
|
||||||
|
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||||
|
import net.minecraft.client.renderer.RenderType;
|
||||||
import net.minecraft.state.properties.BlockStateProperties;
|
import net.minecraft.state.properties.BlockStateProperties;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.Direction.Axis;
|
import net.minecraft.util.Direction.Axis;
|
||||||
|
@ -24,19 +28,19 @@ public class GaugeTileEntityRenderer extends KineticTileEntityRenderer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderFast(KineticTileEntity te, double x, double y, double z, float partialTicks,
|
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
||||||
int destroyStage, BufferBuilder buffer) {
|
int light, int overlay) {
|
||||||
|
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
|
||||||
BlockState gaugeState = te.getBlockState();
|
BlockState gaugeState = te.getBlockState();
|
||||||
super.renderFast(te, x, y, z, partialTicks, destroyStage, buffer);
|
|
||||||
GaugeTileEntity gaugeTE = (GaugeTileEntity) te;
|
GaugeTileEntity gaugeTE = (GaugeTileEntity) te;
|
||||||
int lightCoords = gaugeState.getPackedLightmapCoords(getWorld(), te.getPos());
|
int lightCoords = gaugeState.getPackedLightmapCoords(te.getWorld(), te.getPos());
|
||||||
|
|
||||||
SuperByteBuffer headBuffer = (type == Type.SPEED ? AllBlockPartials.GAUGE_HEAD_SPEED
|
SuperByteBuffer headBuffer = (type == Type.SPEED ? AllBlockPartials.GAUGE_HEAD_SPEED
|
||||||
: AllBlockPartials.GAUGE_HEAD_STRESS).renderOn(gaugeState);
|
: AllBlockPartials.GAUGE_HEAD_STRESS).renderOn(gaugeState);
|
||||||
SuperByteBuffer dialBuffer = AllBlockPartials.GAUGE_DIAL.renderOn(gaugeState);
|
SuperByteBuffer dialBuffer = AllBlockPartials.GAUGE_DIAL.renderOn(gaugeState);
|
||||||
|
|
||||||
for (Direction facing : Direction.values()) {
|
for (Direction facing : Direction.values()) {
|
||||||
if (!((GaugeBlock) gaugeState.getBlock()).shouldRenderHeadOnFace(getWorld(), te.getPos(), gaugeState,
|
if (!((GaugeBlock) gaugeState.getBlock()).shouldRenderHeadOnFace(te.getWorld(), te.getPos(), gaugeState,
|
||||||
facing))
|
facing))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -45,8 +49,9 @@ public class GaugeTileEntityRenderer extends KineticTileEntityRenderer {
|
||||||
dialBuffer.translate(0, dialPivot, dialPivot).rotate(Axis.X, (float) (Math.PI / 2 * -progress)).translate(0,
|
dialBuffer.translate(0, dialPivot, dialPivot).rotate(Axis.X, (float) (Math.PI / 2 * -progress)).translate(0,
|
||||||
-dialPivot, -dialPivot);
|
-dialPivot, -dialPivot);
|
||||||
|
|
||||||
rotateBufferTowards(dialBuffer, facing).light(lightCoords).translate(x, y, z).renderInto(buffer);
|
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
|
||||||
rotateBufferTowards(headBuffer, facing).light(lightCoords).translate(x, y, z).renderInto(buffer);
|
rotateBufferTowards(dialBuffer, facing).light(lightCoords).renderInto(ms, vb);
|
||||||
|
rotateBufferTowards(headBuffer, facing).light(lightCoords).renderInto(ms, vb);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,15 @@
|
||||||
package com.simibubi.create.modules.contraptions.relays.gearbox;
|
package com.simibubi.create.modules.contraptions.relays.gearbox;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
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.RenderType;
|
||||||
|
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||||
import net.minecraft.state.properties.BlockStateProperties;
|
import net.minecraft.state.properties.BlockStateProperties;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.Direction.Axis;
|
import net.minecraft.util.Direction.Axis;
|
||||||
|
@ -14,9 +17,13 @@ import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
public class GearboxTileEntityRenderer extends KineticTileEntityRenderer {
|
public class GearboxTileEntityRenderer extends KineticTileEntityRenderer {
|
||||||
|
|
||||||
|
public GearboxTileEntityRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||||
|
super(dispatcher);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderFast(KineticTileEntity te, double x, double y, double z, float partialTicks,
|
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
||||||
int destroyStage, BufferBuilder buffer) {
|
int light, int overlay) {
|
||||||
final Axis boxAxis = te.getBlockState().get(BlockStateProperties.AXIS);
|
final Axis boxAxis = te.getBlockState().get(BlockStateProperties.AXIS);
|
||||||
final BlockPos pos = te.getPos();
|
final BlockPos pos = te.getPos();
|
||||||
float time = AnimationTickHolder.getRenderTick();
|
float time = AnimationTickHolder.getRenderTick();
|
||||||
|
@ -42,8 +49,8 @@ public class GearboxTileEntityRenderer extends KineticTileEntityRenderer {
|
||||||
angle += offset;
|
angle += offset;
|
||||||
angle = angle / 180f * (float) Math.PI;
|
angle = angle / 180f * (float) Math.PI;
|
||||||
|
|
||||||
kineticRotationTransform(shaft, te, axis, angle, getWorld());
|
kineticRotationTransform(shaft, te, axis, angle);
|
||||||
shaft.translate(x, y, z).renderInto(buffer);
|
shaft.renderInto(ms, buffer.getBuffer(RenderType.getSolid()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,19 @@
|
||||||
package com.simibubi.create.modules.schematics.client;
|
package com.simibubi.create.modules.schematics.client;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
import org.lwjgl.system.MemoryUtil;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
import com.mojang.datafixers.util.Pair;
|
||||||
import com.simibubi.create.foundation.type.Cuboid;
|
import com.simibubi.create.foundation.type.Cuboid;
|
||||||
import com.simibubi.create.modules.schematics.SchematicWorld;
|
import com.simibubi.create.modules.schematics.SchematicWorld;
|
||||||
|
|
||||||
|
@ -20,13 +25,11 @@ import net.minecraft.client.renderer.ActiveRenderInfo;
|
||||||
import net.minecraft.client.renderer.BlockRendererDispatcher;
|
import net.minecraft.client.renderer.BlockRendererDispatcher;
|
||||||
import net.minecraft.client.renderer.BufferBuilder;
|
import net.minecraft.client.renderer.BufferBuilder;
|
||||||
import net.minecraft.client.renderer.RegionRenderCacheBuilder;
|
import net.minecraft.client.renderer.RegionRenderCacheBuilder;
|
||||||
|
import net.minecraft.client.renderer.RenderType;
|
||||||
|
import net.minecraft.client.renderer.RenderTypeLookup;
|
||||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
|
||||||
import net.minecraft.client.renderer.vertex.VertexFormatElement;
|
|
||||||
import net.minecraft.client.renderer.vertex.VertexFormatElement.Usage;
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.util.BlockRenderLayer;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.world.gen.feature.template.PlacementSettings;
|
import net.minecraft.world.gen.feature.template.PlacementSettings;
|
||||||
|
@ -37,8 +40,8 @@ import net.minecraftforge.client.model.data.EmptyModelData;
|
||||||
public class SchematicHologram {
|
public class SchematicHologram {
|
||||||
|
|
||||||
private final RegionRenderCacheBuilder bufferCache = new RegionRenderCacheBuilder();
|
private final RegionRenderCacheBuilder bufferCache = new RegionRenderCacheBuilder();
|
||||||
private final boolean[] usedBlockRenderLayers = new boolean[BlockRenderLayer.values().length];
|
private final Set<RenderType> usedBlockRenderLayers = new HashSet<>(RenderType.getBlockLayers().size());
|
||||||
private final boolean[] startedBufferBuilders = new boolean[BlockRenderLayer.values().length];
|
private final Set<RenderType> startedBufferBuilders = new HashSet<>(RenderType.getBlockLayers().size());
|
||||||
private boolean active;
|
private boolean active;
|
||||||
private boolean changed;
|
private boolean changed;
|
||||||
private SchematicWorld schematic;
|
private SchematicWorld schematic;
|
||||||
|
@ -85,8 +88,8 @@ public class SchematicHologram {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void redraw(Minecraft minecraft) {
|
private void redraw(Minecraft minecraft) {
|
||||||
Arrays.fill(usedBlockRenderLayers, false);
|
usedBlockRenderLayers.clear();
|
||||||
Arrays.fill(startedBufferBuilders, false);
|
startedBufferBuilders.clear();
|
||||||
|
|
||||||
final SchematicWorld blockAccess = schematic;
|
final SchematicWorld blockAccess = schematic;
|
||||||
final BlockRendererDispatcher blockRendererDispatcher = minecraft.getBlockRendererDispatcher();
|
final BlockRendererDispatcher blockRendererDispatcher = minecraft.getBlockRendererDispatcher();
|
||||||
|
@ -97,15 +100,13 @@ public class SchematicHologram {
|
||||||
blockAccess.getBounds().getOrigin().add(blockAccess.getBounds().getSize()))) {
|
blockAccess.getBounds().getOrigin().add(blockAccess.getBounds().getSize()))) {
|
||||||
BlockPos pos = localPos.add(anchor);
|
BlockPos pos = localPos.add(anchor);
|
||||||
BlockState state = blockAccess.getBlockState(pos);
|
BlockState state = blockAccess.getBlockState(pos);
|
||||||
for (BlockRenderLayer blockRenderLayer : BlockRenderLayer.values()) {
|
for (RenderType blockRenderLayer : RenderType.getBlockLayers()) {
|
||||||
if (!state.getBlock().canRenderInLayer(state, blockRenderLayer)) {
|
if (!RenderTypeLookup.canRenderInLayer(state, blockRenderLayer)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ForgeHooksClient.setRenderLayer(blockRenderLayer);
|
ForgeHooksClient.setRenderLayer(blockRenderLayer);
|
||||||
final int blockRenderLayerId = blockRenderLayer.ordinal();
|
final BufferBuilder bufferBuilder = bufferCache.get(blockRenderLayer);
|
||||||
final BufferBuilder bufferBuilder = bufferCache.getBuilder(blockRenderLayerId);
|
if (startedBufferBuilders.add(blockRenderLayer)) {
|
||||||
if (!startedBufferBuilders[blockRenderLayerId]) {
|
|
||||||
startedBufferBuilders[blockRenderLayerId] = true;
|
|
||||||
// Copied from RenderChunk
|
// Copied from RenderChunk
|
||||||
{
|
{
|
||||||
bufferBuilder.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
|
bufferBuilder.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
|
||||||
|
@ -120,8 +121,9 @@ public class SchematicHologram {
|
||||||
state = Blocks.QUARTZ_SLAB.getDefaultState();
|
state = Blocks.QUARTZ_SLAB.getDefaultState();
|
||||||
}
|
}
|
||||||
|
|
||||||
usedBlockRenderLayers[blockRenderLayerId] |= blockRendererDispatcher.renderBlock(state, pos,
|
if (blockRendererDispatcher.renderModel(state, pos, blockAccess, new MatrixStack(), bufferBuilder, true, minecraft.world.rand, EmptyModelData.INSTANCE)) {
|
||||||
blockAccess, bufferBuilder, minecraft.world.rand, EmptyModelData.INSTANCE);
|
usedBlockRenderLayers.add(blockRenderLayer);
|
||||||
|
}
|
||||||
blockstates.add(state);
|
blockstates.add(state);
|
||||||
// if (Config.isShaders())
|
// if (Config.isShaders())
|
||||||
// SVertexBuilder.popEntity(bufferBuilder);
|
// SVertexBuilder.popEntity(bufferBuilder);
|
||||||
|
@ -130,11 +132,11 @@ public class SchematicHologram {
|
||||||
}
|
}
|
||||||
|
|
||||||
// finishDrawing
|
// finishDrawing
|
||||||
for (int blockRenderLayerId = 0; blockRenderLayerId < usedBlockRenderLayers.length; blockRenderLayerId++) {
|
for (RenderType layer : RenderType.getBlockLayers()) {
|
||||||
if (!startedBufferBuilders[blockRenderLayerId]) {
|
if (!startedBufferBuilders.contains(layer)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
bufferCache.getBuilder(blockRenderLayerId).finishDrawing();
|
bufferCache.get(layer).finishDrawing();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,50 +154,35 @@ public class SchematicHologram {
|
||||||
double renderPosY = view.y;
|
double renderPosY = view.y;
|
||||||
double renderPosZ = view.z;
|
double renderPosZ = view.z;
|
||||||
|
|
||||||
GlStateManager.enableAlphaTest();
|
RenderSystem.enableAlphaTest();
|
||||||
GlStateManager.enableBlend();
|
RenderSystem.enableBlend();
|
||||||
Minecraft.getInstance().getTextureManager().bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
|
Minecraft.getInstance().getTextureManager().bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
|
||||||
|
|
||||||
for (int blockRenderLayerId = 0; blockRenderLayerId < usedBlockRenderLayers.length; blockRenderLayerId++) {
|
for (RenderType layer : RenderType.getBlockLayers()) {
|
||||||
if (!usedBlockRenderLayers[blockRenderLayerId]) {
|
if (!usedBlockRenderLayers.contains(layer)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
final BufferBuilder bufferBuilder = bufferCache.getBuilder(blockRenderLayerId);
|
final BufferBuilder bufferBuilder = bufferCache.get(layer);
|
||||||
GlStateManager.pushMatrix();
|
RenderSystem.pushMatrix();
|
||||||
GlStateManager.translated(-renderPosX, -renderPosY, -renderPosZ);
|
RenderSystem.translated(-renderPosX, -renderPosY, -renderPosZ);
|
||||||
drawBuffer(bufferBuilder);
|
drawBuffer(bufferBuilder);
|
||||||
GlStateManager.popMatrix();
|
RenderSystem.popMatrix();
|
||||||
}
|
}
|
||||||
GlStateManager.disableAlphaTest();
|
RenderSystem.disableAlphaTest();
|
||||||
GlStateManager.disableBlend();
|
RenderSystem.disableBlend();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Coppied from the Tesselator's vboUploader - Draw everything but don't
|
// Coppied from WorldVertexBufferUploader - Draw everything but don't
|
||||||
// reset the buffer
|
// reset the buffer
|
||||||
private static void drawBuffer(final BufferBuilder bufferBuilder) {
|
private static void drawBuffer(final BufferBuilder bufferBuilder) {
|
||||||
if (bufferBuilder.getVertexCount() > 0) {
|
Pair<BufferBuilder.DrawState, ByteBuffer> pair = bufferBuilder.popData();
|
||||||
|
BufferBuilder.DrawState state = pair.getFirst();
|
||||||
|
|
||||||
VertexFormat vertexformat = bufferBuilder.getVertexFormat();
|
if (state.getCount() > 0) {
|
||||||
int size = vertexformat.getSize();
|
state.getVertexFormat().startDrawing(MemoryUtil.memAddress(pair.getSecond()));
|
||||||
ByteBuffer bytebuffer = bufferBuilder.getByteBuffer();
|
GlStateManager.drawArrays(state.getMode(), 0, state.getCount());
|
||||||
List<VertexFormatElement> list = vertexformat.getElements();
|
state.getVertexFormat().endDrawing();
|
||||||
|
|
||||||
for (int index = 0; index < list.size(); ++index) {
|
|
||||||
VertexFormatElement vertexformatelement = list.get(index);
|
|
||||||
Usage usage = vertexformatelement.getUsage();
|
|
||||||
bytebuffer.position(vertexformat.getOffset(index));
|
|
||||||
usage.preDraw(vertexformat, index, size, bytebuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
GlStateManager.drawArrays(bufferBuilder.getDrawMode(), 0, bufferBuilder.getVertexCount());
|
|
||||||
|
|
||||||
for (int index = 0; index < list.size(); ++index) {
|
|
||||||
VertexFormatElement vertexformatelement = list.get(index);
|
|
||||||
Usage usage = vertexformatelement.getUsage();
|
|
||||||
usage.postDraw(vertexformat, index, size, bytebuffer);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue