Search in sources :

Example 1 with ControllerTileTesterEntity

use of com.lowdragmc.multiblocked.api.tile.ControllerTileTesterEntity in project Multiblocked by Low-Drag-MC.

the class PredicateComponent method buildPredicate.

@Override
public SimplePredicate buildPredicate() {
    predicate = state -> {
        TileEntity tileEntity = state.getTileEntity();
        if (tileEntity instanceof IComponent) {
            return ((IComponent) tileEntity).getDefinition().location.equals(location);
        }
        return false;
    };
    candidates = () -> {
        if (MbdComponents.COMPONENT_BLOCKS_REGISTRY.containsKey(location)) {
            return new BlockInfo[] { new BlockInfo(MbdComponents.COMPONENT_BLOCKS_REGISTRY.get(location).defaultBlockState(), MbdComponents.DEFINITION_REGISTRY.get(location).createNewTileEntity()) };
        } else {
            if (definition == null)
                return new BlockInfo[0];
            if (definition instanceof ControllerDefinition) {
                ControllerTileTesterEntity te = new ControllerTileTesterEntity(ControllerTileTesterEntity.DEFAULT_DEFINITION);
                te.setDefinition((ControllerDefinition) definition);
                return new BlockInfo[] { new BlockInfo(MbdComponents.COMPONENT_BLOCKS_REGISTRY.get(ControllerTileTesterEntity.DEFAULT_DEFINITION.location).defaultBlockState(), te) };
            } else {
                DummyComponentTileEntity te = new DummyComponentTileEntity(MbdComponents.DummyComponentBlock.definition);
                te.setDefinition(definition);
                return new BlockInfo[] { new BlockInfo(MbdComponents.DummyComponentBlock.defaultBlockState(), te) };
            }
        }
    };
    return this;
}
Also used : DummyComponentTileEntity(com.lowdragmc.multiblocked.api.tile.DummyComponentTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) ControllerDefinition(com.lowdragmc.multiblocked.api.definition.ControllerDefinition) IComponent(com.lowdragmc.multiblocked.api.tile.IComponent) BlockInfo(com.lowdragmc.lowdraglib.utils.BlockInfo) ControllerTileTesterEntity(com.lowdragmc.multiblocked.api.tile.ControllerTileTesterEntity) DummyComponentTileEntity(com.lowdragmc.multiblocked.api.tile.DummyComponentTileEntity)

Aggregations

BlockInfo (com.lowdragmc.lowdraglib.utils.BlockInfo)1 ControllerDefinition (com.lowdragmc.multiblocked.api.definition.ControllerDefinition)1 ControllerTileTesterEntity (com.lowdragmc.multiblocked.api.tile.ControllerTileTesterEntity)1 DummyComponentTileEntity (com.lowdragmc.multiblocked.api.tile.DummyComponentTileEntity)1 IComponent (com.lowdragmc.multiblocked.api.tile.IComponent)1 TileEntity (net.minecraft.tileentity.TileEntity)1