[add] Monkey

This commit is contained in:
2026-09-28 22:26:39 +02:00
parent f8c4e0f31d
commit b3b4b1751d
26 changed files with 374 additions and 15 deletions
@@ -30,6 +30,7 @@ public class ModCreativeModeTabs {
output.accept(ModItems.RED_PANDA_SPAWN_EGG);
output.accept(ModItems.BUTTERFLY_SPAWN_EGG);
output.accept(ModItems.RACCOON_SPAWN_EGG);
output.accept(ModItems.MONKEY_SPAWN_EGG);
}).build());
@@ -49,6 +49,9 @@ public class ModItems {
public static final DeferredItem<Item> RACCOON_SPAWN_EGG = ITEMS.register("raccoon_spawn_egg",
() -> new DeferredSpawnEggItem(ModEntities.RACCOON, 0x68696a, 0xa6a4a3,
new Item.Properties()));
public static final DeferredItem<Item> MONKEY_SPAWN_EGG = ITEMS.register("monkey_spawn_egg",
() -> new DeferredSpawnEggItem(ModEntities.MONKEY, 0x795136, 0x9e9178,
new Item.Properties()));
public static void register(IEventBus eventBus) {
ITEMS.register(eventBus);
@@ -19,6 +19,7 @@ import ovh.glitchlabs.masterwild.Item.ModCreativeModeTabs;
import ovh.glitchlabs.masterwild.Item.ModItems;
import ovh.glitchlabs.masterwild.Sounds.ModSounds;
import ovh.glitchlabs.masterwild.entity.ModEntities;
import ovh.glitchlabs.masterwild.entity.client.Monkey.MonkeyRenderer;
import ovh.glitchlabs.masterwild.entity.client.Pinguin.PinguinRenderer;
import ovh.glitchlabs.masterwild.entity.client.Raccoon.RaccoonRenderer;
import ovh.glitchlabs.masterwild.entity.client.Rooster.RoosterRenderer;
@@ -82,6 +83,7 @@ public class Masterwild {
EntityRenderers.register(ModEntities.RED_PANDA.get(), Red_PandaRenderer::new);
EntityRenderers.register(ModEntities.BUTTERFLY.get(), ButterflyRenderer::new);
EntityRenderers.register(ModEntities.RACCOON.get(), RaccoonRenderer::new);
EntityRenderers.register(ModEntities.MONKEY.get(), MonkeyRenderer::new);
}
}
}
@@ -14,6 +14,7 @@ public class ModSounds {
DeferredRegister.create(BuiltInRegistries.SOUND_EVENT, Masterwild.MODID);
public static final Supplier<SoundEvent> ROOSTER_CROW = registerSound("rooster_crow");
public static final Supplier<SoundEvent> MONKEY_HURT = registerSound("monkey_hurt");
private static Supplier<SoundEvent> registerSound(String name) {
ResourceLocation id = ResourceLocation.fromNamespaceAndPath(Masterwild.MODID, name);
@@ -29,5 +29,6 @@ public class ModItemModelProvider extends ItemModelProvider {
withExistingParent(ModItems.RED_PANDA_SPAWN_EGG.getId().getPath(), mcLoc("item/template_spawn_egg"));
withExistingParent(ModItems.BUTTERFLY_SPAWN_EGG.getId().getPath(), mcLoc("item/template_spawn_egg"));
withExistingParent(ModItems.RACCOON_SPAWN_EGG.getId().getPath(), mcLoc("item/template_spawn_egg"));
withExistingParent(ModItems.MONKEY_SPAWN_EGG.getId().getPath(), mcLoc("item/template_spawn_egg"));
}
}
@@ -25,6 +25,7 @@ public class ModLanguageProvider extends LanguageProvider {
add(ModEntities.RED_PANDA.get(), "Red Panda");
add(ModEntities.BUTTERFLY.get(), "Butterfly");
add(ModEntities.RACCOON.get(), "Raccoon");
add(ModEntities.MONKEY.get(), "Monkey");
add(ModItems.PINGUIN_SPAWN_EGG.get(), "Pinguin Spawn Egg");
add(ModItems.FIREFLY_SPAWN_EGG.get(), "Firefly Spawn Egg");
@@ -34,8 +35,11 @@ public class ModLanguageProvider extends LanguageProvider {
add(ModItems.RED_PANDA_SPAWN_EGG.get(), "Red Panda Spawn Egg");
add(ModItems.BUTTERFLY_SPAWN_EGG.get(), "Butterfly Spawn Egg");
add(ModItems.RACCOON_SPAWN_EGG.get(), "Raccoon Spawn Egg");
add(ModItems.MONKEY_SPAWN_EGG.get(), "Monkey Spawn Egg");
add("creativetab.masterwild.masterwild", "MasterWild");
add("subtitles.masterwild.rooster_crow", "Rooster crows");
add("subtitles.masterwild.monkey_hurt", "Monkey Hurt");
}
}
@@ -46,6 +46,10 @@ public class ModEntities {
ENTITY_TYPES.register("raccoon", () -> EntityType.Builder.of(RaccoonEntity::new, MobCategory.CREATURE)
.sized(0.6f, 0.5f).build("raccoon"));
public static final Supplier<EntityType<MonkeyEntity>> MONKEY =
ENTITY_TYPES.register("monkey", () -> EntityType.Builder.of(MonkeyEntity::new, MobCategory.CREATURE)
.sized(0.6f, 0.5f).build("monkey"));
public static void register(IEventBus eventBus) {
ENTITY_TYPES.register(eventBus);
@@ -0,0 +1,78 @@
package ovh.glitchlabs.masterwild.entity.client.Monkey;// Save this class in your mod and generate all required imports
import net.minecraft.client.animation.AnimationChannel;
import net.minecraft.client.animation.AnimationDefinition;
import net.minecraft.client.animation.Keyframe;
import net.minecraft.client.animation.KeyframeAnimations;
/**
* Made with Blockbench 5.2.0
* Exported for Minecraft version 1.19 or later with Mojang mappings
* @author Author
*/
public class MonkeyAnimation {
public static final AnimationDefinition Monky_Running = AnimationDefinition.Builder.withLength(0.6667F).looping()
.addAnimation("body", new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM),
new Keyframe(0.3333F, KeyframeAnimations.degreeVec(5.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM),
new Keyframe(0.5F, KeyframeAnimations.degreeVec(7.5F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM),
new Keyframe(0.6667F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM)
))
.addAnimation("bone2", new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM),
new Keyframe(0.1667F, KeyframeAnimations.degreeVec(2.5F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM),
new Keyframe(0.6667F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM)
))
.addAnimation("R_front_Leg", new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM),
new Keyframe(0.1667F, KeyframeAnimations.degreeVec(-12.5F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM),
new Keyframe(0.3333F, KeyframeAnimations.degreeVec(-30.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM),
new Keyframe(0.6667F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM)
))
.addAnimation("L_front_Leg", new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM),
new Keyframe(0.1667F, KeyframeAnimations.degreeVec(-12.5F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM),
new Keyframe(0.3333F, KeyframeAnimations.degreeVec(-30.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM),
new Keyframe(0.6667F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM)
))
.addAnimation("L_up", new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM),
new Keyframe(0.1667F, KeyframeAnimations.degreeVec(22.5F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM),
new Keyframe(0.3333F, KeyframeAnimations.degreeVec(52.5F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM),
new Keyframe(0.5F, KeyframeAnimations.degreeVec(52.5F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM),
new Keyframe(0.6667F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM)
))
.addAnimation("L_up", new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0.0F, KeyframeAnimations.posVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM)
))
.addAnimation("L_up", new AnimationChannel(AnimationChannel.Targets.SCALE,
new Keyframe(0.0F, KeyframeAnimations.scaleVec(1.0F, 1.0F, 1.0F), AnimationChannel.Interpolations.CATMULLROM)
))
.addAnimation("L_down", new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM),
new Keyframe(0.1667F, KeyframeAnimations.degreeVec(-25.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM),
new Keyframe(0.3333F, KeyframeAnimations.degreeVec(-42.5F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM),
new Keyframe(0.5F, KeyframeAnimations.degreeVec(-7.5F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM),
new Keyframe(0.6667F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM)
))
.addAnimation("R_up", new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM),
new Keyframe(0.1667F, KeyframeAnimations.degreeVec(22.5F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM),
new Keyframe(0.3333F, KeyframeAnimations.degreeVec(52.5F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM),
new Keyframe(0.5F, KeyframeAnimations.degreeVec(52.5F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM),
new Keyframe(0.6667F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM)
))
.addAnimation("R_up", new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0.0F, KeyframeAnimations.posVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM)
))
.addAnimation("R_up", new AnimationChannel(AnimationChannel.Targets.SCALE,
new Keyframe(0.0F, KeyframeAnimations.scaleVec(1.0F, 1.0F, 1.0F), AnimationChannel.Interpolations.CATMULLROM)
))
.addAnimation("R_down", new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM),
new Keyframe(0.1667F, KeyframeAnimations.degreeVec(-25.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM),
new Keyframe(0.3333F, KeyframeAnimations.degreeVec(-42.5F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM),
new Keyframe(0.5F, KeyframeAnimations.degreeVec(-7.5F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM),
new Keyframe(0.6667F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM)
))
.build();
}
@@ -0,0 +1,126 @@
package ovh.glitchlabs.masterwild.entity.client.Monkey;// Made with Blockbench 5.2.0
// Exported for Minecraft version 1.17 or later with Mojang mappings
// Paste this class into your mod and generate all required imports
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import net.minecraft.client.model.EntityModel;
import net.minecraft.client.model.HierarchicalModel;
import net.minecraft.client.model.geom.ModelLayerLocation;
import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.client.model.geom.PartPose;
import net.minecraft.client.model.geom.builders.*;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import ovh.glitchlabs.masterwild.Masterwild;
import ovh.glitchlabs.masterwild.entity.custom.MonkeyEntity;
public class MonkeyModel<T extends MonkeyEntity> extends HierarchicalModel<T> {
// This layer location should be baked with EntityRendererProvider.Context in the entity renderer and passed into this model's constructor
public static final ModelLayerLocation LAYER_LOCATION = new ModelLayerLocation(ResourceLocation.fromNamespaceAndPath(Masterwild.MODID, "monkeymodel"), "main");
private final ModelPart monkey;
private final ModelPart body;
private final ModelPart bone2;
private final ModelPart legs;
private final ModelPart R_front_Leg;
private final ModelPart R_back_Leg;
private final ModelPart R_up;
private final ModelPart R_down;
private final ModelPart L_front_Leg;
private final ModelPart L_back_Leg;
private final ModelPart L_up;
private final ModelPart L_down;
private final ModelPart head;
private final ModelPart tail;
public MonkeyModel(ModelPart root) {
this.monkey = root.getChild("monkey");
this.body = this.monkey.getChild("body");
this.bone2 = this.body.getChild("bone2");
this.legs = this.body.getChild("legs");
this.R_front_Leg = this.legs.getChild("R_front_Leg");
this.R_back_Leg = this.legs.getChild("R_back_Leg");
this.R_up = this.R_back_Leg.getChild("R_up");
this.R_down = this.R_up.getChild("R_down");
this.L_front_Leg = this.legs.getChild("L_front_Leg");
this.L_back_Leg = this.legs.getChild("L_back_Leg");
this.L_up = this.L_back_Leg.getChild("L_up");
this.L_down = this.L_up.getChild("L_down");
this.head = this.body.getChild("head");
this.tail = this.body.getChild("tail");
}
public static LayerDefinition createBodyLayer() {
MeshDefinition meshdefinition = new MeshDefinition();
PartDefinition partdefinition = meshdefinition.getRoot();
PartDefinition monkey = partdefinition.addOrReplaceChild("monkey", CubeListBuilder.create(), PartPose.offset(0.5F, 20.0F, 0.0F));
PartDefinition body = monkey.addOrReplaceChild("body", CubeListBuilder.create(), PartPose.offset(-2.125F, -2.7083F, 2.2083F));
PartDefinition bone2 = body.addOrReplaceChild("bone2", CubeListBuilder.create(), PartPose.offset(1.625F, -0.1931F, -0.9507F));
PartDefinition cube_r1 = bone2.addOrReplaceChild("cube_r1", CubeListBuilder.create().texOffs(0, 0).addBox(-4.0F, -6.0F, -4.0F, 7.0F, 6.0F, 10.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.5F, 2.9014F, -1.2577F, -0.0873F, 0.0F, 0.0F));
PartDefinition legs = body.addOrReplaceChild("legs", CubeListBuilder.create(), PartPose.offset(2.125F, 2.7083F, -2.2083F));
PartDefinition R_front_Leg = legs.addOrReplaceChild("R_front_Leg", CubeListBuilder.create().texOffs(0, 33).addBox(-1.0F, -0.5F, -1.0F, 2.0F, 5.0F, 2.0F, new CubeDeformation(0.0F)), PartPose.offset(-2.75F, -0.5F, -2.75F));
PartDefinition R_back_Leg = legs.addOrReplaceChild("R_back_Leg", CubeListBuilder.create(), PartPose.offset(-3.0F, -0.9604F, 3.8174F));
PartDefinition R_up = R_back_Leg.addOrReplaceChild("R_up", CubeListBuilder.create(), PartPose.offset(0.0F, 0.0396F, -0.4326F));
PartDefinition cube_r2 = R_up.addOrReplaceChild("cube_r2", CubeListBuilder.create().texOffs(20, 25).addBox(-1.0F, -2.0F, -3.0F, 3.0F, 5.0F, 4.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(-0.5F, -0.0793F, 1.1152F, -0.3927F, 0.0F, 0.0F));
PartDefinition R_down = R_up.addOrReplaceChild("R_down", CubeListBuilder.create().texOffs(34, 6).addBox(-1.0F, -1.0F, -1.0F, 2.0F, 4.0F, 2.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 1.9207F, -1.1348F));
PartDefinition L_front_Leg = legs.addOrReplaceChild("L_front_Leg", CubeListBuilder.create().texOffs(8, 33).addBox(-1.0F, -0.5F, -1.0F, 2.0F, 5.0F, 2.0F, new CubeDeformation(0.0F)), PartPose.offset(1.75F, -0.5F, -2.75F));
PartDefinition L_back_Leg = legs.addOrReplaceChild("L_back_Leg", CubeListBuilder.create(), PartPose.offset(2.0F, -0.9604F, 3.8174F));
PartDefinition L_up = L_back_Leg.addOrReplaceChild("L_up", CubeListBuilder.create(), PartPose.offset(0.0F, 0.0396F, -0.4326F));
PartDefinition cube_r3 = L_up.addOrReplaceChild("cube_r3", CubeListBuilder.create().texOffs(20, 16).addBox(-2.0F, -2.0F, -3.0F, 3.0F, 5.0F, 4.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.5F, -0.0793F, 1.1152F, -0.3927F, 0.0F, 0.0F));
PartDefinition L_down = L_up.addOrReplaceChild("L_down", CubeListBuilder.create().texOffs(34, 0).addBox(-1.0F, -1.0F, -1.0F, 2.0F, 4.0F, 2.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 1.9207F, -1.1348F));
PartDefinition head = body.addOrReplaceChild("head", CubeListBuilder.create().texOffs(0, 16).addBox(-3.0F, -3.0889F, -3.7083F, 6.0F, 6.0F, 4.0F, new CubeDeformation(0.0F))
.texOffs(34, 12).addBox(-2.0F, -0.0889F, -4.7083F, 4.0F, 3.0F, 1.0F, new CubeDeformation(0.0F)), PartPose.offset(1.625F, -2.5361F, -5.6667F));
PartDefinition cube_r4 = head.addOrReplaceChild("cube_r4", CubeListBuilder.create().texOffs(16, 34).addBox(-2.0F, -2.0F, 0.0F, 3.0F, 3.0F, 1.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(4.0F, -0.2555F, -2.5417F, 0.0F, 0.0F, -0.1745F));
PartDefinition cube_r5 = head.addOrReplaceChild("cube_r5", CubeListBuilder.create().texOffs(34, 16).addBox(-1.0F, -2.0F, 0.0F, 3.0F, 3.0F, 1.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(-4.0F, -0.2555F, -2.5417F, 0.0F, 0.0F, 0.1745F));
PartDefinition tail = body.addOrReplaceChild("tail", CubeListBuilder.create().texOffs(14, 29).addBox(-0.5F, 1.3686F, 3.5304F, 1.0F, 1.0F, 1.0F, new CubeDeformation(0.0F))
.texOffs(0, 26).addBox(-0.5F, -0.6314F, -0.4696F, 1.0F, 1.0F, 6.0F, new CubeDeformation(0.0F))
.texOffs(14, 26).addBox(-0.5F, 0.3686F, 4.5304F, 1.0F, 2.0F, 1.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(1.625F, -1.625F, 4.125F, 0.2618F, 0.0F, 0.0F));
return LayerDefinition.create(meshdefinition, 64, 64);
}
@Override
public void setupAnim(MonkeyEntity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {
this.root().getAllParts().forEach(ModelPart::resetPose);
this.animateWalk(MonkeyAnimation.Monky_Running, limbSwing, limbSwingAmount, 2f, 2.5f);
this.applyHeadRotation(netHeadYaw, headPitch);
}
private void applyHeadRotation(float headYaw, float headPitch) {
headYaw = Mth.clamp(headYaw, -30f, 30f);
headPitch = Mth.clamp(headPitch, -25f, 45f);
this.head.yRot = headYaw * ((float) Math.PI / 180f);
this.head.xRot = headPitch * ((float) Math.PI / 180f);
}
@Override
public void renderToBuffer(PoseStack poseStack, VertexConsumer vertexConsumer, int packedLight, int packedOverlay, int color) {
monkey.render(poseStack, vertexConsumer, packedLight, packedOverlay, color);
}
@Override
public ModelPart root() {
return monkey;
}
}
@@ -0,0 +1,33 @@
package ovh.glitchlabs.masterwild.entity.client.Monkey;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.client.renderer.entity.MobRenderer;
import net.minecraft.resources.ResourceLocation;
import ovh.glitchlabs.masterwild.Masterwild;
import ovh.glitchlabs.masterwild.entity.custom.MonkeyEntity;
public class MonkeyRenderer extends MobRenderer<MonkeyEntity, MonkeyModel<MonkeyEntity>> {
private static final float ADULT_SCALE = 1.0f;
private static final float BABY_SCALE = 0.45f;
private static final float SHADOW = 0.45f;
private static final ResourceLocation TEXTURE =
ResourceLocation.fromNamespaceAndPath(Masterwild.MODID, "textures/entity/monkey.png");
public MonkeyRenderer(EntityRendererProvider.Context context) {
super(context, new MonkeyModel<>(context.bakeLayer(MonkeyModel.LAYER_LOCATION)), SHADOW);
}
@Override
public ResourceLocation getTextureLocation(MonkeyEntity entity) {
return TEXTURE;
}
@Override
protected void scale(MonkeyEntity entity, PoseStack poseStack, float partialTick) {
float scale = entity.isBaby() ? BABY_SCALE : ADULT_SCALE;
poseStack.scale(scale, scale, scale);
this.shadowRadius = SHADOW * scale;
}
}
@@ -0,0 +1,78 @@
package ovh.glitchlabs.masterwild.entity.custom;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.AgeableMob;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.ai.attributes.Attribute;
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.ai.goal.*;
import net.minecraft.world.entity.animal.Animal;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.level.Level;
import org.jetbrains.annotations.Nullable;
import ovh.glitchlabs.masterwild.Item.ModItems;
import ovh.glitchlabs.masterwild.Sounds.ModSounds;
import ovh.glitchlabs.masterwild.entity.ModEntities;
public class MonkeyEntity extends Animal {
private static final Ingredient FOOD = Ingredient.of(ModItems.BANANA);
public MonkeyEntity(EntityType<? extends Animal> entityType, Level level) {
super(entityType, level);
}
public static AttributeSupplier.Builder createAttributes() {
return AgeableMob.createMobAttributes()
.add(Attributes.MAX_HEALTH, 8)
.add(Attributes.MOVEMENT_SPEED, 0.25)
.add(Attributes.FOLLOW_RANGE, 10)
.add(Attributes.STEP_HEIGHT, 0.6);
}
@Override
protected void registerGoals() {
this.goalSelector.addGoal(1, new MeleeAttackGoal(this, 1, false) {
@Override
protected boolean canPerformAttack(LivingEntity entity) {
return this.isTimeToAttack() && this.mob.distanceToSqr(entity) < (this.mob.getBbWidth() * this.mob.getBbWidth() + entity.getBbWidth()) && this.mob.getSensing().hasLineOfSight(entity);
}
});
this.goalSelector.addGoal(1, new PanicGoal(this, 1.5));
this.goalSelector.addGoal(2, new BreedGoal(this, 1.0));
this.goalSelector.addGoal(3, new TemptGoal(this, 1.1, FOOD, false));
this.goalSelector.addGoal(4, new FollowParentGoal(this, 1.1));
this.goalSelector.addGoal(5, new WaterAvoidingRandomStrollGoal(this, 0.8));
this.goalSelector.addGoal(6, new LookAtPlayerGoal(this, Player.class, 6.0F));
this.goalSelector.addGoal(7, new RandomLookAroundGoal(this));
this.goalSelector.addGoal(0, new FloatGoal(this));
}
@Override
protected void dropCustomDeathLoot(ServerLevel serverLevel, DamageSource source, boolean recentlyHit) {
super.dropCustomDeathLoot(serverLevel, source, recentlyHit);
this.spawnAtLocation(new ItemStack(ModItems.BANANA_PEEL.get()));
}
@Override
public boolean isFood(ItemStack itemStack) {
return FOOD.test(itemStack);
}
@Override
public @Nullable AgeableMob getBreedOffspring(ServerLevel serverLevel, AgeableMob ageableMob) {
return ModEntities.MONKEY.get().create(serverLevel);
}
@Override
public SoundEvent getHurtSound(DamageSource damageSource) {
return ModSounds.MONKEY_HURT.get();
}
}
@@ -11,6 +11,7 @@ import net.neoforged.neoforge.event.entity.EntityAttributeCreationEvent;
import net.neoforged.neoforge.event.entity.RegisterSpawnPlacementsEvent;
import ovh.glitchlabs.masterwild.Masterwild;
import ovh.glitchlabs.masterwild.entity.ModEntities;
import ovh.glitchlabs.masterwild.entity.client.Monkey.MonkeyModel;
import ovh.glitchlabs.masterwild.entity.client.Pinguin.PinguinModel;
import ovh.glitchlabs.masterwild.entity.client.Raccoon.RaccoonModel;
import ovh.glitchlabs.masterwild.entity.client.Rooster.RoosterModel;
@@ -33,6 +34,7 @@ public class ModEventBusEvents {
event.registerLayerDefinition(Red_PandaModel.LAYER_LOCATION, Red_PandaModel::createBodyLayer);
event.registerLayerDefinition(ButterflyModel.LAYER_LOCATION, ButterflyModel::createBodyLayer);
event.registerLayerDefinition(RaccoonModel.LAYER_LOCATION, RaccoonModel::createBodyLayer);
event.registerLayerDefinition(MonkeyModel.LAYER_LOCATION, MonkeyModel::createBodyLayer);
}
@SubscribeEvent
@@ -44,11 +46,6 @@ public class ModEventBusEvents {
event.put(ModEntities.HEDGEHOG.get(), HedgehogEntity.createAttributes().build());
event.put(ModEntities.RED_PANDA.get(), Red_PandaEntity.createAttributes().build());
event.put(ModEntities.RACCOON.get(), RaccoonEntity.createAttributes().build());
}
@SubscribeEvent
public static void registerSpawnPlacements(RegisterSpawnPlacementsEvent event) {
event.register(ModEntities.RACCOON.get(), SpawnPlacementTypes.ON_GROUND, Heightmap.Types.MOTION_BLOCKING_NO_LEAVES,
Animal::checkAnimalSpawnRules, RegisterSpawnPlacementsEvent.Operation.REPLACE);
event.put(ModEntities.MONKEY.get(), MonkeyEntity.createAttributes().build());
}
}
@@ -30,6 +30,9 @@ public class ModSpawnPlacements {
event.register(ModEntities.RED_PANDA.get(), SpawnPlacementTypes.ON_GROUND,
Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, Animal::checkAnimalSpawnRules,
RegisterSpawnPlacementsEvent.Operation.REPLACE);
event.register(ModEntities.MONKEY.get(), SpawnPlacementTypes.ON_GROUND,
Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, Animal::checkAnimalSpawnRules,
RegisterSpawnPlacementsEvent.Operation.REPLACE);
event.register(ModEntities.SHARK.get(), SpawnPlacementTypes.IN_WATER,
Heightmap.Types.OCEAN_FLOOR, WaterAnimal::checkSurfaceWaterAnimalSpawnRules,
@@ -37,7 +40,7 @@ public class ModSpawnPlacements {
event.register(ModEntities.FIREFLY.get(), SpawnPlacementTypes.NO_RESTRICTIONS,
Heightmap.Types.MOTION_BLOCKING,
(type, level, reason, pos, random) -> level.getLevel().isNight() && level.canSeeSky(pos),
(type, level, reason, pos, random) -> level.getLevel().isNight(),
RegisterSpawnPlacementsEvent.Operation.REPLACE);
event.register(ModEntities.BUTTERFLY.get(), SpawnPlacementTypes.NO_RESTRICTIONS,
Heightmap.Types.MOTION_BLOCKING,
@@ -28,6 +28,7 @@ public class ModBiomeModifiers {
public static final ResourceKey<BiomeModifier> SPAWN_HEDGEHOG = registerKey("spawn_hedgehog");
public static final ResourceKey<BiomeModifier> SPAWN_RED_PANDA = registerKey("spawn_red_panda");
public static final ResourceKey<BiomeModifier> SPAWN_BUTTERFLY = registerKey("spawn_butterfly");
public static final ResourceKey<BiomeModifier> SPAWN_MONKEY = registerKey("spawn_monkey");
public static void bootstrap(BootstrapContext<BiomeModifier> context) {
var placedFeatures = context.lookup(Registries.PLACED_FEATURE);
@@ -64,7 +65,7 @@ public class ModBiomeModifiers {
biomes.getOrThrow(Biomes.PLAINS),
biomes.getOrThrow(Biomes.SUNFLOWER_PLAINS),
biomes.getOrThrow(Biomes.MEADOW)),
ModEntities.ROOSTER.get(), 10, 2, 3);
ModEntities.ROOSTER.get(), 5, 2, 3);
addSpawn(context, SPAWN_SHARK,
biomes.getOrThrow(BiomeTags.IS_OCEAN),
@@ -81,6 +82,11 @@ public class ModBiomeModifiers {
biomes.getOrThrow(Biomes.CHERRY_GROVE)),
ModEntities.RED_PANDA.get(), 8, 1, 3);
addSpawn(context, SPAWN_MONKEY,
HolderSet.direct(
biomes.getOrThrow(Biomes.JUNGLE)),
ModEntities.MONKEY.get(), 9, 2, 5);
addSpawn(context, SPAWN_BUTTERFLY,
HolderSet.direct(
biomes.getOrThrow(Biomes.FLOWER_FOREST),