Jump to content

[1.12.2] Giving an Entity the Enchantment Glint


Xenocorpse

Recommended Posts

So I have a mob whose job it is is to drop enchanted golden apples. As such, I'd like the entity itself to have the enchantment glint present like items would, except I can't just override the hasEffect() method like an item. I thought about taking the texture and using it as a second layer but I have no idea where to begin as far as the code.

I may or may not know a bit about Java. But if I do, it's probably because of my AP Computer Science textbook...

Link to comment
Share on other sites

You might want to look at how RenderItem#renderEffect works

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

1 minute ago, Cadiboo said:

You might want to look at how RenderItem#renderEffect works

I've noticed that the function is using a TextureManager. Is there any other way to apply the texture to the model?

I may or may not know a bit about Java. But if I do, it's probably because of my AP Computer Science textbook...

Link to comment
Share on other sites

Why? I’m sure there is but due to how the enchantment texture works, it will probably require some significant effort to do.

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

Just now, Cadiboo said:

Why? I’m sure there is but due to how the enchantment texture works, it will probably require some significant effort to do.

Simply because I'm not familiar with how TextureManager works. Oh well, looks like I've got some researching to do.

I may or may not know a bit about Java. But if I do, it's probably because of my AP Computer Science textbook...

Link to comment
Share on other sites

this.textureManager.bindTexture(RES_ITEM_GLINT); simply sets the texture that is going to be used when rendering the next thing. This call just sets the texture to the item glint/enchantment texture. 

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

So I've implemented the code but nothing happens. Where should I call the bindTexture() function? Code:

Spoiler

package xeno.spawnore.entity.render;

import net.minecraft.client.Minecraft;
import net.minecraft.client.model.ModelCow;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.resources.IResourceManager;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.client.registry.IRenderFactory;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import xeno.spawnore.entity.EntityEnchantedCow;

import javax.annotation.Nullable;

@SideOnly(Side.CLIENT)
public class RenderEnchantedCow extends RenderLiving<EntityEnchantedCow> {

    private static ResourceLocation TEXTURE = new ResourceLocation("spawnore:textures/entity/goldencow/goldencow.png");
    private static ResourceLocation GLINT = new ResourceLocation("minecraft:textures/misc/enchanted_item_glint.png");

    public static final Factory FACTORY = new Factory();

    private static IResourceManager resourceManager = Minecraft.getMinecraft().getResourceManager();

    private static TextureManager textureManager = new TextureManager(resourceManager);

    public RenderEnchantedCow(RenderManager rendermanagerIn) {
        super(rendermanagerIn, new ModelCow(), 0.5F);
    }

    @Override
    public void doRender(EntityEnchantedCow entity, double x, double y, double z, float entityYaw, float partialTicks) {
        super.doRender(entity, x, y, z, entityYaw, partialTicks);
        this.textureManager.bindTexture(GLINT);
    }


    @Nullable
    @Override
    protected ResourceLocation getEntityTexture(EntityEnchantedCow entity) {
        return TEXTURE;
    }

    public static class Factory implements IRenderFactory<EntityEnchantedCow> {

        @Override
        public Render<? super EntityEnchantedCow> createRenderFor(RenderManager manager) {
            return new RenderEnchantedCow(manager);
        }
    }
}

 

 

I may or may not know a bit about Java. But if I do, it's probably because of my AP Computer Science textbook...

Link to comment
Share on other sites

9 hours ago, Xenocorpse said:

public static final Factory FACTORY = new Factory();

No. Use constructor references

9 hours ago, Xenocorpse said:

private static IResourceManager resourceManager = Minecraft.getMinecraft().getResourceManager();

Don’t store this in a static field unless it changes

9 hours ago, Xenocorpse said:

private static TextureManager textureManager = new TextureManager(resourceManager);

No. Use Minecraft’s texture manager

9 hours ago, Xenocorpse said:

this.textureManager.bindTexture(GLINT);

You’ve got to do the rest of the rendering.

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