Jump to content

How do i make an entity changing it´s model and scale if it gets damage?


Drachenbauer

Recommended Posts

Hello

 

I´m working on an Angry Birds-mod.

 

One of the birds (the orange one) is very small, but has the ability to inflate him self like a balloon.

 

For this one, i have 2 model-files.

 

Is there any way, how i can script, that he inflates him self for a few secconds by getting damage (by changing his model and scale from 0,5 to 1 and back to 0,5)?

 

I already managet to scale the very small birds down to 0.5 while spawning them

 

Link to comment
Share on other sites

... Like you've said, you can change the scale from 0.5 to 1 to simulate inflating.

 

Override

Entity#attackEntityFrom

.

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Link to comment
Share on other sites

Entity#setSize

 

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Link to comment
Share on other sites

1. If you just want to resize the rendered model, add an EventSubscriber for RenderLivingEvent.Pre and use GlStateManager#scale to resize the rendered model.

2. https://stackoverflow.com/questions/11247793/why-do-some-folks-use-classmethod-instead-of-class-method-in-correspondence (or, you know, Google is your friend)

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Link to comment
Share on other sites

Why do you want to change the model?

To simulate the inflating you just need to change the size of your entity.

The 2 models are not necessary.

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Link to comment
Share on other sites

How do you plan on going between the models?

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

Ok, but how do you plan to smoothly transfer between two static models? Or do you not care about transferring smoothly?

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

  • 4 months later...

Now i have both model-classes with their renderer-classes.

 

How can i switch bitween the renderers, if the entity collides with the player (i think, that´s better than damage, so i can cause him to inflate, withouf damage him)?

I found this mothod for the collision.

    @Override
    public void onCollideWithPlayer(PlayerEntity entityIn)
    {
        super.onCollideWithPlayer(entityIn);
    }

What must i put in there to cause a change to the other renderer?

 

During another project, i found a way to make it first do stuff, than wait a time, than do other stuff:

With this i will make him inflate in the moment of the collision and deflate 4 seconds later:

    @Override
    public void onCollideWithPlayer(PlayerEntity entityIn)
    {
        //command for inflate
        timer.schedule(new TimerTask()
        {
            @Override
            public void run()
            {
                //command for deflate after 4 seconds
            }
        }
        , 4000);
        
        super.onCollideWithPlayer(entityIn);
    }

But what must i put above and inside the timer to change the renderer for this instance of the entity?

Edited by Drachenbauer
Link to comment
Share on other sites

5 hours ago, Drachenbauer said:

What must i put in there to cause a change to the other renderer?

I would have a field on my entity that would store the time since it was last hit, set it to 0 in that method and increment it each tick.

 

5 hours ago, Drachenbauer said:

timer.schedule(new TimerTask()

do NOT do this. 

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

15 hours ago, Cadiboo said:

I would have a field on my entity that would store the time since it was last hit, set it to 0 in that method and increment it each tick.

 

do NOT do this. 

Why i should not do this timer thing?

In my other project (a simple sokoban-game, nothing about minecraft) it works fine.

 

And how do i increase a time-field by tick?

Edited by Drachenbauer
Link to comment
Share on other sites

Is this better:

    @Override
    public void livingTick()
    {
        timeUntilDeflating++;
        
        if (timeUntilDeflating >= 80)
        {
            //command or deflating here
        }
        
        super.livingTick();
    }
    
    @Override
    public void onCollideWithPlayer(PlayerEntity entityIn)
    {
        timeUntilDeflating = 0;
        //command for inflating here
    }
Edited by Drachenbauer
Link to comment
Share on other sites

On 2/16/2019 at 9:52 PM, Drachenbauer said:

Hello

 

I´m working on an Angry Birds-mod.

 

One of the birds (the orange one) is very small, but has the ability to inflate him self like a balloon.

 

For this one, i have 2 model-files.

 

Is there any way, how i can script, that he inflates him self for a few secconds by getting damage (by changing his model and scale from 0,5 to 1 and back to 0,5)?

 

I already managet to scale the very small birds down to 0.5 while spawning them

 

Angry zombies in Thaumcraft grow larger when they damaged by players.
you can view Thaumcraft source aswell  :\

Link to comment
Share on other sites

what i need is, how to change the renderer for this instance, because the proportions of this bird change, if he inflates himself.

His body expands, but his face and feathers stax the same size.

So i have two renderers, wich use different models.

If i register both in my render-handler, the seccond one is used for the entity.

At first i thaught, maybe it will render both at the same place, doing the same stuff in the same moment.

But that isn´t the case.

 

so what must i put in the command-spots of the piece of code in my last post to change the renderer for this instance?

Link to comment
Share on other sites

I have got an idea:

I can create the inflated version as an own entity without living animations.

And in the original entity of the bird, it should spawn the inflated version at it´s position, if i collide with him and despawn it after the four secconds, i declared in the living-tick.

And while theese four secconds, the normal one should do no living animations to stay hidden inside the inflated model.

 

My code in the entity-class for this so far:

    @Override
    public void livingTick()
    {
        if (timeUntilDeflating > 0)
        {
            timeUntilDeflating--;
            
            if (timeUntilDeflating == 0)
            {
                //command for deflating here
            }
        }
        else
        {
            super.livingTick();
        }
    }
    
    @Override
    public void onCollideWithPlayer(PlayerEntity entityIn)
    {
        if (timeUntilDeflating == 0)
        {
            timeUntilDeflating = 80;
            //command for inflating here
        }
    }

It actually makes the entity stop it´s whoole movement and animations for four secconds after a collision with the player.

I´ll use this effect to keep the normal model hidden inside the inflated one.

 

I´m still working on an abstract renderer, that uses a model-class and scalefactor, but no living-animations (for the inflated variant).

 

How do i write a command, that spawns the inflated entity and fits in here?

And one that despawns it?

It should be spawned in the actual position of the normal one (to encase it) and with it´s rotation-angle around the vertical axis.

Edited by Drachenbauer
Link to comment
Share on other sites

  • 6 months later...

Now i use two models ant e texture, thad holds stuff for both models to simulate his inflating skill.

This worked well.

Then i thaught about resizing his boundingbox to fit the two different sizes.

Now he disappears, if i run into him to make him inflate.

I created theese boundingboxes:

    protected static final AxisAlignedBB BBUBBLES_AABB = new AxisAlignedBB(6.0D, 0.0D, 6.0D, 12.0D, 4.0D, 12.0D);
    protected static final AxisAlignedBB BBUBBLES_INFLATED_AABB = new AxisAlignedBB(-2.0D, 0.0D, -2.0D, 18.0D, 20.0D, 18.0D);

 

and use them in theese methods:

    @Override
    public void livingTick()
    {
        if (timeUntilDeflating > 0)
        {
            timeUntilDeflating--;
            
            if (timeUntilDeflating == 0)
            {
                isInflated = false;
                setBoundingBox(BBUBBLES_AABB);
                
            }
        }
        else
        {
            super.livingTick();
        }
    }
    
    @Override
    public void onCollideWithPlayer(PlayerEntity entityIn)
    {
        if (timeUntilDeflating == 0)
        {
            timeUntilDeflating = 80;
            isInflated = true;
            setBoundingBox(BBUBBLES_INFLATED_AABB);
        }
    }

in ormal state he is a 4x4x4 pixels (1/4 block-edgelength) cube and inflated 20.2.x2.pixels (a bit bigger than a block)

Is something wrong with my boundingboxes?

Edited by Drachenbauer
Link to comment
Share on other sites

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Detik4D adalah situs slot 4D resmi yang menawarkan pengalaman bermain yang mengasyikkan dan peluang menang besar. Dengan koleksi permainan slot yang beragam dan fitur-fitur menarik, Detik4D menjadi pilihan utama bagi para pecinta slot online. Peluang Menang Besar dengan Jackpot Resmi Salah satu keunggulan utama Detik4D adalah peluang menang besar yang ditawarkan. Dengan sistem jackpot resmi, para pemain memiliki kesempatan untuk memenangkan hadiah besar yang dapat mengubah hidup mereka. Jackpot-jackpot ini tidak hanya menghadirkan keseruan tambahan dalam bermain, tetapi juga memberikan peluang nyata untuk meraih keuntungan yang signifikan. Detik4D juga memiliki berbagai macam permainan slot dengan tingkat pembayaran yang tinggi. Dengan demikian, peluang untuk meraih kemenangan dalam jumlah besar semakin terbuka lebar. Para pemain dapat memilih dari berbagai jenis permainan slot yang menarik, termasuk slot klasik, video slot, dan slot progresif. Setiap jenis permainan memiliki fitur-fitur unik dan tema yang berbeda, sehingga para pemain tidak akan pernah merasa bosan. Pengalaman Bermain yang Mengasyikkan Selain peluang menang besar, Detik4D juga menawarkan pengalaman bermain yang mengasyikkan. Dengan tampilan grafis yang menarik dan suara yang menghibur, para pemain akan merasa seperti berada di kasino sungguhan. Fitur-fitur interaktif seperti putaran bonus, putaran gratis, dan fitur-fitur lainnya juga akan menambah keseruan dalam bermain. Detik4D juga memiliki antarmuka yang user-friendly, sehingga para pemain dapat dengan mudah mengakses permainan dan fitur-fitur lainnya. Proses pendaftaran dan deposit juga sangat mudah dan cepat, sehingga para pemain dapat segera memulai petualangan mereka di dunia slot online. Detik4D juga menyediakan layanan pelanggan yang responsif dan profesional. Tim dukungan pelanggan yang ramah akan siap membantu para pemain dengan segala pertanyaan atau masalah yang mereka hadapi. Dengan demikian, para pemain dapat bermain dengan tenang dan yakin bahwa mereka akan mendapatkan bantuan yang mereka butuhkan. Keamanan dan Kepercayaan Detik4D sangat memprioritaskan keamanan dan kepercayaan para pemain. Situs ini menggunakan teknologi enkripsi terkini untuk melindungi data pribadi dan transaksi keuangan para pemain. Selain itu, Detik4D juga bekerja sama dengan penyedia permainan terkemuka yang telah teruji dan terpercaya, sehingga para pemain dapat bermain dengan aman dan adil. Detik4D juga memiliki lisensi resmi dan diatur oleh otoritas perjudian yang terkemuka. Hal ini menjamin bahwa semua permainan yang ditawarkan adalah fair dan tidak ada kecurangan yang terjadi. Para pemain dapat bermain dengan tenang, mengetahui bahwa mereka berada di situs yang terpercaya dan terjamin. Jadi, jika Anda mencari situs slot 4D resmi dengan peluang menang besar dan pengalaman bermain yang mengasyikkan, Detik4D adalah pilihan yang tepat. Bergabunglah sekarang dan rasakan sendiri keseruan dan keuntungan yang ditawarkan oleh Detik4D.
    • Perjudian online telah menjadi tren yang populer di kalangan penggemar permainan kasino. Salah satu permainan yang paling diminati adalah mesin slot online. Mesin slot online menawarkan kesenangan dan kegembiraan yang tak tertandingi, serta peluang untuk memenangkan hadiah besar. Salah satu situs slot online resmi yang menarik perhatian banyak pemain adalah Tuyul Slot. Kenapa Memilih Tuyul Slot? Tuyul Slot adalah situs slot online resmi yang menawarkan berbagai keuntungan bagi para pemainnya. Berikut adalah beberapa alasan mengapa Anda harus memilih Tuyul Slot: 1. Keamanan dan Kepercayaan Tuyul Slot adalah situs slot online resmi yang terpercaya dan memiliki reputasi yang baik di kalangan pemain judi online. Situs ini menggunakan teknologi keamanan terkini untuk melindungi data pribadi dan transaksi keuangan pemain. Anda dapat bermain dengan tenang dan yakin bahwa informasi Anda aman. 2. Pilihan Permainan yang Beragam Tuyul Slot menawarkan berbagai macam permainan slot online yang menarik. Anda dapat memilih dari ratusan judul permainan yang berbeda, dengan tema dan fitur yang beragam. Setiap permainan memiliki tampilan grafis yang menarik dan suara yang menghibur, memberikan pengalaman bermain yang tak terlupakan. 3. Kemudahan Menang Salah satu keunggulan utama dari Tuyul Slot adalah kemudahan untuk memenangkan hadiah. Situs ini menyediakan mesin slot online dengan tingkat pengembalian yang tinggi, sehingga peluang Anda untuk memenangkan hadiah besar lebih tinggi. Selain itu, Tuyul Slot juga menawarkan berbagai bonus dan promosi menarik yang dapat meningkatkan peluang Anda untuk menang. Cara Memulai Bermain di Tuyul Slot Untuk memulai bermain di Tuyul Slot, Anda perlu mengikuti langkah-langkah berikut: 1. Daftar Akun Kunjungi situs Tuyul Slot dan klik tombol "Daftar" untuk membuat akun baru. Isi formulir pendaftaran dengan informasi pribadi yang valid dan lengkap. Pastikan untuk memberikan data yang akurat dan jaga kerahasiaan informasi Anda. 2. Deposit Dana Setelah mendaftar, Anda perlu melakukan deposit dana ke akun Anda. Tuyul Slot menyediakan berbagai metode pembayaran yang aman dan terpercaya. Pilih metode yang paling nyaman untuk Anda dan ikuti petunjuk untuk melakukan deposit. 3. Pilih Permainan Setelah memiliki dana di akun Anda, Anda dapat memilih permainan slot online yang ingin Anda mainkan. Telusuri koleksi permainan yang tersedia dan pilih yang paling menarik bagi Anda. Anda juga dapat mencoba permainan secara gratis sebelum memasang taruhan uang sungguhan. 4. Mulai Bermain Saat Anda sudah memilih permainan, klik tombol "Main" untuk memulai permainan. Anda dapat mengatur jumlah taruhan dan jumlah garis pembayaran sesuai dengan preferensi Anda. Setelah itu, tekan tombol "Putar" dan lihat apakah Anda beruntung untuk memenangkan hadiah. Promosi dan Bonus Tuyul Slot menawarkan berbagai promosi dan bonus menarik kepada para pemainnya. Beberapa jenis promosi yang tersedia termasuk bonus deposit, cashback, dan turnamen slot. Pastikan untuk memanfaatkan promosi ini untuk meningkatkan peluang Anda memenangkan hadiah besar. Kesimpulan Tuyul Slot adalah situs slot online resmi yang menawarkan pengalaman bermain yang seru dan peluang menang yang tinggi. Dengan keamanan dan kepercayaan yang terjamin, berbagai pilihan permainan yang menarik, serta bonus dan promosi yang menguntungkan, Tuyul Slot menjadi pilihan yang tepat bagi para penggemar mesin slot online. Segera daftar akun dan mulai bermain di Tuyul Slot untuk kesempatan memenangkan hadiah besar!
    • I have been having a problem with minecraft forge. Any version. Everytime I try to launch it it always comes back with error code 1. I have tried launching from curseforge, from the minecraft launcher. I have also tried resetting my computer to see if that would help. It works on my other computer but that one is too old to run it properly. I have tried with and without mods aswell. Fabric works, optifine works, and MultiMC works aswell but i want to use forge. If you can help with this issue please DM on discord my # is Haole_Dawg#6676
    • Add the latest.log (logs-folder) with sites like https://paste.ee/ and paste the link to it here  
    • I have no idea how a UI mod crashed a whole world but HUGE props to you man, just saved me +2 months of progress!  
  • Topics

×
×
  • Create New...

Important Information

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