Search in sources :

Example 1 with DummyWorld

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]);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) DummyWorld(com.cleanroommc.multiblocked.util.world.DummyWorld) BlockInfo(com.cleanroommc.multiblocked.api.pattern.util.BlockInfo) ArrayList(java.util.ArrayList) Block(net.minecraft.block.Block)

Example 2 with DummyWorld

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]);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) DummyWorld(com.cleanroommc.multiblocked.util.world.DummyWorld) BlockInfo(com.cleanroommc.multiblocked.api.pattern.util.BlockInfo) ArrayList(java.util.ArrayList) Block(net.minecraft.block.Block)

Example 3 with DummyWorld

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;
}
Also used : DummyWorld(com.cleanroommc.multiblocked.util.world.DummyWorld) MapStorage(net.minecraft.world.storage.MapStorage)

Aggregations

DummyWorld (com.cleanroommc.multiblocked.util.world.DummyWorld)3 BlockInfo (com.cleanroommc.multiblocked.api.pattern.util.BlockInfo)2 ArrayList (java.util.ArrayList)2 Block (net.minecraft.block.Block)2 TileEntity (net.minecraft.tileentity.TileEntity)2 MapStorage (net.minecraft.world.storage.MapStorage)1