Skip to content

Commit

Permalink
✨ Better birch generation!
Browse files Browse the repository at this point in the history
Still needs polypores and twigs
  • Loading branch information
CallMeEchoCodes committed Mar 7, 2024
1 parent 5110d6c commit 55f74b5
Show file tree
Hide file tree
Showing 36 changed files with 1,002 additions and 51 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 1.20.1 2024-02-28T16:10:55.923496592 Hollow/Model Definitions
// 1.20.1 2024-03-05T19:09:45.284734127 Hollow/Model Definitions
957f8f0186bb09ed323faac324b5df5f8671b02d assets/hollow/models/block/stripped_cherry_hollow_log.json
641cc377332e8cf8d849ac2e135a175f33733b37 assets/hollow/models/block/stripped_cherry_hollow_log_horizontal.json
28a6bd9e9b4a62bd3ce03d0f0af1c99acd72aa88 assets/hollow/models/item/stripped_oak_hollow_log.json
Expand All @@ -16,9 +16,9 @@ fd8d6b93e356a2632b8db7a846273ab9b1737db7 assets/hollow/models/block/crimson_holl
bd3123ec45fe3d031a28d5b0868b229ecc0dabed assets/hollow/models/item/stripped_mangrove_hollow_log.json
68a7a41493cb5c9cf6d4c84daa4ff878f02451fc assets/hollow/blockstates/stripped_mangrove_hollow_log.json
f48c02690796da2328b2afb51a6e64ae76c8fcb2 assets/hollow/models/item/oak_hollow_log.json
6cfc739e7aeebff948981811876f709fb8d404fe assets/hollow/blockstates/warped_hollow_stem.json
cb048fa4b582d96b7d5c9345273ec9dc2a9c3d4a assets/hollow/models/block/stripped_crimson_hollow_stem.json
989df3afc76cd3268265f35f24a92f48b07bc809 assets/hollow/models/block/stripped_oak_hollow_log.json
6cfc739e7aeebff948981811876f709fb8d404fe assets/hollow/blockstates/warped_hollow_stem.json
0b3bbe89040c807a8e46ce665f554929c0b28784 assets/hollow/blockstates/birch_hollow_log.json
f78d6aaf29d2f56153350a99bc5dc2b8e69571f6 assets/hollow/models/block/stripped_jungle_hollow_log.json
e9028ee18b8c78ae0482073f3332e606e9c6d47f assets/hollow/models/item/spruce_hollow_log.json
Expand Down Expand Up @@ -61,8 +61,8 @@ d37c24fa00564bc4f804814d0bb9956d8e46ea1e assets/hollow/models/block/stripped_bir
3cac0a21adf2477e3b01cd21945d0f806f82a1a9 assets/hollow/blockstates/oak_hollow_log.json
d2b27363f222a836291843499134c1c713d8b9ce assets/hollow/models/item/stripped_acacia_hollow_log.json
01c40b7e9bc6af191f3e44cc993691501b8f3f10 assets/hollow/blockstates/stripped_jungle_hollow_log.json
846db65370b5234748b994a5f2c8d359261d20cd assets/hollow/models/block/stripped_dark_oak_hollow_log_horizontal.json
eae596b71330da28b5566ac1078d3a2d16c4dabb assets/hollow/blockstates/stripped_dark_oak_hollow_log.json
846db65370b5234748b994a5f2c8d359261d20cd assets/hollow/models/block/stripped_dark_oak_hollow_log_horizontal.json
5fc6bfd74fd5c2bb9c21b6cc069f59dc3051c805 assets/hollow/models/block/stripped_spruce_hollow_log.json
cd86ba8936382b6f13e4206f5fcc202779fc9e74 assets/hollow/blockstates/cherry_hollow_log.json
346d05d24a30781b0c8fcf318fadcbccd84cc892 assets/hollow/models/block/warped_hollow_stem.json
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/dev/callmeecho/hollow/client/HollowClient.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
package dev.callmeecho.hollow.client;

import dev.callmeecho.hollow.client.render.entity.FireflyEntityRenderer;
import dev.callmeecho.hollow.main.Hollow;
import dev.callmeecho.hollow.main.block.HollowLogBlock;
import dev.callmeecho.hollow.main.registry.HollowBlockRegistry;
import dev.callmeecho.hollow.main.registry.HollowEntityTypeRegistry;
import dev.callmeecho.hollow.main.registry.HollowItemRegistry;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry;
import net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry;
import net.fabricmc.fabric.mixin.client.rendering.BlockColorsMixin;
import net.minecraft.block.BlockState;
import net.minecraft.client.color.block.BlockColors;
import net.minecraft.client.color.item.ItemColorProvider;
import net.minecraft.client.color.item.ItemColors;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.item.BlockItem;

public class HollowClient implements ClientModInitializer {
@Override
Expand All @@ -16,5 +25,8 @@ public void onInitializeClient() {

BlockRenderLayerMap.INSTANCE.putBlock(HollowBlockRegistry.PINK_DAISY, RenderLayer.getCutout());
BlockRenderLayerMap.INSTANCE.putBlock(HollowBlockRegistry.PAEONIA, RenderLayer.getCutout());
BlockRenderLayerMap.INSTANCE.putBlock(HollowBlockRegistry.LOTUS_LILYPAD, RenderLayer.getCutout());
ColorProviderRegistry.BLOCK.register((state, world, pos, tintIndex) -> world != null && pos != null ? 0x208030 : 0x71C35C, HollowBlockRegistry.LOTUS_LILYPAD);
ColorProviderRegistry.ITEM.register((stack, tintIndex) -> tintIndex == 0 ? 0x71C35C : -1, HollowItemRegistry.LOTUS_LILYPAD);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@

import java.util.Optional;

import static dev.callmeecho.hollow.main.Hollow.MODID;
import static dev.callmeecho.hollow.main.registry.HollowBlockRegistry.LOTUS_LILYPAD;
import static net.minecraft.data.client.BlockStateModelGenerator.createAxisRotatedBlockState;
import static net.minecraft.data.client.BlockStateModelGenerator.createBlockStateWithRandomHorizontalRotations;

public class ModelProvider extends FabricModelProvider {
public static final Model HOLLOW_LOG = new Model(Optional.of(new Identifier("hollow", "block/" + "hollow_log_template")), Optional.empty(), TextureKey.SIDE, TextureKey.INSIDE, TextureKey.END);
Expand Down
19 changes: 5 additions & 14 deletions src/main/java/dev/callmeecho/hollow/main/Hollow.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,10 @@
import dev.callmeecho.cabinetapi.item.CabinetItemGroup;
import dev.callmeecho.cabinetapi.registry.RegistrarHandler;
import dev.callmeecho.hollow.main.entity.FireflyEntity;
import dev.callmeecho.hollow.main.registry.HollowBlockRegistry;
import dev.callmeecho.hollow.main.registry.HollowEntityTypeRegistry;
import dev.callmeecho.hollow.main.registry.HollowItemRegistry;
import dev.callmeecho.hollow.main.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.object.builder.v1.entity.FabricDefaultAttributeRegistry;
import net.minecraft.entity.SpawnGroup;
import net.minecraft.entity.SpawnRestriction;
import net.minecraft.util.Identifier;
import net.minecraft.world.Heightmap;
import net.minecraft.world.biome.BiomeKeys;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -29,13 +21,12 @@ public void onInitialize() {
RegistrarHandler.process(HollowBlockRegistry.class, MODID);
RegistrarHandler.process(HollowItemRegistry.class, MODID);
RegistrarHandler.process(HollowEntityTypeRegistry.class, MODID);
RegistrarHandler.process(HollowFeatureRegistry.class, MODID);
RegistrarHandler.process(HollowTreeDecoratorRegistry.class, MODID);

FabricDefaultAttributeRegistry.register(HollowEntityTypeRegistry.FIREFLY, FireflyEntity.createFireflyAttributes());
BiomeModifications.addSpawn(BiomeSelectors.includeByKey(
BiomeKeys.SWAMP,
BiomeKeys.MANGROVE_SWAMP
), SpawnGroup.AMBIENT, HollowEntityTypeRegistry.FIREFLY, 20, 10, 30);
SpawnRestriction.register(HollowEntityTypeRegistry.FIREFLY, SpawnRestriction.Location.NO_RESTRICTIONS, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, FireflyEntity::canSpawn);

HollowBiomeModifications.init();

GROUP.initialize();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package dev.callmeecho.hollow.main;

import dev.callmeecho.hollow.main.entity.FireflyEntity;
import dev.callmeecho.hollow.main.registry.HollowEntityTypeRegistry;
import net.fabricmc.fabric.api.biome.v1.BiomeModificationContext;
import net.fabricmc.fabric.api.biome.v1.BiomeModifications;
import net.fabricmc.fabric.api.biome.v1.BiomeSelectors;
import net.fabricmc.fabric.api.biome.v1.ModificationPhase;
import net.minecraft.entity.SpawnGroup;
import net.minecraft.entity.SpawnRestriction;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.util.Identifier;
import net.minecraft.world.Heightmap;
import net.minecraft.world.biome.BiomeKeys;
import net.minecraft.world.gen.GenerationStep;
import net.minecraft.world.gen.feature.PlacedFeature;
import net.minecraft.world.gen.feature.VegetationPlacedFeatures;

public class HollowBiomeModifications {
public static void init() {
BiomeModifications.addSpawn(BiomeSelectors.includeByKey(
BiomeKeys.SWAMP,
BiomeKeys.MANGROVE_SWAMP
), SpawnGroup.AMBIENT, HollowEntityTypeRegistry.FIREFLY, 5, 10, 15);
SpawnRestriction.register(HollowEntityTypeRegistry.FIREFLY, SpawnRestriction.Location.NO_RESTRICTIONS, Heightmap.Type.WORLD_SURFACE, FireflyEntity::canSpawn);

BiomeModifications.addFeature(BiomeSelectors.includeByKey(
BiomeKeys.BIRCH_FOREST,
BiomeKeys.OLD_GROWTH_BIRCH_FOREST
), GenerationStep.Feature.VEGETAL_DECORATION, getPlacedFeature("fallen_birch"));

BiomeModifications.create(new Identifier(Hollow.MODID, "better_swamps_replace")).add(ModificationPhase.REPLACEMENTS, BiomeSelectors.includeByKey(
BiomeKeys.SWAMP,
BiomeKeys.MANGROVE_SWAMP
), context -> {
BiomeModificationContext.GenerationSettingsContext generationSettings = context.getGenerationSettings();

if (generationSettings.removeFeature(VegetationPlacedFeatures.PATCH_WATERLILY))
generationSettings.addFeature(GenerationStep.Feature.VEGETAL_DECORATION, getPlacedFeature("patch_waterlily"));
});

BiomeModifications.create(new Identifier(Hollow.MODID, "better_birch_replace")).add(ModificationPhase.REPLACEMENTS, BiomeSelectors.includeByKey(
BiomeKeys.BIRCH_FOREST,
BiomeKeys.OLD_GROWTH_BIRCH_FOREST
), context -> {
BiomeModificationContext.GenerationSettingsContext generationSettings = context.getGenerationSettings();
if (generationSettings.removeFeature(VegetationPlacedFeatures.TREES_BIRCH))
generationSettings.addFeature(GenerationStep.Feature.VEGETAL_DECORATION, getPlacedFeature("trees_birch"));

if (generationSettings.removeFeature(VegetationPlacedFeatures.BIRCH_TALL))
generationSettings.addFeature(GenerationStep.Feature.VEGETAL_DECORATION, getPlacedFeature("birch_tall"));

if (generationSettings.removeFeature(VegetationPlacedFeatures.FLOWER_DEFAULT) && generationSettings.removeFeature(VegetationPlacedFeatures.FOREST_FLOWERS))
generationSettings.addFeature(GenerationStep.Feature.VEGETAL_DECORATION, getPlacedFeature("patch_lilac_birch"));
});

BiomeModifications.create(new Identifier(Hollow.MODID, "better_birch_remove")).add(ModificationPhase.REMOVALS, BiomeSelectors.includeByKey(
BiomeKeys.BIRCH_FOREST,
BiomeKeys.OLD_GROWTH_BIRCH_FOREST
), context -> {
BiomeModificationContext.GenerationSettingsContext generationSettings = context.getGenerationSettings();

generationSettings.removeFeature(VegetationPlacedFeatures.PATCH_PUMPKIN);
});
}

public static RegistryKey<PlacedFeature> getPlacedFeature(String id) {
return RegistryKey.of(RegistryKeys.PLACED_FEATURE, new Identifier(Hollow.MODID, id));
}
}
45 changes: 32 additions & 13 deletions src/main/java/dev/callmeecho/hollow/main/entity/FireflyEntity.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package dev.callmeecho.hollow.main.entity;

import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.Flutterer;
import net.minecraft.entity.SpawnReason;
import net.minecraft.entity.*;
import net.minecraft.entity.ai.AboveGroundTargeting;
import net.minecraft.entity.ai.NoPenaltySolidTargeting;
import net.minecraft.entity.ai.control.FlightMoveControl;
Expand All @@ -28,6 +25,7 @@
import net.minecraft.world.LightType;
import net.minecraft.world.ServerWorldAccess;
import net.minecraft.world.World;
import net.minecraft.world.WorldView;

import java.util.EnumSet;

Expand Down Expand Up @@ -94,16 +92,24 @@ public static DefaultAttributeContainer.Builder createFireflyAttributes() {
public void tick() {
super.tick();

if (this.age % 5 == 0 && this.random.nextInt(5) == 0) {
this.setLightTicks(this.getLightTicks() - this.random.nextBetween(10, 15));
if (getEntityWorld().isNight() || getEntityWorld().getLightLevel(this.getBlockPos()) < 5) {
if (this.age % 5 == 0 && this.random.nextInt(5) == 0) {
this.setLightTicks(this.getLightTicks() - this.random.nextBetween(10, 15));
} else {
this.setLightTicks(this.getLightTicks() + 1);
}
} else {
this.setLightTicks(this.getLightTicks() + 1);
if (this.age % 5 == 0 && this.random.nextInt(5) == 0) {
this.setLightTicks(this.getLightTicks() + this.random.nextBetween(5, 10));
} else {
this.setLightTicks(this.getLightTicks() - 1);
}
}

if (this.getLightTicks() > 15) {
this.setLightTicks(15);
}

if (this.getLightTicks() < 0 || this.isWet()) {
this.setLightTicks(0);
}
Expand Down Expand Up @@ -138,25 +144,38 @@ public static boolean canSpawn(EntityType<FireflyEntity> entityType, ServerWorld
return FireflyEntity.canMobSpawn(entityType, worldAccess, spawnReason, pos, random);
}

@Override
public float getPathfindingFavor(BlockPos pos, WorldView world) {
return world.getBlockState(pos).isAir() ? 10.0F : 0.0F;
}

@Override
protected float getActiveEyeHeight(EntityPose pose, EntityDimensions dimensions) {
return dimensions.height * 0.5F;
}



static class FlyRandomlyGoal extends Goal {
private final FireflyEntity firefly;

public FlyRandomlyGoal(FireflyEntity firefly) {
this.firefly = firefly;
this.setControls(EnumSet.of(Goal.Control.MOVE));
}



protected Vec3d getWanderTarget() {
Vec3d rotation = firefly.getRotationVec(0.0F);
Vec3d target = AboveGroundTargeting.find(firefly, 8, 2, rotation.x, rotation.z, MathHelper.HALF_PI, 3, 1);
Vec3d target = AboveGroundTargeting.find(firefly, 8, 7, rotation.x, rotation.z, MathHelper.HALF_PI, 3, 1);
if (target != null) return target;

return NoPenaltySolidTargeting.find(firefly, 8, 2, -2, rotation.x, rotation.z, MathHelper.HALF_PI);
return NoPenaltySolidTargeting.find(firefly, 8, 4, -2, rotation.x, rotation.z, MathHelper.HALF_PI);
}

@Override
public boolean canStart() {
return firefly.navigation.isIdle() && firefly.random.nextInt(5) == 0;
return firefly.navigation.isIdle() && firefly.random.nextInt(10) == 0;
}

@Override
Expand Down
Loading

0 comments on commit 55f74b5

Please sign in to comment.