[add] Red Panda

This commit is contained in:
2026-09-27 13:45:35 +02:00
parent af67b3d212
commit 2e5c656b56
15 changed files with 584 additions and 3 deletions
@@ -29,6 +29,7 @@ public class ModCreativeModeTabs {
output.accept(ModItems.ROOSTER_SPAWN_EGG);
output.accept(ModItems.SHARK_SPAWN_EGG);
output.accept(ModItems.HEDGEHOG_SPAWN_EGG);
output.accept(ModItems.RED_PANDA_SPAWN_EGG);
}).build());
@@ -29,6 +29,9 @@ public class ModItems {
public static final DeferredItem<Item> HEDGEHOG_SPAWN_EGG = ITEMS.register("hedgehog_spawn_egg",
() -> new DeferredSpawnEggItem(ModEntities.HEDGEHOG, 0x372a21, 0x8f8973,
new Item.Properties()));
public static final DeferredItem<Item> RED_PANDA_SPAWN_EGG = ITEMS.register("red-panda_spawn_egg",
() -> new DeferredSpawnEggItem(ModEntities.RED_PANDA, 0x923918, 0x211b1b,
new Item.Properties()));
public static void register(IEventBus eventBus) {
ITEMS.register(eventBus);
@@ -24,6 +24,7 @@ import ovh.glitchlabs.masterwild.entity.client.Rooster.RoosterRenderer;
import ovh.glitchlabs.masterwild.entity.client.Shark.SharkRenderer;
import ovh.glitchlabs.masterwild.entity.client.firefly.FireflyRenderer;
import ovh.glitchlabs.masterwild.entity.client.hedgehog.HedgehogRenderer;
import ovh.glitchlabs.masterwild.entity.client.red_panda.Red_PandaRenderer;
// The value here should match an entry in the META-INF/neoforge.mods.toml file
@Mod(Masterwild.MODID)
@@ -76,6 +77,7 @@ public class Masterwild {
EntityRenderers.register(ModEntities.ROOSTER.get(), RoosterRenderer::new);
EntityRenderers.register(ModEntities.SHARK.get(), SharkRenderer::new);
EntityRenderers.register(ModEntities.HEDGEHOG.get(), HedgehogRenderer::new);
EntityRenderers.register(ModEntities.RED_PANDA.get(), Red_PandaRenderer::new);
}
}
}
@@ -19,5 +19,6 @@ public class ModItemModelProvider extends ItemModelProvider {
withExistingParent(ModItems.ROOSTER_SPAWN_EGG.getId().getPath(), mcLoc("item/template_spawn_egg"));
withExistingParent(ModItems.SHARK_SPAWN_EGG.getId().getPath(), mcLoc("item/template_spawn_egg"));
withExistingParent(ModItems.HEDGEHOG_SPAWN_EGG.getId().getPath(), mcLoc("item/template_spawn_egg"));
withExistingParent(ModItems.RED_PANDA_SPAWN_EGG.getId().getPath(), mcLoc("item/template_spawn_egg"));
}
}
@@ -19,12 +19,14 @@ public class ModLanguageProvider extends LanguageProvider {
add(ModEntities.ROOSTER.get(), "Rooster");
add(ModEntities.SHARK.get(), "Shark");
add(ModEntities.HEDGEHOG.get(), "Hedgehog");
add(ModEntities.RED_PANDA.get(), "Red Panda");
add(ModItems.PINGUIN_SPAWN_EGG.get(), "Pinguin Spawn Egg");
add(ModItems.FIREFLY_SPAWN_EGG.get(), "Firefly Spawn Egg");
add(ModItems.ROOSTER_SPAWN_EGG.get(), "Rooster Spawn Egg");
add(ModItems.SHARK_SPAWN_EGG.get(), "Shark Spawn Egg");
add(ModItems.HEDGEHOG_SPAWN_EGG.get(), "Hedgehog Spawn Egg");
add(ModItems.RED_PANDA_SPAWN_EGG.get(), "Red Panda Spawn Egg");
add("creativetab.masterwild.masterwild", "MasterWild");
add("subtitles.masterwild.rooster_crow", "Rooster crows");
@@ -34,6 +34,9 @@ public class ModEntities {
ENTITY_TYPES.register("hedgehog", () -> EntityType.Builder.of(HedgehogEntity::new, MobCategory.CREATURE)
.sized(0.5f, 0.4f).build("hedgehog"));
public static final Supplier<EntityType<Red_PandaEntity>> RED_PANDA =
ENTITY_TYPES.register("red_panda", () -> EntityType.Builder.of(Red_PandaEntity::new, MobCategory.CREATURE)
.sized(0.6f, 0.7f).build("red_panda"));
public static void register(IEventBus eventBus) {
@@ -0,0 +1,214 @@
package ovh.glitchlabs.masterwild.entity.client.red_panda;// 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.1
* Exported for Minecraft version 1.19 or later with Mojang mappings
* @author Author
*/
public class Red_PandaAnimation {
public static final AnimationDefinition red_panda_sit = AnimationDefinition.Builder.withLength(0.0F)
.addAnimation("red_panda", new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0.0F, KeyframeAnimations.degreeVec(-30.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR)
))
.addAnimation("red_panda", new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0.0F, KeyframeAnimations.posVec(0.0F, 0.75F, 0.0F), AnimationChannel.Interpolations.LINEAR)
))
.addAnimation("tail", new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0.0F, KeyframeAnimations.degreeVec(44.7192F, -35.3963F, -29.8378F), AnimationChannel.Interpolations.LINEAR)
))
.addAnimation("tail", new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0.0F, KeyframeAnimations.posVec(0.0F, -1.0F, 0.0F), AnimationChannel.Interpolations.LINEAR)
))
.addAnimation("r_leg_front", new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0.0F, KeyframeAnimations.degreeVec(30.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR)
))
.addAnimation("r_leg_back", new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0.0F, KeyframeAnimations.degreeVec(-122.1338F, 32.139F, -83.2786F), AnimationChannel.Interpolations.LINEAR)
))
.addAnimation("r_leg_back", new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0.0F, KeyframeAnimations.posVec(0.75F, 0.0F, 0.25F), AnimationChannel.Interpolations.LINEAR)
))
.addAnimation("l_leg_back", new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0.0F, KeyframeAnimations.degreeVec(-122.1338F, -32.139F, 83.2786F), AnimationChannel.Interpolations.LINEAR)
))
.addAnimation("l_leg_back", new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0.0F, KeyframeAnimations.posVec(0.0F, 1.25F, 0.0F), AnimationChannel.Interpolations.LINEAR)
))
.addAnimation("l_leg_front", new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0.0F, KeyframeAnimations.degreeVec(30.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR)
))
.addAnimation("head", new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0.0F, KeyframeAnimations.degreeVec(2.4786F, -0.3262F, 7.4928F), AnimationChannel.Interpolations.LINEAR)
))
.build();
public static final AnimationDefinition red_panda_defend_standup = AnimationDefinition.Builder.withLength(0.5F)
.addAnimation("red_panda", new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.5F, KeyframeAnimations.degreeVec(10.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR)
))
.addAnimation("red_panda", new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0.0F, KeyframeAnimations.posVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.5F, KeyframeAnimations.posVec(0.0F, -0.75F, 0.0F), AnimationChannel.Interpolations.LINEAR)
))
.addAnimation("body", new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.5F, KeyframeAnimations.degreeVec(-80.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR)
))
.addAnimation("body", new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0.0F, KeyframeAnimations.posVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.5F, KeyframeAnimations.posVec(0.0F, 1.0F, 0.0F), AnimationChannel.Interpolations.LINEAR)
))
.addAnimation("body", new AnimationChannel(AnimationChannel.Targets.SCALE,
new Keyframe(0.0F, KeyframeAnimations.scaleVec(1.0F, 1.0F, 1.0F), AnimationChannel.Interpolations.LINEAR)
))
.addAnimation("tail", new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.5F, KeyframeAnimations.degreeVec(67.5F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR)
))
.addAnimation("tail", new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0.0F, KeyframeAnimations.posVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.5F, KeyframeAnimations.posVec(0.0F, -0.5F, -0.25F), AnimationChannel.Interpolations.LINEAR)
))
.addAnimation("r_leg_front", new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM),
new Keyframe(0.5F, KeyframeAnimations.degreeVec(-42.2549F, 5.059F, 68.044F), AnimationChannel.Interpolations.CATMULLROM)
))
.addAnimation("r_leg_front", new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0.0F, KeyframeAnimations.posVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM),
new Keyframe(0.5F, KeyframeAnimations.posVec(0.0F, 0.25F, 0.5F), AnimationChannel.Interpolations.CATMULLROM)
))
.addAnimation("r_leg_front", new AnimationChannel(AnimationChannel.Targets.SCALE,
new Keyframe(0.0F, KeyframeAnimations.scaleVec(1.0F, 1.0F, 1.0F), AnimationChannel.Interpolations.CATMULLROM)
))
.addAnimation("r_leg_back", new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM),
new Keyframe(0.5F, KeyframeAnimations.degreeVec(67.5F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM)
))
.addAnimation("r_leg_back", new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0.0F, KeyframeAnimations.posVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM)
))
.addAnimation("r_leg_back", new AnimationChannel(AnimationChannel.Targets.SCALE,
new Keyframe(0.0F, KeyframeAnimations.scaleVec(1.0F, 1.0F, 1.0F), AnimationChannel.Interpolations.CATMULLROM)
))
.addAnimation("l_leg_back", new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM),
new Keyframe(0.5F, KeyframeAnimations.degreeVec(67.5F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM)
))
.addAnimation("l_leg_back", new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0.0F, KeyframeAnimations.posVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM)
))
.addAnimation("l_leg_back", new AnimationChannel(AnimationChannel.Targets.SCALE,
new Keyframe(0.0F, KeyframeAnimations.scaleVec(1.0F, 1.0F, 1.0F), AnimationChannel.Interpolations.CATMULLROM)
))
.addAnimation("l_leg_front", new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM),
new Keyframe(0.5F, KeyframeAnimations.degreeVec(-42.2549F, -5.059F, -68.044F), AnimationChannel.Interpolations.CATMULLROM)
))
.addAnimation("l_leg_front", new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0.0F, KeyframeAnimations.posVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM),
new Keyframe(0.5F, KeyframeAnimations.posVec(0.0F, 0.25F, 0.5F), AnimationChannel.Interpolations.CATMULLROM)
))
.addAnimation("l_leg_front", new AnimationChannel(AnimationChannel.Targets.SCALE,
new Keyframe(0.0F, KeyframeAnimations.scaleVec(1.0F, 1.0F, 1.0F), AnimationChannel.Interpolations.CATMULLROM)
))
.addAnimation("head", new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.5F, KeyframeAnimations.degreeVec(60.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR)
))
.addAnimation("head", new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0.0F, KeyframeAnimations.posVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.5F, KeyframeAnimations.posVec(0.01F, 1.0F, 0.0F), AnimationChannel.Interpolations.LINEAR)
))
.addAnimation("head", new AnimationChannel(AnimationChannel.Targets.SCALE,
new Keyframe(0.0F, KeyframeAnimations.scaleVec(1.0F, 1.0F, 1.0F), AnimationChannel.Interpolations.LINEAR)
))
.build();
public static final AnimationDefinition red_panda_defend_standdown = AnimationDefinition.Builder.withLength(0.5F)
.addAnimation("red_panda", new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0.0F, KeyframeAnimations.degreeVec(10.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM),
new Keyframe(0.5F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM)
))
.addAnimation("red_panda", new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0.0F, KeyframeAnimations.posVec(0.0F, -0.75F, 0.0F), AnimationChannel.Interpolations.CATMULLROM),
new Keyframe(0.5F, KeyframeAnimations.posVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM)
))
.addAnimation("body", new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0.0F, KeyframeAnimations.degreeVec(-80.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM),
new Keyframe(0.5F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM)
))
.addAnimation("body", new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0.0F, KeyframeAnimations.posVec(0.0F, 1.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM),
new Keyframe(0.5F, KeyframeAnimations.posVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM)
))
.addAnimation("body", new AnimationChannel(AnimationChannel.Targets.SCALE,
new Keyframe(0.5F, KeyframeAnimations.scaleVec(1.0F, 1.0F, 1.0F), AnimationChannel.Interpolations.CATMULLROM)
))
.addAnimation("tail", new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0.0F, KeyframeAnimations.degreeVec(67.5F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM),
new Keyframe(0.5F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM)
))
.addAnimation("tail", new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0.0F, KeyframeAnimations.posVec(0.0F, -0.5F, -0.25F), AnimationChannel.Interpolations.CATMULLROM),
new Keyframe(0.5F, KeyframeAnimations.posVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM)
))
.addAnimation("r_leg_front", new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0.0F, KeyframeAnimations.degreeVec(-42.2549F, 5.059F, 68.044F), AnimationChannel.Interpolations.CATMULLROM),
new Keyframe(0.5F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM)
))
.addAnimation("r_leg_front", new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0.0F, KeyframeAnimations.posVec(0.0F, 0.25F, 0.5F), AnimationChannel.Interpolations.CATMULLROM),
new Keyframe(0.5F, KeyframeAnimations.posVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM)
))
.addAnimation("r_leg_front", new AnimationChannel(AnimationChannel.Targets.SCALE,
new Keyframe(0.5F, KeyframeAnimations.scaleVec(1.0F, 1.0F, 1.0F), AnimationChannel.Interpolations.CATMULLROM)
))
.addAnimation("r_leg_back", new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0.0F, KeyframeAnimations.degreeVec(67.5F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM),
new Keyframe(0.5F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM)
))
.addAnimation("r_leg_back", new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0.5F, KeyframeAnimations.posVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM)
))
.addAnimation("r_leg_back", new AnimationChannel(AnimationChannel.Targets.SCALE,
new Keyframe(0.5F, KeyframeAnimations.scaleVec(1.0F, 1.0F, 1.0F), AnimationChannel.Interpolations.CATMULLROM)
))
.addAnimation("l_leg_back", new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0.0F, KeyframeAnimations.degreeVec(67.5F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM),
new Keyframe(0.5F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM)
))
.addAnimation("l_leg_back", new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0.5F, KeyframeAnimations.posVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM)
))
.addAnimation("l_leg_back", new AnimationChannel(AnimationChannel.Targets.SCALE,
new Keyframe(0.5F, KeyframeAnimations.scaleVec(1.0F, 1.0F, 1.0F), AnimationChannel.Interpolations.CATMULLROM)
))
.addAnimation("l_leg_front", new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0.0F, KeyframeAnimations.degreeVec(-42.2549F, -5.059F, -68.044F), AnimationChannel.Interpolations.CATMULLROM),
new Keyframe(0.5F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM)
))
.addAnimation("l_leg_front", new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0.0F, KeyframeAnimations.posVec(0.0F, 0.25F, 0.5F), AnimationChannel.Interpolations.CATMULLROM),
new Keyframe(0.5F, KeyframeAnimations.posVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM)
))
.addAnimation("l_leg_front", new AnimationChannel(AnimationChannel.Targets.SCALE,
new Keyframe(0.5F, KeyframeAnimations.scaleVec(1.0F, 1.0F, 1.0F), AnimationChannel.Interpolations.CATMULLROM)
))
.addAnimation("head", new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0.0F, KeyframeAnimations.degreeVec(60.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM),
new Keyframe(0.5F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM)
))
.addAnimation("head", new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0.0F, KeyframeAnimations.posVec(0.01F, 1.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM),
new Keyframe(0.5F, KeyframeAnimations.posVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.CATMULLROM)
))
.addAnimation("head", new AnimationChannel(AnimationChannel.Targets.SCALE,
new Keyframe(0.5F, KeyframeAnimations.scaleVec(1.0F, 1.0F, 1.0F), AnimationChannel.Interpolations.CATMULLROM)
))
.build();
}
@@ -0,0 +1,126 @@
package ovh.glitchlabs.masterwild.entity.client.red_panda;// Made with Blockbench 5.2.1
// 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.Red_PandaEntity;
public class Red_PandaModel<T extends Red_PandaEntity> 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, "red_pandamodelmodel"), "main");
private final ModelPart red_panda;
private final ModelPart body;
private final ModelPart tail;
private final ModelPart legs;
private final ModelPart r_leg_front;
private final ModelPart r_leg_back;
private final ModelPart l_leg_front;
private final ModelPart l_leg_back;
private final ModelPart head;
private final ModelPart ears;
private final ModelPart r_ear;
private final ModelPart l_ear;
public Red_PandaModel(ModelPart root) {
this.red_panda = root.getChild("red_panda");
this.body = this.red_panda.getChild("body");
this.tail = this.body.getChild("tail");
this.legs = this.body.getChild("legs");
this.r_leg_front = this.legs.getChild("r_leg_front");
this.r_leg_back = this.legs.getChild("r_leg_back");
this.l_leg_front = this.legs.getChild("l_leg_front");
this.l_leg_back = this.legs.getChild("l_leg_back");
this.head = this.body.getChild("head");
this.ears = this.head.getChild("ears");
this.r_ear = this.ears.getChild("r_ear");
this.l_ear = this.ears.getChild("l_ear");
}
public static LayerDefinition createBodyLayer() {
MeshDefinition meshdefinition = new MeshDefinition();
PartDefinition partdefinition = meshdefinition.getRoot();
PartDefinition red_panda = partdefinition.addOrReplaceChild("red_panda", CubeListBuilder.create(), PartPose.offset(2.75F, 24.0F, -2.75F));
PartDefinition body = red_panda.addOrReplaceChild("body", CubeListBuilder.create().texOffs(0, 0).addBox(-3.8125F, -3.5625F, -6.25F, 7.0F, 5.0F, 11.0F, new CubeDeformation(0.0F)), PartPose.offset(-2.4375F, -4.6875F, 5.0F));
PartDefinition tail = body.addOrReplaceChild("tail", CubeListBuilder.create().texOffs(0, 16).addBox(-1.5F, -2.0F, 0.0F, 4.0F, 4.0F, 10.0F, new CubeDeformation(0.0F)), PartPose.offset(-0.8125F, -2.0625F, 4.75F));
PartDefinition legs = body.addOrReplaceChild("legs", CubeListBuilder.create(), PartPose.offset(2.4375F, 4.6875F, 3.25F));
PartDefinition r_leg_front = legs.addOrReplaceChild("r_leg_front", CubeListBuilder.create().texOffs(28, 28).addBox(0.0F, -1.0F, -1.5F, 2.0F, 4.0F, 3.0F, new CubeDeformation(0.0F)), PartPose.offset(-6.5F, -3.0F, -7.75F));
PartDefinition r_leg_back = legs.addOrReplaceChild("r_leg_back", CubeListBuilder.create().texOffs(0, 30).addBox(0.0F, -1.0F, -1.5F, 2.0F, 4.0F, 3.0F, new CubeDeformation(0.0F)), PartPose.offset(-6.5F, -3.0F, -0.5F));
PartDefinition l_leg_front = legs.addOrReplaceChild("l_leg_front", CubeListBuilder.create().texOffs(10, 30).addBox(-1.0F, -1.0F, -1.5F, 2.0F, 4.0F, 3.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, -3.0F, -7.75F));
PartDefinition l_leg_back = legs.addOrReplaceChild("l_leg_back", CubeListBuilder.create().texOffs(20, 35).addBox(-1.0F, -1.0F, -1.5F, 2.0F, 4.0F, 3.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, -3.0F, -0.5F));
PartDefinition head = body.addOrReplaceChild("head", CubeListBuilder.create().texOffs(30, 35).addBox(-1.0F, 0.0F, -9.0F, 3.0F, 2.0F, 2.0F, new CubeDeformation(0.0F))
.texOffs(28, 16).addBox(-3.0F, -3.0F, -7.0F, 7.0F, 5.0F, 7.0F, new CubeDeformation(0.0F)), PartPose.offset(-0.8125F, -1.5625F, -6.25F));
PartDefinition ears = head.addOrReplaceChild("ears", CubeListBuilder.create(), PartPose.offset(3.25F, -3.0F, -5.5F));
PartDefinition r_ear = ears.addOrReplaceChild("r_ear", CubeListBuilder.create(), PartPose.offset(0.0F, 0.0F, 0.0F));
PartDefinition cube_r1 = r_ear.addOrReplaceChild("cube_r1", CubeListBuilder.create().texOffs(36, 0).addBox(-1.5F, -1.5F, -0.5F, 3.0F, 3.0F, 1.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(-5.5F, 0.0F, 0.0F, 0.0F, 0.0F, 0.3927F));
PartDefinition l_ear = ears.addOrReplaceChild("l_ear", CubeListBuilder.create(), PartPose.offset(0.0F, 0.0F, 0.0F));
PartDefinition cube_r2 = l_ear.addOrReplaceChild("cube_r2", CubeListBuilder.create().texOffs(20, 30).addBox(-1.5F, -1.5F, -0.5F, 3.0F, 3.0F, 1.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, -0.3927F));
return LayerDefinition.create(meshdefinition, 64, 64);
}
@Override
public void setupAnim(Red_PandaEntity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {
this.root().getAllParts().forEach(ModelPart::resetPose);
this.applyHeadRotation(netHeadYaw, headPitch);
boolean posed = entity.isInSittingPose() || entity.isDefending();
if (!posed) {
this.walk(limbSwing, limbSwingAmount);
}
this.animate(entity.sitingAnimationState, Red_PandaAnimation.red_panda_sit, ageInTicks);
this.animate(entity.standupAnimationState, Red_PandaAnimation.red_panda_defend_standup, ageInTicks);
this.animate(entity.standdownAnimationState, Red_PandaAnimation.red_panda_defend_standdown, ageInTicks);
}
private void walk(float limbSwing, float limbSwingAmount) {
float amount = 1.2F * limbSwingAmount;
this.r_leg_front.xRot = Mth.cos(limbSwing * 0.6662F) * amount;
this.l_leg_back.xRot = Mth.cos(limbSwing * 0.6662F) * amount;
this.l_leg_front.xRot = Mth.cos(limbSwing * 0.6662F + (float) Math.PI) * amount;
this.r_leg_back.xRot = Mth.cos(limbSwing * 0.6662F + (float) Math.PI) * amount;
}
private void applyHeadRotation(float headYaw, float headPitch) {
headYaw = Mth.clamp(headYaw, -30f, 30f);
headPitch = Math.clamp(headPitch, -25f, 45);
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) {
red_panda.render(poseStack, vertexConsumer, packedLight, packedOverlay, color);
}
@Override
public ModelPart root() {
return red_panda;
}
}
@@ -0,0 +1,33 @@
package ovh.glitchlabs.masterwild.entity.client.red_panda;
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.Red_PandaEntity;
public class Red_PandaRenderer extends MobRenderer<Red_PandaEntity, Red_PandaModel<Red_PandaEntity>> {
private static final float ADULT_SCALE = 1.2f;
private static final float BABY_SCALE = 0.45f;
private static final float SHADOW = 0.8f;
private static final ResourceLocation TEXTURE =
ResourceLocation.fromNamespaceAndPath(Masterwild.MODID, "textures/entity/red_panda.png");
public Red_PandaRenderer(EntityRendererProvider.Context context) {
super(context, new Red_PandaModel<>(context.bakeLayer(Red_PandaModel.LAYER_LOCATION)), SHADOW);
}
@Override
public ResourceLocation getTextureLocation(Red_PandaEntity entity) {
return TEXTURE;
}
@Override
protected void scale(Red_PandaEntity 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,190 @@
package ovh.glitchlabs.masterwild.entity.custom;
import net.minecraft.network.syncher.EntityDataAccessor;
import net.minecraft.network.syncher.EntityDataSerializers;
import net.minecraft.network.syncher.SynchedEntityData;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.AgeableMob;
import net.minecraft.world.entity.AnimationState;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.TamableAnimal;
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.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;
/**
* Roter Panda: zähmbar mit Beeren/Äpfeln, setzt sich per Rechtsklick oder wird per Halsband
* kontrolliert (Standard-TamableAnimal-Verhalten), und richtet sich bei Schaden kurz zur
* Verteidigung auf (nur Optik, kein zusätzlicher Schaden).
*/
public class Red_PandaEntity extends TamableAnimal {
private static final Ingredient FOOD = Ingredient.of(Items.SWEET_BERRIES, Items.APPLE);
private static final int DEFEND_DURATION = 40; // 2 Sekunden
private static final EntityDataAccessor<Boolean> DEFENDING =
SynchedEntityData.defineId(Red_PandaEntity.class, EntityDataSerializers.BOOLEAN);
public final AnimationState sitingAnimationState = new AnimationState();
public final AnimationState standupAnimationState = new AnimationState();
public final AnimationState standdownAnimationState = new AnimationState();
private int defendTicks = 0;
private boolean wasDefendingClient = false;
public Red_PandaEntity(EntityType<? extends TamableAnimal> entityType, Level level) {
super(entityType, level);
}
public static AttributeSupplier.Builder createAttributes() {
return Mob.createMobAttributes()
.add(Attributes.MAX_HEALTH, 10)
.add(Attributes.MOVEMENT_SPEED, 0.25)
.add(Attributes.FOLLOW_RANGE, 12)
.add(Attributes.STEP_HEIGHT, 0.6);
}
@Override
protected void registerGoals() {
this.goalSelector.addGoal(0, new FloatGoal(this));
this.goalSelector.addGoal(1, new SitWhenOrderedToGoal(this));
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 FollowOwnerGoal(this, 1.1, 10.0F, 2.0F));
this.goalSelector.addGoal(8, new RandomLookAroundGoal(this));
}
@Override
protected void defineSynchedData(SynchedEntityData.Builder builder) {
super.defineSynchedData(builder);
builder.define(DEFENDING, false);
}
public boolean isDefending() {
return this.entityData.get(DEFENDING);
}
private void setDefending(boolean defending) {
this.entityData.set(DEFENDING, defending);
}
@Override
public boolean isFood(ItemStack stack) {
return FOOD.test(stack);
}
@Override
public InteractionResult mobInteract(Player player, InteractionHand hand) {
ItemStack stack = player.getItemInHand(hand);
if (!this.isTame()) {
if (FOOD.test(stack)) {
if (!player.getAbilities().instabuild) {
stack.shrink(1);
}
if (!this.level().isClientSide()) {
if (this.random.nextInt(3) == 0) {
this.tame(player);
this.setOrderedToSit(true);
this.level().broadcastEntityEvent(this, (byte) 7); // Herz-Partikel
} else {
this.level().broadcastEntityEvent(this, (byte) 6); // Rauch-Partikel
}
}
return InteractionResult.SUCCESS;
}
return super.mobInteract(player, hand);
}
if (this.isOwnedBy(player)) {
if (FOOD.test(stack) && this.getHealth() < this.getMaxHealth()) {
if (!player.getAbilities().instabuild) {
stack.shrink(1);
}
this.heal(4.0F);
return InteractionResult.sidedSuccess(this.level().isClientSide());
}
if (!this.level().isClientSide() && !player.isSecondaryUseActive()) {
this.setOrderedToSit(!this.isOrderedToSit());
}
return InteractionResult.sidedSuccess(this.level().isClientSide());
}
return super.mobInteract(player, hand);
}
@Override
public boolean hurt(DamageSource source, float amount) {
boolean hurt = super.hurt(source, amount);
if (hurt && !this.level().isClientSide() && !this.isDeadOrDying()) {
this.defendTicks = DEFEND_DURATION;
this.setDefending(true);
this.playSound(SoundEvents.CAT_HISS, 1.0F, 1.0F);
}
return hurt;
}
@Override
public void tick() {
super.tick();
if (this.level().isClientSide()) {
this.setupAnimationStates();
} else if (this.isDefending() && --this.defendTicks <= 0) {
this.setDefending(false);
}
}
private void setupAnimationStates() {
if (this.isInSittingPose()) {
this.sitingAnimationState.startIfStopped(this.tickCount);
} else {
this.sitingAnimationState.stop();
}
boolean defending = this.isDefending();
if (defending && !this.wasDefendingClient) {
this.standdownAnimationState.stop();
this.standupAnimationState.start(this.tickCount);
} else if (!defending && this.wasDefendingClient) {
this.standupAnimationState.stop();
this.standdownAnimationState.start(this.tickCount);
}
this.wasDefendingClient = defending;
}
@Nullable
@Override
public AgeableMob getBreedOffspring(ServerLevel level, AgeableMob partner) {
return (AgeableMob) this.getType().create(level);
}
@Override
protected SoundEvent getAmbientSound() {
return SoundEvents.FOX_AMBIENT;
}
@Override
protected SoundEvent getHurtSound(DamageSource damageSource) {
return SoundEvents.FOX_HURT;
}
@Override
protected SoundEvent getDeathSound() {
return SoundEvents.FOX_DEATH;
}
}
@@ -11,6 +11,7 @@ import ovh.glitchlabs.masterwild.entity.client.Rooster.RoosterModel;
import ovh.glitchlabs.masterwild.entity.client.Shark.SharkModel;
import ovh.glitchlabs.masterwild.entity.client.firefly.FireflyModel;
import ovh.glitchlabs.masterwild.entity.client.hedgehog.HedgehogModel;
import ovh.glitchlabs.masterwild.entity.client.red_panda.Red_PandaModel;
import ovh.glitchlabs.masterwild.entity.custom.*;
@EventBusSubscriber(modid = Masterwild.MODID, bus = EventBusSubscriber.Bus.MOD)
@@ -22,6 +23,7 @@ public class ModEventBusEvents {
event.registerLayerDefinition(RoosterModel.LAYER_LOCATION, RoosterModel::createBodyLayer);
event.registerLayerDefinition(SharkModel.LAYER_LOCATION, SharkModel::createBodyLayer);
event.registerLayerDefinition(HedgehogModel.LAYER_LOCATION, HedgehogModel::createBodyLayer);
event.registerLayerDefinition(Red_PandaModel.LAYER_LOCATION, Red_PandaModel::createBodyLayer);
}
@SubscribeEvent
@@ -31,5 +33,6 @@ public class ModEventBusEvents {
event.put(ModEntities.ROOSTER.get(), RoosterEntity.createAttributes().build());
event.put(ModEntities.SHARK.get(), SharkEntity.createAttributes().build());
event.put(ModEntities.HEDGEHOG.get(), HedgehogEntity.createAttributes().build());
event.put(ModEntities.RED_PANDA.get(), Red_PandaEntity.createAttributes().build());
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB