Follow along with the video below to see how to install our site as a web app on your home screen.
Примечание: This feature may not be available in some browsers.
Тогда вопрос: где брать partialTickTime для этого метода?Agravaine написал(а):EntityRenderer#getMouseOver.
@SideOnly(Side.CLIENT)
public static Entity getMouseOver(float partialTicks, double distance, boolean canBeCollidedWith) {
Minecraft mc = Minecraft.getMinecraft();
Entity pointedEntity = null;
MovingObjectPosition rayTrace;
if (mc.renderViewEntity != null) {
if (mc.theWorld != null) {
rayTrace = mc.renderViewEntity.rayTrace(distance, partialTicks);
Vec3 positionVec = mc.renderViewEntity.getPosition(partialTicks);
double distanceToVec3 = distance;
if (rayTrace != null) {
distanceToVec3 = rayTrace.hitVec.distanceTo(positionVec);
}
Vec3 lookVec = mc.renderViewEntity.getLook(partialTicks);
Vec3 posDistVec = positionVec.addVector(lookVec.xCoord * distance, lookVec.yCoord * distance, lookVec.zCoord * distance);
Vec3 tempVec = null;
double boxExpand = 1.0F;
List<Entity> entities = mc.theWorld.getEntitiesWithinAABBExcludingEntity(mc.renderViewEntity, mc.renderViewEntity.boundingBox.addCoord(lookVec.xCoord * distance, lookVec.yCoord * distance, lookVec.zCoord * distance).expand(boxExpand, boxExpand, boxExpand));
double vecInsideDist = distanceToVec3;
for (Entity entity : entities) {
if (!canBeCollidedWith || entity.canBeCollidedWith()) {
double borderSize = entity.getCollisionBorderSize();
AxisAlignedBB expEntityBox = entity.boundingBox.expand(borderSize, borderSize, borderSize);
MovingObjectPosition calculateInterceptPos = expEntityBox.calculateIntercept(positionVec, posDistVec);
if (expEntityBox.isVecInside(positionVec)) {
if (0.0D < vecInsideDist || vecInsideDist == 0.0D) {
pointedEntity = entity;
tempVec = calculateInterceptPos == null ? positionVec : calculateInterceptPos.hitVec;
vecInsideDist = 0.0D;
}
} else if (calculateInterceptPos != null) {
double calcInterceptPosDist = positionVec.distanceTo(calculateInterceptPos.hitVec);
if (calcInterceptPosDist < vecInsideDist || vecInsideDist == 0.0D) {
if (entity == mc.renderViewEntity.ridingEntity && !entity.canRiderInteract()) {
if (vecInsideDist == 0.0D) {
pointedEntity = entity;
tempVec = calculateInterceptPos.hitVec;
}
} else {
pointedEntity = entity;
tempVec = calculateInterceptPos.hitVec;
vecInsideDist = calcInterceptPosDist;
}
}
}
}
}
if (pointedEntity != null && (vecInsideDist < distanceToVec3 || rayTrace == null)) {
return pointedEntity;
}
}
}
return null;
}