Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Can i use a layer-class to show and hide inflated state of Bubbles (orange bird)?


Drachenbauer
 Share

Recommended Posts

You could use a layer, but I would just do everything in my Renderer. I would check how vanilla layers are used by looking at one of the players render layer classes (search for classes that end with “Layer”) and then looking for usages of it’s constructor.

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

5 minutes ago, Drachenbauer said:

Can i switch between two models in the renderer, and control this in the entity-class (where i already created a control-structure, where i just need to call the right methods inside)

I would just switch the models then, why do you need a render layer?

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

Now i asked for your way.

 

How do you switch models in the renderer?

 

maybe i can have this in my renderer:

    public static void setInflated(boolean inflated)
    {
        if (inflated)
        {
            
        }
        else
        {
            
        }
    }

but i don´t know, what to insert into the "if"-"else"-statement to load the different models...

Edited by Drachenbauer
Link to comment
Share on other sites

if (bird.inflated)

    inflatedModel.render();

else

    normalModel.render();

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

And what must i put inte the render-method in the model?

I have to create it before i can use it there, because it´s not more part from the normal model-classes.

 

For the texture i looked at the pufferfish.

there i saw, that they placed the textures for all sizes in one single graphic file.

So i made it for this bird the same way.

I just hat to place the texture for his normal sized body into the texture for the inflated state.

If inflated, he is five times as big as normal.

So the normal body-texture fit´s in one of the top-squares, that the inflated state-texture leaves empty.

I can use the textures for beak and feathers for both states, because theese parts do not grow or shrink, if he inflates or deflates..

 

 

Edited by Drachenbauer
Link to comment
Share on other sites

This is now the renderer-class:

package drachenbauer32.angrybirdsmod.entities.renderers;

import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.systems.RenderSystem;

import drachenbauer32.angrybirdsmod.entities.BubblesEntity;
import drachenbauer32.angrybirdsmod.entities.models.BubblesInflatedModel;
import drachenbauer32.angrybirdsmod.entities.models.BubblesModel;
import drachenbauer32.angrybirdsmod.util.Reference;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.EntityRendererManager;
import net.minecraft.client.renderer.entity.MobRenderer;
import net.minecraft.client.renderer.entity.model.EntityModel;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.client.registry.IRenderFactory;

@OnlyIn(Dist.CLIENT)
public class BubblesRenderer extends MobRenderer<BubblesEntity, EntityModel<BubblesEntity>>
{
    private static final ResourceLocation BUBBLES_TEXTURE = new ResourceLocation(Reference.MOD_ID + ":textures/entity/bubbles.png");
    private final BubblesModel<BubblesEntity> BUBBLES_MODEL= new BubblesModel<>();
    private final BubblesInflatedModel<BubblesEntity> BUBBLES_INFLATED_MODEL= new BubblesInflatedModel<>();
    
    public BubblesRenderer(EntityRendererManager manager)
    {
        super(manager, new BubblesModel<>(), 0.25f);
    }
    
    @Override
    public ResourceLocation getEntityTexture(BubblesEntity arg0)
    {
        return BUBBLES_TEXTURE;
    }
    
    @Override
    protected void func_225629_a_(BubblesEntity p_225629_1_, String p_225629_2_, MatrixStack p_225629_3_, IRenderTypeBuffer p_225629_4_, int p_225629_5_)
    {
        RenderSystem.scalef(0.5f, 0.5f, 0.5f);
    }
    
    public void setInflated(boolean inflated)
    {
        if (inflated)
        {
            entityModel = BUBBLES_INFLATED_MODEL;
        }
        else
        {
            entityModel = BUBBLES_MODEL;
        }
    }
    
    public static class RenderFactory implements IRenderFactory<BubblesEntity>
    {
        @Override
        public EntityRenderer<? super BubblesEntity> createRenderFor(EntityRendererManager manager)
        {
            return new BubblesRenderer(manager);
        }
    }
}

 

For controlling the inflating by collision with my player-character, i created this in the BubblesEntity-class:

    @Override
    public void livingTick()
    {
        if (timeUntilDeflating > 0)
        {
            timeUntilDeflating--;
            
            if (timeUntilDeflating == 0)
            {
                //method-call for deflate
            }
        }
        else
        {
            super.livingTick();
        }
    }
    
    @Override
    public void onCollideWithPlayer(PlayerEntity entityIn)
    {
        if (timeUntilDeflating == 0)
        {
            timeUntilDeflating = 80;
            //method-call for inflate
        }
    }

 

But now i have a question:

If i spawn an entity, it generates it´s own instances from it´s entity-class and renderer-clas.

 

If i spawn 2 or more, there must be instances like this:

Bubbles-bird 1:

BubblesEntity-class-instance 1

BubblesRenderer-class-instance 1

 

Bubbles-bird 2:

BubblesEntity-class-instance 2

BubblesRenderer-class-instance 2

...

 

So how do i call my method from the renderer in the shown code in the entity-class, that it calls it from the matching renderer-instance?

 

Collision with Bubbles-bird 1:

BubblesEntity-class-instance 1 --- calls --> method in BubblesRenderer-class-instance 1

 

Collision with Bubbles-bird 2

BubblesEntity-class-instance 2 --- calls --> method in BubblesRenderer-class-instance 2

...

 

I think, if i call it the static way, all of them will inflate, if i collide with one.

So how do i make it find the right instance from the renderer to call the method?

Edited by Drachenbauer
Link to comment
Share on other sites

14 hours ago, Drachenbauer said:

else { super.livingTick(); }

You’re definitely going to want to call super regardless of if you’re going to deflate soon or not. 

 

14 hours ago, Drachenbauer said:

If i spawn an entity, it generates it´s own instances from it´s entity-class and renderer-clas.

No. There is only one renderer instance. This instance renders all of your entities one by one. So you need to get the data from your entity in your Renderer and act according to that data

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

8 hours ago, Cadiboo said:

You’re definitely going to want to call super regardless of if you’re going to deflate soon or not. 

 

No. There is only one renderer instance. This instance renders all of your entities one by one. So you need to get the data from your entity in your Renderer and act according to that data


1.

i want him to stay in place without movement,as long as he is inflated.

 

2.

How do i get the data, wich entity calls the method?

How do i call the method the non static way?

Edited by Drachenbauer
Link to comment
Share on other sites

20 hours ago, Drachenbauer said:

i want him to stay in place without movement,as long as he is inflated.

I hadn’t considered that. Still you’ll probably want to change just the movement stuff rather than circumventing the entire tick method.

 

20 hours ago, Drachenbauer said:

How do i get the data, wich entity calls the method?

The entity that is currently being rendered is passed into your renderer as one of the parameters.

20 hours ago, Drachenbauer said:

How do i call the method the non static way?

Don’t call anything on your renderer from your entity.

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

7 hours ago, Cadiboo said:

Don’t call anything on your renderer from your entity.

What else shoud i call in the entity in the positions with the comments?

Why i should not use a method from the renderer there?

 

Edit:

in the renderer from the pufferfish i found the method:

   public void func_225623_a_(PufferfishEntity p_225623_1_, float p_225623_2_, float p_225623_3_,
                              MatrixStack p_225623_4_, IRenderTypeBuffer p_225623_5_, int p_225623_6_)
   {
      int i = p_225623_1_.getPuffState();
      if (i != this.field_203772_j) {
         if (i == 0) {
            this.entityModel = this.field_203773_k;
         } else if (i == 1) {
            this.entityModel = this.field_203774_l;
         } else {
            this.entityModel = this.field_203775_m;
         }
      }

      this.field_203772_j = i;
      this.shadowSize = 0.1F + 0.1F * (float)i;
      super.func_225623_a_(p_225623_1_, p_225623_2_, p_225623_3_, p_225623_4_, p_225623_5_, p_225623_6_);
   }

That holds it´s different sized models.

Is this a good place for the models of my entity?

 

I also have a subclass called RenderFactory in my renderers.

But i don´t see it for sample at the pufferfish.

do i still need it?

Edited by Drachenbauer
Link to comment
Share on other sites

16 hours ago, Drachenbauer said:

Why i should not use a method from the renderer there?

Many reasons including

On 1/29/2020 at 6:14 PM, Cadiboo said:

There is only one renderer instance. This instance renders all of your entities one by one. So you need to get the data from your entity in your Renderer and act according to that data

and that entities are common (exist on both client and server) and rendering is client only. 

 

16 hours ago, Drachenbauer said:

I also have a subclass called RenderFactory in my renderers.

But i don´t see it for sample at the pufferfish.

do i still need it?

No. You can use a lambda/method reference. This has been the case since whenever Java 8 came out, any tutorial that still uses a seperate RenderFactory class is extremely outdated.

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

16 hours ago, Drachenbauer said:

in the renderer from the pufferfish i found the method:

16 hours ago, Drachenbauer said:

That holds it´s different sized models.

Is this a good place for the models of my entity?

Yes. Your model instances should go in your renderer. Where else would you have them?

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

i first created a new method for them in my renderer.

But now i think, the shown method (found in the pufferfish) is the right place instead.

And in the Entity-class i have a boolean, that is set to true for inflating and false for deflating.

The method, i now use in the renderer, checks this boolean from the Entity-class to choose the model.

Edited by Drachenbauer
Link to comment
Share on other sites

2 hours ago, Drachenbauer said:

And in the Entity-class i have a boolean, that is set to true for inflating and false for deflating.

The method, i now use in the renderer, checks this boolean from the Entity-class to choose the model.

This is the right way to do it. Make sure you sync it properly with the EntityDataManger or similar.

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

10 hours ago, Drachenbauer said:

how do i do this?

Look at how the arrow entity syncs its isCritical flag.

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.