Started by
ninjawizard1234
on
Topic category: Help with Minecraft modding (Java Edition)
Hey guys! long time no see you all (i had another acount but i lost the password, tried to reset it and could not, so i made a new acount)
Im trying to update my mod from 1.16 to 1.20 (from Mcreator 2020 to 2023), after regenerating the code, the breed/taming items got somehow mixed, so now just one work (the berry), the apple was supose to tame and the berry breed, idk what im missing here, here is my Entity main file:
import java.util.List;
public class CapuchinWhiteHeadEntity extends TamableAnimal {
public CapuchinWhiteHeadEntity(PlayMessages.SpawnEntity packet, Level world) {
this(WizardAnimalsPlusModEntities.CAPUCHIN_WHITE_HEAD.get(), world);
}
public CapuchinWhiteHeadEntity(EntityType<CapuchinWhiteHeadEntity> type, Level world) {
super(type, world);
setMaxUpStep(0.6f);
xpReward = 3;
setNoAi(false);
}
@Override
public Packet<ClientGamePacketListener> getAddEntityPacket() {
return NetworkHooks.getEntitySpawningPacket(this);
}
@Override
protected void registerGoals() {
super.registerGoals();
this.goalSelector.addGoal(1, new BreedGoal(this, 1));
this.goalSelector.addGoal(2, new TemptGoal(this, 1.2, Ingredient.of(Items.SWEET_BERRIES), false));
this.goalSelector.addGoal(3, new TemptGoal(this, 1.2, Ingredient.of(Items.APPLE), false));
this.goalSelector.addGoal(4, new FollowOwnerGoal(this, 1, (float) 10, (float) 2, false));
this.goalSelector.addGoal(5, new FollowParentGoal(this, 0.8));
this.targetSelector.addGoal(6, new NearestAttackableTargetGoal(this, BeetleYellowStagEntity.class, true, true));
this.targetSelector.addGoal(7, new NearestAttackableTargetGoal(this, BeetleDeadNettleEntity.class, true, true));
this.targetSelector.addGoal(8, new NearestAttackableTargetGoal(this, BeetleCelestialBlueEntity.class, true, true));
this.goalSelector.addGoal(9, new AvoidEntityGoal<>(this, AlligatorEntity.class, (float) 6, 1, 1.2));
this.goalSelector.addGoal(10, new RandomStrollGoal(this, 1));
this.goalSelector.addGoal(11, new LookAtPlayerGoal(this, Player.class, (float) 6));
this.goalSelector.addGoal(12, new RandomLookAroundGoal(this));
this.goalSelector.addGoal(13, new FloatGoal(this));
this.goalSelector.addGoal(14, new PanicGoal(this, 1.2));
}
@Override
public MobType getMobType() {
return MobType.UNDEFINED;
}
protected void dropCustomDeathLoot(DamageSource source, int looting, boolean recentlyHitIn) {
super.dropCustomDeathLoot(source, looting, recentlyHitIn);
this.spawnAtLocation(new ItemStack(Items.LEATHER));
}
@Override
public SoundEvent getAmbientSound() {
return ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("wizard_animals_plus:capuchin_ambient"));
}
@Override
public SoundEvent getHurtSound(DamageSource ds) {
return ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("wizard_animals_plus:capuchin_hurt"));
}
@Override
public SoundEvent getDeathSound() {
return ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("wizard_animals_plus:capuchin_death"));
}
@Override
public InteractionResult mobInteract(Player sourceentity, InteractionHand hand) {
ItemStack itemstack = sourceentity.getItemInHand(hand);
InteractionResult retval = InteractionResult.sidedSuccess(this.level().isClientSide());
Item item = itemstack.getItem();
if (itemstack.getItem() instanceof SpawnEggItem) {
retval = super.mobInteract(sourceentity, hand);
} else if (this.level().isClientSide()) {
retval = (this.isTame() && this.isOwnedBy(sourceentity) || this.isFood(itemstack)) ? InteractionResult.sidedSuccess(this.level().isClientSide()) : InteractionResult.PASS;
} else {
if (this.isTame()) {
if (this.isOwnedBy(sourceentity)) {
if (item.isEdible() && this.isFood(itemstack) && this.getHealth() < this.getMaxHealth()) {
this.usePlayerItem(sourceentity, hand, itemstack);
this.heal((float) item.getFoodProperties().getNutrition());
retval = InteractionResult.sidedSuccess(this.level().isClientSide());
} else if (this.isFood(itemstack) && this.getHealth() < this.getMaxHealth()) {
this.usePlayerItem(sourceentity, hand, itemstack);
this.heal(4);
retval = InteractionResult.sidedSuccess(this.level().isClientSide());
} else {
retval = super.mobInteract(sourceentity, hand);
}
}
} else if (this.isFood(itemstack)) {
this.usePlayerItem(sourceentity, hand, itemstack);
if (this.random.nextInt(3) == 0 && !net.minecraftforge.event.ForgeEventFactory.onAnimalTame(this, sourceentity)) {
this.tame(sourceentity);
this.level().broadcastEntityEvent(this, (byte) 7);
} else {
this.level().broadcastEntityEvent(this, (byte) 6);
}
this.setPersistenceRequired();
retval = InteractionResult.sidedSuccess(this.level().isClientSide());
} else {
retval = super.mobInteract(sourceentity, hand);
if (retval == InteractionResult.SUCCESS || retval == InteractionResult.CONSUME)
this.setPersistenceRequired();
}
}
return retval;
}
@Override
public AgeableMob getBreedOffspring(ServerLevel serverWorld, AgeableMob ageable) {
CapuchinWhiteHeadEntity retval = WizardAnimalsPlusModEntities.CAPUCHIN_WHITE_HEAD.get().create(serverWorld);
retval.finalizeSpawn(serverWorld, serverWorld.getCurrentDifficultyAt(retval.blockPosition()), MobSpawnType.BREEDING, null, null);
return retval;
}
@Override
public boolean isFood(ItemStack stack) {
return List.of(Items.SWEET_BERRIES, Items.APPLE).contains(stack.getItem());
}
public static void init() {
SpawnPlacements.register(WizardAnimalsPlusModEntities.CAPUCHIN_WHITE_HEAD.get(), SpawnPlacements.Type.ON_GROUND, Heightmap.Types.MOTION_BLOCKING_NO_LEAVES,
(entityType, world, reason, pos, random) -> (world.getBlockState(pos.below()).is(BlockTags.ANIMALS_SPAWNABLE_ON) && world.getRawBrightness(pos, 0) > 8));
}
public static AttributeSupplier.Builder createAttributes() {
AttributeSupplier.Builder builder = Mob.createMobAttributes();
builder = builder.add(Attributes.MOVEMENT_SPEED, 0.35);
builder = builder.add(Attributes.MAX_HEALTH, 8);
builder = builder.add(Attributes.ARMOR, 0);
builder = builder.add(Attributes.ATTACK_DAMAGE, 0);
builder = builder.add(Attributes.FOLLOW_RANGE, 16);
return builder;
}
}
its breeding and taming with the berry only atm, i want to separate this, thanks :)
also i would like help to make the tamed mob Sit with the right click (i got the sitting model already), was working before too on 1.16, its so insane how they change so many coding each time they update minecraft really
OK, I do know how to make sitting work
So in the "AI and goals" section in your mob, you may notice "Conditions: OO" in your code blocks. Make a procedure, call it "YUMBOOOOOOO". Make this: [If [Get number of items in [Item in main hand of [Event/target entity]]] = 2 do]Return logic: [true ▾]]
And back in your mob's AI, click on the "Conditions: OO" thingle in the tasks that are related to movement, and add your YUMBOOOOOOO procedure in both conditions. Now, in "Behavior", in "Equipment", give the mob granite stairs in it's main hand. Make another procedure, call it "IOIOIOJOJOJOJO", and make: [Grow item [Item in main hand of [Event/target entity]] for [1]] [If [Get number of items in [Item in main hand of [Event/target entity]]] > 2 do]Set number of items in [Item in main hand of [Event/target entity]] to [1]] and add this procedure to the entity's "When right clicked on entity" trigger.