<commit_before>package team.creative.itemphysic.client;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.systems.RenderSystem;

import net.minecraft.block.Blocks;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.Vector3f;
import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.client.renderer.model.ItemCameraTransforms;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.client.util.InputMappings;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.ProjectileHelper;
import net.minecraft.fluid.Fluid;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.network.play.client.CPlayerDiggingPacket;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.EntityRayTraceResult;
import net.minecraft.util.math.RayTraceContext;
import net.minecraft.util.math.RayTraceContext.BlockMode;
import net.minecraft.util.math.RayTraceContext.FluidMode;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.RayTraceResult.Type;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.TickEvent.ClientTickEvent;
import net.minecraftforge.event.TickEvent.Phase;
import net.minecraftforge.event.TickEvent.RenderTickEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent.EntityInteract;
import net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock;
import net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickEmpty;
import net.minecraftforge.eventbus.api.Event.Result;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import team.creative.itemphysic.ItemPhysic;
import team.creative.itemphysic.common.CommonPhysic;
import team.creative.itemphysic.common.packet.DropPacket;
import team.creative.itemphysic.common.packet.PickupPacket;

@OnlyIn(value = Dist.CLIENT)
public class ItemPhysicClient {
	
	public static KeyBinding pickup = new KeyBinding("key.pickup.item", InputMappings.INPUT_INVALID.getKeyCode(), "key.categories.gameplay");
	public static Minecraft mc;
	
	public static void init(FMLClientSetupEvent event) {
		ClientRegistry.registerKeyBinding(pickup);
		mc = event.getMinecraftSupplier().get();
		
		MinecraftForge.EVENT_BUS.register(ItemPhysicClient.class);
	}
	
	public static long lastTickTime;
	
	@SubscribeEvent
	@OnlyIn(value = Dist.CLIENT)
	public static void renderTick(RenderTickEvent event) {
		if (event.phase == Phase.END)
			lastTickTime = System.nanoTime();
		
		renderTickFull();
	}
	
	public static boolean renderItem(ItemEntity entityIn, float entityYaw, float partialTicks, MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int packedLightIn, net.minecraft.client.renderer.ItemRenderer itemRenderer, Random random) {
		if (entityIn.getAge() == 0)
			return false;
		
		matrixStackIn.push();
		ItemStack itemstack = entityIn.getItem();
		int i = itemstack.isEmpty() ? 187 : Item.getIdFromItem(itemstack.getItem()) + itemstack.getDamage();
		random.setSeed(i);
		IBakedModel ibakedmodel = itemRenderer.getItemModelWithOverrides(itemstack, entityIn.world, (LivingEntity) null);
		boolean flag = ibakedmodel.isGui3d();
		int j = getModelCount(itemstack);
		
		float rotateBy = (System.nanoTime() - lastTickTime) / 200000000F;
		if (mc.isGamePaused())
			rotateBy = 0;
		
		matrixStackIn.rotate(Vector3f.XP.rotation((float) Math.PI / 2));
		matrixStackIn.rotate(Vector3f.ZP.rotation(entityIn.rotationYaw));
		
		boolean applyEffects = entityIn.getAge() != 0 && (flag || mc.getRenderManager().options != null);
		
		//Handle Rotations
		if (applyEffects) {
			if (flag) {
				if (!entityIn.onGround) {
					rotateBy *= 2;
					Fluid fluid = CommonPhysic.getFluid(entityIn);
					if (fluid == null)
						fluid = CommonPhysic.getFluid(entityIn, true);
					if (fluid != null)
						rotateBy /= fluid.getAttributes().getDensity() / 1000 * 10;
					
					entityIn.rotationPitch += rotateBy;
				}
			} else if (entityIn != null && !Double.isNaN(entityIn.getPosX()) && !Double.isNaN(entityIn.getPosY()) && !Double.isNaN(entityIn.getPosZ()) && entityIn.world != null) {
				if (entityIn.onGround) {
					if (!flag)
						entityIn.rotationPitch = 0;
				} else {
					rotateBy *= 2;
					Fluid fluid = CommonPhysic.getFluid(entityIn);
					if (fluid != null)
						rotateBy /= fluid.getAttributes().getDensity() / 1000 * 10;
					
					entityIn.rotationPitch += rotateBy;
				}
			}
			
			if (flag)
				matrixStackIn.translate(0, -0.2, -0.08);
			else if (entityIn.world.getBlockState(entityIn.getPosition()).getBlock() == Blocks.SNOW)
				matrixStackIn.translate(0, 0.0, -0.14);
			else
				matrixStackIn.translate(0, 0, -0.04);
			
			double height = 0.2;
			if (flag)
				matrixStackIn.translate(0, height, 0);
			matrixStackIn.rotate(Vector3f.YP.rotation(entityIn.rotationPitch));
			if (flag)
				matrixStackIn.translate(0, -height, 0);
		}
		
		if (!flag) {
			float f7 = -0.0F * (j - 1) * 0.5F;
			float f8 = -0.0F * (j - 1) * 0.5F;
			float f9 = -0.09375F * (j - 1) * 0.5F;
			matrixStackIn.translate(f7, f8, f9);
		}
		
		for (int k = 0; k < j; ++k) {
			matrixStackIn.push();
			if (k > 0) {
				if (flag) {
					float f11 = (random.nextFloat() * 2.0F - 1.0F) * 0.15F;
					float f13 = (random.nextFloat() * 2.0F - 1.0F) * 0.15F;
					float f10 = (random.nextFloat() * 2.0F - 1.0F) * 0.15F;
					matrixStackIn.translate(f11, f13, f10);
				}
			}
			<commit_msg>Fixed items not being visible on soul sand<commit_after>package team.creative.itemphysic.client;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.systems.RenderSystem;

import net.minecraft.block.Blocks;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.Vector3f;
import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.client.renderer.model.ItemCameraTransforms;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.client.util.InputMappings;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.ProjectileHelper;
import net.minecraft.fluid.Fluid;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.network.play.client.CPlayerDiggingPacket;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.EntityRayTraceResult;
import net.minecraft.util.math.RayTraceContext;
import net.minecraft.util.math.RayTraceContext.BlockMode;
import net.minecraft.util.math.RayTraceContext.FluidMode;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.RayTraceResult.Type;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.TickEvent.ClientTickEvent;
import net.minecraftforge.event.TickEvent.Phase;
import net.minecraftforge.event.TickEvent.RenderTickEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent.EntityInteract;
import net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock;
import net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickEmpty;
import net.minecraftforge.eventbus.api.Event.Result;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import team.creative.itemphysic.ItemPhysic;
import team.creative.itemphysic.common.CommonPhysic;
import team.creative.itemphysic.common.packet.DropPacket;
import team.creative.itemphysic.common.packet.PickupPacket;

@OnlyIn(value = Dist.CLIENT)
public class ItemPhysicClient {
	
	public static KeyBinding pickup = new KeyBinding("key.pickup.item", InputMappings.INPUT_INVALID.getKeyCode(), "key.categories.gameplay");
	public static Minecraft mc;
	
	public static void init(FMLClientSetupEvent event) {
		ClientRegistry.registerKeyBinding(pickup);
		mc = event.getMinecraftSupplier().get();
		
		MinecraftForge.EVENT_BUS.register(ItemPhysicClient.class);
	}
	
	public static long lastTickTime;
	
	@SubscribeEvent
	@OnlyIn(value = Dist.CLIENT)
	public static void renderTick(RenderTickEvent event) {
		if (event.phase == Phase.END)
			lastTickTime = System.nanoTime();
		
		renderTickFull();
	}
	
	public static boolean renderItem(ItemEntity entityIn, float entityYaw, float partialTicks, MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int packedLightIn, net.minecraft.client.renderer.ItemRenderer itemRenderer, Random random) {
		if (entityIn.getAge() == 0)
			return false;
		
		matrixStackIn.push();
		ItemStack itemstack = entityIn.getItem();
		int i = itemstack.isEmpty() ? 187 : Item.getIdFromItem(itemstack.getItem()) + itemstack.getDamage();
		random.setSeed(i);
		IBakedModel ibakedmodel = itemRenderer.getItemModelWithOverrides(itemstack, entityIn.world, (LivingEntity) null);
		boolean flag = ibakedmodel.isGui3d();
		int j = getModelCount(itemstack);
		
		float rotateBy = (System.nanoTime() - lastTickTime) / 200000000F;
		if (mc.isGamePaused())
			rotateBy = 0;
		
		matrixStackIn.rotate(Vector3f.XP.rotation((float) Math.PI / 2));
		matrixStackIn.rotate(Vector3f.ZP.rotation(entityIn.rotationYaw));
		
		boolean applyEffects = entityIn.getAge() != 0 && (flag || mc.getRenderManager().options != null);
		
		//Handle Rotations
		if (applyEffects) {
			if (flag) {
				if (!entityIn.onGround) {
					rotateBy *= 2;
					Fluid fluid = CommonPhysic.getFluid(entityIn);
					if (fluid == null)
						fluid = CommonPhysic.getFluid(entityIn, true);
					if (fluid != null)
						rotateBy /= fluid.getAttributes().getDensity() / 1000 * 10;
					
					entityIn.rotationPitch += rotateBy;
				}
			} else if (entityIn != null && !Double.isNaN(entityIn.getPosX()) && !Double.isNaN(entityIn.getPosY()) && !Double.isNaN(entityIn.getPosZ()) && entityIn.world != null) {
				if (entityIn.onGround) {
					if (!flag)
						entityIn.rotationPitch = 0;
				} else {
					rotateBy *= 2;
					Fluid fluid = CommonPhysic.getFluid(entityIn);
					if (fluid != null)
						rotateBy /= fluid.getAttributes().getDensity() / 1000 * 10;
					
					entityIn.rotationPitch += rotateBy;
				}
			}
			
			if (flag)
				matrixStackIn.translate(0, -0.2, -0.08);
			else if (entityIn.world.getBlockState(entityIn.getPosition()).getBlock() == Blocks.SNOW || entityIn.world.getBlockState(entityIn.getPosition().down()).getBlock() == Blocks.SOUL_SAND)
				matrixStackIn.translate(0, 0.0, -0.14);
			else
				matrixStackIn.translate(0, 0, -0.04);
			
			double height = 0.2;
			if (flag)
				matrixStackIn.translate(0, height, 0);
			matrixStackIn.rotate(Vector3f.YP.rotation(entityIn.rotationPitch));
			if (flag)
				matrixStackIn.translate(0, -height, 0);
		}
		
		if (!flag) {
			float f7 = -0.0F * (j - 1) * 0.5F;
			float f8 = -0.0F * (j - 1) * 0.5F;
			float f9 = -0.09375F * (j - 1) * 0.5F;
			matrixStackIn.translate(f7, f8, f9);
		}
		
		for (int k = 0; k < j; ++k) {
			matrixStackIn.push();
			if (k > 0) {
				if (flag) {
					float f11 = (random.nextFloat() * 2.0F - 1.0F) * 0.15F;
					float f13 = (random.nextFloat() * 2.0F - 1.0F) * 0.15F;
					float f10 = (random.nextFloat() * 2.0F - 1.0F) * 0.15F;
					matrixStackIn.translate(f11, f13, f10);
				}
			}
			
{'fraction_non_alphanumeric': 0.124874739844292, 'fraction_numerical': 0.01880829414938719, 'mean_word_length': 4.577815993121238, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1373449', 'n_tokens_mistral': 4864, 'n_tokens_neox': 4325, 'n_words': 749}