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

I have a problem with my inflateble entity:

With a method, that i found a the enderdragon, imade him bounce me away in the moment of inflating.

But if he is inflated, i can glitch through him...

If i press F3+B i see his bigger bounding-box, if he is inflated.

 

Here is my actual code for this behavior::

    @Override
    public void livingTick()
    {
        if (timeUntilDeflating > 0)
        {
            timeUntilDeflating--;
            
            if (timeUntilDeflating == 0)
            {
                isInflated = false;
                AxisAlignedBB aabb = this.getBoundingBox();
                this.setBoundingBox(new AxisAlignedBB(aabb.minX + 0.5d, aabb.minY, aabb.minZ + 0.5d, aabb.maxX - 0.5d, aabb.maxY - 1.0d, aabb.maxZ - 0.5d));
            }
        }
        else
        {
            super.livingTick();
        }
    }
    
    @Override
    public void onCollideWithPlayer(PlayerEntity entityIn)
    {
        if (timeUntilDeflating == 0)
        {
            timeUntilDeflating = 80;
            isInflated = true;
            AxisAlignedBB aabb = this.getBoundingBox();
            this.setBoundingBox(new AxisAlignedBB(aabb.minX - 0.5d, aabb.minY, aabb.minZ - 0.5d, aabb.maxX + 0.5d, aabb.maxY + 1.0d, aabb.maxZ + 0.5d));
            this.collideWithEntities(this.world.getEntitiesInAABBexcluding(this, this.getBoundingBox().grow(0.5D, 0.5D, 0.5D).offset(0.0D, 0.0D, 0.0D), null));
        }
    }
    
    private void collideWithEntities(List<Entity> entities)
    {
        double d0 = (getBoundingBox().minX + getBoundingBox().maxX) / 2.0D;
        double d1 = (getBoundingBox().minZ + getBoundingBox().maxZ) / 2.0D;
        
        for(Entity entity : entities)
        {
            if (entity instanceof LivingEntity)
            {
                double d2 = entity.getPosX() - d0;
                double d3 = entity.getPosZ() - d1;
                double d4 = d2 * d2 + d3 * d3;
                entity.addVelocity(d2 / d4 * 4.0D, (double)0.2F, d3 / d4 * 4.0D);
            }
        }
    }
}

My idea now is, tha something in super.livingTicks makes the boundingbox work.

How can i make him stay in his actual position and rotation, while inflates, but without stopping to use super.livingTicks?

 

Another question:

How nust i modify the last calculation here, that i bounce less far away from him (about the half distance is enough)?

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.