Why can't I give my custom mobs items?!

Started by Xzotius on Thu, 08/04/2016 - 03:31

Topic category: Help with MCreator's application

Last seen on 03:38, 4. Aug 2016
Joined Nov 2015
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
Why can't I give my custom mobs items?!
Thu, 08/04/2016 - 03:31

 

I wanted to created a boss fight with a "King Zombie" But I can't because the weapon I wanted to give him (custom) When I give it to him I get a recompilation error!  

 

warning: [options] bootstrap class path not set in conjunction with -source 1.6
C:\Pylo\MCreator169\forge\build\sources\main\java\mod\mcreator\mcreator_zombieKing.java:224: error: processInteract(EntityPlayer,EnumHand,ItemStack) in EntityzombieKing cannot override processInteract(EntityPlayer,EnumHand,ItemStack) in EntityZombie
        protected boolean processInteract(EntityPlayer entity, EnumHand hand, ItemStack stack) {
                          ^
  attempting to assign weaker access privileges; was public
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error
1 warning

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

 

I fixed this in my "Zombie Minion" mob by deleting it and remaking it without the stone sword (please let us remove items from slots so we dont have to restart entire mob!!!)

But to have this mob I MUST let it use my "Zombie Wand" or at least make it APPEAR to be holding it!

 

Console Log:

 

Executing gradle command: clean build
Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.
C:\Pylo\MCreator169>cd forge
C:\Pylo\MCreator169\forge>SET "JAVA_HOME=C:\Pylo\MCreator169\jdk64\"
C:\Pylo\MCreator169\forge>SET JAVA_EXE=%JAVA_HOME%\bin\java.exe
C:\Pylo\MCreator169\forge>SET PATH=%JAVA_HOME%\bin\;%PATH%
C:\Pylo\MCreator169\forge>SET "JAVA_OPTS=-Xmx2526m -Xms1514m"
C:\Pylo\MCreator169\forge>gradlew clean build
#################################################
         ForgeGradle 2.2-SNAPSHOT-0447b4e        
  https://github.com/MinecraftForge/ForgeGradle  
#################################################
               Powered by MCP unknown               
             http://modcoderpack.com             
         by: Searge, ProfMobius, Fesh0r,         
         R4wk, ZeuX, IngisKahn, bspkrs           
#################################################
:clean
:deobfCompileDummyTask
:getVersionJson
:extractUserdev UP-TO-DATE
:downloadClient SKIPPED
:downloadServer SKIPPED
:splitServerJar SKIPPED
:mergeJars SKIPPED
:applyBinaryPatches SKIPPED
:deobfProvidedDummyTask
:extractDependencyATs SKIPPED
:extractMcpData SKIPPED
:extractMcpMappings SKIPPED
:genSrgs SKIPPED
:deobfMcMCP SKIPPED
:sourceApiJava
:compileApiJava UP-TO-DATE
:processApiResources UP-TO-DATE
:apiClasses UP-TO-DATE
:sourceMainJava
C:\Pylo\MCreator169\forge\build\sources\main\java\mod\mcreator\mcreator_zombieKing.java:224: error: processInteract(EntityPlayer,EnumHand,ItemStack) in EntityzombieKing cannot override processInteract(EntityPlayer,EnumHand,ItemStack) in EntityZombie
        protected boolean processInteract(EntityPlayer entity, EnumHand hand, ItemStack stack) {
                          ^
  attempting to assign weaker access privileges; was public
1 error
:compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 11 mins 7.936 secs
C:\Pylo\MCreator169\forge>
Task completed with return code 0 in 680004 milliseconds

 

Code for Zombie King:

 

 

import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.common.registry.EntityRegistry;
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.client.registry.RenderingRegistry;

import net.minecraft.world.biome.Biome;
import net.minecraft.world.World;
import net.minecraft.world.BossInfoServer;
import net.minecraft.world.BossInfo;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.EnumHand;
import net.minecraft.util.DamageSource;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Item;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.Entity;
import net.minecraft.client.renderer.entity.RenderBiped;
import net.minecraft.client.model.ModelZombie;
import net.minecraft.client.Minecraft;

import java.util.Random;
import java.util.Iterator;
import java.util.ArrayList;

@SuppressWarnings("unchecked")
public class mcreator_zombieKing {

    public int mobid = 0;
    public static Object instance;

    public void load(FMLInitializationEvent event) {
    }

    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;
    }

    @SideOnly(Side.CLIENT)
    public void registerRenderers() {
        RenderBiped customRender = new RenderBiped(Minecraft.getMinecraft().getRenderManager(), new ModelZombie(), 0) {
            protected ResourceLocation getEntityTexture(Entity par1Entity) {
                return new ResourceLocation("king_zombie.png");
            }
        };
        customRender.addLayer(new net.minecraft.client.renderer.entity.layers.LayerHeldItem(customRender));
        customRender.addLayer(new net.minecraft.client.renderer.entity.layers.LayerBipedArmor(customRender) {
            protected void initArmor() {
                this.modelLeggings = new ModelZombie();
                this.modelArmor = new ModelZombie();
            }
        });
        RenderingRegistry.registerEntityRenderingHandler(mcreator_zombieKing.EntityzombieKing.class, customRender);
    }

    public void serverLoad(FMLServerStartingEvent event) {
    }

    public void preInit(FMLPreInitializationEvent event) {
        int entityID = MathHelper.getRandomUUID().hashCode();
        mobid = entityID;
        EntityRegistry.registerModEntity(mcreator_zombieKing.EntityzombieKing.class, "zombieKing", entityID, instance, 64, 1, true, (0 << 16)
                + (102 << 8) + 0, (255 << 16) + (153 << 8) + 0);
        EntityRegistry.addSpawn(mcreator_zombieKing.EntityzombieKing.class, 0, 0, 30, EnumCreatureType.MONSTER, clean(Biome.REGISTRY));

    }

    public static Biome[] clean(net.minecraft.util.registry.RegistryNamespaced<ResourceLocation, Biome> in) {
        Iterator<Biome> itr = in.iterator();
        ArrayList<Biome> ls = new ArrayList<Biome>();
        while (itr.hasNext()) {
            ls.add(itr.next());
        }
        return ls.toArray(new Biome[ls.size()]);
    }

    /*
     * public Entity spawnEntity(int var1, World var2, double var3, double var5,
     * double var7) { if(var1==mobid) return new
     * mcreator_zombieKing.EntityzombieKing(var2); else return null; }
     */

    public static class EntityzombieKing extends EntityZombie {
        World world = null;

        public EntityzombieKing(World var1) {
            super(var1);
            world = var1;
            experienceValue = 50;
            this.isImmuneToFire = true;
            addRandomArmor();
            setNoAI(!true);

        }

        protected void addRandomArmor() {

            this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(mcreator_zombieWand.block));
        }

        @Override
        public boolean isNonBoss() {
            return false;
        }

        private final BossInfoServer bossInfo = (BossInfoServer) (new BossInfoServer(this.getDisplayName(), BossInfo.Color.RED,
                BossInfo.Overlay.PROGRESS));

        @Override
        public void addTrackingPlayer(EntityPlayerMP player) {
            super.addTrackingPlayer(player);
            this.bossInfo.addPlayer(player);
        }

        @Override
        public void removeTrackingPlayer(EntityPlayerMP player) {
            super.removeTrackingPlayer(player);
            this.bossInfo.removePlayer(player);
        }

        @Override
        public void onUpdate() {
            super.onUpdate();
            this.bossInfo.setPercent(this.getHealth() / this.getMaxHealth());
        }

        protected void dropRareDrop(int par1) {
            this.dropItem(new ItemStack(mcreator_zombieChrystal.block).getItem(), 1);
        }

        @Override
        protected Item getDropItem() {
            return new ItemStack(mcreator_zombieWand.block).getItem();
        }

        @Override
        protected net.minecraft.util.SoundEvent getAmbientSound() {
            return (net.minecraft.util.SoundEvent) net.minecraft.util.SoundEvent.REGISTRY.getObject(new ResourceLocation("entity.zombie.ambient"));
        }

        @Override
        protected net.minecraft.util.SoundEvent getHurtSound() {
            return (net.minecraft.util.SoundEvent) net.minecraft.util.SoundEvent.REGISTRY.getObject(new ResourceLocation("entity.zombie.hurt"));
        }

        @Override
        protected net.minecraft.util.SoundEvent getDeathSound() {
            return (net.minecraft.util.SoundEvent) net.minecraft.util.SoundEvent.REGISTRY.getObject(new ResourceLocation("entity.zombie.death"));
        }

        @Override
        public void onStruckByLightning(EntityLightningBolt entityLightningBolt) {
            super.onStruckByLightning(entityLightningBolt);
            int i = (int) this.posX;
            int j = (int) this.posY;
            int k = (int) this.posZ;
            Entity entity = this;

        }

        @Override
        public void fall(float l, float d) {
            super.fall(l, d);
            int i = (int) this.posX;
            int j = (int) this.posY;
            int k = (int) this.posZ;
            super.fall(l, d);
            Entity entity = this;

        }

        @Override
        public void onDeath(DamageSource source) {
            super.onDeath(source);
            int i = (int) this.posX;
            int j = (int) this.posY;
            int k = (int) this.posZ;
            Entity entity = this;

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

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

            if ((Math.random() * 100) <= 20) {
                Entity sentity = EntityList.createEntityByName("zombieMinion", world);
                if (sentity != null && !world.isRemote) {
                    sentity.setLocationAndAngles(i, j, k, world.rand.nextFloat() * 360F, 0.0F);
                    world.spawnEntityInWorld(sentity);
                    ((EntityLiving) sentity).playLivingSound();
                }
            }

        }

        @Override
        protected boolean processInteract(EntityPlayer entity, EnumHand hand, ItemStack stack) {
            super.processInteract(entity, hand, stack);
            int i = (int) this.posX;
            int j = (int) this.posY;
            int k = (int) this.posZ;

            return true;
        }

        @Override
        protected float getSoundVolume() {
            return 1.0F;
        }

    }

}

Thanks for reading and/or helping!

 

Last seen on 04:31, 22. Aug 2019
Joined Mar 2015
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
  • wiki contributor
  • moderator
You AI and the items don't
Sat, 08/06/2016 - 07:26

You AI and the items don't like each other it seems...