Jump to content

Recommended Posts

Posted

Hello all,

 

I recently got my custom mob working with model and texture, and now want it to hold a weapon.  I'm going to make a custom sword, but in the meantime I thought I would use a regular stone sword.  Unfortunately, for some reason, my mob holds out his hand, as if he was holding an item, but there is nothing in the hand.  Below will be the Entity****.java class:

 

 

package timescape.entity;

 

import net.minecraft.entity.Entity;

import net.minecraft.entity.EntityAgeable;

import net.minecraft.entity.EnumCreatureAttribute;

import net.minecraft.entity.ai.EntityAIAttackOnCollide;

import net.minecraft.entity.ai.EntityAIFollowParent;

import net.minecraft.entity.ai.EntityAIHurtByTarget;

import net.minecraft.entity.ai.EntityAILookIdle;

import net.minecraft.entity.ai.EntityAIMate;

import net.minecraft.entity.ai.EntityAINearestAttackableTarget;

import net.minecraft.entity.ai.EntityAIPanic;

import net.minecraft.entity.ai.EntityAISwimming;

import net.minecraft.entity.ai.EntityAITempt;

import net.minecraft.entity.ai.EntityAIWander;

import net.minecraft.entity.ai.EntityAIWatchClosest;

import net.minecraft.entity.monster.EntityMob;

import net.minecraft.entity.passive.EntityAnimal;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import net.minecraft.world.World;

 

 

public class EntityNutcracker extends EntityMob

{

 

public EntityNutcracker(World world)

        {

                super(world);

                this.texture = "/mods/Nutcracker.png";

                this.getNavigator().setAvoidsWater(true);

                this.isImmuneToFire = false;

                this.moveSpeed = 0.25F;

                this.tasks.addTask(0, new EntityAISwimming(this));

                this.tasks.addTask(2, new EntityAIAttackOnCollide(this, EntityPlayer.class, this.moveSpeed, false));

                this.tasks.addTask(3, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));

                this.tasks.addTask(4, new EntityAIWander(this, this.moveSpeed));

                this.tasks.addTask(5, new EntityAILookIdle(this));

                this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));

                this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 16.0F, 0, true));

        }

 

        public boolean isAIEnabled()

        {

        return true;

        }

     

        public int getMaxHealth()

        {

                return 20;

        }

       

        protected void addRandomArmor()

        {

            this.setCurrentItemOrArmor(0, new ItemStack(Item.swordStone));

        }

           

        public EnumCreatureAttribute getCreatureAttribute()

        {

        return EnumCreatureAttribute.UNDEAD;

        }

        protected String getLivingSound()

        {

                return "mob.endermen.idle";

        }

       

        protected String getHurtSound()

        {

                return "mob.endermen.hit";

        }

       

        protected String getDeathSound()

        {

                return "mob.endermen.death";

        }

 

        protected void playStepSound(int par1, int par2, int par3, int par4)

        {

                this.worldObj.playSoundAtEntity(this, null, 0.15F,  1.0F);

        }

       

        protected int getDropItemId()

        {

                return Item.swordStone.itemID;

        }

       

        public EntityAgeable createChild1(EntityAgeable var1)

        {

                return null;

        }

        public ItemStack getHeldItem()

        {

                return defaultHeldItem;

        }

               

                static

        {

                defaultHeldItem = new ItemStack(Item.swordStone, 1);

        }

               

        private static final ItemStack defaultHeldItem;

       

        @Override

protected boolean isValidLightLevel()

{

    return true;

}

}

 

 

Any help would be greatly appreciated.

 

Greenman

Posted

Ah, my bad.  In that case, I haven't done anything to the render class, but here it is anyways:

 

 

package timescape.render;

 

import timescape.ModelNutcracker;

import timescape.entity.EntityNutcracker;

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

import net.minecraft.client.model.ModelBase;

import net.minecraft.client.model.ModelEnderman;

import net.minecraft.client.renderer.entity.RenderLiving;

import net.minecraft.entity.Entity;

import net.minecraft.entity.EntityLiving;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

 

@SideOnly(Side.CLIENT)

public class RenderNutcracker extends RenderLiving

{

        public RenderNutcracker(ModelNutcracker ModelNutcracker_Test, float f)

        {

                super(new ModelNutcracker(), 0.5F);

        }

        public RenderNutcracker(ModelBase par1ModelBase, float par2)

        {

                super(par1ModelBase, par2);

        }

        public void RenderNutcracker(EntityNutcracker par1EntityNutcracker, double par2, double par4, double par6, float par8, float par9)

        {

                super.doRenderLiving(par1EntityNutcracker, par2, par4, par6, par8, par9);

        }

        public void doRenderLiving(EntityLiving par1EntityLiving, double par2, double par4, double par6, float par8, float par9)

        {

                this.RenderNutcracker((EntityNutcracker)par1EntityLiving, par2, par4, par6, par8, par9);

        }

        public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)

        {

                this.RenderNutcracker((EntityNutcracker)par1Entity, par2, par4, par6, par8, par9);

        }

}

 

Posted

Alright, so I found another tut to try working off of, and I got the entity*** to this:

 

 

package timescape.entity;

 

import net.minecraft.entity.Entity;

import net.minecraft.entity.EntityAgeable;

import net.minecraft.entity.EnumCreatureAttribute;

import net.minecraft.entity.ai.EntityAIAttackOnCollide;

import net.minecraft.entity.ai.EntityAIFollowParent;

import net.minecraft.entity.ai.EntityAIHurtByTarget;

import net.minecraft.entity.ai.EntityAILookIdle;

import net.minecraft.entity.ai.EntityAIMate;

import net.minecraft.entity.ai.EntityAINearestAttackableTarget;

import net.minecraft.entity.ai.EntityAIPanic;

import net.minecraft.entity.ai.EntityAISwimming;

import net.minecraft.entity.ai.EntityAITempt;

import net.minecraft.entity.ai.EntityAIWander;

import net.minecraft.entity.ai.EntityAIWatchClosest;

import net.minecraft.entity.monster.EntityMob;

import net.minecraft.entity.passive.EntityAnimal;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import net.minecraft.world.World;

 

public class EntityNutcracker extends EntityMob

{

 

public EntityNutcracker(World world)

        {

                super(world);

                this.texture = "/mods/Nutcracker.png";

                this.getNavigator().setAvoidsWater(true);

                this.isImmuneToFire = false;

                this.moveSpeed = 0.25F;

                this.tasks.addTask(0, new EntityAISwimming(this));

                this.tasks.addTask(2, new EntityAIAttackOnCollide(this, EntityPlayer.class, this.moveSpeed, false));

                this.tasks.addTask(3, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));

                this.tasks.addTask(4, new EntityAIWander(this, this.moveSpeed));

                this.tasks.addTask(5, new EntityAILookIdle(this));

                this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));

                this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 16.0F, 0, true));

        }

 

        public boolean isAIEnabled()

        {

        return true;

        }

     

        public int getMaxHealth()

        {

                return 20;

        }

       

        protected void addRandomArmor()

        {

            this.setCurrentItemOrArmor(0, new ItemStack(Item.swordStone));

        }

           

        public EnumCreatureAttribute getCreatureAttribute()

        {

        return EnumCreatureAttribute.UNDEAD;

        }

        protected String getLivingSound()

        {

                return "mob.endermen.idle";

        }

       

        protected String getHurtSound()

        {

                return "mob.endermen.hit";

        }

       

        protected String getDeathSound()

        {

                return "mob.endermen.death";

        }

 

        protected void playStepSound(int par1, int par2, int par3, int par4)

        {

                this.worldObj.playSoundAtEntity(this, null, 0.15F,  1.0F);

        }

       

        protected int getDropItemId()

        {

                return Item.swordStone.itemID;

        }

       

        public EntityAgeable createChild1(EntityAgeable var1)

        {

                return null;

        }

        public ItemStack getHeldItem()

        {

        return heldItem;

        }

       

        private static ItemStack heldItem = new ItemStack(Item.swordStone);

        @Override

      protected boolean isValidLightLevel()

{

    return true;

}

}

 

 

And I understand that I need to render getHeldItem, but I can`t for the life of me figure out what exact line of code I would put in.

 

EDIT: So I think I found something that MAY render it, but the this.func_82428_a has an error.

 

RenderNutcracker.java

 

package timescape.render;

 

import java.awt.geom.Arc2D.Float;

 

import timescape.ModelNutcracker;

import timescape.entity.EntityNutcracker;

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

import net.minecraft.client.model.ModelBase;

import net.minecraft.client.model.ModelEnderman;

import net.minecraft.client.renderer.entity.RenderLiving;

import net.minecraft.entity.Entity;

import net.minecraft.entity.EntityLiving;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

 

@SideOnly(Side.CLIENT)

public class RenderNutcracker extends RenderLiving

{

        public RenderNutcracker(ModelNutcracker ModelNutcracker_Test, float f)

        {

                super(new ModelNutcracker(), 0.5F);

        }

        public RenderNutcracker(ModelBase par1ModelBase, float par2)

        {

                super(par1ModelBase, par2);

        }

        public void RenderNutcracker(EntityNutcracker par1EntityNutcracker, double par2, double par4, double par6, float par8, float par9)

        {

                super.doRenderLiving(par1EntityNutcracker, par2, par4, par6, par8, par9);

        }

        public void doRenderLiving(EntityLiving par1EntityLiving, double par2, double par4, double par6, float par8, float par9)

        {

                this.RenderNutcracker((EntityNutcracker)par1EntityLiving, par2, par4, par6, par8, par9);

        }

        public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)

        {

                this.RenderNutcracker((EntityNutcracker)par1Entity, par2, par4, par6, par8, par9);

        }

        protected void renderEquippedItems(EntityLiving par1EntityLiving, float par2)

        {

        this.func_82428_a((EntityNutcracker)par1EntityLiving, par2);

        }

}

 

Posted

So, my friend, if you are talking about HOLDING an ItemStack, you must add, at least, two methods, the EqquipedTems stuff, and the RenderCarrying. You can see they at the EnderMan renderer

 

Look, about that function stuff, you will substitute it to your RenderCarrying, thats the thing, got it?

 

Posted

I took those two things (EquippedItems and RenderCarrying) and I input them into the render***.java class.  This is what it look like:

 

 

package timescape.render;

 

import java.awt.geom.Arc2D.Float;

 

import timescape.ModelNutcracker;

import timescape.entity.EntityNutcracker;

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

import net.minecraft.client.model.ModelBase;

import net.minecraft.client.renderer.entity.RenderLiving;

import net.minecraft.entity.Entity;

import net.minecraft.entity.EntityLiving;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

 

@SideOnly(Side.CLIENT)

public class RenderNutcracker extends RenderLiving

{

        public RenderNutcracker(ModelNutcracker ModelNutcracker_Test, float f)

        {

                super(new ModelNutcracker(), 0.5F);

        }

        public RenderNutcracker(ModelBase par1ModelBase, float par2)

        {

                super(par1ModelBase, par2);

        }

        public void RenderNutcracker(EntityNutcracker par1EntityNutcracker, double par2, double par4, double par6, float par8, float par9)

        {

                super.doRenderLiving(par1EntityNutcracker, par2, par4, par6, par8, par9);

        }

        public void doRenderLiving(EntityLiving par1EntityLiving, double par2, double par4, double par6, float par8, float par9)

        {

                this.RenderNutcracker((EntityNutcracker)par1EntityLiving, par2, par4, par6, par8, par9);

        }

        public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)

        {

                this.RenderNutcracker((EntityNutcracker)par1Entity, par2, par4, par6, par8, par9);

        }

        protected void renderCarrying(EntityNutcracker par1EntityNutcracker, float par2)

        {

            super.renderEquippedItems(par1EntityNutcracker, par2);

}

}

 

 

However, the sword still doesn't render with the mob.

Posted

Heey, now i see that you mean a sword hehe, i will try to explain it

 

 

Well, i dont like messing up with these func12346969 i really dont like them.

But the only thing that i can tell you, is that in the Zombie, when you add that func stuff in the EquipedItems, you add a void method about it also. Example:

 

public void func123 (stuff par1stuff....)

.

.

.

renderEquiperItems(stuff)

func123(blabla)

Posted

I didn't really understand that, so let me clarify exactly what I want to do.

 

I want a custom mob (with custom model) to render(already done), but I want to render a weapon for it at the same time (eg: sword)

 

However, as I don't understand functions either, I would prefer to stay away from them.  There must be another way, like what Newt was talking about.  Could either of you explain what YOU would personally use to render a weapon for a mob?

 

Thanks again for all the help I'm getting.

Posted

Still can't figure it out for the life of me :P

 

If anyone has any ideas about this, please hit me with everything you've got.  ;)

*throws several thermonuclear bombs and a can of Coke at Greenman*

 

I assure you, that would solve your problem, and in fact ensure that you don't have any problems anymore. ;D

BEWARE OF GOD

---

Co-author of Pentachoron Labs' SBFP Tech.

Posted

Still can't figure it out for the life of me :P

 

If anyone has any ideas about this, please hit me with everything you've got.  ;)

*throws several thermonuclear bombs and a can of Coke at Greenman*

 

I assure you, that would solve your problem, and in fact ensure that you don't have any problems anymore. ;D

 

wha...well played Newt, well played.

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

    • Hi, this is my second post with the same content as no one answered this and it's been a long time since I made the last post, I want to make a client-only mod, everything is ok, but when I use shaders, none of the textures rendered in RenderLevelStageEvent nor the crow entity model are rendered, I want them to be visible, because it's a horror themed mod I've already tried it with different shaders, but it didn't work with any of them and I really want to add support for shaders Here is how i render the crow model in the CrowEntityRenderer<CrowEntity>, by the time i use this method, i know is not the right method but i don't think this is the cause of the problem, the renderType i'm using is entityCutout @Override public void render(CrowEntity p_entity, float entityYaw, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource, int packedLight) { super.render(p_entity, entityYaw, partialTick, poseStack, bufferSource, packedLight); ClientEventHandler.getClient().crow.renderToBuffer(poseStack, bufferSource.getBuffer(ClientEventHandler.getClient().crow .renderType(TEXTURE)), packedLight, OverlayTexture.NO_OVERLAY, Utils.rgb(255, 255, 255)); } Here renderLevelStage @Override public void renderWorld(RenderLevelStageEvent e) { horrorEvents.draw(e); } Here is how i render every event public void draw(RenderLevelStageEvent e) { for (HorrorEvent event : currentHorrorEvents) { event.tick(e.getPartialTick()); event.draw(e); } } Here is how i render the crow model on the event @Override public void draw(RenderLevelStageEvent e) { if(e.getStage() == RenderLevelStageEvent.Stage.AFTER_ENTITIES) { float arcProgress = getArcProgress(0.25f); int alpha = (int) Mth.lerp(arcProgress, 0, 255); int packedLight = LevelRenderer.getLightColor(Minecraft.getInstance().level, blockPos); VertexConsumer builder = ClientEventHandler.bufferSource.getBuffer(crow); Crow<CreepyBirdHorrorEvent> model = ClientEventHandler .getClient().crow; model.setupAnim(this); RenderHelper.renderModelInWorld(model, position, offset, e.getCamera(), e.getPoseStack(), builder, packedLight, OverlayTexture.NO_OVERLAY, alpha); builder = ClientEventHandler.bufferSource.getBuffer(eyes); RenderHelper.renderModelInWorld(model, position, offset, e.getCamera(), e.getPoseStack(), builder, 15728880, OverlayTexture.NO_OVERLAY, alpha); } } How i render the model public static void renderModelInWorld(Model model, Vector3f pos, Vector3f offset, Camera camera, PoseStack matrix, VertexConsumer builder, int light, int overlay, int alpha) { matrix.pushPose(); Vec3 cameraPos = camera.getPosition(); double finalX = pos.x - cameraPos.x + offset.x; double finalY = pos.y - cameraPos.y + offset.y; double finalZ = pos.z - cameraPos.z + offset.z; matrix.pushPose(); matrix.translate(finalX, finalY, finalZ); matrix.mulPose(Axis.XP.rotationDegrees(180f)); model.renderToBuffer(matrix, builder, light, overlay, Utils .rgba(255, 255, 255, alpha)); matrix.popPose(); matrix.popPose(); } Thanks in advance
    • Same issue - I have no idea
    • I am trying to develop a modpack for me and my friends to use on our server. Does anyone know how to develop a modpack for a server or could they help take a look at my modpack to potentially help at all?
    • un server de armas realista.  
    • removed both, nope https://pastebin.com/kgtwq9us
  • Topics

×
×
  • Create New...

Important Information

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