fixed item physics (kinda) and made the code kinda readable

This commit is contained in:
kone 2023-04-12 16:32:49 -04:00
parent 94b14a7a73
commit 4718aad6e9
4 changed files with 22548 additions and 22535 deletions

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -13,8 +13,10 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
public class RenderItemPhysics {
public static int func_177077_a(EntityItem itemIn, double p_177077_2_, double p_177077_4_, double p_177077_6_, float p_177077_8_, IBakedModel p_177077_9_, int func_177078_a) {
public static int func_177077_a(EntityItem itemIn, double x, double y, double z, float partialTicks, IBakedModel bakedModel, int itemStackNum) {
ItemStack itemstack = itemIn.getEntityItem();
Item item = itemstack.getItem();
Block block = Block.getBlockFromItem(item);
@ -22,26 +24,26 @@ public class RenderItemPhysics {
if (item == null) {
return 0;
} else {
boolean flag = p_177077_9_.isGui3d();
int i = func_177078_a;
boolean flag = bakedModel.isGui3d();
int i = itemStackNum;
if (ModManager.itemPhysics.isEnabled()) {
if (block != null) {
GlStateManager.translate((float) p_177077_2_, (float) p_177077_4_ + 0.15F, (float) p_177077_6_);
GlStateManager.translate((float) x, (float) y + 0.15F, (float) z);
} else {
GlStateManager.translate((float) p_177077_2_, (float) p_177077_4_ + 0.02F, (float) p_177077_6_);
GlStateManager.translate((float) x, (float) y + 0.02F, (float) z);
GlStateManager.rotate(-90F, 1F, 0F, 0F);
}
} else {
float f1 = MathHelper.sin(((float) itemIn.getAge() + p_177077_8_) / 10.0F + itemIn.hoverStart) * 0.1F + 0.1F;
float f2 = p_177077_9_.getItemCameraTransforms().getTransform(ItemCameraTransforms.TransformType.GROUND).scale.y;
float f1 = MathHelper.sin(((float) itemIn.getAge() + partialTicks) / 10.0F + itemIn.hoverStart) * 0.1F + 0.1F;
float f2 = bakedModel.getItemCameraTransforms().getTransform(ItemCameraTransforms.TransformType.GROUND).scale.y;
GlStateManager.translate((float) p_177077_2_, (float) p_177077_4_ + f1 + 0.25F * f2, (float) p_177077_6_);
GlStateManager.translate((float) x, (float) y + f1 + 0.25F * f2, (float) z);
}
if (!ModManager.itemPhysics.isEnabled()) {
if (flag || Minecraft.getMinecraft().getRenderManager().options != null) {
float f3 = (((float) itemIn.getAge() + p_177077_8_) / 20.0F + itemIn.hoverStart) * (180F / (float) Math.PI);
float f3 = (((float) itemIn.getAge() + partialTicks) / 20.0F + itemIn.hoverStart) * (180F / (float) Math.PI);
GlStateManager.rotate(f3, 0.0F, 1.0F, 0.0F);
}
}
@ -55,7 +57,7 @@ public class RenderItemPhysics {
if (ModManager.itemPhysics.isEnabled() && !itemIn.onGround) {
float angle = System.currentTimeMillis() % (360 * 20) / (float) (4.5 - ItemPhysics.speed.getValue() / 2);
GlStateManager.rotate(angle, 1F, 1F, 1F);
GlStateManager.rotate(angle, 1f, 0f, 0f);
}
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);