Started by
CraftMania41
on
Topic category: Help with Minecraft modding (Java Edition)
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!
I Think Its Not Possible Yet I Think
You can find out how here:
https://mcreator.pylo.co/forum/33841/move-or-enlarge-hitbox-mob
@#2 the way to do it is in the comments of the link, Nuparu's comment to be exact
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?
@#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.
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)
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.
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!
Please show your code.We have small chances to know what is wrong, in case that we can not see your actual tries.
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;
}
}
}
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!
@#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
@#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 ?
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?