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