2020-01-22 01:32:26 +01:00
|
|
|
package de.ellpeck.naturesaura.reg;
|
|
|
|
|
2021-12-04 15:40:09 +01:00
|
|
|
import net.minecraft.world.level.block.Block;
|
|
|
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
|
|
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
2020-01-22 01:32:26 +01:00
|
|
|
|
2020-10-19 03:05:13 +02:00
|
|
|
import java.util.Arrays;
|
2020-01-22 01:32:26 +01:00
|
|
|
|
2021-12-04 15:40:09 +01:00
|
|
|
public class ModTileType<T extends BlockEntity> implements IModItem {
|
2020-01-22 01:32:26 +01:00
|
|
|
|
2021-12-04 15:40:09 +01:00
|
|
|
public final BlockEntityType<T> type;
|
2020-01-22 01:32:26 +01:00
|
|
|
public final String name;
|
|
|
|
|
2021-12-04 15:40:09 +01:00
|
|
|
public ModTileType(BlockEntityType.BlockEntitySupplier<T> supplier, IModItem item) {
|
2020-10-19 03:05:13 +02:00
|
|
|
this(supplier, item.getBaseName(), item);
|
|
|
|
}
|
|
|
|
|
2021-12-04 15:40:09 +01:00
|
|
|
public ModTileType(BlockEntityType.BlockEntitySupplier<T> supplier, String name, IModItem... items) {
|
2020-10-19 03:05:13 +02:00
|
|
|
this.name = name;
|
2021-12-15 16:30:22 +01:00
|
|
|
var blocks = Arrays.stream(items).map(i -> (Block) i).toArray(Block[]::new);
|
2021-12-04 15:40:09 +01:00
|
|
|
this.type = BlockEntityType.Builder.of(supplier, blocks).build(null);
|
2020-01-22 01:32:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getBaseName() {
|
|
|
|
return this.name;
|
|
|
|
}
|
|
|
|
}
|