The rest of the compile errors, a few rendering fixes

This commit is contained in:
tterrag 2020-03-30 01:45:29 -04:00
parent c849bb188e
commit f16e534a89
13 changed files with 133 additions and 46 deletions

View file

@ -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();

View file

@ -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;
}
}
}

View file

@ -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();
}
}

View file

@ -95,7 +95,6 @@ public class ContraptionEntityRenderer extends EntityRenderer<ContraptionEntity>
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);

View file

@ -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;
}

View file

@ -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();
});

View file

@ -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) {

View file

@ -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();
}
}

View file

@ -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();
}
}

View file

@ -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

View file

@ -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();
}

View file

@ -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);

View file

@ -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();
}
}