Skip to content

Commit

Permalink
修改铁砧锤逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
Gu-ZT committed Apr 12, 2024
1 parent f5c17c1 commit 14aa4b8
Show file tree
Hide file tree
Showing 25 changed files with 371 additions and 96 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package dev.dubhe.anvilcraft.api.hammer;

import net.minecraft.world.level.block.Block;

import java.util.HashMap;

Check warning on line 5 in common/src/main/java/dev/dubhe/anvilcraft/api/hammer/HammerManager.java

View workflow job for this annotation

GitHub Actions / checkstyle

[Checkstyle] reported by reviewdog 🐶 Extra separation in import group before 'java.util.HashMap' Raw Output: /home/runner/work/AnvilCraftMod/AnvilCraftMod/common/src/main/java/dev/dubhe/anvilcraft/api/hammer/HammerManager.java:5:1: warning: Extra separation in import group before 'java.util.HashMap' (com.puppycrawl.tools.checkstyle.checks.imports.CustomImportOrderCheck)

Check warning on line 5 in common/src/main/java/dev/dubhe/anvilcraft/api/hammer/HammerManager.java

View workflow job for this annotation

GitHub Actions / checkstyle

[Checkstyle] reported by reviewdog 🐶 Wrong lexicographical order for 'java.util.HashMap' import. Should be before 'net.minecraft.world.level.block.Block'. Raw Output: /home/runner/work/AnvilCraftMod/AnvilCraftMod/common/src/main/java/dev/dubhe/anvilcraft/api/hammer/HammerManager.java:5:1: warning: Wrong lexicographical order for 'java.util.HashMap' import. Should be before 'net.minecraft.world.level.block.Block'. (com.puppycrawl.tools.checkstyle.checks.imports.CustomImportOrderCheck)
import java.util.Map;

Check warning on line 6 in common/src/main/java/dev/dubhe/anvilcraft/api/hammer/HammerManager.java

View workflow job for this annotation

GitHub Actions / checkstyle

[Checkstyle] reported by reviewdog 🐶 Wrong lexicographical order for 'java.util.Map' import. Should be before 'net.minecraft.world.level.block.Block'. Raw Output: /home/runner/work/AnvilCraftMod/AnvilCraftMod/common/src/main/java/dev/dubhe/anvilcraft/api/hammer/HammerManager.java:6:1: warning: Wrong lexicographical order for 'java.util.Map' import. Should be before 'net.minecraft.world.level.block.Block'. (com.puppycrawl.tools.checkstyle.checks.imports.CustomImportOrderCheck)
import java.util.function.Supplier;

Check warning on line 7 in common/src/main/java/dev/dubhe/anvilcraft/api/hammer/HammerManager.java

View workflow job for this annotation

GitHub Actions / checkstyle

[Checkstyle] reported by reviewdog 🐶 Wrong lexicographical order for 'java.util.function.Supplier' import. Should be before 'net.minecraft.world.level.block.Block'. Raw Output: /home/runner/work/AnvilCraftMod/AnvilCraftMod/common/src/main/java/dev/dubhe/anvilcraft/api/hammer/HammerManager.java:7:1: warning: Wrong lexicographical order for 'java.util.function.Supplier' import. Should be before 'net.minecraft.world.level.block.Block'. (com.puppycrawl.tools.checkstyle.checks.imports.CustomImportOrderCheck)

@SuppressWarnings("unused")

Check warning on line 9 in common/src/main/java/dev/dubhe/anvilcraft/api/hammer/HammerManager.java

View workflow job for this annotation

GitHub Actions / checkstyle

[Checkstyle] reported by reviewdog 🐶 Missing a Javadoc comment. Raw Output: /home/runner/work/AnvilCraftMod/AnvilCraftMod/common/src/main/java/dev/dubhe/anvilcraft/api/hammer/HammerManager.java:9:1: warning: Missing a Javadoc comment. (com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocTypeCheck)
public class HammerManager {
private static final Map<Supplier<Block>, IHammerChangeable> INIT_CHANGE = new HashMap<>();
private static final Map<Block, IHammerChangeable> CHANGE = new HashMap<>();

public static void registerChange(Supplier<Block> block, IHammerChangeable changeable) {
HammerManager.INIT_CHANGE.put(block, changeable);
}

public static IHammerChangeable getChange(Block block) {
if (block instanceof IHammerChangeable changeable) return changeable;
return HammerManager.CHANGE.getOrDefault(block, IHammerChangeableBlock.EMPTY);
}

public static void register() {
for (Map.Entry<Supplier<Block>, IHammerChangeable> entry : INIT_CHANGE.entrySet()) {
HammerManager.CHANGE.put(entry.getKey().get(), entry.getValue());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package dev.dubhe.anvilcraft.api.hammer;

import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import org.jetbrains.annotations.NotNull;

@FunctionalInterface
public interface IHammerChangeable {
/**
* 改变状态
*
* @param player 玩家
* @param blockPos 坐标
* @param level 世界
* @param anvilHammer 铁砧锤物品
* @return 是否改变成功
*/
boolean change(Player player, BlockPos blockPos, @NotNull Level level, ItemStack anvilHammer);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package dev.dubhe.anvilcraft.api.hammer;

import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.block.state.properties.DirectionProperty;
import org.jetbrains.annotations.NotNull;

@SuppressWarnings("unused")

Check warning on line 13 in common/src/main/java/dev/dubhe/anvilcraft/api/hammer/IHammerChangeableBlock.java

View workflow job for this annotation

GitHub Actions / checkstyle

[Checkstyle] reported by reviewdog 🐶 Missing a Javadoc comment. Raw Output: /home/runner/work/AnvilCraftMod/AnvilCraftMod/common/src/main/java/dev/dubhe/anvilcraft/api/hammer/IHammerChangeableBlock.java:13:1: warning: Missing a Javadoc comment. (com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocTypeCheck)
public interface IHammerChangeableBlock extends IHammerChangeable {

Check warning on line 14 in common/src/main/java/dev/dubhe/anvilcraft/api/hammer/IHammerChangeableBlock.java

View workflow job for this annotation

GitHub Actions / checkstyle

[Checkstyle] reported by reviewdog 🐶 Abbreviation in name 'IHammerChangeableBlock' must contain no more than '1' consecutive capital letters. Raw Output: /home/runner/work/AnvilCraftMod/AnvilCraftMod/common/src/main/java/dev/dubhe/anvilcraft/api/hammer/IHammerChangeableBlock.java:14:18: warning: Abbreviation in name 'IHammerChangeableBlock' must contain no more than '1' consecutive capital letters. (com.puppycrawl.tools.checkstyle.checks.naming.AbbreviationAsWordInNameCheck)
DirectionProperty FACING_HOPPER = BlockStateProperties.FACING_HOPPER;
DirectionProperty FACING = BlockStateProperties.FACING;
DirectionProperty HORIZONTAL_FACING = BlockStateProperties.HORIZONTAL_FACING;
IHammerChangeableBlock DEFAULT = new IHammerChangeableBlock() {
};
IHammerChangeableBlock EMPTY = new IHammerChangeableBlock() {
public boolean change(Player player, BlockPos blockPos, @NotNull Level level, ItemStack anvilHammer) {

Check warning on line 21 in common/src/main/java/dev/dubhe/anvilcraft/api/hammer/IHammerChangeableBlock.java

View workflow job for this annotation

GitHub Actions / checkstyle

[Checkstyle] reported by reviewdog 🐶 Line is longer than 100 characters (found 110). Raw Output: /home/runner/work/AnvilCraftMod/AnvilCraftMod/common/src/main/java/dev/dubhe/anvilcraft/api/hammer/IHammerChangeableBlock.java:21:0: warning: Line is longer than 100 characters (found 110). (com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck)
return false;
}
};

@Override
default boolean change(Player player, BlockPos blockPos, @NotNull Level level, ItemStack anvilHammer) {

Check warning on line 27 in common/src/main/java/dev/dubhe/anvilcraft/api/hammer/IHammerChangeableBlock.java

View workflow job for this annotation

GitHub Actions / checkstyle

[Checkstyle] reported by reviewdog 🐶 Line is longer than 100 characters (found 107). Raw Output: /home/runner/work/AnvilCraftMod/AnvilCraftMod/common/src/main/java/dev/dubhe/anvilcraft/api/hammer/IHammerChangeableBlock.java:27:0: warning: Line is longer than 100 characters (found 107). (com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck)
BlockState state = level.getBlockState(blockPos);
if (state.hasProperty(FACING)) {
state = IHammerChangeableBlock.rotate(state);
} else if (state.hasProperty(FACING_HOPPER)) {
state = IHammerChangeableBlock.hopperRotate(state);
} else if (state.hasProperty(HORIZONTAL_FACING)) {
state = IHammerChangeableBlock.horizontalRotate(state);
}
level.setBlockAndUpdate(blockPos, state);
return true;
}

private static @NotNull BlockState rotate(@NotNull BlockState state) {
Direction direction = state.getValue(FACING);
return switch (direction) {
case WEST -> state.setValue(FACING, Direction.UP);
case UP -> state.setValue(FACING, Direction.DOWN);
case DOWN -> state.setValue(FACING, Direction.NORTH);
default -> state.setValue(FACING, direction.getClockWise());
};
}

private static @NotNull BlockState hopperRotate(@NotNull BlockState state) {
Direction direction = state.getValue(FACING_HOPPER);
return switch (direction) {
case WEST -> state.setValue(FACING_HOPPER, Direction.DOWN);
case DOWN -> state.setValue(FACING_HOPPER, Direction.NORTH);
default -> state.setValue(FACING_HOPPER, direction.getClockWise());
};
}

@SuppressWarnings("SameParameterValue")
private static @NotNull BlockState horizontalRotate(@NotNull BlockState state) {
return state.setValue(HORIZONTAL_FACING, state.getValue(HORIZONTAL_FACING).getClockWise());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package dev.dubhe.anvilcraft.api.hammer;

public interface IHammerRemovable {
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package dev.dubhe.anvilcraft.block;

import dev.dubhe.anvilcraft.api.depository.FilteredItemDepository;
import dev.dubhe.anvilcraft.api.hammer.IHammerChangeableBlock;
import dev.dubhe.anvilcraft.api.hammer.IHammerRemovable;
import dev.dubhe.anvilcraft.block.entity.AutoCrafterBlockEntity;
import dev.dubhe.anvilcraft.init.ModBlockEntities;
import dev.dubhe.anvilcraft.init.ModMenuTypes;
Expand Down Expand Up @@ -38,7 +40,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class AutoCrafterBlock extends BaseEntityBlock {
public class AutoCrafterBlock extends BaseEntityBlock implements IHammerChangeableBlock, IHammerRemovable {
public static final DirectionProperty FACING = DirectionalBlock.FACING;
public static final BooleanProperty LIT = RedstoneTorchBlock.LIT;

Expand Down
18 changes: 17 additions & 1 deletion common/src/main/java/dev/dubhe/anvilcraft/block/ChuteBlock.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package dev.dubhe.anvilcraft.block;

import dev.dubhe.anvilcraft.api.depository.FilteredItemDepository;
import dev.dubhe.anvilcraft.api.hammer.IHammerChangeableBlock;
import dev.dubhe.anvilcraft.api.hammer.IHammerRemovable;
import dev.dubhe.anvilcraft.block.entity.ChuteBlockEntity;
import dev.dubhe.anvilcraft.init.ModBlockEntities;
import dev.dubhe.anvilcraft.init.ModBlocks;
Expand Down Expand Up @@ -46,7 +48,7 @@
import javax.annotation.Nonnull;
import java.util.stream.Stream;

public class ChuteBlock extends BaseEntityBlock {
public class ChuteBlock extends BaseEntityBlock implements IHammerChangeableBlock, IHammerRemovable {
public static final DirectionProperty FACING = BlockStateProperties.FACING_HOPPER;
public static final BooleanProperty ENABLED = BlockStateProperties.ENABLED;

Expand Down Expand Up @@ -259,4 +261,18 @@ public static boolean hasChuteFacing(Level level, BlockPos pos) {
}
return false;
}

// @Override
// public boolean change(Player player, BlockPos pos, @NotNull Level level, ItemStack anvilHammer) {
// BlockState state = level.getBlockState(pos);
// BlockState facingState = level.getBlockState(pos.relative(state.getValue(FACING)));
// if (facingState.is(ModBlocks.CHUTE.get()) || facingState.is(ModBlocks.SIMPLE_CHUTE.get())) {
// if (facingState.getValue(FACING).getOpposite() == state.getValue(FACING)) {
// level.destroyBlock(pos, true);
// return true;
// }
// }
// IHammerChangeableBlock.DEFAULT.change(player, pos, level, anvilHammer);
// return true;
// }
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.dubhe.anvilcraft.block;

import dev.dubhe.anvilcraft.api.hammer.IHammerRemovable;
import dev.dubhe.anvilcraft.init.ModMenuTypes;
import dev.dubhe.anvilcraft.inventory.RoyalAnvilMenu;
import net.minecraft.core.BlockPos;
Expand Down Expand Up @@ -28,7 +29,7 @@

import javax.annotation.Nonnull;

public class RoyalAnvilBlock extends AnvilBlock {
public class RoyalAnvilBlock extends AnvilBlock implements IHammerRemovable {
private static final VoxelShape BASE = Block.box(2.0, 0.0, 2.0, 14.0, 4.0, 14.0);
private static final VoxelShape X_LEG1 = Block.box(4.0, 4.0, 5.0, 12.0, 10.0, 11.0);
private static final VoxelShape X_TOP = Block.box(0.0, 10.0, 3.0, 16.0, 16.0, 13.0);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.dubhe.anvilcraft.block;

import dev.dubhe.anvilcraft.api.hammer.IHammerRemovable;
import dev.dubhe.anvilcraft.init.ModMenuTypes;
import dev.dubhe.anvilcraft.inventory.RoyalGrindstoneMenu;
import net.minecraft.core.BlockPos;
Expand All @@ -18,7 +19,7 @@
import net.minecraft.world.phys.BlockHitResult;
import org.jetbrains.annotations.NotNull;

public class RoyalGrindstone extends GrindstoneBlock {
public class RoyalGrindstone extends GrindstoneBlock implements IHammerRemovable {

private static final Component CONTAINER_TITLE = Component.translatable("container.grindstone_title");

Expand All @@ -33,6 +34,7 @@ public RoyalGrindstone(Properties properties) {
player.awardStat(Stats.INTERACT_WITH_GRINDSTONE);
return InteractionResult.CONSUME;
}

@Override
public MenuProvider getMenuProvider(@NotNull BlockState state, @NotNull Level level, @NotNull BlockPos pos) {
return new SimpleMenuProvider((i, inventory, player) -> new RoyalGrindstoneMenu(i, inventory, ContainerLevelAccess.create(level, pos)), CONTAINER_TITLE);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.dubhe.anvilcraft.block;

import dev.dubhe.anvilcraft.api.hammer.IHammerRemovable;
import dev.dubhe.anvilcraft.init.ModMenuTypes;
import dev.dubhe.anvilcraft.inventory.RoyalSmithingMenu;
import net.minecraft.core.BlockPos;
Expand All @@ -18,7 +19,7 @@
import net.minecraft.world.phys.BlockHitResult;
import org.jetbrains.annotations.NotNull;

public class RoyalSmithingTableBlock extends SmithingTableBlock {
public class RoyalSmithingTableBlock extends SmithingTableBlock implements IHammerRemovable {
private static final Component CONTAINER_TITLE = Component.translatable("container.upgrade");

public RoyalSmithingTableBlock(Properties properties) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package dev.dubhe.anvilcraft.block;

import dev.dubhe.anvilcraft.api.depository.ItemDepository;
import dev.dubhe.anvilcraft.api.hammer.IHammerChangeable;
import dev.dubhe.anvilcraft.api.hammer.IHammerChangeableBlock;
import dev.dubhe.anvilcraft.api.hammer.IHammerRemovable;
import dev.dubhe.anvilcraft.block.entity.SimpleChuteBlockEntity;
import dev.dubhe.anvilcraft.init.ModBlockEntities;
import dev.dubhe.anvilcraft.init.ModBlocks;
Expand All @@ -9,6 +12,8 @@
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.RandomSource;
import net.minecraft.world.Containers;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.BaseEntityBlock;
Expand All @@ -35,7 +40,7 @@

import javax.annotation.Nonnull;

public class SimpleChuteBlock extends BaseEntityBlock implements SimpleWaterloggedBlock {
public class SimpleChuteBlock extends BaseEntityBlock implements SimpleWaterloggedBlock, IHammerChangeable, IHammerRemovable {
public static final DirectionProperty FACING = BlockStateProperties.FACING_HOPPER;
public static final BooleanProperty ENABLED = BlockStateProperties.ENABLED;
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
Expand Down Expand Up @@ -184,4 +189,18 @@ public int getAnalogOutputSignal(@NotNull BlockState blockState, @NotNull Level
public FluidState getFluidState(BlockState state) {
return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state);
}

@Override
public boolean change(Player player, BlockPos pos, @NotNull Level level, ItemStack anvilHammer) {
IHammerChangeableBlock.DEFAULT.change(player, pos, level, anvilHammer);
BlockState state = level.getBlockState(pos);
BlockState facingState = level.getBlockState(pos.relative(state.getValue(FACING)));
if (facingState.is(ModBlocks.CHUTE.get()) || facingState.is(ModBlocks.SIMPLE_CHUTE.get())) {
if (facingState.getValue(FACING).getOpposite() == state.getValue(FACING)) {
level.destroyBlock(pos, true);
return true;
}
}
return true;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.dubhe.anvilcraft.block;

import dev.dubhe.anvilcraft.api.hammer.IHammerRemovable;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.item.context.BlockPlaceContext;
Expand All @@ -19,7 +20,7 @@
import net.minecraft.world.phys.shapes.VoxelShape;
import org.jetbrains.annotations.NotNull;

public class StampingPlatformBlock extends Block implements SimpleWaterloggedBlock {
public class StampingPlatformBlock extends Block implements SimpleWaterloggedBlock, IHammerRemovable {
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
private static final VoxelShape REDUCE_AABB = Shapes.or(
Block.box(2.0, 12.0, 2.0, 14.0, 16.0, 14.0),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.tterrag.registrate.providers.RegistrateTagsProvider;
import dev.dubhe.anvilcraft.init.ModBlockTags;
import dev.dubhe.anvilcraft.init.ModBlocks;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import org.jetbrains.annotations.NotNull;
Expand All @@ -16,7 +15,13 @@ public static void init(@NotNull RegistrateTagsProvider<Block> provider) {
.add(Blocks.BROWN_MUSHROOM_BLOCK)
.add(Blocks.RED_MUSHROOM_BLOCK)
.add(Blocks.MUSHROOM_STEM);
provider.addTag(ModBlockTags.REMOVABLE).setReplace(false)
provider.addTag(ModBlockTags.HAMMER_CHANGEABLE).setReplace(false)
.add(Blocks.OBSERVER)
.add(Blocks.HOPPER)
.add(Blocks.DROPPER)
.add(Blocks.DISPENSER)
.add(Blocks.LIGHTNING_ROD);
provider.addTag(ModBlockTags.HAMMER_REMOVABLE).setReplace(false)
.add(Blocks.BELL)
.add(Blocks.REDSTONE_LAMP)
.add(Blocks.IRON_DOOR)
Expand Down Expand Up @@ -61,12 +66,6 @@ public static void init(@NotNull RegistrateTagsProvider<Block> provider) {
.add(Blocks.CAMPFIRE)
.add(Blocks.ANVIL)
.add(Blocks.CHIPPED_ANVIL)
.add(Blocks.DAMAGED_ANVIL)
.add(ModBlocks.ROYAL_SMITHING_TABLE.getId())
.add(ModBlocks.AUTO_CRAFTER.getId())
.add(ModBlocks.CHUTE.getId())
.add(ModBlocks.STAMPING_PLATFORM.getId())
.add(ModBlocks.ROYAL_ANVIL.getId())
.add(ModBlocks.ROYAL_GRINDSTONE.getId());
.add(Blocks.DAMAGED_ANVIL);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
import dev.dubhe.anvilcraft.api.event.SubscribeEvent;
import dev.dubhe.anvilcraft.api.event.server.ServerEndDataPackReloadEvent;
import dev.dubhe.anvilcraft.api.event.server.ServerStartedEvent;
import dev.dubhe.anvilcraft.api.hammer.HammerManager;
import dev.dubhe.anvilcraft.data.recipe.anvil.AnvilRecipe;
import dev.dubhe.anvilcraft.data.recipe.anvil.outcome.SpawnItem;
import dev.dubhe.anvilcraft.data.recipe.anvil.predicate.HasBlock;
import dev.dubhe.anvilcraft.data.recipe.anvil.predicate.HasItemIngredient;
import dev.dubhe.anvilcraft.init.ModHammerInits;
import net.minecraft.advancements.critereon.BlockPredicate;
import net.minecraft.core.NonNullList;
import net.minecraft.core.RegistryAccess;
Expand All @@ -36,6 +38,8 @@ public class ServerEventListener {
public void onServerStarted(@NotNull ServerStartedEvent event) {
MinecraftServer server = event.getServer();
ServerEventListener.processRecipes(server);
ModHammerInits.init();
HammerManager.register();
}

@SubscribeEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ public class ModBlockTags {
public static final TagKey<Block> REDSTONE_TORCH = bind("redstone_torch");
public static final TagKey<Block> MUSHROOM_BLOCK = bind("mushroom_block");
public static final TagKey<Block> CANT_BROKEN_ANVIL = bind("cant_broken_anvil");
public static final TagKey<Block> REMOVABLE = bind("removable");
public static final TagKey<Block> HAMMER_REMOVABLE = bind("hammer_removable");
public static final TagKey<Block> HAMMER_CHANGEABLE = bind("hammer_changeable");

private static @NotNull TagKey<Block> bindC(String id) {
return TagKey.create(Registries.BLOCK, new ResourceLocation("c", id));
Expand Down
16 changes: 16 additions & 0 deletions common/src/main/java/dev/dubhe/anvilcraft/init/ModHammerInits.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package dev.dubhe.anvilcraft.init;

import dev.dubhe.anvilcraft.api.hammer.HammerManager;
import dev.dubhe.anvilcraft.api.hammer.IHammerChangeableBlock;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.level.block.Block;

public class ModHammerInits {
@SuppressWarnings("deprecation")
public static void init() {
for (Block block : BuiltInRegistries.BLOCK) {
if (!block.builtInRegistryHolder().is(ModBlockTags.HAMMER_CHANGEABLE)) continue;
HammerManager.registerChange(() -> block, IHammerChangeableBlock.DEFAULT);
}
}
}
Loading

0 comments on commit 14aa4b8

Please sign in to comment.