Started by
UtahPlaysYT
on
Topic category: Help with Minecraft modding (Java Edition)
I am trying to make a tamed mob sit. I have created 2 different entity's one that can't move and one that will follow once tamed! However when i make it so it follows me again i need to re-tame it as its going to a different entity's is their anyway i can make it force tame to the closes player so i can tell it to sit and follow?
Thanks!
There is no need to make two different mobs, taming is built into MCreator. I believe it's in the AI part of the mob creator. There will be no sitting model though, it will have the same model :/
However, if you ignore everything I just said I think there is a "Tame [entity] to [entity]" procedure block
would it be like right clicked to sit as there is:
Breed
Hurt entitys that hurt player
Hurt entitys that player attacked
Follow playr with a speed factor of.. minimal distance ... Maximal distance if tamed
Follow parents if animal
there is no right click to sit or anything :/
Sorry im still getting used to Mcreator xD
Hi i have had a look and it doesn't say anywhere a sit command? if you could send a screen shot of what i should be using i would appericate that :)
Thanks!
There is no sit.
I think the main problem is that the wolf entity is specifically made to handle sit commands, same with cats. So if you have a custom entity it doesn't work.
I'm a bit late, but something you can try is setting a logic NBT tag on the mob called "sitting" and then set it to false or true when you click it, then set the condition to start/continue wandering around to "return: not sitting" so they will only wander around when not sitting. For a different model maybe you can make an animation where the mob is only sitting and play it with geckolib when sitting is true.
I have a simple solution using procedures:
create a true or false variable for this for the example it will be sitting
Now if the function:
When you right-click the entity:
If sitting = false do:
Give current entity slowness 7 (totally immobile even with speed) for (VERY long as 999999999999999999 or more), set sitting to false
If not: remove slowness on entity, set sitting to true
Of course, the texture and appearance will be the same, but you can try to use geckolib (it did not work for me) or add custom particles for when you are sitting.
how to put an animation when it sits? (when mcreator's built-in taming is activated)
How to make your Tameable mob to Sit:
-First off dont use the MCreator Tame option, dont select it. Open the code to Edit:
add these libraries:
import net.minecraft.util.Hand;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.ai.goal.SitGoal;
import net.minecraft.entity.passive.TameableEntity;
2) on this line:
public static class CustomEntity extends TameableEntity <---- change AnimalEntity or wtv to TameableEntity
3) add these 2 behaviors: (more if you want it to follow owner and stuff, but u can set these others on Mcreator entity creation)
this.sitGoal = new SitGoal(this);
this.goalSelector.addGoal(1, this.sitGoal);
4) add this code part BELOW your behaviors:
// TAME CODE
public void setTamed(boolean tamed) {
super.setTamed(tamed);
// whatever you want your mob to do when it's tamed e.g. the wolf's class uses
// this to increase the mob's max health to 20 if it's tamed
}
public boolean processInteract(PlayerEntity player, Hand handIn) {
ItemStack itemstack = player.getHeldItem(handIn);
if (!this.isTamed() && itemstack.getItem() == Items.MELON_SLICE && !this.isBreedingItem(itemstack)) { // <--- Tame Item (can be different from breeding one)
if (!player.abilities.isCreativeMode) {
itemstack.shrink(1);
}
if (!this.world.isRemote) {
if (this.rand.nextInt(3) == 0 && !net.minecraftforge.event.ForgeEventFactory.onAnimalTame(this, player)) {
this.setTamedBy(player);
this.navigator.clearPath();
this.setAttackTarget((LivingEntity) null);
this.sitGoal.setSitting(true);
this.setHealth(30.0F);
this.playTameEffect(true);
this.world.setEntityState(this, (byte) 7);
} else {
this.playTameEffect(false);
this.world.setEntityState(this, (byte) 6);
}
}
return true;
} else if (this.isOwner(player) && !this.world.isRemote && !this.isBreedingItem(itemstack)) {
this.sitGoal.setSitting(!this.isSitting());
this.isJumping = false;
this.navigator.clearPath();
this.setAttackTarget((LivingEntity) null);
return true;
}
return super.processInteract(player, handIn);
}
// TAME CODE END
5) add this part, just above the Rotation animations, at the very end of the file:
public void setLivingAnimations(Entity entityIn, float limbSwing, float limbSwingAmount, float partialTickTime) {
if (((ChimpanzeEntity.CustomEntity) entityIn).isSitting()) { //<--------- your entity NAME here, put it right or it will crash
//here you set your rotations when its sitting, like
this.BodyBack.setRotationPoint(0F, 13.5F, 4F);
this.BodyBack.rotateAngleX = -1.047198F; }
} else { // <----------- here set the animations when its not sitting, moving;
this.DownLeg2.setRotationPoint(2F, 15F, 7F);
this.Foot2.setRotationPoint(2F, 15F, 7F);
this.UpperLeg1.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F) * 1.4F * limbSwingAmount - 0.0872665F;
this.DownLeg1.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F) * 1.4F * limbSwingAmount - 0.0872665F;
//etc...
}
}
6) finally remove the animations you put here, from the last part of the file (you dont need them in 2 places)
remember, even thou you dont need 2 entities, you still need to make another model (the sitting one), then just export the java, open on notepad++ and copy the RotationPoints and RotationAngles that DIFFER when the mob is Sitting or Moving.
btw this do not work for 1.16 anymore.. they change the code so much i will prb take ages to update my mod :(
Sitting pets will still teleport to me though
Step 1
Create an entity tameable
Step 2
Create a procedure
- return { NBT logic "follow"
Step 3
At AI and goals set "follow Owner" an press condition, there, use the procedure of step 2
Step 4
At Triggers, "When right click on the entity" create a procedure
- if{ nbt logic "follow" = true
Do( set nbt logic "follow" false
- else{ set nbt logic "follow" true
With that, the entity is going to follow or not, but it hasn't animation or changed model
I know I'm late. But i don't understand how to do it (I'm new in mcreator), can someone send screenshot of the procedure i should do to sit my pet?
PD: Sorry for my english, It isn't my native language.