From 21ed3ffc55745a1eaaf712f207edb26d8e5e00a9 Mon Sep 17 00:00:00 2001 From: Sollace Date: Sat, 28 Jul 2018 14:02:49 +0200 Subject: [PATCH] Added jumping and sneaking when previewing a skin --- .../voxelmodpack/hdskins/gui/DummyWorld.java | 7 ++++++ .../hdskins/gui/EntityPlayerModel.java | 22 +++++++++++++++++++ .../voxelmodpack/hdskins/gui/GuiSkins.java | 12 +++++++++- .../hdskins/gui/RenderPlayerModel.java | 2 +- 4 files changed, 41 insertions(+), 2 deletions(-) diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/gui/DummyWorld.java b/src/hdskins/java/com/voxelmodpack/hdskins/gui/DummyWorld.java index b51ae3e9..8a9a7153 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/gui/DummyWorld.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/gui/DummyWorld.java @@ -1,5 +1,7 @@ package com.voxelmodpack.hdskins.gui; +import net.minecraft.block.state.IBlockState; +import net.minecraft.init.Blocks; import net.minecraft.util.math.BlockPos; import net.minecraft.world.GameType; import net.minecraft.world.World; @@ -27,6 +29,11 @@ public class DummyWorld extends World { return true; } + @Override + public IBlockState getBlockState(BlockPos pos) { + return Blocks.AIR.getDefaultState(); + } + @Override public float getLightBrightness(BlockPos pos) { return 1; diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/gui/EntityPlayerModel.java b/src/hdskins/java/com/voxelmodpack/hdskins/gui/EntityPlayerModel.java index 5ad575b3..a86af574 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/gui/EntityPlayerModel.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/gui/EntityPlayerModel.java @@ -110,6 +110,28 @@ public class EntityPlayerModel extends EntityLivingBase implements IBlankSkinSup } swingProgress = swingProgressInt / 8F; + + motionY *= 0.98; + if (Math.abs(motionY) < 0.003) { + motionY = 0; + } + + if (posY == 0 && isJumping) { + jump(); + } + + + motionY -= 0.08D; + motionY *= 0.9800000190734863D; + + posY += motionY; + + if (posY < 0) { + posY = 0; + } + onGround = posY == 0; + + ticksExisted++; } @Override diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/gui/GuiSkins.java b/src/hdskins/java/com/voxelmodpack/hdskins/gui/GuiSkins.java index 5e1c45eb..f1d981f1 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/gui/GuiSkins.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/gui/GuiSkins.java @@ -11,7 +11,6 @@ import com.minelittlepony.gui.Button; import com.minelittlepony.gui.GameGui; import com.minelittlepony.gui.IconicButton; import com.minelittlepony.gui.Label; -import com.minelittlepony.util.math.MathUtil; import com.mojang.authlib.GameProfile; import com.mojang.authlib.minecraft.MinecraftProfileTexture; import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type; @@ -394,6 +393,17 @@ public class GuiSkins extends GameGui { @Override protected void drawContents(int mouseX, int mouseY, float partialTick) { + + + boolean sneak = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT); + + localPlayer.setSneaking(sneak); + remotePlayer.setSneaking(sneak); + + boolean jump = Keyboard.isKeyDown(Keyboard.KEY_SPACE); + localPlayer.setJumping(jump); + remotePlayer.setJumping(jump); + float deltaTime = panorama.getDelta(partialTick); panorama.render(partialTick, zLevel); diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/gui/RenderPlayerModel.java b/src/hdskins/java/com/voxelmodpack/hdskins/gui/RenderPlayerModel.java index c7754d91..acaa8c4d 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/gui/RenderPlayerModel.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/gui/RenderPlayerModel.java @@ -108,7 +108,7 @@ public class RenderPlayerModel extends RenderLiving GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); - double offset = entity.getYOffset() + 0.01; + double offset = entity.getYOffset() + entity.posY + 0.01; pushMatrix(); enableBlend();