Skip to content

Commit

Permalink
music discs & refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
rotgruengelb committed May 5, 2024
1 parent 574449b commit 9038be0
Show file tree
Hide file tree
Showing 23 changed files with 934 additions and 244 deletions.
3 changes: 3 additions & 0 deletions src/client/java/net/rotgruengelb/forestal/ForestalClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry;
import net.rotgruengelb.forestal.client.particle.ForestalParticleFactories;
import net.rotgruengelb.forestal.client.render.entity.DeerEntityRenderer;
import net.rotgruengelb.forestal.client.render.entity.GrizzlyBearEntityRenderer;
import net.rotgruengelb.forestal.entity.ForestalEntities;

Expand All @@ -11,6 +12,8 @@ public class ForestalClient implements ClientModInitializer {
public void onInitializeClient() {

EntityRendererRegistry.register(ForestalEntities.GRIZZLY_BEAR, GrizzlyBearEntityRenderer::new);
// EntityRendererRegistry.register(ForestalEntities.DEER, DeerEntityRenderer::new);

ForestalParticleFactories.registerModParticleFactories();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package net.rotgruengelb.forestal.client.render.entity;

import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.entity.EntityRendererFactory;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.Identifier;
import net.rotgruengelb.forestal.Forestal;
import net.rotgruengelb.forestal.client.render.entity.model.DeerEntityModel;
import net.rotgruengelb.forestal.entity.DeerEntity;
import software.bernie.geckolib.renderer.GeoEntityRenderer;

public class DeerEntityRenderer extends GeoEntityRenderer<DeerEntity> {

public DeerEntityRenderer(EntityRendererFactory.Context renderManager) {
super(renderManager, new DeerEntityModel());
}

@Override
public Identifier getTextureLocation(DeerEntity grizzlyBear) {
return new Identifier(Forestal.MOD_ID, "textures/entity/deer.png");
}

@Override
public void render(DeerEntity deerEntity, float entityYaw, float partialTick, MatrixStack poseStack, VertexConsumerProvider bufferSource, int packedLight) {
if (deerEntity.isBaby()) {
poseStack.scale(0.6F, 0.6F, 0.6F);
}
if (deerEntity.isSleeping()) {
poseStack.translate(0, -0.5, 0);
}
super.render(deerEntity, entityYaw, partialTick, poseStack, bufferSource, packedLight);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ public Identifier getTextureLocation(GrizzlyBearEntity grizzlyBear) {
}

@Override
public void render(GrizzlyBearEntity grizzlyBear, float entityYaw, float partialTick, MatrixStack poseStack, VertexConsumerProvider bufferSource, int packedLight) {
if (grizzlyBear.isBaby()) {
public void render(GrizzlyBearEntity grizzlyBearEntity, float entityYaw, float partialTick, MatrixStack poseStack, VertexConsumerProvider bufferSource, int packedLight) {
if (grizzlyBearEntity.isBaby()) {
poseStack.scale(0.6F, 0.6F, 0.6F);
}
if (grizzlyBear.isSleeping()) {
if (grizzlyBearEntity.isSleeping()) {
poseStack.translate(0, -0.5, 0);
}
super.render(grizzlyBear, entityYaw, partialTick, poseStack, bufferSource, packedLight);
super.render(grizzlyBearEntity, entityYaw, partialTick, poseStack, bufferSource, packedLight);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package net.rotgruengelb.forestal.client.render.entity.model;

import net.minecraft.util.Identifier;
import net.minecraft.util.math.MathHelper;
import net.rotgruengelb.forestal.Forestal;
import net.rotgruengelb.forestal.entity.DeerEntity;
import software.bernie.geckolib.constant.DataTickets;
import software.bernie.geckolib.core.animatable.model.CoreGeoBone;
import software.bernie.geckolib.core.animation.AnimationState;
import software.bernie.geckolib.model.GeoModel;
import software.bernie.geckolib.model.data.EntityModelData;

public class DeerEntityModel extends GeoModel<DeerEntity> {
@Override
public Identifier getModelResource(DeerEntity animatable) {
return new Identifier(Forestal.MOD_ID, "geo/deer.geo.json");
}

@Override
public Identifier getTextureResource(DeerEntity grizzlyBear) {
return new Identifier(Forestal.MOD_ID, "textures/entity/deer.png");
}

@Override
public Identifier getAnimationResource(DeerEntity animatable) {
return new Identifier(Forestal.MOD_ID, "animations/deer.animation.json");
}

@Override
public void setCustomAnimations(DeerEntity animatable, long instanceId, AnimationState<DeerEntity> animationState) {
CoreGeoBone head = getAnimationProcessor().getBone("head");

if (head != null) {
EntityModelData entityData = animationState.getData(DataTickets.ENTITY_MODEL_DATA);
head.setRotX(entityData.headPitch() * MathHelper.RADIANS_PER_DEGREE);
head.setRotY(entityData.netHeadYaw() * MathHelper.RADIANS_PER_DEGREE);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.item.BlockItem;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
Expand All @@ -14,6 +15,8 @@ public class ForestalBlocks {

public static final Block GRIZZLY_PLUSHIE = registerBlock("grizzly_plushie", new PlushieBlock(FabricBlockSettings.create()
.nonOpaque().breakInstantly().noBlockBreakParticles().sounds(BlockSoundGroup.WOOL)));
public static final Block PUFFED_DANDELION = registerBlock("puffed_dandelion",
new PuffedDandelionBlock(FabricBlockSettings.copyOf(Blocks.DANDELION)));

private static Block registerBlockNoItem(String name, Block block) {
return Registry.register(Registries.BLOCK, new Identifier(Forestal.MOD_ID, name), block);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package net.rotgruengelb.forestal.block;

import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.BlockState;
import net.minecraft.block.CherryLeavesBlock;
import net.minecraft.block.FlowerBlock;
import net.minecraft.client.util.ParticleUtil;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.random.Random;
import net.minecraft.world.World;

public class PuffedDandelionBlock extends FlowerBlock {

public PuffedDandelionBlock(FabricBlockSettings settings) {
super(StatusEffects.SATURATION, 7, settings);
}

@Override
public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) {
super.randomDisplayTick(state, world, pos, random);
if (random.nextInt(10) != 0) {
return;
}
BlockPos blockPos = pos.down();
BlockState blockState = world.getBlockState(blockPos);
if (CherryLeavesBlock.isFaceFullSquare(blockState.getCollisionShape(world, blockPos), Direction.UP)) {
return;
}
ParticleUtil.spawnParticle(world, pos, random, ParticleTypes.CHERRY_LEAVES);
}
}
Loading

0 comments on commit 9038be0

Please sign in to comment.