Skip to content

Commit

Permalink
Expose block entity creation
Browse files Browse the repository at this point in the history
  • Loading branch information
UnRealDinnerbone committed Dec 11, 2024
1 parent 561dd6e commit cdd282f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
### 21.4.2
### 21.4.3

- Pass ResourceKey for creation of new items
- Expose Block Entity creation for common api
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;

import java.util.List;
import java.util.Set;
Expand All @@ -38,12 +40,26 @@ public static void addItemsToCreateTab(ResourceKey<CreativeModeTab> tabResourceK
Services.PLATFORM.addItemToCreativeTab(tabResourceKey, item);
}

@Deprecated(forRemoval = true)
@ApiStatus.ScheduledForRemoval(inVersion = "22.0.0")
public static <T extends BlockEntity> BlockEntityType<T> createBlockEntityType(BlockEntityType.BlockEntitySupplier<T> creator, Block... validBlocks) {
return new BlockEntityType<>(creator, Set.of(validBlocks));
}

public static <T extends BlockEntity> BlockEntityType<T> createBEType(BESuppler<T> creator, Block... validBlocks) {
return new BlockEntityType<>(creator, Set.of(validBlocks));
}

public static <T extends AbstractContainerMenu> MenuType<T> createMenuType(BiFunction<Integer, Inventory, T> supplier) {
return new MenuType<>(supplier::apply, FeatureFlagSet.of());
}


public interface BESuppler<T extends BlockEntity> extends BlockEntityType.BlockEntitySupplier<T> {

@Override
@NotNull
T create(BlockPos blockPos, BlockState blockState);
}

}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Project
mod_version=21.4.2
mod_version=21.4.3
maven_group=com.unrealdinnerbone
mod_name=Trenzalore
mod_author=UnRealDinnerbone
Expand Down

0 comments on commit cdd282f

Please sign in to comment.