diff --git a/src/main/java/com/simibubi/create/modules/contraptions/base/KineticTileEntityRenderer.java b/src/main/java/com/simibubi/create/modules/contraptions/base/KineticTileEntityRenderer.java index 48cd00041..b8d091ba5 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/base/KineticTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/base/KineticTileEntityRenderer.java @@ -39,7 +39,7 @@ public class KineticTileEntityRenderer extends SafeTileEntityRenderer if (entity.getContraption() == null) return; + // TODO 1.15 buffered render RenderSystem.pushMatrix(); long randomBits = (long) entity.getEntityId() * 493286711L; randomBits = randomBits * randomBits * 4392167121L + randomBits * 98761L; diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerTileEntityRenderer.java b/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerTileEntityRenderer.java index 221ecf5e1..80e3e0eec 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerTileEntityRenderer.java @@ -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 extends SafeTileEntityRenderer { @@ -18,8 +19,8 @@ public class EngineRenderer 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 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())); } } } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/mixer/MechanicalMixerTileEntityRenderer.java b/src/main/java/com/simibubi/create/modules/contraptions/components/mixer/MechanicalMixerTileEntityRenderer.java index aa000ac90..80bfc4419 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/mixer/MechanicalMixerTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/mixer/MechanicalMixerTileEntityRenderer.java @@ -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(); diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/press/MechanicalPressTileEntityRenderer.java b/src/main/java/com/simibubi/create/modules/contraptions/components/press/MechanicalPressTileEntityRenderer.java index c037e664c..ed432fe50 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/press/MechanicalPressTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/press/MechanicalPressTileEntityRenderer.java @@ -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); diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/saw/SawTileEntityRenderer.java b/src/main/java/com/simibubi/create/modules/contraptions/components/saw/SawTileEntityRenderer.java index 3277908e2..3044aecb6 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/saw/SawTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/saw/SawTileEntityRenderer.java @@ -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 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 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(); } } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/redstone/AnalogLeverTileEntityRenderer.java b/src/main/java/com/simibubi/create/modules/contraptions/redstone/AnalogLeverTileEntityRenderer.java index 4bb4d05f5..639724ef2 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/redstone/AnalogLeverTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/redstone/AnalogLeverTileEntityRenderer.java @@ -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 { @@ -20,30 +23,32 @@ public class AnalogLeverTileEntityRenderer extends SafeTileEntityRenderer