Jump to content

Recommended Posts

Posted

 

this is whath im triying to achive

 

actualy this gun bullets hold in place the target entity for 100 ticks reseting its position every tick, then explodes inside the mob, but the mob can still do damage if the player gets close enougth, the squeletons can shoot arrows creepers xplode

i wanna leave the target entity absolutly stun until the bullets xplodes

 

//SI la bala esta dentro de una Entidad            
            if (this.inEntity)
            {
            	int entityTicks = this.getTicksInEntity();
            	
                this.setTicksInEntity(entityTicks + 1);

                
                if (entityTicks == 1){
                	
                    EntityLivingBase mob =(EntityLivingBase) this.targetEntity;
                	mob.hurtResistantTime=0;
                
            		this.posX=targetPosX;
            		this.posY=targetEntity.posY;
            		this.posZ=targetPosZ;
            		
            	    //mob.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 90));
                    //mob.addPotionEffect(new PotionEffect(Potion.blindness.id, 99));
                    //mob.addPotionEffect(new PotionEffect(Potion.confusion.id, 99));
                	
                }
                
                //this.targetEntity.setInWeb(); //this.targetEntity.setInWeb();
                
                this.targetEntity.setPositionAndRotation(targetPosX, targetPosY , targetPosZ, this.targetRotY , 0.0F );
                
               
             
        		if ( this.getTicksInEntity() > 100  )
        		{
        			
        		//System.out.println(this.targetEntity.getName()+" X= "+targetPosX+" Z="+targetPosZ  );
        		     		
        			
        			if (!this.targetEntity.isDead){
        			EntityLivingBase mob =(EntityLivingBase) this.targetEntity;	
        		
        			//bullet position reset
        			this.posX=targetPosX;
            		this.posY=targetEntity.posY;
            		this.posZ=targetPosZ;
            		        			
            		this.targetEntity.hurtResistantTime=0;
        			
            		int R = 1 + ((int) (Math.random() * 9)); //minimo 1 de daño
            		
                    //causar daño alos ender
            	    String mName=this.targetEntity.getName();
            	    	if (mName.toLowerCase().contains("ender"))
            	    	{
            	    		this.targetEntity.attackEntityFrom(DamageSource.outOfWorld, damageE + R  );
            	    	}
                    
                    DamageSource damagesourceX = DamageSource.causeThrownDamage(this, this.shootingEntity);
                    this.targetEntity.attackEntityFrom(damagesourceX, damageM + R );            
    	    		        			
                    
        			this.worldObj.newExplosion((Entity)null, targetPosX, targetPosY + 0.5D,  targetPosZ, 1.0F, false, false);
    				
        			float HM = mob.getMaxHealth();
    				float H = mob.getHealth();
    				//System.out.println(this.targetEntity.getName()+" Hp= "+H+" / "+HM );
                                        
        			}
        			
        			this.setDead();
        			        			
        		}
            	
            }

 

some idea about how to stun a mob ??

Posted

It's not very elegant, but the way I did it is to subscribe to LivingAttackEvent, check if the attacking entity (event.source.getEntity()) is under the 'stun' effect and, if so, cancel the event.

 

That will at least prevent mobs from doing damage that way. As for creepers, there is now an explosion event of some kind that you should be able to cancel - I haven't used it yet, but I bet it has everything you need.

 

There is also the cancelable EnderTeleportEvent which, as you might guess, you can use to prevent teleportation. This may or may not work for modded mobs, depending on whether the mod author follows convention and posts the event for their custom entities or not.

 

Lots of events, as you can see ;)

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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