Skip to content

Commit

Permalink
also 3r1
Browse files Browse the repository at this point in the history
  • Loading branch information
jrbudda committed Aug 16, 2020
1 parent f32f493 commit 60453ca
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 76 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--- a/net/minecraft/client/renderer/FirstPersonRenderer.java
+++ b/net/minecraft/client/renderer/FirstPersonRenderer.java
@@ -2,25 +2,75 @@
@@ -2,25 +2,77 @@

import com.google.common.base.MoreObjects;
import com.mojang.blaze3d.matrix.MatrixStack;
Expand All @@ -13,8 +13,10 @@
import java.util.Objects;
+import java.util.stream.Stream;
+
+import javax.annotation.Nullable;
+import javax.management.relation.RelationServiceNotRegisteredException;
+
+import org.apache.commons.lang3.tuple.Triple;
+import org.lwjgl.opengl.GL11;
+import org.vivecraft.control.ControllerType;
+import org.vivecraft.gameplay.trackers.BowTracker;
Expand Down Expand Up @@ -76,7 +78,7 @@
import net.minecraft.util.math.vector.Vector3f;
import net.minecraft.world.storage.MapData;
import net.optifine.Config;
@@ -30,8 +80,8 @@
@@ -30,8 +82,8 @@

public class FirstPersonRenderer
{
Expand All @@ -87,7 +89,7 @@
private final Minecraft mc;
private ItemStack itemStackMainHand = ItemStack.EMPTY;
private ItemStack itemStackOffHand = ItemStack.EMPTY;
@@ -41,12 +91,22 @@
@@ -41,12 +93,22 @@
private float prevEquippedProgressOffHand;
private final EntityRendererManager renderManager;
private final ItemRenderer itemRenderer;
Expand All @@ -111,39 +113,39 @@
}

public void renderItemSide(LivingEntity livingEntityIn, ItemStack itemStackIn, ItemCameraTransforms.TransformType transformTypeIn, boolean leftHand, MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int combinedLightIn)
@@ -68,6 +128,7 @@
@@ -68,6 +130,7 @@
return -MathHelper.cos(f * (float)Math.PI) * 0.5F + 0.5F;
}

+ //unused
private void renderArm(MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int combinedLightIn, HandSide side)
{
this.mc.getTextureManager().bindTexture(this.mc.player.getLocationSkin());
@@ -91,6 +152,7 @@
@@ -91,6 +154,7 @@
matrixStackIn.pop();
}

+ //unused
private void renderMapFirstPersonSide(MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int combinedLightIn, float equippedProgress, HandSide handIn, float swingProgress, ItemStack stack)
{
float f = handIn == HandSide.RIGHT ? 1.0F : -1.0F;
@@ -118,6 +180,7 @@
@@ -118,6 +182,7 @@
matrixStackIn.pop();
}

+ //unused
private void renderMapFirstPerson(MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int combinedLightIn, float pitch, float equippedProgress, float swingProgress)
{
float f = MathHelper.sqrt(swingProgress);
@@ -143,6 +206,7 @@
@@ -143,6 +208,7 @@
this.renderMapFirstPerson(matrixStackIn, bufferIn, combinedLightIn, this.itemStackMainHand);
}

+ //actually used.
private void renderMapFirstPerson(MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int combinedLightIn, ItemStack stack)
{
matrixStackIn.rotate(Vector3f.YP.rotationDegrees(180.0F));
@@ -168,24 +232,38 @@
@@ -168,24 +234,38 @@
{
boolean flag = side != HandSide.LEFT;
float f = flag ? 1.0F : -1.0F;
Expand Down Expand Up @@ -198,7 +200,7 @@

if (flag)
{
@@ -195,6 +273,8 @@
@@ -195,6 +275,8 @@
{
playerrenderer.renderLeftArm(matrixStackIn, bufferIn, combinedLightIn, abstractclientplayerentity);
}
Expand All @@ -207,15 +209,15 @@
}

private void transformEatFirstPerson(MatrixStack matrixStackIn, float partialTicks, HandSide handIn, ItemStack stack)
@@ -216,6 +296,7 @@
@@ -216,6 +298,7 @@
matrixStackIn.rotate(Vector3f.ZP.rotationDegrees((float)i * f3 * 30.0F));
}

+ //unused
private void transformFirstPerson(MatrixStack matrixStackIn, HandSide handIn, float swingProgress)
{
int i = handIn == HandSide.RIGHT ? 1 : -1;
@@ -226,6 +307,44 @@
@@ -226,6 +309,44 @@
matrixStackIn.rotate(Vector3f.XP.rotationDegrees(f1 * -80.0F));
matrixStackIn.rotate(Vector3f.YP.rotationDegrees((float)i * -45.0F));
}
Expand Down Expand Up @@ -260,15 +262,15 @@

private void transformSideFirstPerson(MatrixStack matrixStackIn, HandSide handIn, float equippedProg)
{
@@ -233,6 +352,7 @@
@@ -233,6 +354,7 @@
matrixStackIn.translate((double)((float)i * 0.56F), (double)(-0.52F + equippedProg * -0.6F), (double) - 0.72F);
}

+ //Vivecraft unused
public void renderItemInFirstPerson(float partialTicks, MatrixStack matrixStackIn, IRenderTypeBuffer.Impl bufferIn, ClientPlayerEntity playerEntityIn, int combinedLightIn)
{
float f = playerEntityIn.getSwingProgress(partialTicks);
@@ -310,186 +430,421 @@
@@ -310,186 +432,421 @@
bufferIn.finish();
}

Expand Down Expand Up @@ -869,7 +871,7 @@
}

public void tick()
@@ -571,4 +926,120 @@
@@ -571,4 +928,121 @@
this.equippedProgressOffHand = 0.0F;
}
}
Expand All @@ -892,21 +894,22 @@
+ return false;
+ }
+
+ public float isNearOpaqueBlock(Vector3d in, double dist)
+ @Nullable
+ public Triple<Float, BlockState, BlockPos> getNearOpaqueBlock(Vector3d in, double dist)
+ {
+ if (mc.world == null) return 0;
+ if (mc.world == null) return null;
+
+
+ AxisAlignedBB eye = new AxisAlignedBB(in.subtract(dist, dist, dist), in.add(dist, dist, dist));
+
+ Stream<BlockPos> list = BlockPos.getAllInBox(eye).filter((bp)-> {
+ return mc.world.getBlockState(bp).isOpaqueCube(mc.world, bp);
+ return mc.world.getBlockState(bp).causesSuffocation(mc.world, bp);
+ });
+
+ if (list.count() > 0)
+ return 1;
+ if (list.findFirst().isPresent())
+ return Triple.of(1f, mc.world.getBlockState(list.findFirst().get()), list.findFirst().get());
+
+ return 0;
+ return null;
+
+// BlockPos bp = new BlockPos(in);
+//
Expand Down
53 changes: 29 additions & 24 deletions patches/net/minecraft/client/renderer/GameRenderer.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.Style;
import net.minecraft.util.text.event.ClickEvent;
@@ -67,15 +96,40 @@
@@ -67,15 +96,41 @@
import net.optifine.GlErrors;
import net.optifine.Lagometer;
import net.optifine.RandomEntities;
Expand All @@ -93,6 +93,7 @@
import net.optifine.shaders.ShadersRender;
import net.optifine.util.MemoryMonitor;
import net.optifine.util.TimedEvent;
+import org.apache.commons.lang3.tuple.Triple;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import org.lwjgl.BufferUtils;
Expand Down Expand Up @@ -120,7 +121,7 @@

public class GameRenderer implements IResourceManagerReloadListener, AutoCloseable
{
@@ -113,10 +167,12 @@
@@ -113,10 +168,12 @@
public static final int SHADER_COUNT = SHADERS_TEXTURES.length;
private int shaderIndex = SHADER_COUNT;
private boolean useShader;
Expand All @@ -135,7 +136,7 @@
private long lastServerTime = 0L;
private int lastServerTicks = 0;
private int serverWaitTime = 0;
@@ -125,6 +181,39 @@
@@ -125,6 +182,39 @@
private float avgServerTickDiff = 0.0F;
private ShaderGroup[] fxaaShaders = new ShaderGroup[10];
private boolean guiLoadingVisible = false;
Expand Down Expand Up @@ -175,7 +176,7 @@

public GameRenderer(Minecraft p_i176_1_, IResourceManager p_i176_2_, RenderTypeBuffers p_i176_3_)
{
@@ -135,6 +224,12 @@
@@ -135,6 +225,12 @@
this.lightmapTexture = new LightTexture(this, p_i176_1_);
this.renderTypeBuffers = p_i176_3_;
this.shaderGroup = null;
Expand All @@ -188,7 +189,7 @@
}

public void close()
@@ -198,7 +293,7 @@
@@ -198,7 +294,7 @@
}

try
Expand All @@ -197,7 +198,7 @@
this.shaderGroup = new ShaderGroup(this.mc.getTextureManager(), this.resourceManager, this.mc.getFramebuffer(), resourceLocationIn);
this.shaderGroup.createBindFramebuffers(this.mc.getMainWindow().getFramebufferWidth(), this.mc.getMainWindow().getFramebufferHeight());
this.useShader = true;
@@ -298,13 +393,18 @@
@@ -298,13 +394,18 @@
{
Entity entity = this.mc.getRenderViewEntity();

Expand All @@ -219,7 +220,7 @@
boolean flag = false;
int i = 3;
double d1 = d0;
@@ -330,8 +430,9 @@
@@ -330,8 +431,9 @@
{
d1 = this.mc.objectMouseOver.getHitVec().squareDistanceTo(vector3d);
}
Expand All @@ -231,7 +232,7 @@
Vector3d vector3d2 = vector3d.add(vector3d1.x * d0, vector3d1.y * d0, vector3d1.z * d0);
float f = 1.0F;
AxisAlignedBB axisalignedbb = entity.getBoundingBox().expand(vector3d1.scale(d0)).grow(1.0D, 1.0D, 1.0D);
@@ -391,6 +492,10 @@
@@ -391,6 +493,10 @@

private double getFOVModifier(ActiveRenderInfo activeRenderInfoIn, float partialTicks, boolean useFOVSetting)
{
Expand All @@ -242,7 +243,7 @@
if (this.debugView)
{
return 90.0D;
@@ -495,7 +600,9 @@
@@ -495,7 +601,9 @@
matrixStackIn.rotate(Vector3f.XP.rotationDegrees(Math.abs(MathHelper.cos(f1 * (float)Math.PI - 0.2F) * f2) * 5.0F));
}
}
Expand All @@ -252,7 +253,7 @@
private void renderHand(MatrixStack matrixStackIn, ActiveRenderInfo activeRenderInfoIn, float partialTicks)
{
this.renderHand(matrixStackIn, activeRenderInfoIn, partialTicks, true, true, false);
@@ -590,13 +697,32 @@
@@ -590,13 +698,32 @@
this.clipDistance = 173.0F;
}

Expand Down Expand Up @@ -292,7 +293,7 @@
return matrixstack.getLast().getMatrix();
}

@@ -608,10 +734,12 @@
@@ -608,10 +735,12 @@

public void updateCameraAndRender(float partialTicks, long nanoTime, boolean renderWorldIn)
{
Expand All @@ -307,7 +308,7 @@
if (Util.milliTime() - this.prevFrameTime > 500L)
{
this.mc.displayInGameMenu(false);
@@ -621,16 +749,23 @@
@@ -621,16 +750,23 @@
{
this.prevFrameTime = Util.milliTime();
}
Expand All @@ -333,7 +334,7 @@

if (this.mc.isSingleplayer() && this.timeWorldIcon < Util.milliTime() - 1000L)
{
@@ -642,9 +777,10 @@
@@ -642,9 +778,10 @@
}
}

Expand All @@ -345,7 +346,7 @@
{
RenderSystem.disableBlend();
RenderSystem.disableDepthTest();
@@ -660,130 +796,35 @@
@@ -660,130 +797,35 @@

this.mc.getFramebuffer().bindFramebuffer(true);
}
Expand Down Expand Up @@ -497,7 +498,7 @@
}
}

@@ -827,7 +868,10 @@
@@ -827,7 +869,10 @@

private boolean isDrawBlockOutline()
{
Expand All @@ -509,7 +510,7 @@
{
return false;
}
@@ -862,17 +906,36 @@
@@ -862,17 +907,36 @@
}
}

Expand Down Expand Up @@ -551,7 +552,7 @@
if (Config.isShaders())
{
Shaders.beginRender(this.mc, this.activeRender, partialTicks, finishTimeNano);
@@ -885,36 +948,17 @@
@@ -885,36 +949,17 @@
{
Shaders.beginRenderPass(partialTicks, finishTimeNano);
}
Expand Down Expand Up @@ -593,7 +594,7 @@
}

float f = MathHelper.lerp(partialTicks, this.mc.player.prevTimeInPortal, this.mc.player.timeInPortal);
@@ -930,69 +974,51 @@
@@ -930,69 +975,51 @@

float f1 = 5.0F / (f * f + 5.0F) - f * 0.04F;
f1 = f1 * f1;
Expand Down Expand Up @@ -686,7 +687,7 @@
this.mc.getProfiler().endSection();
}

@@ -1104,8 +1130,6 @@
@@ -1104,8 +1131,6 @@

if (!this.initialized)
{
Expand All @@ -695,7 +696,7 @@
if (Config.getBitsOs() == 64 && Config.getBitsJre() == 32)
{
Config.setNotify64BitJava(true);
@@ -1274,25 +1298,30 @@
@@ -1274,25 +1299,30 @@
float f6 = this.itemActivationOffY * (float)(heightScaled / 4);
RenderSystem.enableAlphaTest();
RenderSystem.pushMatrix();
Expand Down Expand Up @@ -742,7 +743,7 @@
}
}

@@ -1320,4 +1349,2194 @@
@@ -1320,4 +1350,2198 @@
{
return this.overlayTexture;
}
Expand Down Expand Up @@ -2163,9 +2164,13 @@
+ if (!this.mc.player.isSpectator() && !isInMenuRoom() && mc.player.isAlive())
+ {
+ Vector3d pos = mc.vrPlayer.vrdata_world_render.getEye(mc.currentPass).getPosition();
+ inBlock = itemRenderer.isNearOpaqueBlock(pos, minClipDistance);
+ inwater = this.mc.player.areEyesInFluid(FluidTags.WATER) && !Reflector.callBoolean(Reflector.ForgeEventFactory_renderWaterOverlay, this.mc.player, partialTicks);
+ onfire = mc.currentPass != RenderPass.THIRD && this.mc.player.isBurning() && !Reflector.callBoolean(Reflector.ForgeEventFactory_renderFireOverlay, this.mc.player, partialTicks);
+ Triple<Float, BlockState, BlockPos> triple = itemRenderer.getNearOpaqueBlock(pos, minClipDistance);
+ if (triple != null && !Reflector.callBoolean(Reflector.ForgeEventFactory_renderBlockOverlay, this.mc.player, new MatrixStack(), Reflector.getFieldValue(Reflector.RenderBlockOverlayEvent_OverlayType_BLOCK), triple.getMiddle(), triple.getRight()))
+ inBlock = triple.getLeft();
+ else
+ inBlock = 0;
+ inwater = this.mc.player.areEyesInFluid(FluidTags.WATER) && !Reflector.callBoolean(Reflector.ForgeEventFactory_renderWaterOverlay, this.mc.player, new MatrixStack());
+ onfire = mc.currentPass != RenderPass.THIRD && this.mc.player.isBurning() && !Reflector.callBoolean(Reflector.ForgeEventFactory_renderFireOverlay, this.mc.player, new MatrixStack());
+ }
+ }
+
Expand Down
Loading

0 comments on commit 60453ca

Please sign in to comment.