Skip to content

Commit

Permalink
chore: rename stuff and more datagen
Browse files Browse the repository at this point in the history
  • Loading branch information
CallMeEchoCodes committed Dec 1, 2024
1 parent f3937b9 commit 78fe327
Show file tree
Hide file tree
Showing 60 changed files with 456 additions and 476 deletions.
20 changes: 8 additions & 12 deletions src/client/java/dev/spiritstudios/hollow/HollowClient.java
Original file line number Diff line number Diff line change
@@ -1,42 +1,38 @@
package dev.spiritstudios.hollow;

import dev.spiritstudios.hollow.block.HollowLogBlock;
import dev.spiritstudios.hollow.particle.FireflyJarParticle;
import dev.spiritstudios.hollow.registry.*;
import dev.spiritstudios.hollow.render.entity.FireflyEntityRenderer;
import dev.spiritstudios.hollow.render.entity.JarBlockEntityRenderer;
import dev.spiritstudios.specter.api.config.ModMenuHelper;
import dev.spiritstudios.specter.api.core.util.ReflectionHelper;
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.EntityRendererRegistry;
import net.minecraft.client.item.ModelPredicateProviderRegistry;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.block.entity.BlockEntityRendererFactories;
import net.minecraft.util.Identifier;

public class HollowClient implements ClientModInitializer {
@Override
public void onInitializeClient() {
EntityRendererRegistry.register(HollowEntityTypeRegistrar.FIREFLY, FireflyEntityRenderer::new);
EntityRendererRegistry.register(HollowEntityTypes.FIREFLY, FireflyEntityRenderer::new);

ModelPredicateProviderRegistry.register(
HollowItemRegistrar.COPPER_HORN,
HollowItems.COPPER_HORN,
Identifier.ofVanilla("tooting"),
(stack, world, entity, seed) -> entity != null && entity.isUsingItem() && entity.getActiveItem() == stack ? 1.0F : 0.0F
);

BlockEntityRendererFactories.register(HollowBlockEntityRegistrar.JAR_BLOCK_ENTITY, JarBlockEntityRenderer::new);
BlockEntityRendererFactories.register(HollowBlockEntityTypes.JAR_BLOCK_ENTITY, JarBlockEntityRenderer::new);

ColorProviderRegistry.BLOCK.register((state, world, pos, tintIndex) -> world != null && pos != null ? 0x208030 : 0x71C35C, HollowBlockRegistrar.LOTUS_LILYPAD);
ColorProviderRegistry.ITEM.register((stack, tintIndex) -> tintIndex == 0 ? 0x71C35C : -1, HollowItemRegistrar.LOTUS_LILYPAD);
ColorProviderRegistry.BLOCK.register((state, world, pos, tintIndex) -> world != null && pos != null ? 0x208030 : 0x71C35C, HollowBlocks.LOTUS_LILYPAD);
ColorProviderRegistry.ITEM.register((stack, tintIndex) -> tintIndex == 0 ? 0x71C35C : -1, HollowItems.LOTUS_LILYPAD);

ColorProviderRegistry.BLOCK.register((state, world, pos, tintIndex) -> world != null && pos != null ? 0x208030 : 0x71C35C, HollowBlockRegistrar.GIANT_LILYPAD);
ColorProviderRegistry.ITEM.register((stack, tintIndex) -> tintIndex == 0 ? 0x71C35C : -1, HollowItemRegistrar.GIANT_LILYPAD);
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);

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

ModMenuHelper.addConfig(Hollow.MODID, HollowConfig.HOLDER.id());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

import dev.lambdaurora.lambdynlights.api.DynamicLightHandlers;
import dev.lambdaurora.lambdynlights.api.item.ItemLightSourceManager;
import dev.spiritstudios.hollow.registry.HollowEntityTypeRegistrar;
import dev.spiritstudios.hollow.registry.HollowEntityTypes;
import dev.lambdaurora.lambdynlights.api.DynamicLightsInitializer;
import net.minecraft.util.math.MathHelper;

public class HollowDynamicLights implements DynamicLightsInitializer {
@Override
public void onInitializeDynamicLights(ItemLightSourceManager itemLightSourceManager) {
DynamicLightHandlers.registerDynamicLightHandler(
HollowEntityTypeRegistrar.FIREFLY,
HollowEntityTypes.FIREFLY,
entity -> (int) MathHelper.clampedLerp(15.0F, 0.0F, (1.0F - entity.getLightTicks() / 10.0F))
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.spiritstudios.hollow.render.entity;

import dev.spiritstudios.hollow.Hollow;
import dev.spiritstudios.hollow.entity.FireflyEntity;
import net.minecraft.client.render.OverlayTexture;
import net.minecraft.client.render.RenderLayer;
Expand All @@ -13,10 +14,8 @@
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RotationAxis;

import static dev.spiritstudios.hollow.Hollow.MODID;

public class FireflyEntityRenderer extends EntityRenderer<FireflyEntity> {
private static final Identifier TEXTURE = Identifier.of(MODID, "textures/entity/firefly.png");
private static final Identifier TEXTURE = Hollow.id("textures/entity/firefly.png");
private static final RenderLayer LAYER = RenderLayer.getEntityCutoutNoCull(TEXTURE);

public FireflyEntityRenderer(EntityRendererFactory.Context ctx) {
Expand Down
6 changes: 6 additions & 0 deletions src/main/generated/data/minecraft/tags/block/flower_pots.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"values": [
"hollow:potted_rooted_orchid",
"hollow:potted_paeonia"
]
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"replace": false,
"values": [
"hollow:sculk_jaw"
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
{
"replace": false,
"values": [
"hollow:echoing_pot",
"hollow:stone_chest_lid",
"hollow:stone_chest",

"hollow:stone_chest_lid",
"hollow:copper_pillar",
"hollow:weathered_copper_pillar",
"hollow:exposed_copper_pillar",
"hollow:oxidized_copper_pillar",

"hollow:waxed_copper_pillar",
"hollow:waxed_weathered_copper_pillar",
"hollow:waxed_exposed_copper_pillar",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"values": [
"hollow:paeonia",
"hollow:rooted_orchid",
"hollow:lotus_lilypad"
]
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"replace": false,
"values": [
"hollow:campion"
]
Expand Down
30 changes: 17 additions & 13 deletions src/main/java/dev/spiritstudios/hollow/Hollow.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,20 @@ public class Hollow implements ModInitializer {

@Override
public void onInitialize() {
Registrar.process(HollowSoundEventRegistrar.class, MODID);
Registrar.process(HollowBlockRegistrar.class, MODID);
Registrar.process(HollowItemRegistrar.class, MODID);
Registrar.process(HollowEntityTypeRegistrar.class, MODID);
Registrar.process(HollowFeatureRegistrar.class, MODID);
Registrar.process(HollowTreeDecoratorRegistrar.class, MODID);
Registrar.process(HollowBlockEntityRegistrar.class, MODID);
Registrar.process(HollowParticleRegistrar.class, MODID);
Registrar.process(HollowDataComponentRegistrar.class, MODID);
Registrar.process(HollowFoliagePlacerRegistrar.class, MODID);
Registrar.process(HollowSoundEvents.class, MODID);
Registrar.process(HollowBlocks.class, MODID);
Registrar.process(HollowItems.class, MODID);
Registrar.process(HollowEntityTypes.class, MODID);
Registrar.process(HollowFeatures.class, MODID);
Registrar.process(HollowTreeDecorators.class, MODID);
Registrar.process(HollowBlockEntityTypes.class, MODID);
Registrar.process(HollowParticleTypes.class, MODID);
Registrar.process(HollowDataComponentTypes.class, MODID);
Registrar.process(HollowFoliagePlacerTypes.class, MODID);

Registry.register(
Registries.LOOT_FUNCTION_TYPE,
Identifier.of(MODID, "set_copper_instrument"),
id("set_copper_instrument"),
SET_COPPER_INSTRUMENT
);

Expand All @@ -50,7 +50,7 @@ public void onInitialize() {
"bass"
).forEach(name -> {
for (int i = 0; i < 10; i++) {
Identifier id = Identifier.of(MODID, "horn.%s.%d".formatted(name, i));
Identifier id = id("horn.%s.%d".formatted(name, i));
Registry.register(
Registries.SOUND_EVENT,
id,
Expand All @@ -59,9 +59,13 @@ public void onInitialize() {
}
});

FabricDefaultAttributeRegistry.register(HollowEntityTypeRegistrar.FIREFLY, FireflyEntity.createFireflyAttributes());
FabricDefaultAttributeRegistry.register(HollowEntityTypes.FIREFLY, FireflyEntity.createFireflyAttributes());

HollowBiomeModifications.init();
HollowLootTableModifications.init();
}

public static Identifier id(String path) {
return Identifier.of(MODID, path);
}
}
3 changes: 1 addition & 2 deletions src/main/java/dev/spiritstudios/hollow/HollowConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
import dev.spiritstudios.specter.api.config.Config;
import dev.spiritstudios.specter.api.config.ConfigHolder;
import dev.spiritstudios.specter.api.config.Value;
import net.minecraft.util.Identifier;

public class HollowConfig extends Config<HollowConfig> {
public static final ConfigHolder<HollowConfig, ?> HOLDER = ConfigHolder.builder(
Identifier.of(Hollow.MODID, "hollow"), HollowConfig.class
Hollow.id("hollow"), HollowConfig.class
).build();
public static final HollowConfig INSTANCE = HOLDER.get();

Expand Down
11 changes: 2 additions & 9 deletions src/main/java/dev/spiritstudios/hollow/HollowTags.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
package dev.spiritstudios.hollow;

import net.minecraft.block.Block;
import net.minecraft.registry.Registries;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.tag.TagKey;
import net.minecraft.util.Identifier;
import net.minecraft.world.biome.Biome;

public class HollowTags {
public static final TagKey<Block> HOLLOW_LOGS = TagKey.of(Registries.BLOCK.getKey(), id("hollow_logs"));
public static final TagKey<Block> HOLLOW_LOGS = TagKey.of(RegistryKeys.BLOCK, Hollow.id("hollow_logs"));

public static final TagKey<Biome> CLOSER_FOG = TagKey.of(RegistryKeys.BIOME, id("closer_fog"));


public static Identifier id(String path) {
return Identifier.of(Hollow.MODID, path);
}
public static final TagKey<Biome> CLOSER_FOG = TagKey.of(RegistryKeys.BIOME, Hollow.id("closer_fog"));
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ public class CampionBlock extends TallFlowerBlock {
public CampionBlock(Settings settings) {
super(settings);
}



@Override
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
return state.get(HALF) == DoubleBlockHalf.UPPER ?
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package dev.spiritstudios.hollow.block;

import com.llamalad7.mixinextras.sugar.Share;
import com.mojang.serialization.MapCodec;
import dev.spiritstudios.hollow.registry.HollowBlockRegistrar;
import net.minecraft.SharedConstants;
import dev.spiritstudios.hollow.registry.HollowBlocks;
import net.minecraft.block.*;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.fluid.Fluid;
Expand All @@ -17,13 +15,10 @@
import net.minecraft.state.property.Properties;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.random.Random;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.WorldView;
import org.jetbrains.annotations.Nullable;

public class CattailBlock extends AbstractPlantStemBlock implements FluidFillable {
Expand Down Expand Up @@ -60,7 +55,7 @@ protected MapCodec<CattailBlock> getCodec() {

@Override
protected Block getPlant() {
return HollowBlockRegistrar.CATTAIL_STEM;
return HollowBlocks.CATTAIL_STEM;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
package dev.spiritstudios.hollow.block;

import com.mojang.serialization.Codec;
import com.mojang.serialization.MapCodec;
import dev.spiritstudios.hollow.registry.HollowBlockRegistrar;
import dev.spiritstudios.hollow.registry.HollowBlocks;
import net.minecraft.block.*;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.FluidState;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.registry.tag.FluidTags;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.random.Random;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.*;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -44,7 +40,7 @@ protected MapCodec<CattailStemBlock> getCodec() {

@Override
protected AbstractPlantStemBlock getStem() {
return HollowBlockRegistrar.CATTAIL;
return HollowBlocks.CATTAIL;
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.mojang.serialization.MapCodec;
import dev.spiritstudios.hollow.block.entity.EchoingPotBlockEntity;
import dev.spiritstudios.hollow.registry.HollowBlockEntityRegistrar;
import dev.spiritstudios.hollow.registry.HollowBlockEntityTypes;
import net.minecraft.block.*;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityTicker;
Expand Down Expand Up @@ -75,7 +75,7 @@ protected ItemActionResult onUseWithItem(ItemStack stack, BlockState state, Worl
@Nullable
@Override
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state, BlockEntityType<T> type) {
return validateTicker(type, HollowBlockEntityRegistrar.ECHOING_POT_BLOCK_ENTITY, EchoingPotBlockEntity::tick);
return validateTicker(type, HollowBlockEntityTypes.ECHOING_POT_BLOCK_ENTITY, EchoingPotBlockEntity::tick);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package dev.spiritstudios.hollow.block;

import dev.spiritstudios.hollow.registry.HollowParticleRegistrar;
import dev.spiritstudios.hollow.registry.HollowParticleTypes;
import net.minecraft.block.*;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.random.Random;
Expand All @@ -22,7 +22,7 @@ public BlockRenderType getRenderType(BlockState state) {
public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) {
if (random.nextInt(15) == 0)
world.addParticle(
HollowParticleRegistrar.FIREFLY_JAR,
HollowParticleTypes.FIREFLY_JAR,
(pos.getX() + 0.5) + (random.nextDouble() - 0.5) / 5.0F,
(pos.getY() + 0.5) + (2 * random.nextDouble() - 1) / 5.0F,
(pos.getZ() + 0.5) + (random.nextDouble() - 0.5) / 5.0F,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dev.spiritstudios.hollow.block;

import dev.spiritstudios.hollow.Hollow;
import dev.spiritstudios.hollow.registry.HollowSoundEventRegistrar;
import dev.spiritstudios.hollow.registry.HollowSoundEvents;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.SculkBlock;
Expand Down Expand Up @@ -44,7 +44,7 @@ protected void appendProperties(StateManager.Builder<Block, BlockState> builder)
public void onSteppedOn(World world, BlockPos pos, BlockState state, Entity entity) {
if (!entity.bypassesSteppingEffects() && !world.isClient() && !(entity instanceof WardenEntity)) {
if (!world.getBlockState(pos).get(ACTIVE))
world.playSound(null, pos.up(), HollowSoundEventRegistrar.SCULK_JAW_BITE, SoundCategory.BLOCKS, 1F, 0.6F);
world.playSound(null, pos.up(), HollowSoundEvents.SCULK_JAW_BITE, SoundCategory.BLOCKS, 1F, 0.6F);

world.setBlockState(pos, state.with(ACTIVE, true));

Expand Down
Loading

0 comments on commit 78fe327

Please sign in to comment.