-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1 parent
82723f5
commit 5e26cba
Showing
9 changed files
with
182 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/main/java/com/besson/tutorialmod/entity/ModEntities.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.besson.tutorialmod.entity; | ||
|
||
import com.besson.tutorialmod.TutorialMod; | ||
import com.besson.tutorialmod.entity.custom.TigerEntity; | ||
import net.fabricmc.fabric.api.object.builder.v1.entity.FabricEntityTypeBuilder; | ||
import net.minecraft.entity.EntityDimensions; | ||
import net.minecraft.entity.EntityType; | ||
import net.minecraft.entity.SpawnGroup; | ||
import net.minecraft.registry.Registries; | ||
import net.minecraft.registry.Registry; | ||
import net.minecraft.util.Identifier; | ||
|
||
public class ModEntities { | ||
public static final EntityType<TigerEntity> TIGER = Registry.register(Registries.ENTITY_TYPE, | ||
new Identifier(TutorialMod.MOD_ID,"tiger"), | ||
FabricEntityTypeBuilder.create(SpawnGroup.CREATURE,TigerEntity::new) | ||
.dimensions(EntityDimensions.fixed(1f,1f)).build()); | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/besson/tutorialmod/entity/client/ModModelLayers.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.besson.tutorialmod.entity.client; | ||
|
||
import com.besson.tutorialmod.TutorialMod; | ||
import net.minecraft.client.render.entity.model.EntityModelLayer; | ||
import net.minecraft.util.Identifier; | ||
|
||
public class ModModelLayers { | ||
public static final EntityModelLayer TIGER = | ||
new EntityModelLayer(new Identifier(TutorialMod.MOD_ID,"tiger"),"main"); | ||
} |
51 changes: 51 additions & 0 deletions
51
src/main/java/com/besson/tutorialmod/entity/client/TigerModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.besson.tutorialmod.entity.client; | ||
|
||
import com.besson.tutorialmod.entity.custom.TigerEntity; | ||
import net.minecraft.client.model.*; | ||
import net.minecraft.client.render.VertexConsumer; | ||
import net.minecraft.client.render.entity.model.SinglePartEntityModel; | ||
import net.minecraft.client.util.math.MatrixStack; | ||
|
||
// Made with Blockbench 4.9.3 | ||
// Exported for Minecraft version 1.17+ for Yarn | ||
// Paste this class into your mod and generate all required imports | ||
public class TigerModel<T extends TigerEntity> extends SinglePartEntityModel<T> { | ||
private final ModelPart tiger; | ||
public TigerModel(ModelPart root) { | ||
this.tiger = root.getChild("tiger"); | ||
} | ||
public static TexturedModelData getTexturedModelData() { | ||
ModelData modelData = new ModelData(); | ||
ModelPartData modelPartData = modelData.getRoot(); | ||
ModelPartData tiger = modelPartData.addChild("tiger", ModelPartBuilder.create(), ModelTransform.pivot(0.0F, 24.0F, 0.0F)); | ||
|
||
ModelPartData right_back_leg = tiger.addChild("right_back_leg", ModelPartBuilder.create().uv(0, 0).cuboid(-1.0F, 0.0F, -1.0F, 2.0F, 4.0F, 2.0F, new Dilation(0.0F)), ModelTransform.pivot(-3.0F, -4.0F, 4.0F)); | ||
|
||
ModelPartData tail = tiger.addChild("tail", ModelPartBuilder.create(), ModelTransform.pivot(0.0F, -7.2914F, 4.9639F)); | ||
|
||
ModelPartData cube_r1 = tail.addChild("cube_r1", ModelPartBuilder.create().uv(8, 0).cuboid(-0.5F, -4.0F, -3.9F, 1.0F, 6.0F, 1.0F, new Dilation(0.0F)), ModelTransform.of(0.0F, 1.2343F, 3.9312F, -0.7418F, 0.0F, 0.0F)); | ||
|
||
ModelPartData left_front_leg = tiger.addChild("left_front_leg", ModelPartBuilder.create().uv(22, 21).cuboid(-1.0F, 0.0F, -1.0F, 2.0F, 4.0F, 2.0F, new Dilation(0.0F)), ModelTransform.pivot(3.0F, -4.0F, -4.0F)); | ||
|
||
ModelPartData body = tiger.addChild("body", ModelPartBuilder.create().uv(0, 0).cuboid(-3.0F, -2.5F, -6.0F, 6.0F, 5.0F, 12.0F, new Dilation(0.0F)), ModelTransform.pivot(0.0F, -5.5F, 0.0F)); | ||
|
||
ModelPartData left_back_leg = tiger.addChild("left_back_leg", ModelPartBuilder.create().uv(16, 17).cuboid(-1.0F, 0.0F, -1.0F, 2.0F, 4.0F, 2.0F, new Dilation(0.0F)), ModelTransform.pivot(3.0F, -4.0F, 4.0F)); | ||
|
||
ModelPartData right_front_leg = tiger.addChild("right_front_leg", ModelPartBuilder.create().uv(0, 6).cuboid(-1.0F, 0.0F, -1.0F, 2.0F, 4.0F, 2.0F, new Dilation(0.0F)), ModelTransform.pivot(-3.0F, -4.0F, -4.0F)); | ||
|
||
ModelPartData head = tiger.addChild("head", ModelPartBuilder.create().uv(0, 17).cuboid(-2.0F, -2.0F, -2.0F, 4.0F, 4.0F, 4.0F, new Dilation(0.0F)), ModelTransform.pivot(0.0F, -9.0F, -7.0F)); | ||
return TexturedModelData.of(modelData, 64, 64); | ||
} | ||
@Override | ||
public void setAngles(TigerEntity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) { | ||
} | ||
@Override | ||
public void render(MatrixStack matrices, VertexConsumer vertexConsumer, int light, int overlay, float red, float green, float blue, float alpha) { | ||
tiger.render(matrices, vertexConsumer, light, overlay, red, green, blue, alpha); | ||
} | ||
|
||
@Override | ||
public ModelPart getPart() { | ||
return this.tiger; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/com/besson/tutorialmod/entity/client/TigerRenderer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.besson.tutorialmod.entity.client; | ||
|
||
import com.besson.tutorialmod.TutorialMod; | ||
import com.besson.tutorialmod.entity.custom.TigerEntity; | ||
import net.minecraft.client.render.VertexConsumerProvider; | ||
import net.minecraft.client.render.entity.EntityRendererFactory; | ||
import net.minecraft.client.render.entity.MobEntityRenderer; | ||
import net.minecraft.client.util.math.MatrixStack; | ||
import net.minecraft.util.Identifier; | ||
|
||
public class TigerRenderer extends MobEntityRenderer<TigerEntity,TigerModel<TigerEntity>> { | ||
private static final Identifier TEXTURE = new Identifier(TutorialMod.MOD_ID,"textures/entity/tiger.png"); | ||
public TigerRenderer(EntityRendererFactory.Context context) { | ||
super(context, new TigerModel<>(context.getPart(ModModelLayers.TIGER)),0.5f); | ||
} | ||
|
||
@Override | ||
public Identifier getTexture(TigerEntity entity) { | ||
return TEXTURE; | ||
} | ||
|
||
@Override | ||
public void render(TigerEntity mobEntity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i) { | ||
if (mobEntity.isBaby()){ | ||
matrixStack.scale(0.5f,0.5f,0.5f); | ||
}else { | ||
matrixStack.scale(1.5f,1.5f,1.5f); | ||
} | ||
super.render(mobEntity, f, g, matrixStack, vertexConsumerProvider, i); | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
src/main/java/com/besson/tutorialmod/entity/custom/TigerEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.besson.tutorialmod.entity.custom; | ||
|
||
import com.besson.tutorialmod.entity.ModEntities; | ||
import net.minecraft.entity.EntityType; | ||
import net.minecraft.entity.ai.goal.*; | ||
import net.minecraft.entity.attribute.DefaultAttributeContainer; | ||
import net.minecraft.entity.attribute.EntityAttributes; | ||
import net.minecraft.entity.mob.MobEntity; | ||
import net.minecraft.entity.passive.AnimalEntity; | ||
import net.minecraft.entity.passive.PassiveEntity; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.item.Items; | ||
import net.minecraft.recipe.Ingredient; | ||
import net.minecraft.server.world.ServerWorld; | ||
import net.minecraft.world.World; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class TigerEntity extends AnimalEntity { | ||
public TigerEntity(EntityType<? extends AnimalEntity> entityType, World world) { | ||
super(entityType, world); | ||
} | ||
|
||
@Override | ||
public void tick() { | ||
super.tick(); | ||
} | ||
|
||
@Override | ||
protected void initGoals() { | ||
this.goalSelector.add(0,new SwimGoal(this)); | ||
this.goalSelector.add(1,new AnimalMateGoal(this,1.0D)); | ||
this.goalSelector.add(2,new TemptGoal(this,1.25D, Ingredient.ofItems(Items.BEEF),false)); | ||
this.goalSelector.add(3,new FollowParentGoal(this,1.0D)); | ||
this.goalSelector.add(4,new WanderAroundFarGoal(this,1.0D)); | ||
this.goalSelector.add(5,new LookAtEntityGoal(this, PlayerEntity.class,3f)); | ||
this.goalSelector.add(6,new LookAroundGoal(this)); | ||
} | ||
public static DefaultAttributeContainer.Builder createTigerAttributes(){ | ||
return MobEntity.createMobAttributes() | ||
.add(EntityAttributes.GENERIC_MAX_HEALTH,200) | ||
.add(EntityAttributes.GENERIC_MOVEMENT_SPEED,0.2F) | ||
.add(EntityAttributes.GENERIC_ARMOR,0.5F) | ||
.add(EntityAttributes.GENERIC_ATTACK_DAMAGE,5); | ||
} | ||
|
||
@Override | ||
public boolean isBreedingItem(ItemStack stack) { | ||
return stack.isOf(Items.BEEF); | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public PassiveEntity createChild(ServerWorld world, PassiveEntity entity) { | ||
return ModEntities.TIGER.create(world); | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.