All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.magistuarmory.client.ClientHelper Maven / Gradle / Ivy

The newest version!
package com.magistuarmory.client;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.class_1297;
import net.minecraft.class_1675;
import net.minecraft.class_2338;
import net.minecraft.class_2350;
import net.minecraft.class_238;
import net.minecraft.class_239;
import net.minecraft.class_243;
import net.minecraft.class_310;
import net.minecraft.class_3965;
import net.minecraft.class_3966;
import net.minecraft.world.phys.*;

import java.util.Objects;

@Environment(EnvType.CLIENT)
public class ClientHelper
{
	public static class_239 getMouseOver(class_310 mc, float reach)
	{
		class_239 result = null;
		class_1297 cameraentity = mc.method_1560();

		if (cameraentity != null)
		{
			result = cameraentity.method_5745(reach, 0.0F, false);
			class_243 eyepos = cameraentity.method_33571();
			double d1 = reach;
			d1 *= d1;
			if (result != null)
				d1 = result.method_17784().method_1025(eyepos);
			class_243 view = cameraentity.method_5828(1.0F);
			class_243 attackvec = eyepos.method_1031(view.field_1352 * (double) reach, view.field_1351 * (double) reach, view.field_1350 * (double) reach);
			class_238 expBounds = cameraentity.method_5829().method_18804(view.method_1021(reach)).method_1009(1.0D, 1.0D, 1.0D);
			class_3966 entityhitresult = class_1675.method_18075(cameraentity, eyepos, attackvec, expBounds, entity -> (!entity.method_7325() && entity.method_5863()), d1);
			result = Objects.requireNonNullElseGet(entityhitresult, () -> class_3965.method_17778(attackvec, class_2350.method_10142(view.field_1352, view.field_1351, view.field_1350), new class_2338((int) attackvec.field_1352, (int) attackvec.field_1351, (int) attackvec.field_1350)));
		}
		return result;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy