-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9038be0
commit 900bad7
Showing
57 changed files
with
1,252 additions
and
103 deletions.
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
66 changes: 66 additions & 0 deletions
66
src/client/java/net/rotgruengelb/forestal/client/particle/DandelionPappusParticle.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,66 @@ | ||
package net.rotgruengelb.forestal.client.particle; | ||
|
||
import net.fabricmc.api.EnvType; | ||
import net.fabricmc.api.Environment; | ||
import net.minecraft.client.particle.*; | ||
import net.minecraft.client.world.ClientWorld; | ||
|
||
@Environment(value = EnvType.CLIENT) | ||
public class DandelionPappusParticle extends SpriteBillboardParticle { | ||
private final float j; | ||
private final float k; | ||
private float l; | ||
|
||
protected DandelionPappusParticle(ClientWorld world, double x, double y, double z, SpriteProvider spriteProvider) { | ||
super(world, x, y, z); | ||
float f; | ||
this.setSprite(spriteProvider); | ||
this.l = (float) Math.toRadians(this.random.nextBoolean() ? -30.0 : 30.0); | ||
this.j = this.random.nextFloat(); | ||
this.k = (float) Math.toRadians(this.random.nextBoolean() ? -5.0 : 5.0); | ||
this.maxAge = 300; | ||
this.gravityStrength = 5E-4f; | ||
this.scale = f = this.random.nextBoolean() ? 0.05f : 0.075f; | ||
this.setBoundingBoxSpacing(f, f); | ||
this.velocityMultiplier = 0.8f; | ||
} | ||
|
||
@Override | ||
public ParticleTextureSheet getType() { | ||
return ParticleTextureSheet.PARTICLE_SHEET_OPAQUE; | ||
} | ||
|
||
@Override | ||
public void tick() { | ||
this.prevPosX = this.x; | ||
this.prevPosY = this.y; | ||
this.prevPosZ = this.z; | ||
if (this.maxAge-- <= 0) { | ||
this.markDead(); | ||
} | ||
if (this.dead) { | ||
return; | ||
} | ||
float f = 300 - this.maxAge; | ||
float g = Math.min(f / 300.0f, 1.0f); | ||
double d = Math.cos(Math.toRadians(this.j * 60.0f)) * 2.0 * Math.pow(g, 1.25); | ||
double e = Math.sin(Math.toRadians(this.j * 60.0f)) * 2.0 * Math.pow(g, 1.25); | ||
this.velocityX += d * (double) 0.0025f; | ||
this.velocityZ += e * (double) 0.0025f; | ||
this.velocityY -= this.gravityStrength; | ||
this.l += this.k / 20.0f; | ||
this.prevAngle = this.angle; | ||
this.angle += this.l / 20.0f; | ||
this.move(this.velocityX, this.velocityY, this.velocityZ); | ||
if (this.onGround || this.maxAge < 299 && (this.velocityX == 0.0 || this.velocityZ == 0.0)) { | ||
this.markDead(); | ||
} | ||
if (this.dead) { | ||
return; | ||
} | ||
this.velocityX *= this.velocityMultiplier * (this.random.nextBoolean() ? 1.15 : 1.25); | ||
this.velocityY *= this.velocityMultiplier; | ||
this.velocityZ *= this.velocityMultiplier * (this.random.nextBoolean() ? 1.15 : 1.25); | ||
} | ||
} | ||
|
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
37 changes: 37 additions & 0 deletions
37
src/client/java/net/rotgruengelb/forestal/client/render/entity/BlackBearEntityRenderer.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,37 @@ | ||
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.BlackBearEntityModel; | ||
import net.rotgruengelb.forestal.entity.BlackBearEntity; | ||
import software.bernie.geckolib.renderer.GeoEntityRenderer; | ||
|
||
public class BlackBearEntityRenderer extends GeoEntityRenderer<BlackBearEntity> { | ||
|
||
public BlackBearEntityRenderer(EntityRendererFactory.Context renderManager) { | ||
super(renderManager, new BlackBearEntityModel()); | ||
} | ||
|
||
@Override | ||
public Identifier getTextureLocation(BlackBearEntity grizzlyBear) { | ||
if (grizzlyBear.isSleeping()) { | ||
return new Identifier(Forestal.MOD_ID, "textures/entity/black_bear/black_bear_sleeping.png"); | ||
} | ||
return new Identifier(Forestal.MOD_ID, "textures/entity/black_bear/black_bear_normal.png"); | ||
} | ||
|
||
@Override | ||
public void render(BlackBearEntity grizzlyBearEntity, float entityYaw, float partialTick, MatrixStack poseStack, VertexConsumerProvider bufferSource, int packedLight) { | ||
poseStack.scale(1.6F, 1.6F, 1.6F); | ||
if (grizzlyBearEntity.isBaby()) { | ||
poseStack.scale(0.6F, 0.6F, 0.6F); | ||
} | ||
if (grizzlyBearEntity.isSleeping()) { | ||
poseStack.translate(0, -0.5, 0); | ||
} | ||
super.render(grizzlyBearEntity, entityYaw, partialTick, poseStack, bufferSource, packedLight); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...lient/java/net/rotgruengelb/forestal/client/render/entity/model/BlackBearEntityModel.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,42 @@ | ||
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.BlackBearEntity; | ||
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 BlackBearEntityModel extends GeoModel<BlackBearEntity> { | ||
@Override | ||
public Identifier getModelResource(BlackBearEntity animatable) { | ||
return new Identifier(Forestal.MOD_ID, "geo/black_bear.geo.json"); | ||
} | ||
|
||
@Override | ||
public Identifier getTextureResource(BlackBearEntity grizzlyBear) { | ||
if (grizzlyBear.isSleeping()) { | ||
return new Identifier(Forestal.MOD_ID, "textures/entity/black_bear/black_bear_sleeping.png"); | ||
} | ||
return new Identifier(Forestal.MOD_ID, "textures/entity/black_bear/black_bear_normal.png"); | ||
} | ||
|
||
@Override | ||
public Identifier getAnimationResource(BlackBearEntity animatable) { | ||
return new Identifier(Forestal.MOD_ID, "animations/black_bear.animation.json"); | ||
} | ||
|
||
@Override | ||
public void setCustomAnimations(BlackBearEntity animatable, long instanceId, AnimationState<BlackBearEntity> 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); | ||
} | ||
} | ||
} |
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
45 changes: 34 additions & 11 deletions
45
src/main/java/net/rotgruengelb/forestal/block/PuffedDandelionBlock.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 |
---|---|---|
@@ -1,34 +1,57 @@ | ||
package net.rotgruengelb.forestal.block; | ||
|
||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; | ||
import net.fabricmc.fabric.api.tag.convention.v1.ConventionalBiomeTags; | ||
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.particle.ParticleEffect; | ||
import net.minecraft.registry.entry.RegistryEntry; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.util.math.Direction; | ||
import net.minecraft.util.math.Vec3d; | ||
import net.minecraft.util.math.random.Random; | ||
import net.minecraft.world.World; | ||
import net.minecraft.world.biome.Biome; | ||
import net.minecraft.world.dimension.DimensionType; | ||
import net.rotgruengelb.forestal.particle.ForestalParticleTypes; | ||
|
||
import java.awt.*; | ||
|
||
public class PuffedDandelionBlock extends FlowerBlock { | ||
|
||
public PuffedDandelionBlock(FabricBlockSettings settings) { | ||
super(StatusEffects.SATURATION, 7, settings); | ||
} | ||
|
||
public static void spawnParticle(World world, Vec3d pos, Random random, ParticleEffect effect) { | ||
double d = pos.getX() + (random.nextDouble() / 2); | ||
double e = pos.getY() - 0.05; | ||
double f = pos.getZ() + (random.nextDouble() / 2); | ||
world.addParticle(effect, d, e, f, 0.0, 0.0, 0.0); | ||
} | ||
|
||
public int particlesFrequency(World world, BlockPos pos) { | ||
if (world.hasRain(pos)) { return 1; } | ||
|
||
final RegistryEntry<Biome> biome = world.getBiome(pos); | ||
final DimensionType dim = world.getDimension(); | ||
|
||
int freq = 19; | ||
if (biome.isIn(ConventionalBiomeTags.IN_NETHER) || dim.ultrawarm()) { freq += 5; } | ||
if (biome.isIn(ConventionalBiomeTags.CLIMATE_DRY)) { freq += 6; } | ||
if (!world.isSkyVisible(pos) || world.isRaining()) { freq += 2; } | ||
if (!biome.isIn(ConventionalBiomeTags.FLORAL)) { freq += 3; } | ||
return freq; | ||
} | ||
|
||
@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)) { | ||
if (random.nextInt(particlesFrequency(world, pos)) != 2) { | ||
return; | ||
} | ||
ParticleUtil.spawnParticle(world, pos, random, ParticleTypes.CHERRY_LEAVES); | ||
double spawnY = (pos.getY() + (random.nextBoolean() ? 0.7 : 0.5)); | ||
Vec3d particlePos = new Vec3d(pos.getX(), spawnY, pos.getZ()); | ||
spawnParticle(world, particlePos, random, ForestalParticleTypes.DANDELION_PAPPUS); | ||
} | ||
} |
Oops, something went wrong.