summaryrefslogtreecommitdiff
path: root/src/main/java/lv/enes/mc/eris_alchemy/block/entity
diff options
context:
space:
mode:
authorGravatar Uko Kokņevičs2024-01-10 00:26:04 +0100
committerGravatar Uko Kokņevičs2024-01-10 00:26:04 +0100
commit982f0bbbd7564b6f292a0890dd862149d9f710a9 (patch)
tree30875caa478390a6c30096e17b4e0c8133a3cf88 /src/main/java/lv/enes/mc/eris_alchemy/block/entity
parentMake Alchemical Chest waterloggable. (diff)
downloadmc-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.java14
-rw-r--r--src/main/java/lv/enes/mc/eris_alchemy/block/entity/ErisAlchemyBlockEntities.java33
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 @@
1package lv.enes.mc.eris_alchemy.block.entity; 1package lv.enes.mc.eris_alchemy.block.entity;
2 2
3import jakarta.annotation.Nonnull; 3import jakarta.annotation.Nonnull;
4import lv.enes.mc.eris_alchemy.block.ErisAlchemyBlocks; 4import lv.enes.mc.eris_alchemy.ErisAlchemyRegistry;
5import lv.enes.mc.eris_alchemy.menu.AlchemicalChestMenu; 5import lv.enes.mc.eris_alchemy.menu.AlchemicalChestMenu;
6import net.minecraft.core.BlockPos; 6import net.minecraft.core.BlockPos;
7import net.minecraft.core.NonNullList; 7import 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 @@
1package lv.enes.mc.eris_alchemy.block.entity;
2
3import lv.enes.mc.eris_alchemy.ErisAlchemy;
4import lv.enes.mc.eris_alchemy.block.ErisAlchemyBlocks;
5import net.minecraft.resources.ResourceLocation;
6import net.minecraft.world.level.block.entity.BlockEntity;
7import net.minecraft.world.level.block.entity.BlockEntityType;
8import org.quiltmc.qsl.block.entity.api.QuiltBlockEntityTypeBuilder;
9
10import java.util.LinkedHashMap;
11import java.util.Map;
12import java.util.function.BiConsumer;
13
14public 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}