Compare commits

...

5 Commits

Author SHA1 Message Date
Kaupenjoe
3a6aa1140d attack animation 2023-09-30 15:47:50 +02:00
Kaupenjoe
bfd445c5a2 custom entity 2023-09-30 15:12:27 +02:00
Kaupenjoe
3df4bc942e custom music disc 2023-08-28 16:16:51 +02:00
Kaupenjoe
23db75e368 custom sounds 2023-08-28 14:06:56 +02:00
Kaupenjoe
d59ec7e69b custom villagers 2023-08-28 12:35:56 +02:00
40 changed files with 1058 additions and 4 deletions

View File

@@ -1,4 +1,5 @@
// 1.20.1 2023-08-25T20:00:29.1439601 Item Models: tutorialmod
// 1.20.1 2023-08-28T16:11:02.6585535 Item Models: tutorialmod
f746b64540daf2ab6302b3ec01a78490c48fc10b assets/tutorialmod/models/item/bar_brawl_music_disc.json
d3e9cad00ae44c9319dfbb411667eb4a09a63e57 assets/tutorialmod/models/item/catmint.json
6126e26da373f9113d9e9be875b14a0d13857444 assets/tutorialmod/models/item/corn.json
4c5c277fa6360b149d6c3ab20584fcc4450cda27 assets/tutorialmod/models/item/corn_seeds.json

View File

@@ -1,2 +1,4 @@
// 1.20.1 2023-08-07T09:00:54.5654219 Tags for minecraft:item mod id tutorialmod
// 1.20.1 2023-08-28T16:11:02.6575435 Tags for minecraft:item mod id tutorialmod
526ec127a145db02975e7ec564384fa0a5389523 data/minecraft/tags/items/creeper_drop_music_discs.json
526ec127a145db02975e7ec564384fa0a5389523 data/minecraft/tags/items/music_discs.json
2514998bb25494de346fa0d088b7e216d8165efd data/minecraft/tags/items/trimmable_armor.json

View File

@@ -0,0 +1,2 @@
// 1.20.1 2023-08-28T12:32:21.1985044 Tags for minecraft:point_of_interest_type mod id tutorialmod
83f1c4f1a14965cf8c4c3a99edb0f816c3115ee6 data/minecraft/tags/point_of_interest_type/acquirable_job_site.json

View File

@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "tutorialmod:item/bar_brawl_music_disc"
}
}

View File

@@ -0,0 +1,5 @@
{
"values": [
"tutorialmod:bar_brawl_music_disc"
]
}

View File

@@ -0,0 +1,5 @@
{
"values": [
"tutorialmod:bar_brawl_music_disc"
]
}

View File

@@ -0,0 +1,8 @@
{
"values": [
{
"id": "tutorialmod:sound_poi",
"required": false
}
]
}

View File

@@ -2,9 +2,15 @@ package net.kaupenjoe.tutorialmod;
import com.mojang.logging.LogUtils;
import net.kaupenjoe.tutorialmod.block.ModBlocks;
import net.kaupenjoe.tutorialmod.entity.ModEntities;
import net.kaupenjoe.tutorialmod.entity.client.RhinoRenderer;
import net.kaupenjoe.tutorialmod.item.ModCreativeModTabs;
import net.kaupenjoe.tutorialmod.item.ModItems;
import net.kaupenjoe.tutorialmod.loot.ModLootModifiers;
import net.kaupenjoe.tutorialmod.sound.ModSounds;
import net.kaupenjoe.tutorialmod.villager.ModVillagers;
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.EntityRenderers;
import net.minecraft.world.item.CreativeModeTabs;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.FlowerPotBlock;
@@ -35,6 +41,10 @@ public class TutorialMod {
ModBlocks.register(modEventBus);
ModLootModifiers.register(modEventBus);
ModVillagers.register(modEventBus);
ModSounds.register(modEventBus);
ModEntities.register(modEventBus);
modEventBus.addListener(this::commonSetup);
@@ -66,7 +76,7 @@ public class TutorialMod {
public static class ClientModEvents {
@SubscribeEvent
public static void onClientSetup(FMLClientSetupEvent event) {
EntityRenderers.register(ModEntities.RHINO.get(), RhinoRenderer::new);
}
}
}

View File

@@ -5,6 +5,7 @@ import net.kaupenjoe.tutorialmod.block.custom.CornCropBlock;
import net.kaupenjoe.tutorialmod.block.custom.SoundBlock;
import net.kaupenjoe.tutorialmod.block.custom.StrawberryCropBlock;
import net.kaupenjoe.tutorialmod.item.ModItems;
import net.kaupenjoe.tutorialmod.sound.ModSounds;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.util.valueproviders.UniformInt;
import net.minecraft.world.effect.MobEffects;
@@ -43,7 +44,7 @@ public class ModBlocks {
.strength(5f).requiresCorrectToolForDrops(), UniformInt.of(3, 7)));
public static final RegistryObject<Block> SOUND_BLOCK = registerBlock("sound_block",
() -> new SoundBlock(BlockBehaviour.Properties.copy(Blocks.IRON_BLOCK)));
() -> new SoundBlock(BlockBehaviour.Properties.copy(Blocks.IRON_BLOCK).sound(ModSounds.SOUND_BLOCK_SOUNDS)));
public static final RegistryObject<Block> SAPPHIRE_STAIRS = registerBlock("sapphire_stairs",
() -> new StairBlock(() -> ModBlocks.SAPPHIRE_BLOCK.get().defaultBlockState(),

View File

@@ -31,5 +31,6 @@ public class DataGenerators {
generator.addProvider(event.includeServer(), new ModItemTagGenerator(packOutput, lookupProvider, blockTagGenerator.contentsGetter(), existingFileHelper));
generator.addProvider(event.includeServer(), new ModGlobalLootModifiersProvider(packOutput));
generator.addProvider(event.includeServer(), new ModPoiTypeTagsProvider(packOutput, lookupProvider, existingFileHelper));
}
}

View File

@@ -53,6 +53,8 @@ public class ModItemModelProvider extends ItemModelProvider {
simpleItem(ModItems.CORN);
simpleItem(ModItems.CORN_SEEDS);
simpleItem(ModItems.BAR_BRAWL_MUSIC_DISC);
simpleBlockItem(ModBlocks.SAPPHIRE_DOOR);
fenceItem(ModBlocks.SAPPHIRE_FENCE, ModBlocks.SAPPHIRE_BLOCK);
@@ -78,6 +80,8 @@ public class ModItemModelProvider extends ItemModelProvider {
trimmedArmorItem(ModItems.SAPPHIRE_BOOTS);
simpleBlockItemBlockTexture(ModBlocks.CATMINT);
withExistingParent(ModItems.RHINO_SPANW_EGG.getId().getPath(), mcLoc("item/template_spawn_egg"));
}
// Shoutout to El_Redstoniano for making this

View File

@@ -25,5 +25,11 @@ public class ModItemTagGenerator extends ItemTagsProvider {
ModItems.SAPPHIRE_CHESTPLATE.get(),
ModItems.SAPPHIRE_LEGGINGS.get(),
ModItems.SAPPHIRE_BOOTS.get());
this.tag(ItemTags.MUSIC_DISCS)
.add(ModItems.BAR_BRAWL_MUSIC_DISC.get());
this.tag(ItemTags.CREEPER_DROP_MUSIC_DISCS)
.add(ModItems.BAR_BRAWL_MUSIC_DISC.get());
}
}

View File

@@ -0,0 +1,24 @@
package net.kaupenjoe.tutorialmod.datagen;
import net.kaupenjoe.tutorialmod.TutorialMod;
import net.minecraft.core.HolderLookup;
import net.minecraft.data.PackOutput;
import net.minecraft.data.tags.PoiTypeTagsProvider;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.PoiTypeTags;
import net.minecraftforge.common.data.ExistingFileHelper;
import org.jetbrains.annotations.Nullable;
import java.util.concurrent.CompletableFuture;
public class ModPoiTypeTagsProvider extends PoiTypeTagsProvider {
public ModPoiTypeTagsProvider(PackOutput pOutput, CompletableFuture<HolderLookup.Provider> pProvider, @Nullable ExistingFileHelper existingFileHelper) {
super(pOutput, pProvider, TutorialMod.MOD_ID, existingFileHelper);
}
@Override
protected void addTags(HolderLookup.Provider pProvider) {
tag(PoiTypeTags.ACQUIRABLE_JOB_SITE)
.addOptional(new ResourceLocation(TutorialMod.MOD_ID, "sound_poi"));
}
}

View File

@@ -0,0 +1,24 @@
package net.kaupenjoe.tutorialmod.entity;
import net.kaupenjoe.tutorialmod.TutorialMod;
import net.kaupenjoe.tutorialmod.entity.custom.RhinoEntity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.MobCategory;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
public class ModEntities {
public static final DeferredRegister<EntityType<?>> ENTITY_TYPES =
DeferredRegister.create(ForgeRegistries.ENTITY_TYPES, TutorialMod.MOD_ID);
public static final RegistryObject<EntityType<RhinoEntity>> RHINO =
ENTITY_TYPES.register("rhino", () -> EntityType.Builder.of(RhinoEntity::new, MobCategory.CREATURE)
.sized(2.5f, 2.5f).build("rhino"));
public static void register(IEventBus eventBus) {
ENTITY_TYPES.register(eventBus);
}
}

View File

@@ -0,0 +1,88 @@
package net.kaupenjoe.tutorialmod.entity.ai;
import net.kaupenjoe.tutorialmod.entity.custom.RhinoEntity;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.PathfinderMob;
import net.minecraft.world.entity.ai.goal.MeleeAttackGoal;
public class RhinoAttackGoal extends MeleeAttackGoal {
private final RhinoEntity entity;
private int attackDelay = 40;
private int ticksUntilNextAttack = 40;
private boolean shouldCountTillNextAttack = false;
public RhinoAttackGoal(PathfinderMob pMob, double pSpeedModifier, boolean pFollowingTargetEvenIfNotSeen) {
super(pMob, pSpeedModifier, pFollowingTargetEvenIfNotSeen);
entity = ((RhinoEntity) pMob);
}
@Override
public void start() {
super.start();
attackDelay = 40;
ticksUntilNextAttack = 40;
}
@Override
protected void checkAndPerformAttack(LivingEntity pEnemy, double pDistToEnemySqr) {
if (isEnemyWithinAttackDistance(pEnemy, pDistToEnemySqr)) {
shouldCountTillNextAttack = true;
if(isTimeToStartAttackAnimation()) {
entity.setAttacking(true);
}
if(isTimeToAttack()) {
this.mob.getLookControl().setLookAt(pEnemy.getX(), pEnemy.getEyeY(), pEnemy.getZ());
performAttack(pEnemy);
}
} else {
resetAttackCooldown();
shouldCountTillNextAttack = false;
entity.setAttacking(false);
entity.attackAnimationTimeout = 0;
}
}
private boolean isEnemyWithinAttackDistance(LivingEntity pEnemy, double pDistToEnemySqr) {
return pDistToEnemySqr <= this.getAttackReachSqr(pEnemy);
}
protected void resetAttackCooldown() {
this.ticksUntilNextAttack = this.adjustedTickDelay(attackDelay * 2);
}
protected boolean isTimeToAttack() {
return this.ticksUntilNextAttack <= 0;
}
protected boolean isTimeToStartAttackAnimation() {
return this.ticksUntilNextAttack <= attackDelay;
}
protected int getTicksUntilNextAttack() {
return this.ticksUntilNextAttack;
}
protected void performAttack(LivingEntity pEnemy) {
this.resetAttackCooldown();
this.mob.swing(InteractionHand.MAIN_HAND);
this.mob.doHurtTarget(pEnemy);
}
@Override
public void tick() {
super.tick();
if(shouldCountTillNextAttack) {
this.ticksUntilNextAttack = Math.max(this.ticksUntilNextAttack - 1, 0);
}
}
@Override
public void stop() {
entity.setAttacking(false);
super.stop();
}
}

View File

@@ -0,0 +1,369 @@
package net.kaupenjoe.tutorialmod.entity.animations;
import net.minecraft.client.animation.AnimationChannel;
import net.minecraft.client.animation.AnimationDefinition;
import net.minecraft.client.animation.Keyframe;
import net.minecraft.client.animation.KeyframeAnimations;
public class ModAnimationDefinitions {
public static final AnimationDefinition RHINO_IDLE = AnimationDefinition.Builder.withLength(2f).looping()
.addAnimation("rhino",
new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1f, KeyframeAnimations.posVec(0f, 1f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(2f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("body",
new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.5f, KeyframeAnimations.posVec(0f, -0.5f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.4583433f, KeyframeAnimations.posVec(0f, -0.5f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.9583433f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(2f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("torso",
new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.5f, KeyframeAnimations.posVec(0f, -1f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(2f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("torso",
new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.5f, KeyframeAnimations.degreeVec(1f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.4583433f, KeyframeAnimations.degreeVec(-1f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.9583433f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(2f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR))).build();
public static final AnimationDefinition RHINO_WALK = AnimationDefinition.Builder.withLength(2f).looping()
.addAnimation("torso",
new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0.125f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.75f, KeyframeAnimations.posVec(0f, 1f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1f, KeyframeAnimations.posVec(0f, 1.5f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(2f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("left_back_leg",
new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0.9167666f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.25f, KeyframeAnimations.posVec(0f, -1f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.6766667f, KeyframeAnimations.posVec(0f, -1f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(2f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("left_back_leg",
new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0.9167666f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.25f, KeyframeAnimations.degreeVec(2.5f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.6766667f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(2f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("left_back_knee",
new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0.9167666f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.25f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.6766667f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(2f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("left_back_knee",
new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0.9167666f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.25f, KeyframeAnimations.degreeVec(7.5f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.6766667f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(2f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("left_back_heel",
new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0.9167666f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.25f, KeyframeAnimations.posVec(0f, 1f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.6766667f, KeyframeAnimations.posVec(0f, 1f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(2f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("left_back_heel",
new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0.9167666f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.25f, KeyframeAnimations.degreeVec(-7.16f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.6766667f, KeyframeAnimations.degreeVec(-2.5f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(2f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("right_back_leg",
new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.375f, KeyframeAnimations.posVec(0f, -1f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.7083434f, KeyframeAnimations.posVec(0f, -1.25f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.125f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("right_back_leg",
new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.375f, KeyframeAnimations.degreeVec(5f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.7083434f, KeyframeAnimations.degreeVec(2.5f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.125f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("right_back_knee",
new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.375f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.7083434f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.125f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("right_back_knee",
new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.375f, KeyframeAnimations.degreeVec(7.5f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.7083434f, KeyframeAnimations.degreeVec(5f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.125f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("right_back_heel",
new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.2916767f, KeyframeAnimations.posVec(0f, 1f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.5834334f, KeyframeAnimations.posVec(0f, 1.5f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("right_back_heel",
new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.2916767f, KeyframeAnimations.degreeVec(-10f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.5834334f, KeyframeAnimations.degreeVec(-7.5f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("right_front_leg",
new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(1f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.2916767f, KeyframeAnimations.posVec(0f, -1f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.625f, KeyframeAnimations.posVec(0f, -1f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(2f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("right_front_leg",
new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(1f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.2916767f, KeyframeAnimations.degreeVec(-7.5f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.625f, KeyframeAnimations.degreeVec(-2.5f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(2f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("right_front_knee",
new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(1f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.2916767f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.625f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(2f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("right_front_knee",
new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(1f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.2916767f, KeyframeAnimations.degreeVec(10f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.625f, KeyframeAnimations.degreeVec(2.5f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(2f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("left_front_leg",
new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.25f, KeyframeAnimations.posVec(0f, -1f, -1f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.6766666f, KeyframeAnimations.posVec(0f, -1f, 1f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("left_front_leg",
new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.25f, KeyframeAnimations.degreeVec(-5f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.6766666f, KeyframeAnimations.degreeVec(-2.5f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("left_front_knee",
new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.25f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.6766666f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("left_front_knee",
new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.25f, KeyframeAnimations.degreeVec(10f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.6766666f, KeyframeAnimations.degreeVec(17.5f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR))).build();
public static final AnimationDefinition RHINO_ATTACK = AnimationDefinition.Builder.withLength(4f).looping()
.addAnimation("skull",
new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.5f, KeyframeAnimations.degreeVec(22.5f, 0f, -45f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(2f, KeyframeAnimations.degreeVec(22.5f, 0f, -45f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(2.5f, KeyframeAnimations.degreeVec(-60.03f, 17.68f, -19.21f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(3.5f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(4f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR))).build();
public static final AnimationDefinition RHINO_SIT = AnimationDefinition.Builder.withLength(2f).looping()
.addAnimation("rhino",
new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0f, KeyframeAnimations.posVec(0f, -1f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(2f, KeyframeAnimations.posVec(0f, -1f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("body",
new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0f, KeyframeAnimations.posVec(0f, -4f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.5f, KeyframeAnimations.posVec(0f, -4.5f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.4583433f, KeyframeAnimations.posVec(0f, -4.5f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.9583433f, KeyframeAnimations.posVec(0f, -4f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(2f, KeyframeAnimations.posVec(0f, -4f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("body",
new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0f, KeyframeAnimations.degreeVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("torso",
new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.5f, KeyframeAnimations.posVec(0f, -1f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(2f, KeyframeAnimations.posVec(0f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("torso",
new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0f, KeyframeAnimations.degreeVec(-7.5f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(0.5f, KeyframeAnimations.degreeVec(-10f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.4583433f, KeyframeAnimations.degreeVec(-10f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(1.9583433f, KeyframeAnimations.degreeVec(-10f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR),
new Keyframe(2f, KeyframeAnimations.degreeVec(-10f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("left_back_leg",
new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0f, KeyframeAnimations.posVec(0f, -11f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("left_back_knee",
new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0f, KeyframeAnimations.posVec(0f, 3f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("left_back_knee",
new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0f, KeyframeAnimations.degreeVec(-25f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("left_back_heel",
new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0f, KeyframeAnimations.posVec(0f, 2f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("left_back_heel",
new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0f, KeyframeAnimations.degreeVec(27.5f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("right_back_leg",
new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0f, KeyframeAnimations.posVec(0f, -11f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("right_back_knee",
new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0f, KeyframeAnimations.posVec(0f, 4f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("right_back_knee",
new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0f, KeyframeAnimations.degreeVec(-22.5f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("right_back_heel",
new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0f, KeyframeAnimations.posVec(0f, 1f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("right_back_heel",
new AnimationChannel(AnimationChannel.Targets.ROTATION,
new Keyframe(0f, KeyframeAnimations.degreeVec(25f, 0f, 0f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("right_front_leg",
new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0f, KeyframeAnimations.posVec(0f, 0f, 2f),
AnimationChannel.Interpolations.LINEAR)))
.addAnimation("left_front_leg",
new AnimationChannel(AnimationChannel.Targets.POSITION,
new Keyframe(0f, KeyframeAnimations.posVec(0f, 0f, 2f),
AnimationChannel.Interpolations.LINEAR))).build();
}

View File

@@ -0,0 +1,11 @@
package net.kaupenjoe.tutorialmod.entity.client;
import net.kaupenjoe.tutorialmod.TutorialMod;
import net.minecraft.client.model.geom.ModelLayerLocation;
import net.minecraft.resources.ResourceLocation;
public class ModModelLayers {
public static final ModelLayerLocation RHINO_LAYER = new ModelLayerLocation(
new ResourceLocation(TutorialMod.MOD_ID, "rhino_layer"), "main");
}

View File

@@ -0,0 +1,111 @@
package net.kaupenjoe.tutorialmod.entity.client;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import net.kaupenjoe.tutorialmod.entity.animations.ModAnimationDefinitions;
import net.kaupenjoe.tutorialmod.entity.custom.RhinoEntity;
import net.minecraft.client.model.HierarchicalModel;
import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.client.model.geom.PartPose;
import net.minecraft.client.model.geom.builders.*;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity;
public class RhinoModel<T extends Entity> extends HierarchicalModel<T> {
private final ModelPart rhino;
private final ModelPart head;
public RhinoModel(ModelPart root) {
this.rhino = root.getChild("rhino");
this.head = rhino.getChild("body").getChild("torso").getChild("head");
}
public static LayerDefinition createBodyLayer() {
MeshDefinition meshdefinition = new MeshDefinition();
PartDefinition partdefinition = meshdefinition.getRoot();
PartDefinition rhino = partdefinition.addOrReplaceChild("rhino", CubeListBuilder.create(), PartPose.offset(0.0F, 24.0F, 2.5F));
PartDefinition body = rhino.addOrReplaceChild("body", CubeListBuilder.create(), PartPose.offset(0.0F, 0.0F, 0.0F));
PartDefinition torso = body.addOrReplaceChild("torso", CubeListBuilder.create().texOffs(0, 0).addBox(-10.0F, -38.0F, -26.0F, 20.0F, 24.0F, 16.0F, new CubeDeformation(0.0F))
.texOffs(0, 41).addBox(-9.0F, -37.0F, -10.0F, 18.0F, 25.0F, 16.0F, new CubeDeformation(0.0F))
.texOffs(53, 67).addBox(-7.0F, -37.0F, 6.0F, 14.0F, 21.0F, 16.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 0.0F, 0.0F));
PartDefinition head = torso.addOrReplaceChild("head", CubeListBuilder.create(), PartPose.offset(0.0F, -21.0F, -26.0F));
PartDefinition skull = head.addOrReplaceChild("skull", CubeListBuilder.create().texOffs(69, 29).addBox(-6.0F, -9.0F, -12.0F, 12.0F, 20.0F, 12.0F, new CubeDeformation(0.0F))
.texOffs(0, 8).addBox(-1.0F, -1.0F, -15.0F, 2.0F, 2.0F, 3.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 0.0F, 0.0F));
PartDefinition horn = skull.addOrReplaceChild("horn", CubeListBuilder.create().texOffs(0, 102).addBox(-5.0F, -5.0F, -9.0F, 5.0F, 5.0F, 9.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(2.5F, 8.5F, -11.0F, -0.1745F, 0.0F, 0.0F));
PartDefinition horn2 = horn.addOrReplaceChild("horn2", CubeListBuilder.create().texOffs(103, 15).addBox(-3.0F, -3.0F, -9.0F, 3.0F, 3.0F, 9.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(-1.0F, -1.0F, -9.0F, -0.4363F, 0.0F, 0.0F));
PartDefinition left_ear = skull.addOrReplaceChild("left_ear", CubeListBuilder.create().texOffs(0, 0).addBox(-1.0F, -5.0F, -0.5F, 4.0F, 6.0F, 1.0F, new CubeDeformation(0.0F)), PartPose.offset(5.0F, -8.0F, -9.5F));
PartDefinition right_ear = skull.addOrReplaceChild("right_ear", CubeListBuilder.create().texOffs(0, 0).mirror().addBox(-3.0F, -5.0F, -0.5F, 4.0F, 6.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false), PartPose.offset(-5.0F, -8.0F, -9.5F));
PartDefinition left_eye = skull.addOrReplaceChild("left_eye", CubeListBuilder.create().texOffs(55, 46).addBox(-0.45F, -0.4F, -0.9F, 1.0F, 1.0F, 1.0F, new CubeDeformation(0.0F))
.texOffs(57, 46).addBox(-0.55F, -1.6F, -1.1F, 1.0F, 3.0F, 3.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(5.8F, 5.1F, -9.4F, 0.2618F, 0.0F, 0.0F));
PartDefinition left_eyelid = skull.addOrReplaceChild("left_eyelid", CubeListBuilder.create().texOffs(42, 85).addBox(-0.55F, -2.1F, -1.6F, 1.0F, 4.0F, 4.0F, new CubeDeformation(0.0F)), PartPose.offset(5.05F, 5.1F, -9.4F));
PartDefinition right_eyelid = skull.addOrReplaceChild("right_eyelid", CubeListBuilder.create().texOffs(42, 85).mirror().addBox(-0.45F, -2.1F, -1.6F, 1.0F, 4.0F, 4.0F, new CubeDeformation(0.0F)).mirror(false), PartPose.offset(-5.05F, 5.1F, -9.4F));
PartDefinition right_eye = skull.addOrReplaceChild("right_eye", CubeListBuilder.create().texOffs(55, 46).mirror().addBox(-0.55F, -0.4F, -0.9F, 1.0F, 1.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false)
.texOffs(57, 46).mirror().addBox(-0.45F, -1.6F, -1.1F, 1.0F, 3.0F, 3.0F, new CubeDeformation(0.0F)).mirror(false), PartPose.offsetAndRotation(-5.8F, 5.1F, -9.4F, 0.2618F, 0.0F, 0.0F));
PartDefinition tail = torso.addOrReplaceChild("tail", CubeListBuilder.create().texOffs(16, 88).addBox(-1.5F, 0.0F, 0.0F, 3.0F, 0.0F, 13.0F, new CubeDeformation(0.0F))
.texOffs(57, 0).addBox(-2.5F, 0.0F, 13.0F, 5.0F, 0.0F, 7.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.0F, -35.0F, 22.0F, -1.309F, 0.0F, 0.0F));
PartDefinition left_back_leg = body.addOrReplaceChild("left_back_leg", CubeListBuilder.create().texOffs(73, 0).addBox(-4.5F, -4.5F, -5.0F, 9.0F, 13.0F, 10.0F, new CubeDeformation(0.0F)), PartPose.offset(7.0F, -28.5F, 15.5F));
PartDefinition left_back_knee = left_back_leg.addOrReplaceChild("left_back_knee", CubeListBuilder.create().texOffs(98, 62).addBox(-3.5F, 0.0F, -1.0F, 7.0F, 10.0F, 7.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 8.5F, -3.0F));
PartDefinition left_back_heel = left_back_knee.addOrReplaceChild("left_back_heel", CubeListBuilder.create().texOffs(54, 105).addBox(-3.0F, 0.0F, 0.0F, 6.0F, 10.0F, 6.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 10.0F, -0.5F));
PartDefinition right_back_leg = body.addOrReplaceChild("right_back_leg", CubeListBuilder.create().texOffs(73, 0).mirror().addBox(-4.5F, -4.5F, -5.0F, 9.0F, 13.0F, 10.0F, new CubeDeformation(0.0F)).mirror(false), PartPose.offset(-7.0F, -28.5F, 15.5F));
PartDefinition right_back_knee = right_back_leg.addOrReplaceChild("right_back_knee", CubeListBuilder.create().texOffs(98, 62).mirror().addBox(-3.5F, 0.0F, -1.0F, 7.0F, 10.0F, 7.0F, new CubeDeformation(0.0F)).mirror(false), PartPose.offset(0.0F, 8.5F, -3.0F));
PartDefinition right_back_heel = right_back_knee.addOrReplaceChild("right_back_heel", CubeListBuilder.create().texOffs(54, 105).mirror().addBox(-3.0F, 0.0F, 0.0F, 6.0F, 10.0F, 6.0F, new CubeDeformation(0.0F)).mirror(false), PartPose.offset(0.0F, 10.0F, -0.5F));
PartDefinition right_front_leg = body.addOrReplaceChild("right_front_leg", CubeListBuilder.create().texOffs(100, 111).mirror().addBox(-3.5F, -3.0F, -3.0F, 7.0F, 10.0F, 7.0F, new CubeDeformation(0.0F)).mirror(false), PartPose.offset(-7.0F, -17.0F, -20.5F));
PartDefinition right_front_knee = right_front_leg.addOrReplaceChild("right_front_knee", CubeListBuilder.create().texOffs(54, 105).mirror().addBox(-3.0F, 0.0F, 0.0F, 6.0F, 10.0F, 6.0F, new CubeDeformation(0.0F)).mirror(false), PartPose.offset(0.0F, 7.0F, -2.5F));
PartDefinition left_front_leg = body.addOrReplaceChild("left_front_leg", CubeListBuilder.create().texOffs(100, 111).addBox(-3.5F, -3.0F, -3.0F, 7.0F, 10.0F, 7.0F, new CubeDeformation(0.0F)), PartPose.offset(7.0F, -17.0F, -20.5F));
PartDefinition left_front_knee = left_front_leg.addOrReplaceChild("left_front_knee", CubeListBuilder.create().texOffs(54, 105).addBox(-3.0F, 0.0F, 0.0F, 6.0F, 10.0F, 6.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 7.0F, -2.5F));
return LayerDefinition.create(meshdefinition, 128, 128);
}
@Override
public void setupAnim(T entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {
this.root().getAllParts().forEach(ModelPart::resetPose);
this.applyHeadRotation(netHeadYaw, headPitch, ageInTicks);
this.animateWalk(ModAnimationDefinitions.RHINO_WALK, limbSwing, limbSwingAmount, 2f, 2.5f);
this.animate(((RhinoEntity) entity).idleAnimationState, ModAnimationDefinitions.RHINO_IDLE, ageInTicks, 1f);
this.animate(((RhinoEntity) entity).attackAnimationState, ModAnimationDefinitions.RHINO_ATTACK, ageInTicks, 1f);
}
private void applyHeadRotation(float pNetHeadYaw, float pHeadPitch, float pAgeInTicks) {
pNetHeadYaw = Mth.clamp(pNetHeadYaw, -30.0F, 30.0F);
pHeadPitch = Mth.clamp(pHeadPitch, -25.0F, 45.0F);
this.head.yRot = pNetHeadYaw * ((float)Math.PI / 180F);
this.head.xRot = pHeadPitch * ((float)Math.PI / 180F);
}
@Override
public void renderToBuffer(PoseStack poseStack, VertexConsumer vertexConsumer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha) {
rhino.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
}
@Override
public ModelPart root() {
return rhino;
}
}

View File

@@ -0,0 +1,30 @@
package net.kaupenjoe.tutorialmod.entity.client;
import com.mojang.blaze3d.vertex.PoseStack;
import net.kaupenjoe.tutorialmod.TutorialMod;
import net.kaupenjoe.tutorialmod.entity.custom.RhinoEntity;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.client.renderer.entity.MobRenderer;
import net.minecraft.resources.ResourceLocation;
public class RhinoRenderer extends MobRenderer<RhinoEntity, RhinoModel<RhinoEntity>> {
public RhinoRenderer(EntityRendererProvider.Context pContext) {
super(pContext, new RhinoModel<>(pContext.bakeLayer(ModModelLayers.RHINO_LAYER)), 2f);
}
@Override
public ResourceLocation getTextureLocation(RhinoEntity pEntity) {
return new ResourceLocation(TutorialMod.MOD_ID, "textures/entity/rhino.png");
}
@Override
public void render(RhinoEntity pEntity, float pEntityYaw, float pPartialTicks, PoseStack pMatrixStack,
MultiBufferSource pBuffer, int pPackedLight) {
if(pEntity.isBaby()) {
pMatrixStack.scale(0.5f, 0.5f, 0.5f);
}
super.render(pEntity, pEntityYaw, pPartialTicks, pMatrixStack, pBuffer, pPackedLight);
}
}

View File

@@ -0,0 +1,154 @@
package net.kaupenjoe.tutorialmod.entity.custom;
import net.kaupenjoe.tutorialmod.entity.ModEntities;
import net.kaupenjoe.tutorialmod.entity.ai.RhinoAttackGoal;
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.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.Pose;
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.ai.goal.target.HurtByTargetGoal;
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;
public class RhinoEntity extends Animal {
private static final EntityDataAccessor<Boolean> ATTACKING =
SynchedEntityData.defineId(RhinoEntity.class, EntityDataSerializers.BOOLEAN);
public RhinoEntity(EntityType<? extends Animal> pEntityType, Level pLevel) {
super(pEntityType, pLevel);
}
public final AnimationState idleAnimationState = new AnimationState();
private int idleAnimationTimeout = 0;
public final AnimationState attackAnimationState = new AnimationState();
public int attackAnimationTimeout = 0;
@Override
public void tick() {
super.tick();
if(this.level().isClientSide()) {
setupAnimationStates();
}
}
private void setupAnimationStates() {
if(this.idleAnimationTimeout <= 0) {
this.idleAnimationTimeout = this.random.nextInt(40) + 80;
this.idleAnimationState.start(this.tickCount);
} else {
--this.idleAnimationTimeout;
}
if(this.isAttacking() && attackAnimationTimeout <= 0) {
attackAnimationTimeout = 80; // Length in ticks of your animation
attackAnimationState.start(this.tickCount);
} else {
--this.attackAnimationTimeout;
}
if(!this.isAttacking()) {
attackAnimationState.stop();
}
}
@Override
protected void updateWalkAnimation(float pPartialTick) {
float f;
if(this.getPose() == Pose.STANDING) {
f = Math.min(pPartialTick * 6F, 1f);
} else {
f = 0f;
}
this.walkAnimation.update(f, 0.2f);
}
public void setAttacking(boolean attacking) {
this.entityData.set(ATTACKING, attacking);
}
public boolean isAttacking() {
return this.entityData.get(ATTACKING);
}
@Override
protected void defineSynchedData() {
super.defineSynchedData();
this.entityData.define(ATTACKING, false);
}
@Override
protected void registerGoals() {
this.goalSelector.addGoal(0, new FloatGoal(this));
this.goalSelector.addGoal(1, new RhinoAttackGoal(this, 1.0D, true));
this.goalSelector.addGoal(1, new BreedGoal(this, 1.15D));
this.goalSelector.addGoal(2, new TemptGoal(this, 1.2D, Ingredient.of(Items.COOKED_BEEF), false));
this.goalSelector.addGoal(3, new FollowParentGoal(this, 1.1D));
this.goalSelector.addGoal(4, new WaterAvoidingRandomStrollGoal(this, 1.1D));
this.goalSelector.addGoal(5, new LookAtPlayerGoal(this, Player.class, 3f));
this.goalSelector.addGoal(6, new RandomLookAroundGoal(this));
this.targetSelector.addGoal(1, new HurtByTargetGoal(this));
}
public static AttributeSupplier.Builder createAttributes() {
return Animal.createLivingAttributes()
.add(Attributes.MAX_HEALTH, 20D)
.add(Attributes.FOLLOW_RANGE, 24D)
.add(Attributes.MOVEMENT_SPEED, 0.25D)
.add(Attributes.ARMOR_TOUGHNESS, 0.1f)
.add(Attributes.ATTACK_KNOCKBACK, 0.5f)
.add(Attributes.ATTACK_DAMAGE, 2f);
}
@Nullable
@Override
public AgeableMob getBreedOffspring(ServerLevel pLevel, AgeableMob pOtherParent) {
return ModEntities.RHINO.get().create(pLevel);
}
@Override
public boolean isFood(ItemStack pStack) {
return pStack.is(Items.COOKED_BEEF);
}
@Nullable
@Override
protected SoundEvent getAmbientSound() {
return SoundEvents.HOGLIN_AMBIENT;
}
@Nullable
@Override
protected SoundEvent getHurtSound(DamageSource pDamageSource) {
return SoundEvents.RAVAGER_HURT;
}
@Nullable
@Override
protected SoundEvent getDeathSound() {
return SoundEvents.DOLPHIN_DEATH;
}
}

View File

@@ -0,0 +1,17 @@
package net.kaupenjoe.tutorialmod.event;
import net.kaupenjoe.tutorialmod.TutorialMod;
import net.kaupenjoe.tutorialmod.entity.client.ModModelLayers;
import net.kaupenjoe.tutorialmod.entity.client.RhinoModel;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.EntityRenderersEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
@Mod.EventBusSubscriber(modid = TutorialMod.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
public class ModEventBusClientEvents {
@SubscribeEvent
public static void registerLayer(EntityRenderersEvent.RegisterLayerDefinitions event) {
event.registerLayerDefinition(ModModelLayers.RHINO_LAYER, RhinoModel::createBodyLayer);
}
}

View File

@@ -0,0 +1,16 @@
package net.kaupenjoe.tutorialmod.event;
import net.kaupenjoe.tutorialmod.TutorialMod;
import net.kaupenjoe.tutorialmod.entity.ModEntities;
import net.kaupenjoe.tutorialmod.entity.custom.RhinoEntity;
import net.minecraftforge.event.entity.EntityAttributeCreationEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
@Mod.EventBusSubscriber(modid = TutorialMod.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
public class ModEventBusEvents {
@SubscribeEvent
public static void registerAttributes(EntityAttributeCreationEvent event) {
event.put(ModEntities.RHINO.get(), RhinoEntity.createAttributes().build());
}
}

View File

@@ -2,7 +2,9 @@ package net.kaupenjoe.tutorialmod.event;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import net.kaupenjoe.tutorialmod.TutorialMod;
import net.kaupenjoe.tutorialmod.block.ModBlocks;
import net.kaupenjoe.tutorialmod.item.ModItems;
import net.kaupenjoe.tutorialmod.villager.ModVillagers;
import net.minecraft.world.entity.npc.VillagerProfession;
import net.minecraft.world.entity.npc.VillagerTrades;
import net.minecraft.world.item.EnchantedBookItem;
@@ -56,6 +58,20 @@ public class ModEvents {
enchantedBook,
2, 8, 0.02f));
}
if(event.getType() == ModVillagers.SOUND_MASTER.get()) {
Int2ObjectMap<List<VillagerTrades.ItemListing>> trades = event.getTrades();
trades.get(1).add((pTrader, pRandom) -> new MerchantOffer(
new ItemStack(Items.EMERALD, 16),
new ItemStack(ModBlocks.SOUND_BLOCK.get(), 1),
16, 8, 0.02f));
trades.get(2).add((pTrader, pRandom) -> new MerchantOffer(
new ItemStack(Items.EMERALD, 6),
new ItemStack(ModBlocks.SAPPHIRE_ORE.get(), 2),
5, 12, 0.02f));
}
}
@SubscribeEvent

View File

@@ -46,6 +46,9 @@ public class ModCreativeModTabs {
pOutput.accept(ModItems.CORN.get());
pOutput.accept(ModItems.CORN_SEEDS.get());
pOutput.accept(ModItems.BAR_BRAWL_MUSIC_DISC.get());
pOutput.accept(ModItems.RHINO_SPANW_EGG.get());
pOutput.accept(ModBlocks.SAPPHIRE_BLOCK.get());
pOutput.accept(ModBlocks.RAW_SAPPHIRE_BLOCK.get());

View File

@@ -2,10 +2,13 @@ package net.kaupenjoe.tutorialmod.item;
import net.kaupenjoe.tutorialmod.TutorialMod;
import net.kaupenjoe.tutorialmod.block.ModBlocks;
import net.kaupenjoe.tutorialmod.entity.ModEntities;
import net.kaupenjoe.tutorialmod.item.custom.FuelItem;
import net.kaupenjoe.tutorialmod.item.custom.MetalDetectorItem;
import net.kaupenjoe.tutorialmod.item.custom.ModArmorItem;
import net.kaupenjoe.tutorialmod.sound.ModSounds;
import net.minecraft.world.item.*;
import net.minecraftforge.common.ForgeSpawnEggItem;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
@@ -61,6 +64,11 @@ public class ModItems {
public static final RegistryObject<Item> CORN = ITEMS.register("corn",
() -> new Item(new Item.Properties()));
public static final RegistryObject<Item> BAR_BRAWL_MUSIC_DISC = ITEMS.register("bar_brawl_music_disc",
() -> new RecordItem(6, ModSounds.BAR_BRAWL, new Item.Properties().stacksTo(1), 2440));
public static final RegistryObject<Item> RHINO_SPANW_EGG = ITEMS.register("rhino_spawn_egg",
() -> new ForgeSpawnEggItem(ModEntities.RHINO, 0x7e9680, 0xc5d1c5, new Item.Properties()));
public static void register(IEventBus eventBus) {
ITEMS.register(eventBus);

View File

@@ -1,9 +1,11 @@
package net.kaupenjoe.tutorialmod.item.custom;
import net.kaupenjoe.tutorialmod.sound.ModSounds;
import net.kaupenjoe.tutorialmod.util.ModTags;
import net.minecraft.client.resources.language.I18n;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
@@ -37,6 +39,9 @@ public class MetalDetectorItem extends Item {
outputValuableCoordinates(positionClicked.below(i), player, state.getBlock());
foundBlock = true;
pContext.getLevel().playSeededSound(null, positionClicked.getX(), positionClicked.getY(), positionClicked.getZ(),
ModSounds.METAL_DETECTOR_FOUND_ORE.get(), SoundSource.BLOCKS, 1f, 1f, 0);
break;
}
}

View File

@@ -0,0 +1,39 @@
package net.kaupenjoe.tutorialmod.sound;
import net.kaupenjoe.tutorialmod.TutorialMod;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvent;
import net.minecraftforge.common.util.ForgeSoundType;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
public class ModSounds {
public static final DeferredRegister<SoundEvent> SOUND_EVENTS =
DeferredRegister.create(ForgeRegistries.SOUND_EVENTS, TutorialMod.MOD_ID);
public static final RegistryObject<SoundEvent> METAL_DETECTOR_FOUND_ORE = registerSoundEvents("metal_detector_found_ore");
public static final RegistryObject<SoundEvent> SOUND_BLOCK_BREAK = registerSoundEvents("sound_block_break");
public static final RegistryObject<SoundEvent> SOUND_BLOCK_STEP = registerSoundEvents("sound_block_step");
public static final RegistryObject<SoundEvent> SOUND_BLOCK_FALL = registerSoundEvents("sound_block_fall");
public static final RegistryObject<SoundEvent> SOUND_BLOCK_PLACE = registerSoundEvents("sound_block_place");
public static final RegistryObject<SoundEvent> SOUND_BLOCK_HIT = registerSoundEvents("sound_block_hit");
public static final RegistryObject<SoundEvent> BAR_BRAWL = registerSoundEvents("bar_brawl");
public static final ForgeSoundType SOUND_BLOCK_SOUNDS = new ForgeSoundType(1f, 1f,
ModSounds.SOUND_BLOCK_BREAK, ModSounds.SOUND_BLOCK_STEP, ModSounds.SOUND_BLOCK_PLACE,
ModSounds.SOUND_BLOCK_HIT, ModSounds.SOUND_BLOCK_FALL);
private static RegistryObject<SoundEvent> registerSoundEvents(String name) {
return SOUND_EVENTS.register(name, () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(TutorialMod.MOD_ID, name)));
}
public static void register(IEventBus eventBus) {
SOUND_EVENTS.register(eventBus);
}
}

View File

@@ -0,0 +1,35 @@
package net.kaupenjoe.tutorialmod.villager;
import com.google.common.collect.ImmutableSet;
import net.kaupenjoe.tutorialmod.TutorialMod;
import net.kaupenjoe.tutorialmod.block.ModBlocks;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.entity.ai.village.poi.PoiType;
import net.minecraft.world.entity.npc.VillagerProfession;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
public class ModVillagers {
public static final DeferredRegister<PoiType> POI_TYPES =
DeferredRegister.create(ForgeRegistries.POI_TYPES, TutorialMod.MOD_ID);
public static final DeferredRegister<VillagerProfession> VILLAGER_PROFESSIONS =
DeferredRegister.create(ForgeRegistries.VILLAGER_PROFESSIONS, TutorialMod.MOD_ID);
public static final RegistryObject<PoiType> SOUND_POI = POI_TYPES.register("sound_poi",
() -> new PoiType(ImmutableSet.copyOf(ModBlocks.SOUND_BLOCK.get().getStateDefinition().getPossibleStates()),
1, 1));
public static final RegistryObject<VillagerProfession> SOUND_MASTER =
VILLAGER_PROFESSIONS.register("soundmaster", () -> new VillagerProfession("soundmaster",
holder -> holder.get() == SOUND_POI.get(), holder -> holder.get() == SOUND_POI.get(),
ImmutableSet.of(), ImmutableSet.of(), SoundEvents.VILLAGER_WORK_ARMORER));
public static void register(IEventBus eventBus) {
POI_TYPES.register(eventBus);
VILLAGER_PROFESSIONS.register(eventBus);
}
}

View File

@@ -23,6 +23,9 @@
"item.tutorialmod.corn": "Corn",
"item.tutorialmod.corn_seeds": "Corn Seeds",
"item.tutorialmod.bar_brawl_music_disc": "Bar Brawl Music Disc",
"item.tutorialmod.bar_brawl_music_disc.desc": "Bryan Tech - Bar Brawl (CC0)",
"block.tutorialmod.sapphire_block": "Block of Sapphire",
"block.tutorialmod.raw_sapphire_block": "Block of Raw Sapphire",
@@ -47,6 +50,10 @@
"tooltip.tutorialmod.metal_detector.tooltip": "Finds valuables underground!",
"entity.minecraft.villager.tutorialmod.soundmaster": "Sound Master",
"sounds.tutorialmod.metal_detector_found_ore": "Metal Detector Jingle",
"creativetab.tutorial_tab": "Sapphire Tutorial Tab"
}

View File

@@ -0,0 +1,46 @@
{
"metal_detector_found_ore": {
"subtitles": "sounds.tutorialmod.metal_detector_found_ore",
"sounds": [
"tutorialmod:metal_detector_found_ore"
]
},
"sound_block_break": {
"subtitle": "sounds.tutorialmod.sound_block_break",
"sounds": [
"tutorialmod:sound_block_break"
]
},
"sound_block_step": {
"subtitle": "sounds.tutorialmod.sound_block_step",
"sounds": [
"tutorialmod:sound_block_step"
]
},
"sound_block_place": {
"subtitle": "sounds.tutorialmod.sound_block_place",
"sounds": [
"tutorialmod:sound_block_place"
]
},
"sound_block_hit": {
"subtitle": "sounds.tutorialmod.sound_block_hit",
"sounds": [
"tutorialmod:sound_block_hit"
]
},
"sound_block_fall": {
"subtitle": "sounds.tutorialmod.sound_block_fall",
"sounds": [
"tutorialmod:sound_block_fall"
]
},
"bar_brawl": {
"sounds": [
{
"name": "tutorialmod:bar_brawl",
"stream": true
}
]
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 392 B