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

 

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

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

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.