Inspired by 2020's April Fools' 20w14infinite Snapshot, this mod brings endless randomly generated dimensions into Minecraft.
1package net.lerariemann.infinity.block.entity;
2
3import net.lerariemann.infinity.registry.core.ModBlockEntities;
4import net.minecraft.core.BlockPos;
5import net.minecraft.core.HolderLookup;
6import net.minecraft.nbt.CompoundTag;
7import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
8import net.minecraft.world.level.Level;
9import net.minecraft.world.level.block.entity.BlockEntity;
10import net.minecraft.world.level.block.state.BlockState;
11//? if >1.21.4 {
12import net.minecraft.world.level.storage.ValueInput;
13import net.minecraft.world.level.storage.ValueOutput;
14//?}
15import org.jetbrains.annotations.Nullable;
16
17/// This will be used later for player-performed invocations such as creating new biomes, but for now is kinda deprecated
18public class CosmicAltarBlockEntity extends BlockEntity {
19 public CosmicAltarBlockEntity(BlockPos pos, BlockState state) {
20 super(ModBlockEntities.COSMIC_ALTAR.get(), pos, state);
21 }
22
23 //? if >1.21 {
24 @Override
25 public boolean isValidBlockState(BlockState state) {
26 return true;
27 }
28 //?}
29
30 @Deprecated
31 public static void serverTick(Level world, BlockPos pos, BlockState state, CosmicAltarBlockEntity be) {
32 }
33
34 //? if >1.21 {
35 @Override
36 public void loadAdditional(
37 //? if >1.21.2 {
38 ValueInput nbt
39 //?} else {
40 /*CompoundTag nbt
41 *///?}
42 //? if =1.21.1
43 /*,HolderLookup.Provider registryLookup*/
44 ) {
45 super.loadAdditional(nbt
46 //? if =1.21.1
47 /*, registryLookup*/
48 );
49 }
50 //?} else {
51 /*@Override
52 public void load(CompoundTag tag) {
53 super.load(tag);
54 }
55 *///?}
56
57 @Override
58 protected void saveAdditional(
59 //? if =1.21.1 || 1.20.1 {
60 /*CompoundTag nbt
61 *///?} else {
62 ValueOutput nbt
63 //?}
64 //? if =1.21.1
65 /*, HolderLookup.Provider registryLookup*/
66 ) {
67 super.saveAdditional(nbt
68 //? if =1.21.1
69 /*, registryLookup*/
70 );
71 }
72
73 @Nullable
74 @Override
75 public ClientboundBlockEntityDataPacket getUpdatePacket() {
76 return ClientboundBlockEntityDataPacket.create(this);
77 }
78
79 @Override
80 public CompoundTag getUpdateTag(
81 //? if >1.21
82 HolderLookup.Provider registryLookup
83 ) {
84 return saveWithoutMetadata(
85 //? if >1.21
86 registryLookup
87 );
88 }
89}