Skip to content

Commit

Permalink
Add WIP civets
Browse files Browse the repository at this point in the history
  • Loading branch information
Chikorita-Lover committed Apr 7, 2024
1 parent 52aa351 commit de2a98a
Show file tree
Hide file tree
Showing 36 changed files with 582 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// 1.20.1 2024-01-01T00:51:21.9079247 Caffeinated/Recipes
// 1.20.1 2024-04-02T22:49:48.0848404 Caffeinated/Recipes
a6e938fc8f033d82fb2c73674b2d38dbf58ef14d data\caffeinated\advancements\recipes\misc\coffee_beans_from_campfire_cooking.json
134904d483435f3e31bdf94eaf62387c8b3c0caa data\caffeinated\advancements\recipes\misc\java_banner_pattern.json
51838f015a3a334f4cc29bd8c59bc56464b2552d data\caffeinated\recipes\ground_coffee_block.json
1922870ee697bc6be35c4d62cbf7abcb35d46cf1 data\caffeinated\advancements\recipes\food\coffee_bottle.json
5dfbeda6e15d9e292a25fc4e3f33d71b2ab777cb data\caffeinated\recipes\coffee_beans_from_smoking.json
85ccf4fe4d91361b2eab60b79f83fa9c7f3f712f data\caffeinated\advancements\recipes\misc\coffee_beans_from_smoking.json
cd15441554dc9c3417486d7787d4609ccb9888b8 data\caffeinated\recipes\ground_coffee.json
85ccf4fe4d91361b2eab60b79f83fa9c7f3f712f data\caffeinated\advancements\recipes\misc\coffee_beans_from_smoking.json
d746ed80e2bf6726432f6ed1dd39e6851579ed47 data\caffeinated\recipes\coffee_bean_block.json
5721d4f7e3a65f7b6f387ec00ee996f73a2f51ee data\caffeinated\advancements\recipes\misc\coffee_beans.json
b78f30260a00fcc80fd6b65b41be9adce06286c9 data\caffeinated\recipes\coffee_beans.json
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 1.20.1 2024-01-01T00:51:21.9037056 Caffeinated/Model Definitions
// 1.20.1 2024-04-02T22:49:48.0818336 Caffeinated/Model Definitions
da4528a3cfafc1ab21e5814b64029c10ec357178 assets\caffeinated\blockstates\ground_coffee_block.json
26f35f3a03b0d53578efd2c555721b08353d75f0 assets\caffeinated\blockstates\coffee_cauldron.json
b1a481861132973fe035c9b9ce7613e15938034c assets\caffeinated\models\block\coffee_berry_crate.json
Expand All @@ -16,6 +16,7 @@ cdbc1b9ed3c8b04b24b80402af15eb777423817d assets\caffeinated\models\block\ground_
37d547b30cad973f0223896df68f15c5eea49d4b assets\caffeinated\models\item\ground_coffee_block.json
2e82d1add55c94e56c5b85172449dc9ff539882d assets\caffeinated\models\block\coffee_cauldron_full.json
fe9155058173a06c1325878e72a8f42b0acfb9d7 assets\caffeinated\models\block\coffee_shrub_stage1.json
63ec6c618a3a23eab4cab9c52d7d3250de9b516e assets\caffeinated\models\item\civet_spawn_egg.json
2078aae9dd460adbf0bf14e46615e32012f351e8 assets\caffeinated\blockstates\ground_coffee_cauldron.json
865a21f6601205d70079dbcc9d2bc9d375fbbc73 assets\caffeinated\models\block\coffee_bean_block.json
16db00fbb67b98528c1a99e61640adc411cc4cff assets\caffeinated\models\item\tiramisu.json
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"parent": "minecraft:item/template_spawn_egg"
}
18 changes: 14 additions & 4 deletions src/main/java/com/chikoritalover/caffeinated/Caffeinated.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@

import com.chikoritalover.caffeinated.advancement.BrewCoffeeCriterion;
import com.chikoritalover.caffeinated.block.entity.CauldronCampfireBlockEntity;
import com.chikoritalover.caffeinated.entity.CivetEntity;
import com.chikoritalover.caffeinated.recipe.CoffeeBrewingRecipe;
import com.chikoritalover.caffeinated.registry.*;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.biome.v1.BiomeModifications;
import net.fabricmc.fabric.api.biome.v1.BiomeSelectors;
import net.fabricmc.fabric.api.loot.v2.FabricLootPoolBuilder;
import net.fabricmc.fabric.api.loot.v2.LootTableEvents;
import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder;
import net.minecraft.advancement.criterion.Criteria;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.entity.SpawnGroup;
import net.minecraft.entity.SpawnRestriction;
import net.minecraft.loot.LootPool;
import net.minecraft.loot.LootTable;
import net.minecraft.loot.LootTables;
Expand All @@ -20,18 +25,18 @@
import net.minecraft.recipe.RecipeType;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.registry.tag.BiomeTags;
import net.minecraft.util.Identifier;
import net.minecraft.world.Heightmap;
import net.minecraft.world.biome.BiomeKeys;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.function.Consumer;

public class Caffeinated implements ModInitializer {
// This logger is used to write text to the console and the log file.
// It is considered best practice to use your mod id as the logger's name.
// That way, it's clear which mod wrote info, warnings, and errors.
public static final String MODID = "caffeinated";
public static final Logger LOGGER = LoggerFactory.getLogger("modid");
public static final Logger LOGGER = LoggerFactory.getLogger(MODID);
public static final BrewCoffeeCriterion BREW_COFFEE_CRITERION = Criteria.register(new BrewCoffeeCriterion());
public static final BlockEntityType<CauldronCampfireBlockEntity> CAULDRON_CAMPFIRE = Registry.register(
Registries.BLOCK_ENTITY_TYPE,
Expand Down Expand Up @@ -72,6 +77,7 @@ public void onInitialize() {
CaffeinatedBannerPatterns.initAndGetDefault(Registries.BANNER_PATTERN);
CaffeinatedBlocks.register();
CaffeinatedCauldronBehavior.register();
CaffeinatedEntities.register();
CaffeinatedItemGroups.register();
CaffeinatedItems.register();
CaffeinatedParticleTypes.register();
Expand All @@ -87,6 +93,10 @@ public void onInitialize() {
CaffeinatedBannerPatternTags.register();
CaffeinatedBannerPatterns.register();

SpawnRestriction.register(CaffeinatedEntities.CIVET, SpawnRestriction.Location.ON_GROUND, Heightmap.Type.MOTION_BLOCKING, CivetEntity::canSpawn);

BiomeModifications.addSpawn(BiomeSelectors.tag(CaffeinatedBiomeTags.SPAWNS_CIVETS), SpawnGroup.CREATURE, CaffeinatedEntities.CIVET, 4, 1, 2);

LootTableEvents.MODIFY.register((resourceManager, lootManager, id, tableBuilder, source) -> {
if (id.equals(LootTables.JUNGLE_TEMPLE_CHEST)) {
modifyPool(tableBuilder, 0, builder -> builder.with(ItemEntry.builder(CaffeinatedItems.COFFEE_BERRIES).weight(10).apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(1.0F, 7.0F)))));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,27 @@

import com.chikoritalover.caffeinated.block.CauldronCampfireBlock;
import com.chikoritalover.caffeinated.block.entity.CauldronCampfireBlockEntity;
import com.chikoritalover.caffeinated.client.CivetEntityModel;
import com.chikoritalover.caffeinated.client.CivetEntityRenderer;
import com.chikoritalover.caffeinated.registry.CaffeinatedBlocks;
import com.chikoritalover.caffeinated.registry.CaffeinatedEntities;
import com.chikoritalover.caffeinated.registry.CaffeinatedParticleTypes;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry;
import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry;
import net.fabricmc.fabric.api.client.rendering.v1.EntityModelLayerRegistry;
import net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry;
import net.minecraft.block.Block;
import net.minecraft.client.color.world.BiomeColors;
import net.minecraft.client.particle.BubblePopParticle;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.entity.model.EntityModelLayer;
import net.minecraft.util.Identifier;

public class CaffeinatedClient implements ClientModInitializer {
public static EntityModelLayer MODEL_CIVET_LAYER = new EntityModelLayer(new Identifier(Caffeinated.MODID, "civet"), "main");

@Override
public void onInitializeClient() {
BlockRenderLayerMap.INSTANCE.putBlock(CaffeinatedBlocks.COFFEE_SHRUB, RenderLayer.getCutout());
Expand All @@ -29,6 +38,10 @@ public void onInitializeClient() {
return ((CauldronCampfireBlockEntity) world.getBlockEntity(pos)).getColor();
}, CauldronCampfireBlock.CAMPFIRE_TO_CAULDRON_CAMPFIRE.values().toArray(new Block[0]));

EntityModelLayerRegistry.registerModelLayer(MODEL_CIVET_LAYER, CivetEntityModel::getTexturedModelData);

EntityRendererRegistry.register(CaffeinatedEntities.CIVET, CivetEntityRenderer::new);

ParticleFactoryRegistry.getInstance().register(CaffeinatedParticleTypes.COFFEE_POP, BubblePopParticle.Factory::new);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ public void generateItemModels(ItemModelGenerator itemModelGenerator) {
itemModelGenerator.register(CaffeinatedItems.GROUND_COFFEE, Models.GENERATED);
itemModelGenerator.register(CaffeinatedItems.JAVA_BANNER_PATTERN, Models.GENERATED);
itemModelGenerator.register(CaffeinatedItems.TIRAMISU_SLICE, Models.GENERATED);
itemModelGenerator.register(CaffeinatedItems.CIVET_SPAWN_EGG, Models.item("template_spawn_egg"));
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package com.chikoritalover.caffeinated.client;

import com.google.common.collect.ImmutableList;
import net.minecraft.client.model.*;
import net.minecraft.client.render.entity.model.AnimalModel;
import net.minecraft.client.render.entity.model.EntityModelPartNames;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.MathHelper;

public class CivetEntityModel<T extends Entity> extends AnimalModel<T> {
private final ModelPart head;
private final ModelPart body;
private final ModelPart upperTail;
private final ModelPart lowerTail;
private final ModelPart leftHindLeg;
private final ModelPart rightHindLeg;
private final ModelPart leftFrontLeg;
private final ModelPart rightFrontLeg;

public CivetEntityModel(ModelPart root) {
super(true, 9.5F, 3.0F);
this.head = root.getChild(EntityModelPartNames.HEAD);
this.body = root.getChild(EntityModelPartNames.BODY);
this.upperTail = root.getChild("upper_tail");
this.lowerTail = this.upperTail.getChild("lower_tail");
this.leftHindLeg = root.getChild(EntityModelPartNames.LEFT_HIND_LEG);
this.rightHindLeg = root.getChild(EntityModelPartNames.RIGHT_HIND_LEG);
this.leftFrontLeg = root.getChild(EntityModelPartNames.LEFT_FRONT_LEG);
this.rightFrontLeg = root.getChild(EntityModelPartNames.RIGHT_FRONT_LEG);
}

public static TexturedModelData getTexturedModelData() {
ModelData modelData = new ModelData();
ModelPartData modelPartData = modelData.getRoot();
modelPartData.addChild(EntityModelPartNames.HEAD, ModelPartBuilder.create().uv(0, 0).cuboid(-2.5F, -2.0F, -4.0F, 5.0F, 4.0F, 5.0F, new Dilation(0.0F))
.uv(0, 21).cuboid(-1.0F, 0.0F, -6.0F, 2.0F, 2.0F, 2.0F, new Dilation(0.0F))
.uv(0, 9).cuboid(-3.5F, -3.0F, -1.0F, 2.0F, 2.0F, 1.0F, new Dilation(0.0F))
.uv(0, 9).mirrored().cuboid(1.5F, -3.0F, -1.0F, 2.0F, 2.0F, 1.0F, new Dilation(0.0F)).mirrored(false), ModelTransform.pivot(0.0F, 17.5F, -7.0F));

modelPartData.addChild(EntityModelPartNames.BODY, ModelPartBuilder.create().uv(20, 0).cuboid(-2.5F, -6.0F, -3.5F, 5.0F, 13.0F, 4.0F, new Dilation(0.0F)), ModelTransform.of(0.0F, 17.0F, 0.0F, 1.5708F, 0.0F, 0.0F));

ModelPartData upper_tail = modelPartData.addChild("upper_tail", ModelPartBuilder.create().uv(38, 0).cuboid(-1.0F, -0.25F, -0.5F, 2.0F, 8.0F, 2.0F, new Dilation(0.0F)), ModelTransform.of(0.0F, 18.25F, 7.0F, 1.0472F, 0.0F, 0.0F));

upper_tail.addChild("lower_tail", ModelPartBuilder.create().uv(46, 0).cuboid(-1.0F, 0.0F, 0.0F, 2.0F, 10.0F, 2.0F, new Dilation(0.0F)), ModelTransform.of(0.0F, 7.75F, -0.5F, 0.5236F, 0.0F, 0.0F));

modelPartData.addChild(EntityModelPartNames.LEFT_HIND_LEG, ModelPartBuilder.create().uv(8, 9).mirrored().cuboid(-1.0F, -0.5F, -0.9F, 2.0F, 5.0F, 2.0F, new Dilation(0.0F)).mirrored(false), ModelTransform.pivot(1.6F, 19.5F, 5.0F));

modelPartData.addChild(EntityModelPartNames.RIGHT_HIND_LEG, ModelPartBuilder.create().uv(8, 9).cuboid(-1.0F, -0.5F, -0.9F, 2.0F, 5.0F, 2.0F, new Dilation(0.0F)), ModelTransform.pivot(-1.6F, 19.5F, 5.0F));

modelPartData.addChild(EntityModelPartNames.LEFT_FRONT_LEG, ModelPartBuilder.create().uv(0, 12).mirrored().cuboid(-1.0F, -0.5F, -0.9F, 2.0F, 7.0F, 2.0F, new Dilation(0.0F)).mirrored(false), ModelTransform.pivot(1.7F, 17.3F, -5.0F));

modelPartData.addChild(EntityModelPartNames.RIGHT_FRONT_LEG, ModelPartBuilder.create().uv(0, 12).cuboid(-1.0F, -0.5F, -0.9F, 2.0F, 7.0F, 2.0F, new Dilation(0.0F)), ModelTransform.pivot(-1.7F, 17.3F, -5.0F));
return TexturedModelData.of(modelData, 64, 32);
}

@Override
protected Iterable<ModelPart> getHeadParts() {
return ImmutableList.of(this.head);
}

@Override
protected Iterable<ModelPart> getBodyParts() {
return ImmutableList.of(this.body, this.upperTail, this.leftHindLeg, this.rightHindLeg, this.leftFrontLeg, this.rightFrontLeg);
}

@Override
public void setAngles(T entity, float limbAngle, float limbDistance, float animationProgress, float headYaw, float headPitch) {
this.head.pitch = headPitch * ((float) Math.PI / 180);
this.head.yaw = headYaw * ((float) Math.PI / 180);
this.rightHindLeg.pitch = MathHelper.cos(limbAngle * 0.6662F) * 1.4f * limbDistance;
this.leftHindLeg.pitch = MathHelper.cos(limbAngle * 0.6662F + (float) Math.PI) * 1.4F * limbDistance;
this.rightFrontLeg.pitch = MathHelper.cos(limbAngle * 0.6662F + (float) Math.PI) * 1.4F * limbDistance;
this.leftFrontLeg.pitch = MathHelper.cos(limbAngle * 0.6662F) * 1.4F * limbDistance;
this.lowerTail.pitch = 0.52359878F + 0.31415927F * MathHelper.cos(limbAngle) * limbDistance;
}

@Override
public void animateModel(T entity, float limbAngle, float limbDistance, float tickDelta) {
this.upperTail.pitch = 0.9F;
if (entity.isInSneakingPose()) {
this.upperTail.pitch = 1.5707964F;
this.lowerTail.pitch = 1.5707964F;
} else if (entity.isSprinting()) {
this.upperTail.pitch = 1.5707964F;
this.lowerTail.pitch = 1.5707964F;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.chikoritalover.caffeinated.client;

import com.chikoritalover.caffeinated.Caffeinated;
import com.chikoritalover.caffeinated.CaffeinatedClient;
import com.chikoritalover.caffeinated.entity.CivetEntity;
import net.minecraft.client.render.entity.EntityRendererFactory;
import net.minecraft.client.render.entity.MobEntityRenderer;
import net.minecraft.client.render.entity.model.EntityModelLayers;
import net.minecraft.util.Identifier;

public class CivetEntityRenderer extends MobEntityRenderer<CivetEntity, CivetEntityModel<CivetEntity>> {
private static final Identifier TEXTURE = new Identifier(Caffeinated.MODID, "textures/entity/civet/civet.png");

public CivetEntityRenderer(EntityRendererFactory.Context context) {
super(context, new CivetEntityModel<>(context.getPart(CaffeinatedClient.MODEL_CIVET_LAYER)), 0.4F);
}

public Identifier getTexture(CivetEntity civetEntity) {
return TEXTURE;
}
}
Loading

0 comments on commit de2a98a

Please sign in to comment.