How do you change the hitbox size?

Started by CraftMania41 on

Topic category: Help with modding (Java Edition)

Last seen on 18:03, 10. Nov 2017
Joined Jan 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How do you change the hitbox size?

Hello, I am creating a mod that contains mobs that are bigger tha any other mobs (Exepted the Ender Dragon) But the hitbox is still the size of a human. How can i make it the size I want? If somone could help me it would be nice! Thanks in advance!

Last seen on 10:56, 19. Feb 2017
Joined Mar 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I Think Its Not Possible Yet
Tue, 02/14/2017 - 11:01

I Think Its Not Possible Yet I Think

Last seen on 22:44, 19. May 2021
Joined Jan 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:You can find out how here:
Tue, 02/14/2017 - 19:56

@#2 the way to do it is in the comments of the link, Nuparu's comment to be exact

Last seen on 18:03, 10. Nov 2017
Joined Jan 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thanks for responding! I saw
Wed, 02/15/2017 - 00:44

Thanks for responding! I saw the page you told me, and I think it may be the way i searched for! But Could you tell me how the size works? he said " this.setSize(0.6F, 1.95F) " But 0.6F = What dimension in minecraft? and also, what is "constructor" he was talking about?

 

Last seen on 22:44, 19. May 2021
Joined Jan 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:Thanks for responding! I saw
Thu, 02/16/2017 - 02:59

@#3 i am not actually sure about that. for my mob, Sachiel, i spawned it and trapped it in and built a tower to compare it's height and in minecraft blocks, i believe it should be about double (or the same as) the mob's height in blocks.

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

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
 
Thu, 02/16/2017 - 12:49

 

 

the constructor looks like this 

 

public Entitytest(World var1) {
            super(var1);
            world = var1;
            experienceValue = 5;
            this.isImmuneToFire = false;
            addRandomArmor();
            setNoAI(!true);
            this.tasks.addTask(0, new EntityAISwimming(this));
            this.tasks.addTask(6, new EntityAIWander(this, 1.0D));
            this.tasks.addTask(8, new EntityAILookIdle(this));

        }

this is where the mods class is contructed.

to change the hitbox add this.setSize(0.6F, 1.95F) here...

public Entitytest(World var1) {
            super(var1);

            this.setSize(0.6F, 1.95F)
            world = var1;
            experienceValue = 5;
            this.isImmuneToFire = false;
            addRandomArmor();
            setNoAI(!true);
            this.tasks.addTask(0, new EntityAISwimming(this));
            this.tasks.addTask(6, new EntityAIWander(this, 1.0D));
            this.tasks.addTask(8, new EntityAILookIdle(this));

        }

and this.setSize(0.6F, 1.95F) means that the first number is across and the second is up and down. For example a hitbox that is exally one block would be this.setSize(1F, 1F)

Last seen on 18:03, 10. Nov 2017
Joined Jan 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thanks again! I found the
Thu, 02/16/2017 - 22:23

Thanks again! I found the constructor but... Sadly, it doesn't work for me ;-; I am going to try to experiment a bit and i'll tell you if it works. 

Last seen on 18:03, 10. Nov 2017
Joined Jan 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
It's still not working, and I
Sat, 02/18/2017 - 17:21

It's still not working, and I can't figure out what's wrong... So if you could tell me or help me with the code it would be nice! Hope you will answer!

 

Last seen on 17:17, 10. Jan 2024
Joined Aug 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Please show your code.We have
Sat, 02/18/2017 - 18:15

Please show your code.We have small chances to know what is wrong, in case that we can not see your actual tries.

Last seen on 18:03, 10. Nov 2017
Joined Jan 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
 
Sat, 02/18/2017 - 18:29

 

Here is the code of the mob, if you need something else tell me what and i'll show it to you!

 

 

 

package mod.mcreator;

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.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.entity.player.EntityPlayer;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.Entity;
import net.minecraft.client.renderer.entity.RenderBiped;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.Minecraft;

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

@SuppressWarnings("unchecked")
public class mcreator_mobTest {

    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 ModelBiped(), 0, 0) {
            protected ResourceLocation getEntityTexture(Entity par1Entity) {
                return new ResourceLocation("templateman.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 ModelBiped();
                this.modelArmor = new ModelBiped();
            }
        });
        RenderingRegistry.registerEntityRenderingHandler(mcreator_mobTest.EntitymobTest.class, customRender);

    }

    public void serverLoad(FMLServerStartingEvent event) {
    }

    public void preInit(FMLPreInitializationEvent event) {
        int entityID = MathHelper.getRandomUUID().hashCode();
        mobid = entityID;
        EntityRegistry.registerModEntity(mcreator_mobTest.EntitymobTest.class, "mobTest", entityID, instance, 64, 1, true, (204 << 16) + (204 << 8)
                + 204, (102 << 16) + (102 << 8) + 102);
        EntityRegistry.addSpawn(mcreator_mobTest.EntitymobTest.class, 20, 3, 30, EnumCreatureType.CREATURE, 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 static class EntitymobTest extends EntityCreature {
        World world = null;

        public EntitymobTest(World var1) {
            super(var1);

               this.setSize(0.6F, 1.95F);
            world = var1;
            experienceValue = 5;
            this.isImmuneToFire = false;
            addRandomArmor();
            setNoAI(!true);
            this.tasks.addTask(0, new EntityAISwimming(this));
            this.tasks.addTask(6, new EntityAIWander(this, 1.0D));
            this.tasks.addTask(8, new EntityAILookIdle(this));

        }

        protected void applyEntityAttributes() {
            super.applyEntityAttributes();
            this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.25D);
            this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(10D);
            if (this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE) != null)
                this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(3D);
        }

        protected void addRandomArmor() {

        }

        @Override
        protected Item getDropItem() {
            return null;
        }

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

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

        @Override
        protected net.minecraft.util.SoundEvent getDeathSound() {
            return (net.minecraft.util.SoundEvent) net.minecraft.util.SoundEvent.REGISTRY.getObject(new ResourceLocation("game.neutral.die"));
        }

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

        }

        @Override
        public 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;
        }

    }

}

Last seen on 20:11, 10. Nov 2017
Joined Feb 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You should maybe try to
Fri, 02/24/2017 - 01:06

You should maybe try to change the " this.setSize(0.6F, 1.95F);" of place because it may not be able to use it at the place it is right now. But I didn't tested soo if it does not work I can't help you anymore... Hope you will find!

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

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE: 
Fri, 02/24/2017 - 01:53

@#8 Did you directly copy the chunk of code i gave you? That would make problems if other parts of the code are set differently, when it comes to AI

Last seen on 18:03, 10. Nov 2017
Joined Jan 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:RE: 
Sat, 02/25/2017 - 00:35

@#8.1 No I just copied the bit of code (this.setSize(0.6F, 1.95F)) in my codes... I don't need to copy everything, do I ?

Last seen on 05:28, 9. Apr 2020
Joined Jul 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Hey,ahig, i need help. I…
Sat, 12/02/2017 - 23:32

Hey,ahig, i need help. I think i know where to put the setsize thingy, but... how do i set the mob height to where it can fit a 1 block hole?