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

Posted

Hello!

 

Ive been messing around with some code, and i was trying to create a method where my item would damage an entity from a distance. For some reason the damage is not being delt. My log messages appear in the console so im sure the method is being called. if you see an obvious error please tell me!

 

Any help is appreciated!

 

 

 

@Override

public boolean onEntitySwing(EntityLivingBase entity, ItemStack stack) {

EntityPlayer player = (EntityPlayer) entity;

EntityLivingBase target = getMouseOver(1, 10, player);

LogHelper.logInfo("Being called");

if (target != null) {

float missing_health = ((EntityLivingBase) target).getMaxHealth() - ((EntityLivingBase) target).getHealth();

target.attackEntityFrom(Pineapple.pineapple, (float) (5 + (missing_health * 0.10)));

LogHelper.logInfo("Attacking Entity -- Current Health:" + target.getHealth() + " Name:" + target.getClass());

}

 

return false;

}

 

public EntityLivingBase getMouseOver(float tick, float distance, EntityPlayer player) {

if (mc.theWorld != null) {

MovingObjectPosition pos = player.rayTrace(distance, tick);

Vec3 vec3 = mc.renderViewEntity.getPosition(tick);

Vec3 vec31 = mc.renderViewEntity.getLook(tick);

Vec3 vec32 = vec3.addVector(vec31.xCoord * distance, vec31.yCoord * distance, vec31.zCoord * distance);

List list = mc.theWorld.getEntitiesWithinAABBExcludingEntity(this.mc.renderViewEntity, this.mc.renderViewEntity.boundingBox.addCoord(vec31.xCoord * distance, vec31.yCoord * distance, vec31.zCoord * distance).expand(1.0, 1.0, 1.0));

 

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

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

if (entity instanceof EntityLivingBase) {

return (EntityLivingBase) entity;

}

}

}

return null;

}

System.out.println("Hi!");

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.