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

I made an entity that strikes a large amount of lightning. problem is, when ever the entity makes contact with an entity it doesn't render on the screen. it only renders when it hits a block. how should I fix this. here is the code.

 

package com.OlympiansMod.entity;

import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.projectile.EntityLargeFireball;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;

public class EntityMasterBolt extends EntityThrowable{

public EntityMasterBolt(World p_i1776_1_) {
	super(p_i1776_1_);
}
public EntityMasterBolt(World world, EntityLivingBase entity){
	super(world, entity);


}
@Override
protected void onImpact(MovingObjectPosition p_70184_1_) {
	    for(int i = 0; i < 25; i++){
		this.worldObj.spawnParticle("largesmoke", this.posX, this.posY, this.posZ, 0f, 0f, 0f);
		this.setDead();
		EntityLightningBolt undead = new EntityLightningBolt(worldObj, 10, 10, 10);
		undead.setPosition(this.posX, this.posY, this.posZ);
		worldObj.spawnEntityInWorld(undead);





	  }

	if (!this.worldObj.isRemote){
		this.setDead();
		//his.worldObj.createExplosion((Entity) null, this.posX, this.posY, this.posZ, 3.0f, true);

	}


	}
}







Im serious don't look at it!!

I wonder if the lightning bolt needs to hit a block. So maybe you should spawn it at the position under the entity that was hit. You can get entityHit from the moving object position, then calculate the block below the entity position. Note that depending on which version you're using the math might be different because I think in 1.7.10 and earlier that on the server side the position doesn't take account the eye height.

 

Anyway, that's the only thing I can think of as otherwise it looks correct to me.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Gettting the block under an entity is simple math.. Take The actual Position of the entity and go down until you find an entity

To increase The dmg of a lightning Bild use entityHurt

  • Author

how do I specifically set the damage for the lightning not the entityThrowable?

 

if(Pos.entityHit != null)
	       {
	          byte b0 = 100;
	           if (Pos.entityHit instanceof EntityLightningBolt)
	           {
	               b0 = 100;
	           }

		Pos.entityHit.attackEntityFrom(DamageSource.causeIndirectMagicDamage(this, this.getThrower()), b0);
	       

Im serious don't look at it!!

Try this:

 

@Override
protected void onImpact(MovingObjectPosition mop) {
	    for(int i = 0; i < 25; i++){
		this.worldObj.spawnParticle("largesmoke", this.posX, this.posY, this.posZ, 0f, 0f, 0f);
		this.setDead();


                        if (mop.entityHit == null){
                            EntityLightningBolt undead = new EntityLightningBolt(worldObj, 10, 10, 10);
		    undead.setPosition(this.posX, this.posY, this.posZ);
		    worldObj.spawnEntityInWorld(undead);
                        } else {
                            EntityLightningBolt undead = new EntityLightningBolt(worldObj, 10, 10, 10);
                            undead.setPosition(this.posX, this.posY - 1, this.posZ);
                            worldObj.spawnEntityInWorld(undead);
                        }





	  }

	if (!this.worldObj.isRemote){
		this.setDead();
		//his.worldObj.createExplosion((Entity) null, this.posX, this.posY, this.posZ, 3.0f, true);

	}


	}
}

there isn't event.ammount in 1.7.10. anymore help?

 

There is an EntityStruckByLightningEvent. it will give the entity struck. You can then cause more damage to the entity using methods for attacking the entity (check out how lightning normally applies it).

 

I think you could also use the EntityHurtEvent and check if damage source is lightning and if so you could increase the damage.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

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.