Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

  • 4 weeks later...

Hi

 

This line in EntityRenderer.getMouseOver is probably the reason

 

                for (int i = 0; i < list.size(); ++i)

                {

                    Entity entity = (Entity)list.get(i);

 

                    if (entity.canBeCollidedWith())  // here -> can't collide with EntityItem

 

You might need to copy the code from EntityRenderer.getMouseOver into your own method and alter it.  Depending on what you're trying to do, if you want this to work on the server side you probably need to copy the code anyway.

 

-TGG

 

 

 

 

  • Author

THANKS!!!

Code:

public Entity getMouseOver(float partialTicks, double distance, boolean canBeCollidedWith){
Minecraft mc = Minecraft.getMinecraft();
Entity pointedEntity = null;
MovingObjectPosition rayTrace = null;

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(int i = 0; i < entities.size(); i++){
Entity entity = entities.get(i);

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;
}

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.