diff --git a/src/main/java/com/simibubi/create/foundation/gui/ScreenElementRenderer.java b/src/main/java/com/simibubi/create/foundation/gui/ScreenElementRenderer.java index 71caa68bb..059fee889 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/ScreenElementRenderer.java +++ b/src/main/java/com/simibubi/create/foundation/gui/ScreenElementRenderer.java @@ -4,9 +4,11 @@ import java.util.function.Supplier; import org.lwjgl.opengl.GL11; +import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.platform.GlStateManager.DestFactor; import com.mojang.blaze3d.platform.GlStateManager.SourceFactor; import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.IVertexBuilder; import com.simibubi.create.foundation.utility.ColorHelper; import net.minecraft.block.BlockState; @@ -14,14 +16,18 @@ import net.minecraft.block.FireBlock; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.BlockRendererDispatcher; import net.minecraft.client.renderer.BufferBuilder; +import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.RenderTypeLookup; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.client.renderer.texture.AtlasTexture; +import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; +import net.minecraftforge.client.model.data.EmptyModelData; public class ScreenElementRenderer { @@ -59,7 +65,7 @@ public class ScreenElementRenderer { RenderSystem.enableBlend(); RenderSystem.enableRescaleNormal(); RenderSystem.enableAlphaTest(); - RenderHelper.enableGuiDepthLighting(); // TODO 1.15 buffered render + RenderHelper.enableGuiDepthLighting(); RenderSystem.alphaFunc(516, 0.1F); RenderSystem.blendFunc(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA); RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); @@ -81,34 +87,36 @@ public class ScreenElementRenderer { } RenderSystem.scaled(50, -50, 50); - mc.getTextureManager().bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE); - + IRenderTypeBuffer.Impl buffer = mc.getBufferBuilders().getEntityVertexConsumers(); + RenderType renderType = RenderTypeLookup.getEntityBlockLayer(blockToRender); + IVertexBuilder vb = buffer.getBuffer(renderType); + MatrixStack ms = new MatrixStack(); RenderSystem.pushMatrix(); if (fire) { - blockRenderer.renderBlockBrightness(blockToRender, 1); + blockRenderer.renderBlock(blockToRender, ms, buffer, 0xF000F0, OverlayTexture.DEFAULT_UV, + EmptyModelData.INSTANCE); } else { RenderSystem.rotatef(90, 0, 1, 0); if (color == -1) { - blockRenderer.getBlockModelRenderer().renderModelBrightnessColor(modelToRender, 1, 1, 1, 1); + blockRenderer.getBlockModelRenderer().renderModel(ms.peek(), vb, blockToRender, modelToRender, 1, 1, 1, + 0xF000F0, OverlayTexture.DEFAULT_UV, EmptyModelData.INSTANCE); } else { Vec3d rgb = ColorHelper.getRGB(color); - blockRenderer.getBlockModelRenderer().renderModelBrightnessColor(modelToRender, 1, (float) rgb.x, - (float) rgb.y, (float) rgb.z); + blockRenderer.getBlockModelRenderer().renderModel(ms.peek(), vb, blockToRender, modelToRender, + (float) rgb.x, (float) rgb.y, (float) rgb.z, 0xF000F0, OverlayTexture.DEFAULT_UV, + EmptyModelData.INSTANCE); } } RenderSystem.popMatrix(); if (stateMode && !blockToRender.getFluidState().isEmpty()) { RenderHelper.disableStandardItemLighting(); - Tessellator tessellator = Tessellator.getInstance(); - BufferBuilder bufferbuilder = tessellator.getBuffer(); - bufferbuilder.setTranslation(0, -300, 0); - bufferbuilder.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); - blockRenderer.renderFluid(new BlockPos(0, 300, 0), mc.world, bufferbuilder, blockToRender.getFluidState()); - Tessellator.getInstance().draw(); - bufferbuilder.setTranslation(0, 0, 0); + RenderSystem.translatef(0, -300, 0); + blockRenderer.renderFluid(new BlockPos(0, 300, 0), mc.world, vb, blockToRender.getFluidState()); } + + buffer.draw(renderType); RenderSystem.disableAlphaTest(); RenderSystem.disableRescaleNormal(); diff --git a/src/main/java/com/simibubi/create/foundation/utility/DirectionHelper.java b/src/main/java/com/simibubi/create/foundation/utility/DirectionHelper.java new file mode 100644 index 000000000..6737e216a --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/utility/DirectionHelper.java @@ -0,0 +1,71 @@ +package com.simibubi.create.foundation.utility; + +import static net.minecraft.util.Direction.*; + +import net.minecraft.util.Direction; + +/** + * A bunch of methods that got stripped out of Direction in 1.15 + * + * @author Mojang + */ +public class DirectionHelper { + + public static Direction rotateAround(Direction dir, Direction.Axis axis) { + switch (axis) { + case X: + if (dir != WEST && dir != EAST) { + return rotateX(dir); + } + + return dir; + case Y: + if (dir != UP && dir != DOWN) { + return dir.rotateY(); + } + + return dir; + case Z: + if (dir != NORTH && dir != SOUTH) { + return rotateZ(dir); + } + + return dir; + default: + throw new IllegalStateException("Unable to get CW facing for axis " + axis); + } + } + + public static Direction rotateX(Direction dir) { + switch (dir) { + case NORTH: + return DOWN; + case EAST: + case WEST: + default: + throw new IllegalStateException("Unable to get X-rotated facing of " + dir); + case SOUTH: + return UP; + case UP: + return NORTH; + case DOWN: + return SOUTH; + } + } + + public static Direction rotateZ(Direction dir) { + switch (dir) { + case EAST: + return DOWN; + case SOUTH: + default: + throw new IllegalStateException("Unable to get Z-rotated facing of " + dir); + case WEST: + return UP; + case UP: + return EAST; + case DOWN: + return WEST; + } + } +} diff --git a/src/main/java/com/simibubi/create/modules/contraptions/WrenchItemRenderer.java b/src/main/java/com/simibubi/create/modules/contraptions/WrenchItemRenderer.java index ec7f535b8..ee4e86e91 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/WrenchItemRenderer.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/WrenchItemRenderer.java @@ -7,6 +7,8 @@ import com.simibubi.create.foundation.utility.AnimationTickHolder; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.ItemRenderer; +import net.minecraft.client.renderer.Vector3f; +import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType; import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer; import net.minecraft.item.ItemStack; @@ -19,21 +21,21 @@ public class WrenchItemRenderer extends ItemStackTileEntityRenderer { WrenchModel mainModel = (WrenchModel) itemRenderer.getItemModelWithOverrides(stack, Minecraft.getInstance().world, Minecraft.getInstance().player); float worldTime = AnimationTickHolder.getRenderTick(); - RenderSystem.pushMatrix(); - RenderSystem.translatef(0.5F, 0.5F, 0.5F); - itemRenderer.renderItem(stack, mainModel.getBakedModel()); // TODO 1.15 what transform type is this? + ms.push(); + ms.translate(0.5F, 0.5F, 0.5F); + itemRenderer.renderItem(stack, TransformType.NONE, false, ms, buffer, light, overlay, mainModel.getBakedModel()); float angle = worldTime * -.5f % 360; float xOffset = -1/32f; float zOffset = 0; - RenderSystem.translatef(-xOffset, 0, -zOffset); - RenderSystem.rotatef(angle, 0, 1, 0); - RenderSystem.translatef(xOffset, 0, zOffset); + ms.translate(-xOffset, 0, -zOffset); + ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(angle)); + ms.translate(xOffset, 0, zOffset); - itemRenderer.renderItem(stack, mainModel.getPartial("gear")); + itemRenderer.renderItem(stack, TransformType.NONE, false, ms, buffer, light, overlay, mainModel.getPartial("gear")); - RenderSystem.popMatrix(); + ms.pop(); } } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/ContraptionEntityRenderer.java b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/ContraptionEntityRenderer.java index 56563e5c1..bb2a0b1fd 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/ContraptionEntityRenderer.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/ContraptionEntityRenderer.java @@ -95,7 +95,6 @@ public class ContraptionEntityRenderer extends EntityRenderer if (!entity.getContraption().customRenderTEs.isEmpty()) { RenderSystem.pushMatrix(); - RenderSystem.translated(x, y, z); RenderSystem.translated(rotationOffset.x, rotationOffset.y, rotationOffset.z); RenderSystem.rotatef(degPitch, 0, 0, 1); RenderSystem.rotatef(degYaw, 0, 1, 0); diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/StructureTransform.java b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/StructureTransform.java index f685d9719..62ee9d279 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/StructureTransform.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/StructureTransform.java @@ -4,6 +4,7 @@ import static net.minecraft.state.properties.BlockStateProperties.AXIS; import static net.minecraft.state.properties.BlockStateProperties.FACING; import com.simibubi.create.AllBlocks; +import com.simibubi.create.foundation.utility.DirectionHelper; import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.modules.contraptions.base.DirectionalAxisKineticBlock; import com.simibubi.create.modules.contraptions.components.contraptions.chassis.AbstractChassisBlock; @@ -171,7 +172,7 @@ public class StructureTransform { protected Direction transformFacing(Direction facing) { for (int i = 0; i < rotation.ordinal(); i++) - facing = facing.rotateAround(rotationAxis); + facing = DirectionHelper.rotateAround(facing, rotationAxis); return facing; } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/crafter/MechanicalCrafterTileEntityRenderer.java b/src/main/java/com/simibubi/create/modules/contraptions/components/crafter/MechanicalCrafterTileEntityRenderer.java index 78818cf45..1484ee573 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/crafter/MechanicalCrafterTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/crafter/MechanicalCrafterTileEntityRenderer.java @@ -108,7 +108,7 @@ public class MechanicalCrafterTileEntityRenderer extends SafeTileEntityRenderer< ms.push(); ms.translate(pair.getKey() * spacing, pair.getValue() * spacing, 0); TessellatorHelper.fightZFighting(pair.hashCode() + te.getPos().hashCode()); - Minecraft.getInstance().getItemRenderer().renderItem(stack, TransformType.FIXED); + Minecraft.getInstance().getItemRenderer().renderItem(stack, TransformType.FIXED, light, overlay, ms, buffer); ms.pop(); }); diff --git a/src/main/java/com/simibubi/create/modules/contraptions/particle/RotationIndicatorParticle.java b/src/main/java/com/simibubi/create/modules/contraptions/particle/RotationIndicatorParticle.java index 4fae3183f..c2b967fa4 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/particle/RotationIndicatorParticle.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/particle/RotationIndicatorParticle.java @@ -1,5 +1,6 @@ package com.simibubi.create.modules.contraptions.particle; +import com.mojang.blaze3d.vertex.IVertexBuilder; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.ColorHelper; import com.simibubi.create.foundation.utility.VecHelper; @@ -58,13 +59,12 @@ public class RotationIndicatorParticle extends SimpleAnimatedParticle { super.tick(); radius += (radius2 - radius) * .1f; } - + @Override - public void renderParticle(BufferBuilder buffer, ActiveRenderInfo entityIn, float partialTicks, float rotationX, - float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) { + public void buildGeometry(IVertexBuilder buffer, ActiveRenderInfo renderInfo, float partialTicks) { if (!isVisible) return; - super.renderParticle(buffer, entityIn, partialTicks, rotationX, rotationZ, rotationYZ, rotationXY, rotationXZ); + super.buildGeometry(buffer, renderInfo, partialTicks); } public void move(double x, double y, double z) { diff --git a/src/main/java/com/simibubi/create/modules/curiosities/deforester/DeforesterItemRenderer.java b/src/main/java/com/simibubi/create/modules/curiosities/deforester/DeforesterItemRenderer.java index 8bf459a7b..04f53da0a 100644 --- a/src/main/java/com/simibubi/create/modules/curiosities/deforester/DeforesterItemRenderer.java +++ b/src/main/java/com/simibubi/create/modules/curiosities/deforester/DeforesterItemRenderer.java @@ -40,7 +40,7 @@ public class DeforesterItemRenderer extends ItemStackTileEntityRenderer { itemRenderer.renderItem(stack, TransformType.NONE, false, ms, buffer, brightLight, overlay, mainModel.getPartial("gear")); - RenderSystem.popMatrix(); + ms.pop(); } } diff --git a/src/main/java/com/simibubi/create/modules/curiosities/symmetry/SymmetryHandler.java b/src/main/java/com/simibubi/create/modules/curiosities/symmetry/SymmetryHandler.java index 6dfec9cc5..9aacfd1b3 100644 --- a/src/main/java/com/simibubi/create/modules/curiosities/symmetry/SymmetryHandler.java +++ b/src/main/java/com/simibubi/create/modules/curiosities/symmetry/SymmetryHandler.java @@ -5,13 +5,18 @@ import java.util.Random; import org.lwjgl.opengl.GL11; import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.systems.RenderSystem; import com.simibubi.create.AllItems; import com.simibubi.create.modules.curiosities.symmetry.mirror.EmptyMirror; import com.simibubi.create.modules.curiosities.symmetry.mirror.SymmetryMirror; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.player.ClientPlayerEntity; +import net.minecraft.client.renderer.ActiveRenderInfo; +import net.minecraft.client.renderer.Atlases; import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.client.renderer.Matrix4f; +import net.minecraft.client.renderer.RenderTypeLookup; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.item.ItemStack; @@ -75,8 +80,6 @@ public class SymmetryHandler { Minecraft mc = Minecraft.getInstance(); ClientPlayerEntity player = mc.player; - GL11.glEnable(GL11.GL_BLEND); - for (int i = 0; i < PlayerInventory.getHotbarSize(); i++) { ItemStack stackInSlot = player.inventory.getStackInSlot(i); if (stackInSlot != null && AllItems.SYMMETRY_WAND.typeOf(stackInSlot) @@ -89,16 +92,22 @@ public class SymmetryHandler { float yShift = 0; double speed = 1 / 16d; - yShift = MathHelper.sin((float) ((tickCounter + event.getPartialTicks()) * speed)) / 5f; + yShift = MathHelper.sin((float) ((tickCounter) * speed)) / 5f; IRenderTypeBuffer buffer = Minecraft.getInstance().getBufferBuilders().getEntityVertexConsumers(); + ActiveRenderInfo info = mc.gameRenderer.getActiveRenderInfo(); + Vec3d view = info.getProjectedView(); MatrixStack ms = event.getMatrixStack(); ms.push(); - ms.translate(0, yShift + .2f, 0); - mc.getBlockRendererDispatcher().renderBlock(mirror.getModel(), pos, player.world, ms, buffer, + ms.translate(-view.getX(), -view.getY(), -view.getZ()); + ms.translate(pos.getX(), pos.getY(), pos.getZ()); +// ms.translate(0, yShift + .2f, 0); + mc.getBlockRendererDispatcher().renderModel(mirror.getModel(), pos, player.world, ms, buffer.getBuffer(Atlases.getEntityTranslucent()), false, player.world.getRandom(), EmptyModelData.INSTANCE); + Minecraft.getInstance().getBufferBuilders().getEntityVertexConsumers().draw(Atlases.getEntityTranslucent()); + ms.pop(); } } diff --git a/src/main/java/com/simibubi/create/modules/curiosities/symmetry/SymmetryWandScreen.java b/src/main/java/com/simibubi/create/modules/curiosities/symmetry/SymmetryWandScreen.java index 52182d1ac..d5344a6c6 100644 --- a/src/main/java/com/simibubi/create/modules/curiosities/symmetry/SymmetryWandScreen.java +++ b/src/main/java/com/simibubi/create/modules/curiosities/symmetry/SymmetryWandScreen.java @@ -171,9 +171,6 @@ public class SymmetryWandScreen extends AbstractSimiScreen { ms.translate(0, -5, 0); minecraft.getBlockRendererDispatcher().renderBlock(currentElement.getModel(), ms, buffer, 0xF000F0, OverlayTexture.DEFAULT_UV, EmptyModelData.INSTANCE); - - Tessellator.getInstance().draw(); - RenderSystem.popMatrix(); } @Override diff --git a/src/main/java/com/simibubi/create/modules/curiosities/zapper/ZapperScreen.java b/src/main/java/com/simibubi/create/modules/curiosities/zapper/ZapperScreen.java index 85a267760..65c8fc41a 100644 --- a/src/main/java/com/simibubi/create/modules/curiosities/zapper/ZapperScreen.java +++ b/src/main/java/com/simibubi/create/modules/curiosities/zapper/ZapperScreen.java @@ -163,8 +163,6 @@ public class ZapperScreen extends AbstractSimiScreen { protected void renderBlock() { RenderSystem.pushMatrix(); - BufferBuilder buffer = Tessellator.getInstance().getBuffer(); - buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); RenderSystem.translated(guiLeft + 1.7f, guiTop - 49, 120); RenderSystem.rotatef(-30f, .5f, .9f, -.1f); RenderSystem.scaled(20, -20, 20); @@ -172,11 +170,13 @@ public class ZapperScreen extends AbstractSimiScreen { BlockState state = Blocks.AIR.getDefaultState(); if (zapper.hasTag() && zapper.getTag().contains("BlockUsed")) state = NBTUtil.readBlockState(zapper.getTag().getCompound("BlockUsed")); + + RenderSystem.translated(0, -5, 0); - minecraft.getBlockRendererDispatcher().renderBlock(state, new BlockPos(0, -5, 0), minecraft.world, buffer, - minecraft.world.rand, EmptyModelData.INSTANCE); + minecraft.getBlockRendererDispatcher().renderBlock(state, new MatrixStack(), + getMinecraft().getBufferBuilders().getEffectVertexConsumers(), 0xF000F0, OverlayTexture.DEFAULT_UV, + EmptyModelData.INSTANCE); - Tessellator.getInstance().draw(); RenderSystem.popMatrix(); } diff --git a/src/main/java/com/simibubi/create/modules/curiosities/zapper/blockzapper/BlockzapperItemRenderer.java b/src/main/java/com/simibubi/create/modules/curiosities/zapper/blockzapper/BlockzapperItemRenderer.java index f9aae6567..123b5a1b1 100644 --- a/src/main/java/com/simibubi/create/modules/curiosities/zapper/blockzapper/BlockzapperItemRenderer.java +++ b/src/main/java/com/simibubi/create/modules/curiosities/zapper/blockzapper/BlockzapperItemRenderer.java @@ -38,7 +38,7 @@ public class BlockzapperItemRenderer extends ZapperItemRenderer { ms.push(); ms.translate(0.5F, 0.5F, 0.5F); - itemRenderer.renderItem(stack, TransformType.NONE, false, ms, buffer, light, overlay, mainModel); + itemRenderer.renderItem(stack, TransformType.NONE, false, ms, buffer, light, overlay, mainModel.getBakedModel()); renderComponent(stack, mainModel, Body, itemRenderer, ms, buffer, light, overlay); renderComponent(stack, mainModel, Amplifier, itemRenderer, ms, buffer, light, overlay); renderComponent(stack, mainModel, Retriever, itemRenderer, ms, buffer, light, overlay); diff --git a/src/main/java/com/simibubi/create/modules/curiosities/zapper/terrainzapper/TerrainzapperItemRenderer.java b/src/main/java/com/simibubi/create/modules/curiosities/zapper/terrainzapper/TerrainzapperItemRenderer.java index dd59ddd4b..422af2458 100644 --- a/src/main/java/com/simibubi/create/modules/curiosities/zapper/terrainzapper/TerrainzapperItemRenderer.java +++ b/src/main/java/com/simibubi/create/modules/curiosities/zapper/terrainzapper/TerrainzapperItemRenderer.java @@ -72,7 +72,7 @@ public class TerrainzapperItemRenderer extends ZapperItemRenderer { itemRenderer.renderItem(stack, TransformType.NONE, false, ms, buffer, light, overlay, mainModel.getPartial("terrain_accelerator")); - RenderSystem.popMatrix(); + ms.pop(); } }