Skip to content
This repository has been archived by the owner on Jan 14, 2025. It is now read-only.

Commit

Permalink
feat: more refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
chimericdream committed Oct 9, 2024
1 parent ae20b28 commit 16adc4c
Show file tree
Hide file tree
Showing 46 changed files with 252 additions and 472 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ archives_base_name = minekea-fabric
fabric_version = 0.101.1+1.21
cloth_config_version = 15.0.128
mod_menu_version = 11.0.1
chimericlib_version = 1.0.0-beta.3
chimericlib_version = 1.0.0-beta.8

# Optional Dependencies
patchouli_version = 1.21-87-FABRIC
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,12 @@
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricLanguageProvider;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider;
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.minecraft.block.Block;
import net.minecraft.data.client.BlockStateModelGenerator;
import net.minecraft.data.client.ItemModelGenerator;
import net.minecraft.data.server.loottable.BlockLootTableGenerator;
import net.minecraft.data.server.recipe.RecipeExporter;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroups;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.registry.tag.TagKey;

Expand Down Expand Up @@ -141,17 +139,6 @@ public void initializeClient() {
public void registerBlocks() {
BLOCKS.forEach(block -> ((RegisterableBlock) block).register());
BLOCK_GROUPS.forEach(MinekeaBlockCategory::registerBlocks);

ItemGroupEvents.modifyEntriesEvent(ItemGroups.BUILDING_BLOCKS)
.register((itemGroup) -> {
itemGroup.add(BASALT_BRICKS_BLOCK);
itemGroup.add(CHISELED_BASALT_BRICKS_BLOCK);
itemGroup.add(CRACKED_BASALT_BRICKS_BLOCK);
itemGroup.add(CRIMSON_BASALT_BRICKS_BLOCK);
itemGroup.add(MOSSY_BASALT_BRICKS_BLOCK);
itemGroup.add(WARPED_BASALT_BRICKS_BLOCK);
itemGroup.add(WARPED_NETHER_BRICKS_BLOCK);
});
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import com.chimericdream.lib.blocks.BlockDataGenerator;
import com.chimericdream.lib.blocks.RegisterableBlock;
import com.chimericdream.lib.fabric.blocks.FabricBlockDataGenerator;
import com.chimericdream.lib.fabric.blocks.FabricItemGroupEventHelpers;
import com.chimericdream.lib.fabric.registries.FabricRegistryHelpers;
import com.chimericdream.lib.registries.RegistryHelpers;
import com.chimericdream.lib.tags.CommonItemTags;
import com.chimericdream.lib.util.ModConfigurable;
import com.chimericdream.minekea.ModInfo;
Expand All @@ -12,9 +15,6 @@
import net.fabricmc.fabric.api.datagen.v1.provider.FabricLanguageProvider;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricRecipeProvider;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider;
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.fabricmc.fabric.api.registry.FlammableBlockRegistry;
import net.fabricmc.fabric.api.registry.FuelRegistry;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
Expand All @@ -37,13 +37,9 @@
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.fluid.FluidState;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.item.ItemStack;
import net.minecraft.recipe.book.RecipeCategory;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.registry.tag.TagKey;
import net.minecraft.sound.SoundCategory;
Expand Down Expand Up @@ -313,16 +309,12 @@ public boolean canPathfindThrough(BlockState state, NavigationType type) {
}

public void register() {
Registry.register(Registries.BLOCK, BLOCK_ID, this);
Registry.register(Registries.ITEM, BLOCK_ID, new BlockItem(this, new Item.Settings()));
RegistryHelpers.registerBlockWithItem(this, BLOCK_ID);
FabricItemGroupEventHelpers.addBlockToItemGroup(this, MinekeaItemGroups.BEAM_ITEM_GROUP_KEY);

if (config.isFlammable()) {
FuelRegistry.INSTANCE.add(this, 300);
FlammableBlockRegistry.getDefaultInstance().add(this, 30, 20);
FabricRegistryHelpers.registerFlammableBlock(this);
}

ItemGroupEvents.modifyEntriesEvent(MinekeaItemGroups.BEAM_ITEM_GROUP_KEY)
.register(itemGroup -> itemGroup.add(this.asItem()));
}

public void configureBlockTags(RegistryWrapper.WrapperLookup registryLookup, Function<TagKey<Block>, FabricTagProvider<Block>.FabricTagBuilder> getBuilder) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
import com.chimericdream.lib.blocks.BlockDataGenerator;
import com.chimericdream.lib.blocks.RegisterableBlock;
import com.chimericdream.lib.fabric.blocks.FabricBlockDataGenerator;
import com.chimericdream.lib.fabric.blocks.FabricItemGroupEventHelpers;
import com.chimericdream.lib.registries.RegistryHelpers;
import com.chimericdream.lib.util.ModConfigurable;
import com.chimericdream.minekea.ModInfo;
import com.chimericdream.minekea.data.TextureGenerator;
import com.chimericdream.minekea.item.MinekeaItemGroups;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricLanguageProvider;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricRecipeProvider;
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockRenderType;
Expand All @@ -20,14 +21,12 @@
import net.minecraft.data.server.recipe.RecipeExporter;
import net.minecraft.data.server.recipe.ShapedRecipeJsonBuilder;
import net.minecraft.data.server.recipe.ShapelessRecipeJsonBuilder;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.item.ItemStack;
import net.minecraft.item.tooltip.TooltipType;
import net.minecraft.recipe.book.RecipeCategory;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.EnumProperty;
Expand Down Expand Up @@ -112,11 +111,8 @@ protected static float getResistance(int level, float baseResistance) {
}

public void register() {
Registry.register(Registries.BLOCK, BLOCK_ID, this);
Registry.register(Registries.ITEM, BLOCK_ID, new BlockItem(this, new Item.Settings()));

ItemGroupEvents.modifyEntriesEvent(MinekeaItemGroups.COMPRESSED_BLOCK_ITEM_GROUP_KEY)
.register(itemGroup -> itemGroup.add(this));
RegistryHelpers.registerBlockWithItem(this, BLOCK_ID);
FabricItemGroupEventHelpers.addBlockToItemGroup(this, MinekeaItemGroups.COMPRESSED_BLOCK_ITEM_GROUP_KEY);
}

public void configureRecipes(RecipeExporter exporter) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
import com.chimericdream.lib.blocks.BlockDataGenerator;
import com.chimericdream.lib.blocks.RegisterableBlock;
import com.chimericdream.lib.fabric.blocks.FabricBlockDataGenerator;
import com.chimericdream.lib.fabric.blocks.FabricItemGroupEventHelpers;
import com.chimericdream.lib.fabric.registries.FabricRegistryHelpers;
import com.chimericdream.lib.registries.RegistryHelpers;
import com.chimericdream.lib.resource.ModelUtils;
import com.chimericdream.lib.util.ModConfigurable;
import com.chimericdream.minekea.ModInfo;
import com.chimericdream.minekea.item.MinekeaItemGroups;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricLanguageProvider;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricRecipeProvider;
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.fabricmc.fabric.api.registry.FlammableBlockRegistry;
import net.fabricmc.fabric.api.registry.FuelRegistry;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.CarpetBlock;
Expand All @@ -27,12 +27,8 @@
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.fluid.FluidState;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.recipe.book.RecipeCategory;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty;
Expand Down Expand Up @@ -113,16 +109,12 @@ public BlockState getStateForNeighborUpdate(BlockState state, Direction directio
}

public void register() {
Registry.register(Registries.BLOCK, BLOCK_ID, this);
Registry.register(Registries.ITEM, BLOCK_ID, new BlockItem(this, new Item.Settings()));
RegistryHelpers.registerBlockWithItem(this, BLOCK_ID);
FabricItemGroupEventHelpers.addBlockToItemGroup(this, MinekeaItemGroups.COVERS_ITEM_GROUP_KEY);

if (config.isFlammable()) {
FuelRegistry.INSTANCE.add(this, 300);
FlammableBlockRegistry.getDefaultInstance().add(this, 30, 20);
FabricRegistryHelpers.registerFlammableBlock(this);
}

ItemGroupEvents.modifyEntriesEvent(MinekeaItemGroups.COVERS_ITEM_GROUP_KEY)
.register((itemGroup) -> itemGroup.add(this));
}

public void configureRecipes(RecipeExporter exporter) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
import com.chimericdream.lib.blocks.RegisterableBlock;
import com.chimericdream.lib.colors.ColorHelpers;
import com.chimericdream.lib.fabric.blocks.FabricBlockDataGenerator;
import com.chimericdream.lib.fabric.blocks.FabricItemGroupEventHelpers;
import com.chimericdream.lib.registries.RegistryHelpers;
import com.chimericdream.lib.util.ModConfigurable;
import com.chimericdream.minekea.ModInfo;
import com.chimericdream.minekea.item.MinekeaItemGroups;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricLanguageProvider;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricRecipeProvider;
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.component.DataComponentTypes;
Expand All @@ -20,7 +21,6 @@
import net.minecraft.data.server.recipe.RecipeExporter;
import net.minecraft.data.server.recipe.ShapedRecipeJsonBuilder;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroups;
import net.minecraft.item.ItemPlacementContext;
Expand All @@ -30,8 +30,6 @@
import net.minecraft.particle.ParticleTypes;
import net.minecraft.potion.Potions;
import net.minecraft.recipe.book.RecipeCategory;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.SoundCategory;
Expand All @@ -50,6 +48,8 @@
import net.minecraft.world.World;
import net.minecraft.world.event.GameEvent;

import java.util.List;

public class DyedBlock extends Block implements BlockDataGenerator, FabricBlockDataGenerator, ModConfigurable, RegisterableBlock {
public static final EnumProperty<Direction.Axis> AXIS;

Expand Down Expand Up @@ -113,14 +113,15 @@ protected ItemActionResult onUseWithItem(ItemStack stack, BlockState state, Worl
}

public void register() {
Registry.register(Registries.BLOCK, BLOCK_ID, this);
Registry.register(Registries.ITEM, BLOCK_ID, new BlockItem(this, new Item.Settings()));

ItemGroupEvents.modifyEntriesEvent(ItemGroups.COLORED_BLOCKS)
.register((itemGroup) -> itemGroup.add(this));
RegistryHelpers.registerBlockWithItem(this, BLOCK_ID);
FabricItemGroupEventHelpers.addBlockToItemGroups(
this,
List.of(
ItemGroups.COLORED_BLOCKS,
MinekeaItemGroups.DYED_BLOCK_ITEM_GROUP_KEY
)
);

ItemGroupEvents.modifyEntriesEvent(MinekeaItemGroups.DYED_BLOCK_ITEM_GROUP_KEY)
.register((itemGroup) -> itemGroup.add(this));
}

public void configureRecipes(RecipeExporter exporter) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
import com.chimericdream.lib.blocks.RegisterableBlock;
import com.chimericdream.lib.colors.ColorHelpers;
import com.chimericdream.lib.fabric.blocks.FabricBlockDataGenerator;
import com.chimericdream.lib.fabric.blocks.FabricItemGroupEventHelpers;
import com.chimericdream.lib.registries.RegistryHelpers;
import com.chimericdream.lib.resource.ModelUtils;
import com.chimericdream.lib.resource.TextureUtils;
import com.chimericdream.lib.util.ModConfigurable;
import com.chimericdream.minekea.ModInfo;
import com.chimericdream.minekea.item.MinekeaItemGroups;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricLanguageProvider;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricRecipeProvider;
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.PillarBlock;
Expand All @@ -26,7 +27,6 @@
import net.minecraft.data.server.recipe.RecipeExporter;
import net.minecraft.data.server.recipe.ShapedRecipeJsonBuilder;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroups;
import net.minecraft.item.ItemPlacementContext;
Expand All @@ -36,8 +36,6 @@
import net.minecraft.particle.ParticleTypes;
import net.minecraft.potion.Potions;
import net.minecraft.recipe.book.RecipeCategory;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.SoundCategory;
Expand All @@ -56,6 +54,8 @@
import net.minecraft.world.World;
import net.minecraft.world.event.GameEvent;

import java.util.List;

public class DyedPillarBlock extends PillarBlock implements BlockDataGenerator, FabricBlockDataGenerator, ModConfigurable, RegisterableBlock {
public static final EnumProperty<Direction.Axis> AXIS;

Expand Down Expand Up @@ -121,14 +121,14 @@ protected ItemActionResult onUseWithItem(ItemStack stack, BlockState state, Worl
}

public void register() {
Registry.register(Registries.BLOCK, BLOCK_ID, this);
Registry.register(Registries.ITEM, BLOCK_ID, new BlockItem(this, new Item.Settings()));

ItemGroupEvents.modifyEntriesEvent(ItemGroups.COLORED_BLOCKS)
.register((itemGroup) -> itemGroup.add(this));

ItemGroupEvents.modifyEntriesEvent(MinekeaItemGroups.DYED_BLOCK_ITEM_GROUP_KEY)
.register((itemGroup) -> itemGroup.add(this));
RegistryHelpers.registerBlockWithItem(this, BLOCK_ID);
FabricItemGroupEventHelpers.addBlockToItemGroups(
this,
List.of(
ItemGroups.COLORED_BLOCKS,
MinekeaItemGroups.DYED_BLOCK_ITEM_GROUP_KEY
)
);
}

public void configureRecipes(RecipeExporter exporter) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import com.chimericdream.lib.blocks.BlockDataGenerator;
import com.chimericdream.lib.blocks.RegisterableBlock;
import com.chimericdream.lib.fabric.blocks.FabricBlockDataGenerator;
import com.chimericdream.lib.fabric.blocks.FabricItemGroupEventHelpers;
import com.chimericdream.lib.fabric.registries.FabricRegistryHelpers;
import com.chimericdream.lib.registries.RegistryHelpers;
import com.chimericdream.lib.resource.TextureUtils;
import com.chimericdream.lib.util.ModConfigurable;
import com.chimericdream.minekea.ModInfo;
Expand All @@ -13,9 +16,6 @@
import net.fabricmc.fabric.api.datagen.v1.provider.FabricLanguageProvider;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricRecipeProvider;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider;
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.fabricmc.fabric.api.registry.FlammableBlockRegistry;
import net.fabricmc.fabric.api.registry.FuelRegistry;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.data.client.BlockStateModelGenerator;
Expand All @@ -28,13 +28,9 @@
import net.minecraft.data.server.loottable.BlockLootTableGenerator;
import net.minecraft.data.server.recipe.RecipeExporter;
import net.minecraft.data.server.recipe.ShapelessRecipeJsonBuilder;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroups;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.recipe.book.RecipeCategory;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.registry.tag.BlockTags;
import net.minecraft.registry.tag.TagKey;
Expand Down Expand Up @@ -183,15 +179,11 @@ private BooleanProperty getConnectionProperty(Direction direction) {
}

public void register() {
Registry.register(Registries.BLOCK, BLOCK_ID, this);
Registry.register(Registries.ITEM, BLOCK_ID, new BlockItem(this, new Item.Settings()));

ItemGroupEvents.modifyEntriesEvent(ItemGroups.BUILDING_BLOCKS)
.register(itemGroup -> itemGroup.add(this));
RegistryHelpers.registerBlockWithItem(this, BLOCK_ID);
FabricItemGroupEventHelpers.addBlockToItemGroup(this, ItemGroups.BUILDING_BLOCKS);

if (config.isFlammable()) {
FuelRegistry.INSTANCE.add(this, 300);
FlammableBlockRegistry.getDefaultInstance().add(this, 30, 20);
FabricRegistryHelpers.registerFlammableBlock(this);
}
}

Expand Down
Loading

0 comments on commit 16adc4c

Please sign in to comment.