diff options
| author | 2024-01-18 00:20:47 +0200 | |
|---|---|---|
| committer | 2024-01-18 00:20:47 +0200 | |
| commit | c458a42575d51169d20d7171dcaadd8504356b53 (patch) | |
| tree | 0d5661f644b127c55e1d19ebda03713d0ea4bebf /src/main/java/lv/enes/mc/eris_alchemy/block | |
| parent | Actually sync from server to client (diff) | |
| download | mc-eris-alchemy-c458a42575d51169d20d7171dcaadd8504356b53.tar.gz mc-eris-alchemy-c458a42575d51169d20d7171dcaadd8504356b53.tar.xz mc-eris-alchemy-c458a42575d51169d20d7171dcaadd8504356b53.zip | |
Fix a dedicated server crash
Diffstat (limited to 'src/main/java/lv/enes/mc/eris_alchemy/block')
3 files changed, 25 insertions, 9 deletions
diff --git a/src/main/java/lv/enes/mc/eris_alchemy/block/entity/AlchemicalChestEntity.java b/src/main/java/lv/enes/mc/eris_alchemy/block/entity/AlchemicalChestEntity.java index 659e4b1..4fff3fa 100644 --- a/src/main/java/lv/enes/mc/eris_alchemy/block/entity/AlchemicalChestEntity.java +++ b/src/main/java/lv/enes/mc/eris_alchemy/block/entity/AlchemicalChestEntity.java | |||
| @@ -3,15 +3,17 @@ package lv.enes.mc.eris_alchemy.block.entity; | |||
| 3 | import jakarta.annotation.Nonnull; | 3 | import jakarta.annotation.Nonnull; |
| 4 | import lv.enes.mc.eris_alchemy.ErisAlchemyRegistry.BlockEntities; | 4 | import lv.enes.mc.eris_alchemy.ErisAlchemyRegistry.BlockEntities; |
| 5 | import lv.enes.mc.eris_alchemy.ErisAlchemyRegistry.Blocks; | 5 | import lv.enes.mc.eris_alchemy.ErisAlchemyRegistry.Blocks; |
| 6 | import lv.enes.mc.eris_alchemy.ErisAlchemyRegistry.Materials; | 6 | import lv.enes.mc.eris_alchemy.client.ErisAlchemyClientRegistry.Materials; |
| 7 | import lv.enes.mc.eris_alchemy.menu.AlchemicalChestMenu; | 7 | import lv.enes.mc.eris_alchemy.menu.AlchemicalChestMenu; |
| 8 | import lv.enes.mc.eris_alchemy.menu.ChestLikeMenu; | 8 | import lv.enes.mc.eris_alchemy.menu.ChestLikeMenu; |
| 9 | import net.minecraft.client.resources.model.Material; | ||
| 9 | import net.minecraft.core.BlockPos; | 10 | import net.minecraft.core.BlockPos; |
| 10 | import net.minecraft.core.NonNullList; | 11 | import net.minecraft.core.NonNullList; |
| 11 | import net.minecraft.world.entity.player.Inventory; | 12 | import net.minecraft.world.entity.player.Inventory; |
| 12 | import net.minecraft.world.item.ItemStack; | 13 | import net.minecraft.world.item.ItemStack; |
| 13 | import net.minecraft.world.level.block.Block; | 14 | import net.minecraft.world.level.block.Block; |
| 14 | import net.minecraft.world.level.block.state.BlockState; | 15 | import net.minecraft.world.level.block.state.BlockState; |
| 16 | import org.quiltmc.loader.api.minecraft.ClientOnly; | ||
| 15 | 17 | ||
| 16 | public class AlchemicalChestEntity extends ChestLikeEntity { | 18 | public class AlchemicalChestEntity extends ChestLikeEntity { |
| 17 | private final static int WIDTH = 13; | 19 | private final static int WIDTH = 13; |
| @@ -20,7 +22,7 @@ public class AlchemicalChestEntity extends ChestLikeEntity { | |||
| 20 | private final NonNullList<ItemStack> items = NonNullList.withSize(WIDTH * HEIGHT, ItemStack.EMPTY); | 22 | private final NonNullList<ItemStack> items = NonNullList.withSize(WIDTH * HEIGHT, ItemStack.EMPTY); |
| 21 | 23 | ||
| 22 | public AlchemicalChestEntity(BlockPos pos, BlockState state) { | 24 | public AlchemicalChestEntity(BlockPos pos, BlockState state) { |
| 23 | super(BlockEntities.ALCHEMICAL_CHEST, pos, state, Materials.ALCHEMICAL_CHEST); | 25 | super(BlockEntities.ALCHEMICAL_CHEST, pos, state); |
| 24 | } | 26 | } |
| 25 | 27 | ||
| 26 | @Nonnull | 28 | @Nonnull |
| @@ -35,6 +37,12 @@ public class AlchemicalChestEntity extends ChestLikeEntity { | |||
| 35 | return items; | 37 | return items; |
| 36 | } | 38 | } |
| 37 | 39 | ||
| 40 | @ClientOnly | ||
| 41 | @Nonnull | ||
| 42 | public Material getMaterial() { | ||
| 43 | return Materials.ALCHEMICAL_CHEST; | ||
| 44 | } | ||
| 45 | |||
| 38 | @Nonnull | 46 | @Nonnull |
| 39 | @Override | 47 | @Override |
| 40 | protected Block getParent() { | 48 | protected Block getParent() { |
diff --git a/src/main/java/lv/enes/mc/eris_alchemy/block/entity/ChestLikeEntity.java b/src/main/java/lv/enes/mc/eris_alchemy/block/entity/ChestLikeEntity.java index 8f40d26..09aecc7 100644 --- a/src/main/java/lv/enes/mc/eris_alchemy/block/entity/ChestLikeEntity.java +++ b/src/main/java/lv/enes/mc/eris_alchemy/block/entity/ChestLikeEntity.java | |||
| @@ -18,12 +18,11 @@ import net.minecraft.world.level.Level; | |||
| 18 | import net.minecraft.world.level.block.Block; | 18 | import net.minecraft.world.level.block.Block; |
| 19 | import net.minecraft.world.level.block.entity.*; | 19 | import net.minecraft.world.level.block.entity.*; |
| 20 | import net.minecraft.world.level.block.state.BlockState; | 20 | import net.minecraft.world.level.block.state.BlockState; |
| 21 | import org.quiltmc.loader.api.minecraft.ClientOnly; | ||
| 21 | 22 | ||
| 22 | public abstract class ChestLikeEntity extends BaseContainerBlockEntity implements LidBlockEntity { | 23 | public abstract class ChestLikeEntity extends BaseContainerBlockEntity implements LidBlockEntity { |
| 23 | protected static final int EVENT_INTERACTED = 1; | 24 | protected static final int EVENT_INTERACTED = 1; |
| 24 | 25 | ||
| 25 | public final Material material; | ||
| 26 | |||
| 27 | protected final ChestLidController lidController = new ChestLidController(); | 26 | protected final ChestLidController lidController = new ChestLidController(); |
| 28 | protected final ContainerOpenersCounter openersCounter = new ContainerOpenersCounter() { | 27 | protected final ContainerOpenersCounter openersCounter = new ContainerOpenersCounter() { |
| 29 | @Override | 28 | @Override |
| @@ -53,16 +52,17 @@ public abstract class ChestLikeEntity extends BaseContainerBlockEntity implement | |||
| 53 | public ChestLikeEntity( | 52 | public ChestLikeEntity( |
| 54 | BlockEntityType<? extends ChestLikeEntity> type, | 53 | BlockEntityType<? extends ChestLikeEntity> type, |
| 55 | BlockPos pos, | 54 | BlockPos pos, |
| 56 | BlockState state, | 55 | BlockState state |
| 57 | Material material | ||
| 58 | ) { | 56 | ) { |
| 59 | super(type, pos, state); | 57 | super(type, pos, state); |
| 60 | this.material = material; | ||
| 61 | } | 58 | } |
| 62 | 59 | ||
| 63 | 60 | ||
| 64 | @Nonnull | 61 | @Nonnull |
| 65 | protected abstract NonNullList<ItemStack> getItems(); | 62 | protected abstract NonNullList<ItemStack> getItems(); |
| 63 | @ClientOnly | ||
| 64 | @Nonnull | ||
| 65 | public abstract Material getMaterial(); | ||
| 66 | @Nonnull | 66 | @Nonnull |
| 67 | protected abstract Block getParent(); | 67 | protected abstract Block getParent(); |
| 68 | 68 | ||
diff --git a/src/main/java/lv/enes/mc/eris_alchemy/block/entity/EnergyCondenserEntity.java b/src/main/java/lv/enes/mc/eris_alchemy/block/entity/EnergyCondenserEntity.java index 432ba6f..33a6250 100644 --- a/src/main/java/lv/enes/mc/eris_alchemy/block/entity/EnergyCondenserEntity.java +++ b/src/main/java/lv/enes/mc/eris_alchemy/block/entity/EnergyCondenserEntity.java | |||
| @@ -4,12 +4,13 @@ import jakarta.annotation.Nonnull; | |||
| 4 | import lv.enes.mc.eris_alchemy.Emc; | 4 | import lv.enes.mc.eris_alchemy.Emc; |
| 5 | import lv.enes.mc.eris_alchemy.ErisAlchemyRegistry.BlockEntities; | 5 | import lv.enes.mc.eris_alchemy.ErisAlchemyRegistry.BlockEntities; |
| 6 | import lv.enes.mc.eris_alchemy.ErisAlchemyRegistry.Blocks; | 6 | import lv.enes.mc.eris_alchemy.ErisAlchemyRegistry.Blocks; |
| 7 | import lv.enes.mc.eris_alchemy.ErisAlchemyRegistry.Materials; | 7 | import lv.enes.mc.eris_alchemy.client.ErisAlchemyClientRegistry; |
| 8 | import lv.enes.mc.eris_alchemy.menu.ChestLikeMenu; | 8 | import lv.enes.mc.eris_alchemy.menu.ChestLikeMenu; |
| 9 | import lv.enes.mc.eris_alchemy.menu.EnergyCondenserMenu; | 9 | import lv.enes.mc.eris_alchemy.menu.EnergyCondenserMenu; |
| 10 | import lv.enes.mc.eris_alchemy.utils.ContainerOpenersCounterUtil; | 10 | import lv.enes.mc.eris_alchemy.utils.ContainerOpenersCounterUtil; |
| 11 | import lv.enes.mc.eris_alchemy.utils.SyncedValue.SyncedDouble; | 11 | import lv.enes.mc.eris_alchemy.utils.SyncedValue.SyncedDouble; |
| 12 | import net.fabricmc.fabric.api.screenhandler.v1.ExtendedScreenHandlerFactory; | 12 | import net.fabricmc.fabric.api.screenhandler.v1.ExtendedScreenHandlerFactory; |
| 13 | import net.minecraft.client.resources.model.Material; | ||
| 13 | import net.minecraft.core.BlockPos; | 14 | import net.minecraft.core.BlockPos; |
| 14 | import net.minecraft.core.NonNullList; | 15 | import net.minecraft.core.NonNullList; |
| 15 | import net.minecraft.nbt.CompoundTag; | 16 | import net.minecraft.nbt.CompoundTag; |
| @@ -20,6 +21,7 @@ import net.minecraft.world.item.ItemStack; | |||
| 20 | import net.minecraft.world.level.Level; | 21 | import net.minecraft.world.level.Level; |
| 21 | import net.minecraft.world.level.block.Block; | 22 | import net.minecraft.world.level.block.Block; |
| 22 | import net.minecraft.world.level.block.state.BlockState; | 23 | import net.minecraft.world.level.block.state.BlockState; |
| 24 | import org.quiltmc.loader.api.minecraft.ClientOnly; | ||
| 23 | 25 | ||
| 24 | import java.util.stream.IntStream; | 26 | import java.util.stream.IntStream; |
| 25 | 27 | ||
| @@ -32,7 +34,7 @@ public class EnergyCondenserEntity extends ChestLikeEntity implements ExtendedSc | |||
| 32 | public final SyncedDouble storedEmc = new SyncedDouble(0); | 34 | public final SyncedDouble storedEmc = new SyncedDouble(0); |
| 33 | 35 | ||
| 34 | public EnergyCondenserEntity(BlockPos pos, BlockState state) { | 36 | public EnergyCondenserEntity(BlockPos pos, BlockState state) { |
| 35 | super(BlockEntities.ENERGY_CONDENSER, pos, state, Materials.ENERGY_CONDENSER); | 37 | super(BlockEntities.ENERGY_CONDENSER, pos, state); |
| 36 | } | 38 | } |
| 37 | 39 | ||
| 38 | @Nonnull | 40 | @Nonnull |
| @@ -47,6 +49,12 @@ public class EnergyCondenserEntity extends ChestLikeEntity implements ExtendedSc | |||
| 47 | return items; | 49 | return items; |
| 48 | } | 50 | } |
| 49 | 51 | ||
| 52 | @ClientOnly | ||
| 53 | @Nonnull | ||
| 54 | public Material getMaterial() { | ||
| 55 | return ErisAlchemyClientRegistry.Materials.ENERGY_CONDENSER; | ||
| 56 | } | ||
| 57 | |||
| 50 | @Nonnull | 58 | @Nonnull |
| 51 | @Override | 59 | @Override |
| 52 | protected Block getParent() { | 60 | protected Block getParent() { |