Port remaining uses of RenderHelper and getCombinedLight

This commit is contained in:
tterrag 2020-03-29 15:18:14 -04:00
parent e1e3220b68
commit c849bb188e
14 changed files with 69 additions and 63 deletions

View file

@ -111,7 +111,7 @@ public class ContraptionEntityRenderer extends EntityRenderer<ContraptionEntity>
RenderSystem.shadeModel(7424);
RenderSystem.alphaFunc(516, 0.1F);
RenderSystem.matrixMode(5888);
RenderHelper.enableStandardItemLighting();
RenderHelper.enable();
super.render(entity, yaw, partialTicks, ms, buffers, overlay);
}

View file

@ -6,9 +6,9 @@ import java.util.function.Consumer;
import org.apache.commons.lang3.tuple.Pair;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL13;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.platform.GLX;
import com.mojang.blaze3d.systems.RenderSystem;
import com.simibubi.create.Create;
import com.simibubi.create.CreateClient;
@ -26,7 +26,9 @@ import net.minecraft.client.renderer.BlockModelRenderer;
import net.minecraft.client.renderer.BlockRendererDispatcher;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.LightTexture;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
@ -72,11 +74,11 @@ public class ContraptionRenderer {
BlockPos pos = tileEntity.getPos();
if (!tileEntity.hasFastRenderer()) {
RenderHelper.enableStandardItemLighting();
int i = lightingWorld.getCombinedLight(pos, 0);
int j = i % 65536;
int k = i / 65536;
RenderSystem.glMultiTexCoord2f(GLX.GL_TEXTURE1, (float) j, (float) k);
RenderHelper.enable();
int i = WorldRenderer.getLightmapCoordinates(lightingWorld, pos);
int j = LightTexture.getBlockLightCoordinates(i);
int k = LightTexture.getSkyLightCoordinates(i);
RenderSystem.glMultiTexCoord2f(GL13.GL_TEXTURE1, (float) j, (float) k);
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
}
@ -188,8 +190,8 @@ public class ContraptionRenderer {
}
@Override
public int getCombinedLight(BlockPos pos, int minLight) {
return super.getCombinedLight(transformPos(pos), minLight);
public int getBaseLightLevel(BlockPos pos, int minLight) {
return super.getBaseLightLevel(transformPos(pos), minLight);
}
private BlockPos transformPos(BlockPos pos) {

View file

@ -68,8 +68,6 @@ public class MechanicalCrafterTileEntityRenderer extends SafeTileEntityRenderer<
}
public void renderItems(MechanicalCrafterTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) {
RenderHelper.enableStandardItemLighting();
if (te.phase == Phase.IDLE) {
ItemStack stack = te.inventory.getStackInSlot(0);
if (!stack.isEmpty()) {
@ -137,8 +135,6 @@ public class MechanicalCrafterTileEntityRenderer extends SafeTileEntityRenderer<
}
}
RenderHelper.disableStandardItemLighting();
}
public void renderFast(MechanicalCrafterTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer) {

View file

@ -214,7 +214,7 @@ public class DeployerHandler {
!(player.isSneaking() && holdingSomething) || (stack.doesSneakBypassUse(world, clickedPos, player));
// Use on block
if (event.getUseBlock() != DENY && flag1 && clickedState.onBlockActivated(world, player, hand, result))
if (event.getUseBlock() != DENY && flag1 && clickedState.onUse(world, player, hand, result) == ActionResultType.SUCCESS)
return;
if (stack.isEmpty())
return;

View file

@ -11,6 +11,7 @@ import net.minecraft.client.particle.IParticleFactory;
import net.minecraft.client.particle.IParticleRenderType;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.particle.SimpleAnimatedParticle;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.particles.BlockParticleData;
import net.minecraft.particles.ParticleTypes;
import net.minecraft.tileentity.TileEntity;
@ -143,7 +144,7 @@ public class AirFlowParticle extends SimpleAnimatedParticle {
public int getBrightnessForRender(float partialTick) {
BlockPos blockpos = new BlockPos(this.posX, this.posY, this.posZ);
return this.world.isBlockPresent(blockpos) ? this.world.getCombinedLight(blockpos, 0) : 0;
return this.world.isBlockPresent(blockpos) ? WorldRenderer.getLightmapCoordinates(world, blockpos) : 0;
}
private void selectSprite(int index) {

View file

@ -149,8 +149,6 @@ public class BeltTileEntityRenderer extends SafeTileEntityRenderer<BeltTileEntit
IndependentShadowRenderer.renderShadow(ms, buffer, shadowPos, .75f, blockItem ? .2f : .2f);
}
RenderHelper.enableStandardItemLighting();
int count = (int) (MathHelper.log2((int) (transported.stack.getCount()))) / 2;
ms.multiply(new Vector3f(slopeAlongX ? 0 : 1, 0, slopeAlongX ? 1 : 0).getDegreesQuaternion(slopeAngle));
if (onSlope)

View file

@ -9,6 +9,7 @@ import com.simibubi.create.foundation.utility.SuperByteBuffer;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.LightTexture;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
@ -58,11 +59,14 @@ public class BeltTunnelTileEntityRenderer extends SafeTileEntityRenderer<BeltTun
if (te.syncedFlaps.containsKey(direction)) {
float lightIntensity = abs * abs * abs;
int indicatorLight = WorldRenderer.getLightmapCoordinates(world, pos);
int indicatorBlockLight = LightTexture.getBlockLightCoordinates(indicatorLight);
int indicatorSkyLight = LightTexture.getSkyLightCoordinates(indicatorLight);
indicatorBlockLight = Math.max(indicatorBlockLight, (int) (12 * lightIntensity));
indicatorLight = LightTexture.pack(indicatorBlockLight, indicatorSkyLight);
int color = ColorHelper.mixColors(0x808080, 0xFFFFFF, lightIntensity);
indicatorBuffer.rotateCentered(Axis.Y, (float) ((horizontalAngle + 90) / 180f * Math.PI))
.color(color)
// TODO 1.15 wtf is this doing?
.light(world.getCombinedLight(pos, (int) (12 * lightIntensity))).renderInto(ms, vb);
.color(color).light(indicatorLight).renderInto(ms, vb);
}
flapBuffer.translate(0, 0, -segment * 3 / 16f);

View file

@ -23,6 +23,7 @@ import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.Vector3f;
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
import net.minecraft.client.renderer.texture.AtlasTexture;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.item.ItemStack;
@ -137,7 +138,7 @@ public class SymmetryWandScreen extends AbstractSimiScreen {
RenderSystem.pushLightingAttributes();
RenderSystem.pushMatrix();
RenderHelper.enableStandardItemLighting();
RenderHelper.enable();
RenderSystem.enableBlend();
RenderSystem.enableRescaleNormal();
RenderSystem.enableAlphaTest();
@ -149,7 +150,8 @@ public class SymmetryWandScreen extends AbstractSimiScreen {
RenderSystem.rotatef(-30, .4f, 0, -.2f);
RenderSystem.rotatef(90 + 0.2f * animationProgress, 0, 1, 0);
RenderSystem.scaled(100, -100, 100);
itemRenderer.renderItem(wand, itemRenderer.getModelWithOverrides(wand));
itemRenderer.renderItem(wand, TransformType.NONE, 0xF000F0, OverlayTexture.DEFAULT_UV, new MatrixStack(),
Minecraft.getInstance().getBufferBuilders().getEntityVertexConsumers());
RenderSystem.disableAlphaTest();
RenderSystem.disableRescaleNormal();

View file

@ -9,6 +9,7 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.client.renderer.Vector3f;
import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer;
@ -30,21 +31,21 @@ public class SandPaperItemRenderer extends ItemStackTileEntityRenderer {
boolean leftHand = perspective == TransformType.FIRST_PERSON_LEFT_HAND;
boolean firstPerson = leftHand || perspective == TransformType.FIRST_PERSON_RIGHT_HAND;
RenderSystem.pushMatrix();
RenderSystem.translatef(.5f, .5f, .5f);
ms.push();
ms.translate(.5f, .5f, .5f);
CompoundNBT tag = stack.getOrCreateTag();
boolean jeiMode = tag.contains("JEI");
if (tag.contains("Polishing")) {
RenderSystem.pushMatrix();
ms.push();
if (perspective == TransformType.GUI) {
RenderSystem.translatef(0.0F, .2f, 1.0F);
RenderSystem.scalef(.75f, .75f, .75f);
ms.translate(0.0F, .2f, 1.0F);
ms.scale(.75f, .75f, .75f);
} else {
int modifier = leftHand ? -1 : 1;
RenderSystem.rotatef(modifier * 40, 0, 1, 0);
ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(modifier * 40));
}
// Reverse bobbing
@ -54,15 +55,15 @@ public class SandPaperItemRenderer extends ItemStackTileEntityRenderer {
float bobbing = -MathHelper.abs(MathHelper.cos(time / 4.0F * (float) Math.PI) * 0.1F);
if (perspective == TransformType.GUI)
RenderSystem.translatef(bobbing, bobbing, 0.0F);
ms.translate(bobbing, bobbing, 0.0F);
else
RenderSystem.translatef(0.0f, bobbing, 0.0F);
ms.translate(0.0f, bobbing, 0.0F);
}
ItemStack toPolish = ItemStack.read(tag.getCompound("Polishing"));
itemRenderer.renderItem(toPolish, itemRenderer.getItemModelWithOverrides(toPolish, Minecraft.getInstance().world, null).getBakedModel());
itemRenderer.renderItem(toPolish, TransformType.NONE, light, overlay, ms, buffer);
RenderSystem.popMatrix();
ms.pop();
}
if (firstPerson) {
@ -76,9 +77,9 @@ public class SandPaperItemRenderer extends ItemStackTileEntityRenderer {
}
}
itemRenderer.renderItem(stack, mainModel.getBakedModel());
itemRenderer.renderItem(stack, TransformType.NONE, false, ms, buffer, light, overlay, mainModel.getBakedModel());
RenderSystem.popMatrix();
ms.pop();
}
public static class SandPaperModel extends CustomRenderedItemModel {

View file

@ -7,6 +7,7 @@ import java.util.function.Supplier;
import org.lwjgl.opengl.GL11;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.systems.RenderSystem;
import com.simibubi.create.AllSoundEvents;
import com.simibubi.create.foundation.utility.TessellatorHelper;
@ -17,6 +18,7 @@ import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.FirstPersonRenderer;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.Vector3f;
import net.minecraft.client.renderer.entity.PlayerRenderer;
import net.minecraft.client.renderer.model.ItemCameraTransforms;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
@ -176,9 +178,11 @@ public class ZapperRenderHandler {
Minecraft mc = Minecraft.getInstance();
boolean rightHand = event.getHand() == Hand.MAIN_HAND ^ mc.player.getPrimaryHand() == HandSide.LEFT;
MatrixStack ms = event.getMatrixStack();
// TODO 1.15 buffered render
RenderSystem.pushMatrix();
ms.push();
float recoil = rightHand ? MathHelper.lerp(event.getPartialTicks(), lastRightHandAnimation, rightHandAnimation)
: MathHelper.lerp(event.getPartialTicks(), lastLeftHandAnimation, leftHandAnimation);
@ -196,47 +200,45 @@ public class ZapperRenderHandler {
float f2 = -0.3F * MathHelper.sin(f1 * (float) Math.PI);
float f3 = 0.4F * MathHelper.sin(f1 * ((float) Math.PI * 2F));
float f4 = -0.4F * MathHelper.sin(event.getSwingProgress() * (float) Math.PI);
RenderSystem.translatef(f * (f2 + 0.64000005F - .1f), f3 + -0.4F + equipProgress * -0.6F,
ms.translate(f * (f2 + 0.64000005F - .1f), f3 + -0.4F + equipProgress * -0.6F,
f4 + -0.71999997F + .3f + recoil);
RenderSystem.rotatef(f * 75.0F, 0.0F, 1.0F, 0.0F);
ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(f * 75.0F));
float f5 = MathHelper.sin(event.getSwingProgress() * event.getSwingProgress() * (float) Math.PI);
float f6 = MathHelper.sin(f1 * (float) Math.PI);
RenderSystem.rotatef(f * f6 * 70.0F, 0.0F, 1.0F, 0.0F);
RenderSystem.rotatef(f * f5 * -20.0F, 0.0F, 0.0F, 1.0F);
ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(f * f6 * 70.0F));
ms.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(f * f5 * -20.0F));
AbstractClientPlayerEntity abstractclientplayerentity = mc.player;
mc.getTextureManager().bindTexture(abstractclientplayerentity.getLocationSkin());
RenderSystem.translatef(f * -1.0F, 3.6F, 3.5F);
RenderSystem.rotatef(f * 120.0F, 0.0F, 0.0F, 1.0F);
RenderSystem.rotatef(200.0F, 1.0F, 0.0F, 0.0F);
RenderSystem.rotatef(f * -135.0F, 0.0F, 1.0F, 0.0F);
RenderSystem.translatef(f * 5.6F, 0.0F, 0.0F);
RenderSystem.rotatef(f * 40.0F, 0.0F, 1.0F, 0.0F);
ms.translate(f * -1.0F, 3.6F, 3.5F);
ms.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(f * 120.0F));
ms.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(200.0F));
ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(f * -135.0F));
ms.translate(f * 5.6F, 0.0F, 0.0F);
ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(f * 40.0F));
PlayerRenderer playerrenderer = (PlayerRenderer) mc.getRenderManager().getRenderer(abstractclientplayerentity);
RenderSystem.disableCull();
if (rightHand) {
playerrenderer.renderRightArm(abstractclientplayerentity);
playerrenderer.renderRightArm(event.getMatrixStack(), event.getBuffers(), event.getLight(), abstractclientplayerentity);
} else {
playerrenderer.renderLeftArm(abstractclientplayerentity);
playerrenderer.renderLeftArm(event.getMatrixStack(), event.getBuffers(), event.getLight(), abstractclientplayerentity);
}
RenderSystem.enableCull();
RenderSystem.popMatrix();
ms.pop();
// Render gun
RenderSystem.pushMatrix();
RenderSystem.translatef(f * (f2 + 0.64000005F - .1f), f3 + -0.4F + equipProgress * -0.6F,
ms.push();
ms.translate(f * (f2 + 0.64000005F - .1f), f3 + -0.4F + equipProgress * -0.6F,
f4 + -0.71999997F - 0.1f + recoil);
RenderSystem.rotatef(f * f6 * 70.0F, 0.0F, 1.0F, 0.0F);
RenderSystem.rotatef(f * f5 * -20.0F, 0.0F, 0.0F, 1.0F);
ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(f * f6 * 70.0F));
ms.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(f * f5 * -20.0F));
RenderSystem.translatef(f * -0.1f, 0.1f, -0.4f);
RenderSystem.rotatef(f * 5.0F, 0.0F, 1.0F, 0.0F);
ms.translate(f * -0.1f, 0.1f, -0.4f);
ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(f * 5.0F));
FirstPersonRenderer firstPersonRenderer = mc.getFirstPersonRenderer();
firstPersonRenderer.renderItemSide(mc.player, heldItem,
firstPersonRenderer.renderItem(mc.player, heldItem,
rightHand ? ItemCameraTransforms.TransformType.FIRST_PERSON_RIGHT_HAND
: ItemCameraTransforms.TransformType.FIRST_PERSON_LEFT_HAND,
!rightHand);
RenderSystem.popMatrix();
!rightHand, event.getMatrixStack(), event.getBuffers(), event.getLight());
ms.pop();
event.setCanceled(true);
}

View file

@ -138,7 +138,7 @@ public class ZapperScreen extends AbstractSimiScreen {
RenderSystem.pushLightingAttributes();
RenderSystem.pushMatrix();
RenderHelper.enableStandardItemLighting();
RenderHelper.enable();
RenderSystem.enableBlend();
RenderSystem.enableRescaleNormal();
RenderSystem.enableAlphaTest();

View file

@ -61,7 +61,7 @@ public abstract class AbstractFilterScreen<F extends AbstractFilterContainer> ex
font.drawString(playerInventory.getDisplayName().getFormattedText(), invX + 7, invY + 6, 0x666666);
font.drawString(I18n.format(container.filterItem.getTranslationKey()), x + 15, y + 9, 0x5B5037);
RenderHelper.enableGUIStandardItemLighting();
RenderHelper.enableGuiDepthLighting();
RenderSystem.pushMatrix();
RenderSystem.translated(guiLeft + background.width + 0, guiTop + background.height - 60, 0);
RenderSystem.scaled(5, 5, 5);

View file

@ -129,7 +129,7 @@ public class SchematicTableScreen extends AbstractSimiContainerScreen<SchematicT
RenderSystem.enableBlend();
RenderSystem.enableRescaleNormal();
RenderSystem.enableAlphaTest();
RenderHelper.enableGUIStandardItemLighting();
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);

View file

@ -238,7 +238,7 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen<Schematica
RenderSystem.enableBlend();
RenderSystem.enableRescaleNormal();
RenderSystem.enableAlphaTest();
RenderHelper.enableGUIStandardItemLighting();
RenderHelper.enableGuiDepthLighting();
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.translated(guiLeft + 240, guiTop + 120, 200);