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

Jumping Mob


DoorCloser
 Share

Recommended Posts

I just want my mob to LEAP or JUMP on me when it gets as NEAR as CODE says. OTHERWISE my MOB is just going to WALK! Here is the damn code.

 

 

package halflifemod.entity.monster;

 

import net.minecraft.entity.EntityLiving;

import net.minecraft.entity.monster.IMob;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.item.Item;

import net.minecraft.nbt.NBTTagCompound;

import net.minecraft.util.DamageSource;

import net.minecraft.util.MathHelper;

import net.minecraft.world.World;

import net.minecraft.world.WorldType;

import net.minecraft.world.biome.BiomeGenBase;

import net.minecraft.world.chunk.Chunk;

 

public class EntityHeadcrab extends EntityLiving implements IMob

{

    /** Chances for slimes to spawn in swamps for every moon phase. */

    private static final float[] spawnChances = new float[] {1.0F, 0.75F, 0.5F, 0.25F, 0.0F, 0.25F, 0.5F, 0.75F};

    public float field_70813_a;

    public float field_70811_b;

    public float field_70812_c;

 

    /** the time between each jump of the slime */

    private int slimeJumpDelay = 0;

 

    public EntityHeadcrab(World par1World)

    {

        super(par1World);

        this.texture = "/mob/HL/Headcrab.png";

        int i = 1 << this.rand.nextInt(3);

        this.yOffset = 0.0F;

        this.slimeJumpDelay = this.rand.nextInt(20) + 10;

    }

 

    protected void entityInit()

    {

        super.entityInit();

        this.dataWatcher.addObject(16, new Byte((byte)1));

    }

 

    protected void setSlimeSize(int par1)

    {

        this.dataWatcher.updateObject(16, new Byte((byte)par1));

        this.setSize(0.6F * (float)par1, 0.6F * (float)par1);

        this.setPosition(this.posX, this.posY, this.posZ);

        this.setEntityHealth(this.getMaxHealth());

        this.experienceValue = par1;

    }

 

    public int getMaxHealth()

    {

        return 3;

    }

 

 

    /**

    * (abstract) Protected helper method to write subclass entity data to NBT.

    */

    public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)

    {

        super.writeEntityToNBT(par1NBTTagCompound);

       

    }

 

    /**

    * (abstract) Protected helper method to read subclass entity data from NBT.

    */

    public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)

    {

        super.readEntityFromNBT(par1NBTTagCompound);

       

    }

 

    /**

    * Returns the name of a particle effect that may be randomly created by EntitySlime.onUpdate()

    */

    protected String getSlimeParticle()

    {

        return "slime";

    }

 

    /**

    * Returns the name of the sound played when the slime jumps.

    */

    protected String getJumpSound()

    {

        return "mob.slime.big";

    }

 

    /**

    * Called to update the entity's position/logic.

    */

    public void onUpdate()

    {

        if (!this.worldObj.isRemote && this.worldObj.difficultySetting == 0)

        {

            this.isDead = true;

        }

 

        this.field_70811_b += (this.field_70813_a - this.field_70811_b) * 0.5F;

        this.field_70812_c = this.field_70811_b;

        boolean flag = this.onGround;

        super.onUpdate();

        int i;

 

        if (this.onGround && !flag)

        {

 

            for (int j = 0; j < 8; ++j)

            {

                float f = this.rand.nextFloat() * (float)Math.PI * 2.0F;

                float f1 = this.rand.nextFloat() * 0.5F + 0.5F;

                float f2 = MathHelper.sin(f) * 0.5F * f1;

                float f3 = MathHelper.cos(f) * 0.5F * f1;

            }

 

            if (this.makesSoundOnLand())

            {

                this.playSound(this.getJumpSound(), this.getSoundVolume(), ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F) / 0.8F);

            }

 

            this.field_70813_a = -0.5F;

        }

        else if (!this.onGround && flag)

        {

            this.field_70813_a = 1.0F;

        }

 

        this.func_70808_l();

 

   

        }

   

 

    protected void updateEntityActionState()

    {

        this.despawnEntity();

        EntityPlayer entityplayer = this.worldObj.getClosestVulnerablePlayerToEntity(this, 3.0D);

 

        if (entityplayer != null)

        {

            this.faceEntity(entityplayer, 10.0F, 20.0F);

        }

 

        if (this.onGround && this.slimeJumpDelay-- <= 0)

        {

            this.slimeJumpDelay = this.getJumpDelay();

 

            if (entityplayer != null)

            {

                this.slimeJumpDelay /= 3;

                this.isJumping = true;

            }

 

            if (this.makesSoundOnJump())

            {

                this.playSound(this.getJumpSound(), this.getSoundVolume(), ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F) * 0.8F);

            }

 

            this.moveStrafing = 1.0F - this.rand.nextFloat() * 2.0F;

            this.moveForward = (float)(1);

        }

        else

        {

            this.isJumping = false;

 

            if (this.onGround)

            {

                this.moveSpeed = 0.5F;

            }

        }

    }

 

    protected void func_70808_l()

    {

        this.field_70813_a *= 0.6F;

    }

 

    /**

    * Gets the amount of time the slime needs to wait between jumps.

    */

    protected int getJumpDelay()

    {

        return this.rand.nextInt(20) + 10;

    }

 

    protected EntityHeadcrab createInstance()

    {

        return new EntityHeadcrab(this.worldObj);

    }

    /**

    * Called by a player entity when they collide with an entity

    */

    public void onCollideWithPlayer(EntityPlayer par1EntityPlayer)

    {

        if (this.canDamagePlayer())

        {

           

 

            if (this.canEntityBeSeen(par1EntityPlayer) && this.getDistanceSqToEntity(par1EntityPlayer) < 0.6D * 0.6D && par1EntityPlayer.attackEntityFrom(DamageSource.causeMobDamage(this), this.getAttackStrength()))

            {

                this.playSound("mob.attack", 1.0F, (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F);

            }

        }

    }

 

    /**

    * Indicates weather the slime is able to damage the player (based upon the slime's size)

    */

    protected boolean canDamagePlayer()

    {

        return true;

    }

 

    /**

    * Gets the amount of damage dealt to the player when "attacked" by the slime.

    */

    protected int getAttackStrength()

    {

        return 3;

    }

 

    /**

    * Returns the sound this mob makes when it is hurt.

    */

    protected String getHurtSound()

    {

        return "mob.slime.big";

    }

 

    /**

    * Returns the sound this mob makes on death.

    */

    protected String getDeathSound()

    {

        return "mob.slime.big";

    }

 

    /**

    * Returns the item ID for the item the mob drops on death.

    */

    protected int getDropItemId()

    {

        return Item.slimeBall.itemID;

    }

 

    /**

    * Returns the volume for the sounds this mob makes.

    */

    protected float getSoundVolume()

    {

        return 0.4F;

    }

 

    /**

    * The speed it takes to move the entityliving's rotationPitch through the faceEntity method. This is only currently

    * use in wolves.

    */

    public int getVerticalFaceSpeed()

    {

        return 0;

    }

 

    /**

    * Returns true if the slime makes a sound when it jumps (based upon the slime's size)

    */

    protected boolean makesSoundOnJump()

    {

        return true;

    }

 

    /**

    * Returns true if the slime makes a sound when it lands after a jump (based upon the slime's size)

    */

    protected boolean makesSoundOnLand()

    {

        return true;

    }

}

 

 

 

 

I've MADE my MOB to PERFORM JUMPING ACTIONS, but he DOESNT WALK. I TRIED to USE the moveSpeed METHOD, but that DIDNT WORKS. It only READS moveForward and moveStarfing. MAYBE thats because of AIDISABLED. I havent enabled it's AI because code WOULDNT WORK! WHAT I SUPPOSE TO DO. HOW CAN I MAKE MY MOB TO PERFORM JUMP ACTIONS WHEN HE GETS AS NEAR AS CODE SAYS, BUT OTHERWISE MOB WILL JUST WALK AFTER ME!

 

CAN ANYBODY HELP!?

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • you need to check if the EventHandler is called
    • update Forge to the latest version 1.16.5 requires java 8
    • C:\Users\(My Name)\Desktop\Clockwise server>java -Xmx10240M -Xms10240M -jar forgeserver.jar nogui 2022-05-26 12:35:05,381 main WARN Advanced terminal features are not available in this environment [12:35:05] [main/INFO] [cp.mo.mo.Launcher/MODLAUNCHER]: ModLauncher running: args [--gameDir, ., --launchTarget, fmlserver, --fml.forgeVersion, 36.1.30, --fml.mcpVersion, 20210115.111550, --fml.mcVersion, 1.16.5, --fml.forgeGroup, net.minecraftforge, nogui] [12:35:05] [main/INFO] [cp.mo.mo.Launcher/MODLAUNCHER]: ModLauncher 8.0.9+86+master.3cf110c starting: java version 1.8.0_333 by Oracle Corporation [12:35:06] [main/INFO] [ne.mi.fm.lo.FixSSL/CORE]: Added Lets Encrypt root certificates as additional trust [12:35:06] [main/INFO] [mixin/]: SpongePowered MIXIN Subsystem Version=0.8.2 Source=file:/C:/Users/Joshua%20Hague/Desktop/Clockwise%20server/libraries/org/spongepowered/mixin/0.8.2/mixin-0.8.2.jar Service=ModLauncher Env=SERVER [12:35:06] [main/WARN] [ne.mi.fm.lo.FMLConfig/CORE]: Configuration file C:\Users\Joshua Hague\Desktop\Clockwise server\config\fml.toml is not correct. Correcting [12:35:06] [main/WARN] [ne.mi.fm.lo.FMLConfig/CORE]: Incorrect key [defaultConfigPath] was corrected from null to defaultconfigs [12:35:06] [main/INFO] [cp.mo.mo.LaunchServiceHandler/MODLAUNCHER]: Launching target 'fmlserver' with arguments [--gameDir, ., nogui] Exception in thread "main" [12:35:07] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]: java.lang.NoSuchMethodError: sun.security.util.ManifestEntryVerifier.<init>(Ljava/util/jar/Manifest;)V [12:35:07] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at cpw.mods.modlauncher.SecureJarHandler.createCodeSource(SecureJarHandler.java:66) [12:35:07] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at cpw.mods.modlauncher.TransformingClassLoader$DelegatedClassLoader.findClass(TransformingClassLoader.java:275) [12:35:07] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at cpw.mods.modlauncher.TransformingClassLoader.loadClass(TransformingClassLoader.java:136) [12:35:07] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at cpw.mods.modlauncher.TransformingClassLoader.loadClass(TransformingClassLoader.java:98) [12:35:07] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at java.lang.ClassLoader.loadClass(Unknown Source) [12:35:07] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at java.lang.Class.forName0(Native Method) [12:35:07] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at java.lang.Class.forName(Unknown Source) [12:35:07] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at net.minecraftforge.fml.loading.FMLServerLaunchProvider.lambda$launchService$0(FMLServerLaunchProvider.java:51) [12:35:07] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [12:35:07] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [12:35:07] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [12:35:07] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at cpw.mods.modlauncher.Launcher.run(Launcher.java:82) [12:35:07] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at cpw.mods.modlauncher.Launcher.main(Launcher.java:66) [12:35:07] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at net.minecraftforge.server.ServerMain$Runner.runLauncher(ServerMain.java:63) [12:35:07] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at net.minecraftforge.server.ServerMain$Runner.access$100(ServerMain.java:60) [12:35:07] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at net.minecraftforge.server.ServerMain.main(ServerMain.java:57) C:\Users\(My Name)\Desktop\Clockwise server>PAUSE Tried it again with just Java version 8 update 333, still nothing.
    • package com.zaksen.fancydecorativeblocks; import com.zaksen.fancydecorativeblocks.screen.FancyMenuTypes; import com.zaksen.fancydecorativeblocks.screen.WoodCrateScreen; import net.minecraft.client.gui.screens.MenuScreens; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; @Mod.EventBusSubscriber(modid = FancyDecorativeBlocks.MOD_ID) public class ClientSetup { @SubscribeEvent public static void clientSetup(final FMLClientSetupEvent Event) { Runnable runnable = new Runnable() { @Override public void run() { MenuScreens.register(FancyMenuTypes.WOOD_CRATE_MENU.get(), WoodCrateScreen::new); } }; Event.enqueueWork(runnable); } } I create new class for it, but how i need call it?
    • Hey thanks for the reply So I can't exactly remove mods from the modpack without causing severe problems with the world so I just tried increasing the max-tick-time and found out it happens between these lines   [26May2022 20:15:49.384] [Server thread/DEBUG] [mixin/]: Mixing MixinNetworkItemManager from creativewirelesstransmitter.mixins.json into com.refinedmods.refinedstorage.apiimpl.network.item.NetworkItemManager [26May2022 20:19:51.050] [Server thread/DEBUG] [mixin/]: Mixing MixinBlockEntityExtension from architectury.mixins.json into me.shedaniel.architectury.extensions.BlockEntityExtension Here's the full debug.log, had to shorten it a little cause it was too big for pastebin so I cut the start out, if you need it I can also send it Also because I increased the max-tick-time it didn't crash but I dont wanna keep it that way since a 4 minute tick has to have an explanation. So any idea of how to fix this?
  • Topics

×
×
  • Create New...

Important Information

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