Jump to content

Recommended Posts

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

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