Skip to content

Commit

Permalink
feat: refactoring and retexturing
Browse files Browse the repository at this point in the history
  • Loading branch information
CallMeEchoCodes committed Dec 3, 2024
1 parent 960186e commit 9f00d51
Show file tree
Hide file tree
Showing 107 changed files with 1,813 additions and 385 deletions.
17 changes: 17 additions & 0 deletions src/client/java/dev/spiritstudios/hollow/HollowClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,22 @@

import dev.spiritstudios.hollow.particle.FireflyJarParticle;
import dev.spiritstudios.hollow.registry.*;
import dev.spiritstudios.hollow.render.block.EchoingPotBlockEntityRenderer;
import dev.spiritstudios.hollow.render.entity.FireflyEntityRenderer;
import dev.spiritstudios.hollow.render.entity.JarBlockEntityRenderer;
import dev.spiritstudios.specter.api.config.ModMenuHelper;
import net.fabricmc.api.ClientModInitializer;
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.Blocks;
import net.minecraft.client.color.world.BiomeColors;
import net.minecraft.client.item.ModelPredicateProviderRegistry;
import net.minecraft.client.render.block.entity.BlockEntityRendererFactories;
import net.minecraft.client.render.entity.model.EntityModelLayer;
import net.minecraft.util.Identifier;
import net.minecraft.world.biome.GrassColors;

public class HollowClient implements ClientModInitializer {
@Override
Expand All @@ -32,8 +38,19 @@ public void onInitializeClient() {
ColorProviderRegistry.BLOCK.register((state, world, pos, tintIndex) -> world != null && pos != null ? 0x208030 : 0x71C35C, HollowBlocks.GIANT_LILYPAD);
ColorProviderRegistry.ITEM.register((stack, tintIndex) -> tintIndex == 0 ? 0x71C35C : -1, HollowItems.GIANT_LILYPAD);

ColorProviderRegistry.BLOCK.register((state, world, pos, tintIndex) -> {
return tintIndex != 0 ?
world != null && pos != null ? BiomeColors.getGrassColor(world, pos) : GrassColors.getDefaultColor() :
-1;
}, HollowBlocks.BLUE_WILDFLOWER, HollowBlocks.WHITE_WILDFLOWER, HollowBlocks.PURPLE_WILDFLOWER);

ParticleFactoryRegistry.getInstance().register(HollowParticleTypes.FIREFLY_JAR, FireflyJarParticle.Factory::new);

ModMenuHelper.addConfig(Hollow.MODID, HollowConfig.HOLDER.id());

BlockEntityRendererFactories.register(
HollowBlockEntityTypes.ECHOING_POT_BLOCK_ENTITY,
EchoingPotBlockEntityRenderer::new
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package dev.spiritstudios.hollow.render.block;

import dev.spiritstudios.hollow.block.entity.EchoingPotBlockEntity;
import net.minecraft.block.entity.DecoratedPotBlockEntity;
import net.minecraft.client.render.RenderLayers;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.block.BlockRenderManager;
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
import net.minecraft.client.render.block.entity.BlockEntityRendererFactory;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RotationAxis;

import java.util.Objects;

public class EchoingPotBlockEntityRenderer implements BlockEntityRenderer<EchoingPotBlockEntity> {
private final BlockRenderManager renderManager;

public EchoingPotBlockEntityRenderer(BlockEntityRendererFactory.Context context) {
this.renderManager = context.getRenderManager();
}

@Override
public void render(EchoingPotBlockEntity entity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
matrices.push();

DecoratedPotBlockEntity.WobbleType wobbleType = entity.lastWobbleType;
if (wobbleType != null && entity.getWorld() != null) {
float wobbleProgress = ((float) (entity.getWorld().getTime() - entity.lastWobbleTime) + tickDelta) / (float) wobbleType.lengthInTicks;
if (wobbleProgress >= 0.0F && wobbleProgress <= 1.0F) {
if (wobbleType == DecoratedPotBlockEntity.WobbleType.POSITIVE) {
float progressRadians = wobbleProgress * MathHelper.TAU;

matrices.multiply(
RotationAxis.POSITIVE_X.rotation((-1.5F * (MathHelper.cos(progressRadians) + 0.5F) * MathHelper.sin(progressRadians / 2.0F)) * 0.015625F),
0.5F, 0.0F, 0.5F
);

matrices.multiply(
RotationAxis.POSITIVE_Z.rotation(MathHelper.sin(progressRadians) * 0.015625F),
0.5F, 0.0F, 0.5F
);
} else matrices.multiply(
RotationAxis.POSITIVE_Y.rotation(MathHelper.sin(-wobbleProgress * 3.0F * MathHelper.PI) * 0.125F * (1.0F - wobbleProgress)),
0.5F, 0.0F, 0.5F
);
}
}

VertexConsumer vertexConsumer = vertexConsumers.getBuffer(RenderLayers.getBlockLayer(entity.getCachedState()));

renderManager.getModelRenderer().render(
entity.getWorld(),
renderManager.getModel(entity.getCachedState()),
entity.getCachedState(),
entity.getPos(),
matrices,
vertexConsumer,
true,
Objects.requireNonNull(entity.getWorld()).getRandom(),
light,
overlay
);

matrices.pop();
}
}
160 changes: 160 additions & 0 deletions src/main/generated/assets/hollow/blockstates/blue_wildflower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
{
"multipart": [
{
"apply": {
"model": "hollow:block/blue_wildflower_1"
},
"when": {
"facing": "north",
"flower_amount": "1|2|3|4"
}
},
{
"apply": {
"model": "hollow:block/blue_wildflower_1",
"y": 90
},
"when": {
"facing": "east",
"flower_amount": "1|2|3|4"
}
},
{
"apply": {
"model": "hollow:block/blue_wildflower_1",
"y": 180
},
"when": {
"facing": "south",
"flower_amount": "1|2|3|4"
}
},
{
"apply": {
"model": "hollow:block/blue_wildflower_1",
"y": 270
},
"when": {
"facing": "west",
"flower_amount": "1|2|3|4"
}
},
{
"apply": {
"model": "hollow:block/blue_wildflower_2"
},
"when": {
"facing": "north",
"flower_amount": "2|3|4"
}
},
{
"apply": {
"model": "hollow:block/blue_wildflower_2",
"y": 90
},
"when": {
"facing": "east",
"flower_amount": "2|3|4"
}
},
{
"apply": {
"model": "hollow:block/blue_wildflower_2",
"y": 180
},
"when": {
"facing": "south",
"flower_amount": "2|3|4"
}
},
{
"apply": {
"model": "hollow:block/blue_wildflower_2",
"y": 270
},
"when": {
"facing": "west",
"flower_amount": "2|3|4"
}
},
{
"apply": {
"model": "hollow:block/blue_wildflower_3"
},
"when": {
"facing": "north",
"flower_amount": "3|4"
}
},
{
"apply": {
"model": "hollow:block/blue_wildflower_3",
"y": 90
},
"when": {
"facing": "east",
"flower_amount": "3|4"
}
},
{
"apply": {
"model": "hollow:block/blue_wildflower_3",
"y": 180
},
"when": {
"facing": "south",
"flower_amount": "3|4"
}
},
{
"apply": {
"model": "hollow:block/blue_wildflower_3",
"y": 270
},
"when": {
"facing": "west",
"flower_amount": "3|4"
}
},
{
"apply": {
"model": "hollow:block/blue_wildflower_4"
},
"when": {
"facing": "north",
"flower_amount": "4"
}
},
{
"apply": {
"model": "hollow:block/blue_wildflower_4",
"y": 90
},
"when": {
"facing": "east",
"flower_amount": "4"
}
},
{
"apply": {
"model": "hollow:block/blue_wildflower_4",
"y": 180
},
"when": {
"facing": "south",
"flower_amount": "4"
}
},
{
"apply": {
"model": "hollow:block/blue_wildflower_4",
"y": 270
},
"when": {
"facing": "west",
"flower_amount": "4"
}
}
]
}
7 changes: 7 additions & 0 deletions src/main/generated/assets/hollow/blockstates/cattail.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "hollow:block/cattail"
}
}
}
Loading

0 comments on commit 9f00d51

Please sign in to comment.