Help With mob Please

Started by revmykl777 on

Topic category: Help with MCreator software

Last seen on 02:37, 18. Sep 2023
Joined Oct 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Help With mob Please

Did not see this exact issue elsewhere, so forgive me if it has already been discussed.

MCreator Version 1.6.9 for 1.9.4

I have created a new mob, no problem. Custom texture on the prebuilt biped setting. AI works great. Spawns fine with use of a spawn egg. The problem is when I tried to make an Item to spawn the mob with, it will not spawn. It has 3 events in the "when right clicked on block" option.

Event 1: Spawn Entity (Does not work)

Event 2: Remove item from inventory (works)

Event 3: Add item to inventory (works)

 

I don't get any errors when compiling, I am at a loss....

 

Thanks in advance for any help

Last seen on 02:37, 18. Sep 2023
Joined Oct 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
No help huh? Well, guess I'll
Wed, 07/20/2016 - 18:05

No help huh? Well, guess I'll just keep hacking away till i figure it out....

Last seen on 00:44, 29. Nov 2022
Joined Dec 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
does it spawn the entity but
Wed, 07/20/2016 - 18:53

does it spawn the entity but the entity doesn't do anything, or is there no entity at all.

Last seen on 02:37, 18. Sep 2023
Joined Oct 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:does it spawn the entity but
Fri, 07/22/2016 - 17:33

No entity at all. I even set the item to I'm using to spawn the mob to be consumed after spawning, and it gets consumed just fine. The spawn egg that gets created when you make a mob, will spawn the mob just fine, it will use the proper AI and everything. But this item I made will not spawn the mob.

Last seen on 00:44, 29. Nov 2022
Joined Dec 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
can i see the code for your
Fri, 07/22/2016 - 18:57

can i see the code for your item

Last seen on 02:37, 18. Sep 2023
Joined Oct 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:can i see the code for your
Fri, 07/22/2016 - 21:42

@#4   Here it is, hope you can find the issue

. Thanks for the help

package mod.mcreator;

import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;

import net.minecraft.world.World;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumHand;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumActionResult;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Item;
import net.minecraft.init.Items;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.Entity;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.Minecraft;
import net.minecraft.block.state.IBlockState;
import net.minecraft.block.Block;

import java.util.Set;
import java.util.Random;
import java.util.List;

@SuppressWarnings("unchecked")
public class mcreator_cardLesserFireElemental {

    public mcreator_cardLesserFireElemental() {
    }

    public static Item block;
    public static Object instance;

    public void load(FMLInitializationEvent event) {
        if (event.getSide() == Side.CLIENT)
            Minecraft.getMinecraft().getRenderItem().getItemModelMesher()
                    .register(block, 0, new ModelResourceLocation("TestEnvironmentMod:CardLesserFireElemental", "inventory"));

        GameRegistry.addRecipe(
                new ItemStack(block, 1),
                new Object[]{"012", "345", "678", Character.valueOf('0'), Items.MAGMA_CREAM, Character.valueOf('1'), Items.COAL,
                        Character.valueOf('2'), Items.MAGMA_CREAM, Character.valueOf('3'), Items.COAL, Character.valueOf('4'), Items.PAPER,
                        Character.valueOf('5'), Items.COAL, Character.valueOf('6'), mcreator_sparkOfFire.block, Character.valueOf('7'),
                        mcreator_sparkOfFire.block, Character.valueOf('8'), mcreator_sparkOfFire.block,});
    }

    public void generateNether(World world, Random random, int chunkX, int chunkZ) {
    }

    public void generateSurface(World world, Random random, int chunkX, int chunkZ) {
    }

    public int addFuel(ItemStack fuel) {
        return 0;
    }

    public void serverLoad(FMLServerStartingEvent event) {
    }

    public void preInit(FMLPreInitializationEvent event) {
    }

    public void registerRenderers() {
    }

    static {
        block = (new ItemcardLesserFireElemental(435));

    }

    static class ItemcardLesserFireElemental extends Item {

        public ItemcardLesserFireElemental(int par1) {
            setMaxDamage(0);
            maxStackSize = 64;
            setUnlocalizedName("CardLesserFireElemental");
            GameRegistry.registerItem(this, "CardLesserFireElemental");
            setCreativeTab(mcreator_overworldCards.tab);
        }

        @Override
        public int getItemEnchantability() {
            return 0;
        }

        @Override
        public int getMaxItemUseDuration(ItemStack par1ItemStack) {
            return 0;
        }

        @Override
        public float getStrVsBlock(ItemStack par1ItemStack, IBlockState par2Block) {
            return 1.0F;
        }

        public EnumActionResult onItemUseFirst(ItemStack itemStack, EntityPlayer entity, World world, BlockPos pos, EnumFacing side, float hitX,
                float hitY, float hitZ, EnumHand hand) {
            float var4 = 1.0F;
            int i = pos.getX();
            int j = pos.getY();
            int k = pos.getZ();

            if (true) {
                Entity sentity = EntityList.createEntityByName("fireElementalLesser", world);
                if (sentity != null && !world.isRemote) {
                    sentity.setLocationAndAngles(i, j + 1, k + 1, world.rand.nextFloat() * 360F, 0.0F);
                    world.spawnEntityInWorld(sentity);
                    ((EntityLiving) sentity).playLivingSound();
                }
            }

            if (true) {
                if (entity instanceof EntityPlayer)
                    ((EntityPlayer) entity).inventory.clearMatchingItems(mcreator_cardLesserFireElemental.block, -1, 1, null);
            }

            if (true) {
                if (entity instanceof EntityPlayer)
                    ((EntityPlayer) entity).inventory.addItemStackToInventory(new ItemStack(mcreator_sparkOfFire.block, 1));
            }

            return EnumActionResult.PASS;
        }

        @Override
        public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List list, boolean par4) {
            list.add("Name:Lesser Fire Elemental");
            list.add("Set: Overworld");
            list.add("Type: Summoning Fire");
            list.add("Rarity: Rare");
            list.add("Summons a Lesser Fire Elemental");
            list.add("to fight for you and protect you");
        }

    }
}