use of com.cleanroommc.multiblocked.util.world.DummyWorld in project Multiblocked by CleanroomMC.
the class FluidMultiblockCapability method getCandidates.
@Override
public BlockInfo[] getCandidates() {
List<BlockInfo> list = new ArrayList<>();
DummyWorld dummyWorld = new DummyWorld();
for (Block block : ForgeRegistries.BLOCKS.getValuesCollection()) {
if (block.getRegistryName() != null) {
String path = block.getRegistryName().getPath();
if (path.contains("tank") || path.contains("fluid") || path.contains("liquid")) {
try {
if (block.hasTileEntity(block.getDefaultState())) {
TileEntity tileEntity = block.createTileEntity(dummyWorld, block.getDefaultState());
if (tileEntity != null && isBlockHasCapability(IO.BOTH, tileEntity)) {
list.add(new BlockInfo(block.getDefaultState(), tileEntity));
}
}
} catch (Throwable ignored) {
}
}
}
}
return list.toArray(new BlockInfo[0]);
}
use of com.cleanroommc.multiblocked.util.world.DummyWorld in project Multiblocked by CleanroomMC.
the class FEMultiblockCapability method getCandidates.
@Override
public BlockInfo[] getCandidates() {
List<BlockInfo> list = new ArrayList<>();
DummyWorld dummyWorld = new DummyWorld();
for (Block block : ForgeRegistries.BLOCKS.getValuesCollection()) {
if (block.getRegistryName() != null) {
String path = block.getRegistryName().getPath();
if (path.contains("energy") || path.contains("rf")) {
try {
if (block.hasTileEntity(block.getDefaultState())) {
TileEntity tileEntity = block.createTileEntity(dummyWorld, block.getDefaultState());
if (tileEntity != null && isBlockHasCapability(IO.BOTH, tileEntity)) {
list.add(new BlockInfo(block.getDefaultState(), tileEntity));
}
}
} catch (Throwable ignored) {
}
}
}
}
return list.toArray(new BlockInfo[0]);
}
use of com.cleanroommc.multiblocked.util.world.DummyWorld in project Multiblocked by CleanroomMC.
the class MultiblockWorldSavedData method getOrCreate.
public static MultiblockWorldSavedData getOrCreate(World world) {
if (world == null || world instanceof DummyWorld) {
return DUMMY;
}
MapStorage perWorldStorage = world.getPerWorldStorage();
String name = getName(world);
worldRef = new WeakReference<>(world);
MultiblockWorldSavedData mbwsd = (MultiblockWorldSavedData) perWorldStorage.getOrLoadData(MultiblockWorldSavedData.class, name);
worldRef = null;
if (mbwsd == null) {
perWorldStorage.setData(name, mbwsd = new MultiblockWorldSavedData(name));
}
return mbwsd;
}
Aggregations