mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 23:28:35 +01:00
fixed special render.
This commit is contained in:
parent
f4f5ee91ad
commit
925590f70d
1 changed files with 40 additions and 45 deletions
|
@ -12,10 +12,9 @@ package de.ellpeck.actuallyadditions.mod.misc.special;
|
||||||
|
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||||
|
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.player.PlayerModelPart;
|
import net.minecraft.entity.player.PlayerModelPart;
|
||||||
|
@ -23,6 +22,7 @@ import net.minecraft.item.BlockItem;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.Util;
|
import net.minecraft.util.Util;
|
||||||
import net.minecraft.util.math.vector.Vector3d;
|
import net.minecraft.util.math.vector.Vector3d;
|
||||||
|
import net.minecraft.util.math.vector.Vector3f;
|
||||||
|
|
||||||
public class RenderSpecial {
|
public class RenderSpecial {
|
||||||
|
|
||||||
|
@ -32,60 +32,55 @@ public class RenderSpecial {
|
||||||
this.theThingToRender = stack;
|
this.theThingToRender = stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void render(MatrixStack matrices, IRenderTypeBuffer buffer, int combinedLight, PlayerEntity player, float partialTicks) {
|
public void render(MatrixStack matrixStack, IRenderTypeBuffer buffer, int combinedLight, PlayerEntity player, float partialTicks) {
|
||||||
if (player.isInvisible() || !player.isModelPartShown(PlayerModelPart.CAPE) || player.isFallFlying()) {
|
if (this.theThingToRender.isEmpty() || player.isInvisible() || !player.isModelPartShown(PlayerModelPart.CAPE) || player.isFallFlying()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GlStateManager._pushMatrix();
|
matrixStack.pushPose();
|
||||||
|
|
||||||
Vector3d currentPos = Minecraft.getInstance().player.getEyePosition(partialTicks);
|
Vector3d currentPos = Minecraft.getInstance().player.getEyePosition(partialTicks);
|
||||||
Vector3d playerPos = player.getEyePosition(partialTicks);
|
Vector3d playerPos = player.getEyePosition(partialTicks);
|
||||||
GlStateManager._translated(playerPos.x - currentPos.x, playerPos.y - currentPos.y, playerPos.z - currentPos.z);
|
matrixStack.translate(playerPos.x - currentPos.x, playerPos.y - currentPos.y, playerPos.z - currentPos.z);
|
||||||
GlStateManager._translated(0D, 2.575D - (player.isShiftKeyDown()
|
matrixStack.translate(0D, 2.575D - (player.isCrouching()
|
||||||
? 0.125D
|
? 0.125D
|
||||||
: 0D), 0D);
|
: 0D), 0D);
|
||||||
|
|
||||||
this.render(matrices, buffer, combinedLight);
|
|
||||||
GlStateManager._popMatrix();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void render(MatrixStack matrices, IRenderTypeBuffer buffer, int combinedLight) {
|
matrixStack.pushPose();
|
||||||
if (StackUtil.isValid(this.theThingToRender)) {
|
|
||||||
boolean isBlock = this.theThingToRender.getItem() instanceof BlockItem;
|
boolean isBlock = this.theThingToRender.getItem() instanceof BlockItem;
|
||||||
|
|
||||||
GlStateManager._pushMatrix();
|
|
||||||
|
|
||||||
if (isBlock) {
|
if (isBlock) {
|
||||||
GlStateManager._translated(0D, -0.1875D, 0D);
|
matrixStack.translate(0D, -0.1875D, 0D);
|
||||||
}
|
}
|
||||||
GlStateManager._rotatef(180F, 1.0F, 0.0F, 1.0F);
|
matrixStack.mulPose(Vector3f.ZP.rotationDegrees(180));
|
||||||
|
|
||||||
float size = isBlock
|
float size = isBlock
|
||||||
? 0.5F
|
? 0.5F
|
||||||
: 0.4F;
|
: 0.4F;
|
||||||
GlStateManager._scalef(size, size, size);
|
matrixStack.scale(size, size, size);
|
||||||
|
|
||||||
//Make the floaty stuff look nice using sine waves \o/ -xdjackiexd
|
//Make the floaty stuff look nice using sine waves \o/ -xdjackiexd
|
||||||
//Peck edit: What do you mean by "nice" you jackass? >_>
|
//Peck edit: What do you mean by "nice" you jackass? >_>
|
||||||
double boop = Util.getMillis() / 1000D;
|
double boop = Util.getMillis() / 1000D;
|
||||||
GlStateManager._translated(0D, Math.sin(boop % (2 * Math.PI)) * 0.25, 0D);
|
matrixStack.translate(0D, Math.sin(boop % (2 * Math.PI)) * 0.25, 0D);
|
||||||
GlStateManager._rotatef((float) (boop * 40D % 360), 0, 1, 0);
|
matrixStack.mulPose(Vector3f.YP.rotationDegrees((float) (boop * 40D % 360)));
|
||||||
|
|
||||||
GlStateManager._disableLighting();
|
GlStateManager._disableLighting();
|
||||||
GlStateManager._pushMatrix();
|
matrixStack.pushPose();
|
||||||
|
|
||||||
if (!isBlock) {
|
if (!isBlock) {
|
||||||
GlStateManager._translated(0D, 0.5D, 0D);
|
matrixStack.translate(0D, 0.5D, 0D);
|
||||||
}
|
}
|
||||||
GlStateManager._rotatef(180F, 1F, 0F, 0F);
|
matrixStack.mulPose(Vector3f.XN.rotationDegrees(180F));
|
||||||
AssetUtil.renderItemInWorld(this.theThingToRender, combinedLight, OverlayTexture.NO_OVERLAY, matrices, buffer);
|
Minecraft.getInstance().getItemRenderer().renderStatic(theThingToRender, ItemCameraTransforms.TransformType.FIXED, combinedLight, OverlayTexture.NO_OVERLAY, matrixStack, buffer);
|
||||||
GlStateManager._popMatrix();
|
matrixStack.popPose();
|
||||||
|
|
||||||
GlStateManager._enableLighting();
|
GlStateManager._enableLighting();
|
||||||
|
|
||||||
GlStateManager._popMatrix();
|
matrixStack.popPose();
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
matrixStack.popPose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue