Search in sources :

Example 16 with ServerPlayerEntity

use of net.minecraft.entity.player.ServerPlayerEntity in project BluePower by Qmunity.

the class MultipartUtils method getRayTraceVectors.

/**
 * Returns the look vector and max reach distance vector relative to the multipart block position.
 * based on MC Multipart
 * @param entity
 */
public static Pair<Vector3d, Vector3d> getRayTraceVectors(Entity entity) {
    float pitch = entity.xRot;
    float yaw = entity.yRot;
    Vector3d start = new Vector3d(entity.getX(), entity.getY() + entity.getEyeHeight(), entity.getZ());
    float f1 = MathHelper.cos(-yaw * 0.017453292F - (float) Math.PI);
    float f2 = MathHelper.sin(-yaw * 0.017453292F - (float) Math.PI);
    float f3 = -MathHelper.cos(-pitch * 0.017453292F);
    float f4 = MathHelper.sin(-pitch * 0.017453292F);
    float f5 = f2 * f3;
    float f6 = f1 * f3;
    double d3 = 5.0D;
    if (entity instanceof ServerPlayerEntity) {
        d3 = ((ServerPlayerEntity) entity).getAttribute(net.minecraftforge.common.ForgeMod.REACH_DISTANCE.get()).getValue();
    }
    Vector3d end = start.add(f5 * d3, f4 * d3, f6 * d3);
    return Pair.of(start, end);
}
Also used : Vector3d(net.minecraft.util.math.vector.Vector3d) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity)

Aggregations

ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)16 ItemStack (net.minecraft.item.ItemStack)8 PlayerEntity (net.minecraft.entity.player.PlayerEntity)4 MinecraftServer (net.minecraft.server.MinecraftServer)3 ResourceLocation (net.minecraft.util.ResourceLocation)3 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)3 Nullable (javax.annotation.Nullable)2 PlayerInventory (net.minecraft.entity.player.PlayerInventory)2 Container (net.minecraft.inventory.container.Container)2 BlockPos (net.minecraft.util.math.BlockPos)2 Vector3d (net.minecraft.util.math.vector.Vector3d)2 StringTextComponent (net.minecraft.util.text.StringTextComponent)2 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)2 NetworkEvent (net.minecraftforge.fml.network.NetworkEvent)2 IGuiButtonSensitive (com.bluepowermod.client.gui.IGuiButtonSensitive)1 ContainerDataMessage (com.cjm721.overloaded.network.packets.ContainerDataMessage)1 NoClipStatusMessage (com.cjm721.overloaded.network.packets.NoClipStatusMessage)1 IGenericDataStorage (com.cjm721.overloaded.storage.IGenericDataStorage)1 JsonObject (com.google.gson.JsonObject)1 SeedAnalyzerContainer (com.infinityraider.agricraft.plugins.agrigui.analyzer.SeedAnalyzerContainer)1