diff options
| author | 2024-01-10 00:26:04 +0100 | |
|---|---|---|
| committer | 2024-01-10 00:26:04 +0100 | |
| commit | 982f0bbbd7564b6f292a0890dd862149d9f710a9 (patch) | |
| tree | 30875caa478390a6c30096e17b4e0c8133a3cf88 /src/main/java/lv/enes/mc/eris_alchemy/block/entity | |
| parent | Make Alchemical Chest waterloggable. (diff) | |
| download | mc-eris-alchemy-982f0bbbd7564b6f292a0890dd862149d9f710a9.tar.gz mc-eris-alchemy-982f0bbbd7564b6f292a0890dd862149d9f710a9.tar.xz mc-eris-alchemy-982f0bbbd7564b6f292a0890dd862149d9f710a9.zip | |
Some refactoring
Diffstat (limited to 'src/main/java/lv/enes/mc/eris_alchemy/block/entity')
| -rw-r--r-- | src/main/java/lv/enes/mc/eris_alchemy/block/entity/AlchemicalChestBlockEntity.java | 14 | ||||
| -rw-r--r-- | src/main/java/lv/enes/mc/eris_alchemy/block/entity/ErisAlchemyBlockEntities.java | 33 |
2 files changed, 10 insertions, 37 deletions
diff --git a/src/main/java/lv/enes/mc/eris_alchemy/block/entity/AlchemicalChestBlockEntity.java b/src/main/java/lv/enes/mc/eris_alchemy/block/entity/AlchemicalChestBlockEntity.java index 9c9942f..1e881f8 100644 --- a/src/main/java/lv/enes/mc/eris_alchemy/block/entity/AlchemicalChestBlockEntity.java +++ b/src/main/java/lv/enes/mc/eris_alchemy/block/entity/AlchemicalChestBlockEntity.java | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | package lv.enes.mc.eris_alchemy.block.entity; | 1 | package lv.enes.mc.eris_alchemy.block.entity; |
| 2 | 2 | ||
| 3 | import jakarta.annotation.Nonnull; | 3 | import jakarta.annotation.Nonnull; |
| 4 | import lv.enes.mc.eris_alchemy.block.ErisAlchemyBlocks; | 4 | import lv.enes.mc.eris_alchemy.ErisAlchemyRegistry; |
| 5 | import lv.enes.mc.eris_alchemy.menu.AlchemicalChestMenu; | 5 | import lv.enes.mc.eris_alchemy.menu.AlchemicalChestMenu; |
| 6 | import net.minecraft.core.BlockPos; | 6 | import net.minecraft.core.BlockPos; |
| 7 | import net.minecraft.core.NonNullList; | 7 | import net.minecraft.core.NonNullList; |
| @@ -62,8 +62,14 @@ public class AlchemicalChestBlockEntity extends BaseContainerBlockEntity impleme | |||
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | @Override | 64 | @Override |
| 65 | protected void openerCountChanged(Level world, BlockPos pos, BlockState state, int oldViewerCount, int newViewerCount) { | 65 | protected void openerCountChanged( |
| 66 | world.blockEvent(worldPosition, ErisAlchemyBlocks.ALCHEMICAL_CHEST, EVENT, newViewerCount); | 66 | Level world, |
| 67 | BlockPos pos, | ||
| 68 | BlockState state, | ||
| 69 | int oldViewerCount, | ||
| 70 | int newViewerCount | ||
| 71 | ) { | ||
| 72 | world.blockEvent(worldPosition, ErisAlchemyRegistry.Blocks.ALCHEMICAL_CHEST, EVENT, newViewerCount); | ||
| 67 | } | 73 | } |
| 68 | 74 | ||
| 69 | @Override | 75 | @Override |
| @@ -76,7 +82,7 @@ public class AlchemicalChestBlockEntity extends BaseContainerBlockEntity impleme | |||
| 76 | }; | 82 | }; |
| 77 | 83 | ||
| 78 | public AlchemicalChestBlockEntity(BlockPos pos, BlockState state) { | 84 | public AlchemicalChestBlockEntity(BlockPos pos, BlockState state) { |
| 79 | super(ErisAlchemyBlockEntities.ALCHEMICAL_CHEST, pos, state); | 85 | super(ErisAlchemyRegistry.BlockEntities.ALCHEMICAL_CHEST, pos, state); |
| 80 | } | 86 | } |
| 81 | 87 | ||
| 82 | @Override | 88 | @Override |
diff --git a/src/main/java/lv/enes/mc/eris_alchemy/block/entity/ErisAlchemyBlockEntities.java b/src/main/java/lv/enes/mc/eris_alchemy/block/entity/ErisAlchemyBlockEntities.java deleted file mode 100644 index a95ac58..0000000 --- a/src/main/java/lv/enes/mc/eris_alchemy/block/entity/ErisAlchemyBlockEntities.java +++ /dev/null | |||
| @@ -1,33 +0,0 @@ | |||
| 1 | package lv.enes.mc.eris_alchemy.block.entity; | ||
| 2 | |||
| 3 | import lv.enes.mc.eris_alchemy.ErisAlchemy; | ||
| 4 | import lv.enes.mc.eris_alchemy.block.ErisAlchemyBlocks; | ||
| 5 | import net.minecraft.resources.ResourceLocation; | ||
| 6 | import net.minecraft.world.level.block.entity.BlockEntity; | ||
| 7 | import net.minecraft.world.level.block.entity.BlockEntityType; | ||
| 8 | import org.quiltmc.qsl.block.entity.api.QuiltBlockEntityTypeBuilder; | ||
| 9 | |||
| 10 | import java.util.LinkedHashMap; | ||
| 11 | import java.util.Map; | ||
| 12 | import java.util.function.BiConsumer; | ||
| 13 | |||
| 14 | public final class ErisAlchemyBlockEntities { | ||
| 15 | private static final Map<ResourceLocation, BlockEntityType<?>> entities = new LinkedHashMap<>(); | ||
| 16 | |||
| 17 | public static final BlockEntityType<AlchemicalChestBlockEntity> ALCHEMICAL_CHEST = register( | ||
| 18 | "alchemical_chest", | ||
| 19 | QuiltBlockEntityTypeBuilder.create(AlchemicalChestBlockEntity::new, ErisAlchemyBlocks.ALCHEMICAL_CHEST) | ||
| 20 | .build() | ||
| 21 | ); | ||
| 22 | |||
| 23 | public static void consumeBlockEntities(BiConsumer<? super ResourceLocation, ? super BlockEntityType<?>> consumer) { | ||
| 24 | entities.forEach(consumer); | ||
| 25 | } | ||
| 26 | |||
| 27 | private static <T extends BlockEntity> BlockEntityType<T> register(String id, BlockEntityType<T> type) { | ||
| 28 | entities.putIfAbsent(new ResourceLocation(ErisAlchemy.ID, id), type); | ||
| 29 | return type; | ||
| 30 | } | ||
| 31 | |||
| 32 | private ErisAlchemyBlockEntities() {} | ||
| 33 | } | ||